You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by vi...@apache.org on 2019/04/12 17:38:45 UTC
[phoenix] branch 4.x-HBase-1.3 updated: PHOENIX-5194 Thread Cache
is not update for Index retries in for MutationState#send()#doMutation()
This is an automated email from the ASF dual-hosted git repository.
vincentpoon pushed a commit to branch 4.x-HBase-1.3
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x-HBase-1.3 by this push:
new 8052cb9 PHOENIX-5194 Thread Cache is not update for Index retries in for MutationState#send()#doMutation()
8052cb9 is described below
commit 8052cb918757adb126f1acfc26f8902b9b50318f
Author: Monani Mihir <mo...@gmail.com>
AuthorDate: Fri Apr 12 21:48:45 2019 +0530
PHOENIX-5194 Thread Cache is not update for Index retries in for MutationState#send()#doMutation()
---
.../org/apache/phoenix/execute/MutationState.java | 28 ++++++++++++++++++++++
.../phoenix/index/PhoenixIndexFailurePolicy.java | 10 ++++++--
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
index 80dd3f9..36d120a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
@@ -994,6 +994,9 @@ public class MutationState implements SQLCloseable {
if (shouldRetryIndexedMutation) {
// if there was an index write failure, retry the mutation in a loop
final Table finalHTable = hTable;
+ final ImmutableBytesWritable finalindexMetaDataPtr =
+ indexMetaDataPtr;
+ final PTable finalPTable = table;
PhoenixIndexFailurePolicy.doBatchWithRetries(new MutateCommand() {
@Override
public void doMutation() throws IOException {
@@ -1002,6 +1005,9 @@ public class MutationState implements SQLCloseable {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IOException(e);
+ } catch (IOException e) {
+ e = updateTableRegionCacheIfNecessary(e);
+ throw e;
}
}
@@ -1009,6 +1015,28 @@ public class MutationState implements SQLCloseable {
public List<Mutation> getMutationList() {
return mutationBatch;
}
+
+ private IOException
+ updateTableRegionCacheIfNecessary(IOException ioe) {
+ SQLException sqlE =
+ ServerUtil.parseLocalOrRemoteServerException(ioe);
+ if (sqlE != null
+ && sqlE.getErrorCode() == SQLExceptionCode.INDEX_METADATA_NOT_FOUND
+ .getErrorCode()) {
+ try {
+ connection.getQueryServices().clearTableRegionCache(
+ finalHTable.getName().getName());
+ IndexMetaDataCacheClient.setMetaDataOnMutations(
+ connection, finalPTable, mutationBatch,
+ finalindexMetaDataPtr);
+ } catch (SQLException e) {
+ return ServerUtil.createIOException(
+ "Exception during updating index meta data cache",
+ ioe);
+ }
+ }
+ return ioe;
+ }
}, iwe, connection, connection.getQueryServices().getProps());
} else {
hTable.batch(mutationBatch);
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
index 1516bf8..852cd65 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
@@ -488,8 +488,14 @@ public class PhoenixIndexFailurePolicy extends DelegateIndexFailurePolicy {
} catch (IOException e) {
SQLException inferredE = ServerUtil.parseLocalOrRemoteServerException(e);
if (inferredE == null || inferredE.getErrorCode() != SQLExceptionCode.INDEX_WRITE_FAILURE.getErrorCode()) {
- // if it's not an index write exception, throw exception, to be handled normally in caller's try-catch
- throw e;
+ // If this call is from phoenix client, we also need to check if SQLException
+ // error is INDEX_METADATA_NOT_FOUND or not
+ // if it's not an INDEX_METADATA_NOT_FOUND, throw exception,
+ // to be handled normally in caller's try-catch
+ if (inferredE.getErrorCode() != SQLExceptionCode.INDEX_METADATA_NOT_FOUND
+ .getErrorCode()) {
+ throw e;
+ }
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();