KAFKA-20731: Streams: transitToUpdateStandby is called without checking ACTIVE_RESTORING, crashing the state updater thread#22864
Open
arnabnandy7 wants to merge 1 commit into
Conversation
Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
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.
Fixes KAFKA-20731.
DefaultStateUpdatercould call the non-idempotentChangelogReader#transitToUpdateStandbymethod while the changelog reader was already inSTANDBY_UPDATING. This could happen after all updating standby tasks were paused or removed because the empty-task state did not transition the reader back toACTIVE_RESTORING. Adding or resuming a standby task afterward attempted the standby transition again, throwing anIllegalStateExceptionand terminating the state updater thread.This change centralizes changelog reader state transitions in
DefaultStateUpdaterand enforces the following invariants:ACTIVE_RESTORING.STANDBY_UPDATINGonly if it is currently restoring active tasks.StoreChangelogReader#transitToUpdateStandbyremain unchanged.The transition helper is invoked after task additions, resumptions, pauses, removals, failures, and active restoration completion so that the reader state remains consistent with the updating task set.
The
DefaultStateUpdaterTestchangelog reader mock now models the actual reader state transitions. This allows the standby pause/resume regression test to fail iftransitToUpdateStandbyis invoked twice without an intervening transition back to active restoration.Testing:
All 87
DefaultStateUpdaterTesttests passed. The test execution also completedcheckstyleMain,checkstyleTest, andspotbugsMainsuccessfully.