Skip to content

Feature Request: Checkpoint with open file descriptors by non-JDK APIs #17

@LarsGjesse-Zoetis

Description

@LarsGjesse-Zoetis

The motivation for this request is a use case where an agent is attached to the JVM.
When an agent is attached, the JVM holds an open file descriptor to the agent JAR. This causes an exception when creating a checkpoint:

...

2023-11-07T12:38:55.452+01:00 WARN 115571 --- [ main] jdk.crac : File agent.jar was not closed by the application.
2023-11-07T12:38:55.527+01:00 WARN 115571 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to take CRaC checkpoint on refresh
2023-11-07T12:38:55.636+01:00 ERROR 115571 --- [ main] o.s.boot.SpringApplication : Application run failed

org.springframework.context.ApplicationContextException: Failed to take CRaC checkpoint on refresh
at org.springframework.context.support.DefaultLifecycleProcessor$CracDelegate.checkpointRestore(DefaultLifecycleProcessor.java:521) ~[spring-context-6.1.0-SNAPSHOT.jar!/:6.1.0-SNAPSHOT]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:183) ~[spring-context-6.1.0-SNAPSHOT.jar!/:6.1.0-SNAPSHOT]

...

Caused by: org.crac.CheckpointException: null
at org.crac.Core$Compat.checkpointRestore(Core.java:144) ~[crac-1.4.0.jar!/:na]
at org.crac.Core.checkpointRestore(Core.java:237) ~[crac-1.4.0.jar!/:na]
at org.springframework.context.support.DefaultLifecycleProcessor$CracDelegate.checkpointRestore(DefaultLifecycleProcessor.java:515) ~[spring-context-6.1.0-SNAPSHOT.jar!/:6.1.0-SNAPSHOT]
... 17 common frames omitted
Suppressed: jdk.internal.crac.mirror.impl.CheckpointOpenFileException: FD fd=15 type=regular path=agent.jar
at java.base/jdk.internal.crac.mirror.Core.translateJVMExceptions(Core.java:114) ~[na:na]
...
... 19 common frames omitted

The file descriptor policies feature doesn't help here, because the file does not appear to be opened through a JDK API.
I investigated if the agent JAR could be loaded from a memory file system, like https://github.com/marschall/memoryfilesystem. But as far as I can see, an agent JAR can only be specified via a path to the default filesystem.
The underlying CRIU library does allow a checkpoint to be created with open FDs for several types of descriptors, including normal files.

Would it be possible to extend file descriptor policies to FDs not opened through a JDK API?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions