Copilot commented on code in PR #16872:
URL: https://github.com/apache/pinot/pull/16872#discussion_r2370729641


##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/mailbox/channel/MailboxContentObserver.java:
##########
@@ -72,9 +71,8 @@ public void onNext(MailboxContent mailboxContent) {
     }
     try {
       long timeoutMs = 
Context.current().getDeadline().timeRemaining(TimeUnit.MILLISECONDS);
-      List<ByteBuffer> buffers = new ArrayList<>(_mailboxBuffers);
+      ReceivingMailbox.ReceivingMailboxStatus status = 
_mailbox.offerRaw(_mailboxBuffers, timeoutMs);
       _mailboxBuffers.clear();

Review Comment:
   Potential race condition: _mailboxBuffers could be modified by another 
thread between the call to offerRaw() and clear(). Consider clearing within a 
synchronized block or using a local copy as in the original code.



##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/mailbox/channel/MailboxContentObserver.java:
##########
@@ -48,16 +48,15 @@ public class MailboxContentObserver implements 
StreamObserver<MailboxContent> {
 
   private final MailboxService _mailboxService;
   private final StreamObserver<MailboxStatus> _responseObserver;
-  private final List<ByteBuffer> _mailboxBuffers;
+  private final List<ByteBuffer> _mailboxBuffers = 
Collections.synchronizedList(new ArrayList<>());

Review Comment:
   Using Collections.synchronizedList() provides coarse-grained synchronization 
which can become a bottleneck under high concurrency. Consider using 
ConcurrentLinkedQueue or explicit locking if this collection is accessed 
frequently from multiple threads.



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

Reply via email to