* perf(issueops): batched is_blocked mark/unmark decide membership through the batch-scoped should-be-blocked union
The four batched templates (issues/wisps x mark/unmark) spelled out five
correlated EXISTS per outer row; the engine re-executed them per candidate
row — ~1.5–4.7 s per 200-id batch on committed data and unbounded over a
large uncommitted working set (>69 min observed on dolt 2.1.8 during a
proxied-server import, gastownhall/beads#6288).
They now decide membership through the same uncorrelated union the full
repair and the doctor count already use (shouldBeBlockedIDsUnionSQL,
bd-t9ypt), scoped to the batch: shouldBeBlockedIDsUnionScopedSQL(depTable,
scope) splices `AND d.issue_id IN (batch)` into every leg, and
expandBatchTemplate repeats the IN-list placeholders and bound ids for every
%s in the template (outer filter + 5 legs).
The waits-for leg wraps its dependency rows in a derived table BEFORE the
gate predicate is applied: flat, the planner pushed the gate's correlated
EXISTS ahead of the type filter and evaluated them against the whole overlay
per candidate row (436 s for zero rows); barriered, 0.01 s.
dolt 2.1.8, real 19k-issue db, one 200-id batch: committed 1.5–4.7 s → 0.04–0.08 s;
uncommitted overlay >24.6 min → 3–8 s (box load dependent).
Statement prefixes, the fixpoint loop, the updated_at self-assignment and
the error strings are unchanged. Proof: sqlmock issueops suite, container-
backed dolt Blocked|IsBlocked suite, golangci-lint clean, 8/8 mutants killed.
* test(issueops): pin expandBatchTemplate's percent budget at the fast tier
Maintainer review fixups for #6291. No production logic changes — one new
fast-tier test plus three comment corrections.
The batched mark/unmark templates reach the engine through
expandBatchTemplate, which decides how many IN-lists to splice by counting
"%s" textually. Nothing pinned that at the fast tier: the sqlmock
expectations in blocked_state_result_test.go match an unanchored statement
prefix and never call WithArgs, so they stay green against a miscounted
template, and a break surfaces only in the container-backed dolt suite.
go vet catches a stray percent only when it sits in the Sprintf format
literal. waitsForGateBlockedSQL is spliced in as an argument, so a future
LIKE 'x%' there is invisible to vet and to sqlmock both — verified by
counterfactual: injecting one leaves %s at 6 while total % goes to 7, vet
stays clean, the sqlmock suite stays green, and only the new
TestBatchedTemplatePercentBudget fires. The stray-percent guard, not the %s
count, is the assertion that bites.
Comment corrections, all pre-existing drift this change is the natural
moment to fix:
- dolt/store.go recomputeAllBlocked justified openLongTimeoutConn with "the
full pass's batched UPDATEs carry five correlated EXISTS subqueries each".
Wrong twice over: the full pass runs unbatched whole-table semi-join
UPDATEs (see recomputeIsBlockedCounting) and has used the decorrelated
union since bd-t9ypt. Load/deadline rationale kept verbatim.
- CountIsBlockedInconsistenciesInTx said detection and repair "share no
SQL"; countStaleIsBlockedSQL has built on shouldBeBlockedIDsUnionSQL
since bd-t9ypt, and this PR's own comment 60 lines above now says all
three consumers share the one definition.
- blocked_full_repair_test.go's header claimed the differential half
cross-checks the write path against the full repair on every leg. Both
sides now render from one builder, so it validates scope-splicing and the
waits-for barrier; per-leg semantics are pinned by the absolute fixture
expectations, now called out so they are not dropped as redundant.
Validation: issueops suite green; go vet clean; the container-backed dolt
blocked family green on the real engine, 27/27 PASS with zero skips,
including TestRecomputeAllIsBlocked_FullRepairAllLegsDifferential.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>