Skip to content

Commit 3492c6f

Browse files
zimulalati-chi-bot
authored andcommitted
This is an automated cherry-pick of pingcap#45170
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
1 parent 2db988e commit 3492c6f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

domain/domain.go

+15
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@ func (do *Domain) Init(ddlLease time.Duration, sysExecutorFactory func(*Domain)
852852
if err != nil {
853853
return err
854854
}
855+
startReloadTime := time.Now()
855856
// step 2: domain reload the infoSchema.
856857
err = do.Reload()
857858
if err != nil {
@@ -866,7 +867,21 @@ func (do *Domain) Init(ddlLease time.Duration, sysExecutorFactory func(*Domain)
866867
// Only when the store is local that the lease value is 0.
867868
// If the store is local, it doesn't need loadSchemaInLoop.
868869
if ddlLease > 0 {
870+
<<<<<<< HEAD
869871
do.wg.Add(1)
872+
=======
873+
sub := time.Since(startReloadTime)
874+
// The reload(in step 2) operation takes more than ddlLease and a new reload operation was not performed,
875+
// the next query will respond by ErrInfoSchemaExpired error. So we do a new reload to update schemaValidator.latestSchemaExpire.
876+
if sub > (ddlLease / 2) {
877+
logutil.BgLogger().Warn("loading schema takes a long time, we do a new reload", zap.Duration("take time", sub))
878+
err = do.Reload()
879+
if err != nil {
880+
return err
881+
}
882+
}
883+
884+
>>>>>>> 492e0df543c (domain: fix a bug when reloading take a long time in domain.Init (#45170))
870885
// Local store needs to get the change information for every DDL state in each session.
871886
go do.loadSchemaInLoop(ctx, ddlLease)
872887
}

0 commit comments

Comments
 (0)