From: Marco Nenciarini <marco.nenciarini@2ndquadrant.it>
To: pgsql-bugs@postgresql.org, PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: [HACKERS] BUG #13473: VACUUM FREEZE mistakenly cancel standby sessions
Date: Wed, 25 May 2016 19:33:12 +0200
Message-ID: <52fb5d06-ac66-ea1e-c6fd-46949d17962e@2ndquadrant.it> (raw)
In-Reply-To: <558DDC9B.6090001@BlueTreble.com>
References: <20150626134310.3876.82768@wrigleys.postgresql.org>
<558D58B1.70400@2ndquadrant.it>
<558DDC9B.6090001@BlueTreble.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On 27/06/15 01:13, Jim Nasby wrote:
> On 6/26/15 8:50 AM, Marco Nenciarini wrote:
>>> >In the heap_xlog_freeze we need to subtract one to the value of
>>> cutoff_xid
>>> >before passing it to ResolveRecoveryConflictWithSnapshot.
>>> >
>>> >
>>> >
>> Attached a proposed patch that solves the issue.
>
I have hit the bug again, as it has been fixed only from 9.5+
The procedure to reproduce it sent in the original post is not fully
accurate, below there is one that always works:
Run the following operation on an idle cluster.
1) connect to the master and run the following script
create table t(id int primary key);
insert into t select generate_series(1, 10000);
2) connect to the standby and simulate a long running query:
select pg_sleep(3600);
3) on the master and run the following commands:
vacuum freeze verbose t;
drop table t;
4) after 30 seconds the pg_sleep query on standby will be canceled.
Attached there is a patch that apply on every version that misses the
fix (9.0, 9.1, 9.2, 9.3, 9.4)
Regards,
Marco
--
Marco Nenciarini - 2ndQuadrant Italy
PostgreSQL Training, Services and Support
marco.nenciarini@2ndQuadrant.it | www.2ndQuadrant.it
Attachments:avoid-hot-standby-cancels-from-vac-freeze.patch (text/x-patch, 679B) downloaddiff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.cindex eb8eada..434880a 100644--- a/src/backend/access/heap/heapam.c+++ b/src/backend/access/heap/heapam.c@@ -4764,7 +4764,13 @@ heap_xlog_freeze(XLogRecPtr lsn, XLogRecord *record)
* consider the frozen xids as running.
*/
if (InHotStandby)
- ResolveRecoveryConflictWithSnapshot(cutoff_xid, xlrec->node);+ {+ TransactionId latestRemovedXid = cutoff_xid;++ TransactionIdRetreat(latestRemovedXid);++ ResolveRecoveryConflictWithSnapshot(latestRemovedXid, xlrec->node);+ }
/* If we have a full-page image, restore it and we're done */
if (record->xl_info & XLR_BKP_BLOCK(0))
signature.asc (application/pgp-signature, 800B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: marco.nenciarini@2ndquadrant.it, pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] BUG #13473: VACUUM FREEZE mistakenly cancel standby sessions
In-Reply-To: <52fb5d06-ac66-ea1e-c6fd-46949d17962e@2ndquadrant.it>
References: <20150626134310.3876.82768@wrigleys.postgresql.org> <558D58B1.70400@2ndquadrant.it> <558DDC9B.6090001@BlueTreble.com> <52fb5d06-ac66-ea1e-c6fd-46949d17962e@2ndquadrant.it>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox