adapter: validate BILLED AS against the replica size map - #38630
Draft
ggevay wants to merge 1 commit into
Draft
Conversation
CREATE CLUSTER REPLICA ... INTERNAL, BILLED AS '<size>' with a size that is not in the environment's replica size map panicked the coordinator: the credit-consumption check looked the billing size up with an expect that assumed it had been validated like SIZE, but only SIZE was. Validate BILLED AS at both DDL entry points (CREATE CLUSTER REPLICA and CREATE CLUSTER ... REPLICAS), accepting disabled sizes and ignoring the role's allowed sizes, since billing only reads the credit rate. Make the credit lookups tolerant of a billing size that has since left the map: such a replica counts as free with a soft panic, so it can still be dropped. Dropping it used to hit the same expect. Closes: SQL-658 Closes: CPU-236 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ggevay
force-pushed
the
gabor/billed-as-size-validation
branch
from
September 2, 2026 17:52
06a3c2d to
6bf5610
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Creating an internal replica with a
BILLED ASvalue that is not a configured replica size crashed environmentd instead of returning an error (SQL-658). This hit a production environment in #incident-db-1257: three coordinator panics from one statement retried twice, about twelve minutes of environmentd downtime across three restarts.Cause
BILLED ASwas not validated when the replica location is concretized, onlySIZEwas validated.expect, so an unknownBILLED ASpanicked the coordinator thread.Validation,
src/adapter/src/coord/sequencer/inner/cluster.rsCoordinator::ensure_valid_billed_as_sizechecks the value against the size map. In contrast toSIZE, this accepts disabled sizes and ignores the role's allowed sizes, since billing only reads the credit rate.CREATE CLUSTER REPLICAandCREATE CLUSTER ... REPLICAS (...). The statement now fails withunknown cluster replica size <size> in BILLED AS.concretize_replica_location, which catalog open also runs for every durable replica andexpects to succeed. A check there would turn aBILLED ASsize removed from the map after the replica exists into a startup panic, whereas at DDL time the statement can simply fail.Tolerant credit lookups,
src/adapter/src/coord.rsandcoord/ddl.rsCoordinator::replica_credits_per_hour, which counts a replica whose billing size has since left the map as free and raisessoft_panic_or_log!.SIZEis validated at catalog open, so a stale billing size only reaches the drop site. Dropping such a replica used to panic the coordinator.Tests
test/sqllogictest/cluster.slt:CREATE CLUSTER REPLICAandCREATE CLUSTER ... REPLICASwith an unknownBILLED ASnow expect the error. The existingBILLED AS 'free'case, a disabled size in the test map, keeps passing.test/cluster/mzcompose.py, workflowtest-billed-as-size-removed: creates an internalBILLED ASreplica, restarts environmentd with that size removed from the map and soft assertions off, then drops the replica and runs further cluster DDL.How this was verified
Closes: SQL-658
Closes: CPU-236
🤖 Generated with Claude Code