-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[branch-2.9][cherry-pick] Close TransactionBuffer when MessageDeduplication#checkStatus failed #19287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[branch-2.9][cherry-pick] Close TransactionBuffer when MessageDeduplication#checkStatus failed #19287
Changes from all commits
07a8c2f
585553d
deb4400
6376d42
4c66310
44c6423
69d200d
aca0911
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1325,6 +1325,12 @@ private void checkOwnershipAndCreatePersistentTopic(final String topic, boolean | |
| }); | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
| public void createPersistentTopic0(final String topic, boolean createIfMissing, | ||
| CompletableFuture<Optional<Topic>> topicFuture) { | ||
| createPersistentTopic(topic, createIfMissing, topicFuture); | ||
| } | ||
|
|
||
| private void createPersistentTopic(final String topic, boolean createIfMissing, | ||
| CompletableFuture<Optional<Topic>> topicFuture) { | ||
| final long topicCreateTimeMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); | ||
|
|
@@ -1367,7 +1373,7 @@ public void openLedgerComplete(ManagedLedger ledger, Object ctx) { | |
| try { | ||
| PersistentTopic persistentTopic = isSystemTopic(topic) | ||
| ? new SystemTopic(topic, ledger, BrokerService.this) | ||
| : new PersistentTopic(topic, ledger, BrokerService.this); | ||
| : newPersistentTopic(topic, ledger, BrokerService.this); | ||
| CompletableFuture<Void> preCreateSubForCompaction = | ||
| persistentTopic.preCreateSubscriptionForCompactionIfNeeded(); | ||
| CompletableFuture<Void> replicationFuture = persistentTopic | ||
|
|
@@ -1400,6 +1406,12 @@ public void openLedgerComplete(ManagedLedger ledger, Object ctx) { | |
| "Replication or dedup check failed." | ||
| + " Removing topic from topics list {}, {}", | ||
| topic, ex); | ||
| persistentTopic.getTransactionBuffer() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add this similar logic to line
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great catch! |
||
| .closeAsync() | ||
| .exceptionally(t -> { | ||
| log.error("[{}] Close transactionBuffer failed", topic, t); | ||
| return null; | ||
| }); | ||
| persistentTopic.stopReplProducers().whenCompleteAsync((v, exception) -> { | ||
| topics.remove(topic, topicFuture); | ||
| topicFuture.completeExceptionally(ex); | ||
|
|
@@ -2947,6 +2959,11 @@ public long getPausedConnections() { | |
| return pausedConnections.longValue(); | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
| public PersistentTopic newPersistentTopic(String topic, ManagedLedger ledger, BrokerService brokerService){ | ||
| return new PersistentTopic(topic, ledger, brokerService); | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
| public void setPulsarChannelInitializerFactory(PulsarChannelInitializer.Factory factory) { | ||
| this.pulsarChannelInitFactory = factory; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't use
BrokerService#getTopic?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes we can use the method, but when I wrote the test, I chose this method