Skip to content

Commit

Permalink
[Java] Read high-water mark position after computing the rebuild posi…
Browse files Browse the repository at this point in the history
…tion to ensure the widest possible loss detection scan window.

Loss detection code is concurrent to the application threads that are consuming from the image but also to the receiver thread that inserts new packets into the image and advances the high-water mark position counter. Reading that counter last ensures that we take into account all inserted packets up to this point.
  • Loading branch information
vyazelenko committed Jan 24, 2025
1 parent 192989e commit 60e6047
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,6 @@ int trackRebuild(final long nowNs)

if (isRebuilding)
{
final long hwmPosition = this.hwmPosition.getVolatile();
long minSubscriberPosition = Long.MAX_VALUE;
long maxSubscriberPosition = 0;

Expand All @@ -552,6 +551,7 @@ int trackRebuild(final long nowNs)
}

final long rebuildPosition = Math.max(this.rebuildPosition.get(), maxSubscriberPosition);
final long hwmPosition = this.hwmPosition.getVolatile();
final long scanOutcome = lossDetector.scan(
termBuffers[indexByPosition(rebuildPosition, positionBitsToShift)],
rebuildPosition,
Expand Down

0 comments on commit 60e6047

Please sign in to comment.