Skip to content

statistics, config: rightly deal with innodb_lock_wait_timeout when to load stats#65632

Merged
ti-chi-bot[bot] merged 10 commits intopingcap:masterfrom
hawkingrei:disable_load_innodb_lock_wait_timeout
Jan 19, 2026
Merged

statistics, config: rightly deal with innodb_lock_wait_timeout when to load stats#65632
ti-chi-bot[bot] merged 10 commits intopingcap:masterfrom
hawkingrei:disable_load_innodb_lock_wait_timeout

Conversation

@hawkingrei
Copy link
Copy Markdown
Member

@hawkingrei hawkingrei commented Jan 19, 2026

What problem does this PR solve?

Issue Number: close #65634

Problem Summary:

load large plan replayer (for example, plan replayer testing). You will see this error log.

[2026/01/19 15:34:53.818 +08:00] [WARN] [conn.go:1215] ["command dispatched failed"] [conn=2650800358] [session_alias=] [connInfo="id:2650800358, addr:127.0.0.1:37854 status:10, collation:utf8mb4_general_ci, user:root"] [command=Query] [status="inTxn:0, autocommit:1"] [sql="plan replayer load './replayer/partition/xxxx/plan_replayer1121.zip'"] [txn_mode=PESSIMISTIC] [timestamp=463682415160721420] [err="[tikv:1205]Lock wait timeout exceeded; try restarting transaction\ngithub.com/pingcap/errors.Trace\n\t/root/go/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20250523034308-74f78ae071ee/juju_adaptor.go:15\ngithub.com/pingcap/tidb/pkg/statistics/handle/util.finishTransaction\n\t/workspace/source/tidb/pkg/statistics/handle/util/util.go:71\ngithub.com/pingcap/tidb/pkg/statistics/handle/util.WrapTxn.func1\n\t/workspace/source/tidb/pkg/statistics/handle/util/util.go:195\ngithub.com/pingcap/tidb/pkg/statistics/handle/util.WrapTxn\n\t/workspace/source/tidb/pkg/statistics/handle/util/util.go:198\ngithub.com/pingcap/tidb/pkg/statistics/handle/util.CallWithSCtx.func1.1\n\t/workspace/source/tidb/pkg/statistics/handle/util/util.go:95\ngithub.com/pingcap/tidb/pkg/session/syssession.(*Session).WithSessionContext.func1\n\t/workspace/source/tidb/pkg/session/syssession/session.go:519\ngithub.com/pingcap/tidb/pkg/session/syssession.(*session).OwnerWithSctx\n\t/workspace/source/tidb/pkg/session/syssession/session.go:278\ngithub.com/pingcap/tidb/pkg/session/syssession.(*Session).WithSessionContext\n\t/workspace/source/tidb/pkg/session/syssession/session.go:518\ngithub.com/pingcap/tidb/pkg/statistics/handle/util.CallWithSCtx.func1\n\t/workspace/source/tidb/pkg/statistics/handle/util/util.go:83\ngithub.com/pingcap/tidb/pkg/session/syssession.(*AdvancedSessionPool).WithSession\n\t/workspace/source/tidb/pkg/session/syssession/pool.go:274\ngithub.com/pingcap/tidb/pkg/statistics/handle/util.CallWithSCtx\n\t/workspace/source/tidb/pkg/statistics/handle/util/util.go:82\ngithub.com/pingcap/tidb/pkg/statistics/handle/storage.(*statsReadWriter).SaveColOrIdxStatsToStorage\n\t/workspace/source/tidb/pkg/statistics/handle/storage/stats_read_writer.go:213\ngithub.com/pingcap/tidb/pkg/statistics/handle/storage.(*statsReadWriter).loadStatsFromJSON.func1\n\t/workspace/source/tidb/pkg/statistics/handle/storage/stats_read_writer.go:677\ngithub.com/pingcap/tidb/pkg/statistics.(*HistColl).ForEachColumnImmutable\n\t/workspace/source/tidb/pkg/statistics/table.go:333\ngithub.com/pingcap/tidb/pkg/statistics/handle/storage.(*statsReadWriter).loadStatsFromJSON\n\t/workspace/source/tidb/pkg/statistics/handle/storage/stats_read_writer.go:673\ngithub.com/pingcap/tidb/pkg/statistics/handle/storage.(*statsReadWriter).LoadStatsFromJSONConcurrently.func1\n\t/workspace/source/tidb/pkg/statistics/handle/storage/stats_read_writer.go:595\ngithub.com/tiancaiamao/gp.workerLoop\n\t/root/go/pkg/mod/github.com/tiancaiamao/gp@v0.0.0-20221230034425-4025bc8a4d4a/gp.go:72\ngithub.com/tiancaiamao/gp.worker\n\t/root/go/pkg/mod/github.com/tiancaiamao/gp@v0.0.0-20221230034425-4025bc8a4d4a/gp.go:51\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1693"]

What changed and how does it work?

  1. plan replayer cannot load innodb_lock_wait_timeout
  2. when loading stats, we use global innodb_lock_wait_timeout into internal sql.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

test it with plan replayer testing.

  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Copilot AI review requested due to automatic review settings January 19, 2026 06:02
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 19, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a filtering mechanism to prevent loading specific system variables during plan replayer operations. The change excludes innodb_lock_wait_timeout from being loaded when restoring session state from plan replayer data.

Changes:

  • Introduced a blacklist map for system variables that should be skipped during plan replayer load
  • Added filtering logic in LoadConfig to check against the blacklist before processing variables

Copilot AI review requested due to automatic review settings January 19, 2026 06:23
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
@hawkingrei hawkingrei force-pushed the disable_load_innodb_lock_wait_timeout branch from 093862c to 053a85d Compare January 19, 2026 06:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.

Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Copilot AI review requested due to automatic review settings January 19, 2026 06:46
@ti-chi-bot ti-chi-bot bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 19, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
@hawkingrei hawkingrei force-pushed the disable_load_innodb_lock_wait_timeout branch from 860ee29 to 4005322 Compare January 19, 2026 06:58
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Copilot AI review requested due to automatic review settings January 19, 2026 07:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 19, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Jan 19, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-01-19 07:39:50.480633239 +0000 UTC m=+393218.094590096: ☑️ agreed by qw4990.
  • 2026-01-19 09:25:01.531682353 +0000 UTC m=+399529.145639199: ☑️ agreed by time-and-fate.

@hawkingrei
Copy link
Copy Markdown
Member Author

/unhold

Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
@hawkingrei
Copy link
Copy Markdown
Member Author

/unhold

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

@YangKeao
Copy link
Copy Markdown
Member

/retest

1 similar comment
@YangKeao
Copy link
Copy Markdown
Member

/retest

Copy link
Copy Markdown
Contributor

@mjonss mjonss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider renaming LoadConfig to LoadConfigForPlanReplayer, so it is more clear to not be used in any other context.

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Jan 19, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mjonss, qw4990, time-and-fate

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hawkingrei
Copy link
Copy Markdown
Member Author

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 19, 2026
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
@hawkingrei
Copy link
Copy Markdown
Member Author

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 19, 2026
@YangKeao
Copy link
Copy Markdown
Member

/retest

2 similar comments
@YangKeao
Copy link
Copy Markdown
Member

/retest

@YangKeao
Copy link
Copy Markdown
Member

/retest

@ti-chi-bot ti-chi-bot bot merged commit ecfd25a into pingcap:master Jan 19, 2026
32 checks passed
hawkingrei added a commit to hawkingrei/tidb that referenced this pull request Jan 19, 2026
@hawkingrei
Copy link
Copy Markdown
Member Author

/cherrypick release-8.5

@ti-chi-bot
Copy link
Copy Markdown
Member

@hawkingrei: new pull request created to branch release-8.5: #65759.
But this PR has conflicts, please resolve them!

Details

In response to this:

/cherrypick release-8.5

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jan 23, 2026
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
hawkingrei added a commit that referenced this pull request Feb 11, 2026
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot bot pushed a commit that referenced this pull request Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved component/statistics lgtm release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

large plan replayer will raise the Lock wait timeout exceeded

7 participants