[crac] RFR: Fix ordering of invocation on Resources [v2]
Anton Kozlov
akozlov at openjdk.org
Tue Apr 25 13:53:39 UTC 2023
On Tue, 25 Apr 2023 11:54:32 GMT, Radim Vansa <duke at openjdk.org> wrote:
>> I figured out there is another problem with allowing the registration and failing afterwards: let's assume that you have two children contexts, C1 and C2. C1.beforeCheckpoint succeeds, and during C2.beforeCheckpoint you try to register something on C1. You suggest to allow this, but C1 won't be invoked and we cannot find that there's a new resource that should have failed the checkpoint - so it's kind of silently failing. The best you could do is to invoke the beforeCheckpoint on the resource when you find C1 to be done, but this is not what we discussed before.
>
> Thinking about this again, the current code does not prevent that from happening either, had JDK context registered something new in the global context this would be silently ignored.
> I can imagine that Core could keep a checkpoint counter and the Context would record last finished counter. During registration, if the current counter equals finished counter the registration could throw. However if we're to rollback the checkpoint, we would probably need to set a global flag in Core, too.
Yes, the current implementation allows new Resources registered during notification and silently ignored. I hope this change will deal with the problem somehow.
> The best you could do is to invoke the beforeCheckpoint on the resource when you find C1 to be done, but this is not what we discussed before.
This is an interesting approach, but this won't suit e.g. Global Context, as last registered Resource would need to be notified first. If notification is in progress, we've lost our chance.
But I assume some Context implementation may opt to this, so we need to leave some room in the spec to allow such implementations.
-------------
PR Review Comment: https://git.openjdk.org/crac/pull/60#discussion_r1176549896
More information about the crac-dev
mailing list