Skip to content

Commit 23cd0d1

Browse files
author
zhiyuanlei
committed
Merge branch 'feat/replicator_worker' into '4.14.4_csig' (merge request !24)
feat: support retry in replicator worker
2 parents 4ef8da7 + b94b523 commit 23cd0d1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerUnderreplicationManager.java

+12
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,10 @@ public void releaseUnderreplicatedLedger(long ledgerId) throws ReplicationExcept
636636
}
637637
} catch (KeeperException.NoNodeException nne) {
638638
// this is ok
639+
} catch (KeeperException.ConnectionLossException | KeeperException.SessionExpiredException ke) {
640+
LOG.error("Error deleting underreplicated ledger lock,we need to retry", ke);
641+
waitBackOffTime(1000);
642+
releaseUnderreplicatedLedger(ledgerId);
639643
} catch (KeeperException ke) {
640644
LOG.error("Error deleting underreplicated ledger lock", ke);
641645
throw new ReplicationException.UnavailableException("Error contacting zookeeper", ke);
@@ -646,6 +650,14 @@ public void releaseUnderreplicatedLedger(long ledgerId) throws ReplicationExcept
646650
heldLocks.remove(ledgerId);
647651
}
648652

653+
private static void waitBackOffTime(long backoffMs) {
654+
try {
655+
Thread.sleep(backoffMs);
656+
} catch (InterruptedException e) {
657+
Thread.currentThread().interrupt();
658+
}
659+
}
660+
649661
@Override
650662
public void close() throws ReplicationException.UnavailableException {
651663
if (LOG.isDebugEnabled()) {

0 commit comments

Comments
 (0)