Skip to content

Commit 5a4e397

Browse files
committed
TEST: Adjust rollback condition when shard is empty
If a shard is empty, it won't rollback its engine on promotion. This commit adjusts the expectation in the rollback test. Relates #33473
1 parent b0587bc commit 5a4e397

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,8 @@ public void testRollbackReplicaEngineOnPromotion() throws IOException, Interrupt
962962
Set<String> docsBelowGlobalCheckpoint = getShardDocUIDs(indexShard).stream()
963963
.filter(id -> Long.parseLong(id) <= Math.max(globalCheckpointOnReplica, globalCheckpoint)).collect(Collectors.toSet());
964964
final CountDownLatch latch = new CountDownLatch(1);
965-
final boolean shouldRollback = Math.max(globalCheckpoint, globalCheckpointOnReplica) < indexShard.seqNoStats().getMaxSeqNo();
965+
final boolean shouldRollback = Math.max(globalCheckpoint, globalCheckpointOnReplica) < indexShard.seqNoStats().getMaxSeqNo()
966+
&& indexShard.seqNoStats().getMaxSeqNo() != SequenceNumbers.NO_OPS_PERFORMED;
966967
final Engine beforeRollbackEngine = indexShard.getEngine();
967968
indexShard.acquireReplicaOperationPermit(
968969
indexShard.pendingPrimaryTerm + 1,

0 commit comments

Comments
 (0)