Skip to content

Commit 01e4aaf

Browse files
author
Hendrik Muhs
committed
[Transfrom] prevent concurrent state persistence when indexer gets triggered during shutdown (#69551)
the latest state, during the 2 stages a new run might get triggered and run into a race condition where a new state persists runs while the old has not finished yet. This change prevents the trigger if the indexer is in the described intermediate state fixes #67121
1 parent b01f80b commit 01e4aaf

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/TransformIndexer.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,22 @@ public synchronized boolean maybeTriggerAsyncJob(long now) {
492492
return false;
493493
}
494494

495+
/*
496+
* ignore if indexer thread is shutting down (after finishing a checkpoint)
497+
* shutting down means:
498+
* - indexer has finished a checkpoint and called onFinish
499+
* - indexer state has changed from indexing to started
500+
* - state persistence has been called but has _not_ returned yet
501+
*
502+
* If we trigger the indexer in this situation the 2nd indexer thread might
503+
* try to save state at the same time, causing a version conflict
504+
* see gh#67121
505+
*/
506+
if (indexerThreadShuttingDown) {
507+
logger.debug("[{}] indexer thread is shutting down. Ignoring trigger.", getJobId());
508+
return false;
509+
}
510+
495511
return super.maybeTriggerAsyncJob(now);
496512
}
497513

0 commit comments

Comments
 (0)