Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 ea66af60f -> d2f2bade0 refs/heads/4.x-HBase-1.0 37e8948ec -> a5caaeb89 refs/heads/4.x-HBase-1.1 847e90c4b -> 7b9c34980 refs/heads/master bfda226ee -> 557197ed6
PHOENIX-3015 Any metadata changes may cause unpredictable result when local indexes are using Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/557197ed Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/557197ed Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/557197ed Branch: refs/heads/master Commit: 557197ed6311356892b8f5144bb1a1d6731611ef Parents: bfda226 Author: Sergey Soldatov <s...@apache.org> Authored: Tue Jun 21 18:02:56 2016 -0700 Committer: Sergey Soldatov <s...@apache.org> Committed: Wed Jun 22 13:53:06 2016 -0700 ---------------------------------------------------------------------- .../IndexHalfStoreFileReaderGenerator.java | 2 +- .../phoenix/index/PhoenixIndexFailurePolicy.java | 2 +- .../java/org/apache/phoenix/util/PhoenixRuntime.java | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/557197ed/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java index 7b5287a..670bb82 100644 --- a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java @@ -144,7 +144,7 @@ public class IndexHalfStoreFileReaderGenerator extends BaseRegionObserver { try { conn = QueryUtil.getConnectionOnServer(ctx.getEnvironment().getConfiguration()).unwrap( PhoenixConnection.class); - PTable dataTable = PhoenixRuntime.getTable(conn, tableName.getNameAsString()); + PTable dataTable = PhoenixRuntime.getTableNoCache(conn, tableName.getNameAsString()); List<PTable> indexes = dataTable.getIndexes(); Map<ImmutableBytesWritable, IndexMaintainer> indexMaintainers = new HashMap<ImmutableBytesWritable, IndexMaintainer>(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/557197ed/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java ---------------------------------------------------------------------- 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 d7850ba..67242f6 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 @@ -224,7 +224,7 @@ public class PhoenixIndexFailurePolicy extends DelegateIndexFailurePolicy { try { conn = QueryUtil.getConnectionOnServer(this.env.getConfiguration()).unwrap( PhoenixConnection.class); - PTable dataTable = PhoenixRuntime.getTable(conn, ref.getTableName()); + PTable dataTable = PhoenixRuntime.getTableNoCache(conn, ref.getTableName()); List<PTable> indexes = dataTable.getIndexes(); // local index used to get view id from index mutation row key. PTable localIndex = null; http://git-wip-us.apache.org/repos/asf/phoenix/blob/557197ed/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java index 199c425..184288e 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java @@ -371,6 +371,19 @@ public class PhoenixRuntime { }; } + public static PTable getTableNoCache(Connection conn, String name) throws SQLException { + String schemaName = SchemaUtil.getSchemaNameFromFullName(name); + String tableName = SchemaUtil.getTableNameFromFullName(name); + PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + MetaDataMutationResult result = new MetaDataClient(pconn).updateCache(pconn.getTenantId(), + schemaName, tableName, true); + if(result.getMutationCode() != MutationCode.TABLE_ALREADY_EXISTS) { + throw new TableNotFoundException(schemaName, tableName); + } + + return result.getTable(); + + } /** * * @param conn