vitessio/vitess · error
Error setting tablet to read-only: %w
Error message
Error setting tablet to read-only: %w
What it means
SetReadOnly calls vtctld SetWritable(writable=false) on the tablet; if that RPC fails, VTAdmin wraps the error with this message. The tablet remains in its prior writability state and the caller receives the wrapped underlying error.
Source
Thrown at go/vt/vtadmin/api.go:2375
}, nil
}
// SetReadOnly is part of the vtadminpb.VTAdminServer interface.
func (api *API) SetReadOnly(ctx context.Context, req *vtadminpb.SetReadOnlyRequest) (*vtadminpb.SetReadOnlyResponse, error) {
span, ctx := trace.NewSpan(ctx, "API.SetReadOnly")
defer span.Finish()
tablet, c, err := api.getTabletForAction(ctx, span, rbac.ManageTabletWritabilityAction, req.Alias, req.ClusterIds)
if err != nil {
return nil, err
}
err = c.SetWritable(ctx, &vtctldatapb.SetWritableRequest{
TabletAlias: tablet.Tablet.Alias,
Writable: false,
})
if err != nil {
return nil, fmt.Errorf("Error setting tablet to read-only: %w", err)
}
return &vtadminpb.SetReadOnlyResponse{}, nil
}
// SetReadWrite is part of the vtadminpb.VTAdminServer interface.
func (api *API) SetReadWrite(ctx context.Context, req *vtadminpb.SetReadWriteRequest) (*vtadminpb.SetReadWriteResponse, error) {
span, ctx := trace.NewSpan(ctx, "API.SetReadWrite")
defer span.Finish()
tablet, c, err := api.getTabletForAction(ctx, span, rbac.ManageTabletWritabilityAction, req.Alias, req.ClusterIds)
if err != nil {
return nil, err
}
err = c.SetWritable(ctx, &vtctldatapb.SetWritableRequest{
TabletAlias: tablet.Tablet.Alias,
Writable: true,View on GitHub (pinned to 01a25a7d17)
Solutions
- Check the wrapped error for the failing tablet and verify the tablet is up (vtctld GetTablet / tablet status page)
- Verify vtadmin can reach the cluster's vtctld and retry SetReadOnly
- If the tablet is gone, correct the alias or remove it from use
Defensive patterns
Strategy: try-catch
Validate before calling
// confirm the tablet is reachable via topo before calling // e.g. tablet, err := client.GetTablet(ctx, alias); require tablet != nil and state healthy
Try / catch
resp, err := client.SetReadOnly(ctx, req)
if err != nil {
if strings.Contains(err.Error(), "Error setting tablet to read-only") {
return fmt.Errorf("tablet %s not set read-only: %w — check vtctld/tablet health", alias, err)
}
return err
} Prevention
- Check tablet health in the topo before issuing SetWritable calls
- Ensure vtadmin has network access to each cluster's vtctld
- Handle already-achieved states gracefully (tablet already read-only) to keep operations idempotent
When it happens
Trigger: Calling API.SetReadOnly when the cluster's SetWritable RPC to vtctld fails — vtctld unreachable, tablet down, or the tablet rejects the command.
Common situations: Tablet already drained/in a transitional state; vtctld service down; network timeout between vtadmin and vtctld; tablet alias belongs to a retired tablet.
Related errors
- Error setting tablet to read-write: %w
- invalid key:value pair
- failed to delete tablet: %w
- ReloadSchemas(cluster = %s) failed: %w
- GetKeyspaces(cluster = %s) failed: %w
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/15bd56acc1d5018e.
Report an issue: GitHub.