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

ddl: skip adding index reorg work for empty tables #56406

Merged
merged 27 commits into from
Oct 25, 2024

Conversation

tangenta
Copy link
Contributor

@tangenta tangenta commented Sep 29, 2024

What problem does this PR solve?

Issue Number: close #54230, close #51421

Problem Summary:

We can reduce the overhead of data reorganization or distributed framework scheduling if the target table is empty.

What changed and how does it work?

See code changes.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    Before this PR (empty tables):
    mysql> create index idx_listid on tt1(id,listid);
    Query OK, 0 rows affected (2.52 sec)
    
    mysql> create index idx_listid on tt2(listid);
    Query OK, 0 rows affected (1.52 sec)
    After this PR (empty tables):
    mysql> create index idx_listid on tt1(id,listid);
    Query OK, 0 rows affected (0.34 sec)
    
    mysql> create index idx_listid on tt2(listid);
    Query OK, 0 rows affected (0.29 sec)
    Before this PR (non-empty tables):
    mysql> create index idx_listid on tt1(id,listid);
    Query OK, 0 rows affected (2.49 sec)
    
    mysql> create index idx_listid on tt2(listid);
    Query OK, 0 rows affected (2.16 sec)
    After this PR (non-empty tables):
    mysql> create index idx_listid on tt1(id,listid);
    Query OK, 0 rows affected (2.57 sec)
    
    mysql> create index idx_listid on tt2(listid);
    Query OK, 0 rows affected (2.20 sec)
  • 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

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 29, 2024
Copy link

tiprow bot commented Sep 29, 2024

Hi @tangenta. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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.

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Sep 29, 2024
Copy link

codecov bot commented Sep 29, 2024

Codecov Report

Attention: Patch coverage is 90.85366% with 15 lines in your changes missing coverage. Please review.

Project coverage is 57.3725%. Comparing base (ed9a909) to head (da86bd9).
Report is 8 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #56406         +/-   ##
=================================================
- Coverage   73.2825%   57.3725%   -15.9100%     
=================================================
  Files          1636       1786        +150     
  Lines        453340     643316     +189976     
=================================================
+ Hits         332219     369087      +36868     
- Misses       100768     248976     +148208     
- Partials      20353      25253       +4900     
Flag Coverage Δ
integration 39.5413% <85.9756%> (?)
unit 72.6393% <90.8536%> (+0.1537%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.9478% <ø> (ø)
parser ∅ <ø> (∅)
br 63.1443% <ø> (+17.1531%) ⬆️

Copy link
Contributor

@D3Hunter D3Hunter left a comment

Choose a reason for hiding this comment

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

lgtm except existing comments

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 29, 2024
Copy link

ti-chi-bot bot commented Sep 29, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-29 08:27:28.756711325 +0000 UTC m=+170604.176924336: ☑️ agreed by lance6716.
  • 2024-09-29 08:48:54.421181701 +0000 UTC m=+171889.841394714: ☑️ agreed by D3Hunter.

Copy link
Collaborator

@Benjamin2037 Benjamin2037 left a comment

Choose a reason for hiding this comment

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

rest LGTM

@D3Hunter
Copy link
Contributor

/hold

please pass ctx in bootstrapSessionImpl to rebuildAllPartitionValueMapAndSorted. you can unhold youself after that

@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 Sep 29, 2024
@tangenta
Copy link
Contributor Author

/hold

please pass ctx in bootstrapSessionImpl to rebuildAllPartitionValueMapAndSorted. you can unhold youself after that

Done.

Copy link

@yudongusa yudongusa left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added the approved label Sep 29, 2024
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 30, 2024
@tangenta
Copy link
Contributor Author

tangenta commented Oct 1, 2024

/retest

Copy link

tiprow bot commented Oct 1, 2024

@tangenta: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@tangenta
Copy link
Contributor Author

tangenta commented Oct 8, 2024

/ok-to-test

@tangenta
Copy link
Contributor Author

tangenta commented Oct 8, 2024

/retest

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Oct 8, 2024
@tangenta
Copy link
Contributor Author

tangenta commented Oct 9, 2024

/retest

@tangenta
Copy link
Contributor Author

tangenta commented Oct 9, 2024

/retest

go: downloading github.com/pingcap/failpoint v0.0.0-20240527053858-9b3b6e34194a
go: downloading github.com/sergi/go-diff v1.1.0
bazel --output_user_root=/home/jenkins/.tidb/tmp run --config=ci --repository_cache=/share/.cache/bazel-repository-cache //:gazelle
make: execvp: bazel: Permission denied
make: *** [Makefile:591: bazel_ci_simple_prepare] Error 127
./build/jenkins_unit_test.sh: line 26: bazel_collect: command not found
mv: cannot stat 'bazel.xml': No such file or directory
script returned exit code 2

Copy link

ti-chi-bot bot commented Oct 16, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Benjamin2037, D3Hunter, lance6716, yudongusa

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

@tangenta
Copy link
Contributor 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 Oct 22, 2024
@tangenta
Copy link
Contributor Author

/retest

    plan_test.go:40: 
        	Error Trace:	pkg/planner/core/casetest/plan_test.go:40
        	            				pkg/planner/core/casetest/tiflash_selection_late_materialization_test.go:76
        	Error:      	Not equal: 
        	            	expected: 4
        	            	actual  : 3
        	Test:       	TestTiFlashLateMaterialization


    plan_stats_test.go:81: 
        	Error Trace:	pkg/planner/core/casetest/planstats/plan_stats_test.go:81
        	            				pkg/planner/core/casetest/planstats/plan_stats_test.go:210
        	Error:      	Not equal: 
        	            	expected: 0
        	            	actual  : -1
        	Test:       	TestPlanStatsLoad

@tangenta
Copy link
Contributor Author

/retest

    testkit.go:161: 
        	Error Trace:	pkg/testkit/testkit.go:161
        	            				pkg/testkit/testkit.go:154
        	            				pkg/planner/core/casetest/instanceplancache/concurrency_test.go:84
        	            				src/runtime/asm_amd64.s:1700
        	Error:      	Received unexpected error:
        	            	[executor:1213]Deadlock found when trying to get lock; try restarting transaction
        	            	github.com/pingcap/errors.AddStack
        	            		external/com_github_pingcap_errors/errors.go:178
        	            	github.com/pingcap/errors.Trace
        	            		external/com_github_pingcap_errors/juju_adaptor.go:15
        	            	github.com/pingcap/tidb/pkg/testkit.(*TestKit).ExecWithContext
        	            		pkg/testkit/testkit.go:443
        	            	github.com/pingcap/tidb/pkg/testkit.(*TestKit).MustExecWithContext
        	            		pkg/testkit/testkit.go:159
        	            	github.com/pingcap/tidb/pkg/testkit.(*TestKit).MustExec
        	            		pkg/testkit/testkit.go:154
        	            	pkg/planner/core/casetest/instanceplancache/instanceplancache_test.(*worker).run
        	            		pkg/planner/core/casetest/instanceplancache/concurrency_test.go:84
        	            	runtime.goexit
        	            		src/runtime/asm_amd64.s:1700
        	Test:       	TestInstancePlanCacheConcurrencySysbench
        	Messages:   	sql:update normal.sbtest set c='4639' where id=157, [], error stack [executor:1213]Deadlock found when trying to get lock; try restarting transaction
        	            	github.com/pingcap/errors.AddStack
        	            		external/com_github_pingcap_errors/errors.go:178
        	            	github.com/pingcap/errors.Trace
        	            		external/com_github_pingcap_errors/juju_adaptor.go:15
        	            	github.com/pingcap/tidb/pkg/testkit.(*TestKit).ExecWithContext
        	            		pkg/testkit/testkit.go:443
        	            	github.com/pingcap/tidb/pkg/testkit.(*TestKit).MustExecWithContext
        	            		pkg/testkit/testkit.go:159
        	            	github.com/pingcap/tidb/pkg/testkit.(*TestKit).MustExec
        	            		pkg/testkit/testkit.go:154
        	            	pkg/planner/core/casetest/instanceplancache/instanceplancache_test.(*worker).run
        	            		pkg/planner/core/casetest/instanceplancache/concurrency_test.go:84
        	            	runtime.goexit
        	            		src/runtime/asm_amd64.s:1700

@tangenta
Copy link
Contributor Author

/retest

    queue_v2_ddl_handler_test.go:437: 
        	Error Trace:	pkg/statistics/handle/autoanalyze/priorityqueue/queue_v2_ddl_handler_test.go:437
        	Error:      	Not equal: 
        	            	expected: 114
        	            	actual  : 110
        	Test:       	TestExchangeTablePartition

https://do.pingcap.net/jenkins/blue/rest/organizations/jenkins/pipelines/pingcap/pipelines/tidb/pipelines/pull_unit_test_ddlv1/runs/256/nodes/63/steps/69/log/?start=0

    distsql_test.go:346: 
        	Error Trace:	pkg/executor/distsql_test.go:346
        	Error:      	"1" is not greater than "2"
        	Test:       	TestCoprocessorPagingSize

https://do.pingcap.net/jenkins/blue/rest/organizations/jenkins/pipelines/pingcap/pipelines/tidb/pipelines/ghpr_unit_test/runs/20924/nodes/63/steps/69/log/?start=0

@tangenta
Copy link
Contributor Author

/retest

#56797

    split_table_test.go:64: 
        	Error Trace:	pkg/executor/test/splittest/split_table_test.go:64
        	Error:      	Expect "t_112_5f7203800000000000000183800000000000" to match "t_115_"
        	Test:       	TestClusterIndexShowTableRegion

https://do.pingcap.net/jenkins/blue/rest/organizations/jenkins/pipelines/pingcap/pipelines/tidb/pipelines/ghpr_unit_test/runs/20982/nodes/63/steps/69/log/?start=0

@ti-chi-bot ti-chi-bot bot merged commit 71238b1 into pingcap:master Oct 25, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add index for small partition table on v8.1.0 is slower than it on v7.5.1 flaky test TestDumpPlanReplayerAPI
5 participants