wenxuwan opened a new pull request, #1243:
URL: https://github.com/apache/rocketmq-client-go/pull/1243
## What is the purpose of the change
Fix trace dispatcher failures when consumers are recreated in a
long-running process after NameServer discovery changes.
Previously, trace initialization could return a typed nil dispatcher,
causing the interceptor to panic before invoking the business callback.
Closing a dispatcher also left its underlying client behind.
This change makes unavailable tracing preserve business callback execution
and gives shared trace resources an explicit lifecycle, while retaining
the existing `WithTrace` API and `TraceConfig` layout.
## Brief changelog
- Add optional `WithSharedTrace` support for sharing trace resources by
stable logical destination, with additional isolation by unit, access
channel and credentials. An independent resolver factory manages discovery
ownership.
- Reference-count shared NameServer and Broker transports. Make dispatcher
startup and shutdown idempotent, drain pending records with bounded
shutdown, and release resources after the final user closes.
- Release trace ownership when consumer or producer construction/startup
fails.
- Handle nil and typed-nil dispatchers without preventing business
operations or replacing their results/errors.
- Share discovery state and periodically refresh trace topic routes,
including cloud region topics.
- Clone cached route snapshots before sorting publish queues to prevent
races between dispatchers and background refresh.
- Add lifecycle, failure-path and concurrent discovery tests, plus usage
documentation in `docs/trace.md`.
The general producer/consumer client registry and its NameServer conflict
checks remain unchanged.
## Verifying this change
- Trace regression tests passed with `-race` in `internal`, `consumer` and
`producer`.
- Added an 8-Broker concurrent route-refresh test that reproduces the race
before the fix.
- Cache immutability and concurrent multi-Broker refresh tests passed five
consecutive runs with `-race` after the fix.
- `git diff --check` passed.
Full-suite success is not claimed. The full run encountered an
asynchronous mock expectation failure in `consumer.TestStart` and a timeout in
`internal/remote.TestInvokeAsyncTimeout`. Both were independently
reproduced against the unmodified upstream baseline.
## Checklist
- [ ] File and link the GitHub issue addressed by this PR.
- [ ] Format the title as `[ISSUE #<number>] Fix shared trace dispatcher
lifecycle and discovery`.
- [x] Provide a description explaining the problem, implementation and
compatibility.
- [ ] Add necessary unit tests with over 80% coverage. Regression tests
are included; the coverage threshold has not been confirmed for the final
patch.
- [ ] File an Apache Individual Contributor License Agreement if required.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]