kfaraz commented on code in PR #18769:
URL: https://github.com/apache/druid/pull/18769#discussion_r2549623961
##########
server/src/test/java/org/apache/druid/server/coordinator/simulate/SegmentBalancingTest.java:
##########
@@ -308,4 +308,47 @@ public void testMaxSegmentsAreMovedWhenClusterIsSkewed()
verifyNotEmitted(Metric.MOVE_SKIPPED);
}
+ /**
+ * Test for https://github.com/apache/druid/issues/18764
+ *
+ */
+ @Test
+ public void testSegmentMoveDoesNotCauseIncorrectDrop()
+ {
+ // Setup: 2 historicals, 1x replication, all segments on server A
+ final CoordinatorSimulation sim =
+ CoordinatorSimulation.builder()
+ .withSegments(segments)
+ .withServers(historicalT11, historicalT12)
+ .withRules(datasource, Load.on(Tier.T1,
1).forever())
+ .build();
+
+ segments.forEach(historicalT11::addDataSegment);
+ startSimulation(sim);
+
+ // Run 1: Initiate moves from A to B
+ runCoordinatorCycle();
+ verifyValue(Metric.MOVED_COUNT, 5L);
+
+ // Physically load segments on B, but don't fire callbacks yet
+ loadQueuedSegmentsSkipCallbacks();
+ Assert.assertEquals(10, historicalT11.getTotalSegments());
+ Assert.assertEquals(5, historicalT12.getTotalSegments());
+
+ // Fire callbacks asynchronously BEFORE next coordinator run
+ // This simulates the race: callbacks fire after first build() but state
is stale
+ firePendingLoadCallbacks();
+ runCoordinatorCycle();
Review Comment:
Is this able to simulate the race condition correctly?
IIUC, as we discussed offline, the race condition gets triggered if the
callback is invoked after the `HistoricalManagementDuties` group starts (so
that snapshot is already taken) and before the `RunRules` duty of that group
has started (so that `RunRules` ends up working on a stale snapshot).
--
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]