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

Updated synchronous_standby_names to be correct #300

Merged
merged 2 commits into from
Apr 27, 2018

Conversation

gclough
Copy link
Collaborator

@gclough gclough commented Mar 12, 2018

Fixes #269

Updated synchronous_standby_names to be correct, even when {{ postgresql_synchronous_standby_num_sync }} isn't specified.

https://www.postgresql.org/docs/9.6/static/runtime-config-replication.html

This parameter specifies a list of standby servers using either of the following syntaxes:

num_sync ( standby_name [, ...] )
standby_name [, ...]

@gclough
Copy link
Collaborator Author

gclough commented Mar 12, 2018

How do I resubmit this to Travis... as it seems to have failed on their end?

@gclough gclough force-pushed the sync_standby_v9.6_syntax branch from 2b538dc to 3ff3868 Compare April 4, 2018 16:02
@gclough
Copy link
Collaborator Author

gclough commented Apr 4, 2018

@WolfgangPecho , can you verify this update is correct for v10. I'm pretty sure it is, as I've test it and it matches the doco.

@@ -251,7 +251,7 @@ track_commit_timestamp = {{'on' if postgresql_track_commit_timestamp else 'off'

# These settings are ignored on a standby server.

synchronous_standby_names = '{{postgresql_synchronous_standby_num_sync}}{% if postgresql_synchronous_standby_names != [] %} ({{postgresql_synchronous_standby_names|join(',')}}){% endif %}' # standby servers that provide sync rep
synchronous_standby_names = '{% if postgresql_synchronous_standby_names != [] %}{% if postgresql_synchronous_standby_choose_sync != "" and postgresql_synchronous_standby_num_sync != "" %}{{ postgresql_synchronous_standby_choose_sync }} {% endif %}{% if postgresql_synchronous_standby_num_sync != "" %}{{ postgresql_synchronous_standby_num_sync }} ({% endif %}{{ postgresql_synchronous_standby_names | join(',') }}{% if postgresql_synchronous_standby_num_sync != "" %}){% endif %}{% endif %}' # standby servers that provide sync rep
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@@ -244,7 +244,7 @@ track_commit_timestamp = {{'on' if postgresql_track_commit_timestamp else 'off'

# These settings are ignored on a standby server.

synchronous_standby_names = '{{postgresql_synchronous_standby_num_sync}}{% if postgresql_synchronous_standby_names != [] %} ({{postgresql_synchronous_standby_names|join(',')}}){% endif %}' # standby servers that provide sync rep
synchronous_standby_names = '{% if postgresql_synchronous_standby_names != [] %}{% if postgresql_synchronous_standby_num_sync != "" %}{{ postgresql_synchronous_standby_num_sync }} ({% endif %}{{ postgresql_synchronous_standby_names | join(',') }}{% if postgresql_synchronous_standby_num_sync != "" %}){% endif %}{% endif %}' # standby servers that provide sync rep
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the v9.6 syntax... which is different from anything <= 9.5, but is also different from v10. It's unique, and only for this one version of PostgreSQL.

https://www.postgresql.org/docs/9.6/static/runtime-config-replication.html#GUC-SYNCHRONOUS-STANDBY-NAMES

@@ -297,7 +297,8 @@ postgresql_track_commit_timestamp: off # (>= 9.5)

# standby servers that provide sync rep.
# number of sync standbys (>= 9.6) and comma-separated list of application_name from standby(s)
postgresql_synchronous_standby_num_sync: ""
postgresql_synchronous_standby_choose_sync: "FIRST" #>= 10
postgresql_synchronous_standby_num_sync: "" # >= 9.6
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

New parameters required for v9.6, and v10

@WolfgangPecho
Copy link
Contributor

WolfgangPecho commented Apr 5, 2018

@gclough I am a bit busy at work and a bit late here ;-).
I have fetched your commit 1e5f77b #300 and ran tests/playbook.yml with vagrant for

  • centos-7
  • centos-6
  • ubuntu-16.04
  • ubuntu-14.04

All passed.
For posgresql 10. And debian-9 passed too.

@gclough
Copy link
Collaborator Author

gclough commented Apr 6, 2018

That's great, thanks @WolfgangPecho . Hopefully this will be verified and merged soon, as the sync standby handling is one of the good features in v9.6 and v10.

@gclough gclough force-pushed the sync_standby_v9.6_syntax branch 2 times, most recently from e8db5ab to 39b9d5b Compare April 10, 2018 17:15
@gclough
Copy link
Collaborator Author

gclough commented Apr 11, 2018

I've done some testing, to merge in the "quoted" hostnames, as raised in #337:

Using PostgreSQL v9.3, and two sync standby's:
--extra-vars='{"postgresql_version":9.3, "postgresql_synchronous_standby_choose_sync":"ANY", "postgresql_synchronous_standby_num_sync": 1, "postgresql_synchronous_standby_names":["server1","server2"]}'

Gives:
synchronous_standby_names = '"server1","server2"' # standby servers that provide sync rep

v9.3, No sync:
--extra-vars='{"postgresql_version":9.3, "postgresql_synchronous_standby_choose_sync":"ANY", "postgresql_synchronous_standby_num_sync": 1, "postgresql_synchronous_standby_names":[]}'

Gives:

synchronous_standby_names = '' # standby servers that provide sync rep

v9.6, two sync:
--extra-vars='{"postgresql_version":9.6, "postgresql_synchronous_standby_choose_sync":"ANY", "postgresql_synchronous_standby_num_sync": 1, "postgresql_synchronous_standby_names":["server1","server2"]}'

Gives:
synchronous_standby_names = '1 ("server1","server2")' # standby servers that provide sync rep

v9.6, no sync:
--extra-vars='{"postgresql_version":9.6, "postgresql_synchronous_standby_choose_sync":"ANY", "postgresql_synchronous_standby_num_sync": 1, "postgresql_synchronous_standby_names":[]}'

Gives:
synchronous_standby_names = '' # standby servers that provide sync rep

v10, two sync:
--extra-vars='{"postgresql_version":10, "postgresql_synchronous_standby_choose_sync":"ANY", "postgresql_synchronous_standby_num_sync": 1, "postgresql_synchronous_standby_names":["server1","server2"]}'

Gives:
synchronous_standby_names = 'ANY 1 ("server1","server2")' # standby servers that provide sync rep

v10, No sync:
--extra-vars='{"postgresql_version":10, "postgresql_synchronous_standby_choose_sync":"ANY", "postgresql_synchronous_standby_num_sync": 1, "postgresql_synchronous_standby_names":[]}'

Gives:
synchronous_standby_names = '' # standby servers that provide sync rep

@gclough gclough force-pushed the sync_standby_v9.6_syntax branch from ef19c02 to 5d4fa50 Compare April 11, 2018 10:57
@gclough
Copy link
Collaborator Author

gclough commented Apr 11, 2018

@jlozadad ... I merged in a fix from #338 by @hakoerber ... but I'm not sure how to give attribution? If you could help I'd appreciate it.

@aoyawale
Copy link
Contributor

no idea either. you can remove the commit if you want.

@hakoerber
Copy link

It's fine. Just wanted to tell you that I think unusual to incorporate fixes from other people's merge requests into your commits.

Anyway, the merge request looks good to me apart from two small issues:

We need documentation about postgresql_synchronous_standby_num_sync and postgresql_synchronous_standby_choose_sync, because their behaviour changed. I order to retain the same functionality, I had to change

postgresql_synchronous_standby_num_sync: "ANY 1"

to

postgresql_synchronous_standby_num_sync: "1"
postgresql_synchronous_standby_choose_sync: "ANY"

I like the second way much better, it just has to be documented properly I think.

Secondly, the diff is now quite huge due to the merge commit. When I do a

git diff upstream/master gclough/sync_standby_v9.6_syntax

I get a much nicer patch. Maybe it is a good idea to make completely new commits with this patch and commit them?

@gclough
Copy link
Collaborator Author

gclough commented Apr 12, 2018

Secondly, the diff is now quite huge due to the merge commit. When I do a
git diff upstream/master gclough/sync_standby_v9.6_syntax
I get a much nicer patch. Maybe it is a good idea to make completely new commits with this patch and commit them?

Good idea. I’m still quite new to GIT and have a little trouble squashing commits. Would you like to do that, and commit it back? That way it will retain the credit that we both worked on this, right?

I see what you're saying about the backwards compatibility... but as the v10 merge was only pushed 14 days ago, is it a big issue? Would you prefer to see it documented in the defaults/main.yml, or somewhere else?

@gclough gclough force-pushed the sync_standby_v9.6_syntax branch 2 times, most recently from f7852b0 to 81c74df Compare April 12, 2018 14:24
@gclough
Copy link
Collaborator Author

gclough commented Apr 12, 2018

@hakoerber ... I'm not sure why, but my local "master" is a bit goofy. I've got a lot of PR's in progress, otherwise I'd blow it away and start again. :o(

I think I've pared it down to a minimal commit, and whenever I try to squash those commits into one then it fails the auto-merge. If this isn't right, then please squash them and re-commit it under your account, as this will tag your username in this PR too, right?

@gclough gclough force-pushed the sync_standby_v9.6_syntax branch from ccb1bf6 to ed90cd1 Compare April 12, 2018 14:53
@UnderGreen
Copy link
Contributor

@gclough is the PR ready for merge?

@gclough
Copy link
Collaborator Author

gclough commented Apr 27, 2018

Yes, I believe so. This allows the v10 syntax to be used without a kludge.

Is there any way to attribute @hakoerber too, as he contributed to this via #338?

@UnderGreen UnderGreen merged commit d0cc433 into ANXS:master Apr 27, 2018
@gclough gclough deleted the sync_standby_v9.6_syntax branch April 27, 2018 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants