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

*: add metadata lock when using the plan cache (#51897) #52956

Merged

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #51897

What problem does this PR solve?

Issue Number: close #51407

Problem Summary:
When executing the prepared statement from the plan cache, tidb doesn't add the metadata lock, which may cause data-index inconsistency.

What changed and how does it work?

  1. Collect the related table information when PREPARE.
  2. Add metadata lock during planCachePreprocess. If the schema is changed, can't use the cache plan anymore.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • 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.

fix a bug that metadata lock is missing when using the plan cache

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-6.5 This PR is cherry-picked to release-6.5 from a source PR. labels Apr 28, 2024
@ti-chi-bot ti-chi-bot bot added do-not-merge/cherry-pick-not-approved size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 28, 2024
@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label May 31, 2024
@lance6716
Copy link
Contributor

@wjhuang2016 please fix the conflict

Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@wjhuang2016 wjhuang2016 force-pushed the cherry-pick-51897-to-release-6.5 branch from f4fe834 to 9c24c67 Compare June 4, 2024 09:15
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 4, 2024
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@wjhuang2016
Copy link
Member

/retest

1 similar comment
@lance6716
Copy link
Contributor

/retest

@lance6716
Copy link
Contributor

    conn_stmt_test.go:580: 
        	Error Trace:	server/conn_stmt_test.go:580
        	Error:      	An error is expected but got nil.
        	Test:       	TestCursorFetchErrorInFetch

@qw4990
Copy link
Contributor

qw4990 commented Jun 7, 2024

/test unit-test

Copy link

tiprow bot commented Jun 7, 2024

@qw4990: No presubmit jobs available for pingcap/tidb@release-6.5

In response to this:

/test unit-test

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 kubernetes-sigs/prow repository.

@qw4990
Copy link
Contributor

qw4990 commented Jun 11, 2024

/test unit-test

Copy link

tiprow bot commented Jun 11, 2024

@qw4990: No presubmit jobs available for pingcap/tidb@release-6.5

In response to this:

/test unit-test

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 kubernetes-sigs/prow repository.

@wjhuang2016
Copy link
Member

/retest

2 similar comments
@tangenta
Copy link
Contributor

/retest

@tangenta
Copy link
Contributor

/retest

@ti-chi-bot ti-chi-bot bot removed the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 12, 2024
@ti-chi-bot ti-chi-bot bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jun 12, 2024
@tangenta
Copy link
Contributor

/retest

@tangenta
Copy link
Contributor

tangenta commented Jun 12, 2024

Error Trace:	testkit/testkit.go:132
			testkit/testkit.go:125
			tests/realtikvtest/addindextest/add_index_test.go:34
			tests/realtikvtest/addindextest/multi_schema_change_test.go:22
			tests/realtikvtest/addindextest/multi_schema_change_test.go:43
Error:      	Received unexpected error:
			[domain:8243]no leader

@tangenta
Copy link
Contributor

/retest

@tangenta
Copy link
Contributor

    db_partition_test.go:4736: 
        	Error Trace:	ddl/db_partition_test.go:4736
        	Error:      	Error "[domain:8028]Information schema is changed during the execution of the statement(for example, table definition may be updated by other DDL ran in parallel). If you see this error often, try increasing `tidb_max_delta_schema_count`. [try again later]" does not contain "[ddl:8200]Unsupported modify column: table is partition table"
        	Test:       	TestIssue40135Ver2

@tangenta
Copy link
Contributor

    oom_test.go:110: 
        	Error Trace:	executor/oomtest/oom_test.go:110
        	Error:      	Not equal: 
        	            	expected: "expensive_query during bootstrap phase"
        	            	actual  : "SetTiFlashGroupConfig"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-expensive_query during bootstrap phase
        	            	+SetTiFlashGroupConfig
        	Test:       	TestMemTracker4InsertAndReplaceExec

@ti-chi-bot ti-chi-bot removed the cherry-pick-approved Cherry pick PR approved by release team. label Jun 12, 2024
Copy link

codecov bot commented Jun 12, 2024

Codecov Report

Attention: Patch coverage is 30.00000% with 56 lines in your changes missing coverage. Please review.

Please upload report for BASE (release-6.5@ddc6543). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-6.5     #52956   +/-   ##
================================================
  Coverage               ?   73.6204%           
================================================
  Files                  ?       1096           
  Lines                  ?     352204           
  Branches               ?          0           
================================================
  Hits                   ?     259294           
  Misses                 ?      76238           
  Partials               ?      16672           

@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Jun 12, 2024
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jun 12, 2024
@ti-chi-bot ti-chi-bot bot added the lgtm label Jun 12, 2024
Copy link

ti-chi-bot bot commented Jun 12, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qw4990, tangenta

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

The pull request process is described here

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

@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 12, 2024
Copy link

ti-chi-bot bot commented Jun 12, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-12 06:30:03.133366862 +0000 UTC m=+532557.186678788: ☑️ agreed by tangenta.
  • 2024-06-12 07:04:06.178963133 +0000 UTC m=+534600.232275057: ☑️ agreed by qw4990.

@ti-chi-bot ti-chi-bot bot merged commit 2306250 into pingcap:release-6.5 Jun 12, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved cherry-pick-approved Cherry pick PR approved by release team. lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/cherry-pick-for-release-6.5 This PR is cherry-picked to release-6.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants