Skip to content

Commit

Permalink
[Transfrom] prevent concurrent state persistence when indexer gets tr…
Browse files Browse the repository at this point in the history
…iggered 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
  • Loading branch information
Hendrik Muhs committed Feb 25, 2021
1 parent 1580932 commit 447318f
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,22 @@ public synchronized boolean maybeTriggerAsyncJob(long now) {
return false;
}

/*
* ignore if indexer thread is shutting down (after finishing a checkpoint)
* shutting down means:
* - indexer has finished a checkpoint and called onFinish
* - indexer state has changed from indexing to started
* - state persistence has been called but has _not_ returned yet
*
* If we trigger the indexer in this situation the 2nd indexer thread might
* try to save state at the same time, causing a version conflict
* see gh#67121
*/
if (indexerThreadShuttingDown) {
logger.debug("[{}] indexer thread is shutting down. Ignoring trigger.", getJobId());
return false;
}

return super.maybeTriggerAsyncJob(now);
}

Expand Down

0 comments on commit 447318f

Please sign in to comment.