Skip to content

skills/analyzing-schema-change-storage-risk: rewrite to match docs and code - #9

Merged
rafiss merged 1 commit into
mainfrom
rafiss/fix-schema-change-storage-skill
Apr 29, 2026
Merged

rafiss merged 1 commit into
mainfrom
rafiss/fix-schema-change-storage-skill

Conversation

@rafiss

@rafiss rafiss commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

The current skill is built around a "3× the largest range size" rule that
doesn't exist in CockroachDB. Engineers from the schema team flagged it as
inaccurate in this Slack thread.

Reviewing the CockroachDB source confirmed the skill's specifics are
fabricated:

  • No "3× largest range" rule exists anywhere in the codebase.
  • The claimed mechanism ("1× existing + 1× backfill + 1× MVCC") has no basis.
  • The cited cluster setting kv.range_split.by_load_enabled controls
    load-based range splitting, not disk-based backfill pausing. The real
    mechanism is kv.bulk_io_write.min_capacity_remaining_fraction (default
    5%), enforced on AddSSTable ingests; on rejection the schema change job
    pauses itself via jobs.MarkPauseRequestError.
  • The recommended SQL queries use span_stats->>'approximate_disk_bytes'
    rather than the range_size_mb column the official docs recommend.

This rewrite:

  • Mirrors the official docs guidance: up to 3× the size of the
    affected table or index as a conservative bound, not "3× the largest
    range".
  • Distinguishes CREATE INDEX (~1× the new index) from ALTER PRIMARY KEY
    (where 3× the table is the right ballpark).
  • Uses the docs-recommended SHOW RANGES ... WITH DETAILS, KEYS, INDEXES
    query and range_size_mb.
  • Documents the real disk-full mechanism.
  • Drops references/storage-calculations.md entirely; its decision trees
    and "common mistakes" all hinge on the removed framing.

…d code

The current skill is built around a "3× the largest range size" rule that
doesn't exist in CockroachDB. Engineers from the schema team flagged it as
inaccurate in [this Slack thread][thread].

Reviewing the CockroachDB source confirmed the skill's specifics are
fabricated:

- No "3× largest range" rule exists anywhere in the codebase.
- The claimed mechanism ("1× existing + 1× backfill + 1× MVCC") has no basis.
- The cited cluster setting `kv.range_split.by_load_enabled` controls
  load-based range splitting, not disk-based backfill pausing. The real
  mechanism is `kv.bulk_io_write.min_capacity_remaining_fraction` (default
  5%), enforced on `AddSSTable` ingests; on rejection the schema change job
  pauses itself via `jobs.MarkPauseRequestError`.
- The recommended SQL queries use `span_stats->>'approximate_disk_bytes'`
  rather than the `range_size_mb` column the official docs recommend.

This rewrite:

- Mirrors the [official docs guidance][docs]: up to 3× the size of the
  affected *table or index* as a conservative bound, not "3× the largest
  range".
- Distinguishes CREATE INDEX (~1× the new index) from ALTER PRIMARY KEY
  (where 3× the table is the right ballpark).
- Uses the docs-recommended `SHOW RANGES ... WITH DETAILS, KEYS, INDEXES`
  query and `range_size_mb`.
- Documents the real disk-full mechanism.
- Drops `references/storage-calculations.md` entirely; its decision trees
  and "common mistakes" all hinge on the removed framing.

[thread]: https://cockroachlabs.slack.com/archives/C04U1BTF8/p1777324688585579?thread_ts=1777323782.834359&cid=C04U1BTF8
[docs]: https://www.cockroachlabs.com/docs/stable/online-schema-changes#estimate-your-storage-capacity-before-performing-online-schema-changes

@kevin-v-ngo kevin-v-ngo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Rafi!

@rafiss
rafiss merged commit 84bc1e4 into main Apr 29, 2026
1 check passed
@rafiss
rafiss deleted the rafiss/fix-schema-change-storage-skill branch April 29, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants