Skip to content

Commit 9c504f5

Browse files
authored
[improve][broker]Improve the log when encountered in-flight read limitation (apache#24359)
1 parent 8db6a3b commit 9c504f5

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/cache/InflightReadsLimiter.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,13 @@ private synchronized Optional<Handle> internalAcquire(long permits, Consumer<Han
177177
return Optional.of(new Handle(maxReadsInFlightSize, handle.creationTime, true));
178178
} else {
179179
if (queuedHandles.size() >= maxReadsInFlightAcquireQueueSize) {
180-
log.warn("Failed to queue handle for acquiring permits: {}, creationTime: {}, remainingBytes:{}",
181-
permits, handle.creationTime, remainingBytes);
180+
log.warn("Failed to queue handle for acquiring permits: {}, creationTime: {}, remainingBytes:{},"
181+
+ " maxReadsInFlightAcquireQueueSize:{}, pending-queue-size: {}, please increase broker"
182+
+ " config managedLedgerMaxReadsInFlightPermitsAcquireQueueSize and confirm the configuration of"
183+
+ " managedLedgerMaxReadsInFlightSizeInMB and"
184+
+ " managedLedgerMaxReadsInFlightPermitsAcquireTimeoutMillis are suitable.",
185+
permits, handle.creationTime, remainingBytes, maxReadsInFlightAcquireQueueSize,
186+
queuedHandles.size());
182187
return Optional.of(new Handle(0, handle.creationTime, false));
183188
} else {
184189
queuedHandles.offer(new QueuedHandle(handle, callback));
@@ -223,15 +228,17 @@ private synchronized void timeoutCheck() {
223228
}
224229

225230
private void handleTimeout(QueuedHandle queuedHandle) {
226-
if (log.isDebugEnabled()) {
227-
log.debug("timed out queued permits: {}, creationTime: {}, remainingBytes:{}",
228-
queuedHandle.handle.permits, queuedHandle.handle.creationTime, remainingBytes);
229-
}
231+
log.warn("timed out queued permits: {}, creationTime: {}, remainingBytes:{}, acquireTimeoutMillis: {}. Please"
232+
+ " review whether the BK read requests is fast enough or broker config"
233+
+ " managedLedgerMaxReadsInFlightSizeInMB and managedLedgerMaxReadsInFlightPermitsAcquireTimeoutMillis"
234+
+ " are suitable",
235+
queuedHandle.handle.permits, queuedHandle.handle.creationTime, remainingBytes, acquireTimeoutMillis);
230236
try {
231237
queuedHandle.callback.accept(new Handle(0, queuedHandle.handle.creationTime, false));
232238
} catch (Exception e) {
233-
log.error("Error in callback of timed out queued permits: {}, creationTime: {}, remainingBytes:{}",
234-
queuedHandle.handle.permits, queuedHandle.handle.creationTime, remainingBytes, e);
239+
log.error("Error in callback of timed out queued permits: {}, creationTime: {}, remainingBytes:{},"
240+
+ " acquireTimeoutMillis: {}",
241+
queuedHandle.handle.permits, queuedHandle.handle.creationTime, remainingBytes, acquireTimeoutMillis, e);
235242
}
236243
}
237244

managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/cache/RangeEntryCacheImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,10 @@ void doAsyncReadEntriesWithAcquiredPermits(ReadHandle lh, Position firstPosition
335335
String message = String.format(
336336
"Couldn't acquire enough permits on the max reads in flight limiter to read from ledger "
337337
+ "%d, %s, estimated read size %d bytes for %d entries (check "
338-
+ "managedLedgerMaxReadsInFlightSizeInMB, "
338+
+ "managedLedgerMaxReadsInFlightPermitsAcquireQueueSize (direct config), "
339339
+ "managedLedgerMaxReadsInFlightPermitsAcquireTimeoutMillis and "
340-
+ "managedLedgerMaxReadsInFlightPermitsAcquireQueueSize)", lh.getId(), getName(),
340+
+ "managedLedgerMaxReadsInFlightSizeInMB)", lh.getId(), getName(),
341341
estimatedReadSize, numberOfEntries);
342-
log.error(message);
343342
originalCallback.readEntriesFailed(new ManagedLedgerException.TooManyRequestsException(message), ctx);
344343
return;
345344
}

0 commit comments

Comments
 (0)