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

Slowness in schema reload makes all requests on the same tidb slow #45400

Closed
AndreMouche opened this issue Jul 17, 2023 · 3 comments · Fixed by #45802
Closed

Slowness in schema reload makes all requests on the same tidb slow #45400

AndreMouche opened this issue Jul 17, 2023 · 3 comments · Fixed by #45802
Labels
affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-6.5 affects-7.1 sig/sql-infra SIG: SQL Infra type/enhancement The issue or PR belongs to an enhancement.

Comments

@AndreMouche
Copy link
Contributor

Enhancement

When TiKV restarts, the latency increases due to the shared lock between expiredTimeStamp4PC and load-schema.
The related issue #45385 that if Load infoschema operation in domain takes a long time, then it may block the 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, then OptimizeExecStmt https://github.com/pingcap/tidb/blob/v6.5.0/planner/optimize.go#L129, then calls GetPlanFromSessionPlanCache https://github.com/pingcap/tidb/blob/v6.5.0/planner/optimize.go#L439, then planCachePreprocess https://github.com/pingcap/tidb/blob/v6.5.0/planner/core/plan_cache.go#L118, then ExpiredTimeStamp4PC 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#L395

thus 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.

@AndreMouche AndreMouche added the type/enhancement The issue or PR belongs to an enhancement. label Jul 17, 2023
@AndreMouche
Copy link
Contributor Author

@zimulala @qw4990 Please help take a look, thanks

@aidendou
Copy link
Contributor

aidendou commented Jul 27, 2023

Hi @AndreMouche, I'll take this one.

@jebter
Copy link

jebter commented Sep 21, 2023

/sig sql-infra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-6.5 affects-7.1 sig/sql-infra SIG: SQL Infra type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants