Skip to content

Commit 308cd72

Browse files
briaugenreichBriana Augenreich
andauthored
HBASE-26809: Report client backoff time for server overloaded (#4729)
Co-authored-by: Briana Augenreich <baugenreich@hubspot.com> Signed-off-by: Duo Zhang <zhangduo@apache.org>
1 parent 10d85f3 commit 308cd72

4 files changed

Lines changed: 25 additions & 0 deletions

File tree

hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,11 @@ private void tryResubmit(Stream<Action> actions, int tries, boolean immediately,
487487
} else {
488488
delayNs = getPauseTime(pauseNsToUse, tries - 1);
489489
}
490+
491+
if (isServerOverloaded) {
492+
Optional<MetricsConnection> metrics = conn.getConnectionMetrics();
493+
metrics.ifPresent(m -> m.incrementServerOverloadedBackoffTime(delayNs, TimeUnit.NANOSECONDS));
494+
}
490495
retryTimer.newTimeout(t -> groupAndSend(actions, tries + 1), delayNs, TimeUnit.NANOSECONDS);
491496
}
492497

hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRpcRetryingCaller.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ private void tryScheduleRetry(Throwable error) {
139139
delayNs = getPauseTime(pauseNsToUse, tries - 1);
140140
}
141141
tries++;
142+
if (HBaseServerException.isServerOverloaded(error)) {
143+
Optional<MetricsConnection> metrics = conn.getConnectionMetrics();
144+
metrics.ifPresent(m -> m.incrementServerOverloadedBackoffTime(delayNs, TimeUnit.NANOSECONDS));
145+
}
142146
retryTimer.newTimeout(t -> doCall(), delayNs, TimeUnit.NANOSECONDS);
143147
}
144148

hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncScanSingleRegionRpcRetryingCaller.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ class AsyncScanSingleRegionRpcRetryingCaller {
113113

114114
private final Runnable completeWhenNoMoreResultsInRegion;
115115

116+
private final AsyncConnectionImpl conn;
117+
116118
private final CompletableFuture<Boolean> future;
117119

118120
private final HBaseRpcController controller;
@@ -318,6 +320,7 @@ public AsyncScanSingleRegionRpcRetryingCaller(Timer retryTimer, AsyncConnectionI
318320
long pauseNsForServerOverloaded, int maxAttempts, long scanTimeoutNs, long rpcTimeoutNs,
319321
int startLogErrorsCnt) {
320322
this.retryTimer = retryTimer;
323+
this.conn = conn;
321324
this.scan = scan;
322325
this.scanMetrics = scanMetrics;
323326
this.scannerId = scannerId;
@@ -441,6 +444,11 @@ private void onError(Throwable error) {
441444
return;
442445
}
443446
tries++;
447+
448+
if (HBaseServerException.isServerOverloaded(error)) {
449+
Optional<MetricsConnection> metrics = conn.getConnectionMetrics();
450+
metrics.ifPresent(m -> m.incrementServerOverloadedBackoffTime(delayNs, TimeUnit.NANOSECONDS));
451+
}
444452
retryTimer.newTimeout(t -> call(), delayNs, TimeUnit.NANOSECONDS);
445453
}
446454

hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ public Counter newMetric(Class<?> clazz, String name, String scope) {
315315
protected final Histogram numActionsPerServerHist;
316316
protected final Counter nsLookups;
317317
protected final Counter nsLookupsFailed;
318+
protected final Timer overloadedBackoffTimer;
318319

319320
// dynamic metrics
320321

@@ -376,6 +377,8 @@ protected Ratio getRatio() {
376377
registry.histogram(name(MetricsConnection.class, "numActionsPerServer", scope));
377378
this.nsLookups = registry.counter(name(this.getClass(), NS_LOOKUPS, scope));
378379
this.nsLookupsFailed = registry.counter(name(this.getClass(), NS_LOOKUPS_FAILED, scope));
380+
this.overloadedBackoffTimer =
381+
registry.timer(name(this.getClass(), "overloadedBackoffDurationMs", scope));
379382

380383
this.reporter = JmxReporter.forRegistry(this.registry).build();
381384
this.reporter.start();
@@ -449,6 +452,11 @@ public void incrDelayRunnersAndUpdateDelayInterval(long interval) {
449452
this.runnerStats.updateDelayInterval(interval);
450453
}
451454

455+
/** Update the overloaded backoff time **/
456+
public void incrementServerOverloadedBackoffTime(long time, TimeUnit timeUnit) {
457+
overloadedBackoffTimer.update(time, timeUnit);
458+
}
459+
452460
/**
453461
* Get a metric for {@code key} from {@code map}, or create it with {@code factory}.
454462
*/

0 commit comments

Comments
 (0)