[crac] RFR: CRaC may exit before image dump is completed [v2]
Anton Kozlov
akozlov at openjdk.org
Tue Feb 28 17:43:35 UTC 2023
On Wed, 22 Feb 2023 13:21:35 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..
>
> Roman Marchenko has updated the pull request incrementally with one additional commit since the last revision:
>
> Added sighandler to the main process
Changes requested by akozlov (Lead).
src/java.base/share/native/launcher/main.c line 118:
> 116: pid = wait(&st);
> 117: if (!status && 0 < pid && WIFEXITED(st)) {
> 118: status = WEXITSTATUS(st);
Some `WEXITSTATUS(st)` can end up 0, so the a next exited child can override this status.
I think here we should watch for the status of the g_child_pid, and ignoring statuses of other childs that are not our immediate java process child.
-------------
PR: https://git.openjdk.org/crac/pull/46
More information about the crac-dev
mailing list