Skip to content

Commit

Permalink
feat: reorder WaitForDBAGrants so that it is called before we start t…
Browse files Browse the repository at this point in the history
…rying to restore

Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 committed Dec 20, 2023
1 parent 91bb0b9 commit 584b470
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions go/vt/vttablet/tabletmanager/tm_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,14 @@ func (tm *TabletManager) Start(tablet *topodatapb.Tablet, config *tabletenv.Tabl
tm.exportStats()
servenv.OnRun(tm.registerTabletManager)

// Make sure we have the correct privileges for the DBA user before we start the state manager.
// We want to ensure that the users have the correct privileges before we create any connections.
// Calling WaitForDBAGrants here will mean that we call it once more if MySQL is restoring from backup, but it should be safe to do so.
err = tabletserver.WaitForDBAGrants(config, dbaGrantWaitTime)
if err != nil {
return err
}

restoring, err := tm.handleRestore(tm.BatchCtx, config)
if err != nil {
return err
Expand All @@ -417,11 +425,6 @@ func (tm *TabletManager) Start(tablet *topodatapb.Tablet, config *tabletenv.Tabl
return err
}

// Make sure we have the correct privileges for the DBA user before we start the state manager.
err = tabletserver.WaitForDBAGrants(config, dbaGrantWaitTime)
if err != nil {
return err
}
tm.tmState.Open()
return nil
}
Expand Down

0 comments on commit 584b470

Please sign in to comment.