[fix][txn] Prevent queued snapshot writes from stalling - #26565
Open
lhotari wants to merge 3 commits into
Open
Conversation
Delegate the context loader mocks to an empty URLClassLoader with the test loader as parent, so logging service discovery receives valid resource enumerations. Assisted-by: Codex
lhotari
requested review from
Demogorgon314,
Technoboy-,
dao-jun,
david-streamlio,
merlimat and
nodece
September 12, 2026 21:21
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.
Depends on #26567. Its interceptor fixture class-loading fix is included so the broker test suite can run successfully.
Fixes #19650
Motivation
SegmentAbortedTxnProcessorTest.testClearSnapshotSegmentscan observe only one of the two expected snapshot segments because the persistent worker schedules its next task before releasing its operating state. If that task runs immediately, it cannot acquire the state and returns, leaving the next write queued until another operation triggers processing.A related race occurs when another caller drains the queue between the initial empty check and acquiring the operating state: the second empty check returns without releasing that state.
Modifications
Release the operating state before scheduling the next successful task. When the second queue check finds no work, release the state and recheck the queue to cover an append that observed the worker as busy.
Add deterministic tests for immediate executor handoff and for queue drain/append interleavings, retaining assertions that queued writes run serially and eventually complete.
Verifying this change
Make sure that the change passes the CI checks.
The immediate-executor test fails on the original implementation because the second write never starts.
The queue-interleaving test fails without the empty-queue fix because an appended write never completes.
Both regression tests passed 10 invocations each with retries disabled; temporary invocation counts were removed.
All 6 tests in
SegmentAbortedTxnProcessorTestpassed, includingtestClearSnapshotSegments../gradlew spotlessCheck checkstyleMain checkstyleTestpassed.Does this pull request potentially affect one of the following parts: