Show real shard count for custom sharding in collections list - #440
Merged
Conversation
The Shards column rendered `config.params.shard_number`, which for `sharding_method: custom` is only the *default* number of shards per shard key, not the total: each shard key can be created with its own `shards_number`, and a collection with no shard keys yet has no shards at all. A custom-sharded collection therefore showed "1" regardless of how many shards it actually had. Read the total from the collection cluster info (`shard_count`) for custom-sharded collections instead, and show the number of shard keys alongside it. Cluster info is only requested for custom sharding, and falls back to the `shard_number` default (marked as such) when it is unavailable, e.g. for restricted API keys. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
KShivendu
force-pushed
the
fix/custom-sharding-shard-count
branch
from
September 2, 2026 10:56
573ea6d to
74f77a0
Compare
Replace the nested ternaries with early returns per case, drop the redundant "default" caption (the `N / key` value and the tooltip already say it), and only attach `shard_count` when it parses as a finite number, so the cell needs a single null check. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
Author
|
CI is failing due to unrelated stuff (dependency audit) |
5 tasks
Contributor
|
CI failure here is unrelated to the shard-count changes — the ESLint workflow's Audit step fails on a newly disclosed high-severity Fix PR: #441 ( |
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.
Why
The Shards column showed
config.params.shard_number, which forsharding_method: "custom"is not the total shard count — it is only the default number of shards given to each new shard key. So every custom-sharded collection reported the default (usually1) no matter how many shards it really had.Demo collections on a distributed v1.16.3 cluster:
b_tenants_defaulthas 3 shard keys × 1 shard,c_tenants_unevenhas 3 shard keys created withshards_number2 / 3 / 1.Before — 3 shard keys read as
1, and 2 / 3 / 1 shards read as2:After — the real totals, with the shard key count as context:
Tooltip on a custom-sharded row:
Thanks to @nleroy917 for discovering this
Key decisions
GET /collections/{name}/cluster→shard_count, never computed asshard_keys × shard_number.PUT /collections/{name}/shardstakes a per-keyshards_number, so keys of 2 / 3 / 1 shards total 6 while a 2 / 2 / 1 split totals 5 — both withshard_number: 2and 3 keys.sharding_method: "custom". Auto-sharded collections keep the existing single request per row and render unchanged.Worth knowing
getCollection). It has to followgetCollectionbecausesharding_methodis only known from its response, so such a row costs 2 sequential round trips instead of 1; rows are still fetched in parallel, so a page adds ~1 round trip, not one per row. Auto-sharded collections are untouched.isRestricted, and any failure falls back toshard_numberrendered asN / key, so a per-key default is never mistaken for a total.0(it really has no shards) instead of1.getCollectionper match.🤖 Generated with Claude Code