|
45 | 45 | import java.util.stream.Collectors; |
46 | 46 | import java.util.stream.Stream; |
47 | 47 | import org.apache.commons.lang3.mutable.MutableBoolean; |
| 48 | +import org.apache.hadoop.hbase.CallQueueTooBigException; |
48 | 49 | import org.apache.hadoop.hbase.CellScannable; |
49 | 50 | import org.apache.hadoop.hbase.DoNotRetryIOException; |
50 | 51 | import org.apache.hadoop.hbase.HConstants; |
@@ -103,6 +104,8 @@ class AsyncBatchRpcRetryingCaller<T> { |
103 | 104 |
|
104 | 105 | private final long pauseNs; |
105 | 106 |
|
| 107 | + private final long pauseForCQTBENs; |
| 108 | + |
106 | 109 | private final int maxAttempts; |
107 | 110 |
|
108 | 111 | private final long operationTimeoutNs; |
@@ -147,17 +150,17 @@ public int getPriority() { |
147 | 150 | } |
148 | 151 |
|
149 | 152 | public AsyncBatchRpcRetryingCaller(Timer retryTimer, AsyncConnectionImpl conn, |
150 | | - TableName tableName, List<? extends Row> actions, long pauseNs, int maxAttempts, |
151 | | - long operationTimeoutNs, long rpcTimeoutNs, int startLogErrorsCnt) { |
| 153 | + TableName tableName, List<? extends Row> actions, long pauseNs, long pauseForCQTBENs, |
| 154 | + int maxAttempts, long operationTimeoutNs, long rpcTimeoutNs, int startLogErrorsCnt) { |
152 | 155 | this.retryTimer = retryTimer; |
153 | 156 | this.conn = conn; |
154 | 157 | this.tableName = tableName; |
155 | 158 | this.pauseNs = pauseNs; |
| 159 | + this.pauseForCQTBENs = pauseForCQTBENs; |
156 | 160 | this.maxAttempts = maxAttempts; |
157 | 161 | this.operationTimeoutNs = operationTimeoutNs; |
158 | 162 | this.rpcTimeoutNs = rpcTimeoutNs; |
159 | 163 | this.startLogErrorsCnt = startLogErrorsCnt; |
160 | | - |
161 | 164 | this.actions = new ArrayList<>(actions.size()); |
162 | 165 | this.futures = new ArrayList<>(actions.size()); |
163 | 166 | this.action2Future = new IdentityHashMap<>(actions.size()); |
@@ -337,7 +340,7 @@ private void onComplete(Map<byte[], RegionRequest> actionsByRegion, int tries, |
337 | 340 | } |
338 | 341 | }); |
339 | 342 | if (!failedActions.isEmpty()) { |
340 | | - tryResubmit(failedActions.stream(), tries, retryImmediately.booleanValue()); |
| 343 | + tryResubmit(failedActions.stream(), tries, retryImmediately.booleanValue(), false); |
341 | 344 | } |
342 | 345 | } |
343 | 346 |
|
@@ -442,24 +445,27 @@ private void onError(Map<byte[], RegionRequest> actionsByRegion, int tries, Thro |
442 | 445 | List<Action> copiedActions = actionsByRegion.values().stream().flatMap(r -> r.actions.stream()) |
443 | 446 | .collect(Collectors.toList()); |
444 | 447 | addError(copiedActions, error, serverName); |
445 | | - tryResubmit(copiedActions.stream(), tries, error instanceof RetryImmediatelyException); |
| 448 | + tryResubmit(copiedActions.stream(), tries, error instanceof RetryImmediatelyException, |
| 449 | + error instanceof CallQueueTooBigException); |
446 | 450 | } |
447 | 451 |
|
448 | | - private void tryResubmit(Stream<Action> actions, int tries, boolean immediately) { |
| 452 | + private void tryResubmit(Stream<Action> actions, int tries, boolean immediately, |
| 453 | + boolean isCallQueueTooBig) { |
449 | 454 | if (immediately) { |
450 | 455 | groupAndSend(actions, tries); |
451 | 456 | return; |
452 | 457 | } |
453 | 458 | long delayNs; |
| 459 | + long pauseNsToUse = isCallQueueTooBig ? pauseForCQTBENs : pauseNs; |
454 | 460 | if (operationTimeoutNs > 0) { |
455 | 461 | long maxDelayNs = remainingTimeNs() - SLEEP_DELTA_NS; |
456 | 462 | if (maxDelayNs <= 0) { |
457 | 463 | failAll(actions, tries); |
458 | 464 | return; |
459 | 465 | } |
460 | | - delayNs = Math.min(maxDelayNs, getPauseTime(pauseNs, tries - 1)); |
| 466 | + delayNs = Math.min(maxDelayNs, getPauseTime(pauseNsToUse, tries - 1)); |
461 | 467 | } else { |
462 | | - delayNs = getPauseTime(pauseNs, tries - 1); |
| 468 | + delayNs = getPauseTime(pauseNsToUse, tries - 1); |
463 | 469 | } |
464 | 470 | retryTimer.newTimeout(t -> groupAndSend(actions, tries + 1), delayNs, TimeUnit.NANOSECONDS); |
465 | 471 | } |
@@ -498,7 +504,7 @@ private void groupAndSend(Stream<Action> actions, int tries) { |
498 | 504 | sendOrDelay(actionsByServer, tries); |
499 | 505 | } |
500 | 506 | if (!locateFailed.isEmpty()) { |
501 | | - tryResubmit(locateFailed.stream(), tries, false); |
| 507 | + tryResubmit(locateFailed.stream(), tries, false, false); |
502 | 508 | } |
503 | 509 | }); |
504 | 510 | } |
|
0 commit comments