Skip to content

Commit

Permalink
comment: add code comments
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 committed Sep 26, 2024
1 parent 38983b7 commit ff452cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions go/vt/vttablet/tabletmanager/rpc_replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,8 @@ func (tm *TabletManager) setReplicationSourceLocked(ctx context.Context, parentA
// Since we continue in the case of this error, make sure 'status' is
// in a known, empty state.
status = replication.ReplicationStatus{}
// The replica position we use for the errant GTID detection should be the executed
// GTID set since this tablet is not running replication at all.
replicaPosition, err = tm.MysqlDaemon.PrimaryPosition(ctx)
if err != nil {
return err
Expand Down Expand Up @@ -754,6 +756,10 @@ func (tm *TabletManager) setReplicationSourceLocked(ctx context.Context, parentA
}
// Errant GTID detection.
{
// Find the executed GTID set of the tablet that we are reparenting to.
// We will then compare our own position against it to verify that we don't
// have an errant GTID. If we find any GTID that we have, but the primary doesn't,
// we will not enter the replication graph and instead fail replication.
var primaryPosition string
primaryPosition, err = tm.tmc.PrimaryPosition(ctx, parent.Tablet)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions go/vt/vttablet/tabletmanager/tm_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,11 @@ func (tm *TabletManager) initializeReplication(ctx context.Context, tabletType t
return "", nil
}

// Find our own executed GTID set and,
// the executed GTID set of the tablet that we are reparenting to.
// We will then compare our own position against it to verify that we don't
// have an errant GTID. If we find any GTID that we have, but the primary doesn't,
// we will not enter the replication graph and instead fail replication.
primaryPosStr, err = tm.tmc.PrimaryPosition(ctx, currentPrimary.Tablet)
if err != nil {
return "", err
Expand Down

0 comments on commit ff452cc

Please sign in to comment.