Skip to content

Commit

Permalink
placement: quorum number done right (#31188)
Browse files Browse the repository at this point in the history
close #31186
  • Loading branch information
xhebox authored Dec 30, 2021
1 parent f40bfa1 commit 1cc0b51
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ddl/placement/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func NewBundleFromSugarOptions(options *model.PlacementSettings) (*Bundle, error
primaryCount = uint64(math.Ceil(float64(followers+1) / float64(len(regions))))
case "majority_in_primary":
// calculate how many replicas need to be in the primary region for quorum
primaryCount = uint64(math.Ceil(float64(followers+1)/2 + 1))
primaryCount = (followers+1)/2 + 1
default:
return nil, fmt.Errorf("%w: unsupported schedule %s", ErrInvalidPlacementOptions, schedule)
}
Expand Down
4 changes: 2 additions & 2 deletions ddl/placement/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,11 @@ func (s *testBundleSuite) TestNewBundleFromOptions(c *C) {
input: &model.PlacementSettings{
PrimaryRegion: "sh",
Regions: "bj,sh",
Followers: 5,
Followers: 4,
Schedule: "majority_in_primary",
},
output: []*Rule{
NewRule(Voter, 4, NewConstraintsDirect(
NewRule(Voter, 3, NewConstraintsDirect(
NewConstraintDirect("region", In, "sh"),
)),
NewRule(Follower, 2, NewConstraintsDirect(
Expand Down

0 comments on commit 1cc0b51

Please sign in to comment.