[fix][consumer] Use resolved partition topic for single-partition zero queue consumer - #1531
Conversation
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Fixes zero-queue consumer subscription behavior for single-partition partitioned topics by ensuring it uses the resolved physical partition topic name (e.g., *-partition-0) instead of the base topic, avoiding broker rejections due to partitioned metadata.
Changes:
- Pass the resolved single partition topic (
partitions[0]) into the zero-queue consumer constructor. - Add a unit/integration test validating the zero-queue consumer uses the resolved partition topic internally.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pulsar/consumer_impl.go | Ensures zero-queue consumer uses the resolved single-partition topic name when partitions==1. |
| pulsar/consumer_zero_queue_test.go | Adds coverage asserting zero-queue consumer binds to the single physical partition topic. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Motivation
When a partitioned topic has exactly one partition, TopicPartitions returns the physical partition topic, e.g. topic-partition-0. However, the zero queue consumer path ignored that resolved topic and still created the internal consumer with the original base topic.
With newer brokers that enforce topic consistency, subscribing to the base topic after partitioned metadata exists is rejected with "Found partitioned metadata for non-partitioned topic". This change makes zero queue consumers use the resolved single partition topic, matching the normal consumer path and avoiding repeated failed subscribe attempts.
Modifications
Describe the modifications you've done.
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation