Skip to content

Commit

Permalink
Fix isAheadOf logic for ReplicationCheckpoint comparison (#4112)
Browse files Browse the repository at this point in the history
Signed-off-by: Suraj Singh <[email protected]>
  • Loading branch information
dreamer-89 authored Aug 3, 2022
1 parent 3ab0d1f commit 7af8e37
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 7af8e37

Please sign in to comment.