Skip to content

Commit

Permalink
Update isAheadOf logic to compare PrimaryTerms when segmentInfosVersi…
Browse files Browse the repository at this point in the history
…ons are equal

Signed-off-by: Suraj Singh <surajrider@gmail.com>
  • Loading branch information
dreamer-89 committed Aug 3, 2022
1 parent 6f23300 commit c992024
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,13 @@ public int hashCode() {
}

/**
* Checks if other is aheadof current replication point by comparing segmentInfosVersion. Returns true for null
* Checks if current replication checkpoint is AheadOf `other` replication checkpoint point by first comparing
* primaryTerm followed by segmentInfosVersion. Returns true when `other` is null.
*/
public boolean isAheadOf(@Nullable ReplicationCheckpoint other) {
return other == null || segmentInfosVersion > other.getSegmentInfosVersion() || primaryTerm > other.getPrimaryTerm();
return other == null
|| primaryTerm > other.getPrimaryTerm()
|| (primaryTerm == other.getPrimaryTerm() && segmentInfosVersion > other.getSegmentInfosVersion());
}

@Override
Expand Down

0 comments on commit c992024

Please sign in to comment.