Concurrency issues in search (#23249)

* Fix - 23213 : WebSocketManager Issue on concurrent modification

* Await till consumers comelete the job

---------

Co-authored-by: Pere Miquel Brull <peremiquelbrull@gmail.com>
This commit is contained in:
Mohit Yadav 2025-09-04 22:55:50 +05:30 committed by GitHub
parent 2fb41687d2
commit 080f0d21fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 5 deletions

View File

@ -756,10 +756,9 @@ public class SearchIndexApp extends AbstractNativeApplication {
private void waitForConsumersToComplete(CountDownLatch consumerLatch)
throws InterruptedException {
boolean finished = consumerLatch.await(5, TimeUnit.MINUTES);
if (!finished) {
LOG.warn("Consumers did not finish within timeout");
}
LOG.info("Waiting for all consumers to complete their work...");
consumerLatch.await(); // Wait indefinitely for consumers to finish all work
LOG.info("All consumers have completed their work");
}
private void handleInterruption(InterruptedException e) throws InterruptedException {

View File

@ -108,7 +108,7 @@ public class WebSocketManager {
userSocketConnections =
activityFeedEndpoints.containsKey(id)
? activityFeedEndpoints.get(id)
: new HashMap<>();
: new ConcurrentHashMap<>();
userSocketConnections.put(socket.getId(), socket);
activityFeedEndpoints.put(id, userSocketConnections);
}