You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "ShauryaChauhan1411 (via GitHub)" <gi...@apache.org> on 2026/03/11 17:59:16 UTC

[PR] [IOTDB-17268] Optimize: replace unbounded thread pool with bounded ThreadPoolExecutor in SessionPoolExample [iotdb]

ShauryaChauhan1411 opened a new pull request, #17287:
URL: https://github.com/apache/iotdb/pull/17287

   In the current SessionPoolExample.java, the ExecutorService was using Executors.newFixedThreadPool(10). While it limits the number of active threads, it uses an unbounded LinkedBlockingQueue by default. In a high-throughput scenario, this can lead to an excessive number of queued tasks, potentially causing an OutOfMemoryError (OOM).
   
   This PR replaces the default fixed thread pool with a manually configured ThreadPoolExecutor that uses:
   
   Core/Max Pool Size: 10 threads.
   
   Bounded Queue: ArrayBlockingQueue with a capacity of 1000 tasks.
   
   Rejection Policy: CallerRunsPolicy to throttle the submission of new tasks when the queue is full, ensuring system stability.
   
   Changes
   Modified SessionPoolExample.java to use ThreadPoolExecutor instead of Executors.newFixedThreadPool.
   
   Added necessary imports for ArrayBlockingQueue, ThreadPoolExecutor, and TimeUnit.
   
   Cleaned up the thread pool initialization to follow best practices for resource management.
   
   Test Result
   Built successfully using mvn clean install -DskipTests -pl example/session -am.
   
   Verified that the example runs correctly and executes queries without resource exhaustion.


-- 
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: reviews-unsubscribe@iotdb.apache.org

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