diff --git a/go/vt/vttablet/tabletserver/tabletserver.go b/go/vt/vttablet/tabletserver/tabletserver.go index 34b284c9ee6..63f06b125d1 100644 --- a/go/vt/vttablet/tabletserver/tabletserver.go +++ b/go/vt/vttablet/tabletserver/tabletserver.go @@ -234,7 +234,9 @@ func NewTabletServer(ctx context.Context, name string, config *tabletenv.TabletC // WaitForDBAGrants waits for DBA user to have the required privileges to function properly. func WaitForDBAGrants(config *tabletenv.TabletConfig, waitTime time.Duration) error { - if waitTime == 0 { + // We don't wait for grants if the tablet is externally managed. Permissions + // are then the responsibility of the DBA. + if config.DB.HasGlobalSettings() || waitTime == 0 { return nil } timer := time.NewTimer(waitTime) diff --git a/go/vt/vttablet/tabletserver/tabletserver_test.go b/go/vt/vttablet/tabletserver/tabletserver_test.go index 71ad86bf854..0f85e1018f5 100644 --- a/go/vt/vttablet/tabletserver/tabletserver_test.go +++ b/go/vt/vttablet/tabletserver/tabletserver_test.go @@ -2706,12 +2706,38 @@ func TestWaitForDBAGrants(t *testing.T) { cluster.TearDown() } }, + }, { + name: "Success for externally managed tablet", + waitTime: 300 * time.Millisecond, + errWanted: "", + setupFunc: func(t *testing.T) (*tabletenv.TabletConfig, func()) { + // Create a new mysql but don't give the grants to the vt_dba user at all. + // This should cause a timeout after waiting, since the privileges are never granted. + testUser := "vt_test_dba" + cluster, err := startMySQLAndCreateUser(t, testUser) + require.NoError(t, err) + + tc := &tabletenv.TabletConfig{ + DB: &dbconfigs.DBConfigs{ + Host: "some.unknown.host", + }, + } + connParams := cluster.MySQLConnParams() + connParams.Uname = testUser + tc.DB.SetDbParams(connParams, mysql.ConnParams{}, mysql.ConnParams{}) + return tc, func() { + cluster.TearDown() + } + }, }, { name: "Empty timeout", waitTime: 0, errWanted: "", setupFunc: func(t *testing.T) (*tabletenv.TabletConfig, func()) { - return nil, func() {} + tc := &tabletenv.TabletConfig{ + DB: &dbconfigs.DBConfigs{}, + } + return tc, func() {} }, }, }