You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/08/16 11:19:52 UTC

[GitHub] [ignite-3] ygerzhedovich commented on a diff in pull request #990: IGNITE-17434 Fix partially correct previous implementation of sql implicit transactions.

ygerzhedovich commented on code in PR #990:
URL: https://github.com/apache/ignite-3/pull/990#discussion_r946646707


##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/api/ItSqlSynchronousApiTest.java:
##########
@@ -181,13 +184,100 @@ public void dml() {
 
         var states = (Map<UUID, TxState>) IgniteTestUtils.getFieldValue(txManagerInternal, TxManagerImpl.class, "states");
 
-        states.forEach((k, v) -> assertNotSame(v, TxState.PENDING));
+        assertTrue(waitForCondition(() -> states.values().stream().noneMatch(e -> e.equals(TxState.PENDING)), 5_000));
 
         checkDml(ROW_COUNT, ses, "UPDATE TEST SET VAL0 = VAL0 + ?", 1);
 
         checkDml(ROW_COUNT, ses, "DELETE FROM TEST WHERE VAL0 >= 0");
     }
 
+    /**
+     * Execute concurrent insertion batch of equal pk`s and different val`s.
+     * Check sum of arithmetic progression as a confirmation that only one batch has been commited.
+     */
+    @Test
+    public void concurrentInsertOfHugeDataWithEqPkeys() {
+        sql("CREATE TABLE TEST(ID INT PRIMARY KEY, NUMERIC INT)");
+
+        IgniteSql sql = igniteSql();
+
+        IntStream range1 = IntStream.range(0, 10 * MODIFY_BATCH_SIZE);
+
+        IntStream range2 = IntStream.range(10 * MODIFY_BATCH_SIZE, 20 * MODIFY_BATCH_SIZE);
+
+        // arithmetic progression sum.
+        int s1 = ((0 + 10 * MODIFY_BATCH_SIZE - 1) * 10 * MODIFY_BATCH_SIZE) / 2;
+
+        // arithmetic progression sum.
+        int s2 = ((10 * MODIFY_BATCH_SIZE + 20 * MODIFY_BATCH_SIZE - 1) * 10 * MODIFY_BATCH_SIZE) / 2;
+
+        int[] arr1 = range1.toArray();
+
+        CompletableFuture<?> fut1 = runAsync(() -> {
+            Session ses = sql.createSession();
+
+            StringBuilder insert = new StringBuilder("INSERT INTO TEST VALUES");
+
+            boolean first = true;
+
+            for (int j : arr1) {
+                insert.append(String.format(first ? " (%d, %d)" : ", (%d, %d)", j, j));

Review Comment:
   maybe StringJoiner will be convinient for the case



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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org