[GitHub] [tinkerpop] lyndonbauto commented on pull request #2090: TINKERPOP-2958 Added cancel for query timeout task when query completes.

2023-06-14 Thread via GitHub


lyndonbauto commented on PR #2090:
URL: https://github.com/apache/tinkerpop/pull/2090#issuecomment-1591671107

   Thanks for looking into that Ken, and yeah I noticed that this didn't really 
become an issue until the Context was added to it.


-- 
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: commits-unsubscr...@tinkerpop.apache.org

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



[GitHub] [tinkerpop] lyndonbauto commented on pull request #2090: TINKERPOP-2958 Added cancel for query timeout task when query completes.

2023-06-12 Thread via GitHub


lyndonbauto commented on PR #2090:
URL: https://github.com/apache/tinkerpop/pull/2090#issuecomment-1587954864

   @kenhuuu 
   > Hi Lyndon, is it possible for you to share what kind of testing you were 
running that showed this issue?
   
   Hey Ken, yeah sure, this isn't pretty code but here it is:
   
   ```
   package com.aerospike.firefly.server;
   
   import com.aerospike.firefly.Server;
   import org.apache.tinkerpop.gremlin.driver.Cluster;
   import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection;
   import 
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
   import org.apache.tinkerpop.gremlin.structure.Property;
   import org.junit.Test;
   
   import java.util.ArrayList;
   import java.util.List;
   import java.util.Random;
   import java.util.Timer;
   import java.util.TimerTask;
   import java.util.concurrent.ExecutorService;
   import java.util.concurrent.Executors;
   import java.util.concurrent.Future;
   import java.util.stream.Collectors;
   
   import static org.apache.tinkerpop.gremlin.driver.Tokens.ARGS_EVAL_TIMEOUT;
   import static 
org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal;
   
   public class TestServer {
   
   private static final long SECOND = 1000;
   private static final long MINUTE = 60 * SECOND;
   private static final long TEST_DURATION = 4 * MINUTE;
   private long totalExecuted = 0;
   Server server;
   @Test
   public void testServer() throws Exception {
   server = Server.main(new String[] 
{"../conf/firefly-gremlin-server-local.yaml"});
   HEAP_REPORTING_TIMER.schedule(new HeapReport(), 0, 5000);
   exposeLeak();
   }
   
   private static final Timer HEAP_REPORTING_TIMER = new Timer(true);
   
   private class HeapReport extends TimerTask {
   @Override
   public void run() {
   System.gc();
   System.gc();
   System.gc();
   System.out.printf("Heap size: %d MB%n", 
Runtime.getRuntime().totalMemory() / 1024 / 1024);
   System.out.printf("Executed %d queries%n", totalExecuted);
   }
   }
   
   public void exposeLeak() throws Exception {
   final long startTime = System.currentTimeMillis();
   Cluster cluster = 
Cluster.build().addContactPoint("localhost").port(8182).create();
   DriverRemoteConnection drc = DriverRemoteConnection.using(cluster, 
"g");
   // final DriverRemoteConnection drc = 
DriverRemoteConnection.using("localhost", 8182, "g");
   final GraphTraversalSource g = traversal().withRemote(drc);
   final ExecutorService executorService = 
Executors.newFixedThreadPool(16);
   
   g.with(ARGS_EVAL_TIMEOUT, 1L).V().drop().iterate();
   for (int i = 0; i < 25000; i++) {
   g.addV("randomVertex").
   property("last_seen", String.format("%d", 
System.currentTimeMillis())).
   property("something", String.format("%d", i)).
   property("otherThing", String.format("%d", i)).
   property("anotherThing", String.format("%d", i)).
   property("yetAnotherThing", String.format("%d", i)).
   property("andAnotherThing", String.format("%d", i)).
   property("andYetAnotherThing", String.format("%d", i)).
   iterate();
   }
   
   final List ids = g.V().id().toList();
   final List>> futures = new 
ArrayList<>();
   while (System.currentTimeMillis() - startTime <= TEST_DURATION) {
   while (futures.size() > 500) {
   Thread.sleep(100);
   final List>> 
completedFutures = 
futures.stream().filter(Future::isDone).collect(Collectors.toList());
   completedFutures.forEach(f -> {
   try {
   f.get();
   } catch (Exception e) {
   e.printStackTrace();
   }
   });
   totalExecuted += completedFutures.size();
   futures.removeAll(completedFutures);
   }
   final Random rand = new Random();
   final List idz = new ArrayList<>();
   for (int i = 0; i < 9; i++) {
   idz.add(ids.get(rand.nextInt(ids.size(;
   }
   futures.add(executorService.submit(() -> 
g.V(idz).properties("last_seen").toList()));
   }
   futures.forEach(f-> {
   try {
   f.get();
   } catch (Exception e) {
   e.printStackTrace();
   }
   });
   drc.close();
   Thread.sleep(3);
   }
   }
   ```
   
   The server code is:
   
   ```
   package com.aerospike.firefly;
   
   import 

[GitHub] [tinkerpop] lyndonbauto commented on pull request #2090: TINKERPOP-2958 Added cancel for query timeout task when query completes.

2023-06-12 Thread via GitHub


lyndonbauto commented on PR #2090:
URL: https://github.com/apache/tinkerpop/pull/2090#issuecomment-1587887574

   > Can similar problem occur in `GremlinExecutor.eval`?
   I looked and as far as I can tell, this issue is limited to the two places I 
fixed it, however I am not well versed with this part of the gremlin code base 
so I may be wrong.
   
   > Are you planning to open separate PR for 3.5 and 3.6?
   This code is identical in 3.5 and 3.6 so my plan was to merge this to 
3.5-dev then merge 3.5-dev into 3.6-dev. I just noticed I was pointed at master 
but meant to be pointed at 3.5-dev in this PR. @spmallette is this the right 
merging strategy?
   


-- 
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: commits-unsubscr...@tinkerpop.apache.org

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