Skip to content

Commit

Permalink
Fixes for avoidance of hosts taking backup in PRS & ERS
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo J. Ortega U. <5791035+ejortegau@users.noreply.github.com>
ejortegau committed Nov 29, 2024
1 parent aad2e46 commit fc1faae
Showing 11 changed files with 900 additions and 1,089 deletions.
194 changes: 92 additions & 102 deletions go/vt/proto/replicationdata/replicationdata.pb.go

Large diffs are not rendered by default.

34 changes: 0 additions & 34 deletions go/vt/proto/replicationdata/replicationdata_vtproto.pb.go

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

1,610 changes: 795 additions & 815 deletions go/vt/proto/tabletmanagerdata/tabletmanagerdata.pb.go

Large diffs are not rendered by default.

68 changes: 0 additions & 68 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.

7 changes: 4 additions & 3 deletions go/vt/vtctl/reparentutil/replication.go
Original file line number Diff line number Diff line change
@@ -216,9 +216,6 @@ func stopReplicationAndBuildStatusMaps(
logger.Infof("getting replication position from %v", alias)

stopReplicationStatus, err := tmc.StopReplicationAndGetStatus(groupCtx, tabletInfo.Tablet, replicationdatapb.StopReplicationMode_IOTHREADONLY)
m.Lock()
res.tabletsBackupState[alias] = stopReplicationStatus.GetBackupRunning()
m.Unlock()
if err != nil {
sqlErr, isSQLErr := sqlerror.NewSQLErrorFromError(err).(*sqlerror.SQLError)
if isSQLErr && sqlErr != nil && sqlErr.Number() == sqlerror.ERNotReplica {
@@ -242,6 +239,10 @@ func stopReplicationAndBuildStatusMaps(
err = vterrors.Wrapf(err, "error when getting replication status for alias %v: %v", alias, err)
}
} else {
m.Lock()
res.tabletsBackupState[alias] = stopReplicationStatus.After.BackupRunning
m.Unlock()

var sqlThreadRunning bool
// Check if the sql thread was running for the tablet
sqlThreadRunning, err = SQLThreadWasRunning(stopReplicationStatus)
4 changes: 1 addition & 3 deletions go/vt/vttablet/grpctmserver/server.go
Original file line number Diff line number Diff line change
@@ -354,7 +354,7 @@ func (s *server) MysqlHostMetrics(ctx context.Context, request *tabletmanagerdat
func (s *server) ReplicationStatus(ctx context.Context, request *tabletmanagerdatapb.ReplicationStatusRequest) (response *tabletmanagerdatapb.ReplicationStatusResponse, err error) {
defer s.tm.HandleRPCPanic(ctx, "ReplicationStatus", request, response, false /*verbose*/, &err)
ctx = callinfo.GRPCCallInfo(ctx)
response = &tabletmanagerdatapb.ReplicationStatusResponse{BackupRunning: s.tm.IsBackupRunning()}
response = &tabletmanagerdatapb.ReplicationStatusResponse{}
status, err := s.tm.ReplicationStatus(ctx)
if err == nil {
response.Status = status
@@ -638,8 +638,6 @@ func (s *server) StopReplicationAndGetStatus(ctx context.Context, request *table
response.Status = statusResponse.Status
}

response.BackupRunning = s.tm.IsBackupRunning()

return response, err
}

8 changes: 7 additions & 1 deletion go/vt/vttablet/tabletmanager/rpc_replication.go
Original file line number Diff line number Diff line change
@@ -46,7 +46,11 @@ func (tm *TabletManager) ReplicationStatus(ctx context.Context) (*replicationdat
if err != nil {
return nil, err
}
return replication.ReplicationStatusToProto(status), nil

protoStatus := replication.ReplicationStatusToProto(status)
protoStatus.BackupRunning = tm.IsBackupRunning()

return protoStatus, nil
}

// FullStatus returns the full status of MySQL including the replication information, semi-sync information, GTID information among others
@@ -893,6 +897,7 @@ func (tm *TabletManager) StopReplicationAndGetStatus(ctx context.Context, stopRe
return StopReplicationAndGetStatusResponse{}, vterrors.Wrap(err, "before status failed")
}
before := replication.ReplicationStatusToProto(rs)
before.BackupRunning = tm.IsBackupRunning()

if stopReplicationMode == replicationdatapb.StopReplicationMode_IOTHREADONLY {
if !rs.IOHealthy() {
@@ -939,6 +944,7 @@ func (tm *TabletManager) StopReplicationAndGetStatus(ctx context.Context, stopRe
}, vterrors.Wrap(err, "acquiring replication status failed")
}
after := replication.ReplicationStatusToProto(rsAfter)
after.BackupRunning = tm.IsBackupRunning()

rs.Position = rsAfter.Position
rs.RelayLogPosition = rsAfter.RelayLogPosition
1 change: 0 additions & 1 deletion proto/replicationdata.proto
Original file line number Diff line number Diff line change
@@ -66,7 +66,6 @@ message Configuration {
message StopReplicationStatus {
replicationdata.Status before = 1;
replicationdata.Status after = 2;
bool backup_running = 3;
}

// StopReplicationMode is used to provide controls over how replication is stopped.
2 changes: 0 additions & 2 deletions proto/tabletmanagerdata.proto
Original file line number Diff line number Diff line change
@@ -360,7 +360,6 @@ message ReplicationStatusRequest {

message ReplicationStatusResponse {
replicationdata.Status status = 1;
bool backup_running = 2;
}

message PrimaryStatusRequest {
@@ -549,7 +548,6 @@ message StopReplicationAndGetStatusResponse {

// Status represents the replication status call right before, and right after telling the replica to stop.
replicationdata.StopReplicationStatus status = 2;
bool backup_running = 3;
}

message PromoteReplicaRequest {
12 changes: 0 additions & 12 deletions web/vtadmin/src/proto/vtadmin.d.ts

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

Loading

0 comments on commit fc1faae

Please sign in to comment.