sijie commented on a change in pull request #1461: If cursor update to BK 
fails, fallback to meta store
URL: https://github.com/apache/incubator-pulsar/pull/1461#discussion_r177638796
 
 

 ##########
 File path: 
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
 ##########
 @@ -2055,7 +2056,26 @@ void persistPositionToLedger(final LedgerHandle lh, 
MarkDeleteEntry mdEntry, fin
                 // If we've had a write error, the ledger will be 
automatically closed, we need to create a new one,
                 // in the meantime the mark-delete will be queued.
                 STATE_UPDATER.compareAndSet(ManagedCursorImpl.this, 
State.Open, State.NoLedger);
-                callback.operationFailed(createManagedLedgerException(rc));
+
+                // Before giving up, try to persist the position in the 
metadata store
+                persistPositionMetaStore(-1, position, mdEntry.properties, new 
MetaStoreCallback<Void>() {
+                    @Override
+                    public void operationComplete(Void result, Stat stat) {
+                        if (log.isDebugEnabled()) {
+                            log.debug(
+                                    "[{}][{}] Updated cursor in meta store 
after previous failure in ledger at position {}",
+                                    position);
+                        }
+                        callback.operationComplete();
+                    }
+
+                    @Override
+                    public void operationFailed(MetaStoreException e) {
+                        log.warn("[{}][{}] Failed to update cursor in meta 
store after previous failure in ledger: {}",
 
 Review comment:
   missing logging arguments?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to