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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
