From 0ec2a584920284f7ac73c33ab33db399dbb0df87 Mon Sep 17 00:00:00 2001 From: Daniel Roudnitsky Date: Wed, 7 Aug 2024 21:46:25 -0400 Subject: [PATCH] HBASE-28771 Refactor AsyncRequestFutureImpl.isActionComplete to support non replica actions --- .../hbase/client/AsyncRequestFutureImpl.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRequestFutureImpl.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRequestFutureImpl.java index b34ef863d565..f15c5c1ff26a 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRequestFutureImpl.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRequestFutureImpl.java @@ -731,7 +731,7 @@ Retry manageError(int originalIndex, Row row, Retry canRetry, Throwable throwabl if (canRetry != Retry.YES) { // Batch.Callback was not called on failure in 0.94. We keep this. setError(originalIndex, row, throwable, server); - } else if (isActionComplete(originalIndex, row)) { + } else if (AsyncProcess.isReplicaGet(row) && isActionComplete(originalIndex)) { canRetry = Retry.NO_OTHER_SUCCEEDED; } return canRetry; @@ -1164,10 +1164,16 @@ private void setError(int index, Row row, Throwable throwable, ServerName server * synchronize, assuming element index/field accesses are atomic. This is an opportunistic * optimization check, doesn't have to be strict. * @param index Original action index. - * @param row Original request. + * @return If results are non-null, returns whether a result is currently set for action index. + * @throws IllegalStateException If results are null. We cannot readily tell here whether an + * action that is part of an AsyncRequestFuture that doesn't track + * results is complete */ - private boolean isActionComplete(int index, Row row) { - if (!AsyncProcess.isReplicaGet(row)) return false; + private boolean isActionComplete(int index) { + if (results == null) { + throw new IllegalStateException( + String.format("Cannot check action %d completion when results are null", index)); + } Object resObj = results[index]; return (resObj != null) && (!(resObj instanceof ReplicaResultState) || ((ReplicaResultState) resObj).callCount == 0);