ptupitsyn commented on code in PR #7844:
URL: https://github.com/apache/ignite-3/pull/7844#discussion_r3032307909
##########
modules/client/src/integrationTest/java/org/apache/ignite/internal/client/ItThinClientTransactionsTest.java:
##########
@@ -1397,34 +1404,166 @@ public void
testRollbackDoesNotBlockOnLockConflict(KillTestContext ctx) {
assertThat(kvView.removeAllAsync(null, Arrays.asList(key0, key,
key2)), willSucceedFast());
}
- @Test
- @Disabled("https://issues.apache.org/jira/browse/IGNITE-27947")
- public void testRollbackDoesNotBlockOnLockConflictDuringFirstRequest()
throws InterruptedException {
- // Note: reversed tx priority is required for this test.
- ClientTable table = (ClientTable) table();
- KeyValueView<Tuple, Tuple> kvView = table().keyValueView();
+ static boolean isUsingReverseComparator() {
+ TxIdComparators comparator = IgniteTestUtils.getFieldValue(null,
TxManagerImpl.class, "DEFAULT_TX_ID_COMPARATOR");
+ return comparator == TxIdComparators.REVERSED;
+ }
- Map<Partition, ClusterNode> map =
table.partitionDistribution().primaryReplicasAsync().join();
- List<Tuple> tuples0 = generateKeysForPartition(100, 10, map, 0, table);
+
@EnabledIf("org.apache.ignite.internal.client.ItThinClientTransactionsTest#isUsingReverseComparator")
+ @Nested
+ class OnConflictDuringFirstRequest {
+ class Data {
+ final IgniteImpl ignite;
+ final List<Tuple> tuples;
+ final ClientLazyTransaction tx1;
+ final ClientLazyTransaction tx2;
+ final CompletableFuture<?> req2Fut;
+
+ Data(
+ IgniteImpl ignite,
+ List<Tuple> tuples,
+ ClientLazyTransaction tx1,
+ ClientLazyTransaction tx2,
+ CompletableFuture<?> req2Fut
+ ) {
+ this.ignite = ignite;
+ this.tuples = tuples;
+ this.tx1 = tx1;
+ this.tx2 = tx2;
+ this.req2Fut = req2Fut;
+ }
+ }
- // We need a waiter for this scenario.
- Tuple key = tuples0.get(0);
- Tuple val = val("1");
+ Data prepareBlockedTransaction(KillTestContext ctx) throws
InterruptedException {
+ ClientTable table = (ClientTable) table();
+ ClientSql sql = (ClientSql) client().sql();
+
+ Map<Partition, ClusterNode> map =
table.partitionDistribution().primaryReplicasAsync().join();
+ Entry<Partition, ClusterNode> mapping =
map.entrySet().iterator().next();
+ List<Tuple> tuples0 = generateKeysForPartition(100, 10, map, (int)
mapping.getKey().id(), table);
+ Ignite server = server(mapping.getValue());
+ IgniteImpl ignite = unwrapIgniteImpl(server);
+
+ // Init SQL mappings.
+ Tuple key0 = tuples0.get(0);
+ sql.execute(format("INSERT INTO %s (%s, %s) VALUES (?, ?)",
TABLE_NAME, COLUMN_KEY, COLUMN_VAL),
+ key0.intValue(0), key0.intValue(0) + "");
+ await().atMost(2, TimeUnit.SECONDS)
+ .until(() ->
sql.partitionAwarenessCachedMetas().stream().allMatch(PartitionMappingProvider::ready));
- ClientLazyTransaction tx1 = (ClientLazyTransaction)
client().transactions().begin();
- ClientLazyTransaction tx2 = (ClientLazyTransaction)
client().transactions().begin();
+ // We need a waiter for this scenario.
+ Tuple key = tuples0.get(1);
+
+ ClientLazyTransaction tx2 = (ClientLazyTransaction)
client().transactions().begin();
+ ClientLazyTransaction tx1 = (ClientLazyTransaction)
client().transactions().begin();
+
+ // Starts the transaction.
+ assertThat(ctx.put.apply(client(), tx1, key), willSucceedIn(120,
TimeUnit.SECONDS));
+
+ await().atMost(3, TimeUnit.SECONDS).until(() -> {
+ Iterator<Lock> locks =
ignite.txManager().lockManager().locks(tx1.startedTx().txId());
+
+ int count = CollectionUtils.count(locks);
+ return count == 2;
+ });
+
+ // Will wait for lock.
+ CompletableFuture<?> fut2 = ctx.put.apply(client(), tx2, key);
+ Thread.sleep(500);
+
+ assertThat(fut2.isDone(), is(false));
+ IgniteTestUtils.assertThrows(AssertionError.class, () ->
ClientTransaction.get(tx2), "Transaction is starting");
+
+ return new Data(ignite, tuples0, tx1, tx2, fut2);
+ }
- kvView.put(tx1, key, val);
+ @ParameterizedTest
+
@MethodSource("org.apache.ignite.internal.client.ItThinClientTransactionsTest#killTestContextFactory")
+ public void testRollbackDoesNotBlock(KillTestContext ctx) throws
InterruptedException {
Review Comment:
All those new tests pass on the main branch, looks like we don't test the
new functionality.
--
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]