Every mutating bd command against a remote Dolt backend hung ~10–15s
with `auto-export failed: ... hydrate labels: ... context canceled`.
Root cause: five bulk fetchers in internal/storage/issueops partitioned
IDs into wisp vs permanent buckets by calling IsActiveWispInTx once per
ID, and each call is a round-trip to the SQL server. With ~600 issues
over WAN latency that's ~12s of sequential SELECTs *before* the real
label query runs — blowing past the context deadline.
Fix:
- Add PartitionWispIDsInTx that batches the check into one
`SELECT id FROM wisps WHERE id IN (...)` per queryBatchSize chunk,
reducing cost from O(N) to O(1 + N/200) round-trips. Falls back to
"no wisps" when the wisps table is absent (pre-migration dbs).
- Rewrite GetLabelsForIssuesInTx, GetCommentsForIssuesInTx,
GetDependencyRecordsForIssuesInTx, GetBlockingInfoForIssuesInTx, and
DeleteIssuesInTx to use it.
- Add fast-path helpers GetLabelsForIssuesFromTableInTx and
GetDependencyRecordsForIssuesFromTableInTx for callers (searchTableInTx)
that already know every ID is in a single table, skipping the partition
round-trip entirely on the hot auto-export path.
Tests:
- New wisp_partition_test.go covering the partitioner directly: empty,
all-perm, all-wisp, mixed-with-unknown, input-order preservation, and
a 450-ID large-batch case crossing the queryBatchSize boundary.
- End-to-end mixed-routing regression tests for GetCommentsForIssues,
GetDependencyRecordsForIssues, and a 250-ID GetLabelsForIssues case
that crosses the chunk boundary.
Made-with: Cursor