Skip to content

ParallelScanSafetyTest can deadlock in a full-module run: caller-runs task blocks on a latch only a pool task can release #6568

Closed

Description

@lvca

Summary

com.arcadedb.query.sql.executor.ParallelScanSafetyTest.parallelScanCompletesWhileQueryPoolIsSaturated can deadlock outright during a full engine-module test run. Not a slow test - a hang, at 0% CPU, indefinitely.

Found while verifying #6379 (unrelated change, sparse-vector compaction only). Reproduced twice on an otherwise idle machine, so it is not simply CPU contention.

Evidence

jstack on the wedged Surefire fork:

"main" ... java.lang.Thread.State: WAITING (parking)
    at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:230)
    at com.arcadedb.query.sql.executor.ParallelScanSafetyTest
         .lambda$parallelScanCompletesWhileQueryPoolIsSaturated$1(ParallelScanSafetyTest.java:87)
    at java.util.concurrent.FutureTask.run(FutureTask.java:317)
    at com.arcadedb.utility.DedicatedThreadPool.runRejectedTask(DedicatedThreadPool.java:270)
    at com.arcadedb.utility.DedicatedThreadPool.runOnCaller(DedicatedThreadPool.java:238)

That is a caller-runs latch deadlock: the pool rejects the task, runOnCaller executes it on the submitting thread, and the task then blocks on a CountDownLatch that only another pool task can count down. The submitter is now occupied by the task it was going to wait for.

Why it is worth fixing rather than ignoring

  • It presents in CI as a lane timeout with no failing assertion, so it looks like infrastructure trouble rather than a test problem, and the real cause is invisible without a thread dump from a wedged run.
  • It is load-dependent: the test passes alone in ~1.7s and passes immediately after an unrelated class, so it needs full-suite context. That makes it exactly the kind of failure that shows up rarely, on someone else's PR, and gets waved off.
  • slow-unit-tests is already near its 60-minute cap, so a lane that stalls here fails as a timeout with nothing to point at.

Worth checking beyond the test

The caller-runs saturation policy is production behaviour, not test-only. Whether an engine-internal caller-runs execution can ever block on something only that pool can complete is worth an audit - if it can, the same shape is reachable outside tests. See the engine-concurrency skill for the pool inventory and saturation policy.

Suggested

Either give the latch wait a bounded timeout and fail loudly, or have the test reserve its worker before saturating the pool so the counting-down task cannot be the one that gets rejected.

Activity

  1. added this to the 26.9.1 milestone on Aug 22, 2026
  2. self-assigned this
    on Aug 22, 2026
  3. added theissue type on Aug 25, 2026
  4. added
    in progress
    on Aug 25, 2026
  5. added 8 commits that reference this issue on Aug 26, 2026
  6. lvca commented on Aug 26, 2026

    @lvca
    MemberAuthor

    Fixed in #6739.

    What was wrong. ArcadeDB's internal thread pools fall back to "run the task on the thread that submitted it" when they get overloaded. That fallback was being relied on as the thing that prevents a deadlock, and it isn't: it only kicks in once the pool's queue is completely full. With free slots in the queue the task is simply accepted and the submitting thread waits for it. If every worker in the pool is itself a thread waiting on a task it submitted, nothing in that pool can ever run again.

    The symptom is the worst kind: the JVM sits at 0% CPU with no error, no failing test and nothing in the log. In CI it looks like an infrastructure timeout rather than a bug.

    What changed. A thread that is about to wait for work it handed to a pool now takes that work back out of the queue and does it itself, instead of parking on it. Because a thread waiting for its own work always has something it can get on with, the whole fan-out is now guaranteed to finish - at any pool size, and however deeply the parallel work nests. This covers parallel graph algorithms (PageRank, connected components, BFS), the parallel Cypher operators and parallel scans.

    Two related bugs turned up while doing this and were fixed too: shutting the server down with a query still running could leave background work writing into results the query had already given up on, and a query cancelled or timed out at the wrong moment could return a partial result reported as complete.

    For operators. There's a new Reclaimed column on Studio's Server tab (and an arcadedb.executor.tasks.reclaimed metric). A non-zero value there is healthy - it means the pool was busy and a waiting caller pitched in. That's different from the Caller-Run Fallbacks column next to it, which means the pool was full and is the one worth acting on by raising the pool size.

    No configuration change and no API change is needed.


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  7. removed
    in progress
    on Aug 26, 2026
  8. added a commit that references this issue on Aug 26, 2026
  9. added
    concurrency
    engine
    vector
    on Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugconcurrencyenginevector

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions