Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

domain: fix a bug when reloading take a long time in domain.Init (#45170) #45389

Open
wants to merge 1 commit into
base: release-6.1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ func (do *Domain) Init(ddlLease time.Duration, sysExecutorFactory func(*Domain)
if err != nil {
return err
}
startReloadTime := time.Now()
// step 2: domain reload the infoSchema.
err = do.Reload()
if err != nil {
Expand All @@ -866,7 +867,21 @@ func (do *Domain) Init(ddlLease time.Duration, sysExecutorFactory func(*Domain)
// Only when the store is local that the lease value is 0.
// If the store is local, it doesn't need loadSchemaInLoop.
if ddlLease > 0 {
<<<<<<< HEAD
do.wg.Add(1)
=======
sub := time.Since(startReloadTime)
// The reload(in step 2) operation takes more than ddlLease and a new reload operation was not performed,
// the next query will respond by ErrInfoSchemaExpired error. So we do a new reload to update schemaValidator.latestSchemaExpire.
if sub > (ddlLease / 2) {
logutil.BgLogger().Warn("loading schema takes a long time, we do a new reload", zap.Duration("take time", sub))
err = do.Reload()
if err != nil {
return err
}
}

>>>>>>> 492e0df543c (domain: fix a bug when reloading take a long time in domain.Init (#45170))
// Local store needs to get the change information for every DDL state in each session.
go do.loadSchemaInLoop(ctx, ddlLease)
}
Expand Down