[ https://issues.apache.org/jira/browse/HIVE-24723?focusedWorklogId=547221&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-547221 ]
ASF GitHub Bot logged work on HIVE-24723: ----------------------------------------- Author: ASF GitHub Bot Created on: 03/Feb/21 18:55 Start Date: 03/Feb/21 18:55 Worklog Time Spent: 10m Work Description: belugabehr commented on a change in pull request #1939: URL: https://github.com/apache/hive/pull/1939#discussion_r569663760 ########## File path: ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionPool.java ########## @@ -395,20 +379,38 @@ int getInitialSize() { } while (!deltaRemaining.compareAndSet(oldVal, oldVal + delta)); int toStart = oldVal + delta; if (toStart <= 0) return createDummyFuture(); - LOG.info("Resizing the pool; adding " + toStart + " sessions"); - - // 2) If we need to create some extra sessions, we'd do it just like startup does. - int threadCount = Math.max(1, Math.min(toStart, - HiveConf.getIntVar(initConf, ConfVars.HIVE_SERVER2_TEZ_SESSION_MAX_INIT_THREADS))); - List<ListenableFutureTask<Boolean>> threadTasks = new ArrayList<>(threadCount); - // This is an async method, so always launch threads, even for a single task. - for (int i = 0; i < threadCount; ++i) { - ListenableFutureTask<Boolean> task = ListenableFutureTask.create( - new CreateSessionsRunnable(deltaRemaining)); - new Thread(task, "Tez pool resize " + i).start(); - threadTasks.add(task); + LOG.info("Resizing the pool; adding {} sessions", toStart); + + final int threadCount = + Math.min(toStart, HiveConf.getIntVar(initConf, ConfVars.HIVE_SERVER2_TEZ_SESSION_MAX_INIT_THREADS)); + + return createSessions(toStart, threadCount); + } + + private ListenableFuture<List<Boolean>> createSessions(int sessionCount, int maxParallel) { + Preconditions.checkArgument(sessionCount > 0); + Preconditions.checkArgument(maxParallel > 0); Review comment: This was previous checked in the calling methods. I have moved it here to remove redundancy. Not an expensive operation and it's not called all that often, so no worries even if it is doubled somewhere. Better safe than sorry as the code changes. ---------------------------------------------------------------- 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 547221) Time Spent: 1h 20m (was: 1h 10m) > Use ExecutorService in TezSessionPool > ------------------------------------- > > Key: HIVE-24723 > URL: https://issues.apache.org/jira/browse/HIVE-24723 > Project: Hive > Issue Type: Improvement > Components: Tez > Reporter: David Mollitor > Assignee: David Mollitor > Priority: Minor > Labels: pull-request-available > Time Spent: 1h 20m > Remaining Estimate: 0h > > Currently there are some wonky home-made thread pooling action going on in > {{TezSessionPool}}. Replace it with some JDK/Guava goodness. -- This message was sent by Atlassian Jira (v8.3.4#803005)