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: fix dist ddl reorg table range endKey #45679

Merged
merged 14 commits into from
Aug 7, 2023

Conversation

jiyfhust
Copy link
Contributor

@jiyfhust jiyfhust commented Jul 30, 2023

What problem does this PR solve?

Issue Number: close #45652
Problem Summary:

What is changed and how it works?

As the issue describe:

function getTableRange:
https://github.com/pingcap/tidb/blob/cf7ae4c3b917f81e43cbb2beab44abf841af52cc/ddl/reorg.go#L669C2-L669C2
return [startHandleKey, endHandleKey];
the reorg will use the range above to backfill index data.

Then splitTableRanges will split [startHandleKey, endHandleKey] into small ranges.
https://github.com/pingcap/tidb/blob/cf7ae4c3b917f81e43cbb2beab44abf841af52cc/ddl/scheduler.go#L267C8-L267C8
the small ranges is like [a, b], [b.next, c],[c.next, d].

here use a function getRangeEndKey:
https://github.com/pingcap/tidb/blob/cf7ae4c3b917f81e43cbb2beab44abf841af52cc/ddl/backfilling.go#L562C17-L562C17
change small ranges to [a, b.next), [b.next, c.next), [c.next, d.next).
and it use a "endInclude" to mark case when it is [c.next d].

This pr:

  1. fix the getTableRange, return [startHandleKey, endHandleKey.next)
  2. split rangs into [a, b.next), [b.next, c.next), [c.next, d.next)
  3. don't use getRangeEndKey to change the endKey
  4. remove "endInclude"

Check List

Tests

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

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/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Jul 30, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jul 30, 2023

Hi @jiyfhust. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@tiprow
Copy link

tiprow bot commented Jul 30, 2023

Hi @jiyfhust. 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.

@hawkingrei
Copy link
Member

/ok-to-test

@ti-chi-bot ti-chi-bot bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Jul 31, 2023
@codecov
Copy link

codecov bot commented Jul 31, 2023

Codecov Report

Merging #45679 (11a54e3) into master (e3b95fb) will increase coverage by 0.0045%.
The diff coverage is 85.7142%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #45679        +/-   ##
================================================
+ Coverage   73.3543%   73.3589%   +0.0045%     
================================================
  Files          1272       1275         +3     
  Lines        393070     393723       +653     
================================================
+ Hits         288334     288831       +497     
- Misses        86358      86483       +125     
- Partials      18378      18409        +31     
Flag Coverage Δ
integration 78.1388% <ø> (?)
unit 73.3507% <85.7142%> (-0.0037%) ⬇️

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

Components Coverage Δ
dumpling 54.0444% <ø> (ø)
parser 85.0359% <ø> (ø)
br 52.0258% <ø> (-0.0209%) ⬇️

@jiyfhust
Copy link
Contributor Author

/cc @Defined2014 @zimulala

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.

Could you briefly describe the fix in the PR description?

@ti-chi-bot ti-chi-bot bot requested a review from zimulala August 1, 2023 07:15
@jiyfhust
Copy link
Contributor Author

jiyfhust commented Aug 1, 2023

Could you briefly describe the fix in the PR description?

/cc @zimulala

ddl/backfilling.go Outdated Show resolved Hide resolved
@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 Aug 2, 2023
@jiyfhust
Copy link
Contributor Author

jiyfhust commented Aug 2, 2023

/test unit-test

@tiprow
Copy link

tiprow bot commented Aug 2, 2023

@jiyfhust: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test tiprow_fast_test

Use /test all to run all jobs.

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

@jiyfhust jiyfhust requested a review from tangenta August 2, 2023 12:55
@jiyfhust
Copy link
Contributor Author

jiyfhust commented Aug 3, 2023

Sorry, just ignore it.

The code annotation mislead me.
https://github.com/tikv/client-go/blob/cbfd64018c2194af29694547bfcad1972cb24512/internal/locate/region_cache.go#L993

// LoadRegionsInKeyRange lists regions in [start_key,end_key].
func (c *RegionCache) LoadRegionsInKeyRange(bo *retry.Backoffer, startKey, endKey []byte) (regions []*Region, err error) {
	var batchRegions []*Region
	for {
		batchRegions, err = c.Bat
....
....

it is not [start_key,end_key], but actually [start_key,end_key),so it is not a "tikv/client-go" bug which i said regionCache above.

There is no problems now.

@purelind
Copy link
Contributor

purelind commented Aug 3, 2023

/retest

@tangenta
Copy link
Contributor

tangenta commented Aug 4, 2023

I just found that index ID is not included :(

t.IndexPrefix() is the key like t[tableID]_i. If we use t.IndexPrefix().PrefixNext() here, endKey will be t[tableID]_j?

As a result, we will scan the index records from all indexes.

@jiyfhust Let me fix this issue in another PR, which will include some tests. Could you revert 47f36bd? Rest LGTM.

@jiyfhust
Copy link
Contributor Author

jiyfhust commented Aug 4, 2023

@jiyfhust Let me fix this issue in another PR, which will include some tests. Could you revert 47f36bd? Rest LGTM.

@tangenta done.

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 4, 2023
@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 6, 2023
@jiyfhust
Copy link
Contributor Author

jiyfhust commented Aug 6, 2023

/retest-required

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
Copy link

ti-chi-bot bot commented Aug 7, 2023

[APPROVALNOTIFIER] This PR is APPROVED

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

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 7, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Aug 7, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-08-07 05:52:56.874414952 +0000 UTC m=+683060.816763482: ☑️ agreed by tangenta.
  • 2023-08-07 06:54:01.99353469 +0000 UTC m=+686725.935883221: ☑️ agreed by zimulala.

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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to create index with distribute framework after import data via lightning
5 participants