diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java index 9c4760b236c..1ac6b948ce4 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java @@ -878,13 +878,15 @@ CompletableFuture readEntriesInternalAsync(long firstEntry, // Naturally one of the solutions would be to submit smaller batches and in this case // current implementation will prevent next batch from starting when bookie is // unresponsive thus helpful enough. - DistributionSchedule.WriteSet ws = distributionSchedule.getWriteSet(firstEntry); - try { - if (!waitForWritable(ws, ws.size() - 1, clientCtx.getConf().waitForWriteSetMs)) { - op.allowFailFastOnUnwritableChannel(); + if (clientCtx.getConf().waitForWriteSetMs >= 0) { + DistributionSchedule.WriteSet ws = distributionSchedule.getWriteSet(firstEntry); + try { + if (!waitForWritable(ws, ws.size() - 1, clientCtx.getConf().waitForWriteSetMs)) { + op.allowFailFastOnUnwritableChannel(); + } + } finally { + ws.recycle(); } - } finally { - ws.recycle(); } if (isHandleWritable()) { @@ -1341,13 +1343,15 @@ public String toString() { return; } - DistributionSchedule.WriteSet ws = distributionSchedule.getWriteSet(op.getEntryId()); - try { - if (!waitForWritable(ws, 0, clientCtx.getConf().waitForWriteSetMs)) { - op.allowFailFastOnUnwritableChannel(); + if (clientCtx.getConf().waitForWriteSetMs >= 0) { + DistributionSchedule.WriteSet ws = distributionSchedule.getWriteSet(op.getEntryId()); + try { + if (!waitForWritable(ws, 0, clientCtx.getConf().waitForWriteSetMs)) { + op.allowFailFastOnUnwritableChannel(); + } + } finally { + ws.recycle(); } - } finally { - ws.recycle(); } try { diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandleAdv.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandleAdv.java index 1bdc653650f..52a3f4594db 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandleAdv.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandleAdv.java @@ -263,9 +263,15 @@ public String toString() { return; } - if (!waitForWritable(distributionSchedule.getWriteSet(op.getEntryId()), - 0, clientCtx.getConf().waitForWriteSetMs)) { - op.allowFailFastOnUnwritableChannel(); + if (clientCtx.getConf().waitForWriteSetMs >= 0) { + DistributionSchedule.WriteSet ws = distributionSchedule.getWriteSet(op.getEntryId()); + try { + if (!waitForWritable(ws, 0, clientCtx.getConf().waitForWriteSetMs)) { + op.allowFailFastOnUnwritableChannel(); + } + } finally { + ws.recycle(); + } } try {