Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reorder tablet checks in vtgate tablet gateway #14291

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/vt/vtgate/buffer/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const (
type RetryDoneFunc context.CancelFunc

const (
ClusterEventReshardingInProgress = "current keyspace is being resharded"
ClusterEventReshardingInProgress = "current keyspace is potentially being resharded"
ClusterEventReparentInProgress = "primary is not serving, there may be a reparent operation in progress"
ClusterEventMoveTables = "disallowed due to rule"
)
Expand Down
12 changes: 7 additions & 5 deletions go/vt/vtgate/tabletgateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,22 +283,24 @@ func (gw *TabletGateway) withRetry(ctx context.Context, target *querypb.Target,
// if we have a keyspace event watcher, check if the reason why our primary is not available is that it's currently being resharded
// or if a reparent operation is in progress.
if kev := gw.kev; kev != nil {
if kev.TargetIsBeingResharded(ctx, target) {
log.V(2).Infof("current keyspace is being resharded, retrying: %s: %s", target.Keyspace, debug.Stack())
err = vterrors.Errorf(vtrpcpb.Code_CLUSTER_EVENT, buffer.ClusterEventReshardingInProgress)
continue
}
primary, notServing := kev.PrimaryIsNotServing(ctx, target)
if notServing {
err = vterrors.Errorf(vtrpcpb.Code_CLUSTER_EVENT, buffer.ClusterEventReparentInProgress)
continue
}

// if primary is serving, but we initially found no tablet, we're in an inconsistent state
// we then retry the entire loop
if primary != nil {
err = vterrors.Errorf(vtrpcpb.Code_UNAVAILABLE, "inconsistent state detected, primary is serving but initially found no available tablet")
continue
}

if kev.TargetIsBeingResharded(ctx, target) {
log.V(2).Infof("current keyspace is potentally being resharded, retrying: %s: %s", target.Keyspace, debug.Stack())
err = vterrors.Errorf(vtrpcpb.Code_CLUSTER_EVENT, buffer.ClusterEventReshardingInProgress)
continue
}
}

// fail fast if there is no tablet
Expand Down
Loading