From 6eaac8cc5b71fda95199f69b3a70cfd463f479c8 Mon Sep 17 00:00:00 2001 From: jiyfhust Date: Mon, 2 Aug 2021 16:05:06 +0800 Subject: [PATCH] domain: 'load privilege failed' when autocommit is off (#26691) --- domain/domain.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/domain/domain.go b/domain/domain.go index ca5eb267e6..835d24832f 100644 --- a/domain/domain.go +++ b/domain/domain.go @@ -853,8 +853,12 @@ func (do *Domain) GetEtcdClient() *clientv3.Client { // should be called only once in BootstrapSession. func (do *Domain) LoadPrivilegeLoop(ctx sessionctx.Context) error { ctx.GetSessionVars().InRestrictedSQL = true + _, err := ctx.(sqlexec.SQLExecutor).ExecuteInternal(context.Background(), "set @@autocommit = 1") + if err != nil { + return err + } do.privHandle = privileges.NewHandle() - err := do.privHandle.Update(ctx) + err = do.privHandle.Update(ctx) if err != nil { return err }