Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fqLeO-0005jw-3W for pgsql-bugs@arkaria.postgresql.org; Thu, 16 Aug 2018 17:01:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fqLeM-0005K1-KT for pgsql-bugs@arkaria.postgresql.org; Thu, 16 Aug 2018 17:01:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fqLeM-0005Jt-EY for pgsql-bugs@lists.postgresql.org; Thu, 16 Aug 2018 17:01:30 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fqLeG-0006SY-S9 for pgsql-bugs@lists.postgresql.org; Thu, 16 Aug 2018 17:01:29 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 4C1E85F79C; Thu, 16 Aug 2018 13:01:24 -0400 (EDT) Date: Thu, 16 Aug 2018 13:01:24 -0400 From: Stephen Frost To: spam_from_pgsql_lists@chezphil.org, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15335: Documentation is wrong about archive_command and existing files Message-ID: <20180816170124.GP3326@tamriel.snowman.net> References: <153443580087.1505.359622154765650394@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="EXnMavYLKEVsD8gm" Content-Disposition: inline In-Reply-To: <153443580087.1505.359622154765650394@wrigleys.postgresql.org> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --EXnMavYLKEVsD8gm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * PG Bug reporting form (noreply@postgresql.org) wrote: > The docs in section 25.3.1 say that archive_command should check if the > target file already exists and fail in that case. It seems that this is = not > entirely true; the command should succeed if the target file already exis= ts > and its content is the same as the source. > This is explicitly mentioned in section 26.2.9 for the case of cascaded > replication with a shared archive, but I understand that this is actually > needed in all cases. I encountered this during a failed attempt at > promotion, but there are likely to be other cases. Quoting David Steele > from the -general mailing list: >=20 > "Duplicate WAL is possible in *all* cases. A trivial example is that > Postgres calls archive_command and it succeeds but an error happens (e.g. > network) right before Postgres is notified. It will wait a bit and try the > same WAL segment again." So, I agree with all of the above. > Note that the example archive commands in the documentation (using cp) get > this wrong. Minimal examples of archive commands that do this check > correctly would be very useful. I agree that the example command in the documentation which uses 'cp' gets that wrong- it gets quite a few other things wrong too, really. This is what the problem is though- there really isn't any way to have a reasonable and *correct* "minimal" example of an archive command. To do this correctly, you'd really need to compare (or checksum) the file that's in the archive with the file that's being proposed to be added to the archive and then say everything is fine if they match, and throw an error if they don't. Of course, as just discussed elsewhere, you should really also be checking the system-ID in the WAL files against the system-ID of the WAL archive to make sure you aren't archiving WAL files =66rom one system into the archive of another (or across a pg_upgrade), and further, you should be fsync'ing the WAL file after it's been copied before telling PG that it's been saved... Sadly, accomplishing all of that in a one-line shell command is not really feasible. > (I worry that the non-WAL files that archive_command and restore_command = are > also invoked for, e.g. the .backup and .history files, have some addition= al > or possibly even conflicting requirements.) Not really sure what you're getting at here. Thanks! Stephen --EXnMavYLKEVsD8gm Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJbda3jAAoJEO1sijiDR2RV24IP/23kFZZ2+yigB5HS95ft6Fkb XwyOK/QJ3QhZQJDuX2aZt3IZEEfwjp4zTKbXfqt3GAmboXiJIVrVObDbZFLWdaqa /eka+JqytrpuJE/VeOZNZDp8VI34xw5V2C6lo33Q0viaVzEyIaFetksuoAnEdrfG w8dJEhuPBqyKd8JsmNosSuiRNHpth1PbTc4hUvSGW3rPPMz3pMCxs9DvBNeCG7F4 1qk8lpYCLrBemTTUNyb9olSPXyBd2Y9hFxeemDEHgXU4KGyhIo/X/TxNU0dfq8ff 8zIfvsk/J/VsCbuwM54+TFjuwKXK641QKVFJWEOlG+vqarbqggK7i80KcbJ4mF2g /fGGdG7v/XdSRzRNrjTE8wkM7+HdV7TGPTMf5VPpipx/gBBDy+di1HZncYidRbKq z+4ZiKmewPlIDNxR3XUCwI6EVZKTJSkPBe3cgagN8qhjkCinKAHJ7EYfmN4MALRn L95tc5f1kt44pgJtHJoI3ftLMWWDZmY6bBaGxv7P0qkAYwVTSvCoYXEhpzx2h8X7 QJkMExel93iNVnnKmmRLkLFRp7U63xguvdhUmHAkRwvMCleg4tAzRe60t7Yyua3/ CHt1bsjF+WeauwCjcgAKTiMqzdQQHDl5GcVSHaEhRdF8LScfm2pgSrAG3VPvIPR+ 2/ZiFw/b5OjIu2t5Rppd =EJgV -----END PGP SIGNATURE----- --EXnMavYLKEVsD8gm--