nandorKollar commented on code in PR #4487:
URL: https://github.com/apache/polaris/pull/4487#discussion_r3267520129


##########
runtime/service/src/main/java/org/apache/polaris/service/events/listeners/inmemory/InMemoryBufferEventListener.java:
##########
@@ -63,7 +63,13 @@ public class InMemoryBufferEventListener extends 
PolarisPersistenceEventListener
   @Override
   protected void processEvent(String realmId, PolarisEvent event) {
     var processor = Objects.requireNonNull(processors.get(realmId));
-    processor.onNext(event);
+    // Reactive Streams rule 1.3 requires onNext() to be called sequentially. 
Mutiny's
+    // UnicastProcessor is not safe for concurrent onNext() calls; concurrent 
emissions
+    // can silently drop events. Synchronize on the processor so that 
concurrent
+    // processEvent() calls for the same realm serialize on the same 
underlying processor.
+    synchronized (processor) {

Review Comment:
   The other problem mentioned by @visit2rahul related to the `onComplete()` 
worths consideration though. That one is not synchronized, and probably it can 
cause spooky race conditions, when used along with `onNext()` in multi-threaded 
environments. Maybe that was the cause of the original intermittent test 
failures too?



-- 
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]

Reply via email to