kaybhutani commented on code in PR #3638:
URL: https://github.com/apache/celeborn/pull/3638#discussion_r3021658835
##########
client/src/test/scala/org/apache/celeborn/client/WorkerStatusTrackerSuite.scala:
##########
@@ -92,6 +96,68 @@ class WorkerStatusTrackerSuite extends CelebornFunSuite {
Assert.assertFalse(statusTracker.excludedWorkers.containsKey(mock("host1")))
}
+ test("concurrent access to shuttingWorkers should not throw
ConcurrentModificationException") {
+ val celebornConf = new CelebornConf()
+ val statusTracker = new WorkerStatusTracker(celebornConf, null)
+ val numWriters = 5
+ val numReaders = 5
+ val totalThreads = numWriters + numReaders
+ val executor = Executors.newFixedThreadPool(totalThreads)
+ val barrier = new CyclicBarrier(totalThreads)
+ val errors = new AtomicInteger(0)
+ val futures = new ArrayBuffer[Future[_]]()
+
+ // Pre-populate the set so iteration takes longer, increasing the
+ // window for concurrent modification to trigger a CME with HashSet.
+ (1 to 1000).foreach { i =>
+ statusTracker.shuttingWorkers.add(mock(s"pre-$i"))
+ }
+
+ try {
+ // Writers: concurrently add and remove workers
+ (1 to numWriters).foreach { i =>
+ futures += executor.submit(new Runnable {
+ override def run(): Unit = {
+ barrier.await()
+ (1 to 1000).foreach { j =>
+ val worker = mock(s"host-$i-$j")
+ statusTracker.shuttingWorkers.add(worker)
+ statusTracker.shuttingWorkers.remove(worker)
+ }
+ }
+ })
+ }
+
+ // Readers: iterate shuttingWorkers directly, mirroring how
currentFailedWorkers iterates it
+ (1 to numReaders).foreach { i =>
+ futures += executor.submit(new Runnable {
+ override def run(): Unit = {
+ try {
+ barrier.await()
+ (1 to 1000).foreach { _ =>
+ statusTracker.shuttingWorkers.forEach(_ => ())
Review Comment:
my bad, i ran with scala 2.12, made the change and ran spark2.4 profile.
hopefully should fix now
--
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]