ygerzhedovich commented on code in PR #990:
URL: https://github.com/apache/ignite-3/pull/990#discussion_r947911308
##########
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));
+
+ first = false;
+ }
+
+ ses.execute(null, insert.toString()).close();
+
+ ses.close();
+ });
+
+ CompletableFuture<?> fut2 = runAsync(() -> {
+ Session ses = sql.createSession();
+
+ StringBuilder insert = new StringBuilder("INSERT INTO TEST
VALUES");
+
+ int[] arr2 = range2.toArray();
+
+ boolean first = true;
+
+ for (int i = arr1.length - 1; i == 0; --i) {
+ insert.append(String.format(first ? " (%d, %d)" : ", (%d,
%d)", arr1[i], arr2[i]));
+
+ first = false;
+ }
+
+ ses.execute(null, insert.toString()).close();
Review Comment:
Let's don't ignore an exceptions, we must chech that exception is expected
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]