You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by an...@apache.org on 2017/02/27 11:38:05 UTC
phoenix git commit: PHOENIX-3694 Drop schema does not invalidate
schema from the server cache
Repository: phoenix
Updated Branches:
refs/heads/master 81e932558 -> 07b32b95e
PHOENIX-3694 Drop schema does not invalidate schema from the server cache
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/07b32b95
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/07b32b95
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/07b32b95
Branch: refs/heads/master
Commit: 07b32b95e4a92756d0acf9af1b801e2869ceb6bd
Parents: 81e9325
Author: Ankit Singhal <an...@gmail.com>
Authored: Mon Feb 27 17:07:52 2017 +0530
Committer: Ankit Singhal <an...@gmail.com>
Committed: Mon Feb 27 17:07:52 2017 +0530
----------------------------------------------------------------------
.../apache/phoenix/end2end/DropSchemaIT.java | 11 ++++++
.../coprocessor/MetaDataEndpointImpl.java | 36 ++++++++++++++------
2 files changed, 36 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/07b32b95/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropSchemaIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropSchemaIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropSchemaIT.java
index 9d59ec7..6a7bd52 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropSchemaIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropSchemaIT.java
@@ -132,6 +132,17 @@ public class DropSchemaIT extends BaseClientManagedTimeIT {
admin.createNamespace(NamespaceDescriptor.create(normalizeSchemaIdentifier).build());
conn.createStatement().execute("DROP SCHEMA IF EXISTS " + schema);
assertNotNull(admin.getNamespaceDescriptor(normalizeSchemaIdentifier));
+ conn.createStatement().execute("CREATE SCHEMA " + schema);
+ }
+ props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 80));
+ try (Connection conn = DriverManager.getConnection(getUrl(), props);) {
+ conn.createStatement().execute("DROP SCHEMA " + schema);
+ }
+ try (Connection conn = DriverManager.getConnection(getUrl(), props);) {
+ conn.createStatement().execute("DROP SCHEMA " + schema);
+ fail();
+ } catch (SQLException e) {
+ assertEquals(e.getErrorCode(), SQLExceptionCode.SCHEMA_NOT_FOUND.getErrorCode());
}
admin.close();
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/07b32b95/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
index 1858d0d..e21ef04 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
@@ -1249,6 +1249,10 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso
return table.getName() == null;
}
+ private static boolean isSchemaDeleted(PSchema schema) {
+ return schema.getSchemaName() == null;
+ }
+
private static boolean isFunctionDeleted(PFunction function) {
return function.getFunctionName() == null;
}
@@ -3637,11 +3641,19 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso
PSchema schema = loadSchema(env, lockKey, cacheKey, clientTimeStamp, clientTimeStamp);
if (schema != null) {
if (schema.getTimeStamp() < clientTimeStamp) {
- builder.setReturnCode(MetaDataProtos.MutationCode.SCHEMA_ALREADY_EXISTS);
- builder.setMutationTime(EnvironmentEdgeManager.currentTimeMillis());
- builder.setSchema(PSchema.toProto(schema));
- done.run(builder.build());
- return;
+ if (!isSchemaDeleted(schema)) {
+ builder.setReturnCode(MetaDataProtos.MutationCode.SCHEMA_ALREADY_EXISTS);
+ builder.setMutationTime(EnvironmentEdgeManager.currentTimeMillis());
+ builder.setSchema(PSchema.toProto(schema));
+ done.run(builder.build());
+ return;
+ } else {
+ builder.setReturnCode(MetaDataProtos.MutationCode.NEWER_SCHEMA_FOUND);
+ builder.setMutationTime(EnvironmentEdgeManager.currentTimeMillis());
+ builder.setSchema(PSchema.toProto(schema));
+ done.run(builder.build());
+ return;
+ }
}
}
} catch (Exception e) {
@@ -3902,11 +3914,13 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso
PSchema schema = loadSchema(env, lockKey, cacheKey, clientTimeStamp, clientTimeStamp);
if (schema != null) {
if (schema.getTimeStamp() < clientTimeStamp) {
- builder.setReturnCode(MetaDataProtos.MutationCode.SCHEMA_ALREADY_EXISTS);
- builder.setMutationTime(EnvironmentEdgeManager.currentTimeMillis());
- builder.setSchema(PSchema.toProto(schema));
- done.run(builder.build());
- return;
+ if (!isSchemaDeleted(schema)) {
+ builder.setReturnCode(MetaDataProtos.MutationCode.SCHEMA_ALREADY_EXISTS);
+ builder.setMutationTime(EnvironmentEdgeManager.currentTimeMillis());
+ builder.setSchema(PSchema.toProto(schema));
+ done.run(builder.build());
+ return;
+ }
} else {
builder.setReturnCode(MetaDataProtos.MutationCode.NEWER_SCHEMA_FOUND);
builder.setMutationTime(EnvironmentEdgeManager.currentTimeMillis());
@@ -4014,7 +4028,7 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso
}
if (areTablesExists) { return new MetaDataMutationResult(MutationCode.TABLES_EXIST_ON_SCHEMA, schema,
EnvironmentEdgeManager.currentTimeMillis()); }
-
+ invalidateList.add(new ImmutableBytesPtr(key));
return new MetaDataMutationResult(MutationCode.SCHEMA_ALREADY_EXISTS, schema,
EnvironmentEdgeManager.currentTimeMillis());
}