You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "Aias00 (via GitHub)" <gi...@apache.org> on 2026/09/21 11:48:20 UTC
[I] [Studio][Refactor] Defer pooled client shutdown until in-flight actions finish [rocketmq-dashboard]
Aias00 opened a new issue, #4755:
URL: https://github.com/apache/rocketmq-dashboard/issues/4755
## Problem
`InstanceService` releases cached RocketMQ clients when an instance endpoint or credential reference changes. `MqAdminExtFactory.release(...)` and `MqClientPool.release(...)` currently remove the matching cache entry and immediately call `shutdown()`.
A request that already obtained the same cached admin, producer, or pull consumer can still be executing when the instance update retires it. Immediate shutdown can close the client underneath that in-flight action, producing avoidable RPC/send/pull failures during a normal configuration update. Application shutdown has the same ownership race for actions already admitted before the pool is closed.
This lifecycle race is independent of Ops runtime connection settings and does not require a default/no-instance connection path.
## Proposed Design
1. Add a package-private generic `ClientLease<T>` that owns one cached client, counts admitted actions, and supports one-way retirement.
2. `acquire()` succeeds only before retirement; `release()` decrements the active count; `retire()` prevents new acquisitions and invokes shutdown exactly once when the active count reaches zero.
3. Store leases in `MqAdminExtFactory` and `MqClientPool` without changing cache keys, public method signatures, client construction, authentication identity, or provider constructors.
4. Each execute/send/pull path acquires the current lease before invoking the caller action and releases it in `finally`. If it races with a retired cache entry, remove that exact lease and retry lookup so the request obtains a current client.
5. Endpoint/credential release removes matching entries and retires them. Idle clients close immediately; active clients close after their last action completes.
6. Pool shutdown marks the owner closed before retiring and clearing entries, so no new client can be created while already-admitted actions drain.
## Scope
- `ClientLease`, `MqAdminExtFactory`, `MqClientPool`, and focused lifecycle tests only.
- No Ops connection persistence, default connection routing, transport-setting changes, provider constructor changes, deployment files, or application configuration.
- Preserve all existing exception mapping, endpoint normalization, authentication isolation, and cache reuse behavior.
## Acceptance Criteria
- Releasing an idle admin/producer/consumer shuts it down immediately and evicts it.
- Releasing an in-flight client does not call shutdown until the action exits.
- A request arriving after retirement cannot acquire the retired client and can create/reuse a replacement.
- Endpoint-wide and credential-scoped release keep their existing ownership boundaries.
- Shutdown rejects new calls while allowing admitted actions to finish before closing their clients.
- Shutdown is invoked at most once per cached client.
- All new test method names end with `Test`; focused lifecycle tests, full backend tests, Checkstyle, package, and `git diff --check` pass.
## Direction
The default RocketMQ connection should remain fail-closed and non-editable at runtime under the current instance model. This issue extracts only the reusable pooled-client lifecycle safety identified during review of #4387.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Studio][Refactor] Defer pooled client shutdown until in-flight actions finish [rocketmq-dashboard]
Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins closed issue #4755: [Studio][Refactor] Defer pooled client shutdown until in-flight actions finish
URL: https://github.com/apache/rocketmq-dashboard/issues/4755
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Studio][Refactor] Defer pooled client shutdown until in-flight actions finish [rocketmq-dashboard]
Posted by "LuoYushi7 (via GitHub)" <gi...@apache.org>.
LuoYushi7 commented on issue #4755:
URL: https://github.com/apache/rocketmq-dashboard/issues/4755#issuecomment-5760036412
I would like to take this one if you are not already on it.
Reading the spec, the part I want to confirm before writing code is the retry rule in
step 4, because it is the only piece that changes observable control flow:
> If it races with a retired cache entry, remove that exact lease and retry lookup so
> the request obtains a current client.
Bounded or unbounded? A single retry covers the ordinary case (the entry we grabbed was
just retired by a concurrent endpoint update). A loop instead survives a burst of
successive updates but can spin if retirement keeps winning. I lean towards one retry
returning the same `CLIENT_NOT_FOUND`/`INSTANCE_NOT_FOUND` mapping as a plain cache miss
when the second lookup also comes back retired, so the caller sees a normal failure rather
than a silent extra wait.
Two smaller ones:
* Is `ClientLease` shared between `MqAdminExtFactory` and `MqClientPool`, or one per pool?
The acceptance criteria say shutdown is invoked at most once per cached client, which a
single lease per entry gives for free — I read it as shared, in its own file.
* For "All new test method names end with `Test`" — that matches the existing convention
in the metrics/collector tests, so I will follow it.
If you are already implementing this, say so and I will leave it alone rather than add a
duplicate to the review queue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Studio][Refactor] Defer pooled client shutdown until in-flight actions finish [rocketmq-dashboard]
Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins commented on issue #4755:
URL: https://github.com/apache/rocketmq-dashboard/issues/4755#issuecomment-5845367073
Fixed in 8a27ce63f (#4761) on the `rocketmq-studio` branch.
Closing manually: GitHub only auto-closes an issue when the pull request is merged into the repository's default branch, and `rocketmq-studio` is not it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Studio][Refactor] Defer pooled client shutdown until in-flight actions finish [rocketmq-dashboard]
Posted by "RockteMQ-AI (via GitHub)" <gi...@apache.org>.
RockteMQ-AI commented on issue #4755:
URL: https://github.com/apache/rocketmq-dashboard/issues/4755#issuecomment-5760189692
**Issue Evaluation**
Category: `enhancement` | Status: **Evaluated**
**Feasibility:** Feasible
**Scope:** `internal/studio/client.go` (pool implementation), action dispatch lifecycle
**Compatibility:** No breaking changes — internal refactor of shutdown sequencing
The refactor proposal correctly identifies a lifecycle race condition: the pooled client can be shut down while actions are still in-flight, leading to incomplete operations or errors.
**Key observations:**
1. The current shutdown path does not wait for pending actions to complete, which can cause data loss or inconsistent state.
2. Deferring shutdown until in-flight actions finish is the correct approach for graceful lifecycle management.
3. This requires tracking active actions (e.g., via a WaitGroup or similar mechanism) and blocking shutdown until the count reaches zero.
**Recommendation:** The refactor is sound and improves reliability. Consider adding a shutdown timeout to prevent indefinite blocking if an action hangs. Integration tests should verify that shutdown waits for in-flight actions and that new actions are rejected after shutdown begins.
---
*Automated evaluation by github-manager*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org