From 83538764c2c4ef39fccf6ebd7fdff3eee07aeb87 Mon Sep 17 00:00:00 2001 From: tangenta Date: Thu, 9 Feb 2023 16:02:14 +0800 Subject: [PATCH 1/2] ddl: initialize the mock session in advanced --- ddl/backfilling.go | 1 + 1 file changed, 1 insertion(+) diff --git a/ddl/backfilling.go b/ddl/backfilling.go index 4455801b7cc6d..38beb603b72ec 100644 --- a/ddl/backfilling.go +++ b/ddl/backfilling.go @@ -861,6 +861,7 @@ func initSessCtx(sessCtx sessionctx.Context, sqlMode mysql.SQLMode, tzLocation * sessCtx.GetSessionVars().StmtCtx.DividedByZeroAsWarning = !sqlMode.HasStrictMode() sessCtx.GetSessionVars().StmtCtx.IgnoreZeroInDate = !sqlMode.HasStrictMode() || sqlMode.HasAllowInvalidDatesMode() sessCtx.GetSessionVars().StmtCtx.NoZeroDate = sqlMode.HasStrictMode() + _ = sessCtx.GetDomainInfoSchema() // For mock context, prevent initializing it in the worker concurrently. return nil } From d7b3b031adf5caf7eca15188ca8b92614b8cc9ee Mon Sep 17 00:00:00 2001 From: tangenta Date: Thu, 9 Feb 2023 16:07:47 +0800 Subject: [PATCH 2/2] add more comment --- ddl/backfilling.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ddl/backfilling.go b/ddl/backfilling.go index 38beb603b72ec..6abaad9396e6c 100644 --- a/ddl/backfilling.go +++ b/ddl/backfilling.go @@ -861,7 +861,9 @@ func initSessCtx(sessCtx sessionctx.Context, sqlMode mysql.SQLMode, tzLocation * sessCtx.GetSessionVars().StmtCtx.DividedByZeroAsWarning = !sqlMode.HasStrictMode() sessCtx.GetSessionVars().StmtCtx.IgnoreZeroInDate = !sqlMode.HasStrictMode() || sqlMode.HasAllowInvalidDatesMode() sessCtx.GetSessionVars().StmtCtx.NoZeroDate = sqlMode.HasStrictMode() - _ = sessCtx.GetDomainInfoSchema() // For mock context, prevent initializing it in the worker concurrently. + // Prevent initializing the mock context in the workers concurrently. + // For details, see https://github.com/pingcap/tidb/issues/40879. + _ = sessCtx.GetDomainInfoSchema() return nil }