Skip to content

Commit

Permalink
feat: fix ordering of alter statement in init primary (#10917)
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <manan@planetscale.com>
  • Loading branch information
GuptaManan100 committed Aug 3, 2022
1 parent 2097c95 commit 02f6ee9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions go/vt/vttablet/tabletmanager/rpc_replication.go
Expand Up @@ -271,16 +271,19 @@ func (tm *TabletManager) InitPrimary(ctx context.Context, semiSync bool) (string
return "", err
}

// Execute ALTER statement on reparent_journal table and ignore errors
cmds = mysqlctl.AlterReparentJournal()
_ = tm.MysqlDaemon.ExecuteSuperQueryList(ctx, cmds)

// get the current replication position
pos, err := tm.MysqlDaemon.PrimaryPosition()
if err != nil {
return "", err
}

// Execute ALTER statement on reparent_journal table and ignore errors.
// This ALTER statement has to be after we take the position of the primary
// so that if we use that position to set the gtid_purged on replica's we still
// replicate this statement if it succeeds.
cmds = mysqlctl.AlterReparentJournal()
_ = tm.MysqlDaemon.ExecuteSuperQueryList(ctx, cmds)

// Set the server read-write, from now on we can accept real
// client writes. Note that if semi-sync replication is enabled,
// we'll still need some replicas to be able to commit transactions.
Expand Down

0 comments on commit 02f6ee9

Please sign in to comment.