Characterize scheduled cleanup across shard ownership changes - #12016
Draft
taylan-oai wants to merge 1 commit into
Draft
Characterize scheduled cleanup across shard ownership changes#12016taylan-oai wants to merge 1 commit into
taylan-oai wants to merge 1 commit into
Conversation
|
|
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.
Summary
Characterize scheduled cleanup that deletes a task written by a successor shard owner, so the cleanup contract can be reviewed with a repeatable test.
Problem
Scheduled cleanup selects a time range without the originating shard's ownership version. An owner can authorize cleanup through a boundary that exists only in memory. After ownership changes, the successor restores its scheduling floor from durable metadata and can assign a timer below that boundary before its first reader poll. A delayed cleanup from the predecessor then removes the new task even though ordinary writes from the predecessor are rejected.
The test acquires two real shard ownership ranges and uses the normal task-key assignment and persistence APIs. A timer written by the successor is visible before the predecessor's cleanup and absent afterward. Two controls retain the task: making the predecessor's reader frontier durable before transfer, or polling the successor's queue boundary before assigning the task.
Approach
Add comments at scheduled range cleanup and batched queue-state persistence, plus a passing SQLite-backed characterization test. It records the unsafe outcome explicitly; a future fix must preserve the successor's task and keep it reachable to queue readers.
Two possible follow-ups, neither implemented nor validated here:
SetQueueStateearlier is insufficient because it can return after an in-memory update. This option needs checks for write failures, batching cost, reader holes and the successor's restored read positions.A separate ownership read immediately before deletion leaves a check/write race. Advancing the successor's local time floor earlier narrows startup exposure but does not establish the predecessor's maximum authorized boundary.
Validation
go test -p 4 -tags test_dep ./service/history/shard -count=1 -timeout=5m).The committed test needs no external datastore. It runs real shard acquisition, task-key assignment and persistence operations, with mocked engine callbacks controlling publication and polling. It does not run a complete History engine or reproduce end-to-end workflow loss. The Cassandra overlay is local corroboration and is not included in the diff.
Risks, rollout, and scope
This is a problem-scoping draft containing comments and tests. The passing assertions describe the defect and do not certify either repair option. No production frequency, replica-failure behavior or complete recovery protocol is established by this test.