Repository navigation
Conversation
|
@lhotari A quick update, I think these are helpful for these issues
|
@poorbarcode the PRs you referenced don't seem to make this current PR #20540 obsolete. Please review |
michaeljmarshall
left a comment
There was a problem hiding this comment.
Nice work @lhotari. I left a few comments.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #20540 +/- ##
=============================================
- Coverage 73.58% 36.36% -37.23%
+ Complexity 32254 12289 -19965
=============================================
Files 1858 1722 -136
Lines 138021 131190 -6831
Branches 15111 14338 -773
=============================================
- Hits 101558 47702 -53856
- Misses 28606 77113 +48507
+ Partials 7857 6375 -1482
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Yes |
… out A topic load that timed out kept going: it opened, and so recovered, the managed ledger only to close it again, and the timed-out future stayed in the topic cache until then, so the topic could not be loaded meanwhile. The pending topic load queue, used when maxConcurrentTopicLoadRequest is reached, likewise started loads that had already timed out while queued. At shutdown, unloading a bundle waited for the futures of the queued loads, which only completed when the topic load timed out. - Skip opening the managed ledger when the topic future is already completed, and remove the timed-out future from the cache. - Drop queued loads whose topic future is already completed. - Fail queued loads, and loads queued later, with ServiceUnitNotReadyException when the graceful bundle unload of a shutdown starts. Assisted-by: Claude Code (claude-opus-5-5)
744581f to
766863a
Compare
Denovo1998
left a comment
There was a problem hiding this comment.
LGTM.
This seems to also cover the expired queued loading scenario discussed in #26729, while maintaining the existing cleanup order for loading that has already opened its ledger.
There may be a separate follow-up around the queue wake-up: after tryAcquire() fails, the last active load can release its permit and drain an empty queue before the new request is enqueued. With no later load completion, that request stays queued, and retries keep seeing its cached timeout. This predates the changes here, so I wouldn't block this PR on it.
… out (apache#20540) (cherry picked from commit aec5da3)
… out (apache#20540) (cherry picked from commit aec5da3)
Motivation
A persistent topic load that times out (
topicLoadTimeoutSeconds) keeps going in the background. The timed-outfuture intentionally stays in the
topicscache until the pending load actions finish, so that a new load can'topen the same managed ledger concurrently. But the load then still opens, and so recovers, the managed ledger,
only to close it again because the future was already completed. Until that is done, every lookup of the topic
gets the timed-out failure ("Failed to load topic within timeout" / "Topic is temporarily unavailable").
The same happens to the loads waiting in the pending topic load queue, which is used when
maxConcurrentTopicLoadRequestis reached: loads that timed out while queued are still started, one afteranother, each opening and closing its managed ledger. A backed up queue makes this worse exactly when the broker
is already overloaded.
At shutdown, the graceful bundle unload waits for every topic future cached for the bundle, including the ones
of queued loads. Those only complete when the topic load times out, so the shutdown waits for that timeout (or
the bundle unloading timeout).
This PR was originally opened in 2023 with a broader set of changes. Since then, master has gained most of them
in other forms: closing a topic whose future was completed before its load finished, removing a cache entry only
when it matches the exact create future (
getCreateFuture(), snapshot-basedcleanUnloadedTopicFromCache),re-checking the ownership right before opening the managed ledger, and
TopicLoadingContexttimeout tracing.The PR has been rewritten on top of current master to keep only what is still missing.
Modifications
createPersistentTopic0: if the topic future is already completed right before opening the managed ledger,skip opening it and remove the timed-out future from the cache, so that a new load can start.
createPendingLoadTopic: drop queued loads whose topic future is already completed, removing their cacheentries, instead of starting them.
ServiceUnitNotReadyException("Broker is shutting down")when the graceful bundleunload of a shutdown starts (
unloadNamespaceBundlesGracefully, which is only used on shutdown), and alsoloads that are queued after that. Clients handle
ServiceNotReadyby looking the topic up again.Verifying this change
This change added tests to
BrokerServiceTestand can be verified as follows:testTimedOutTopicLoadDoesNotOpenTheManagedLedger: a load that times out before the managed ledger is openeddoesn't call
asyncOpenand its future is removed from the cache.testPendingTopicLoadThatTimedOutIsNotStarted: a queued load that timed out is not started when the queue isprocessed, and its future is removed from the cache.
testPendingTopicLoadsFailWhenTheBrokerShutsDown: the graceful bundle unload fails a queued load and doesn'twait for its bundle unloading timeout.
Each test fails when the corresponding change is reverted.
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
docdoc-requireddoc-not-neededdoc-complete