fix(server): align worker_concurrency fallbacks with migration 0011 default of 64 by rollroyces · Pull Request #871 · deeplethe/utopia · GitHub
Skip to content

fix(server): align worker_concurrency fallbacks with migration 0011 default of 64 - #871

Merged
WaylandYang merged 2 commits into
deeplethe:devfrom
rollroyces:fix/worker-concurrency-defaults-64
Sep 23, 2026
Merged

WaylandYang merged 2 commits into
deeplethe:devfrom
rollroyces:fix/worker-concurrency-defaults-64

Conversation

@rollroyces

Copy link
Copy Markdown
Contributor

Align server-side worker_concurrency fallbacks with migration 0011's default (64)

Migration 0011 raised deployment_settings.worker_concurrency's default from 32 to 64 (and the CHECK from BETWEEN 1 AND 32 to BETWEEN 1 AND 256) because the previous default was lower than the per-model limits summed, so a 219-document extraction batch starved the queue. The SQL side was fixed; two Rust fallbacks were left at 32.

access::worker_concurrency already returns 64 on missing row, and the_backstop_can_be_raised (crates/utopia-store/tests/the_backstop_can_be_raised.rs) guards against drift there. Two server-side fallbacks bypassed that test:

  • crates/utopia-server/src/main.rs:173 — .unwrap_or(32) on the Result from access::worker_concurrency. Hit when the SQL function itself errors (DB unreachable, query timeout) — exactly the scenario where the system is already degraded. Running with 32 in that window is the same starvation 0011 was designed to prevent.
  • crates/utopia-server/src/state.rs:64 — the initial AtomicUsize value before main.rs's .store(...) runs. Mostly benign (no request can land in the gap) but wrong as written and silently regressed by the same migration.

Both bumped to 64 with a comment pointing at the column default and the access::worker_concurrency fallback, so the next person who changes one side sees the other two.

Not touching set_worker_concurrency's validator (1..=256) — that one was already correct.

The drift shape is the same as the bug the_backstop_can_be_raised was written to catch: a number defined in two places (one SQL, one Rust) that drifted out of sync. Adding a server-side drift test would require the utopia-store test crate to depend on utopia-server, which violates layering — so the guard for now is the comment pointing at the column default, and the existing test continues to guard the access::worker_concurrency fallback.

If we ever see this drift happen again, the right fix is to hoist 64 into a single pub const WORKER_CONCURRENCY_DEFAULT in utopia-store/src/access.rs and have the server side reference it. Worth doing if a third place grows the constant.

Signed-off-by: rollroyces royce@rollroyces.com

… default of 64

Migration 0011 raised `deployment_settings.worker_concurrency`'s default
from 32 to 64 (and the CHECK from BETWEEN 1 AND 32 to BETWEEN 1 AND 256)
because the previous default was lower than the per-model limits summed,
so a 219-document extraction batch starved the queue. The SQL side was
fixed; two Rust fallbacks were left at 32.

`access::worker_concurrency` already returns 64 on missing row, and
`the_backstop_can_be_raised` guards against that drift. Two server-side
fallbacks bypassed that test:

- `crates/utopia-server/src/main.rs:173` — `.unwrap_or(32)` on the
  Result from access::worker_concurrency. This is hit when the SQL
  function itself errors (DB unreachable, query timeout) — exactly the
  scenario where the system is already degraded. Running with 32 in that
  window is the same starvation 0011 was designed to prevent.
- `crates/utopia-server/src/state.rs:64` — the initial AtomicUsize
  value before main.rs's `.store(...)` runs. Mostly benign (no request
  can land in the gap) but wrong as written, and silently regressed by
  the same migration.

Both bumped to 64 with a comment pointing at the column default and the
access::worker_concurrency fallback, so the next person who changes one
side sees the other two.

Not touching set_worker_concurrency (1..=256 validator) — that one was
already correct.

Signed-off-by: rollroyces <royce@rollroyces.com>

@WaylandYang WaylandYang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against dev: migration 0011 sets the column default to 64
(ALTER COLUMN worker_concurrency SET DEFAULT 64), access::worker_concurrency
falls back to 64 on a missing row, and the two server-side sites were still 32
(main.rs:175 on the Result, state.rs:64 for the pre-load value).
the_backstop_can_be_raised still exists under tests/store/ after the test
consolidation and covers the store side only, so these two really were outside it.

The comments say why each site is what it is and point at the other two, which is
the thing that stops the next drift. LGTM.

@WaylandYang
WaylandYang merged commit 5ccb756 into deeplethe:dev Sep 23, 2026
@WaylandYang WaylandYang mentioned this pull request Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants