Skip to content

[fix][broker] Observe replicated subscription update ack failures#26109

Open
Denovo1998 wants to merge 2 commits into
apache:masterfrom
Denovo1998:observe_replicated_subscription_update_ack_failures
Open

[fix][broker] Observe replicated subscription update ack failures#26109
Denovo1998 wants to merge 2 commits into
apache:masterfrom
Denovo1998:observe_replicated_subscription_update_ack_failures

Conversation

@Denovo1998

Copy link
Copy Markdown
Contributor

Motivation

When a replicated subscription update marker is received, the broker acknowledges the target subscription position asynchronously. The returned future was previously ignored, so failures from the ack path could be dropped without any logging or completion observation.

This makes replicated subscription state updates harder to diagnose when the local ack fails.

Modifications

  • Add a helper to acknowledge replicated subscription updates and observe the returned future.
  • Log replicated subscription update ack failures with the subscription name and position.
  • Use the same helper for both existing subscriptions and subscriptions created from incoming replicated updates.
  • Observe subscription creation failures in the create-subscription path.
  • Add a regression test that verifies the update ack future is observed.

Verifying this change

  • Make sure that the change passes the CI checks.

  • gradlew :pulsar-broker:test --tests org.apache.pulsar.broker.service.persistent.ReplicatedSubscriptionsControllerTest -PtestRetryCount=0`

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

If the box was checked, please highlight the changes

  • 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

.thenAccept(subscriptionCreated -> {
subscriptionCreated.acknowledgeMessageAsync(Collections.singletonList(pos),
AckType.Cumulative, Collections.emptyMap());
.thenAccept(subscriptionCreated ->

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.

Non-blocking: this branch is also changed by the PR, but the new test only covers the case where the subscription already exists. It would be useful to add a small test where topic.getSubscription(...) returns null, createSubscription(...) completes successfully, and the ack future returned by the newly-created subscription is observed. That would protect the create-then-ack path from regressing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out. I added testReplicatedSubscriptionUpdateCreatedSubscriptionAckFutureIsObserved to cover the create-then-ack path: topic.getSubscription(...) returns null, createSubscription(...) completes with the newly-created subscription, and the ack future returned by that subscription is asserted to be observed.

@void-ptr974 void-ptr974 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. This change observes the future returned by replicated subscription update acknowledgements, so async ack failures are no longer silently dropped. On failure it logs the subscription name, target position, unwrapped exception, and topic context from the controller logger.

The tests cover both update paths now: when the subscription already exists, and when the subscription is created from the incoming replicated update before applying the ack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants