[
https://issues.apache.org/jira/browse/PHOENIX-6943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17739733#comment-17739733
]
ASF GitHub Bot commented on PHOENIX-6943:
-----------------------------------------
shahrs87 commented on code in PR #1610:
URL: https://github.com/apache/phoenix/pull/1610#discussion_r1251293623
##########
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/VerifyLastDDLTimestamp.java:
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.coprocessor;
+
+import org.apache.hadoop.hbase.client.Mutation;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.phoenix.cache.ServerMetadataCache;
+import org.apache.phoenix.coprocessor.generated.DDLTimestampMaintainersProtos;
+import org.apache.phoenix.util.LastDDLTimestampMaintainerUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.List;
+
+import static
org.apache.phoenix.coprocessor.BaseScannerRegionObserver.LAST_DDL_TIMESTAMP_MAINTAINERS;
+import static
org.apache.phoenix.coprocessor.BaseScannerRegionObserver.LAST_DDL_TIMESTAMP_MAINTAINERS_VERIFIED;
+import static org.apache.phoenix.schema.types.PDataType.TRUE_BYTES;
+
+/**
+ * Client provides last DDL timestamp of tables/views/indexes included in
read/write operation
+ * through scan or mutation {@link
BaseScannerRegionObserver#LAST_DDL_TIMESTAMP_MAINTAINERS}
+ * attribute.
+ * This verifies that client has the latest version of LAST_DDL_TIMESTAMP
version.
+ * If client's provided LAST_DDL_TIMESTAMP is less than what is present in
SYSTEM.CATALOG
+ * then it throws StaleMetadataCacheException. Once it verifies the request,
+ * it will set LAST_DDL_TIMESTAMP_MAINTAINERS_VERIFIED attribute to true so
that
+ * other co-processors within the same session don't validate the
LAST_DDL_TIMESTAMP again.
+ */
+public class VerifyLastDDLTimestamp {
+ private static final Logger LOGGER =
LoggerFactory.getLogger(VerifyLastDDLTimestamp.class);
+
+ public static void
verifyLastDDLTimestamp(MiniBatchOperationInProgress<Mutation> miniBatchOp,
+ RegionCoprocessorEnvironment
env) throws IOException {
+
+ byte[] maintainersBytes = miniBatchOp.getOperation(0).getAttribute(
+ LAST_DDL_TIMESTAMP_MAINTAINERS);
+ if (maintainersBytes == null) {
+ // Client doesn't support sending LAST_DDL_TIMESTAMP_MAINTAINERS.
Do nothing.
+ return;
+ }
+ DDLTimestampMaintainersProtos.DDLTimestampMaintainers maintainers =
+ LastDDLTimestampMaintainerUtil.deserialize(maintainersBytes);
+ verifyLastDDLTimestampInternal(maintainers, env);
+ }
+
+ /**
+ * Verify that LAST_DDL_TIMESTAMP provided by the client is upto date. If
it is stale it will
+ * throw StaleMetadataCacheException.
+ * This method will be called by each coprocessor in the co-proc chain.
The first co-proc in
Review Comment:
I think its fine NOT to check between co processor invocation. In current
implementation we don't resolve table between multiple co processor invocation.
WDYT @jpisaac
> Add MetadaCache on each region server.
> --------------------------------------
>
> Key: PHOENIX-6943
> URL: https://issues.apache.org/jira/browse/PHOENIX-6943
> Project: Phoenix
> Issue Type: Sub-task
> Components: core
> Reporter: Rushabh Shah
> Assignee: Rushabh Shah
> Priority: Major
> Fix For: 5.2.0
>
>
> Design doc
> [here|https://docs.google.com/document/d/1ZIu7TyzI7aDhgMOWa7mbUmwbFNbiPVwpWjb6QisT4ng/edit#heading=h.fa8lnra4hvey].
--
This message was sent by Atlassian Jira
(v8.20.10#820010)