Unable to create snapshots with Java modules

Nikola Grcevski grcevski at gmail.com
Mon Nov 28 22:04:42 UTC 2022


Hello crac-dev,

I've been experimenting with the latest CRaC JDK17 build in the
hopes that I can get it to run with Elasticsearch, at least a very
early checkpoint before we open any sockets or files. However, I
noticed that modules loaded remain open at runtime and the
snapshot creation always fails.

I created a small Java example to try it out:

public class SimpleModule {
    public static void main(String[] args)
        throws RestoreException, CheckpointException {
        Core.checkpointRestore();
        System.out.println("Hello modules!");
    }
}

module simplemodule {
    exports co.elastic.simple;
}

When I run snapshot create and then restore with Java classpath,
everything works as expected:

~/work/simplemodule$ /<path>/openjdk-17-crac+3_linux-x64/bin/java -cp
lib/simplemodule-1.0-SNAPSHOT.jar -XX:CRaCCheckpointTo=/tmp/simple
co.elastic.simple.SimpleModule
CR: Checkpoint ...
Killed
~/work/simplemodule$ /<path>/openjdk-17-crac+3_linux-x64/bin/java -cp
lib/simplemodule-1.0-SNAPSHOT.jar -XX:CRaCRestoreFrom=/tmp/simple
Hello modules!

However, if I try the same thing with the modules usage, the snapshot
creation fails:

~/work/simplemodule$ /<path>/openjdk-17-crac+3_linux-x64/bin/java
-XX:CRaCCheckpointTo=/tmp/simple --module-path lib --module
simplemodule/co.elastic.simple.SimpleModule
Exception in thread "main" jdk.crac.CheckpointException
at java.base/jdk.crac.Core.checkpointRestore1(Core.java:138)
at java.base/jdk.crac.Core.checkpointRestore(Core.java:237)
at simplemodule/co.elastic.simple.SimpleModule.main(SimpleModule.java:9)
Suppressed: jdk.crac.impl.CheckpointOpenFileException:
/<snip>/work/simplemodule/target/simplemodule-1.0-SNAPSHOT.jar
at java.base/jdk.crac.Core.translateJVMExceptions(Core.java:84)
at java.base/jdk.crac.Core.checkpointRestore1(Core.java:142)
... 2 more

If I check the open file descriptors, the simplemodule-1.0-SNAPSHOT.jar is open
regardless of modules or not.

I'd appreciate any pointers or suggestions where to look next or if
there's a workaround I can use.

Thanks,
Nikola


More information about the crac-dev mailing list