Re: pg_stop_backup(wait_for_archive := true) on standby server
Masahiko Sawada <sawada.mshk@gmail.com>
From: Masahiko Sawada <sawada.mshk@gmail.com>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: Stephen Frost <sfrost@snowman.net>,
Peter Eisentraut <peter.eisentraut@2ndquadrant.com>, Magnus Hagander <magnus@hagander.net>,
PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2017-07-07T15:50:04Z
Lists: pgsql-hackers
Attachments
- pg_stop_backup_on_standby_v2.patch (text/x-patch) patch v2
On Fri, Jul 7, 2017 at 3:48 PM, Michael Paquier <michael.paquier@gmail.com> wrote: > On Wed, Jul 5, 2017 at 4:57 PM, Michael Paquier > <michael.paquier@gmail.com> wrote: >> Why not refactoring a bit do_pg_stop_backup() so as the wait phase >> happens even if a backup is started in recovery? Now wait_for_archive >> is ignored because no wait is happening and the stop point is directly >> returned back to the caller. For the wait actually happening, I don't >> have a better idea than documenting the fact that enforcing manually a >> segment switch on the primary needs to happen. That's better than >> having users including WAL in their base backups but not actually >> having everything they need. And I think that documenting that >> properly is better than restricting things that should work. > > While looking at that in more details, I got surprised by two things: > 1) No backup history file is generated on a standby during a base backup. > 2) Because of 1), those files are not archived even if archive_mode = always. > > This sounds to me like a missing optimization of archive_mode = > always, and the following comment block in xlog.c is at least > incorrect as an archiver can be invoked in recovery: > * XXX currently a backup history file is for informational and debug > * purposes only. It's not essential for an online backup. Furthermore, > * even if it's created, it will not be archived during recovery because > * an archiver is not invoked. So it doesn't seem worthwhile to write a > * backup history file during recovery. > > So I would suggest the following things to address this issue: > 1) Generate a backup history file for backups taken at recovery as well. > 2) Archive it if archive_mode = always. > 3) Wait for both the segment of the stop point and the backup history > files to be archived before returning back to the caller of > pg_stop_backup. > > It would be nice to get all that addressed in 10. Thoughts? Yeah, I agree. Attached patch makes it works and deals with the history file issue. Regards, -- Masahiko Sawada NIPPON TELEGRAPH AND TELEPHONE CORPORATION NTT Open Source Software Center
Commits
-
Make pg_stop_backup's wait_for_archive flag work on standbys.
- 52f8a59dd953 10.0 landed
-
Implement backup API functions for non-exclusive backups
- 7117685461af 9.6.0 cited