[crac] RFR: Fix ordering of invocation on Resources

Radim Vansa duke at openjdk.org
Mon Apr 24 07:06:15 UTC 2023


On Fri, 21 Apr 2023 15:24:41 GMT, Anton Kozlov <akozlov at openjdk.org> wrote:

>> * When Context.beforeCheckpoint throws, invoke Context.afterRestore anyway (otherwise some resources stay in suspended state).
>> * Handle Resource.beforeCheckpoint triggering a registration of another resource ** Do not cause deadlock when registering from another thread ** Global resource can register JDKResource
>> ** JDKResource can register resource with higher priority ** Other registrations are prohibited
>
> src/java.base/share/classes/jdk/crac/Resource.java line 41:
> 
>> 39:      * Invoked by a {@code Context} as a notification about checkpoint.
>> 40:      * Order of checkpoint notification is the reverse order of
>> 41:      * {@link Context#register(Resource) registration}.
> 
> This is correct for the Global Context, but the order can be different in other Contexts.
> 
> I don't think Resource javadoc should describe the ordering (otherwise, a Context that uses a different ordering should refuse registration, but the Context does not have any mean to know the resource assumes some particular ordering).

Alright, I think that the order for the global context is rather hidden in the `package-info.java`. So, I'll add a note here that the order is defined by the context, and move this info to `Core.getGlobalContext` javadoc.

Can we say that the fact that afterRestore is called in an inverse order to beforeCheckpoint is an universal rule, or would you keep that specific to context impl?

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

PR Review Comment: https://git.openjdk.org/crac/pull/60#discussion_r1174864397


More information about the crac-dev mailing list