From 0bb18c6789906d8c5daa91ae19a161d1f17c247d Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 22 Apr 2026 21:42:05 +0200 Subject: [PATCH] feat(backend): add thumbnailExecutor bean for isolated thumbnail workload Dedicated thread pool (core=1, max=2, queue=200) with CallerRunsPolicy for back-pressure. Keeps thumbnail rendering off the shared taskExecutor used by OCR and out of the AbortPolicy queue that drops work on overflow. Quick-upload batches (15+ files) now apply back-pressure instead of silently dropping thumbnail jobs. Refs #307 Co-Authored-By: Claude Opus 4.7 --- .../familienarchiv/config/AsyncConfig.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backend/src/main/java/org/raddatz/familienarchiv/config/AsyncConfig.java b/backend/src/main/java/org/raddatz/familienarchiv/config/AsyncConfig.java index 9a7caa80..bafddbfc 100644 --- a/backend/src/main/java/org/raddatz/familienarchiv/config/AsyncConfig.java +++ b/backend/src/main/java/org/raddatz/familienarchiv/config/AsyncConfig.java @@ -37,4 +37,19 @@ public class AsyncConfig { executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy()); return executor; } + + @Bean("thumbnailExecutor") + public Executor thumbnailExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(1); + executor.setMaxPoolSize(2); + executor.setQueueCapacity(200); + executor.setThreadNamePrefix("Thumbnail-"); + // CallerRunsPolicy applies back-pressure to quick-upload batches and admin backfill + // instead of dropping work (shared taskExecutor uses AbortPolicy). Safe because the + // task is dispatched via TransactionSynchronization.afterCommit, which runs on a + // post-commit callback thread without active transaction synchronization. + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); + return executor; + } } \ No newline at end of file