TEST: Only check max_seq_no_of_updates when rollback (#35170)
Currently, we assume that rollback always happens in the test testRestoreLocalHistoryFromTranslogOnPromotion. However, if the global checkpoint equals max_seq_no, we won't rollback. This causes the max_seq_no_of_updates assertion failed because max_seq_no_of_updates won't be advanced to the global checkpoint. With this commit, we assert max_seq_no_of_updates in two different paths.
This commit is contained in:
parent
9b3d581339
commit
d6e44129b1
|
@ -928,6 +928,7 @@ public class IndexShardTests extends IndexShardTestCase {
|
||||||
final long maxSeqNoOfUpdatesOrDeletes = randomLongBetween(SequenceNumbers.NO_OPS_PERFORMED, maxSeqNo);
|
final long maxSeqNoOfUpdatesOrDeletes = randomLongBetween(SequenceNumbers.NO_OPS_PERFORMED, maxSeqNo);
|
||||||
final Set<String> docsBeforeRollback = getShardDocUIDs(indexShard);
|
final Set<String> docsBeforeRollback = getShardDocUIDs(indexShard);
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
final boolean shouldRollback = Math.max(globalCheckpointOnReplica, globalCheckpoint) < maxSeqNo;
|
||||||
indexShard.acquireReplicaOperationPermit(
|
indexShard.acquireReplicaOperationPermit(
|
||||||
indexShard.getPendingPrimaryTerm() + 1,
|
indexShard.getPendingPrimaryTerm() + 1,
|
||||||
globalCheckpoint,
|
globalCheckpoint,
|
||||||
|
@ -947,10 +948,13 @@ public class IndexShardTests extends IndexShardTestCase {
|
||||||
ThreadPool.Names.SAME, "");
|
ThreadPool.Names.SAME, "");
|
||||||
|
|
||||||
latch.await();
|
latch.await();
|
||||||
|
if (shouldRollback) {
|
||||||
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(Collections.max(
|
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(Collections.max(
|
||||||
Arrays.asList(maxSeqNoOfUpdatesOrDeletes, globalCheckpoint, globalCheckpointOnReplica))
|
Arrays.asList(maxSeqNoOfUpdatesOrDeletes, globalCheckpoint, globalCheckpointOnReplica))
|
||||||
));
|
));
|
||||||
|
} else {
|
||||||
|
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(Math.max(maxSeqNoOfUpdatesOrDeletes, currentMaxSeqNoOfUpdates)));
|
||||||
|
}
|
||||||
final ShardRouting newRouting = indexShard.routingEntry().moveActiveReplicaToPrimary();
|
final ShardRouting newRouting = indexShard.routingEntry().moveActiveReplicaToPrimary();
|
||||||
final CountDownLatch resyncLatch = new CountDownLatch(1);
|
final CountDownLatch resyncLatch = new CountDownLatch(1);
|
||||||
indexShard.updateShardState(
|
indexShard.updateShardState(
|
||||||
|
@ -965,9 +969,13 @@ public class IndexShardTests extends IndexShardTestCase {
|
||||||
assertThat(indexShard.getLocalCheckpoint(), equalTo(maxSeqNo));
|
assertThat(indexShard.getLocalCheckpoint(), equalTo(maxSeqNo));
|
||||||
assertThat(indexShard.seqNoStats().getMaxSeqNo(), equalTo(maxSeqNo));
|
assertThat(indexShard.seqNoStats().getMaxSeqNo(), equalTo(maxSeqNo));
|
||||||
assertThat(getShardDocUIDs(indexShard), equalTo(docsBeforeRollback));
|
assertThat(getShardDocUIDs(indexShard), equalTo(docsBeforeRollback));
|
||||||
|
if (shouldRollback) {
|
||||||
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(Collections.max(
|
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(Collections.max(
|
||||||
Arrays.asList(currentMaxSeqNoOfUpdates, maxSeqNoOfUpdatesOrDeletes, globalCheckpoint, globalCheckpointOnReplica))
|
Arrays.asList(currentMaxSeqNoOfUpdates, maxSeqNoOfUpdatesOrDeletes, globalCheckpoint, globalCheckpointOnReplica))
|
||||||
));
|
));
|
||||||
|
} else {
|
||||||
|
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(Math.max(currentMaxSeqNoOfUpdates, maxSeqNoOfUpdatesOrDeletes)));
|
||||||
|
}
|
||||||
closeShard(indexShard, false);
|
closeShard(indexShard, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue