sohami commented on a change in pull request #1504: DRILL-6792: Find the right 
probe side fragment wrapper & fix DrillBuf…
URL: https://github.com/apache/drill/pull/1504#discussion_r236407149
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/work/filter/RuntimeFilterSink.java
 ##########
 @@ -202,32 +209,36 @@ public void setJoinMjId2ScanMjId(Map<Integer, Integer> 
joinMjId2ScanMjId)
     @Override
     public void run()
     {
-      while (joinMjId2rfNumber == null || !joinMjId2rfNumber.isEmpty()) {
-        queueLock.lock();
-        RuntimeFilterWritable toAggregate = rfQueue.poll();
-        if (toAggregate == null) {
-          try {
-            notEmpty.await();
-          }
-          catch (InterruptedException e) {
-            logger.error("RFW_Aggregator thread being interrupted", e);
-          }
-          finally {
-            queueLock.unlock();
-          }
-        } else {
-          queueLock.unlock();
+      while ((joinMjId2rfNumber == null || !joinMjId2rfNumber.isEmpty() ) && 
running.get()) {
+        RuntimeFilterWritable toAggregate = null;
+        synchronized (rfQueue) {
           try {
-            aggregate(toAggregate);
-          }
-          catch (Exception e) {
-            logger.error("fail to aggregate or route the RFW", e);
-            throw new RuntimeException(e);
-          }
-          finally {
-            toAggregate.close();
+            toAggregate = rfQueue.poll();
+            while (toAggregate == null && running.get()) {
+              rfQueue.wait();
+              toAggregate = rfQueue.poll();
+            }
+          } catch (InterruptedException ex) {
+            logger.error("RFW_Aggregator thread being interrupted", ex);
+            continue;
           }
         }
+        // perform aggregate outside the sync block.
+        try {
+          aggregate(toAggregate);
 
 Review comment:
   check if `toAggregate != null` and then only call `aggregate(toAggregate)`. 
This can happen for case when `running` is false.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to