Skip to content

Commit

Permalink
HBASE-26027 The calling of HTable.batch blocked at AsyncRequestFuture…
Browse files Browse the repository at this point in the history
…Impl.waitUntilDone caused by ArrayStoreException (#3925)

* HBASE-26027 The calling of HTable.batch blocked at AsyncRequestFutureImpl.waitUntilDone caused by ArrayStoreException
  • Loading branch information
bsglz authored Dec 10, 2021
1 parent b1bc5f3 commit 26e37bc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -1132,7 +1133,17 @@ private String buildDetailedErrorMsg(String string, int index) {
@Override
public void waitUntilDone() throws InterruptedIOException {
try {
waitUntilDone(Long.MAX_VALUE);
if (this.operationTimeout > 0) {
// the worker thread maybe over by some exception without decrement the actionsInProgress,
// then the guarantee of operationTimeout will be broken, so we should set cutoff to avoid
// stuck here forever
long cutoff = (EnvironmentEdgeManager.currentTime() + this.operationTimeout) * 1000L;
if (!waitUntilDone(cutoff)) {
throw new SocketTimeoutException("time out before the actionsInProgress changed to zero");
}
} else {
waitUntilDone(Long.MAX_VALUE);
}
} catch (InterruptedException iex) {
throw new InterruptedIOException(iex.getMessage());
} finally {
Expand All @@ -1144,7 +1155,7 @@ public void waitUntilDone() throws InterruptedIOException {
}
}

private boolean waitUntilDone(long cutoff) throws InterruptedException {
private boolean waitUntilDone(long cutoff) throws InterruptedException{
boolean hasWait = cutoff != Long.MAX_VALUE;
long lastLog = EnvironmentEdgeManager.currentTime();
long currentInProgress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.RetriesExhaustedException;
import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
Expand Down Expand Up @@ -158,7 +157,7 @@ public void testPutTimeout() {
}

/**
* Tests that a batch mutate on a table throws {@link RetriesExhaustedException} when the
* Tests that a batch mutate on a table throws {@link SocketTimeoutException} when the
* operation takes longer than 'hbase.client.operation.timeout'.
*/
@Test
Expand All @@ -175,7 +174,7 @@ public void testMultiPutsTimeout() {
TABLE.batch(puts, new Object[2]);
Assert.fail("should not reach here");
} catch (Exception e) {
Assert.assertTrue(e instanceof RetriesExhaustedWithDetailsException);
Assert.assertTrue(e instanceof SocketTimeoutException);
}
}

Expand Down

0 comments on commit 26e37bc

Please sign in to comment.