Обсуждение: pg_rewind: confused about recovery.conf/restore_command
Pg 9.6.6 on Ubuntu. I have a master and a streamer/standby. Streamer runs wal_log_hints=on, archive_mode=always, archive_command='send it to some repo'. Promote streamer and make some changes to it. Halt and run pg_rewind as per my understanding of the docs. Rewind immediately errors out due to missing wal segments on target system (streamer). Same target has a recovery.conf at this point w/restore_command that knows how to fetch wal segment from 'some repo'. ISTM rewind is supposed to use it to fetch wals. Success in same attempt if streamer has archive_command='' thus retaining wals inside data directory. Running pg_rewind with --progress --debug shows no indication that it's trying to use restore command and in fact chmod 0 on the recovery.conf file makes no difference either. Am I dreaming that this should work? :-) Thanks -- Jerry Sievers Postgres DBA/Development Consulting e: postgres.consulting@comcast.net p: 312.241.7800
Hi Jerry,
That has been my experience as well; pg_rewind does not fetch the WAL files.
You can use following parameter to keep the most recent logs; i.e. a couple of hours worth. That will allow pg_rewind to work during that time frame — If it is still missing a WAL file or two you can manually copy them over in a pinch.
wal_keep_segments
p.s. I switched to using ZFS snapshots instead.
Rui DeSousa <rui.desousa@icloud.com> writes: > Hi Jerry, > > That has been my experience as well; pg_rewind does not fetch the WAL > files. Hmmm, just prior to my email here last night was my 2nd attempt, taking a few hours of r/d time to eventually conclude that I was misunderstanding the docs :-) A few mentions of recovery.conf in the docs themselves plus what I found searching Google certainly left me with the impression that pg_rewind itself knows how to try using a restore_command if found in a recovery.conf file of the target system to fetch WALs. > You can use following parameter to keep the most recent logs; i.e. a > couple of hours worth. That will allow pg_rewind to work during that Yup this is obvious and I tested same with OK results. > time frame — If it is still missing a WAL file or two you can > manually copy them over in a pinch. Yes and in fact I used my restore_command to do so. > > wal_keep_segments > > > p.s. I switched to using ZFS snapshots instead. Oh, my site is quite familiar with FS or SAN/array snapshots and we use them all the time. Just felt like pg_rewind looked like something we should try. I'll wait to see if others can shed more light on this. Thanks > > -- Jerry Sievers Postgres DBA/Development Consulting e: postgres.consulting@comcast.net p: 312.241.7800