Slowness in schema reload makes all requests on the same tidb slow #45400
Labels
affects-5.4
This bug affects the 5.4.x(LTS) versions.
affects-6.1
This bug affects the 6.1.x(LTS) versions.
affects-6.5
This bug affects the 6.5.x(LTS) versions.
affects-7.1
This bug affects the 7.1.x(LTS) versions.
sig/sql-infra
SIG: SQL Infra
type/enhancement
The issue or PR belongs to an enhancement.
Enhancement
When TiKV restarts, the latency increases due to the shared
lock
betweenexpiredTimeStamp4PC
andload-schema
.The related issue #45385 that if
Load infoschema operation in domain takes a long time
, then it may blockthe compile process
, then makes the request on this tidb slow.more details:
the reload process locks a mutex https://github.com/pingcap/tidb/blob/v6.5.0/domain/domain.go#L455.
however, the compile process calls
Optimize
https://github.com/pingcap/tidb/blob/v6.5.0/executor/compiler.go#L116, thenOptimizeExecStmt
https://github.com/pingcap/tidb/blob/v6.5.0/planner/optimize.go#L129, then callsGetPlanFromSessionPlanCache
https://github.com/pingcap/tidb/blob/v6.5.0/planner/optimize.go#L439, thenplanCachePreprocess
https://github.com/pingcap/tidb/blob/v6.5.0/planner/core/plan_cache.go#L118, thenExpiredTimeStamp4PC
https://github.com/pingcap/tidb/blob/v6.5.0/planner/core/plan_cache.go#L102, which eventually reaches https://github.com/pingcap/tidb/blob/v6.5.0/domain/domain.go#L395thus a slow batch-get request about the shcema version would block all requests on the same tidb, which doesn't make sense, particularly, the lock https://github.com/pingcap/tidb/blob/v6.5.0/domain/domain.go#L394-L407 doesn't need to be the same as the one used in
Reload
using v6.5.0 as an example, the the issue applies to master as well.
The text was updated successfully, but these errors were encountered: