]> granicus.if.org Git - postgresql/commit
Delay fsyncs of pg_basebackup until the end of backup
authorMichael Paquier <michael@paquier.xyz>
Wed, 4 Sep 2019 04:24:06 +0000 (13:24 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 4 Sep 2019 04:24:06 +0000 (13:24 +0900)
commit996c92b27dfe5e36702f3a5a06c883b76be98705
treeaa04cccc838a6e382baa237c9c54dbcef895ae6c
parentf967a1fda89b8b96b363109af21d521ed9d50877
Delay fsyncs of pg_basebackup until the end of backup

Since the addition of fsync requests in bc34223 to make base backup data
consistent on disk once pg_basebackup finishes, each tablespace tar file
is individually flushed once completed, with an additional flush of the
parent directory when the base backup finishes.  While holding a
connection to the server, a fsync request taking a long time may cause a
failure of the base backup, which is annoying for any integration.  A
recent example of breakage can involve tcp_user_timeout, but
wal_sender_timeout can cause similar problems.

While reviewing the code, there was a second issue causing too many
fsync requests to be done for the same WAL data.  As recursive fsyncs
are done at the end of the backup for both the plain and tar formats
from the base target directory where everything is written, it is fine
to disable fsyncs when fetching or streaming WAL.

Reported-by: Ryohei Takahashi
Author: Michael Paquier
Reviewed-by: Ryohei Takahashi
Discussion: https://postgr.es/m/OSBPR01MB4550DAE2F8C9502894A45AAB82BE0@OSBPR01MB4550.jpnprd01.prod.outlook.com
Backpatch-through: 10
src/bin/pg_basebackup/pg_basebackup.c