Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1erWsx-0001Rj-8m for pgsql-admin@arkaria.postgresql.org; Thu, 01 Mar 2018 22:41:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1erWsw-0006GO-1U for pgsql-admin@arkaria.postgresql.org; Thu, 01 Mar 2018 22:41:10 +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 1erWsv-0006GF-Qc for pgsql-admin@lists.postgresql.org; Thu, 01 Mar 2018 22:41:09 +0000 Received: from cat-porwal-prod-mail1.catalyst.net.nz ([2404:130:4080::4]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1erWso-0006GZ-5b for pgsql-admin@lists.postgresql.org; Thu, 01 Mar 2018 22:41:09 +0000 Authentication-Results: auth=pass smtp.auth=mark.kirkwood@catalyst.net.nz smtp.mailfrom=mark.kirkwood@catalyst.net.nz Received: from [IPv6:2406:e001:b9c:1:24e8:ba02:9db7:41c] (unknown [IPv6:2406:e001:b9c:1:24e8:ba02:9db7:41c]) (Authenticated sender: mark.kirkwood@catalyst.net.nz) by cat-porwal-prod-mail1.catalyst.net.nz (Postfix) with ESMTPSA id A0F0180DB3; Fri, 2 Mar 2018 11:40:51 +1300 (NZDT) Subject: Re: Reliable WAL file shipping over unreliable network To: Rui DeSousa , scott ribe Cc: Dianne Skoll , pgsql-admin@lists.postgresql.org References: <400AC9CD-1E43-422C-A689-70BDBAFF231E@elevated-dev.com> <37C5A42B-4CDD-4F01-8F1E-1B185C1819B9@icloud.com> <20180228132620.2c882f84@hydrogen.roaringpenguin.com> <33220469-5BB2-4A40-8F56-8F4F392C95B3@icloud.com> <21AF0CB4-0873-4960-BA14-E72FA08B352E@icloud.com> <5a49c387-e4f4-f70c-537c-9c338c80b687@catalyst.net.nz> <9DDA6F85-077E-4F8D-8708-632CC2907D3C@icloud.com> <06dd8b81-8b1a-ae5c-8ddd-1556b5946176@catalyst.net.nz> <6056907B-551F-4ED0-804B-0FCACD39EB23@icloud.com> <988AB20C-9FDE-4197-BF3F-C54D80C2ED78@elevated-dev.com> From: Mark Kirkwood Message-ID: Date: Fri, 2 Mar 2018 11:40:51 +1300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 02/03/18 03:21, Rui DeSousa wrote: > > >> On Mar 1, 2018, at 12:21 AM, scott ribe > > wrote: >> >> The false report of success is not good, but it's not the root problem. > > A false success if a problem; especially in this use case as the > source WAL file will be deleted by Postgres before it was truly > successful.  While monitoring is nice to avoid the issue it is not a > fix for the issue. > > I personally cannot recommend the use of rsync in this application for > two reasons. > > 1. It adds no value; it’s a more complex cp command (no bandwidth > saved, etc as archive processes a single file at a time). > 2. It lies on success/failure — Period. > > > I have use “cat” longer than I have used rsync to archive WALs.  I can > say that I’ve lost zero WAL files using cat; I can not say the same > for rsync. > > The following code is more reliable than rsync and works with across > multiple platforms and filesystems without fail. > > STS=3 > > OUTPUT=$(cat $XLOGFILE | $SSH_CMD "(mkdir -p $ARCH_DIR && cat > > $ARCH_DIR/$WALFILE.swap) && mv $ARCH_DIR/$WALFILE.swap > $ARCH_DIR/$WALFILE") > if [ $? == 0 ]; then >    STS=0 > fi > > exit $STS > > If you have a self contained case that demonstrates rsync returning 0 when it has actually failed, then please do get the rsync authors involved in investigating it (I'm sure they would be interested). Now I've been unable to reproduce any cases of bad return codes or zero length files (using rsync based archive command + quotas), however I'm probably not using the same setup as you (and probably a different platform as well). regards Mark