From issues-return-7603-archive-asf-public=cust-asf.ponee.io@phoenix.apache.org Wed Jun 12 17:01:12 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id E3F4D180782 for ; Wed, 12 Jun 2019 19:01:11 +0200 (CEST) Received: (qmail 15576 invoked by uid 500); 12 Jun 2019 17:01:11 -0000 Mailing-List: contact issues-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list issues@phoenix.apache.org Received: (qmail 15510 invoked by uid 99); 12 Jun 2019 17:01:11 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Jun 2019 17:01:11 +0000 From: GitBox To: issues@phoenix.apache.org Subject: =?utf-8?q?=5BGitHub=5D_=5Bphoenix=5D_priyankporwal_commented_on_a_change_?= =?utf-8?q?in_pull_request_=23517=3A_PHOENIX-5211_Consistent_Immutable_Glo?= =?utf-8?q?bal_Indexes_for_Non-Transactiona=E2=80=A6?= Message-ID: <156035887116.30441.6107081350331488031.gitbox@gitbox.apache.org> Date: Wed, 12 Jun 2019 17:01:11 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit priyankporwal commented on a change in pull request #517: PHOENIX-5211 Consistent Immutable Global Indexes for Non-Transactiona… URL: https://github.com/apache/phoenix/pull/517#discussion_r293017807 ########## File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ImmutableIndexIT.java ########## @@ -259,7 +275,122 @@ private void assertIndexMutations(Connection conn) throws SQLException { (transactionProvider != null && transactionProvider.isUnsupported(Feature.MAINTAIN_LOCAL_INDEX_ON_SERVER)), iterator.hasNext()); } - + + private void createTableAndIndexForConsistentIndex(Connection conn, String tableName, String indexName, int numOfRowsToInsert) + throws Exception { + String ddl = "CREATE TABLE " + TABLE_NAME + TestUtil.TEST_TABLE_SCHEMA + tableDDLOptions; + INDEX_DDL = + "CREATE " + " INDEX IF NOT EXISTS " + SchemaUtil.getTableNameFromFullName(indexName) + + " ON " + tableName + " (long_pk, varchar_pk)" + + " INCLUDE (long_col1, long_col2) "; + + Statement stmt = conn.createStatement(); + stmt.execute(ddl); + conn.createStatement().execute(INDEX_DDL); + upsertRows(conn, tableName, numOfRowsToInsert); + conn.commit(); + + Thread.sleep(15000); + } + + @Test + public void testGlobalImmutableIndexCreate() throws Exception { + if (localIndex || transactionProvider != null) { + return; + } + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + String tableName = "TBL_" + generateUniqueName(); + String indexName = "IND_" + generateUniqueName(); + String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName); + String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName); + TABLE_NAME = fullTableName; + try (Connection conn = DriverManager.getConnection(getUrl(), props)) { + conn.setAutoCommit(true); + int num = 1; + createTableAndIndexForConsistentIndex(conn, fullTableName, fullIndexName, num); + // TestUtil.waitForIndexRebuild(conn, indexName, PIndexState.ACTIVE); + ResultSet rs; + rs = conn.createStatement().executeQuery("SELECT /*+ NO_INDEX */ COUNT(*) FROM " + TABLE_NAME); + assertTrue(rs.next()); + assertEquals(num,rs.getInt(1)); + rs = conn.createStatement().executeQuery("SELECT COUNT(*) FROM " + fullIndexName); + assertTrue(rs.next()); + assertEquals(num,rs.getInt(1)); + verifyRowsForEmptyColValue(conn, fullIndexName, TRUE_BYTES); + } + } + + @Test + public void testGlobalImmutableIndexDelete() throws Exception { + if (localIndex || transactionProvider != null) { + return; + } + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + String tableName = "TBL_" + generateUniqueName(); + String indexName = "IND_" + generateUniqueName(); + String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName); + String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName); + TABLE_NAME = fullTableName; + try (Connection conn = DriverManager.getConnection(getUrl(), props); + Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin();) { + conn.setAutoCommit(true); + int num = 2; + createTableAndIndexForConsistentIndex(conn, fullTableName, indexName, num); + // TestUtil.waitForIndexRebuild(conn, indexName, PIndexState.ACTIVE); + + String dml = "DELETE from " + fullTableName + " WHERE varchar_pk='varchar1'"; + conn.createStatement().execute(dml); + ResultSet rs; + rs = conn.createStatement().executeQuery("SELECT /*+ NO_INDEX */ COUNT(*) FROM " + TABLE_NAME); + assertTrue(rs.next()); + assertEquals(num-1, rs.getInt(1)); + rs = conn.createStatement().executeQuery("SELECT COUNT(*) FROM " + fullIndexName); + assertTrue(rs.next()); + assertEquals(num-1, rs.getInt(1)); + + // Disable data table so that delete fails on data table but index table row remains as unverified Review comment: Nice test! simulating the unverified index row ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services