Skip to content

Commit

Permalink
Manual backport of vitessio#17300
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo J. Ortega U. <5791035+ejortegau@users.noreply.github.com>
  • Loading branch information
ejortegau committed Dec 2, 2024
1 parent f75d407 commit 5beb164
Show file tree
Hide file tree
Showing 11 changed files with 385 additions and 590 deletions.
175 changes: 82 additions & 93 deletions go/vt/proto/replicationdata/replicationdata.pb.go

Large diffs are not rendered by default.

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

581 changes: 280 additions & 301 deletions go/vt/proto/tabletmanagerdata/tabletmanagerdata.pb.go

Large diffs are not rendered by default.

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

17 changes: 14 additions & 3 deletions go/vt/vtctl/reparentutil/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,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 := mysql.NewSQLErrorFromError(err).(*mysql.SQLError)
if isSQLErr && sqlErr != nil && sqlErr.Number() == mysql.ERNotReplica {
Expand All @@ -276,6 +273,20 @@ func stopReplicationAndBuildStatusMaps(
err = vterrors.Wrapf(err, "error when getting replication status for alias %v: %v", alias, err)
}
} else {
isTakingBackup := false

// Prefer the most up-to-date information regarding whether the tablet is taking a backup from the After
// replication status, but fall back to the Before status if After is nil.
if stopReplicationStatus.After != nil {
isTakingBackup = stopReplicationStatus.After.BackupRunning
} else if stopReplicationStatus.Before != nil {
isTakingBackup = stopReplicationStatus.Before.BackupRunning
}

m.Lock()
res.tabletsBackupState[alias] = isTakingBackup
m.Unlock()

var sqlThreadRunning bool
// Check if the sql thread was running for the tablet
sqlThreadRunning, err = SQLThreadWasRunning(stopReplicationStatus)
Expand Down
2 changes: 0 additions & 2 deletions go/vt/vttablet/grpctmserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ func (s *server) ReplicationStatus(ctx context.Context, request *tabletmanagerda
response.Status = status
}

response.BackupRunning = s.tm.IsBackupRunning()

return response, err
}

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

protoStatus := mysql.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
Expand Down Expand Up @@ -909,6 +913,7 @@ func (tm *TabletManager) StopReplicationAndGetStatus(ctx context.Context, stopRe
return StopReplicationAndGetStatusResponse{}, vterrors.Wrap(err, "before status failed")
}
before := mysql.ReplicationStatusToProto(rs)
before.BackupRunning = tm.IsBackupRunning()

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

rs.Position = rsAfter.Position
rs.RelayLogPosition = rsAfter.RelayLogPosition
Expand Down
1 change: 0 additions & 1 deletion proto/replicationdata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ message Status {
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.
Expand Down
2 changes: 0 additions & 2 deletions proto/tabletmanagerdata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ message ReplicationStatusRequest {

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

message PrimaryStatusRequest {
Expand Down Expand Up @@ -460,7 +459,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 {
Expand Down
18 changes: 0 additions & 18 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 5beb164

Please sign in to comment.