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][admin] PIP-478: off-load the admin's v4 credential and lend it a bounded auth executor by lhotari · Pull Request #26327 · apache/pulsar Conversation
|
| File | Description |
|---|---|
BoundInitContextFallbackTest.java |
Tests bound-context executor fallbacks. |
V5AuthContexts.java |
Adds shared scheduler and executor fallbacks. |
AdminAuthOffloadTest.java |
Tests admin credential off-loading. |
PulsarAdminImpl.java |
Adds the admin authentication executor lifecycle. |
BaseResource.java |
Off-loads legacy authentication composition. |
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/BaseResource.java:167
authenticationStage completes asynchronously: the thenApply continuation below invokes synchronous newRequestHeader on the thread that completes stage, potentially a Jersey/Netty I/O thread. Offload that continuation too so every synchronous v4 hook is covered. private CompletableFuture<Map<String, String>> v4AuthHeaders(URI uri) {
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
8aedf93 to
577e530
Compare
577e530 to
c6bb40a
Compare
a83127f to
c99d08f
Compare
|
Thanks — two of the three are right, and the first one is the more interesting: it says the PR Addressed in 1. The v4 composition went to the shared pool — accepted, fixedThis is the finding that matters. The PR builds a bounded per-admin pool so that a stalled identity My stated reason was that Pinned by 2.
|
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.
The BoundInitContext fallback is a clean fix to a real asymmetry — binding partial services being worse for a plugin than binding none is exactly the kind of thing that bites a third party and nobody else. And the close() ordering does what its comment claims: auth.close() runs first, the executor shuts down last, and shutdown() over shutdownNow() is right given daemon threads and in-flight requests.
My concern is that the PR's two halves pull against each other, and the half that this PR is named for gets the weaker treatment.
1. The v4 composition lands on the process-wide pool — the arrangement the other half of this PR argues is wrong.
PulsarAdminImpl now binds an admin-owned pool, justified as:
leaving it unbound is not right either: the plugin then shares one process-wide pool with every other client in the JVM, so a stalled identity provider reached by one admin throttles authentication for all of them.
BaseResource then passes null, which routes the v4 credential composition to precisely that pool. The call-site comment reconciles this by asserting:
The admin's own bounded pool is still what a services-aware plugin gets, so the work that can actually stall — a KDC or IdP round trip inside the plugin — stays isolated per admin.
That is not true of this branch. I checked which plugins reach it: AuthenticationSasl is the only implementor of AsyncHttpAuthenticationProvider in the tree, so it is the only one taking the driver path above. AuthenticationOAuth2 and AuthenticationAthenz fall through to v4AuthHeaders, and the first thing it does is auth.getAuthData(uri.getHost()) — which for OAuth2 is getAuthData() (the String overload defaults to it), declared public synchronized, performing the blocking IdP fetch on expiry. So the IdP round trip the comment says stays isolated is exactly what runs on the shared pool.
The shared pool is 8 threads for the whole JVM. Because getAuthData() is synchronized, concurrent admin requests through one OAuth2 plugin queue on that monitor while occupying pool threads — one in the fetch, the rest parked on the lock. Copilot made this point; I think it is right and worth more than it claimed.
The part that sharpens it: #26328 puts the proxy's broker-client credential resolution on this same shared pool — V5AuthContexts names the proxy as the caller with no services to bind. In a proxy or broker JVM, then, enough concurrent admin requests against a stalled IdP can occupy all eight workers and stall the proxy's backend connection setup behind them. That is the cross-component throttling this PR's other half was written to prevent, arriving through the door this half opens.
2. The "30 subclasses" constraint is real, but the remedy is cheaper than the comment implies.
I checked: 31 subclasses, 23 super(auth, requestTimeoutMs) call sites. Threading it through the constructor genuinely is that much churn.
But it does not have to go through the constructor. PulsarAdminImpl constructs every one of these objects, so a package-private setter, or an Executor/Supplier<Executor> field on BaseResource assigned once after construction, is a two-file change with no subclass edits. Keeping the shared pool as the fallback when nothing was set preserves today's behaviour for any other caller. The trade-off as written reads as forced when it looks closer to optional.
3. Minor: the off-load is partial for a plugin with an asynchronous authenticationStage.
The javadoc says the deprecated hooks "now run on a blocking executor". For every built-in that is true, because the default authenticationStage completes its future inline (authFuture.complete(null)), so the thenApply computing newRequestHeader runs on the pool thread.
A third-party plugin that overrides authenticationStage and completes asynchronously gets a split: getAuthData and the invocation run on the pool, but newRequestHeader — the half doing the actual header computation — runs on whatever thread completed stage. Not a regression (it behaved the same before), and that population is small, but it is the population the sentence directly above is about ("preserving behaviour for third-party plugins"), so it is worth scoping the claim to getAuthData plus the authenticationStage invocation.
On the other Copilot comment — that the admin pool's LinkedBlockingQueue bounds concurrency but not admission — I would deprioritise it relative to the above. Each queued task is a small lambda; the memory actually retained per in-flight admin request is the caller's own future and request state, which exists whether or not the task is queued. And "queue rather than reject" is the same call SharedBlockingExecutor already documents, for the same reason: the caller is a real request, so saturation should slow it rather than fail it. Worth a comment noting the unbounded admission is deliberate, not worth a redesign.
For disclosure: static analysis over the stacked branch; I did not run sanityCheck or the two new tests locally.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Timing note first: I went through the fix rather than assuming it, and it is complete — and in two places it goes further than what I raised:
I also checked the one thing that looked risky on a first read: On the queue: I had reached your conclusion independently before seeing your reply — my draft says to deprioritise it, on the same ground, that the queued task is trivial next to what the caller already retains to have produced it. Agreed that one configurable bound across both pools is the right shape if it is ever wanted, rather than an arbitrary capacity on the admin pool alone. One residual, forward-looking rather than a defect. The cheap guard is a package-private getter next to the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for the timing note — and for going through the fix rather than re-raising against the old
One deviation from your sketch, for a reason worth stating. Rather than listing the accessors, the Mutation-verified in the way that matters for this particular guard — I dropped It names the accessor, so whoever trips it is told which line to fix rather than that something On your read of the shared-pool interaction with #26328 — that is the part of your review that
Prepared with the assistance of Claude Code (Opus 5). |
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.
Approving. All three findings fixed, verified against ef5aba0494 — and the fix went past two of them: HttpClient got the same thenApplyAsync treatment (the gap existed in the method the PR body cites as the exemplar, which I had missed), and the executor is now shut down on a failed build.
The residual I raised is closed by c585664387, and the test is better than what I sketched: it walks the accessors PulsarAdmin declares rather than a hand-maintained list — avoiding the same forgetting problem one level up — guards against passing vacuously, and is mutation-verified to name the offending accessor.
Nothing outstanding from me.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
c585664 to
4d0f838
Compare
aa4fe64 to
6c440f9
Compare
6c440f9 to
a2e9d2d
Compare
f0bc86b to
29c5fe1
Compare
Review of #26327 by Copilot. The admin built a bounded pool for blast-radius isolation and then sent its own per-request v4 credential composition to the framework's process-wide shared pool, so the common path — every authenticated admin request — kept the blast radius the pool exists to contain. The stated reason was cost: BaseResource is constructed 23 times and each would have to thread an executor through. Lending the pool right after construction gets the same result without touching the 23 resource classes. Second hook, same gap: newRequestHeader ran on whatever thread completed the authentication stage. For a v4 plugin of the multi-round challenge shape that is its own HTTP callback thread, so off-loading the credential resolution alone covered half the composition. The continuation now runs on the same blocking executor. HttpClient's lookup-path composition, which this one mirrors, had the identical gap and is fixed with it. The pool is now created with the admin rather than lazily: it is on the default path, an unused ThreadPoolExecutor starts no threads, and a final field removes the synchronized accessor. Tests: theV4CompositionRunsOnTheOwningAdminsOwnPool builds a real PulsarAdmin, so what is pinned is that the admin lends its pool — not that BaseResource would use one if given it. theNewRequestHeaderHookIsOffLoadedToo hands the stage back to the test to complete, because a stage completed before the continuation is registered runs it on the registering thread and would pass either way. Both mutation-verified: each fails alone when its fix is reverted. Assisted-by: Claude Code (Opus 5)
…t lent the auth pool Review follow-up on #26327 from david-streamlio. lendAuthExecutor(...) is opt-in per construction site. A resource added to PulsarAdminImpl later without the wrapper compiles, runs, and silently falls back to the framework's shared pool — the fix undone with no symptom, because the fallback works. Pinning one resource cannot catch that: the twenty-fourth is the one that would be missed. everyResourceTheAdminExposesIsLentThePool walks the accessors PulsarAdmin itself declares and asserts each resource reports the admin's pool, so the guard grows with the interface rather than with a hand-maintained list. It reflects over public accessors only — no reading of private state — and reads the executor through package-private accessors on both classes. Mutation-verified: dropping the wrapper from one construction site fails the test naming that accessor ("scalableTopics"). Assisted-by: Claude Code (Opus 5)
29c5fe1 to
b6c17d9
Compare
|
Restacked, plus one new commit. The branch was force-pushed after #26326 picked up the fixes from a whole-series final-state review, so the diff view has been reset — the code in this PR is unchanged by that restack. The one new commit here is a Verified as part of the whole stack on lhotari/pulsar#258, 42/44 green (the two non-successes are that fork PR's non-semantic title and a skipped CodeQL run). apache/pulsar runs only the semantic-title check here until #26326 merges. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Review of #26327 by Copilot. The admin built a bounded pool for blast-radius isolation and then sent its own per-request v4 credential composition to the framework's process-wide shared pool, so the common path — every authenticated admin request — kept the blast radius the pool exists to contain. The stated reason was cost: BaseResource is constructed 23 times and each would have to thread an executor through. Lending the pool right after construction gets the same result without touching the 23 resource classes. Second hook, same gap: newRequestHeader ran on whatever thread completed the authentication stage. For a v4 plugin of the multi-round challenge shape that is its own HTTP callback thread, so off-loading the credential resolution alone covered half the composition. The continuation now runs on the same blocking executor. HttpClient's lookup-path composition, which this one mirrors, had the identical gap and is fixed with it. The pool is now created with the admin rather than lazily: it is on the default path, an unused ThreadPoolExecutor starts no threads, and a final field removes the synchronized accessor. Tests: theV4CompositionRunsOnTheOwningAdminsOwnPool builds a real PulsarAdmin, so what is pinned is that the admin lends its pool — not that BaseResource would use one if given it. theNewRequestHeaderHookIsOffLoadedToo hands the stage back to the test to complete, because a stage completed before the continuation is registered runs it on the registering thread and would pass either way. Both mutation-verified: each fails alone when its fix is reverted. Assisted-by: Claude Code (Opus 5)
…t lent the auth pool Review follow-up on #26327 from david-streamlio. lendAuthExecutor(...) is opt-in per construction site. A resource added to PulsarAdminImpl later without the wrapper compiles, runs, and silently falls back to the framework's shared pool — the fix undone with no symptom, because the fallback works. Pinning one resource cannot catch that: the twenty-fourth is the one that would be missed. everyResourceTheAdminExposesIsLentThePool walks the accessors PulsarAdmin itself declares and asserts each resource reports the admin's pool, so the guard grows with the interface rather than with a hand-maintained list. It reflects over public accessors only — no reading of private state — and reads the executor through package-private accessors on both classes. Mutation-verified: dropping the wrapper from one construction site fails the test naming that accessor ("scalableTopics"). Assisted-by: Claude Code (Opus 5)
b6c17d9 to
90f2192
Compare
Review of #26327 by Copilot. The admin built a bounded pool for blast-radius isolation and then sent its own per-request v4 credential composition to the framework's process-wide shared pool, so the common path — every authenticated admin request — kept the blast radius the pool exists to contain. The stated reason was cost: BaseResource is constructed 23 times and each would have to thread an executor through. Lending the pool right after construction gets the same result without touching the 23 resource classes. Second hook, same gap: newRequestHeader ran on whatever thread completed the authentication stage. For a v4 plugin of the multi-round challenge shape that is its own HTTP callback thread, so off-loading the credential resolution alone covered half the composition. The continuation now runs on the same blocking executor. HttpClient's lookup-path composition, which this one mirrors, had the identical gap and is fixed with it. The pool is now created with the admin rather than lazily: it is on the default path, an unused ThreadPoolExecutor starts no threads, and a final field removes the synchronized accessor. Tests: theV4CompositionRunsOnTheOwningAdminsOwnPool builds a real PulsarAdmin, so what is pinned is that the admin lends its pool — not that BaseResource would use one if given it. theNewRequestHeaderHookIsOffLoadedToo hands the stage back to the test to complete, because a stage completed before the continuation is registered runs it on the registering thread and would pass either way. Both mutation-verified: each fails alone when its fix is reverted. Assisted-by: Claude Code (Opus 5)
…t lent the auth pool Review follow-up on #26327 from david-streamlio. lendAuthExecutor(...) is opt-in per construction site. A resource added to PulsarAdminImpl later without the wrapper compiles, runs, and silently falls back to the framework's shared pool — the fix undone with no symptom, because the fallback works. Pinning one resource cannot catch that: the twenty-fourth is the one that would be missed. everyResourceTheAdminExposesIsLentThePool walks the accessors PulsarAdmin itself declares and asserts each resource reports the admin's pool, so the guard grows with the interface rather than with a hand-maintained list. It reflects over public accessors only — no reading of private state — and reads the executor through package-private accessors on both classes. Mutation-verified: dropping the wrapper from one construction site fails the test naming that accessor ("scalableTopics"). Assisted-by: Claude Code (Opus 5)
90f2192 to
9e090f0
Compare
Review of #26327 by Copilot. The admin built a bounded pool for blast-radius isolation and then sent its own per-request v4 credential composition to the framework's process-wide shared pool, so the common path — every authenticated admin request — kept the blast radius the pool exists to contain. The stated reason was cost: BaseResource is constructed 23 times and each would have to thread an executor through. Lending the pool right after construction gets the same result without touching the 23 resource classes. Second hook, same gap: newRequestHeader ran on whatever thread completed the authentication stage. For a v4 plugin of the multi-round challenge shape that is its own HTTP callback thread, so off-loading the credential resolution alone covered half the composition. The continuation now runs on the same blocking executor. HttpClient's lookup-path composition, which this one mirrors, had the identical gap and is fixed with it. The pool is now created with the admin rather than lazily: it is on the default path, an unused ThreadPoolExecutor starts no threads, and a final field removes the synchronized accessor. Tests: theV4CompositionRunsOnTheOwningAdminsOwnPool builds a real PulsarAdmin, so what is pinned is that the admin lends its pool — not that BaseResource would use one if given it. theNewRequestHeaderHookIsOffLoadedToo hands the stage back to the test to complete, because a stage completed before the continuation is registered runs it on the registering thread and would pass either way. Both mutation-verified: each fails alone when its fix is reverted. Assisted-by: Claude Code (Opus 5)
…t lent the auth pool Review follow-up on #26327 from david-streamlio. lendAuthExecutor(...) is opt-in per construction site. A resource added to PulsarAdminImpl later without the wrapper compiles, runs, and silently falls back to the framework's shared pool — the fix undone with no symptom, because the fallback works. Pinning one resource cannot catch that: the twenty-fourth is the one that would be missed. everyResourceTheAdminExposesIsLentThePool walks the accessors PulsarAdmin itself declares and asserts each resource reports the admin's pool, so the guard grows with the interface rather than with a hand-maintained list. It reflects over public accessors only — no reading of private state — and reads the executor through package-private accessors on both classes. Mutation-verified: dropping the wrapper from one construction site fails the test naming that accessor ("scalableTopics"). Assisted-by: Claude Code (Opus 5)
9e090f0 to
5d3913e
Compare
…a bounded auth executor PIP-478 states that every synchronous v4 plugin call is off-loaded, and after the core migration that was true everywhere except one place: BaseResource resolved the credential for each admin request on whatever thread issued the call. HttpClient.computeAuthHeaders off-loads the identical composition for the lookup path and names the self-deadlock it avoids — an OAuth2 or Athenz shim's getAuthData() refreshes its credential over synchronous HTTP, and for a broker calling its own admin client the caller is a request-handling thread. The composition now runs on a blocking executor, and produces the plugin's headers verbatim. The v4 composition is off-loaded to the framework's shared pool rather than the admin's own, because BaseResource is constructed by 30 subclasses that would each have to thread an executor through; the shared pool is exactly what PIP-478 provides for a component with none to lend. What a services-aware plugin gets is different, and is the second half of this change. PulsarAdminImpl bound its framework services with a null blocking executor. That stopped being a live defect when the init context grew a shared-pool fallback, but it left the SASL-over-HTTP challenge rounds putting their GSSAPI work on one process-wide pool shared with every other client in the JVM, so a stalled KDC reached by one admin throttled authentication for all of them. The admin now lends a small bounded pool of its own, created lazily and shut down with the admin, which keeps that blast radius inside the admin that owns the plugin. Its request threads are still never lent out — that was the hazard the original null was avoiding. The scheduler stays unbound: nothing on the admin path schedules periodic authentication work. Instead the bound init context now falls back to the shared scheduler and blocking pool when the bound services leave one null, so the SPI's "never null" contract holds on every path — previously, binding partial services was worse for a third-party plugin than binding none at all, since the no-services context has always guaranteed non-null.
Review of #26327 by Copilot. The admin built a bounded pool for blast-radius isolation and then sent its own per-request v4 credential composition to the framework's process-wide shared pool, so the common path — every authenticated admin request — kept the blast radius the pool exists to contain. The stated reason was cost: BaseResource is constructed 23 times and each would have to thread an executor through. Lending the pool right after construction gets the same result without touching the 23 resource classes. Second hook, same gap: newRequestHeader ran on whatever thread completed the authentication stage. For a v4 plugin of the multi-round challenge shape that is its own HTTP callback thread, so off-loading the credential resolution alone covered half the composition. The continuation now runs on the same blocking executor. HttpClient's lookup-path composition, which this one mirrors, had the identical gap and is fixed with it. The pool is now created with the admin rather than lazily: it is on the default path, an unused ThreadPoolExecutor starts no threads, and a final field removes the synchronized accessor. Tests: theV4CompositionRunsOnTheOwningAdminsOwnPool builds a real PulsarAdmin, so what is pinned is that the admin lends its pool — not that BaseResource would use one if given it. theNewRequestHeaderHookIsOffLoadedToo hands the stage back to the test to complete, because a stage completed before the continuation is registered runs it on the registering thread and would pass either way. Both mutation-verified: each fails alone when its fix is reverted. Assisted-by: Claude Code (Opus 5)
…t lent the auth pool Review follow-up on #26327 from david-streamlio. lendAuthExecutor(...) is opt-in per construction site. A resource added to PulsarAdminImpl later without the wrapper compiles, runs, and silently falls back to the framework's shared pool — the fix undone with no symptom, because the fallback works. Pinning one resource cannot catch that: the twenty-fourth is the one that would be missed. everyResourceTheAdminExposesIsLentThePool walks the accessors PulsarAdmin itself declares and asserts each resource reports the admin's pool, so the guard grows with the interface rather than with a hand-maintained list. It reflects over public accessors only — no reading of private state — and reads the executor through package-private accessors on both classes. Mutation-verified: dropping the wrapper from one construction site fails the test naming that accessor ("scalableTopics"). Assisted-by: Claude Code (Opus 5)
… off-loaded The Error-model section still named BaseResource as "the exception" that "composes v4 headers on the calling thread" and said it was "tracked as a follow-up". This PR is that follow-up: BaseResource.computeAuthHeaders now runs the v4 composition on the bounded authentication executor the owning PulsarAdmin lends each resource, falling back to the shared pool for a resource built outside one. Leaving a closed follow-up recorded as open understates what shipped and makes the surrounding normative sentence read as false when it is now true. Assisted-by: Claude Code (Opus 5)
5d3913e to
8c12b56
Compare
There was an error while loading. Please reload this page.
…a bounded auth executor (apache#26327)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.