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 alter table exchange partition does not work if table has tiflash replica #17940

Merged
merged 97 commits into from
Jun 28, 2020
Merged

Conversation

zhaox1n
Copy link
Contributor

@zhaox1n zhaox1n commented Jun 11, 2020

What problem does this PR solve?

Issue Number: close ##17918

Problem Summary:

We need to compare tiflash replica information and reset the tiflash replica status when exchanging partition.

Check List

Tests

  • Unit test

Side effects

Release note

  • No release note

@codecov
Copy link

codecov bot commented Jun 15, 2020

Codecov Report

Merging #17940 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #17940   +/-   ##
===========================================
  Coverage   79.5854%   79.5854%           
===========================================
  Files           535        535           
  Lines        144578     144578           
===========================================
  Hits         115063     115063           
  Misses        20276      20276           
  Partials       9239       9239           

@@ -2844,14 +2844,37 @@ func checkFieldTypeCompatible(ft *types.FieldType, other *types.FieldType) bool
return true
}

func checkTiFlashReplicaCompatible(source *model.TiFlashReplicaInfo, target *model.TiFlashReplicaInfo) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

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

ddl/partition.go Outdated
@@ -812,6 +812,19 @@ func (w *worker) onExchangeTablePartition(d *ddlCtx, t *meta.Meta, job *model.Jo
// exchange table meta id
partDef.ID = nt.ID

// Clear the tiflash replica available status.
if pt.TiFlashReplica != nil {
pt.TiFlashReplica.Available = false
Copy link
Contributor

Choose a reason for hiding this comment

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

why set Available to false? I think if exchange partition is allowed, the TiFlash replica status of both table are always the same(both available or both not available), it is not necessary to reset the TiFlash replica status to false if they are already available.

Copy link
Contributor

Choose a reason for hiding this comment

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

One more question: is it possible that the available flag is changed between checkTiFlashReplicaCompatible and onExchangeTablePartition , if yes, then we need handle it more carefully.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I get that It seem that tiflash now doesnot support exchange partition in slack. So I just reset false like truncate partition. I would delete the code about changing tiflash status.

Copy link
Contributor

Choose a reason for hiding this comment

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

TiFlash does not support exchange partition when #17149 is merged, and it has supported now, so you can safely delete related code, but take care of my last question, if available flag is changed, we need to handle the status carefully for both partition table and non-partition table.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hava a question about how to change a available status when a exchange partition happening ? It seems that only one worker handle ddl events.

Copy link
Contributor

Choose a reason for hiding this comment

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

I hava a question about how to change a available status when a exchange partition happening ? It seems that only one worker handle ddl events.

I'm not very familiar with TiDB, if available status can not be changed during exchange partition, then just ignore my question.

ddl/partition.go Outdated
@@ -812,6 +812,17 @@ func (w *worker) onExchangeTablePartition(d *ddlCtx, t *meta.Meta, job *model.Jo
// exchange table meta id
partDef.ID = nt.ID

// Clear the tiflash replica available status.
Copy link
Contributor

Choose a reason for hiding this comment

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

should remove this comment since the code no longer clear the tiflash replica available status

ddl/partition.go Outdated
@@ -812,6 +812,17 @@ func (w *worker) onExchangeTablePartition(d *ddlCtx, t *meta.Meta, job *model.Jo
// exchange table meta id
partDef.ID = nt.ID

// Clear the tiflash replica available status.
if pt.TiFlashReplica != nil {
// Set partition replica become unavailable.
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

@zhaox1n zhaox1n Jun 28, 2020

Choose a reason for hiding this comment

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

Done PTAL

@zhaox1n
Copy link
Contributor Author

zhaox1n commented Jun 28, 2020

/run-unit-test

@windtalker
Copy link
Contributor

LGTM

@ti-srebot
Copy link
Contributor

@windtalker, Thanks for your review, however we are sorry that your vote won't be count. You are not a reviewer or committer or co-leader or leader for the related sigs:ddl(slack).

@zimulala zimulala added the status/can-merge Indicates a PR has been approved by a committer. label Jun 28, 2020
@ti-srebot
Copy link
Contributor

@zimulala,Thanks for you review.

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit 59cb7e1 into pingcap:master Jun 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution This PR is from a community contributor. sig/sql-infra SIG: SQL Infra status/can-merge Indicates a PR has been approved by a committer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants