Skip to content

[fix][broker] Return errors for discarded ACKs with receipts - #27128

Merged
poorbarcode merged 2 commits into
apache:masterfrom
AuroraTwinkle:fix/broker-ack-receipt-errors
Oct 27, 2026
Merged

poorbarcode merged 2 commits into
apache:masterfrom
AuroraTwinkle:fix/broker-ack-receipt-errors

Conversation

@AuroraTwinkle

@AuroraTwinkle AuroraTwinkle commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #23261

Motivation

With ACK receipts enabled, an acknowledgment discarded during topic transfer or after a consumer becomes unavailable receives no response. The client waits for its request timeout even though the broker already knows that it will not process the ACK.

Modifications

  • Return an ACK response with ServiceNotReady when the topic is transferring, and ConsumerNotFound when the consumer is missing or its subscription future is pending, failed or cancelled.
  • Send these errors only when the ACK carries a request ID. Preserve ACK handling without receipts, the ignored-ACK counter during transfer, and the normal asynchronous completion path.
  • Add protocol regressions and an end-to-end topic-unload regression using a real broker, bookie and Java client.

The end-to-end test delays an in-flight ACK, unloads its topic through the admin API, and then forwards the original ACK frame. It checks that the client ACK future fails with the correlated ConsumerNotFound response. The close-consumer notification remains delayed until a second producer successfully publishes on the same connection, ensuring that a disconnect cannot account for the failed ACK. The test covers individual and cumulative ACKs, with successful no-unload controls.

Verifying this change

  • Make sure that the change passes the CI checks.

Against the original ServerCnx implementation, the two end-to-end unload cases fail while waiting for the missing ACK response; both no-unload controls pass.

With the fix, 40 tests passed, with zero failures, errors or skipped tests and retries disabled:

  • AckReceiptOnTopicUnloadTest: four end-to-end cases.
  • ServerCnxTest.testAck*: 15 protocol cases covering unavailable consumers, topic transfer, receipt mode on/off, request/consumer ID correlation, and normal asynchronous ACK success/failure.
  • ConsumerTest: 19 existing ACK state/completion cases.
  • PulsarCommandSenderImplTest: two existing serialization cases.

Repository-wide sanityCheck, including quickCheck, passed. Full CI for this revision is not yet verified.

./gradlew :pulsar-broker:test \
  --tests 'org.apache.pulsar.broker.service.AckReceiptOnTopicUnloadTest' \
  --tests 'org.apache.pulsar.broker.service.ServerCnxTest.testAck*' \
  --tests 'org.apache.pulsar.broker.service.ConsumerTest' \
  --tests 'org.apache.pulsar.broker.service.PulsarCommandSenderImplTest' \
  -PtestRetryCount=0 -PtestFailFast=false -PtestMaxParallelForks=1 sanityCheck

Does this pull request potentially affect one of the following parts:

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Discarded ACKs that request receipts now receive an existing ACK_RESPONSE error instead of waiting for a timeout. No command, field or error code is added.

Respond to ACKs carrying a request ID when their consumer is unavailable
or their topic is transferring, instead of leaving the client waiting
for a timeout. Preserve ACK handling without receipts and transfer
statistics. Add protocol regressions and asynchronous completion controls.

Fixes apache#23261

Assisted-by: OpenAI Codex
Delay an in-flight ACK until the admin API unloads its topic, then check
that the Java client's ACK future receives the correlated error response.
Cover individual and cumulative ACKs, with no-unload success controls.
Verify a second producer can still publish on the same connection while
the close notification is delayed.

@Denovo1998 Denovo1998 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@poorbarcode
poorbarcode merged commit dcec727 into apache:master Oct 27, 2026
44 checks passed
lhotari pushed a commit that referenced this pull request Oct 28, 2026
danrubAtPlanview added a commit to danrubAtPlanview/pulsar-dotpulsar that referenced this pull request Nov 1, 2026
Three fixtures hard-coded apachepulsar/pulsar:4.0.9, and the three
tests that need a broker fix that no published image has were skipped
with a static Skip. They could only run after someone edited the code.

BrokerImage reads two variables:
- DOTPULSAR_TESTS_PULSAR_IMAGE replaces the default image
- DOTPULSAR_TESTS_BROKER_FIXES lists the apache/pulsar pull requests
  that the image has, for example 27128,27082

The two unload rows of ConsumerTests (apache/pulsar#27128) and the
row of TopicTransactionBufferPublishOrderTests (#27082) are skipped
unless their number is in the list, with a message that says how to
run them. Without the variables nothing changes: the same 14
integration tests are skipped. With DOTPULSAR_TESTS_BROKER_FIXES set
on the default image the two ConsumerTests rows run and fail with the
ack receipt timeout, which is the bug in that image.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] When ack receipts are enabled, no response is sent to the client if the topic has been unloaded or is being transferred

4 participants