Skip to content

Fix CSM planning of invalid vector names, invalid quotas and Dead replica during resharding - #11528

Merged
ffuugoo merged 6 commits into
devfrom
csm-small-fixes
Nov 13, 2026
Merged

ffuugoo merged 6 commits into
devfrom
csm-small-fixes

Conversation

@ffuugoo

@ffuugoo ffuugoo commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Three consensus state machine fixes for committed entries that the planner handled differently
from the retained handlers:

  • Reject invalid vector names (e.g. ..) in CreateCollection and CreateNamedVector
    as BadInput during planning. For CreateCollection, also reject an empty sparse
    vector name and a name used by both a dense and a sparse vector. Before, segment
    creation failed, and consensus retried the entry forever.
  • Reject invalid quota configs (limits outside 1–100, margin above 100) in SetQuotaConfig
    as BadRequest during planning. Before, quota storage failed, and consensus retried
    the entry forever.
  • When setting a replica Dead aborts resharding, skip the related transfers it already
    unregistered, but still abort every other collected transfer (e.g. an ordinary
    replication of the dropped shard). If the shard was dropped, skip the final Dead write.
    Before, planning rejected the operation with BadRequest for a missing transfer.

Commits:

  • [AI] Reject invalid vector names when planning consensus operations
  • [AI] Reject invalid quota configs when planning consensus operations
  • [AI] Skip transfers already aborted when setting a replica Dead
Prompt (first two commits)

CSM Small Fixes: Implementation Prompt

Implement two missing CSM planner validations and submit them with the existing
Dead-replica fix in one PR targeting dev, for the first CSM release.
The compatibility baseline is rolling upgrades from v1.20.0.

Branch and Scope

The local, unpushed branch is csm-small-fixes.
It was already renamed from csm-scale-up-target-dead-corner-case.
At prompt creation it points to 42c78c9520, based on dev at 9f2a173e61.
The main checkout is on dev at ddbe2fb9c3; inspect actual status before switching.
Preserve unrelated changes and untracked files.

The branch already contains finding 6's 19-line fix in plan_set_shard_replica_state:
skip transfers removed by earlier planned aborts, and return accumulated actions
if an abort dropped the target shard. Preserve that fix.
It makes CSM reach v1.20.0's eventual persisted state without its obsolete final Dead write.
The investigation recorded 313 passing storage tests, clean clippy, and formatting;
those results do not validate the new changes you will make.

Add only these two fixes:

  • Finding 1: reject invalid vector names during CSM planning
  • Finding 7: reject invalid quota configurations during CSM planning

Do not implement the deferred peer-removal, collection-update, or duplicate resharding
Start compatibility changes. Do not broaden this into a general validation audit.
No consensus wire-format change or general planner result refactor is needed.

Read applicable repository instructions, including CLAUDE.md,
.github/review-rules.md, and the contribution requirements before editing.
Use the dev, qdrant-dev, and rust skills if available.

Finding 1: Vector Names

This concerns a vector named .. inside a collection, not a collection named ...
v1.20.0 rejects the name before proposal. A committed operation can bypass that API check:
CSM currently accepts it, segment creation rejects it, and the action failure becomes
ServiceError. Consensus then retries the invalid entry indefinitely.
Planning must return a user error before producing actions.

Use the existing common::validation::validate_vector_name rules.
Validate explicitly supplied dense and sparse vector names in plan_create_collection,
and the supplied name in plan_create_named_vector.
Preserve valid unnamed-vector behavior: the existing validator accepts the empty name,
and VectorsConfig::Single has an implicit unnamed vector.
Do not invent stricter name rules or change existing sparse-name/schema constraints.

Inspect these sources:

  • lib/common/common/src/validation.rs: validate_vector_name
  • lib/storage/src/content_manager/collection_meta_ops.rs:
    CreateCollectionOperation::new already validates dense and sparse map keys
  • lib/storage/src/content_manager/consensus_state_machine/state/plan.rs:
    plan_create_collection and plan_create_named_vector
  • src/actix/api/vector_name_api.rs: named-vector request validation
  • lib/collection/src/collection/vector_name_schema.rs: existing schema validation

Reuse the validator and existing user-error conventions.
A small shared helper is acceptable if it avoids duplicating the same name checks.
Do not call the entire operation constructor or add unrelated derived validation
to the planner merely to reuse these checks.
Verify that the chosen rules agree with v1.20.0; do not introduce a version gate
for checks already enforced by that baseline's API and storage paths.

Add focused tests in the existing CSM operation test modules:

  • Collection creation rejects invalid dense and sparse names, including .. and .
  • Named-vector creation rejects an invalid name for both supported vector kinds
  • Rejection is a user error, yields no executable plan, and leaves state unchanged
  • Valid names and the existing unnamed dense-vector behavior remain accepted

Construct or deserialize operations directly in invalid-input tests,
bypassing API and constructor validation. Otherwise the tests do not exercise the gap.
Cover the planner's use of validation; do not duplicate the validator's full test suite.

Finding 7: Quota Configuration

v1.20.0 rejects invalid quotas as user errors.
CSM currently emits SetQuotaConfig without checking validity;
quota storage rejects it and consensus retries the action failure as ServiceError.
The API already rejects these requests, so this is planner hardening for committed entries.

Inspect these sources:

  • lib/shard/src/quota/config.rs: QuotaConfig and its Validate rules
  • lib/shard/src/quota/manager/store.rs: storage validation and error handling
  • lib/storage/src/content_manager/consensus_state_machine/state/plan.rs:
    plan_set_quota_config
  • lib/storage/src/content_manager/consensus_state_machine/mod.rs:
    dispatch of ConsensusOperations::SetQuotaConfig
  • lib/storage/src/content_manager/consensus_state_machine/tests/ops/quota.rs

Validate with the existing QuotaConfig rules before emitting the action.
Change plan_set_quota_config from Actions to StorageResult<Actions>
and propagate the result through its callers. Map invalid input to a user error,
using existing error conventions and identifying the invalid field.
Do not introduce new quota constraints or duplicate the range definitions.

Preserve these semantics:

  • Memory and disk limits accept 1 through 100; 0 and 101 are invalid
  • Release margin accepts 0 through 100; its zero value is valid
  • Unset fields remain valid
  • Invalid supplied fields are rejected even when quotas are disabled,
    as storage validation already does
  • A valid config equal to the current config still emits SetQuotaConfig,
    because applying it also clears recorded exceeded-quota flags

Add focused operation tests for invalid limits/margin, valid boundaries,
and unchanged state on rejection. Preserve the existing repeated-config test.
Ensure invalid operations reach CSM directly, bypassing REST validation.

Validation

Run focused new tests first, then the storage suite and applicable repository checks:

cargo nextest run -p storage
cargo +nightly fmt --all
cargo clippy --workspace --all-targets -- -D warnings
sg scan --config tools/ast-grep/sgconfig.yml

If a shared helper changes another crate, test that crate as well.
Follow repository guidance for affected feature-gated code.
Distinguish environmental failures and unrelated baseline failures from regressions;
record exact commands and results without claiming unrun checks passed.
Keep each new commit focused and independently buildable with its applicable checks.

The existing Dead-replica scenario tests were deliberately removed from its commit.
Do not recreate that investigation as part of this small validation change.
Preserve the fix and run the existing storage coverage on the combined branch.

PR and Release Tracking

Push csm-small-fixes and open one PR against dev containing all three fixes.
Follow the PR template and AI-attribution requirements in docs/CONTRIBUTING.md.
Describe the concrete failure and resulting behavior for each fix,
and report validation results. Keep the description understandable without these
local investigation documents; do not cite inaccessible reports as the explanation.

The user has requested merging these fixes as a single PR.
Merge after required CI and reviews pass, following repository policy.
Do not bypass protections or failing checks; report any pending requirement.

Update the local tracking files consensus/csm-release.md, consensus/plan.md,
and consensus/csm-release-4-dead-replica-decision.md with the actual commits,
PR, validation, and merge status. Mark findings 1 and 7 implemented only after the code
exists, and mark fixes released or merged only when that actually happens.
The consensus/ directory is currently untracked local investigation material;
keep it and unrelated untracked files out of the code PR.

Finish with a concise summary of the changes, tests, PR link, and any remaining release work.

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you formatted your code locally using cargo +nightly fmt --all command prior to submission?
  3. Have you checked your code using cargo clippy --workspace --all-features command? (without --all-features)

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

🤖 Generated with Claude Code

ffuugoo and others added 3 commits November 12, 2026 21:40
`CreateCollectionOperation::new` and the create-vector-name handler
validate vector names before an operation is proposed, but a committed
entry does not have to come through either of them. The state machine
accepted such an entry, segment creation then rejected the name, and
the failed action became a service error, so consensus retried the
entry forever.

Validate explicitly named dense and sparse vectors in
`plan_create_collection` and the vector name in
`plan_create_named_vector`, with the same `validate_vector_name` rules
and `BadInput` errors as the API path. The unnamed vector of a `Single`
config stays valid.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The API validates a quota config before it is proposed, but a committed
`SetQuotaConfig` entry does not have to come through it. The state
machine emitted `SetQuotaConfig` for any config, quota storage then
rejected the invalid one, and the failed action became a service error,
so consensus retried the entry forever.

Move the quota store's validation onto `QuotaConfig::ensure_valid`, and
call it from `plan_set_quota_config`, which now returns a result. An
invalid config is rejected as `BadRequest` naming the invalid fields,
the same error quota storage returns, including while quotas are
disabled. A valid config equal to the current one still emits
`SetQuotaConfig`, because applying it also clears recorded
exceeded-quota flags.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`plan_set_shard_replica_state` collects the transfers related to the
replica, then plans their aborts one by one against the planned state.
Aborting a resharding transfer aborts resharding, which unregisters the
other transfers related to it and, when resharding up, drops the new
shard. Planning a later transfer from the collected list then returned
`BadRequest` for the missing transfer and rejected the whole operation.

The retained handler skips a transfer that is no longer registered.
Skip it in planning too, and return once the shard is gone, as the
resharding branch above already does. Otherwise the final
`SetReplicaState` would target the dropped shard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

This comment was marked as low quality.

coderabbitai[bot]

This comment was marked as resolved.

ffuugoo and others added 3 commits November 12, 2026 21:48
…ning

Move the empty sparse name and dense/sparse name uniqueness checks from
`CreateCollectionOperation::new` into `CreateCollection::validate_vector_names`,
so the consensus planner rejects them as `BadInput` too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Returning as soon as a resharding abort dropped the shard skipped the
remaining collected transfers. An ordinary transfer of the dropped
shard, such as a replication sent by the scale-up target, is not
related to resharding, so it stayed registered. The retained handler
aborts it and only then fails its final write to the dropped shard.

Finish the loop and skip just the final `SetReplicaState`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ffuugoo
ffuugoo merged commit 577693d into dev Nov 13, 2026
32 checks passed
@ffuugoo
ffuugoo deleted the csm-small-fixes branch November 13, 2026 10:05
generall pushed a commit that referenced this pull request Nov 13, 2026
…lica during resharding (#11528)

Co-authored-by: Tim Visee <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants