You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "DomGarguilo (via GitHub)" <gi...@apache.org> on 2023/03/14 21:01:33 UTC

[GitHub] [accumulo] DomGarguilo opened a new pull request, #3239: Use CompletableFuture for the result in ScanTask

DomGarguilo opened a new pull request, #3239:
URL: https://github.com/apache/accumulo/pull/3239

   Fixes #3238 


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] dlmarion commented on a diff in pull request #3239: Use CompletableFuture for the result in ScanTask

Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion commented on code in PR #3239:
URL: https://github.com/apache/accumulo/pull/3239#discussion_r1140324726


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/scan/ScanTask.java:
##########
@@ -33,7 +33,7 @@
 
   protected final TabletHostingServer server;
   protected AtomicBoolean interruptFlag;
-  protected ArrayBlockingQueue<Object> resultQueue;
+  protected CompletableFuture<Object> resultFuture;

Review Comment:
   I'm not sure that Future's are meant to be re-used. Maybe CompletableFuture is, but there is a lot of complexity (ref: [source](https://github.com/openjdk/jdk/blob/jdk-11+28/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java#L2071)) built into it because it also implements CompletionStage. That complexity is going to cost time, when in reality you just want to set a reference to the result object. I wonder if AtomicReference might be more suitable here.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] cshannon commented on a diff in pull request #3239: Use CompletableFuture for the result in ScanTask

Posted by "cshannon (via GitHub)" <gi...@apache.org>.
cshannon commented on code in PR #3239:
URL: https://github.com/apache/accumulo/pull/3239#discussion_r1141014297


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/scan/ScanTask.java:
##########
@@ -33,7 +33,7 @@
 
   protected final TabletHostingServer server;
   protected AtomicBoolean interruptFlag;
-  protected ArrayBlockingQueue<Object> resultQueue;
+  protected CompletableFuture<Object> resultFuture;

Review Comment:
   I think the main reason to use a Future or current ArrayBlockQueue is so you can wait for the result and have a timeout which is not possible with AtomicReference so I don't know that AtomicReference would work. 
   
   https://github.com/apache/accumulo/blob/540179d1f52dcc478eee3a3ee3c5fac106736c8b/server/tserver/src/main/java/org/apache/accumulo/tserver/scan/ScanTask.java#L124



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] EdColeman commented on a diff in pull request #3239: Use CompletableFuture for the result in ScanTask

Posted by "EdColeman (via GitHub)" <gi...@apache.org>.
EdColeman commented on code in PR #3239:
URL: https://github.com/apache/accumulo/pull/3239#discussion_r1136337609


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/scan/ScanTask.java:
##########
@@ -33,7 +33,7 @@
 
   protected final TabletHostingServer server;
   protected AtomicBoolean interruptFlag;
-  protected ArrayBlockingQueue<Object> resultQueue;
+  protected CompletableFuture<Object> resultFuture;

Review Comment:
   Is this required to be accessed by sub-classes?  Looking at the usages, it seems internal to this class - but not sure we can change now (if it is changing the API?)



##########
server/tserver/src/main/java/org/apache/accumulo/tserver/scan/ScanTask.java:
##########
@@ -73,30 +73,24 @@ public boolean cancel(boolean mayInterruptIfRunning) {
 
     if (state.compareAndSet(INITIAL, CANCELED)) {
       interruptFlag.set(true);
-      resultQueue = null;
+      resultFuture = null;

Review Comment:
   Should this be either cancel() or complete() - setting it to null will block future access to the future - but I don't think it impacts the current task if it is running.  This happens two places in this file.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] dlmarion commented on a diff in pull request #3239: Use CompletableFuture for the result in ScanTask

Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion commented on code in PR #3239:
URL: https://github.com/apache/accumulo/pull/3239#discussion_r1142184621


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/scan/ScanTask.java:
##########
@@ -33,7 +33,7 @@
 
   protected final TabletHostingServer server;
   protected AtomicBoolean interruptFlag;
-  protected ArrayBlockingQueue<Object> resultQueue;
+  protected CompletableFuture<Object> resultFuture;

Review Comment:
   I think this is something that we can replicate (ref: [source](https://github.com/openjdk/jdk/blob/jdk-11%2B28/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java#L424)). Basically, wait while the AtomicReference is empty, return the AtomicReference value when the timeout is over (which may still be empty).



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] DomGarguilo commented on a diff in pull request #3239: Use CompletableFuture for the result in ScanTask

Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo commented on code in PR #3239:
URL: https://github.com/apache/accumulo/pull/3239#discussion_r1143869044


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/scan/ScanTask.java:
##########
@@ -33,7 +33,7 @@
 
   protected final TabletHostingServer server;
   protected AtomicBoolean interruptFlag;
-  protected ArrayBlockingQueue<Object> resultQueue;
+  protected CompletableFuture<Object> resultFuture;

Review Comment:
   Okay I'll just close this for now along with the ticket. Seems like it might not be worth changing this right now.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] cshannon commented on a diff in pull request #3239: Use CompletableFuture for the result in ScanTask

Posted by "cshannon (via GitHub)" <gi...@apache.org>.
cshannon commented on code in PR #3239:
URL: https://github.com/apache/accumulo/pull/3239#discussion_r1142276284


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/scan/ScanTask.java:
##########
@@ -33,7 +33,7 @@
 
   protected final TabletHostingServer server;
   protected AtomicBoolean interruptFlag;
-  protected ArrayBlockingQueue<Object> resultQueue;
+  protected CompletableFuture<Object> resultFuture;

Review Comment:
   I'd probably just leave it as is, I don't see a pressing need to actually change this.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] cshannon commented on a diff in pull request #3239: Use CompletableFuture for the result in ScanTask

Posted by "cshannon (via GitHub)" <gi...@apache.org>.
cshannon commented on code in PR #3239:
URL: https://github.com/apache/accumulo/pull/3239#discussion_r1140282282


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/scan/ScanTask.java:
##########
@@ -33,7 +33,7 @@
 
   protected final TabletHostingServer server;
   protected AtomicBoolean interruptFlag;
-  protected ArrayBlockingQueue<Object> resultQueue;
+  protected CompletableFuture<Object> resultFuture;

Review Comment:
   Also, do we need to mark this volatile? I don't _think_ we do but just wanted to mention it to double check with others who are more familiar with the scan code. I took a quick look and it looks like instances of ScanTask (LookupTask or NextBatchTask) should only be accessed by a TServer in a single thread since the TServer will create new instances when getting each RPC call over thrift so this is fine without volatile but I could be missing something.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] dlmarion commented on a diff in pull request #3239: Use CompletableFuture for the result in ScanTask

Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion commented on code in PR #3239:
URL: https://github.com/apache/accumulo/pull/3239#discussion_r1142192200


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/scan/ScanTask.java:
##########
@@ -33,7 +33,7 @@
 
   protected final TabletHostingServer server;
   protected AtomicBoolean interruptFlag;
-  protected ArrayBlockingQueue<Object> resultQueue;
+  protected CompletableFuture<Object> resultFuture;

Review Comment:
   Another option is to leave as-is, it works.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] dlmarion commented on a diff in pull request #3239: Use CompletableFuture for the result in ScanTask

Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion commented on code in PR #3239:
URL: https://github.com/apache/accumulo/pull/3239#discussion_r1140324726


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/scan/ScanTask.java:
##########
@@ -33,7 +33,7 @@
 
   protected final TabletHostingServer server;
   protected AtomicBoolean interruptFlag;
-  protected ArrayBlockingQueue<Object> resultQueue;
+  protected CompletableFuture<Object> resultFuture;

Review Comment:
   I'm not sure that Future's are meant to be re-used. Maybe CompletableFuture is, but there is a lot of complexity (ref: [source](https://github.com/openjdk/jdk/blob/jdk-11+28/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java#L2071) built into it because it also implements CompletionStage. That complexity is going to cost time, when in reality you just want to set a reference to the result object. I wonder if AtomicReference might be more suitable here.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] cshannon commented on a diff in pull request #3239: Use CompletableFuture for the result in ScanTask

Posted by "cshannon (via GitHub)" <gi...@apache.org>.
cshannon commented on code in PR #3239:
URL: https://github.com/apache/accumulo/pull/3239#discussion_r1140282282


##########
server/tserver/src/main/java/org/apache/accumulo/tserver/scan/ScanTask.java:
##########
@@ -33,7 +33,7 @@
 
   protected final TabletHostingServer server;
   protected AtomicBoolean interruptFlag;
-  protected ArrayBlockingQueue<Object> resultQueue;
+  protected CompletableFuture<Object> resultFuture;

Review Comment:
   Also, do we need to mark this volatile? I don't _think_ we do but just wanted to mention it to double check with others who are more familiar with the scan code. I took a quick look and it looks like instances of ScanTask (LookupTask or NextBatchTask) should only be accessed by a TServer in a single thread since the TServer will create new instances when getting each RPC call over thrift but I could be missing something.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] DomGarguilo closed pull request #3239: Use CompletableFuture for the result in ScanTask

Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo closed pull request #3239: Use CompletableFuture for the result in ScanTask
URL: https://github.com/apache/accumulo/pull/3239


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org