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

Roman Marchenko rmarchenko at openjdk.org
Wed Mar 15 14:18:58 UTC 2023


On Tue, 21 Feb 2023 13:50:23 GMT, Roman Marchenko <rmarchenko at openjdk.org> wrote:

> 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..

This pull request has now been integrated.

Changeset: a11b46a0
Author:    Roman Marchenko <rmarchenko at openjdk.org>
Committer: Anton Kozlov <akozlov at openjdk.org>
URL:       https://git.openjdk.org/crac/commit/a11b46a0f135d522f701d7fbf8833e7670198a19
Stats:     76 lines in 1 file changed: 76 ins; 0 del; 0 mod

CRaC may exit before image dump is completed

Reviewed-by: akozlov

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

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


More information about the crac-dev mailing list