You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2020/03/23 18:55:13 UTC

[GitHub] [phoenix] gokceni commented on a change in pull request #740: PHOENIX-5795 Supporting selective queries for index rows updated conc…

gokceni commented on a change in pull request #740: PHOENIX-5795 Supporting selective queries for index rows updated conc…
URL: https://github.com/apache/phoenix/pull/740#discussion_r396684000
 
 

 ##########
 File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/ConcurrentMutationsExtendedIT.java
 ##########
 @@ -264,6 +281,67 @@ public void testConcurrentUpserts() throws Exception {
         assertEquals(nRows, actualRowCount);
     }
 
+    @Test
+    public void testConcurrentUpsertsWithNoIndexedColumns() throws Exception {
+        int nThreads = 4;
+        final int batchSize = 100;
+        final int nRows = 997;
+        final String tableName = generateUniqueName();
+        final String indexName = generateUniqueName();
+        Connection conn = DriverManager.getConnection(getUrl());
+        conn.createStatement().execute("CREATE TABLE " + tableName
+                + "(k1 INTEGER NOT NULL, k2 INTEGER NOT NULL, a.v1 INTEGER, b.v2 INTEGER, c.v3 INTEGER, d.v4 INTEGER," +
+                "CONSTRAINT pk PRIMARY KEY (k1,k2))  COLUMN_ENCODED_BYTES = 0, VERSIONS=1");
+        TestUtil.addCoprocessor(conn, tableName, DelayingRegionObserver.class);
+        conn.createStatement().execute("CREATE INDEX " + indexName + " ON " + tableName + "(v1) INCLUDE(v2, v3)");
+        final CountDownLatch doneSignal = new CountDownLatch(nThreads);
+        Runnable[] runnables = new Runnable[nThreads];
+        for (int i = 0; i < nThreads; i++) {
+            runnables[i] = new Runnable() {
+
+                @Override public void run() {
+                    try {
+                        Connection conn = DriverManager.getConnection(getUrl());
+                        for (int i = 0; i < 1000; i++) {
+                            if (RAND.nextInt() % 1000 < 10) {
+                                // Do not include the indexed column in upserts
+                                conn.createStatement().execute(
+                                        "UPSERT INTO " + tableName + " (k1, k2, b.v2, c.v3, d.v4) VALUES ("
+                                                + (RAND.nextInt() % nRows) + ", 0, "
+                                                + (RAND.nextBoolean() ? null : RAND.nextInt()) + ", "
+                                                + (RAND.nextBoolean() ? null : RAND.nextInt()) + ", "
+                                                + (RAND.nextBoolean() ? null : RAND.nextInt()) + ")");
+                            } else {
+                                conn.createStatement().execute(
+                                        "UPSERT INTO " + tableName + " VALUES (" + (i % nRows) + ", 0, "
+                                                + (RAND.nextBoolean() ? null : RAND.nextInt()) + ", "
+                                                + (RAND.nextBoolean() ? null : RAND.nextInt()) + ", "
+                                                + (RAND.nextBoolean() ? null : RAND.nextInt()) + ", "
+                                                + (RAND.nextBoolean() ? null : RAND.nextInt()) + ")");
+                            }
+                            if ((i % batchSize) == 0) {
+                                conn.commit();
+                            }
+                        }
+                        conn.commit();
+                    } catch (SQLException e) {
+                        throw new RuntimeException(e);
+                    } finally {
+                        doneSignal.countDown();
+                    }
+                }
+
+            };
+        }
+        for (int i = 0; i < nThreads; i++) {
+            Thread t = new Thread(runnables[i]);
+            t.start();
+        }
+
 
 Review comment:
   Shouldn't you wait for the threads to finish running?

----------------------------------------------------------------
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