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:
parent
f9c15d0fec
commit
e827d2ed92
|
@ -1187,13 +1187,13 @@ public class IndexShardTests extends IndexShardTestCase {
|
||||||
indexShard.updateGlobalCheckpointOnReplica(globalCheckpointOnReplica, "test");
|
indexShard.updateGlobalCheckpointOnReplica(globalCheckpointOnReplica, "test");
|
||||||
|
|
||||||
final long globalCheckpoint = randomLongBetween(UNASSIGNED_SEQ_NO, indexShard.getLocalCheckpoint());
|
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 Set<String> docsBeforeRollback = getShardDocUIDs(indexShard);
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
randomReplicaOperationPermitAcquisition(indexShard,
|
randomReplicaOperationPermitAcquisition(indexShard,
|
||||||
indexShard.getPendingPrimaryTerm() + 1,
|
indexShard.getPendingPrimaryTerm() + 1,
|
||||||
globalCheckpoint,
|
globalCheckpoint,
|
||||||
maxSeqNoOfUpdatesOrDeletes,
|
randomLongBetween(SequenceNumbers.NO_OPS_PERFORMED, maxSeqNo),
|
||||||
new ActionListener<Releasable>() {
|
new ActionListener<Releasable>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Releasable releasable) {
|
public void onResponse(Releasable releasable) {
|
||||||
|
@ -1208,7 +1208,11 @@ public class IndexShardTests extends IndexShardTestCase {
|
||||||
}, "");
|
}, "");
|
||||||
|
|
||||||
latch.await();
|
latch.await();
|
||||||
|
if (globalCheckpoint < maxSeqNo) {
|
||||||
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(maxSeqNo));
|
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(maxSeqNo));
|
||||||
|
} else {
|
||||||
|
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(maxSeqNoOfUpdatesOrDeletesBeforeRollback));
|
||||||
|
}
|
||||||
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(
|
||||||
|
@ -1222,7 +1226,11 @@ 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 (globalCheckpoint < maxSeqNo) {
|
||||||
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(maxSeqNo));
|
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(maxSeqNo));
|
||||||
|
} else {
|
||||||
|
assertThat(indexShard.getMaxSeqNoOfUpdatesOrDeletes(), equalTo(maxSeqNoOfUpdatesOrDeletesBeforeRollback));
|
||||||
|
}
|
||||||
closeShard(indexShard, false);
|
closeShard(indexShard, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue