jaydeepkumar1984 commented on code in PR #4456:
URL: https://github.com/apache/cassandra/pull/4456#discussion_r2516145970
##########
test/unit/org/apache/cassandra/repair/autorepair/AutoRepairUtilsTest.java:
##########
@@ -538,4 +538,42 @@ public void testSkipSystemTraces()
{
assertFalse(AutoRepairUtils.shouldConsiderKeyspace(Keyspace.open(SchemaConstants.TRACE_KEYSPACE_NAME)));
}
+
+ @Test
+ public void testAutoRepairHistoryOutOfOrderDeleteRaceCondition()
+ {
+ // Setup: Create a node that will be deleted
+ UUID nodeToDelete = UUID.randomUUID();
+ UUID votingNode = UUID.randomUUID();
+
+ // Insert an initial row for the node to be deleted
+ QueryProcessor.executeInternal(String.format(
+ "INSERT INTO %s.%s (repair_type, host_id, repair_start_ts,
repair_finish_ts) VALUES ('%s', %s, 100, 200)",
+ SchemaConstants.DISTRIBUTED_KEYSPACE_NAME,
SystemDistributedKeyspace.AUTO_REPAIR_HISTORY,
+ repairType, nodeToDelete));
+
+ // Verify the row exists
+ UntypedResultSet beforeDelete =
QueryProcessor.executeInternal(String.format(
+ "SELECT * FROM %s.%s WHERE repair_type = '%s' AND host_id = %s",
+ SchemaConstants.DISTRIBUTED_KEYSPACE_NAME,
SystemDistributedKeyspace.AUTO_REPAIR_HISTORY,
+ repairType, nodeToDelete));
+ assertNotNull(beforeDelete);
+ assertEquals(1, beforeDelete.size());
+
+ // Simulate the race condition:
+ // 1. First, the delete is executed (this should create a tombstone)
+ AutoRepairUtils.deleteAutoRepairHistory(repairType, nodeToDelete);
+
+ // 2. Then, a vote to delete arrives after the row has already been
deleted
+ AutoRepairUtils.addHostIdToDeleteHosts(repairType, votingNode,
nodeToDelete);
+
Review Comment:
Also clear deleted hosts as part of the late event
```
AutoRepairUtils.clearDeleteHosts(repairType, nodeToDelete);
```
##########
test/unit/org/apache/cassandra/repair/autorepair/AutoRepairUtilsTest.java:
##########
@@ -538,4 +538,42 @@ public void testSkipSystemTraces()
{
assertFalse(AutoRepairUtils.shouldConsiderKeyspace(Keyspace.open(SchemaConstants.TRACE_KEYSPACE_NAME)));
}
+
+ @Test
+ public void testAutoRepairHistoryOutOfOrderDeleteRaceCondition()
Review Comment:
This test passes even without any of the changes because
_ADD_HOST_ID_TO_DELETE_HOSTS_ already had _IF EXISTS_, however, the changes in
this PR are necessary.
Please clarify in the description that the PR includes the test case and a
certain cases we missed earlier.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]