fix: CancellableQueryManager의 CachedThreadPool을 제한된 ThreadPoolExecutor로 교체

Phase 1.3: 무제한 스레드 생성 방지
- newCachedThreadPool → ThreadPoolExecutor(core:5, max:20, queue:100)
- CallerRunsPolicy 적용으로 큐 포화 시 자연 백프레셔
- 부하 시 무제한 스레드 생성으로 인한 OOM/컨텍스트 스위칭 오버헤드 방지

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
HeungTak Lee 2026-02-06 13:37:17 +09:00
부모 78ff307785
커밋 21916716bf

파일 보기

@ -20,13 +20,20 @@ public class CancellableQueryManager {
// 활성 쿼리 컨텍스트 관리
private final Map<String, QueryExecutionContext> activeQueries = new ConcurrentHashMap<>();
// 쿼리 실행을 위한 스레드
private final ExecutorService queryExecutor = Executors.newCachedThreadPool(r -> {
Thread thread = new Thread(r);
thread.setName("query-executor-" + thread.getId());
thread.setDaemon(true);
return thread;
});
// 쿼리 실행을 위한 스레드 (상한 제한)
private final ExecutorService queryExecutor = new ThreadPoolExecutor(
5, // corePoolSize
20, // maximumPoolSize (무제한 방지)
60L, TimeUnit.SECONDS, // keepAliveTime
new LinkedBlockingQueue<>(100), // 대기 크기 제한
r -> {
Thread thread = new Thread(r);
thread.setName("query-executor-" + thread.getId());
thread.setDaemon(true);
return thread;
},
new ThreadPoolExecutor.CallerRunsPolicy() // 포화 호출 스레드에서 실행
);
/**
* 취소 가능한 쿼리 실행