{"record":{"id":"e82f3fa49863158f","repo":"gastownhall/beads","slug":"partition-wisp-ids-probe-w","errorCode":null,"errorMessage":"partition wisp ids: probe: %w","messagePattern":"partition wisp ids: probe: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/issueops/wisp_routing.go","lineNumber":137,"sourceCode":"\t\t}\n\t}\n\treturn wispIDs, permIDs\n}\n\n// PartitionWispIDsInTx partitions a set of IDs into wisp vs non-wisp buckets\n// using a single batched `SELECT id FROM wisps WHERE id IN (...)` query per\n// queryBatchSize chunk, rather than one round-trip per ID. This is critical\n// for remote backends (Dolt) where per-ID round-trips multiply WAN latency\n// and can push bulk hydration past the context deadline (see GH#3414).\n// IDs not present in the wisps table are treated as permanent issue IDs.\n// Returned slices preserve the input ordering within each bucket.\nfunc PartitionWispIDsInTx(ctx context.Context, tx DBTX, ids []string) (wispIDs, permIDs []string, err error) {\n\tif len(ids) == 0 {\n\t\treturn nil, nil, nil\n\t}\n\n\tif empty, probeErr := wispsTableEmptyOrMissingInTx(ctx, tx); probeErr != nil {\n\t\treturn nil, nil, fmt.Errorf(\"partition wisp ids: probe: %w\", probeErr)\n\t} else if empty {\n\t\treturn nil, append([]string(nil), ids...), nil\n\t}\n\n\twispSet := make(map[string]struct{}, len(ids))\n\tfor start := 0; start < len(ids); start += queryBatchSize {\n\t\tend := start + queryBatchSize\n\t\tif end > len(ids) {\n\t\t\tend = len(ids)\n\t\t}\n\t\tbatch := ids[start:end]\n\t\tplaceholders := make([]string, len(batch))\n\t\targs := make([]any, len(batch))\n\t\tfor i, id := range batch {\n\t\t\tplaceholders[i] = \"?\"\n\t\t\targs[i] = id\n\t\t}\n\t\t//nolint:gosec // G201: only ? placeholders in the IN clause.","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/issueops/wisp_routing.go#L119-L155","documentation":"PartitionWispIDsInTx first probes whether the wisps table is empty or missing (SELECT 1 FROM wisps LIMIT 1). This error wraps a probe failure that is neither sql.ErrNoRows nor a table-not-exist error — i.e. a genuine query failure such as a connection error, permission denial, or corrupt table. The partition cannot proceed because wisp status is unknown.","triggerScenarios":"Calling PartitionWispIDsInTx (directly or via GetCommentsForIssuesInTx, GetCommentCountsInTx, ResolveDeletionSetInTx, GetDependencyRecordsForIssuesInTx, GetBlockingInfoForIssuesInTx, GetLabelsForIssuesInTx) when the probe SELECT against wisps fails with a non-table-not-exist driver error (dead connection, access denied, locked DB).","commonSituations":"Dolt server unreachable at call time; the DB user lacks SELECT permission on the wisps table; database file locked by another process in embedded mode; transient network failure against a remote Dolt backend.","solutions":["Inspect the wrapped driver error — fix the underlying connectivity or permission problem first","Confirm the DB user/role has SELECT on the wisps table","For remote Dolt, verify the server is up and reachable (network, port, TLS) before retrying","If the wisps table is corrupt or the schema is mid-migration, run schema repair/migrations to a consistent version"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure store is healthy before batch operations\nif err := store.Ping(ctx); err != nil { return fmt.Errorf(\"store unavailable: %w\", err) }","typeGuard":null,"tryCatchPattern":"wispIDs, permIDs, err := issueops.PartitionWispIDsInTx(ctx, tx, ids)\nif err != nil {\n\tif strings.Contains(err.Error(), \"partition wisp ids: probe:\") {\n\t\t// fall back: treat all as permanent after verifying connectivity\n\t}\n\treturn err\n}","preventionTips":["Ping/health-check the store before large batch operations","Grant SELECT on wisps to the application DB role","Keep Dolt server reachable; alert on connection failures","Complete schema migrations before running bulk operations"],"tags":["database","wisp-routing","probe-query"],"backgroundTag":"db-probe-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}