Skip to content

[#3773]: phase 1 Make ClaimTask, SplitTask and MergeTask fully async#4530

Open
laura-devriendt-lemon wants to merge 1 commit intoenhancement/3773/replace-joinunwrap-pooled-processorfrom
enhancement/3773/fase1-tasks-async
Open

[#3773]: phase 1 Make ClaimTask, SplitTask and MergeTask fully async#4530
laura-devriendt-lemon wants to merge 1 commit intoenhancement/3773/replace-joinunwrap-pooled-processorfrom
enhancement/3773/fase1-tasks-async

Conversation

@laura-devriendt-lemon
Copy link
Copy Markdown

Removes all joinAndUnwrap calls from ClaimTask, SplitTask and MergeTask. Each task's internal logic is now a proper async chain — no coordinator threads are blocked waiting on token store operations.

Key changes:

  • ClaimTask: two sequential UoW calls chained with thenCompose; fetchToken failure caught via exceptionally returning false (preserving original try/catch behavior)
  • SplitTask: splitAndRelease(Segment) changed from boolean to CompletableFuture; callers updated from thenApply to thenCompose to avoid unwaited nested futures; try/finally replaced with whenComplete to guarantee deadline cleanup on both success and failure
  • MergeTask: two sequential segment fetches chained with thenCompose; thenCombine(...).thenCompose(f -> f) keeps parallel token fetching while flattening the nested future; mergeSegments now returns CompletableFuture with whenComplete for deadline cleanup

Adds ClaimTaskTest covering all four scenarios: segment already active, segment not in available list, successful claim, and failed claim (returns false as normal completion, not exceptional).

Extends MergeTaskTest with a missing branch: merge initiated from the higher-ID segment, verifying the lower-ID segment token is always placed first in MergedTrackingToken regardless of which segment triggered the merge.

Removes all joinAndUnwrap calls from ClaimTask, SplitTask and MergeTask.
Each task's internal logic is now a proper async chain — no coordinator
threads are blocked waiting on token store operations.

Key changes:
- ClaimTask: two sequential UoW calls chained with thenCompose; fetchToken
  failure caught via exceptionally returning false (preserving original
  try/catch behavior)
- SplitTask: splitAndRelease(Segment) changed from boolean to
  CompletableFuture<Boolean>; callers updated from thenApply to thenCompose
  to avoid unwaited nested futures; try/finally replaced with whenComplete
  to guarantee deadline cleanup on both success and failure
- MergeTask: two sequential segment fetches chained with thenCompose;
  thenCombine(...).thenCompose(f -> f) keeps parallel token fetching while
  flattening the nested future; mergeSegments now returns
  CompletableFuture<Boolean> with whenComplete for deadline cleanup

Adds ClaimTaskTest covering all four scenarios: segment already active,
segment not in available list, successful claim, and failed claim (returns
false as normal completion, not exceptional).

Extends MergeTaskTest with a missing branch: merge initiated from the
higher-ID segment, verifying the lower-ID segment token is always placed
first in MergedTrackingToken regardless of which segment triggered the merge.

Refs #3773
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 5, 2026

@laura-devriendt-lemon laura-devriendt-lemon added Type: Enhancement Use to signal an issue enhances an already existing feature of the project. Priority 1: Must Highest priority. A release cannot be made if this issue isn’t resolved. labels May 5, 2026
@laura-devriendt-lemon laura-devriendt-lemon changed the title #3773: Make ClaimTask, SplitTask and MergeTask fully async [#3773]: phase 1 Make ClaimTask, SplitTask and MergeTask fully async May 5, 2026
@laura-devriendt-lemon laura-devriendt-lemon self-assigned this May 5, 2026
@laura-devriendt-lemon laura-devriendt-lemon added this to the Release 5.2.0 milestone May 5, 2026
@laura-devriendt-lemon laura-devriendt-lemon marked this pull request as ready for review May 6, 2026 08:08
@laura-devriendt-lemon laura-devriendt-lemon requested a review from a team as a code owner May 6, 2026 08:08
@laura-devriendt-lemon laura-devriendt-lemon requested review from MateuszNaKodach, hatzlj and hjohn and removed request for a team May 6, 2026 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority 1: Must Highest priority. A release cannot be made if this issue isn’t resolved. Type: Enhancement Use to signal an issue enhances an already existing feature of the project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant