Skip to content

Add vtctld get-shard command#1267

Open
maxenglander wants to merge 2 commits into
maxeng/issues-gh-1753/get-routing-rulesfrom
maxeng/issues-gh-1753/get-shard
Open

Add vtctld get-shard command#1267
maxenglander wants to merge 2 commits into
maxeng/issues-gh-1753/get-routing-rulesfrom
maxeng/issues-gh-1753/get-shard

Conversation

@maxenglander

@maxenglander maxenglander commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Adds a hidden vtctld command to read live shard records from the cluster:

pscale branch vtctld get-shard <database> <branch> --keyspace <keyspace> --shard <shard>

Depends on planetscale/planetscale-go#314.

Manual testing

Tested end-to-end against a dev Vitess branch (org with direct_vtctld_access enabled) with the full stack deployed.

  1. Unsharded keyspace:

    pscale branch vtctld get-shard <database> <branch> --keyspace <keyspace> --shard -
    

    returned:

    {
      "keyspace": "<keyspace>",
      "name": "-",
      "key_range": {
        "start": "",
        "end": ""
      },
      "tablet_controls": [],
      "is_primary_serving": true
    }
  2. Created a sharded keyspace with --shards 2:

    pscale keyspace create <database> <branch> sharded-ks --cluster-size PS-10 --shards 2 --wait
    
  3. pscale branch vtctld get-shard <database> <branch> --keyspace sharded-ks --shard -80 returned:

    {
      "keyspace": "sharded-ks",
      "name": "-80",
      "key_range": {
        "start": "",
        "end": "gA=="
      },
      "tablet_controls": [],
      "is_primary_serving": true
    }
  4. pscale branch vtctld get-shard <database> <branch> --keyspace sharded-ks --shard 80- returned:

    {
      "keyspace": "sharded-ks",
      "name": "80-",
      "key_range": {
        "start": "gA==",
        "end": ""
      },
      "tablet_controls": [],
      "is_primary_serving": true
    }

key_range.start/end are base64-encoded bytes (Vitess protojson encoding); "gA==" is byte 0x80, the split point between the two shards.

@maxenglander maxenglander force-pushed the maxeng/issues-gh-1753/get-routing-rules branch from 0fd6c2a to 2a8f6ee Compare June 7, 2026 04:23
@maxenglander maxenglander force-pushed the maxeng/issues-gh-1753/get-shard branch from c523aef to baa7d16 Compare June 7, 2026 04:23
@maxenglander maxenglander force-pushed the maxeng/issues-gh-1753/get-routing-rules branch from 2a8f6ee to a49d8f2 Compare June 7, 2026 04:26
@maxenglander maxenglander force-pushed the maxeng/issues-gh-1753/get-shard branch from baa7d16 to 35ab8e7 Compare June 7, 2026 04:26
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Max Englander <max@planetscale.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@maxenglander maxenglander force-pushed the maxeng/issues-gh-1753/get-shard branch from 35ab8e7 to d76a790 Compare June 10, 2026 02:13
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Max Englander <max@planetscale.com>
@maxenglander maxenglander marked this pull request as ready for review June 11, 2026 03:24
@maxenglander maxenglander requested a review from a team as a code owner June 11, 2026 03:24
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