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: set correct startHandle when add indices meets some errors #6897

Merged
merged 7 commits into from
Jun 25, 2018
Merged

ddl: set correct startHandle when add indices meets some errors #6897

merged 7 commits into from
Jun 25, 2018

Conversation

winkyao
Copy link
Contributor

@winkyao winkyao commented Jun 25, 2018

Thank you for working on TiDB! Please read TiDB's CONTRIBUTING document BEFORE filing this PR.

What have you changed? (mandatory)

Before this PR, we will fail the added gofail test.

When we encounter an error, we will update incorrect handle to the DDL job. Then we will never backfill the skipped indices range, cause admin check table failed.

What are the type of the changes (mandatory)?

  • Bug fix (non-breaking change which fixes an issue)

How has this PR been tested (mandatory)?

Unit test.

@zimulala @crazycs520 @ciscoxll PTAL

ddl/index.go Outdated

batchTasks = append(batchTasks, task)
if len(batchTasks) >= len(workers) || i == (len(kvRanges)-1) {
// Wait tasks finish.
err = w.handleReorgTasks(startTime, startHandle, reorgInfo, &totalAddedCount, workers, batchTasks)
err = w.handleReorgTasks(startTime, firstHandle, reorgInfo, &totalAddedCount, workers, batchTasks)
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the firstHandle argument is redundant.
You can always get it from batchTasks[0].start, right?

ddl/index.go Outdated
@@ -687,6 +689,14 @@ func (w *addIndexWorker) run(d *ddlCtx) {
}

log.Debug("[ddl-reorg] got backfill index task:#v", task)

if task.mockTask {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not gofail here directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is in a multi-thread environment, so it's non-trivial to control the gofail run only once.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use addIndexWorker's offset to control this error run only once? Then we can use gofail here, and remove the variables in handleReorgTasks.

Copy link
Member

Choose a reason for hiding this comment

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

@winkyao
I think it worth it to gofail here directly.
We can check the worker id to avoid race.

@winkyao
Copy link
Contributor Author

winkyao commented Jun 25, 2018

@tiancaiamao PTAL

@tiancaiamao
Copy link
Contributor

LGTM

@tiancaiamao tiancaiamao added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 25, 2018
Copy link
Contributor

@ciscoxll ciscoxll left a comment

Choose a reason for hiding this comment

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

LGTM

@ciscoxll ciscoxll added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jun 25, 2018
@winkyao
Copy link
Contributor Author

winkyao commented Jun 25, 2018

/run-all-tests

ddl/index.go Outdated
for i, task := range batchTasks {
// gofail: var mockAddIndexErr bool
// if mockAddIndexErr && !gofailMockAddindexErrOnceGuard {
Copy link
Member

Choose a reason for hiding this comment

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

gofailMockAddindexErrOnceGuard is too long.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To avoid name conflicts.

@winkyao
Copy link
Contributor Author

winkyao commented Jun 25, 2018

@zimulala @coocood PTAL

@coocood
Copy link
Member

coocood commented Jun 25, 2018

LGTM

@coocood coocood added status/LGT3 The PR has already had 3 LGTM. and removed status/LGT2 Indicates that a PR has LGTM 2. labels Jun 25, 2018
@crazycs520
Copy link
Contributor

LGTM

@winkyao winkyao merged commit dd82195 into pingcap:master Jun 25, 2018
@winkyao winkyao deleted the fix_start_handle branch June 25, 2018 11:36
@you06 you06 added the sig/sql-infra SIG: SQL Infra label Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/sql-infra SIG: SQL Infra status/LGT3 The PR has already had 3 LGTM. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants