codelipenghui commented on code in PR #17164:
URL: https://github.com/apache/pulsar/pull/17164#discussion_r972700657


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java:
##########
@@ -350,21 +356,48 @@ public void operationComplete(Void result, Stat stat) {
                     public void operationFailed(MetaStoreException e) {
                         log.error("[{}] Error while updating ledger cursor: {} 
properties {}", ledger.getName(),
                                 name, cursorProperties, e);
-                        updateCursorPropertiesResult.completeExceptionally(e);
+                        // if resource is updated by other operate then we 
will get bad-version exception
+                        // so, retry the operation.
+                        if (e instanceof 
ManagedLedgerException.BadVersionException) {
+                            
asyncReadAndUpdateCursorProperties(updateFunction).whenComplete((__, ex) -> {

Review Comment:
   > computeCursorProperties(Function<Map<String, String>, Map<String, String>> 
updateFunction) instead of setCursorProperties(Map<String, String> 
cursorProperties)
   
   We can add it after we confirm we really need it.
   
   > It looks like giving the callers handle the update conflict is better. Can 
we add a parameter to choose whether need to automatically retry?
   
   IMO, we can just fail the request with BadVersionException. Let the caller 
make the decision, for the most case I think they can just treat it as a 
RuntimeException.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to