You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/10/20 14:28:44 UTC

[GitHub] [pulsar] poorbarcode commented on a diff in pull request #18123: [test][ml]Add test:Ensure that cursor data is not lost if the recover timeout fails and the retry succeeds

poorbarcode commented on code in PR #18123:
URL: https://github.com/apache/pulsar/pull/18123#discussion_r1000713957


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java:
##########
@@ -500,6 +502,15 @@ protected void recoverFromLedger(final ManagedCursorInfo info, final VoidCallbac
             if (log.isInfoEnabled()) {
                 log.info("[{}] Opened ledger {} for consumer {}. rc={}", ledger.getName(), ledgerId, name, rc);
             }
+            // If ledgerMeta exists, it means ledger is not deleted normally and bookie is trying to recover the data.
+            // We will make several attempts to ensure that do not lose cursor data.
+            if (maybeLedgerRecovering(rc) && retryTimesWhenLedgerRecovering > 0) {
+                log.warn("[{}] Opened ledger {} for consumer {}. rc={}. Ledger maybe is recovering,"
+                        + " try to recover again, at most try {} times", ledger.getName(), ledgerId, name, rc,
+                        retryTimesWhenLedgerRecovering - 1);
+                recoverFromLedger(info, callback, retryTimesWhenLedgerRecovering - 1);
+                return;
+            }

Review Comment:
   Hi @codelipenghui @mattisonchao 
   
   > I think treating the TimeoutException as a recoverable error is simple here. We are not able to load the data from the bookkeeper now. Just let the topic load get failed. The client side will trigger the topic loading again.
   
   Good idea. I have submit a PR to make the timeout ex use a separate error code



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org