Fix testRestoreLocalHistoryFromTranslogOnPromotion (#58745)

If the global checkpoint equals max_seq_no, then we won't reset an engine 
(as all operations are safe), and max_seqno_of_updates_or_deletes 
won't advance to max_seq_no.

Closes #58163
This commit is contained in:
Nhat Nguyen 2020-07-02 10:03:03 -04:00
parent f9c15d0fec
commit e827d2ed92
1 changed files with 12 additions and 4 deletions

View File

@ -1187,13 +1187,13 @@ public class IndexShardTests extends IndexShardTestCase {
indexShard.updateGlobalCheckpointOnReplica(globalCheckpointOnReplica, "test");
final long globalCheckpoint = randomLongBetween(UNASSIGNED_SEQ_NO, indexShard.getLocalCheckpoint());
final long maxSeqNoOfUpdatesOrDeletes = randomLongBetween(SequenceNumbers.NO_OPS_PERFORMED, maxSeqNo);
final long maxSeqNoOfUpdatesOrDeletesBeforeRollback = indexShard.getMaxSeqNoOfUpdatesOrDeletes();
final Set<String> docsBeforeRollback = getShardDocUIDs(indexShard);
final CountDownLatch latch = new CountDownLatch(1);
randomReplicaOperationPermitAcquisition(indexShard,
indexShard.getPendingPrimaryTerm() + 1,
globalCheckpoint,
maxSeqNoOfUpdatesOrDeletes,
randomLongBetween(SequenceNumbers.NO_OPS_PERFORMED, maxSeqNo),
new ActionListener<Releasable>() {
@Override
public void onResponse(Releasable releasable) {
@ -1208,7 +1208,11 @@ public class IndexShardTests extends IndexShardTestCase {
}, "");
latch.await();
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(maxSeqNo));
if (globalCheckpoint < maxSeqNo) {
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(maxSeqNo));
} else {
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(maxSeqNoOfUpdatesOrDeletesBeforeRollback));
}
final ShardRouting newRouting = indexShard.routingEntry().moveActiveReplicaToPrimary();
final CountDownLatch resyncLatch = new CountDownLatch(1);
indexShard.updateShardState(
@ -1222,7 +1226,11 @@ public class IndexShardTests extends IndexShardTestCase {
assertThat(indexShard.getLocalCheckpoint(), equalTo(maxSeqNo));
assertThat(indexShard.seqNoStats().getMaxSeqNo(), equalTo(maxSeqNo));
assertThat(getShardDocUIDs(indexShard), equalTo(docsBeforeRollback));
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(maxSeqNo));
if (globalCheckpoint < maxSeqNo) {
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(maxSeqNo));
} else {
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(maxSeqNoOfUpdatesOrDeletesBeforeRollback));
}
closeShard(indexShard, false);
}