GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||
GeezerVison is showing github.com — [fix][broker] Don't let a stalled __change_events reader hang topic policy updates and topic deletion, and close the reader a failed policy cache init leaks by kaminski-dev · Pull Request #27369 · apache/pulsar Conversation
|
| Result | |
|---|---|
master (bb6bd03) with only the test changes |
8 tests, 8 failed: the updates and the deletions are still waiting after the timeout, and the leaked reader is still cached |
| 31a28d5 (the previous head of this PR) with only the two new tests | 2 tests, 2 failed: the in-flight update timed out after 2 s on the healthy replacement, and the delivery completed after the replacement put maxConsumerPerTopic=6 back into the rebuilt cache |
| 8c0aec1 (the previous head of this PR) with only the unload test | 1 test, 1 failed: dies by its timeout, since the unload cannot be injected where the reader is created under a lock |
| this branch | 11 tests, 11 passed, in 5 consecutive runs |
The topic policy and system topic test classes of pulsar-broker pass as well (15 classes, 360 tests, no failures, -PtestRetryCount=0): SystemTopicBasedTopicPoliciesServiceTest, TopicPolic* in broker.service, InmemoryTopicPoliciesServiceServiceTest, LegacyAwareTopicPoliciesServiceTest, ReplicatorTopicPoliciesTest, BrokerServiceTopicDeletionTest, broker.systopic.*, and TopicPoliciesTest, TopicPoliciesUpdateTest and MetadataStoreTopicPoliciesTest in broker.admin. ./gradlew sanityCheck passes.
topicPoliciesCacheInitTimeoutSeconds, default 60 s, now also bounds how long a topic policy update or a topic deletion waits for the read-back, which was unbounded)pulsar executor, as the initialization timeout of [fix][broker] Don't let a stuck or aborted topic policies cache init make a namespace's topics unloadable #26025 does, instead of on the reader's callback thread)🤖 Generated with Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…reader The update writes its event and then waits, without a time limit, until the namespace's __change_events reader has read the event back. The test stalls the reader and expects the update to fail with a timeout. Assisted-by: Claude Code (Claude Fable 5.1)
Bound the wait in untilMessageIdHasBeenRead with topicPoliciesCacheInitTimeoutSeconds. The update then fails with a TimeoutException, which releases the updates queued behind it in the per-topic sequencer and lets a topic deletion take its existing error path. Assisted-by: Claude Code (Claude Fable 5.1)
After a read-back timeout the reader stays in place, so every later update in the namespace times out as well. Assisted-by: Claude Code (Claude Fable 5.1)
The timeout shows that the reader of the namespace stopped delivering. Close it through the identity-guarded cleanup, so the next initialization reads __change_events with a fresh reader. Assisted-by: Claude Code (Claude Fable 5.1)
…ed out Closing the stalled reader is not enough for a broker that still serves topics of the namespace: nothing reads __change_events again until the next policy access, and a new initialization does not notify loaded topics. Assisted-by: Claude Code (Claude Fable 5.1)
A broker that still owns a bundle of the namespace initializes the policy cache again right after it closed the stalled reader, and that initialization re-notifies the topic-policy listeners. The topics loaded on the broker then apply the events the stalled reader withheld, including the event of the update that timed out. Assisted-by: Claude Code (Claude Fable 5.1)
…eader stalls The deletion waits for the event that deletes the topic's policies. With the read-back timeout it fails, the topic accepts producers again, and a second deletion succeeds on the replacement reader. Assisted-by: Claude Code (Claude Fable 5.1)
When the first read of a namespace's __change_events fails on a broker that owns no bundle of the namespace, the reader stays cached and subscribed: no topic load retries the initialization and no bundle unload closes it. Assisted-by: Claude Code (Claude Fable 5.1)
…roker does not serve The reader of a failed initialization is kept for the retry of the next topic load, and the bundle unload closes it. A broker that owns no bundle of the namespace gets neither, so close the reader with the failed initialization there. Assisted-by: Claude Code (Claude Fable 5.1)
…ad-back wait Assisted-by: Claude Code (Claude Fable 5.1)
… is replaced Closing the message-handler tracker ends the other waits of the namespace, and an update queued behind one of them starts on the same thread, before the stalled reader has left the reader cache. It initializes the namespace with that reader and fails. Assisted-by: Claude Code (Claude Fable 5.1)
…cker An update that starts while cleanupFailedPolicyCacheInit closes the tracker initializes the namespace again. With the reader still cached it got the reader that the cleanup closes right afterwards. Assisted-by: Claude Code (Claude Fable 5.1)
The bundle ownership callbacks run there, so a bundle unload can no longer land between the ownership check and the start of the initialization. Assisted-by: Claude Code (Claude Fable 5.1)
…med-out event is kept Assisted-by: Claude Code (Claude Fable 5.1)
Shorten the timeout only once the readers are stalled, share the two-step stall assertion with the deletion test, and drive the leaked-reader test through a bundle load and a policy read with the failing reader injected at the reader factory. Assisted-by: Claude Code (Claude Fable 5.1)
Restore the default timeout on the thread that reports the stall, before the reader is replaced, and check that both updates are waiting before the first one times out. Assisted-by: Claude Code (Claude Fable 5.1)
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Code Review request for changes for commit ebbfa51.
Summary:
The timeout and reader cleanup address the reported hangs, and all 12 selected PR/existing tests passed. Request changes: recovery can retain compacted-away policies and omit deletion notifications. Two review-only regression probes reproduced these distinct failures with production code unchanged.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
After the reader is replaced, a policy whose deletion was compacted away is still in the policy cache, and a deletion that the replacement reader reads does not reach the topic-policy listeners. Assisted-by: Claude Code (Claude Fable 5.1)
…s replaced The replacement kept the cached policies and only added what the new reader read. A policy that was deleted while the reader was stalled, and whose tombstone was compacted away, stayed cached, and a deletion that the new reader did read never reached the topic-policy listeners. Drop the namespace's cached policies in the same step as the stalled initialization, and tell the listeners of the topics that have no policies after the rebuild. Assisted-by: Claude Code (Claude Fable 5.1)
…ialization A policy read that started a new initialization right after the stalled one was dropped could still be handed the old reader. Also name the record for what it holds, make it immutable, and correct two comments. Assisted-by: Claude Code (Claude Fable 5.1)
Assisted-by: Claude Code (Claude Fable 5.1)
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling the hang on a stalled __change_events reader; bounding the read-back wait is the right shape, and the cache rebuild and deletion replay that were asked for earlier are in. The config key reuse is fine (same name, default 60, already dynamic, documented in both conf files and ServiceConfiguration), the timer runs on the broker executor, and the leaked-reader close is correct. I checked the new tests against the production change: with the read-back timer disabled all seven tests in TopicPoliciesStalledReaderTest fail, and with the !ownsBundleOf(namespace) condition reverted testFailedInitClosesReaderWhenBrokerOwnsNoBundleOfNamespace fails. Remaining points: one case where a replacement reader is closed needlessly, one narrow callback race, and a timing assumption in one test.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Code Review request for changes for commit 31a28d5.
Summary:
The follow-up addresses both original regression scenarios: it clears cached policies and replays deletions. However, the rebuild still allows a superseded reader's delayed callback to restore stale entries. Request changes for that remaining race. Current-head tests were not executed: the managed validator ran the preserved older checkout.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Recommendation remains request changes. The original cache-rebuild and deletion-notification gaps are addressed in source, but the previously reported stale-reader callback race remains unresolved. The new discussion also identifies needless replacement of a healthy reader and a timing-dependent test. No commits changed, and no tests were run in this comments-only follow-up.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…ed (apache#27366) An update whose write is in flight while the reader is replaced has its event applied by the replacement's first pass over __change_events, but its wait for the read-back is registered afterwards and nothing completes it: the update times out, and the timeout then retires the healthy replacement. A delivery the replaced reader had already received can complete after the reader is closed. Its callback writes to the cache that the replacement just cleared, and puts back a policy whose deletion compaction has dropped. Also make the queued-update test independent of host speed: the update that has to keep waiting gets a timeout longer than the test, and only the update that is to report the stall gets the short one. Assisted-by: Claude Code (Claude Fable 5.1) Co-Authored-By: Claude Fable 5.1 <[email protected]>
…uperseded reader (apache#27366) An update whose write was in flight while the stalled reader was replaced registered its wait for the read-back after the replacement had applied its event in its first pass over __change_events; the first pass recorded nothing in the tracker, so the wait timed out and then retired the healthy replacement. The first pass now records every event it applies, as a live delivery does, and the wait takes the initialization and the tracker in one step, so a timeout retires the initialization whose tracker holds the wait. A reader that was replaced or unloaded can still complete a receive it had handed out before it was closed, and its callback wrote to the cache after the replacement had cleared it: a policy whose deletion compaction had dropped came back, and nothing could remove it again. Every delivery now writes to the caches inside policyCacheInitMap.compute on its namespace, and only while its initialization is still current; the replacement and the unload clear the cache inside the same step, so the write either lands before the clearing or is dropped. The tombstone that a legacy DELETE event triggers moves out of that step, so no write to the system topic happens under the lock. Assisted-by: Claude Code (Claude Fable 5.1) Co-Authored-By: Claude Fable 5.1 <[email protected]>
…nts before the lock (apache#27366) replaceStalledReader, cleanupFailedPolicyCacheInit and cleanPoliciesCacheInitMap removed the message-handler tracker after, or before, the step that drops the initialization. A first pass of a new initialization that started in between recorded its progress in the tracker about to be closed, and a wait registered afterwards for an event that pass had applied would time out and retire the healthy reader. The tracker now leaves its map inside the same compute step as the initialization (closing it stays outside), so a wait, a first pass and a timeout always refer to the tracker of one initialization. Also decode the event before the cache write takes the lock, since decoding can wait for a schema fetch; name the first pass's stage future for what it is; and in the tests, build the write-holding factory eagerly, let a held write be released only once the service has made it, and hold the queued-update test's waiting update so it registers its wait under the long timeout. Assisted-by: Claude Code (Claude Fable 5.1) Co-Authored-By: Claude Fable 5.1 <[email protected]>
…apache#27366) replaceStalledReader and cleanupFailedPolicyCacheInit repeated the identity- guarded step that drops an initialization with its reader and tracker; both now go through dropInitializationIfCurrent, which takes what else has to go in the same step. The tracker needs no capture before the step any more: it is created and removed inside compute() on the namespace only, so whatever is installed when the guard passes belongs to the initialization being dropped. Also correct the comment on the pairing of initialization and tracker (the failed-first-read path keeps the tracker with the reader for the retry), pass the decoded event to the listener notification instead of decoding it again, and relay the held write's result through one future in the test harness. Assisted-by: Claude Code (Claude Fable 5.1) Co-Authored-By: Claude Fable 5.1 <[email protected]>
…eader' into fix/27366-topic-policies-stuck-reader Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Thanks for the review, @lhotari. Here is what I did with the three items.
Item 3 needed one more change. I also merged @codelipenghui, the commits since your last review address both of its points. 0a3d2a0 installs an initialization and its reader slot in one step, and a482f33 and fdd932f add the test for it. The queued-update test now waits on |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@lhotari @codelipenghui , can we merge the PR or is something else from me required to merge it? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The two follow-up commits are exactly the requested edits, and nothing in the PR's own files changed after them (only master merges).
SystemTopicBasedTopicPoliciesService.java:354 now reads topicPoliciesCacheInitTimeoutSeconds before addPendingFuture and passes it to scheduleReadBackTimeout, so a wait that pendingReadBackWaits counts already has its deadline. That closes the window from my earlier threads.Nothing else is needed from my side.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Nothing more is needed from you on my side; the latest changes look good to me. The merge is up to the committers. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…olicy updates and topic deletion, and close the reader a failed policy cache init leaks (#27369) Co-authored-by: Claude Fable 5.1 <[email protected]> (cherry picked from commit 192d5c7)
…olicy updates and topic deletion, and close the reader a failed policy cache init leaks (apache#27369) Co-authored-by: Claude Fable 5.1 <[email protected]> (cherry picked from commit 192d5c7)
…olicy updates and topic deletion, and close the reader a failed policy cache init leaks (apache#27369) Co-authored-by: Claude Fable 5.1 <[email protected]> (cherry picked from commit 192d5c7)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
[Bug][broker] Topic policy updates and topic deletion wait forever when the __change_events reader stops, and a failed policy cache init leaks the reader
There was an error while loading. Please reload this page.