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

sentinel: fix check for same reported vs spec sync standbys #494

Merged

Conversation

sgotti
Copy link
Member

@sgotti sgotti commented May 28, 2018

When electing a new master we are swapping the new master uid with the old
master uid in the syncstandbys slice. This could end with an unordered slice in
the spec that will make the sentinel fail the check that the reported standbys
are the same of the spec one blocking any future syncstandby update.

Since the reported order is not a problem just check that the syncstandbys are
the same regardless of their order.

We'll keep the sorting to avoid unneeded updates to synchronous_standby_names by
the keeper.

{[]string{"a", "b", "c"}, []string{"a", "b", "c"}, true},
{[]string{"a", "b", "c"}, []string{"b", "c", "a"}, true},
{[]string{"a", "b", "c", "a"}, []string{"a", "c", "b", "b"}, false},
{[]string{"a", "b", "c", "a"}, []string{"a", "c", "b", "b"}, false},
Copy link
Contributor

Choose a reason for hiding this comment

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

May want to add some cases where the two slices have different length to get coverage of the if len(a) != len(b) { return false } bit (which is what makes it correct e.g. for {abc, abcd, false}).

Copy link
Member Author

Choose a reason for hiding this comment

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

It's covered by the second test (the one with empty strings) but I'll add a more explicit test with non empty strings to make it clear.

@nh2
Copy link
Contributor

nh2 commented May 28, 2018

That's great, thanks!

When electing a new master we are swapping the new master uid with the old
master uid in the syncstandbys slice. This could end with an unordered slice in
the spec that will make the sentinel fail the check that the reported standbys
are the same of the spec one blocking any future syncstandby update.

Since the reported order is not a problem just check that the syncstandbys are
the same regardless of their order.

We'll keep the sorting to avoid unneeded updates to synchronous_standby_names by
the keeper.
@sgotti sgotti force-pushed the fix_reported_vs_spec_syncstandbys_check branch from b3992d0 to be61e2c Compare May 29, 2018 07:26
@sgotti sgotti merged commit be61e2c into sorintlab:master May 29, 2018
sgotti added a commit that referenced this pull request May 29, 2018
…_check

sentinel: fix check for same reported vs spec sync standbys
@sgotti sgotti added this to the v0.11.0 milestone Jun 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants