Skip to content

ddl: fix placement rules compatibility with tiflash#22065

Merged
ti-srebot merged 11 commits intopingcap:masterfrom
xhebox:master
Jan 12, 2021
Merged

ddl: fix placement rules compatibility with tiflash#22065
ti-srebot merged 11 commits intopingcap:masterfrom
xhebox:master

Conversation

@xhebox
Copy link
Contributor

@xhebox xhebox commented Dec 29, 2020

What problem does this PR solve?

Issue: close #22171

Problem Summary: When PD scheduels a partition to tiflash, TiFlash will validate the keyrange if there is a _r suffix. Using GenTableRecordPrefix instead of GenTablePrefix can fix this problem.

But placement rules are not compatible with the old set tiflash replica syntax, so the second commit simply forbids using +engine=tiflash, and will add -engine=tiflash to every rule to avoid scheduels to tiflash instance. Maybe that will be reverted in the future.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
set global tidb_enable_alter_placement=on;
drop table if exists test.t1;
create table test.t1 (a int) partition by hash(a) partitions 2;
alter table test.t1 alter partition p1 alter placement policy CONSTRAINTS='["+engine=tiflash"]' ROLE=follower REPLICAS=1;
(8234, 'Invalid placement policy \'alter placement policy constraints=\'["+engine=tiflash"]\' role=follower replicas=1\': unsupported label constraint \'+engine=tiflash\'')

Release note

  • Forbid adding tiflash replica by placement rules in SQL

@xhebox xhebox marked this pull request as draft December 29, 2020 06:26
@xhebox xhebox marked this pull request as ready for review December 29, 2020 06:30
Copy link
Contributor

@djshow832 djshow832 left a comment

Choose a reason for hiding this comment

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

Add some cases to placement_sql_test.go to test if the placement rules generated by SQL are right in these scenarios:

  1. Whether the placement rules all contain "-engine=tiflash".
  2. When the user also defines "-engine=tiflash", the placement rules should only contain one "-engine=tiflash" constraint.
  3. CONSTRAINTS='{"+zone=bj":1}' REPLICAS=2, the extra count should also contain "-engine=tiflash" constraint. (Maybe?)

@xhebox
Copy link
Contributor Author

xhebox commented Dec 30, 2020

Add some cases to placement_sql_test.go to test if the placement rules generated by SQL are right in these scenarios.

@djshow832 I can not add tests in placement_sql_test.go. Mock test wont update rule cache. Putting it into placement_rule_test.go needs too many modifications(and can not cover the test of 3). I would like to leave it to automated-test.

Or maybe manual test in patition_test.go?

Copy link
Contributor

@djshow832 djshow832 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-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 31, 2020
Copy link
Member

@wjhuang2016 wjhuang2016 left a comment

Choose a reason for hiding this comment

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

Please create an issue for this problem.

Copy link
Member

@wjhuang2016 wjhuang2016 left a comment

Choose a reason for hiding this comment

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

The first commit fixed that. It is not convenient for a reviewer to find your first commit.
You can write: "Using GenTableRecordPrefix instead of GenTablePrefix can fix this problem."
Besides, is there any test for this change?

@xhebox
Copy link
Contributor Author

xhebox commented Jan 5, 2021

@wjhuang2016 I will try if TestDDLCallback can test it. The problem is that rule cache will not refresh without a working PD. I can not check the result after executing placement rules SQL DDL jobs.

@wjhuang2016
Copy link
Member

@wjhuang2016 I will try if TestDDLCallback can test it. The problem is that rule cache will not refresh without a working PD.

You can do a manual test. Start a cluster to test it.

@xhebox
Copy link
Contributor Author

xhebox commented Jan 5, 2021

You can do a manual test. Start a cluster to test it

A manual test is already done, of course.

xhebox added 10 commits January 12, 2021 17:31
TiFlash will compare the the record prefix too.

Signed-off-by: xhe <xw897002528@gmail.com>
Though the previous commit fixed the compatibility between tiflash and
placement rules. But it is still not caompatible with the old `set
tiflash replica` syntax. Thus this commit banned the usage and avoid
using tiflash by appending a hidden label to filter tiflash instance.

Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Copy link
Member

@wjhuang2016 wjhuang2016 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-srebot ti-srebot removed the status/LGT1 Indicates that a PR has LGTM 1. label Jan 12, 2021
@ti-srebot ti-srebot added the status/LGT2 Indicates that a PR has LGTM 2. label Jan 12, 2021
@wjhuang2016
Copy link
Member

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Jan 12, 2021
@ti-srebot
Copy link
Contributor

/run-all-tests

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/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ddl: placement rules in SQL is not compatible with TiFlash

4 participants