Skip to content

Commit

Permalink
Fix isAheadOf logic for ReplicationCheckpoint comparison (opensearch-…
Browse files Browse the repository at this point in the history
…project#4112)

Signed-off-by: Suraj Singh <surajrider@gmail.com>
  • Loading branch information
dreamer-89 authored and Rishikesh1159 committed Aug 17, 2022
1 parent e6acd60 commit a9a7369
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 a9a7369

Please sign in to comment.