Skip to content

Commit

Permalink
Fix primary term in testAddOrRenewRetentionLease (#38239)
Browse files Browse the repository at this point in the history
We should increase primary term before renewing leases; otherwise, the
term of the latest RetentionLeases will be lower than the current term.

Relates #37951
  • Loading branch information
dnhatn authored Feb 2, 2019
1 parent 1ec04df commit 80d3092
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@

public class ReplicationTrackerRetentionLeaseTests extends ReplicationTrackerTestCase {

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/pull/38239")
public void testAddOrRenewRetentionLease() {
final AllocationId allocationId = AllocationId.newInitializing();
long primaryTerm = randomLongBetween(1, Long.MAX_VALUE);
Expand Down Expand Up @@ -83,12 +82,12 @@ public void testAddOrRenewRetentionLease() {
}

for (int i = 0; i < length; i++) {
minimumRetainingSequenceNumbers[i] = randomLongBetween(minimumRetainingSequenceNumbers[i], Long.MAX_VALUE);
replicationTracker.renewRetentionLease(Integer.toString(i), minimumRetainingSequenceNumbers[i], "test-" + i);
if (rarely() && primaryTerm < Long.MAX_VALUE) {
primaryTerm = randomLongBetween(primaryTerm + 1, Long.MAX_VALUE);
replicationTracker.setOperationPrimaryTerm(primaryTerm);
}
minimumRetainingSequenceNumbers[i] = randomLongBetween(minimumRetainingSequenceNumbers[i], Long.MAX_VALUE);
replicationTracker.renewRetentionLease(Integer.toString(i), minimumRetainingSequenceNumbers[i], "test-" + i);
assertRetentionLeases(replicationTracker, length, minimumRetainingSequenceNumbers, () -> 0L, primaryTerm, 1 + length + i, true);
}
}
Expand Down

0 comments on commit 80d3092

Please sign in to comment.