Skip to content

Commit fe0e41f

Browse files
committed
Fix case where callable comes with its own RetryingTimeTracker
1 parent 7768edd commit fe0e41f

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,28 @@ SingleServerRequestRunnable createSingleServerRequest(MultiAction multiAction, i
409409
return new SingleServerRequestRunnable(multiAction, numAttempt, server, callsInProgress);
410410
}
411411

412+
/**
413+
* Some checked calls send a callable with their own tracker. This method checks the operation
414+
* timeout against the appropriate tracker, or returns false if no tracker.
415+
*/
416+
private boolean isOperationTimeoutExceeded() {
417+
RetryingTimeTracker currentTracker;
418+
if (tracker != null) {
419+
currentTracker = tracker;
420+
} else if (currentCallable != null && currentCallable.getTracker() != null) {
421+
currentTracker = currentCallable.getTracker();
422+
} else {
423+
return false;
424+
}
425+
426+
// no-op if already started, this is just to ensure it was initialized (usually true)
427+
currentTracker.start();
428+
429+
// return value of 1 is special to mean exceeded, to differentiate from 0
430+
// which is no timeout. see implementation of getRemainingTime
431+
return currentTracker.getRemainingTime(operationTimeout) == 1;
432+
}
433+
412434
/**
413435
* Group a list of actions per region servers, and send them.
414436
* @param currentActions - the list of row to submit
@@ -420,9 +442,7 @@ void groupAndSendMultiAction(List<Action> currentActions, int numAttempt) {
420442
boolean isReplica = false;
421443
List<Action> unknownReplicaActions = null;
422444
for (Action action : currentActions) {
423-
if (tracker.getRemainingTime(operationTimeout) == 1) {
424-
// return value of 1 is special to mean exceeded, to differentiate from 0
425-
// which is no timeout. see implementation of getRemainingTime
445+
if (isOperationTimeoutExceeded()) {
426446
String message = numAttempt == 1
427447
? "Operation timeout exceeded during resolution of region locations, "
428448
+ "prior to executing any actions."

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,8 @@ protected ClientProtos.ScanResponse doScan(ClientProtos.ScanRequest request)
122122
throws org.apache.hbase.thirdparty.com.google.protobuf.ServiceException {
123123
return getStub().cleanupBulkLoad(getRpcController(), request);
124124
}
125+
126+
RetryingTimeTracker getTracker() {
127+
return tracker;
128+
}
125129
}

0 commit comments

Comments
 (0)