You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by st...@apache.org on 2022/12/06 18:24:48 UTC

[phoenix] branch 5.1 updated: PHOENIX-6711 Add support of skipping the system tables existence check during connection initialisation and create new table result iterator which doesn't require fetch meta data of table(Rajeshbabu)

This is an automated email from the ASF dual-hosted git repository.

stoty pushed a commit to branch 5.1
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/5.1 by this push:
     new 8912d0a5ef PHOENIX-6711 Add support of skipping the system tables existence check during connection initialisation and create new table result iterator which doesn't require fetch meta data of table(Rajeshbabu)
8912d0a5ef is described below

commit 8912d0a5ef521382553650fcb8b1e2f32e09dc2c
Author: Rajeshbabu Chintaguntla <ch...@gmail.com>
AuthorDate: Fri Jun 3 05:35:41 2022 +0530

    PHOENIX-6711 Add support of skipping the system tables existence check during connection initialisation and create new table result iterator which doesn't require fetch meta data of table(Rajeshbabu)
    
    Co-authored-by: Rajeshbabu Chintaguntla <ra...@apache.org>
---
 .../query/SkipSystemTablesExistenceCheckIT.java    | 81 ++++++++++++++++++++++
 .../phoenix/query/ConnectionQueryServicesImpl.java |  9 +++
 .../org/apache/phoenix/query/QueryServices.java    |  5 ++
 .../apache/phoenix/query/QueryServicesOptions.java | 10 ++-
 4 files changed, 103 insertions(+), 2 deletions(-)

diff --git a/phoenix-core/src/it/java/org/apache/phoenix/query/SkipSystemTablesExistenceCheckIT.java b/phoenix-core/src/it/java/org/apache/phoenix/query/SkipSystemTablesExistenceCheckIT.java
new file mode 100644
index 0000000000..96a9641314
--- /dev/null
+++ b/phoenix-core/src/it/java/org/apache/phoenix/query/SkipSystemTablesExistenceCheckIT.java
@@ -0,0 +1,81 @@
+/*
+ * 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.query;
+
+import org.apache.phoenix.end2end.ParallelStatsDisabledIT;
+import org.apache.phoenix.end2end.ParallelStatsDisabledTest;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.jdbc.PhoenixStatement;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import static org.apache.phoenix.util.TestUtil.PHOENIX_JDBC_URL;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+
+@Category(ParallelStatsDisabledTest.class)
+@SuppressWarnings("deprecated")
+public class SkipSystemTablesExistenceCheckIT extends ParallelStatsDisabledIT {
+
+    @Test
+    public void testTableResultIterator() throws Exception {
+        Connection conn = DriverManager.getConnection(PHOENIX_JDBC_URL);
+        PhoenixConnection phoenixConnection = conn.unwrap(PhoenixConnection.class);
+        String tableName = generateUniqueName();
+
+        conn.createStatement().execute("CREATE TABLE " + tableName
+                + " (A UNSIGNED_LONG NOT NULL PRIMARY KEY, B VARCHAR(10))");
+        conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES (1, 'A')");
+        conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES (2, 'B')");
+        conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES (3, 'C')");
+        conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES (4, 'D')");
+        conn.commit();
+
+        scanTable(conn, tableName);
+        Properties props = new Properties();
+        props.setProperty(QueryServices.SKIP_SYSTEM_TABLES_EXISTENCE_CHECK, "true");
+        ConnectionQueryServicesImpl queryServices = ((ConnectionQueryServicesImpl)phoenixConnection.getQueryServices());
+        phoenixConnection.close();
+        queryServices.setInitialized(false);
+        queryServices.init(PHOENIX_JDBC_URL, props);
+        assertTrue(queryServices.isInitialized());
+        conn = DriverManager.getConnection(PHOENIX_JDBC_URL, props);
+        scanTable(conn, tableName);
+    }
+
+    private void scanTable(Connection conn, String tableName) throws SQLException {
+        String sql = "SELECT A, B FROM " + tableName + " ORDER BY A DESC";
+        PhoenixStatement stmt = conn.createStatement().unwrap(PhoenixStatement.class);
+        ResultSet rs = stmt.executeQuery(sql);
+
+        int cnt = 0;
+        while ((rs.next())) {
+            cnt++;
+            assertTrue("too many results returned", cnt <= 4);
+        }
+        assertEquals(4, cnt);
+    }
+}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 6e04e93cd4..0718853cd2 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -3281,6 +3281,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
                             }
                             return null;
                         }
+
                         checkClosed();
                         boolean hConnectionEstablished = false;
                         boolean success = false;
@@ -3289,6 +3290,14 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
                             LOGGER.info("An instance of ConnectionQueryServices was created.");
                             openConnection();
                             hConnectionEstablished = true;
+                            String skipSystemExistenceCheck =
+                                props.getProperty(SKIP_SYSTEM_TABLES_EXISTENCE_CHECK);
+                            if (skipSystemExistenceCheck != null &&
+                                Boolean.valueOf(skipSystemExistenceCheck)) {
+                                initialized = true;
+                                success = true;
+                                return null;
+                            }
                             boolean isDoNotUpgradePropSet = UpgradeUtil.isNoUpgradeSet(props);
                             Properties scnProps = PropertiesUtil.deepCopy(props);
                             scnProps.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB,
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
index 94617e2918..387051003b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
@@ -378,6 +378,11 @@ public interface QueryServices extends SQLCloseable {
     // The max point keys that can be generated for large in list clause
     public static final String MAX_IN_LIST_SKIP_SCAN_SIZE = "phoenix.max.inList.skipScan.size";
 
+    /**
+     * Parameter to skip the system tables existence check to avoid unnecessary calls to
+     * Region server holding the SYSTEM.CATALOG table in batch oriented jobs.
+     */
+    String SKIP_SYSTEM_TABLES_EXISTENCE_CHECK = "phoenix.skip.system.tables.existence.check";
     /**
      * Get executor service used for parallel scans
      */
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
index 56ff09b128..21bcf9a771 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
@@ -78,6 +78,7 @@ import static org.apache.phoenix.query.QueryServices.SCAN_RESULT_CHUNK_SIZE;
 import static org.apache.phoenix.query.QueryServices.SEQUENCE_CACHE_SIZE_ATTRIB;
 import static org.apache.phoenix.query.QueryServices.SEQUENCE_SALT_BUCKETS_ATTRIB;
 import static org.apache.phoenix.query.QueryServices.SERVER_SPOOL_THRESHOLD_BYTES_ATTRIB;
+import static org.apache.phoenix.query.QueryServices.SKIP_SYSTEM_TABLES_EXISTENCE_CHECK;
 import static org.apache.phoenix.query.QueryServices.SPOOL_DIRECTORY;
 import static org.apache.phoenix.query.QueryServices.STATS_CACHE_THREAD_POOL_SIZE;
 import static org.apache.phoenix.query.QueryServices.STATS_COLLECTION_ENABLED;
@@ -376,6 +377,9 @@ public class QueryServicesOptions {
     public static final boolean DEFAULT_LONG_VIEW_INDEX_ENABLED = false;
 
     public static final boolean DEFAULT_PENDING_MUTATIONS_DDL_THROW = false;
+
+    public static final boolean DEFAULT_SKIP_SYSTEM_TABLES_EXISTENCE_CHECK = false;
+
     private final Configuration config;
 
     private QueryServicesOptions(Configuration config) {
@@ -461,8 +465,10 @@ public class QueryServicesOptions {
             .setIfUnset(CLIENT_METRICS_TAG, DEFAULT_CLIENT_METRICS_TAG)
             .setIfUnset(CLIENT_INDEX_ASYNC_THRESHOLD, DEFAULT_CLIENT_INDEX_ASYNC_THRESHOLD)
             .setIfUnset(PHOENIX_TTL_SERVER_SIDE_MASKING_ENABLED, DEFAULT_SERVER_SIDE_MASKING_ENABLED)
-            .setIfUnset(MAX_IN_LIST_SKIP_SCAN_SIZE, DEFAULT_MAX_IN_LIST_SKIP_SCAN_SIZE);
-
+            .setIfUnset(MAX_IN_LIST_SKIP_SCAN_SIZE, DEFAULT_MAX_IN_LIST_SKIP_SCAN_SIZE)
+            .setIfUnset(SKIP_SYSTEM_TABLES_EXISTENCE_CHECK,
+                DEFAULT_SKIP_SYSTEM_TABLES_EXISTENCE_CHECK)
+            ;
         // HBase sets this to 1, so we reset it to something more appropriate.
         // Hopefully HBase will change this, because we can't know if a user set
         // it to 1, so we'll change it.