Skip to content

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

Merged
sgotti merged 1 commit into
sorintlab:masterfrom
sgotti:fix_reported_vs_spec_syncstandbys_check
May 29, 2018
Merged

sentinel: fix check for same reported vs spec sync standbys#494
sgotti merged 1 commit into
sorintlab:masterfrom
sgotti:fix_reported_vs_spec_syncstandbys_check

Conversation

@sgotti

@sgotti sgotti commented May 28, 2018

Copy link
Copy Markdown
Member

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.

Comment thread pkg/util/slice_test.go
{[]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
Copy Markdown
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
Copy Markdown
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

nh2 commented May 28, 2018

Copy link
Copy Markdown
Contributor

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