mattisonchao opened a new pull request, #1493: URL: https://github.com/apache/pulsar-client-go/pull/1493
## Motivation - Partition auto-discovery can resize `consumer.consumers` while newly-created partition consumers are still being installed. - `AckIDList` and related ack paths read `consumer.consumers[msgID.PartitionIdx()]` directly, which can observe a nil partition consumer and panic when invoking `(*partitionConsumer).AckIDList`. - The issue was observed with `AckIDList(0x0, ...)` in the stack trace after a partition count change. ## Modifications - Change the parent consumer lock to `sync.RWMutex` and add a shared partition consumer lookup helper with `RLock` and nil checks. - Route `AckWithTxn`, `AckID`, `AckIDList`, and `AckIDCumulative` through the guarded lookup so ack operations return an error instead of panicking when a partition consumer is unavailable. - Make `ackIDListFromMultiTopics` preserve lookup errors in `AckError` and capture goroutine loop variables explicitly. - Add a unit test that reproduces the nil partition consumer `AckIDList` path without requiring a broker. ## Testing - `env -u GOROOT /Users/mattison/.local/share/mise/installs/go/1.26.1/bin/go test ./pulsar -run '^TestAckIDListReturnsErrorForNilPartitionConsumer$'` - `git diff --check` - Attempted broader `TestAckIDList`, but it requires a local Pulsar broker at `localhost:6650` and failed with connection refused in this environment. -- 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]
