-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Use asyncCloseCursorLedger to replace cursorLedger.asyncClose method in the ManagedCursorImpl.VoidCallback#operationComplete #12113
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
Conversation
eolivelli
left a comment
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.
LGTM
|
@lordcheng10 Thanks for your contribution. For this PR, do we need to update docs? (The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks) |
OK, I'd be happy to update the document |
@Anonymitaet I searched for the document about this method in the project, but did not find any document related to this method, so there is no need to modify the document. |
michaeljmarshall
left a comment
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.
It almost seems to me that this method should have been used to close the cursor ledger here:
pulsar/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
Lines 2235 to 2250 in 0a1ae98
| public void operationComplete() { | |
| log.info("[{}][{}] Updated md-position={} into cursor-ledger {}", ledger.getName(), name, | |
| markDeletePosition, cursorLedger.getId()); | |
| cursorLedger.asyncClose((rc, lh, ctx1) -> { | |
| callback.closeComplete(ctx); | |
| if (rc == BKException.Code.OK) { | |
| log.info("[{}][{}] Closed cursor-ledger {}", ledger.getName(), name, | |
| cursorLedger.getId()); | |
| } else { | |
| log.warn("[{}][{}] Failed to close cursor-ledger {}: {}", ledger.getName(), name, | |
| cursorLedger.getId(), BKException.getMessage(rc)); | |
| } | |
| }, ctx); | |
| } |
The logic of this asyncCloseCursorLedger method is quite similar, but not identical, to the above code block. Specifically, this asyncCloseCursorLedger method has metrics and fails the callback if the close fails. I wonder if its worth updating the persistPositionWhenClosing method to use this currently unused method.
If we do decide to remove asyncCloseCursorLedger, I think if we should either update persistPositionWhenClosing to increment/decrement the cursorLedgerCloseOp or remove the cursorLedgerCloseOp metric, as well as its references, from the ledger.mbean, since it is only updated within this method.
@eolivelli - do you have any thoughts on the right direction here? Thanks.
@michaeljmarshall |
|
I agree that it seems appropriate to use |
@codelipenghui @lhotari @merlimat @BewareMyPower - PTAL, thanks. |
michaeljmarshall
left a comment
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.
LGTM. From my perspective, this PR changes the callback behavior to the expected behavior. We should call the closeFailed callback method when we fail to close the cursor ledger.
@lordcheng10 - now that we're changing direction on this PR, we should update the title so that the commit message will align with the actual change. It might also be a good idea to update the asyncCloseCursorLedger method to log the two removed log lines.
Based on quickly looking at usage for the persistPositionWhenClosing method, it looks like the only code that will change fundamental behavior is here:
Lines 120 to 135 in 0460472
| cursor.asyncClose(new AsyncCallbacks.CloseCallback() { | |
| @Override | |
| public void closeComplete(Object ctx) { | |
| try { | |
| managedLedger.close(); | |
| } catch (Exception e) { | |
| completableFuture.completeExceptionally(e); | |
| } | |
| completableFuture.complete(null); | |
| } | |
| @Override | |
| public void closeFailed(ManagedLedgerException exception, Object ctx) { | |
| completableFuture.completeExceptionally(exception); | |
| } | |
| }, null); |
No other methods have branching behavior in their callback based on closeComplete vs closeFailure.
@congbobo184 - you wrote the above code block for transactions. Will it be a problem to change behavior as this PR proposes?
As you described, I added two logs in asyncCloseCursorLedger and updated the title |
|
@eolivelli, @codelipenghui, @BewareMyPower, @sijie, @hangc0276, @merlimat - PTAL, thanks. |
|
/pulsarbot run-failure-checks |
|
CI has passed @BewareMyPower @michaeljmarshall PTAL ,thanks! |
|
@congbobo184 could you answer the question from @michaeljmarshall ? |
|
@congbobo184 PTAL ,thanks! |
|
LGTM!#12113 (comment) this seem to a bug. This is a bug, can you fix it easily? Future completed twice.thanks |
Yeah. I will fix |
@congbobo184 fix bug: #12362 |
* up/master: (37 commits) re-enabling integration tests for Sinks (apache#12307) [PIP 95][Issue 12040][web] Topic lookup with listener header (apache#12072) Fix the master CI broken with update dispatch rate block issue (apache#12360) Fix message being ignored when the non-persistent topic reader reconnect. (apache#12348) Fix log format. (apache#12346) [website][upgrade]feat: docs migration - version-2.7.2 Concepts and Architecture (apache#12354) [website][upgrade] feat: full docs migration for version 2.8.0 (apache#12359) [website][upgrade]feat: dynamic replace version info before build (apache#12337) Fix flaky tests: ElasticSearchClientTests (apache#12347) Use asyncCloseCursorLedger to replace cursorLedger.asyncClose method in the ManagedCursorImpl.VoidCallback#operationComplete (apache#12113) fix-npe-ZkBookieRackAffinityMapping (apache#11947) [pulsar-admin] Allow setting --forward-source-message-property to false when updating a pulsar function (apache#12128) [website][upgrade]feat: docs migration - Development (apache#12320) Update delete inactive topic configuration documentation (apache#12350) [PIP 95][Issue 12040][broker] Multiple bind addresses for Pulsar protocol (apache#12056) Added Debezium Source for MS SQL Server (apache#12256) Fix: flaky oracle tests (apache#12306) [C++] Use URL encoded content type for OAuth 2.0 authentication (apache#12341) [C++] Handle OAuth 2.0 exceptional cases gracefully (apache#12335) feat(cli): add restart command to pulsar-daemon (apache#12279) ... # Conflicts: # site2/website-next/docusaurus.config.js # site2/website-next/versioned_sidebars/version-2.7.2-sidebars.json # site2/website-next/versions.json
…in the ManagedCursorImpl.VoidCallback#operationComplete (apache#12113) The org.apache.bookkeeper.mledger.impl.ManagedCursorImpl#asyncCloseCursorLedger method is an unused method, delete the redundant method
Use asyncCloseCursorLedger to replace cursorLedger.asyncClose method in the ManagedCursorImpl.VoidCallback#operationComplete