You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by GitBox <gi...@apache.org> on 2021/04/21 12:58:48 UTC

[GitHub] [tinkerpop] divijvaidya commented on a change in pull request #1418: TINKERPOP-2550 Fixed bug in java Client initialization

divijvaidya commented on a change in pull request #1418:
URL: https://github.com/apache/tinkerpop/pull/1418#discussion_r617508796



##########
File path: gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
##########
@@ -511,19 +515,24 @@ protected Connection chooseConnection(final RequestMessage msg) throws TimeoutEx
          */
         @Override
         protected void initializeImplementation() {
+            // use a special executor here to initialize the Host instances as the worker thread pool may be
+            // insufficiently sized for this task and the parallel initialization of the ConnectionPool. if too small
+            // tasks may be schedule in such a way as to produce a deadlock: TINKERPOP-2550
+            //
+            // the cost of this single threaded executor here should be fairly small because it is only used once at
+            // initialization and shutdown. since users will typically construct a Client once for the life of their
+            // application there shouldn't be tons of thread pools being created and destroyed.
+            final BasicThreadFactory threadFactory = new BasicThreadFactory.Builder().namingPattern("gremlin-driver-init-%d").build();
+            final ExecutorService hostExecutor = Executors.newSingleThreadExecutor(threadFactory);

Review comment:
       starting and shutting down executor is an expensive operation which will impact the client start up/shut down time which will impact use cases when customers have short running clients such as in AWS Lambda. Is there an alternative approach that can avoid 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.

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