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

placement: supports follower role with evict-leader hint #47307

Merged
merged 2 commits into from
Oct 9, 2023

Conversation

nolouch
Copy link
Member

@nolouch nolouch commented Sep 26, 2023

What problem does this PR solve?

Issue Number: close #46304

Problem Summary:

Currently, all FOLLOWER_CONSTRAINTS will set the role in the rule to be voter. It can cover major scenarios and reduce the user's burden. but in some scenarios cannot cover, like:

there are three az, zone1, zone2, zone3. the user wants the replicas in zone 1 and zone 2 can be the leader, and normal situations, the leader should be placed in zone 1, if zone 1 is gone, the leader is better in zone 2. and zone3 reject be the leader, zone 3 can be seen as a backup zone, it's not used to serve.

maybe we can enhance the FOLLOWER_CONSTRAINTS, like

add attribute
Dictionary:  e.g. {"+region=us-east": 2, "+region=us-west,#evict-leader": 1}

#evict-leader explains voters should be followers, and reject becoming leaders.

full SQL will like this:

CREATE PLACEMENT POLICY `mydeploy`  LEADER_CONSTRAINTS='{"+region=us-east-1": 1}' FOLLOWER_CONSTRAINTS='{"+region=us-east-1": 1,  "+region=use-east-2":2, "+region=us-west,#evict-leader": 1};

alternative plan

warn: this is the current easy way to achieve this issue scenario. we would be supported leader_preferences in the future to define the leader choice priority.

What is changed and how it works?

add new keywords.

Check List

Tests

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

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. labels Sep 26, 2023
@nolouch nolouch force-pushed the placement-reject-leader branch from e332dec to 2c38ba7 Compare September 26, 2023 17:51
@nolouch
Copy link
Member Author

nolouch commented Sep 27, 2023

/retest-required

@codecov
Copy link

codecov bot commented Sep 27, 2023

Codecov Report

Merging #47307 (f6a1f59) into master (4cc6c18) will increase coverage by 0.0541%.
Report is 71 commits behind head on master.
The diff coverage is 100.0000%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #47307        +/-   ##
================================================
+ Coverage   72.9347%   72.9888%   +0.0541%     
================================================
  Files          1340       1373        +33     
  Lines        400476     409956      +9480     
================================================
+ Hits         292086     299222      +7136     
- Misses        89447      91903      +2456     
+ Partials      18943      18831       -112     
Flag Coverage Δ
integration 39.5136% <0.0000%> (?)
unit 72.6237% <100.0000%> (-0.3110%) ⬇️

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

Components Coverage Δ
dumpling 53.9913% <ø> (ø)
parser 84.7651% <ø> (-0.1581%) ⬇️
br 49.5258% <ø> (-3.5594%) ⬇️

@nolouch
Copy link
Member Author

nolouch commented Sep 27, 2023

/retest-required

ddl/placement/rule.go Outdated Show resolved Hide resolved
Signed-off-by: nolouch <[email protected]>
@nolouch nolouch force-pushed the placement-reject-leader branch from 76f5e42 to f6a1f59 Compare September 28, 2023 06:40
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 28, 2023
@nolouch
Copy link
Member Author

nolouch commented Oct 7, 2023

PTAL @CabinfeverB

Copy link
Member

@rleungx rleungx left a comment

Choose a reason for hiding this comment

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

LGTM, but I was wondering if the user uses # as part of the label, it may have a problem. It's better to add the notice in the doc.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 9, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rleungx, xhebox

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 Oct 9, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 9, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-09-28 06:43:34.556889105 +0000 UTC m=+84212.143999250: ☑️ agreed by xhebox.
  • 2023-10-09 04:20:40.557003946 +0000 UTC m=+1026038.144114091: ☑️ agreed by rleungx.

@ti-chi-bot ti-chi-bot bot merged commit 19e6638 into pingcap:master Oct 9, 2023
@nolouch nolouch deleted the placement-reject-leader branch October 9, 2023 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Placement rule supports set follower strict
3 participants