Feature Request: let BackupShard choose the tablet type to back up from
Feature Description
BackupShard picks whichever of the shard's REPLICA, RDONLY and SPARE tablets has the lowest replication lag. It never looks at the tablet type, and there is no way to ask it to back up from a particular one. The selection loop is here.
Proposal
Add a tablet_types field to BackupShardRequest, and a matching --tablet-types flag on vtctldclient BackupShard.
The list is a preference order, not a filter:
--tablet-types=rdonly,replica— back up from anRDONLYtablet, and use aREPLICAonly when noRDONLYtablet can serve the backup.--tablet-types=rdonly— onlyRDONLY, with no fallback.- Not set — exactly today's behaviour.
Within a single type, the lowest-lag tablet still wins.
A type that cannot serve a backup never matches, so --tablet-types=primary selects nothing and --allow-primary remains the only way to back up a primary.
Backward compatible: the field is empty by default and the selection is unchanged.
Happy to open the PR if this direction looks right.
Use Case(s)
Most of our shards keep an RDONLY tablet. Backups are heavy, so where one exists we want them to run there and stay off the tablets serving replica reads. Our bare-metal automation already works that way: where a shard has an RDONLY tablet it backs up only from that, and shards without one fall back to a REPLICA.
BackupShard cannot express that. Whichever tablet happens to have the lowest lag is used, so a nightly backup can land on a tablet that is serving reads.
On Kubernetes we can't do this at all: the vitess-operator's scheduled backups call shard-wide BackupShard and offer no per-tablet option, so every operator user gets the type-blind choice. No operator-side change would be needed for this, since it already passes arbitrary flags through to BackupShard
Source: vitessio/vitess