Skip to content

[fix][broker] Fix PendingAckHandleImpl when replay failed.#18886

Closed
tjiuming wants to merge 16 commits intoapache:masterfrom
tjiuming:fix/pending_ack_handle_relay_failed
Closed

[fix][broker] Fix PendingAckHandleImpl when replay failed.#18886
tjiuming wants to merge 16 commits intoapache:masterfrom
tjiuming:fix/pending_ack_handle_relay_failed

Conversation

@tjiuming
Copy link
Contributor

@tjiuming tjiuming commented Dec 12, 2022

Motivation

Currently, we don't handle PendingAckHandleImpl replay failed.
If the operation failed, it won't replay again, and won't remove the subscription from PersistentTopic which is already created.
It will lead to an unexpected situation: we couldn't create Consumers on the subscription.
Because in PersistentTopic#subscriptions, the subscription already exists, but initialized failed.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: tjiuming#15

@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2022

Codecov Report

Merging #18886 (5e3b841) into master (3180a4a) will decrease coverage by 7.37%.
The diff coverage is 44.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #18886      +/-   ##
============================================
- Coverage     46.17%   38.79%   -7.38%     
+ Complexity    10359     3027    -7332     
============================================
  Files           703      289     -414     
  Lines         68845    24154   -44691     
  Branches       7382     2805    -4577     
============================================
- Hits          31788     9371   -22417     
+ Misses        33448    13632   -19816     
+ Partials       3609     1151    -2458     
Flag Coverage Δ
unittests 38.79% <44.00%> (-7.38%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...va/org/apache/pulsar/client/impl/ConsumerImpl.java 15.09% <0.00%> (-0.04%) ⬇️
...he/pulsar/client/impl/MultiTopicsConsumerImpl.java 22.78% <0.00%> (-0.09%) ⬇️
...va/org/apache/pulsar/client/impl/ProducerImpl.java 16.83% <0.00%> (-0.17%) ⬇️
.../apache/pulsar/client/impl/BatchMessageIdImpl.java 67.50% <100.00%> (-4.73%) ⬇️
...a/org/apache/pulsar/client/impl/MessageIdImpl.java 80.85% <100.00%> (+0.29%) ⬆️
.../apache/pulsar/client/impl/MultiMessageIdImpl.java 80.55% <100.00%> (+7.58%) ⬆️
...g/apache/bookkeeper/mledger/util/StatsBuckets.java 43.75% <0.00%> (-16.67%) ⬇️
...ookkeeper/mledger/impl/ManagedLedgerMBeanImpl.java 53.17% <0.00%> (-9.53%) ⬇️
.../org/apache/pulsar/client/impl/ConnectionPool.java 37.43% <0.00%> (-1.03%) ⬇️
...rg/apache/pulsar/client/impl/PulsarClientImpl.java 43.85% <0.00%> (-0.95%) ⬇️
... and 418 more

@tjiuming tjiuming changed the title [fix][broker] Fix PendingAckHandleImpl when relay failed. [fix][broker] Fix PendingAckHandleImpl when replay failed. Dec 19, 2022
@github-actions
Copy link

The pr had no activity for 30 days, mark with Stale label.

@github-actions github-actions bot added the Stale label Jan 19, 2023
# Conflicts:
#	pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
#	pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/PersistentTopicTest.java
retryClose();
return null;
});
}, 20, TimeUnit.SECONDS);
Copy link
Contributor

Choose a reason for hiding this comment

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

20 seconds ?
Probably we have to log at WARN level something like

log.warn("Re-scheduling closing of subscription {} in 20 seconds")

Copy link
Contributor

@congbobo184 congbobo184 left a comment

Choose a reason for hiding this comment

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

if recover fail, we only need to close the sub then remove the sub from the PersistentTopic.subscriptions is enough.
https://github.com/nicoloboschi/pulsar/blob/8eb7ee1e9e96d4686e452320cdaba92d5eca7b4f/pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/pendingack/impl/PendingAckHandleImpl.java#L947-L952
add logic into this method

log.warn("PersistentSubscription [{}] pendingAckHandleImpl relay failed "
+ "when initialize topic [{}].", subscriptionName, topic, t);
if (subscriptions.remove(subscriptionName, subscription)) {
subscription.retryClose();
Copy link
Contributor

Choose a reason for hiding this comment

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

why should add this method? persistentTopic init sub then remove will return false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it may happen.

subscription.getInitializeFuture()
                        .exceptionally(t -> {
                              // ignore...
                        })

will be executed after the topic created. If a consumer connected the topic and unsubscribe the topic, subscriptions.remove(...) may return false.

@dao-jun
Copy link
Member

dao-jun commented Dec 19, 2023

Will be fixed by #21760

@dao-jun dao-jun closed this Dec 19, 2023
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.

8 participants