Deploy compose: identify the cause of the ~10 s StartDeployment stall seen in the #923 gate #955

Closed
opened 2026-12-01 19:29:52 -05:00 by dohertj2 · 2 comments
Owner

Follow-up to #949 (88c9766ab). #949 fixed the caller-facing symptom (202 OutcomeUnknown + pre-allocated DeploymentId) but the cause of the >10 s ask was not established. CreatedAtUtc is stamped just before SaveChanges, so the time went into the compose phases under the Serializable transaction (scope-state write lock + range-locked snapshot read) — lock contention with a concurrent config writer is the leading hypothesis, unconfirmed. 88c9766ab adds a Warning with per-phase timings (serializable-begin+scope-lock / snapshot-read / validate / compose / save+commit) for any compose > 3 s. Next time it reproduces (e.g. on the gRPC data rig), read that log line and fix the named phase. Evidence: docs/plans/evidence/grpc-data-ext/H4.md.

Follow-up to #949 (88c9766ab). #949 fixed the caller-facing symptom (202 OutcomeUnknown + pre-allocated DeploymentId) but the cause of the >10 s ask was not established. CreatedAtUtc is stamped just before SaveChanges, so the time went into the compose phases under the Serializable transaction (scope-state write lock + range-locked snapshot read) — lock contention with a concurrent config writer is the leading hypothesis, unconfirmed. 88c9766ab adds a Warning with per-phase timings (serializable-begin+scope-lock / snapshot-read / validate / compose / save+commit) for any compose > 3 s. Next time it reproduces (e.g. on the gRPC data rig), read that log line and fix the named phase. Evidence: docs/plans/evidence/grpc-data-ext/H4.md.
dohertj2 added the type:followuppriority:p3 labels 2026-12-01 19:29:52 -05:00
Author
Owner

Findings (branch worktree-agent-ab520ca395f60bbb8, commit 0a9719c86, not merged; evidence docs/plans/evidence/followups/955.md).

Mechanism reproduced and fixed. The compose's SERIALIZABLE transaction (from 47960a6d5) also swallowed DraftSnapshotFactory's read (it reads inside an existing transaction instead of opening its SNAPSHOT one), so ~22 config tables were range-locked through validate + compose + gzip. Against the central SQL Server (throwaway DB, real actor):

  • a cross-table edit (UPDATE Tag then UPDATE ClusterNode, looped) deadlocked the deploy: first deadlock waited one 5 s lock-monitor cycle, and the deploy was the 1205 victim 9 of 10 times ("StartDeployment failed on the server");
  • an edit holding a row lock 2 s held every deploy ~2 s;
  • AdminUI-style saves (Tag + ConfigEdit) and deploy-bookkeeping writes only cost ms.

Fix: the compose runs SNAPSHOT (no shared locks; neither waits on nor blocks edits), with composes serialised by a transaction-owned sp_getapplock taken before any data access (row-lock-first under SNAPSHOT fails a queued compose with 3960). After: cross-table writer max 946 ms / 0 deadlocks; a 2 s lock holder no longer delays the deploy (p50 210 ms). Regression tests DeployComposeIsolationSqlServerTests (3, SQL Server) are red on revert. The #949 timer now starts at the singleton's receipt and adds dispatch (thread-pool hand-off) and in-flight-check.

Not established for the #923 instance. No concurrent config writer was running then: the seeder's docker compose run --rm exits before the deploy is triggered, and CONTROL's in-process writers (coordinator, retention, audit, fused-node ack) touch only the bookkeeping tables in sub-second SaveChanges; system_health showed no deadlock; the run's logs are gone. Untimed then, still candidates: ask delivery through the singleton proxy (CONTROL-1 <-> CONTROL-2), thread-pool queueing (now timed), the in-flight check (now timed), a SQL/container stall. A repeat now names the phase from receipt; a slow ask with a fast breakdown points at delivery.

Leaving open for the coordinator to decide.

Findings (branch `worktree-agent-ab520ca395f60bbb8`, commit `0a9719c86`, not merged; evidence `docs/plans/evidence/followups/955.md`). **Mechanism reproduced and fixed.** The compose's SERIALIZABLE transaction (from `47960a6d5`) also swallowed `DraftSnapshotFactory`'s read (it reads inside an existing transaction instead of opening its SNAPSHOT one), so ~22 config tables were range-locked through validate + compose + gzip. Against the central SQL Server (throwaway DB, real actor): - a cross-table edit (UPDATE Tag then UPDATE ClusterNode, looped) deadlocked the deploy: first deadlock waited one 5 s lock-monitor cycle, and the deploy was the 1205 victim 9 of 10 times ("StartDeployment failed on the server"); - an edit holding a row lock 2 s held every deploy ~2 s; - AdminUI-style saves (Tag + ConfigEdit) and deploy-bookkeeping writes only cost ms. Fix: the compose runs SNAPSHOT (no shared locks; neither waits on nor blocks edits), with composes serialised by a transaction-owned `sp_getapplock` taken before any data access (row-lock-first under SNAPSHOT fails a queued compose with 3960). After: cross-table writer max 946 ms / 0 deadlocks; a 2 s lock holder no longer delays the deploy (p50 210 ms). Regression tests `DeployComposeIsolationSqlServerTests` (3, SQL Server) are red on revert. The #949 timer now starts at the singleton's receipt and adds `dispatch` (thread-pool hand-off) and `in-flight-check`. **Not established for the #923 instance.** No concurrent config writer was running then: the seeder's `docker compose run --rm` exits before the deploy is triggered, and CONTROL's in-process writers (coordinator, retention, audit, fused-node ack) touch only the bookkeeping tables in sub-second SaveChanges; system_health showed no deadlock; the run's logs are gone. Untimed then, still candidates: ask delivery through the singleton proxy (CONTROL-1 <-> CONTROL-2), thread-pool queueing (now timed), the in-flight check (now timed), a SQL/container stall. A repeat now names the phase from receipt; a slow ask with a fast breakdown points at delivery. Leaving open for the coordinator to decide.
Author
Owner

Closing: a real cause of multi-second deploy stalls was found, reproduced and fixed in 0a9719c86 (merged to master, not yet pushed) — the compose's Serializable transaction range-locked the whole config snapshot, so concurrent edits blocked it or deadlocked it (5 s detection each; 9/10 deploys were deadlock victims in the repro). Now Snapshot isolation + sp_getapplock serialisation; evidence docs/plans/evidence/followups/955.md. Caveat: no concurrent writer is known to have run during the #923 gate, so that exact 10.5 s instance is not proven to be this; phase timing now starts at actor receipt (incl. dispatch / in-flight-check), so a recurrence names its phase — reopen with that log line. ControlPlane.Tests 497/497.

Closing: a real cause of multi-second deploy stalls was found, reproduced and fixed in 0a9719c86 (merged to master, not yet pushed) — the compose's Serializable transaction range-locked the whole config snapshot, so concurrent edits blocked it or deadlocked it (5 s detection each; 9/10 deploys were deadlock victims in the repro). Now Snapshot isolation + sp_getapplock serialisation; evidence docs/plans/evidence/followups/955.md. Caveat: no concurrent writer is known to have run during the #923 gate, so that exact 10.5 s instance is not proven to be this; phase timing now starts at actor receipt (incl. dispatch / in-flight-check), so a recurrence names its phase — reopen with that log line. ControlPlane.Tests 497/497.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dohertj2/lmxopcua#955