[Transform] make shouldStopAtCheckpoint more robust#70461
Merged
hendrikmuhs merged 5 commits intoelastic:masterfrom Mar 22, 2021
Merged
[Transform] make shouldStopAtCheckpoint more robust#70461hendrikmuhs merged 5 commits intoelastic:masterfrom
hendrikmuhs merged 5 commits intoelastic:masterfrom
Conversation
… stops if stopAtCheckpoint has been called in between. This change also fixes a logging problem and ensures a timeout error gets logged. fixes elastic#70416
Collaborator
|
Pinging @elastic/ml-core (Team:ML) |
benwtrent
approved these changes
Mar 18, 2021
Comment on lines
-1117
to
+1144
| if (stopCalledDuringIndexerThreadShutdown) { | ||
| doSaveState(IndexerState.STOPPED, getPosition(), () -> {}); | ||
| if (saveStateRequestedDuringIndexerThreadShutdown) { | ||
| // if stop has been called and set shouldStopAtCheckpoint to true, | ||
| // we should stop if we just finished a checkpoint | ||
| if (context.shouldStopAtCheckpoint() && nextCheckpoint == null) { | ||
| stop(); | ||
| } | ||
| doSaveState(getState(), getPosition(), () -> {}); |
Member
There was a problem hiding this comment.
This seems like a bad bug :/
Previously, even if we were waiting to stop at a checkpoint we would just set the indexer to stopped and save state. No wonder we had two things attempting to save state + a weird race condition
| @@ -719,9 +737,12 @@ private synchronized boolean addSetStopAtCheckpointListener( | |||
|
|
|||
| synchronized void stopAndSaveState() { | |||
Member
There was a problem hiding this comment.
I know that this name has been the same for a while.
But I think something like stopAndMaybeSaveState is better is it will only save state if the indexer is NOT already shutting down + the indexer stopped.
| if (state == IndexerState.STOPPED) { | ||
| getIndexer().stopAndSaveState(); | ||
| } | ||
| getIndexer().stopAndSaveState(); |
Co-authored-by: Przemysław Witek <przemyslaw.witek@elastic.co>
hendrikmuhs
pushed a commit
that referenced
this pull request
Mar 22, 2021
shouldStopAtCheckpoint tells transform to stop at the next checkpoint, if this API is called while a checkpoint is finishing, it can cause a race condition in state persistence. This is similar to #69551, but this time in a different place. With this change _stop?shouldStopAtCheckpoint=true does not call doSaveState if indexer is shutting down. Still it ensures the job stops after the indexer has shutdown. Apart from that the change fixes: a logging problem, it adds error handling in case of a timeout during _stop?shouldStopAtCheckpoint=true. Some logic has been moved from the task to the indexer. fixes #70416
hendrikmuhs
pushed a commit
that referenced
this pull request
Apr 6, 2021
…71343) shouldStopAtCheckpoint tells transform to stop at the next checkpoint, if this API is called while a checkpoint is finishing, it can cause a race condition in state persistence. This is similar to #69551, but this time in a different place. With this change _stop?shouldStopAtCheckpoint=true does not call doSaveState if indexer is shutting down. Still it ensures the job stops after the indexer has shutdown. Apart from that the change fixes: a logging problem, it adds error handling in case of a timeout during _stop?shouldStopAtCheckpoint=true. Some logic has been moved from the task to the indexer. fixes #70416
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
shouldStopAtCheckpoint tells transform to stop at the next checkpoint, if
this API is called while a checkpoint is finishing, it can cause a race condition
in state persistence. This is similar to #69551, but this time in a different
place.
With this change
_stop?shouldStopAtCheckpoint=truedoes not call doSaveStateif indexer is shutting down. Still it ensures the job stops after the indexer has
shutdown. Apart from that the change fixes: a logging problem, it adds error
handling in case of a timeout during
_stop?shouldStopAtCheckpoint=true. Somelogic has been moved from the task to the indexer.
fixes #70416