This is an automated email from the ASF dual-hosted git repository. tballison pushed a commit to branch TIKA-4809-stage-9 in repository https://gitbox.apache.org/repos/asf/tika.git
commit ab8f656c788b301a6440f1c89b99dd229200c425 Author: tallison <[email protected]> AuthorDate: Mon Aug 10 20:54:17 2026 -0400 TIKA-4809: Stop NO_PARSE requests waiting out a poll for a result that never comes --- .../apache/tika/pipes/core/server/PipesServer.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/PipesServer.java b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/PipesServer.java index 5bd291cbba..069e8c4170 100644 --- a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/PipesServer.java +++ b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/PipesServer.java @@ -422,6 +422,17 @@ public class PipesServer implements AutoCloseable { pipesConfig.getParseMode()); } + /** + * Poll slice used before the intermediate result has been written. The parsing modes add + * theirs immediately and then block on the latch released below, so this is short-lived -- + * but NO_PARSE never produces one at all, and a long slice here was costing every such + * request the full wait before completion was even checked. + */ + private static final long PRE_INTERMEDIATE_POLL_MS = 5; + + /** Steady-state slice once the intermediate result is out of the way. */ + private static final long COMPLETION_POLL_MS = 100; + private void loopUntilDone(FetchEmitTuple fetchEmitTuple, ParseContext mergedContext, ExecutorCompletionService<PipesResult> executorCompletionService, ArrayBlockingQueue<Metadata> intermediateResult, CountDownLatch countDownLatch, @@ -436,7 +447,7 @@ public class PipesServer implements AutoCloseable { while (true) { // Check for intermediate result (pre-parse metadata) if (!wroteIntermediateResult) { - Metadata intermediate = intermediateResult.poll(100, TimeUnit.MILLISECONDS); + Metadata intermediate = intermediateResult.poll(PRE_INTERMEDIATE_POLL_MS, TimeUnit.MILLISECONDS); if (intermediate != null) { writeIntermediate(intermediate); countDownLatch.countDown(); @@ -444,8 +455,11 @@ public class PipesServer implements AutoCloseable { } } - // Check for task completion (can happen even without intermediate result if crash occurs early) - Future<PipesResult> future = executorCompletionService.poll(100, TimeUnit.MILLISECONDS); + // Check for task completion (can happen even without intermediate result if crash occurs early). + // Don't block here until the intermediate result is settled: NO_PARSE never produces one, so a + // long wait is pure latency on every request rather than an occasional cost. + Future<PipesResult> future = executorCompletionService.poll( + wroteIntermediateResult ? COMPLETION_POLL_MS : 0, TimeUnit.MILLISECONDS); if (future != null) { PipesResult pipesResult = null; try {
