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

*: caller can use a fixed TS for fast reorg #52993

Merged
merged 17 commits into from May 10, 2024

Conversation

lance6716
Copy link
Contributor

@lance6716 lance6716 commented Apr 29, 2024

What problem does this PR solve?

Issue Number: ref #49233 close #46986

Problem Summary:

What changed and how does it work?

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.
GOCACHE=/tmp/failpoint-cache go build -o bin/tidb-server-failpoint -toolexec failpoint-toolexec ./cmd/tidb-server

tiup playground nightly --tiflash 0 --without-monitor --db 0

rm /tmp/tidb-{0,1}.log

GO_FAILPOINTS="github.com/pingcap/tidb/pkg/ddl/ingest/resignAfterFlush=return();github.com/pingcap/tidb/pkg/ddl/ingest/checkpointLoopExit=return();github.com/pingcap/tidb/pkg/ddl/ingest/forceSyncFlagForTest=return();github.com/pingcap/tidb/pkg/ddl/ownerResignAfterDispatchLoopCheck=return()" ./bin/tidb-server-failpoint -P 4000 --store=tikv --host=127.0.0.1 --status=10080 --path=127.0.0.1:2379 --log-file=/tmp/tidb-0.log

mysql --comments --host 127.0.0.1 --port 4000 -u root -e "set @@global.tidb_enable_dist_task = 0;set @@global.tidb_ddl_reorg_worker_cnt = 1;create table test.t(c int primary key, c2 int);split table test.t between (0) and (10000) regions 10;insert into test.t values (1,1), (3000, 3000), (6000, 6000);"

./bin/tidb-server-failpoint -P 4001 --store=tikv --host=127.0.0.1 --status=10081 --path=127.0.0.1:2379 --log-file=/tmp/tidb-1.log

mysql --comments --host 127.0.0.1 --port 4001 -u root -e "alter table test.t add unique index idx(c2);"

before

image

after

image

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: lance6716 <lance6716@gmail.com>
@ti-chi-bot ti-chi-bot bot added release-note-none do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 29, 2024
Copy link

tiprow bot commented Apr 29, 2024

Hi @lance6716. 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/test-infra repository.

Copy link

codecov bot commented Apr 29, 2024

Codecov Report

Attention: Patch coverage is 57.40741% with 69 lines in your changes are missing coverage. Please review.

Project coverage is 73.8742%. Comparing base (49f09fe) to head (866b8ab).

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #52993        +/-   ##
================================================
+ Coverage   72.4413%   73.8742%   +1.4328%     
================================================
  Files          1492       1533        +41     
  Lines        429013     444320     +15307     
================================================
+ Hits         310783     328238     +17455     
+ Misses        98955      95419      -3536     
- Partials      19275      20663      +1388     
Flag Coverage Δ
integration 49.3033% <52.4691%> (?)
unit 71.2363% <34.8101%> (-0.0962%) ⬇️

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

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 46.6467% <ø> (+5.2232%) ⬆️

Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@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/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 30, 2024
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
@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 May 8, 2024
@lance6716 lance6716 changed the title [WIP]*: add TS field so caller can use a fixed TS *: add TS field so caller can use a fixed TS May 8, 2024
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 8, 2024
Signed-off-by: lance6716 <lance6716@gmail.com>
@lance6716 lance6716 changed the title *: add TS field so caller can use a fixed TS *: caller can use a fixed TS for fast reorg May 8, 2024
@lance6716 lance6716 changed the title *: caller can use a fixed TS for fast reorg [WIP]*: caller can use a fixed TS for fast reorg May 8, 2024
@ti-chi-bot ti-chi-bot bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 8, 2024
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
@lance6716 lance6716 changed the title [WIP]*: caller can use a fixed TS for fast reorg *: caller can use a fixed TS for fast reorg May 8, 2024
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 8, 2024
@lance6716
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented May 8, 2024

@lance6716: 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.

Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
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.

rest lgtm

ts := oracle.ComposeTS(physical, logical)
ts := cfg.TS
if ts == 0 {
ts = oracle.ComposeTS(physical, logical)
Copy link
Contributor

Choose a reason for hiding this comment

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

we can skip GetTS if ts != 0

@@ -89,6 +89,9 @@ type EngineConfig struct {
// KeepSortDir indicates whether to keep the temporary sort directory
// when opening the engine, instead of removing it.
KeepSortDir bool
// TS is the preset timestamp of data in the engine. When it's 0, the used TS
// will be set lazily.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// will be set lazily.
// will be set lazily.
// only used in global sort now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's also used in generateLocalEngineConfig in local fast reorg of DDL

@@ -298,6 +314,7 @@ type ReorgCheckpoint struct {
PhysicalID int64 `json:"physical_id"`
StartKey kv.Key `json:"start_key"`
EndKey kv.Key `json:"end_key"`
TS uint64 `json:"ts"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
TS uint64 `json:"ts"`
// TS of next engine ingest.
TS uint64 `json:"ts"`

return nil
}

func (s *CheckpointManager) refreshTS() (uint64, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (s *CheckpointManager) refreshTS() (uint64, error) {
func (s *CheckpointManager) refreshTSAndUpdateCP() (uint64, error) {

the refreshTS part is same as in resumeOrInitCheckpoint

Signed-off-by: lance6716 <lance6716@gmail.com>
Copy link

ti-chi-bot bot commented May 10, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, 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

Copy link

ti-chi-bot bot commented May 10, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-05-10 08:13:37.757198525 +0000 UTC m=+1208971.514334083: ☑️ agreed by tangenta.
  • 2024-05-10 09:57:20.835816503 +0000 UTC m=+1215194.592952077: ☑️ agreed by D3Hunter.

@lance6716
Copy link
Contributor 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 May 10, 2024
Signed-off-by: lance6716 <lance6716@gmail.com>
@lance6716
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 May 10, 2024
@ti-chi-bot ti-chi-bot bot merged commit f46db20 into pingcap:master May 10, 2024
22 checks passed
@lance6716
Copy link
Contributor Author

/cherry-pick release-8.1

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request May 11, 2024
@ti-chi-bot
Copy link
Member

@lance6716: new pull request created to branch release-8.1: #53188.

In response to this:

/cherry-pick release-8.1

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none 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.

For lightning external engine (global sort), engine TS should keep same after subtask failover
4 participants