[Bug] Cluster transaction service throws before broker address mapping is initialized
- Dominant language
- Java
- Stars
- 22.6k
- Forks
- 12k
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 27
Description
## Problem
`ClusterTransactionService` initializes `brokerAddrNameMapRef` without a map. Before the first successful transaction-heartbeat scan, `getBrokerNameByAddr` dereferences `brokerAddrNameMapRef.get()` directly.
`AbstractTransactionService.addTransactionDataByBrokerAddr` calls this method on the transaction send path, so an otherwise valid transaction can fail with `NullPointerException` during proxy startup or before route discovery has completed.
## Expected behavior
An unresolved broker address should follow the existing `AbstractTransactionService.addTransactionDataByBrokerName` behavior: return `null` and do not record transaction data.
## Proposed fix
Initialize the address-to-broker-name mapping with an empty map (or null-check it) and add a regression test covering `addTransactionDataByBrokerAddr` before the first heartbeat scan.
## Scope
Proxy cluster transaction service. This does not change transaction protocol behavior after route discovery.
Contributor guide
Research direction
Start with ClusterTransactionService.getBrokerNameByAddr and AbstractTransactionService.addTransactionDataByBrokerAddr, then compare the existing addTransactionDataByBrokerName behavior. Add the regression test for calling the address-based path before the first transaction-heartbeat scan; done means an unresolved address returns null without recording transaction data and no NullPointerException occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100