[crac] RFR: Fix ordering of invocation on Resources [v3]

Radim Vansa duke at openjdk.org
Thu May 4 07:24:42 UTC 2023


On Fri, 28 Apr 2023 11:57:03 GMT, Anton Kozlov <akozlov at openjdk.org> wrote:

>> Radim Vansa has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - More fine-grained synchronization
>>  - Rework context ordering (round 2)
>>    
>>    * call afterRestore even if beforeCheckpoint throws
>>    * registering resource in previous/running context does not trigger exception immediatelly
>>    ** instead this will be one of the recorded exceptions and the resource has a chance to fire next time
>>    * we don't guarantee threads not deadlocking when trying to register a resource, though
>
> src/java.base/share/classes/jdk/crac/impl/AbstractContextImpl.java line 75:
> 
>> 73:         restoreQ = new ArrayList<>();
>> 74:         runBeforeCheckpoint();
>> 75:         Collections.reverse(restoreQ);
> 
> Smelly code, restoreQ should be maintained either here or in runBeforeCheckpoint()

Not really; the task of ACI subclass (OC, PC...) is to call `invokeBeforeCheckpoint` on some resources (ACI does not know which ones) in some order. The task of ACI is to remember the order of invocations and in `afterRestore` call this in a reversed order; the subclass does not need to know about any collection used for that.

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

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


More information about the crac-dev mailing list