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 getting actual end key for each range in ingest mode #54143

Merged
merged 4 commits into from
Jun 24, 2024

Conversation

tangenta
Copy link
Contributor

@tangenta tangenta commented Jun 20, 2024

What problem does this PR solve?

Issue Number: close #45847, close #54147

Problem Summary: See #54147 (comment)

What changed and how does it work?

It is slow to get the actual end key of a range.

Previously, we introduce this for the reason that there may be mass writes during adding index, and the txn backfill workers cannot catch up with newly written row records. As a result, adding index never complete.

However, this can hardly happen in ingest mode:

  1. in write&ingest step, we use coprocessor instead of kv.scan to read table data, backfill workers are 10X speeded up.
  2. in merge temp-index step, index records are relatively small, and we have double-write mechanism to avoid temp index data grow infinitely.

This PR skips getting actual end key for each range in ingest mode.

Other changes include:

  • Refine the usage of splitTableRanges.
  • Extract getActualEndKey to a function.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    mysql> alter table usertable add index test_idx(FIELD0);
    Query OK, 0 rows affected (2 min 32.11 sec)
    
    mysql> alter table usertable add index test_idx(FIELD0);
    Query OK, 0 rows affected (2 min 28.35 sec)
    
    mysql> alter table usertable add index test_idx(FIELD0);
    Query OK, 0 rows affected (2 min 33.82 sec)
    
    mysql> alter table usertable add index test_idx(FIELD0);
    Query OK, 0 rows affected (2 min 29.74 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 Jun 20, 2024
Copy link

tiprow bot commented Jun 20, 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.

@tangenta tangenta force-pushed the add-index-skip-act-end branch from 4970024 to f9e4722 Compare June 20, 2024 13:47
Copy link

codecov bot commented Jun 20, 2024

Codecov Report

Attention: Patch coverage is 69.64286% with 17 lines in your changes missing coverage. Please review.

Project coverage is 57.4228%. Comparing base (6ad9cac) to head (095bd6d).
Report is 954 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54143         +/-   ##
=================================================
- Coverage   72.8813%   57.4228%   -15.4586%     
=================================================
  Files          1519       1668        +149     
  Lines        434852     619240     +184388     
=================================================
+ Hits         316926     355585      +38659     
- Misses        98376     239613     +141237     
- Partials      19550      24042       +4492     
Flag Coverage Δ
integration 40.0209% <69.6428%> (?)
unit 72.3601% <69.6428%> (+0.4869%) ⬆️

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

Components Coverage Δ
dumpling 52.9656% <ø> (ø)
parser ∅ <ø> (∅)
br 63.4881% <ø> (+17.3324%) ⬆️

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 21, 2024
Copy link
Contributor

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

pkg/ddl/backfilling.go Outdated Show resolved Hide resolved
pkg/ddl/backfilling.go Show resolved Hide resolved
Copy link
Contributor

@zimulala zimulala 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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 24, 2024
Copy link

ti-chi-bot bot commented Jun 24, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-21 08:42:10.430535516 +0000 UTC m=+363456.916024340: ☑️ agreed by wjhuang2016.
  • 2024-06-24 02:51:36.001170936 +0000 UTC m=+601622.486659783: ☑️ agreed by zimulala.

Copy link

ti-chi-bot bot commented Jun 24, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wjhuang2016, zimulala

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

/retest

Copy link

tiprow bot commented Jun 24, 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.

@ti-chi-bot ti-chi-bot bot merged commit eec20e6 into pingcap:master Jun 24, 2024
21 checks passed
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. label Jul 30, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #55073.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jul 30, 2024
ti-chi-bot bot pushed a commit that referenced this pull request Aug 5, 2024
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label Oct 21, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #56748.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. 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.
Projects
None yet
5 participants