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

slack-vitess-r14.0.5: Revert "delete RPCs that were deprecated in 13.0 (#10099)" #61

Merged
merged 7 commits into from
Mar 31, 2023
5 changes: 4 additions & 1 deletion go/test/endtoend/reparent/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,10 @@ func CheckDBstatus(ctx context.Context, t *testing.T, tablet *cluster.Vttablet,
// unable to setReplicationSource. Since some tests are used in upgrade-downgrade testing, we need this function to
// work with different versions of vtctl.
func SetReplicationSourceFailed(tablet *cluster.Vttablet, prsOut string) bool {
return strings.Contains(prsOut, fmt.Sprintf("tablet %s failed to SetReplicationSource", tablet.Alias))
if strings.Contains(prsOut, fmt.Sprintf("tablet %s failed to SetReplicationSource", tablet.Alias)) {
return true
}
return strings.Contains(prsOut, fmt.Sprintf("tablet %s failed to SetMaster", tablet.Alias))
}

// CheckReplicationStatus checks that the replication for sql and io threads is setup as expected
Expand Down
26 changes: 26 additions & 0 deletions go/test/fuzzing/vttablet_fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,17 @@ func (fs *fuzzStore) callPrimaryPosition() error {
return nil
}

// callDemoteMaster implements a wrapper
// for fuzzing DemoteMaster
func (fs *fuzzStore) callDemoteMaster() error {
tablet, err := fs.getTablet()
if err != nil {
return err
}
_, _ = fs.client.DemoteMaster(context.Background(), tablet)
return nil
}

// callReplicationStatus implements a wrapper
// for fuzzing ReplicationStatus
func (fs *fuzzStore) callReplicationStatus() error {
Expand Down Expand Up @@ -401,6 +412,17 @@ func (fs *fuzzStore) callDemotePrimary() error {
return nil
}

// callUndoDemoteMaster implements a wrapper
// for fuzzing UndoDemoteMaster
func (fs *fuzzStore) callUndoDemoteMaster() error {
tablet, err := fs.getTablet()
if err != nil {
return err
}
_ = fs.client.UndoDemoteMaster(context.Background(), tablet)
return nil
}

// callUndoDemotePrimary implements a wrapper
// for fuzzing UndoDemotePrimary
func (fs *fuzzStore) callUndoDemotePrimary() error {
Expand Down Expand Up @@ -635,12 +657,16 @@ func (fs *fuzzStore) executeInRandomOrder() {
err = fs.callStopReplication()
case 5:
err = fs.callPrimaryPosition()
case 6:
err = fs.callDemoteMaster()
case 7:
err = fs.callReplicationStatus()
case 8:
err = fs.callPrimaryStatus()
case 9:
err = fs.callDemotePrimary()
case 10:
err = fs.callUndoDemoteMaster()
case 11:
err = fs.callUndoDemotePrimary()
case 12:
Expand Down
5 changes: 5 additions & 0 deletions go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ func (fmd *FakeMysqlDaemon) WaitForReparentJournal(ctx context.Context, timeCrea
return nil
}

// DemoteMaster is deprecated: use mysqld.DemotePrimary() instead
func (fmd *FakeMysqlDaemon) DemoteMaster() (mysql.Position, error) {
return fmd.CurrentPrimaryPosition, nil
}

// WaitSourcePos is part of the MysqlDaemon interface
func (fmd *FakeMysqlDaemon) WaitSourcePos(_ context.Context, pos mysql.Position) error {
if fmd.TimeoutHook != nil {
Expand Down
426 changes: 239 additions & 187 deletions go/vt/proto/tabletmanagerservice/tabletmanagerservice.pb.go

Large diffs are not rendered by default.

228 changes: 228 additions & 0 deletions go/vt/proto/tabletmanagerservice/tabletmanagerservice_grpc.pb.go

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions go/vt/vtcombo/tablet_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -868,10 +868,18 @@ func (itmc *internalTabletManagerClient) ExecuteFetchAsApp(context.Context, *top
return nil, fmt.Errorf("not implemented in vtcombo")
}

func (itmc *internalTabletManagerClient) MasterStatus(context.Context, *topodatapb.Tablet) (*replicationdatapb.PrimaryStatus, error) {
return nil, fmt.Errorf("not implemented in vtcombo")
}

func (itmc *internalTabletManagerClient) PrimaryStatus(context.Context, *topodatapb.Tablet) (*replicationdatapb.PrimaryStatus, error) {
return nil, fmt.Errorf("not implemented in vtcombo")
}

func (itmc *internalTabletManagerClient) MasterPosition(context.Context, *topodatapb.Tablet) (string, error) {
return "", fmt.Errorf("not implemented in vtcombo")
}

func (itmc *internalTabletManagerClient) PrimaryPosition(context.Context, *topodatapb.Tablet) (string, error) {
return "", fmt.Errorf("not implemented in vtcombo")
}
Expand All @@ -896,6 +904,10 @@ func (itmc *internalTabletManagerClient) ResetReplication(context.Context, *topo
return fmt.Errorf("not implemented in vtcombo")
}

func (itmc *internalTabletManagerClient) InitMaster(context.Context, *topodatapb.Tablet, bool) (string, error) {
return "", fmt.Errorf("not implemented in vtcombo")
}

func (itmc *internalTabletManagerClient) InitPrimary(context.Context, *topodatapb.Tablet, bool) (string, error) {
return "", fmt.Errorf("not implemented in vtcombo")
}
Expand All @@ -904,6 +916,14 @@ func (itmc *internalTabletManagerClient) PopulateReparentJournal(context.Context
return fmt.Errorf("not implemented in vtcombo")
}

func (itmc *internalTabletManagerClient) DemoteMaster(context.Context, *topodatapb.Tablet) (*replicationdatapb.PrimaryStatus, error) {
return nil, fmt.Errorf("not implemented in vtcombo")
}

func (itmc *internalTabletManagerClient) UndoDemoteMaster(context.Context, *topodatapb.Tablet, bool) error {
return fmt.Errorf("not implemented in vtcombo")
}

func (itmc *internalTabletManagerClient) DemotePrimary(context.Context, *topodatapb.Tablet) (*replicationdatapb.PrimaryStatus, error) {
return nil, fmt.Errorf("not implemented in vtcombo")
}
Expand All @@ -912,6 +932,10 @@ func (itmc *internalTabletManagerClient) UndoDemotePrimary(context.Context, *top
return fmt.Errorf("not implemented in vtcombo")
}

func (itmc *internalTabletManagerClient) SetMaster(context.Context, *topodatapb.Tablet, *topodatapb.TabletAlias, int64, string, bool, bool) error {
return fmt.Errorf("not implemented in vtcombo")
}

func (itmc *internalTabletManagerClient) SetReplicationSource(context.Context, *topodatapb.Tablet, *topodatapb.TabletAlias, int64, string, bool, bool) error {
return fmt.Errorf("not implemented in vtcombo")
}
Expand Down
32 changes: 31 additions & 1 deletion go/vt/vttablet/faketmclient/fake_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ func (client *FakeTabletManagerClient) StopReplicationMinimum(ctx context.Contex
return "", nil
}

// MasterStatus is part of the tmclient.TabletManagerClient interface.
func (client *FakeTabletManagerClient) MasterStatus(ctx context.Context, tablet *topodatapb.Tablet) (*replicationdatapb.PrimaryStatus, error) {
return &replicationdatapb.PrimaryStatus{}, nil
}

// PrimaryStatus is part of the tmclient.TabletManagerClient interface.
func (client *FakeTabletManagerClient) PrimaryStatus(ctx context.Context, tablet *topodatapb.Tablet) (*replicationdatapb.PrimaryStatus, error) {
return &replicationdatapb.PrimaryStatus{}, nil
Expand Down Expand Up @@ -235,6 +240,11 @@ func (client *FakeTabletManagerClient) ReplicaWasRestarted(ctx context.Context,
return nil
}

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

// PrimaryPosition is part of the tmclient.TabletManagerClient interface.
func (client *FakeTabletManagerClient) PrimaryPosition(ctx context.Context, tablet *topodatapb.Tablet) (string, error) {
return "", nil
Expand Down Expand Up @@ -279,6 +289,11 @@ func (client *FakeTabletManagerClient) ResetReplication(ctx context.Context, tab
return nil
}

// InitMaster is part of the tmclient.TabletManagerClient interface.
func (client *FakeTabletManagerClient) InitMaster(ctx context.Context, tablet *topodatapb.Tablet, semiSync bool) (string, error) {
return "", nil
}

// InitPrimary is part of the tmclient.TabletManagerClient interface.
func (client *FakeTabletManagerClient) InitPrimary(ctx context.Context, tablet *topodatapb.Tablet, semiSync bool) (string, error) {
return "", nil
Expand All @@ -289,6 +304,16 @@ func (client *FakeTabletManagerClient) PopulateReparentJournal(ctx context.Conte
return nil
}

// DemoteMaster is part of the tmclient.TabletManagerClient interface.
func (client *FakeTabletManagerClient) DemoteMaster(ctx context.Context, tablet *topodatapb.Tablet) (*replicationdatapb.PrimaryStatus, error) {
return nil, nil
}

// UndoDemoteMaster is part of the tmclient.TabletManagerClient interface.
func (client *FakeTabletManagerClient) UndoDemoteMaster(ctx context.Context, tablet *topodatapb.Tablet, semiSync bool) error {
return nil
}

// DemotePrimary is part of the tmclient.TabletManagerClient interface.
func (client *FakeTabletManagerClient) DemotePrimary(ctx context.Context, tablet *topodatapb.Tablet) (*replicationdatapb.PrimaryStatus, error) {
return nil, nil
Expand All @@ -299,6 +324,11 @@ func (client *FakeTabletManagerClient) UndoDemotePrimary(ctx context.Context, ta
return nil
}

// SetMaster is part of the tmclient.TabletManagerClient interface.
func (client *FakeTabletManagerClient) SetMaster(ctx context.Context, tablet *topodatapb.Tablet, parent *topodatapb.TabletAlias, timeCreatedNS int64, waitPosition string, forceStartReplication bool, semiSync bool) error {
return nil
}

// SetReplicationSource is part of the tmclient.TabletManagerClient interface.
func (client *FakeTabletManagerClient) SetReplicationSource(ctx context.Context, tablet *topodatapb.Tablet, parent *topodatapb.TabletAlias, timeCreatedNS int64, waitPosition string, forceStartReplication bool, semiSync bool) error {
return nil
Expand All @@ -325,7 +355,7 @@ func (e *eofEventStream) Recv() (*logutilpb.Event, error) {
}

// Backup is part of the tmclient.TabletManagerClient interface.
func (client *FakeTabletManagerClient) Backup(ctx context.Context, tablet *topodatapb.Tablet, concurrency int, allowPrimary bool) (logutil.EventStream, error) {
func (client *FakeTabletManagerClient) Backup(ctx context.Context, tablet *topodatapb.Tablet, concurrency int, allowMaster bool) (logutil.EventStream, error) {
return &eofEventStream{}, nil
}

Expand Down
97 changes: 97 additions & 0 deletions go/vt/vttablet/grpctmclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,19 @@ func (client *Client) FullStatus(ctx context.Context, tablet *topodatapb.Tablet)
return response.Status, nil
}

func (client *Client) MasterStatus(ctx context.Context, tablet *topodatapb.Tablet) (*replicationdatapb.PrimaryStatus, error) {
c, closer, err := client.dialer.dial(ctx, tablet)
if err != nil {
return nil, err
}
defer closer.Close()
response, err := c.MasterStatus(ctx, &tabletmanagerdatapb.PrimaryStatusRequest{})
if err != nil {
return nil, err
}
return response.Status, nil
}

// PrimaryStatus is part of the tmclient.TabletManagerClient interface.
func (client *Client) PrimaryStatus(ctx context.Context, tablet *topodatapb.Tablet) (*replicationdatapb.PrimaryStatus, error) {
c, closer, err := client.dialer.dial(ctx, tablet)
Expand All @@ -560,6 +573,20 @@ func (client *Client) PrimaryStatus(ctx context.Context, tablet *topodatapb.Tabl
return response.Status, nil
}

// MasterPosition is part of the tmclient.TabletManagerClient interface.
func (client *Client) MasterPosition(ctx context.Context, tablet *topodatapb.Tablet) (string, error) {
c, closer, err := client.dialer.dial(ctx, tablet)
if err != nil {
return "", err
}
defer closer.Close()
response, err := c.MasterPosition(ctx, &tabletmanagerdatapb.PrimaryPositionRequest{})
if err != nil {
return "", err
}
return response.Position, nil
}

// PrimaryPosition is part of the tmclient.TabletManagerClient interface.
func (client *Client) PrimaryPosition(ctx context.Context, tablet *topodatapb.Tablet) (string, error) {
c, closer, err := client.dialer.dial(ctx, tablet)
Expand Down Expand Up @@ -726,6 +753,23 @@ func (client *Client) ResetReplication(ctx context.Context, tablet *topodatapb.T
return err
}

// InitMaster is part of the tmclient.TabletManagerClient interface.
func (client *Client) InitMaster(ctx context.Context, tablet *topodatapb.Tablet, semiSync bool) (string, error) {
c, closer, err := client.dialer.dial(ctx, tablet)
if err != nil {
return "", err
}
defer closer.Close()

response, err := c.InitMaster(ctx, &tabletmanagerdatapb.InitPrimaryRequest{
SemiSync: semiSync,
})
if err != nil {
return "", err
}
return response.Position, nil
}

// InitPrimary is part of the tmclient.TabletManagerClient interface.
func (client *Client) InitPrimary(ctx context.Context, tablet *topodatapb.Tablet, semiSync bool) (string, error) {
c, closer, err := client.dialer.dial(ctx, tablet)
Expand Down Expand Up @@ -775,6 +819,29 @@ func (client *Client) InitReplica(ctx context.Context, tablet *topodatapb.Tablet
return err
}

// DemoteMaster is part of the tmclient.TabletManagerClient interface.
func (client *Client) DemoteMaster(ctx context.Context, tablet *topodatapb.Tablet) (*replicationdatapb.PrimaryStatus, error) {
c, closer, err := client.dialer.dial(ctx, tablet)
if err != nil {
return nil, err
}
defer closer.Close()
response, err := c.DemoteMaster(ctx, &tabletmanagerdatapb.DemotePrimaryRequest{})
if err != nil {
return nil, err
}
status := response.PrimaryStatus
if status == nil {
// We are assuming this means a response came from an older server.
status = &replicationdatapb.PrimaryStatus{
Position: response.DeprecatedPosition, //nolint
FilePosition: "",
}
}
return status, nil

}

// DemotePrimary is part of the tmclient.TabletManagerClient interface.
func (client *Client) DemotePrimary(ctx context.Context, tablet *topodatapb.Tablet) (*replicationdatapb.PrimaryStatus, error) {
c, closer, err := client.dialer.dial(ctx, tablet)
Expand All @@ -797,6 +864,19 @@ func (client *Client) DemotePrimary(ctx context.Context, tablet *topodatapb.Tabl
return status, nil
}

// UndoDemoteMaster is part of the tmclient.TabletManagerClient interface.
func (client *Client) UndoDemoteMaster(ctx context.Context, tablet *topodatapb.Tablet, semiSync bool) error {
c, closer, err := client.dialer.dial(ctx, tablet)
if err != nil {
return err
}
defer closer.Close()
_, err = c.UndoDemoteMaster(ctx, &tabletmanagerdatapb.UndoDemotePrimaryRequest{
SemiSync: semiSync,
})
return err
}

// UndoDemotePrimary is part of the tmclient.TabletManagerClient interface.
func (client *Client) UndoDemotePrimary(ctx context.Context, tablet *topodatapb.Tablet, semiSync bool) error {
c, closer, err := client.dialer.dial(ctx, tablet)
Expand Down Expand Up @@ -832,6 +912,23 @@ func (client *Client) ResetReplicationParameters(ctx context.Context, tablet *to
return err
}

// SetMaster is part of the tmclient.TabletManagerClient interface.
func (client *Client) SetMaster(ctx context.Context, tablet *topodatapb.Tablet, parent *topodatapb.TabletAlias, timeCreatedNS int64, waitPosition string, forceStartReplication bool, semiSync bool) error {
c, closer, err := client.dialer.dial(ctx, tablet)
if err != nil {
return err
}
defer closer.Close()
_, err = c.SetMaster(ctx, &tabletmanagerdatapb.SetReplicationSourceRequest{
Parent: parent,
TimeCreatedNs: timeCreatedNS,
WaitPosition: waitPosition,
ForceStartReplication: forceStartReplication,
SemiSync: semiSync,
})
return err
}

// SetReplicationSource is part of the tmclient.TabletManagerClient interface.
func (client *Client) SetReplicationSource(ctx context.Context, tablet *topodatapb.Tablet, parent *topodatapb.TabletAlias, timeCreatedNS int64, waitPosition string, forceStartReplication bool, semiSync bool) error {
c, closer, err := client.dialer.dial(ctx, tablet)
Expand Down
Loading