Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-26027 The calling of HTable.batch blocked at AsyncRequestFutureImpl.waitUntilDone caused by ArrayStoreException #3925

Merged
merged 5 commits into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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