This is an automated email from the ASF dual-hosted git repository.
vincentpoon pushed a commit to branch 4.x-HBase-1.2
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x-HBase-1.2 by this push:
new 82f01dc PHOENIX-5194 Thread Cache is not update for Index retries in
for MutationState#send()#doMutation()
82f01dc is described below
commit 82f01dc4fb13f25e6d099f8a1bc489a15863f78c
Author: Monani Mihir <[email protected]>
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 87b4945..7a8540a 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
@@ -987,6 +987,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 {
@@ -995,6 +998,9 @@ public class MutationState implements SQLCloseable {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IOException(e);
+ } catch (IOException e) {
+ e =
updateTableRegionCacheIfNecessary(e);
+ throw e;
}
}
@@ -1002,6 +1008,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 b9da5e9..a952cd5 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
@@ -491,8 +491,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();