Skip to content

Commit 1c85599

Browse files
authored
Improve watcher cleanup logic (#67554)
by waiting for all tasks to complete before deleting watcher history data stream. Closes #66495
1 parent 76d0e35 commit 1c85599

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ public void _cleanup() throws Exception {
202202
// Clear all internal watcher state for the next test method:
203203
logger.info("[#{}]: clearing watcher state", getTestName());
204204
stopWatcher();
205+
// Wait for all pending tasks to complete, this to avoid any potential incoming writes
206+
// to watcher history data stream to recreate the data stream after it has been created.
207+
// Otherwise ESIntegTestCase test cluster's wipe cluster logic that deletes all indices may fail,
208+
// because it attempts to remove the write index of an existing data stream.
209+
waitNoPendingTasksOnAll();
205210
String[] dataStreamsToDelete = {HistoryStoreField.DATA_STREAM};
206211
client().execute(DeleteDataStreamAction.INSTANCE, new DeleteDataStreamAction.Request(dataStreamsToDelete));
207212
GetDataStreamAction.Request getDataStreamRequest = new GetDataStreamAction.Request(dataStreamsToDelete);

0 commit comments

Comments
 (0)