Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#45170
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
zimulala authored and ti-chi-bot committed Jul 17, 2023
1 parent 905a155 commit cf61d1e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,7 @@ func (do *Domain) Init(
if err != nil {
return err
}
startReloadTime := time.Now()
// step 2: domain reload the infoSchema.
err = do.Reload()
if err != nil {
Expand All @@ -1043,7 +1044,21 @@ func (do *Domain) Init(
// 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

0 comments on commit cf61d1e

Please sign in to comment.