Skip to content

WIP explicitly skip-include_stats in ReloadSchema #17101

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

Closed
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
1,913 changes: 962 additions & 951 deletions go/vt/proto/tabletmanagerdata/tabletmanagerdata.pb.go

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions go/vt/proto/tabletmanagerdata/tabletmanagerdata_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,645 changes: 828 additions & 817 deletions go/vt/proto/vtctldata/vtctldata.pb.go

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions go/vt/proto/vtctldata/vtctldata_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions go/vt/vtcombo/tablet_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -864,12 +864,12 @@ func (itmc *internalTabletManagerClient) RunHealthCheck(ctx context.Context, tab
return nil
}

func (itmc *internalTabletManagerClient) ReloadSchema(ctx context.Context, tablet *topodatapb.Tablet, waitPosition string) error {
func (itmc *internalTabletManagerClient) ReloadSchema(ctx context.Context, tablet *topodatapb.Tablet, req *tabletmanagerdatapb.ReloadSchemaRequest) error {
t, ok := tabletMap[tablet.Alias.Uid]
if !ok {
return fmt.Errorf("tmclient: cannot find tablet %v", tablet.Alias.Uid)
}
return t.tm.ReloadSchema(ctx, waitPosition)
return t.tm.ReloadSchema(ctx, req)
}

func (itmc *internalTabletManagerClient) PreflightSchema(ctx context.Context, tablet *topodatapb.Tablet, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error) {
Expand Down
5 changes: 4 additions & 1 deletion go/vt/vtctl/grpcvtctldserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3290,7 +3290,10 @@ func (s *VtctldServer) ReloadSchema(ctx context.Context, req *vtctldatapb.Reload
return nil, err
}

err = s.tmc.ReloadSchema(ctx, ti.Tablet, "")
tmreq := &tabletmanagerdatapb.ReloadSchemaRequest{
SkipIncludeStats: req.SkipIncludeStats,
}
err = s.tmc.ReloadSchema(ctx, ti.Tablet, tmreq)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtctl/grpcvtctldserver/testutil/test_tmclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -1022,12 +1022,12 @@ func (fake *TabletManagerClient) RefreshState(ctx context.Context, tablet *topod
}

// ReloadSchema is part of the tmclient.TabletManagerClient interface.
func (fake *TabletManagerClient) ReloadSchema(ctx context.Context, tablet *topodatapb.Tablet, waitPosition string) error {
func (fake *TabletManagerClient) ReloadSchema(ctx context.Context, tablet *topodatapb.Tablet, req *tabletmanagerdatapb.ReloadSchemaRequest) error {
if fake.ReloadSchemaResults == nil {
return fmt.Errorf("%w: no ReloadSchema results on fake TabletManagerClient", assert.AnError)
}

key := path.Join(topoproto.TabletAliasString(tablet.Alias), waitPosition)
key := path.Join(topoproto.TabletAliasString(tablet.Alias), req.WaitPosition)

if fake.ReloadSchemaDelays != nil {
if delay, ok := fake.ReloadSchemaDelays[key]; ok {
Expand Down
3 changes: 2 additions & 1 deletion go/vt/vtctl/schematools/reload.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"vitess.io/vitess/go/vt/topo/topoproto"
"vitess.io/vitess/go/vt/vttablet/tmclient"

tabletmanagerdatapb "vitess.io/vitess/go/vt/proto/tabletmanagerdata"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
)

Expand Down Expand Up @@ -85,7 +86,7 @@ func ReloadShard(ctx context.Context, ts *topo.Server, tmc tmclient.TabletManage
pos = ""
}

if err := tmc.ReloadSchema(ctx, tablet, pos); err != nil {
if err := tmc.ReloadSchema(ctx, tablet, &tabletmanagerdatapb.ReloadSchemaRequest{WaitPosition: pos}); err != nil {
logger.Warningf(
"Failed to reload schema on replica tablet %v in %v/%v (use vtctl ReloadSchema to try again): %v",
topoproto.TabletAliasString(tablet.Alias), keyspace, shard, err,
Expand Down
4 changes: 3 additions & 1 deletion go/vt/vtctl/schematools/reload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"vitess.io/vitess/go/vt/vtctl/grpcvtctldserver/testutil"
"vitess.io/vitess/go/vt/vttablet/tmclient"

tabletmanagerdatapb "vitess.io/vitess/go/vt/proto/tabletmanagerdata"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
)

Expand All @@ -50,8 +51,9 @@ type reloadSchemaCall struct {
Position string
}

func (tmc *reloadSchemaTMC) ReloadSchema(ctx context.Context, tablet *topodatapb.Tablet, position string) (err error) {
func (tmc *reloadSchemaTMC) ReloadSchema(ctx context.Context, tablet *topodatapb.Tablet, req *tabletmanagerdatapb.ReloadSchemaRequest) (err error) {
rpcErr := err
position := req.WaitPosition
defer func() {
tmc.m.Lock()
defer tmc.m.Unlock()
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/endtoend/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func TestSchemaReload(t *testing.T) {
}
defer conn.ExecuteFetch("drop table vitess_temp", 10, false)

framework.Server.ReloadSchema(context.Background())
framework.Server.ReloadSchema(context.Background(), true)
client := framework.NewClient()
waitTime := 50 * time.Millisecond
for i := 0; i < 10; i++ {
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/faketmclient/fake_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (client *FakeTabletManagerClient) RunHealthCheck(ctx context.Context, table
}

// ReloadSchema is part of the tmclient.TabletManagerClient interface.
func (client *FakeTabletManagerClient) ReloadSchema(ctx context.Context, tablet *topodatapb.Tablet, waitPosition string) error {
func (client *FakeTabletManagerClient) ReloadSchema(ctx context.Context, tablet *topodatapb.Tablet, req *tabletmanagerdatapb.ReloadSchemaRequest) error {
return nil
}

Expand Down
6 changes: 2 additions & 4 deletions go/vt/vttablet/grpctmclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,13 @@ func (client *Client) RunHealthCheck(ctx context.Context, tablet *topodatapb.Tab
}

// ReloadSchema is part of the tmclient.TabletManagerClient interface.
func (client *Client) ReloadSchema(ctx context.Context, tablet *topodatapb.Tablet, waitPosition string) error {
func (client *Client) ReloadSchema(ctx context.Context, tablet *topodatapb.Tablet, req *tabletmanagerdatapb.ReloadSchemaRequest) error {
c, closer, err := client.dialer.dial(ctx, tablet)
if err != nil {
return err
}
defer closer.Close()
_, err = c.ReloadSchema(ctx, &tabletmanagerdatapb.ReloadSchemaRequest{
WaitPosition: waitPosition,
})
_, err = c.ReloadSchema(ctx, req)
return err
}

Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/grpctmserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (s *server) ReloadSchema(ctx context.Context, request *tabletmanagerdatapb.
defer s.tm.HandleRPCPanic(ctx, "ReloadSchema", request, response, false /*verbose*/, &err)
ctx = callinfo.GRPCCallInfo(ctx)
response = &tabletmanagerdatapb.ReloadSchemaResponse{}
return response, s.tm.ReloadSchema(ctx, request.WaitPosition)
return response, s.tm.ReloadSchema(ctx, request)
}

func (s *server) PreflightSchema(ctx context.Context, request *tabletmanagerdatapb.PreflightSchemaRequest) (response *tabletmanagerdatapb.PreflightSchemaResponse, err error) {
Expand Down
3 changes: 2 additions & 1 deletion go/vt/vttablet/onlineddl/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import (
"vitess.io/vitess/go/vt/log"
binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
querypb "vitess.io/vitess/go/vt/proto/query"
tabletmanagerdatapb "vitess.io/vitess/go/vt/proto/tabletmanagerdata"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc"
"vitess.io/vitess/go/vt/schema"
Expand Down Expand Up @@ -3958,7 +3959,7 @@ func (e *Executor) reloadSchema(ctx context.Context) error {
grpcCtx, cancel := context.WithTimeout(ctx, grpcTimeout)
defer cancel()

return tmClient.ReloadSchema(grpcCtx, tablet.Tablet, "")
return tmClient.ReloadSchema(grpcCtx, tablet.Tablet, &tabletmanagerdatapb.ReloadSchemaRequest{SkipIncludeStats: true})
}

// deleteVReplicationEntry cleans up a _vt.vreplication entry; this function is called as part of
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletmanager/rpc_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type RPCTM interface {

RunHealthCheck(ctx context.Context)

ReloadSchema(ctx context.Context, waitPosition string) error
ReloadSchema(ctx context.Context, request *tabletmanagerdatapb.ReloadSchemaRequest) error

PreflightSchema(ctx context.Context, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error)

Expand Down
4 changes: 2 additions & 2 deletions go/vt/vttablet/tabletmanager/rpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (tm *TabletManager) executeMultiFetchAsDba(
}

if err == nil && reloadSchema {
reloadErr := tm.QueryServiceControl.ReloadSchema(ctx)
reloadErr := tm.QueryServiceControl.ReloadSchema(ctx, true)
if reloadErr != nil {
log.Errorf("failed to reload the schema %v", reloadErr)
}
Expand Down Expand Up @@ -247,7 +247,7 @@ func (tm *TabletManager) ExecuteFetchAsAllPrivs(ctx context.Context, req *tablet
result, err := conn.ExecuteFetch(uq, int(req.MaxRows), true /*wantFields*/)

if err == nil && req.ReloadSchema {
reloadErr := tm.QueryServiceControl.ReloadSchema(ctx)
reloadErr := tm.QueryServiceControl.ReloadSchema(ctx, true)
if reloadErr != nil {
log.Errorf("failed to reload the schema %v", reloadErr)
}
Expand Down
14 changes: 7 additions & 7 deletions go/vt/vttablet/tabletmanager/rpc_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,25 @@ func (tm *TabletManager) GetSchema(ctx context.Context, request *tabletmanagerda
// ReloadSchema will reload the schema
// This doesn't need the action mutex because periodic schema reloads happen
// in the background anyway.
func (tm *TabletManager) ReloadSchema(ctx context.Context, waitPosition string) error {
func (tm *TabletManager) ReloadSchema(ctx context.Context, req *tabletmanagerdatapb.ReloadSchemaRequest) error {
if tm.DBConfigs.IsZero() {
// we skip this for test instances that can't connect to the DB anyway
return nil
}

if waitPosition != "" {
pos, err := replication.DecodePosition(waitPosition)
if req.WaitPosition != "" {
pos, err := replication.DecodePosition(req.WaitPosition)
if err != nil {
return vterrors.Wrapf(err, "ReloadSchema: can't parse wait position (%q)", waitPosition)
return vterrors.Wrapf(err, "ReloadSchema: can't parse wait position (%q)", req.WaitPosition)
}
log.Infof("ReloadSchema: waiting for replication position: %v", waitPosition)
log.Infof("ReloadSchema: waiting for replication position: %v", req.WaitPosition)
if err := tm.MysqlDaemon.WaitSourcePos(ctx, pos); err != nil {
return err
}
}

log.Infof("ReloadSchema requested via RPC")
return tm.QueryServiceControl.ReloadSchema(ctx)
return tm.QueryServiceControl.ReloadSchema(ctx, !req.SkipIncludeStats)
}

// ResetSequences will reset the auto-inc counters on the specified tables.
Expand Down Expand Up @@ -94,6 +94,6 @@ func (tm *TabletManager) ApplySchema(ctx context.Context, change *tmutils.Schema
}

// and if it worked, reload the schema
tm.ReloadSchema(ctx, "") // nolint:errcheck
tm.ReloadSchema(ctx, &tabletmanagerdatapb.ReloadSchemaRequest{}) // nolint:errcheck
return scr, nil
}
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletserver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type Controller interface {
ClearQueryPlanCache()

// ReloadSchema makes the query service reload its schema cache
ReloadSchema(ctx context.Context) error
ReloadSchema(ctx context.Context, includeStats bool) error

// RegisterQueryRuleSource adds a query rule source
RegisterQueryRuleSource(ruleSource string)
Expand Down
5 changes: 3 additions & 2 deletions go/vt/vttablet/tabletserver/tabletserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"time"

"vitess.io/vitess/go/acl"
"vitess.io/vitess/go/mysql/replication"
"vitess.io/vitess/go/mysql/sqlerror"
"vitess.io/vitess/go/pools/smartconnpool"
"vitess.io/vitess/go/sqltypes"
Expand Down Expand Up @@ -447,8 +448,8 @@ func (tsv *TabletServer) IsHealthy() error {
}

// ReloadSchema reloads the schema.
func (tsv *TabletServer) ReloadSchema(ctx context.Context) error {
return tsv.se.Reload(ctx)
func (tsv *TabletServer) ReloadSchema(ctx context.Context, includeStats bool) error {
return tsv.se.ReloadAtEx(ctx, replication.Position{}, includeStats)
}

// WaitForSchemaReset blocks the TabletServer until there's been at least `timeout` duration without
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletservermock/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (tqsc *Controller) IsHealthy() error {
}

// ReloadSchema is part of the tabletserver.Controller interface
func (tqsc *Controller) ReloadSchema(ctx context.Context) error {
func (tqsc *Controller) ReloadSchema(ctx context.Context, includeStats bool) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tmclient/rpc_client_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ type TabletManagerClient interface {
RunHealthCheck(ctx context.Context, tablet *topodatapb.Tablet) error

// ReloadSchema asks the remote tablet to reload its schema
ReloadSchema(ctx context.Context, tablet *topodatapb.Tablet, waitPosition string) error
ReloadSchema(ctx context.Context, tablet *topodatapb.Tablet, req *tabletmanagerdatapb.ReloadSchemaRequest) error

// PreflightSchema will test a list of schema changes.
PreflightSchema(ctx context.Context, tablet *topodatapb.Tablet, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error)
Expand Down
Loading
Loading