cockroachdb / cockroachdb/cockroach

bulk: audit empty-instance handling for execution locality across bulk jobs

Open
#173,619 1 comment 0 reactions 1 assignee Claimed by @andrew-r-thomas View on GitHub
A-disaster-recovery C-investigation O-agent P-2 T-disaster-recovery
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Summary:**
Bulk jobs that support an execution-locality filter plan their worker set via
`dsp.SetupAllNodesPlanningWithOracle(... SingleLocalityFilter ...)`, which returns
an empty instance slice (nil error) when no live instance matches the filter.
Callers must guard this empty case; not all do.

**Concrete finding:**
`restore_processor_planning.go` computes
`chunkSize := int(math.Sqrt(float64(md.numImportSpans))) / numNodes` with no guard
against `numNodes == 0`. A RESTORE execution-locality filter matching zero live
instances divides by zero (panic). IMPORT guards this explicitly ("no SQL
instances match ..."); other callers should be checked.

**Next steps:**
- [ ] Audit each `SetupAllNodesPlanningWithOracle` caller (backup, restore,
compaction, revlog, merge, fingerprint) for empty-instance handling.
- [ ] Fix the RESTORE divide-by-zero.
- [ ] Consider centralizing the empty guard in the planning helper.

Epic CRDB-65504

Jira issue: CRDB-66930

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.