-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql/catalog: support batched descriptor writes with deferred validation #171400
Copy link
Copy link
Open
Labels
A-schema-catalogRelated to the schema descriptors collection and the catalog API in general.Related to the schema descriptors collection and the catalog API in general.C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)P-1Issues/test failures with a fix SLA of 1 monthIssues/test failures with a fix SLA of 1 monthT-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Metadata
Metadata
Assignees
Labels
A-schema-catalogRelated to the schema descriptors collection and the catalog API in general.Related to the schema descriptors collection and the catalog API in general.C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)P-1Issues/test failures with a fix SLA of 1 monthIssues/test failures with a fix SLA of 1 monthT-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary
The catalog's
WriteDescriptorsAPI writes all descriptors in a singlekv.Batch, which exceeds the Raft command size limit (kv.raft.command.max_size, default 64 MiB) when the descriptor count is large. At ~1.3 KiB per descriptor proto, 100k descriptors produce a ~130 MB batch. This blocks the Disaster Recovery team's 100k/1M descriptor restore work.See #171338 for the full problem description.
Background
WriteDescriptors(write_descs.go:63) builds a singlekv.Batchfor every database, schema, table, type, and function descriptor plus theirsystem.namespaceentries, then commits viatxn.Run(ctx, b). Naive chunking into separate transactions is unsafe because:checkForCrossDatabaseReferences) runs across the entire written set before commit.publishDescriptorshas the same shape — it writes the full descriptor set (OFFLINE → PUBLIC transition) in a single batch and will hit the same limit.Proposed Approach
As discussed in #171338, the catalog should expose an API that:
publishDescriptorspath as well.This keeps single-transaction atomicity (safe rollback on failure) while staying under the Raft command size ceiling.
Code References
WriteDescriptorspublishDescriptorsWriteDescToBatch(CPut per descriptor)Related Issues
WriteDescriptorsbatch exceeds Raft command size limit at 100k descriptors (upstream tracking issue)system.job_infopayload size fix (separate problem, already addressed)Jira issue: CRDB-64506
Epic CRDB-62269