[crac] RFR: CRaC may exit before image dump is completed [v3]

Roman Marchenko rmarchenko at openjdk.org
Wed Mar 1 16:10:49 UTC 2023


> When running CRaC with docker, java may exit before CRIU is finished dumpring because CRIU kills the original java process, and then docker immediately exits.
> 
> It could be reproduced with a simple Java test:
> 
> public class Test {
>     public static void main(String args[]) throws Exception {
>         jdk.crac.Core.checkpointRestore();
>         System.out.println("finish");
>     }
> }
> 
> and run with docker:
> `docker <docker_options> $JAVA_HOME/java -XX:CRaCCheckpointTo=./cr Test.java`
> 
> After the command above finishes, `cr/cppath` is absent in the case of failure. Or/and it will fail on restore:
> `docker <docker_options> $JAVA_HOME/java -XX:CRaCRestoreFrom=./cr`
> 
> This change fixes the issue by forkin'g the main process in case of PID=1 (pid=1 means it was run with docker), and waiting for children processes are finished. This makes us sure that CRIU finalized the dump, if any. At the same time, there is no conflict with PIDs on restore, since the process being restored has PID not equal to 1, if restoring with the command above..

Roman Marchenko has updated the pull request incrementally with one additional commit since the last revision:

  Returning status of the child only

-------------

Changes:
  - all: https://git.openjdk.org/crac/pull/46/files
  - new: https://git.openjdk.org/crac/pull/46/files/fd074cfc..a0a78087

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=crac&pr=46&range=02
 - incr: https://webrevs.openjdk.org/?repo=crac&pr=46&range=01-02

  Stats: 5 lines in 1 file changed: 2 ins; 2 del; 1 mod
  Patch: https://git.openjdk.org/crac/pull/46.diff
  Fetch: git fetch https://git.openjdk.org/crac pull/46/head:pull/46

PR: https://git.openjdk.org/crac/pull/46


More information about the crac-dev mailing list