denis-chudov commented on code in PR #7196:
URL: https://github.com/apache/ignite-3/pull/7196#discussion_r2610950677
##########
modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItOperationRetryTest.java:
##########
@@ -97,15 +112,105 @@ public void testLockExceptionRetry() {
return false;
});
- view.upsert(tx2, Tuple.create().set("key", 1).set("val", "new value"));
+ view.upsert(tx2, NEW_RECORD_TUPLE);
tx2.commit();
- assertEquals("new value", view.get(null, Tuple.create().set("key",
1)).value("val"));
+ assertEquals(NEW_RECORD_VALUE, view.get(null,
NEW_RECORD_KEY_TUPLE).value("val"));
+ }
+
+ @Test
+ public void retryImplicitTransactionsDueToReplicaMissTest() {
+ ZonePartitionId partitionGroupId = testPartitionGroupId();
+ String leaseholderNodeName =
waitAndGetPrimaryReplica(partitionGroupId);
+ IgniteImpl transactionCoordinatorNode =
findNonLeaseholderNode(leaseholderNodeName);
+
+ // When upsert will be triggered then we have to pull the latch down
and transfer lease to another leaseholder node.
+ CountDownLatch upsertIsTriggeredLatch = new CountDownLatch(1);
+
+ // When the latch is arisen, then in case of RW request to the current
leaseholder we will wait. When latch is pulled down we
+ // additionally transfer lease and still pass a message, so actually
the follow doesn't drop any message, but moves lease at
+ // the moment after upsert was triggered.
+ DefaultMessagingService messagingService = (DefaultMessagingService)
transactionCoordinatorNode.clusterService().messagingService();
+ messagingService.dropMessages((nodeName, msg) -> {
+ boolean isMessageForCurrentLeaseholder =
nodeName.equals(leaseholderNodeName);
+ boolean isLatchArisen = upsertIsTriggeredLatch.getCount() > 0;
+ boolean isUpsertRequestMessage = msg instanceof
ReadWriteSingleRowReplicaRequest;
+
+ boolean shouldWaitForLatchDownAndTransferLease =
isMessageForCurrentLeaseholder && isUpsertRequestMessage && isLatchArisen;
+
+ if (!shouldWaitForLatchDownAndTransferLease) {
+ // Just pass the message then.
+ return false;
+ }
+
+ log.info("Test: awaiting for upsert triggering and lease
transfer.");
+
+ try {
+ upsertIsTriggeredLatch.await();
Review Comment:
Let's add timeout on the latch await.
--
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]