Skip to content

Commit 5643435

Browse files
Fixes testSnapshotShutdownProgressTracker (#134926)
Reorders the test to avoid a race condition due to one snapshot thread becoming blocked Resolves: 134620
1 parent 5cfe5b8 commit 5643435

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,6 @@ tests:
492492
- class: org.elasticsearch.xpack.esql.ccq.MultiClusterSpecIT
493493
method: test {csv-spec:fork.FiveFork}
494494
issue: https://github.com/elastic/elasticsearch/issues/134560
495-
- class: org.elasticsearch.snapshots.SnapshotShutdownIT
496-
method: testSnapshotShutdownProgressTracker
497-
issue: https://github.com/elastic/elasticsearch/issues/134620
498495
- class: org.elasticsearch.xpack.esql.ccq.MultiClusterSpecIT
499496
method: test {csv-spec:spatial.ConvertCartesianFromStringParseError}
500497
issue: https://github.com/elastic/elasticsearch/issues/134635

server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotShutdownIT.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ public void testSnapshotShutdownProgressTracker() throws Exception {
483483
final var otherNode = internalCluster().startDataOnlyNode();
484484
final var otherIndex = randomIdentifier();
485485
createIndexWithContent(otherIndex, indexSettings(numShards, 0).put(REQUIRE_NODE_NAME_SETTING, otherNode).build());
486+
indexAllShardsToAnEqualOrGreaterMinimumSize(otherIndex, ByteSizeValue.of(2, ByteSizeUnit.KB).getBytes());
486487
blockDataNode(repoName, otherNode);
487488

488489
final var nodeForRemoval = internalCluster().startDataOnlyNode(
@@ -493,6 +494,7 @@ public void testSnapshotShutdownProgressTracker() throws Exception {
493494
final var indexName = randomIdentifier();
494495
createIndexWithContent(indexName, indexSettings(numShards, 0).put(REQUIRE_NODE_NAME_SETTING, nodeForRemoval).build());
495496
indexAllShardsToAnEqualOrGreaterMinimumSize(indexName, ByteSizeValue.of(2, ByteSizeUnit.KB).getBytes());
497+
logger.info("---> nodeForRemovalId: " + nodeForRemovalId + ", numShards: " + numShards);
496498

497499
// Start the snapshot with blocking in place on the data node not to allow shard snapshots to finish yet.
498500
final var clusterService = internalCluster().getCurrentMasterNodeInstance(ClusterService.class);
@@ -502,7 +504,21 @@ public void testSnapshotShutdownProgressTracker() throws Exception {
502504

503505
waitForBlock(otherNode, repoName);
504506

505-
logger.info("---> nodeForRemovalId: " + nodeForRemovalId + ", numShards: " + numShards);
507+
// Block on the master when a shard snapshot request comes in, until we can verify that the Tracker saw the outgoing request.
508+
final CountDownLatch snapshotStatusUpdateLatch = new CountDownLatch(1);
509+
final var masterTransportService = MockTransportService.getInstance(internalCluster().getMasterName());
510+
masterTransportService.addRequestHandlingBehavior(
511+
TransportUpdateSnapshotStatusAction.NAME,
512+
(handler, request, channel, task) -> masterTransportService.getThreadPool().generic().execute(() -> {
513+
safeAwait(snapshotStatusUpdateLatch);
514+
try {
515+
handler.messageReceived(request, channel, task);
516+
} catch (Exception e) {
517+
fail(e);
518+
}
519+
})
520+
);
521+
506522
mockLog.addExpectation(
507523
new MockLog.SeenEventExpectation(
508524
"SnapshotShutdownProgressTracker start log message",
@@ -550,21 +566,6 @@ public void testSnapshotShutdownProgressTracker() throws Exception {
550566
mockLog.awaitAllExpectationsMatched();
551567
resetMockLog();
552568

553-
// Block on the master when a shard snapshot request comes in, until we can verify that the Tracker saw the outgoing request.
554-
final CountDownLatch snapshotStatusUpdateLatch = new CountDownLatch(1);
555-
final var masterTransportService = MockTransportService.getInstance(internalCluster().getMasterName());
556-
masterTransportService.addRequestHandlingBehavior(
557-
TransportUpdateSnapshotStatusAction.NAME,
558-
(handler, request, channel, task) -> masterTransportService.getThreadPool().generic().execute(() -> {
559-
safeAwait(snapshotStatusUpdateLatch);
560-
try {
561-
handler.messageReceived(request, channel, task);
562-
} catch (Exception e) {
563-
fail(e);
564-
}
565-
})
566-
);
567-
568569
mockLog.addExpectation(
569570
new MockLog.SeenEventExpectation(
570571
"SnapshotShutdownProgressTracker shard snapshot has paused log message",

0 commit comments

Comments
 (0)