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

[Direct PR] [release-21.0] Augment PrimaryStatus to also send Server UUID #17032

Merged
Merged
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
3 changes: 3 additions & 0 deletions go/mysql/replication/primary_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ type PrimaryStatus struct {
Position Position
// FilePosition represents the server's file based position.
FilePosition Position
// ServerUUID is the UUID of the server.
ServerUUID string
}

// PrimaryStatusToProto translates a PrimaryStatus to proto3.
func PrimaryStatusToProto(s PrimaryStatus) *replicationdatapb.PrimaryStatus {
return &replicationdatapb.PrimaryStatus{
Position: EncodePosition(s.Position),
FilePosition: EncodePosition(s.FilePosition),
ServerUuid: s.ServerUUID,
}
}

Expand Down
7 changes: 7 additions & 0 deletions go/test/endtoend/utils/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ func TestPrimaryStatus(t *testing.T) {
assert.NoError(t, err)

assert.True(t, res.Position.Equal(r.Position), "primary replication status should be same as replication status here")

suuid, err := mysqld.GetServerUUID(context.Background())
assert.NoError(t, err)
assert.NotEmpty(t, suuid)

// The server UUID read from primary status and GetServerUUID should match
assert.Equal(t, suuid, res.ServerUUID)
}

func TestReplicationConfiguration(t *testing.T) {
Expand Down
10 changes: 9 additions & 1 deletion go/vt/mysqlctl/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,15 @@ func (mysqld *Mysqld) PrimaryStatus(ctx context.Context) (replication.PrimarySta
}
defer conn.Recycle()

return conn.Conn.ShowPrimaryStatus()
primaryStatus, err := conn.Conn.ShowPrimaryStatus()
if err != nil {
return replication.PrimaryStatus{}, err
}
primaryStatus.ServerUUID, err = conn.Conn.GetServerUUID()
if err != nil {
return replication.PrimaryStatus{}, err
}
return primaryStatus, nil
}

func (mysqld *Mysqld) ReplicationConfiguration(ctx context.Context) (*replicationdata.Configuration, error) {
Expand Down
2 changes: 2 additions & 0 deletions go/vt/mysqlctl/replication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ func TestPrimaryStatus(t *testing.T) {

db.AddQuery("SELECT 1", &sqltypes.Result{})
db.AddQuery("SHOW MASTER STATUS", sqltypes.MakeTestResult(sqltypes.MakeTestFields("test_field", "varchar"), "test_status"))
db.AddQuery("SELECT @@global.server_uuid", sqltypes.MakeTestResult(sqltypes.MakeTestFields("test_field", "varchar"), "test_uuid"))

testMysqld := NewMysqld(dbc)
defer testMysqld.Close()
Expand All @@ -295,6 +296,7 @@ func TestPrimaryStatus(t *testing.T) {
res, err := testMysqld.PrimaryStatus(ctx)
assert.NoError(t, err)
assert.NotNil(t, res)
assert.EqualValues(t, "test_uuid", res.ServerUUID)

db.AddQuery("SHOW MASTER STATUS", &sqltypes.Result{})
_, err = testMysqld.PrimaryStatus(ctx)
Expand Down
166 changes: 88 additions & 78 deletions go/vt/proto/replicationdata/replicationdata.pb.go

Large diffs are not rendered by default.

44 changes: 44 additions & 0 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 change: 1 addition & 0 deletions proto/replicationdata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ enum StopReplicationMode {
message PrimaryStatus {
string position = 1;
string file_position = 2;
string server_uuid = 3;
}

// FullStatus contains the full status of MySQL including the replication information, semi-sync information, GTID information among others
Expand Down
6 changes: 6 additions & 0 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.

23 changes: 23 additions & 0 deletions web/vtadmin/src/proto/vtadmin.js

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

Loading