flyrain commented on code in PR #4498:
URL: https://github.com/apache/polaris/pull/4498#discussion_r3277215570


##########
runtime/service/src/main/java/org/apache/polaris/service/events/listeners/inmemory/InMemoryBufferEventListener.java:
##########
@@ -56,8 +56,15 @@ public class InMemoryBufferEventListener extends 
PolarisPersistenceEventListener
       Caffeine.newBuilder()
           .expireAfterAccess(Duration.ofHours(1))
           .evictionListener(
-              (String realmId, UnicastProcessor<?> processor, RemovalCause 
cause) ->
-                  processor.onComplete())
+              (String realmId, UnicastProcessor<?> processor, RemovalCause 
cause) -> {
+                // onComplete is not synchronized in smallrye-mutiny's 
UnicastProcessor,
+                // unlike onNext. Acquire the processor's intrinsic monitor 
(the same one
+                // onNext uses) so that eviction-driven onComplete and 
concurrent
+                // processEvent-driven onNext mutually exclude.
+                synchronized (processor) {

Review Comment:
   Comment is good. Worth one extra line: this assumes smallrye-mutiny's 
`UnicastProcessor.onNext` locks on `this` — re-verify on mutiny version bumps, 
otherwise this guard becomes a silent no-op.



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