Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZtYIK-0003ZP-Hq for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Nov 2015 09:54:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZtYIJ-0003Nf-4Z for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Nov 2015 09:54:23 +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.84) (envelope-from ) id 1ZtYIG-0003M3-G9; Tue, 03 Nov 2015 09:54:20 +0000 Received: from forward16p.cmail.yandex.net ([87.250.241.143]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZtYIC-00022o-C0; Tue, 03 Nov 2015 09:54:19 +0000 Received: from smtp18.mail.yandex.net (smtp18.mail.yandex.net [95.108.252.18]) by forward16p.cmail.yandex.net (Yandex) with ESMTP id 506172233F; Tue, 3 Nov 2015 12:51:24 +0300 (MSK) Received: from smtp18.mail.yandex.net (localhost [127.0.0.1]) by smtp18.mail.yandex.net (Yandex) with ESMTP id 1673B18A008E; Tue, 3 Nov 2015 12:51:22 +0300 (MSK) Received: by smtp18.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id lVYZ3phr17-pMNaQjq9; Tue, 3 Nov 2015 12:51:22 +0300 (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=simply.name; s=mail; t=1446544282; bh=zT8knlD7xyxL6Cqk9S+ycbqsu5qxMsVs/WQJ7FnwSS0=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To:X-Mailer; b=gYsEavNbutQeTrGnYg5xmnPXQlrdSz/1AcEa2wH0dOCZM6liQhOyNYpKe6UEX4OBP HkRcjyVKW/4tgyTfWPhvN53unV3yOWXHUgI7azfv/nDIT5JssKv3zyyuoezGME4Rtt jYZvDGDY5tcB3LAuX9aE9SsQArLNcn9w1EgdDfGM= Authentication-Results: smtp18.mail.yandex.net; dkim=pass header.i=@simply.name X-Yandex-ForeignMX: DE Content-Type: multipart/alternative; boundary="Apple-Mail=_81369D19-1129-49AB-82D4-6B55C01C572F" Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: Re: [ADMIN] Replication slots and isolation levels From: Vladimir Borodin In-Reply-To: <20151103083842.GQ11897@awork2.anarazel.de> Date: Tue, 3 Nov 2015 12:51:22 +0300 Cc: Robert Haas , Oleksii Kliukin , Michael Paquier , pgsql-admin , PostgreSQL-development Message-Id: <431D21F8-BD78-4953-80EC-FFF1BF7DA6F5@simply.name> References: <0E6700E4-195C-450D-A051-D19F92B2A9D7@simply.name> <86D2C6D2-C332-4BF9-A82E-C9F7FA471712@simply.name> <088B276D-4073-4582-82D4-08F50E43B426@simply.name> <95FD0B1A-7BD1-4CCE-86D4-2DF2B2AE2C68@simply.name> <20151103083842.GQ11897@awork2.anarazel.de> To: Andres Freund X-Mailer: Apple Mail (2.2104) X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --Apple-Mail=_81369D19-1129-49AB-82D4-6B55C01C572F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > 3 =D0=BD=D0=BE=D1=8F=D0=B1. 2015 =D0=B3., =D0=B2 11:38, Andres Freund = =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0): >=20 > On 2015-11-02 15:37:57 -0500, Robert Haas wrote: >> On Fri, Oct 30, 2015 at 9:49 AM, Vladimir Borodin = wrote: >>> I=E2=80=99ve tried two ways - bare SELECT in autocommit mode and = BEGIN; SELECT; >>> ROLLBACK. I first described the problem in thread on pgsql-admin@ = [0], there >>> is copy-paste from psql there, but during conversation initial = description >>> was lost. >>>=20 >>> [0] >>> = http://www.postgresql.org/message-id/7F74C5EA-6741-44FC-B6C6-E96F18D761FB@= simply.name >>=20 >> Hmm. That behavior seems unexpected to me, but I might be missing = something. >=20 > The conflict is because of a relation lock, not because of > visibility. Hot-Standby feedback changes nothing about that. >=20 > I presume all the other conflicts are all because of relation level > locks? Check pg_stat_database_conflicts and the server logs to verify. Oh, good point, thank you, it gives the answer. Actually I=E2=80=99ve = already done a switchover in this cluster, so pg_stat_database_conflicts = started from scratch :( But the logs haven=E2=80=99t been rotated yet: root@rpopdb01e ~ # fgrep -e 562f9ef0.23df,6 -e 562fa107.451a -e = 562fa1d9.5146 -e 562f9ef0.23df,10 -e 562fa259.56d1 = /var/lib/pgsql/9.4/data/pg_log/postgresql-2015-10-27_185736.csv 2015-10-27 19:06:28.656 MSK,,,9183,,562f9ef0.23df,6,,2015-10-27 18:57:36 = MSK,,0,LOG,00000,"parameter ""hot_standby_feedback"" changed to = ""off""",,,,,,,,,"" 2015-10-27 19:10:05.039 = MSK,"postgres","rpopdb",17690,"[local]",562fa107.451a,1,"",2015-10-27 = 19:06:31 MSK,12/54563,0,ERROR,40001,"canceling statement due to conflict = with recovery","User query might have needed to see row versions that = must be removed.",,,,,"select count(*) from = rpop.rpop_imap_uidls;",,,"psql" 2015-10-27 19:10:05.995 = MSK,"monitor","rpopdb",20806,"localhost:51794",562fa1d9.5146,1,"",2015-10-= 27 19:10:01 MSK,15/24192,0,ERROR,40001,"canceling statement due to = conflict with recovery","User was holding shared buffer pin for too = long.",,,,"SQL function ""to_timestamp"" statement 1","select cnt from = monitor.bad_rpop_total",,,"" 2015-10-27 19:12:06.878 MSK,,,9183,,562f9ef0.23df,10,,2015-10-27 = 18:57:36 MSK,,0,LOG,00000,"parameter ""hot_standby_feedback"" changed to = ""on""",,,,,,,,,"" 2015-10-27 19:17:57.056 = MSK,"postgres","rpopdb",22225,"[local]",562fa259.56d1,1,"",2015-10-27 = 19:12:09 MSK,3/35442,0,FATAL,40001,"terminating connection due to = conflict with recovery","User was holding a relation lock for too = long.",,,,,"select count(*) from rpop.rpop_imap_uidls;",,,"psql" root@rpopdb01e ~ # So FATAL is due to relation lock and one ERROR is due to pinned buffers = (this is actually from another user) but there is also one ERROR due to = old snapshots (first line). But I actually turned off hs_feedback before = first ERROR and turned it on after it. So it seems to work expectedly. Does it actually mean that I could get such conflicts (due to relation = locks, for example) even in repeatable read or serializable? I mean, is = there any dependency between transaction isolation level on standby and = conflicts with recovery? And am I right that the only way not to have confl_lock is to increase = max_standby_streaming_delay? >=20 > Andres >=20 >=20 > --=20 > Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-hackers -- May the force be with you=E2=80=A6 https://simply.name --Apple-Mail=_81369D19-1129-49AB-82D4-6B55C01C572F Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
3 =D0=BD=D0=BE=D1=8F=D0=B1. 2015 =D0=B3., =D0=B2 11:38, = Andres Freund <andres@anarazel.de> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0= =D0=BB(=D0=B0):

On 2015-11-02 15:37:57 -0500, Robert Haas wrote:
On Fri, Oct 30, 2015 at = 9:49 AM, Vladimir Borodin <root@simply.name> wrote:
I=E2=80=99ve tried two ways - bare SELECT in = autocommit mode and BEGIN; SELECT;
ROLLBACK. I first = described the problem in thread on pgsql-admin@ [0], there
is copy-paste from psql there, but during conversation = initial description
was lost.

[0]
http://www.postgresql.org/message-id/7F74C5EA-6741-44FC-B6C6-E9= 6F18D761FB@simply.name

Hmm. =  That behavior seems unexpected to me, but I might be missing = something.

The conflict is = because of a relation lock, not because of
visibility. = Hot-Standby feedback changes nothing about = that.

I presume all the other conflicts are all = because of relation level
locks? Check = pg_stat_database_conflicts and the server logs to verify.

Oh, good = point, thank you, it gives the answer. Actually I=E2=80=99ve already = done a switchover in this cluster, so pg_stat_database_conflicts started = from scratch :( But the logs haven=E2=80=99t been rotated = yet:

root@rpopdb01e ~ # = fgrep -e 562f9ef0.23df,6 -e 562fa107.451a -e 562fa1d9.5146 -e = 562f9ef0.23df,10 -e 562fa259.56d1 = /var/lib/pgsql/9.4/data/pg_log/postgresql-2015-10-27_185736.csv
= 2015-10-27 19:06:28.656 MSK,,,9183,,562f9ef0.23df,6,,2015-10-27 18:57:36 = MSK,,0,LOG,00000,"parameter ""hot_standby_feedback"" changed to = ""off""",,,,,,,,,""
2015-10-27 19:10:05.039 = MSK,"postgres","rpopdb",17690,"[local]",562fa107.451a,1,"",2015-10-27 = 19:06:31 MSK,12/54563,0,ERROR,40001,"canceling statement due to conflict = with recovery","User query might have needed to see row versions that = must be removed.",,,,,"select count(*) from = rpop.rpop_imap_uidls;",,,"psql"
2015-10-27 19:10:05.995 = MSK,"monitor","rpopdb",20806,"localhost:51794",562fa1d9.5146,1,"",2015-10-= 27 19:10:01 MSK,15/24192,0,ERROR,40001,"canceling statement due to = conflict with recovery","User was holding shared buffer pin for too = long.",,,,"SQL function ""to_timestamp"" statement 1","select cnt from = monitor.bad_rpop_total",,,""
2015-10-27 19:12:06.878 = MSK,,,9183,,562f9ef0.23df,10,,2015-10-27 18:57:36 = MSK,,0,LOG,00000,"parameter ""hot_standby_feedback"" changed to = ""on""",,,,,,,,,""
2015-10-27 19:17:57.056 = MSK,"postgres","rpopdb",22225,"[local]",562fa259.56d1,1,"",2015-10-27 = 19:12:09 MSK,3/35442,0,FATAL,40001,"terminating connection due to = conflict with recovery","User was holding a relation lock for too = long.",,,,,"select count(*) from = rpop.rpop_imap_uidls;",,,"psql"
root@rpopdb01e ~ = #

So FATAL is due to relation = lock and one ERROR is due to pinned buffers (this is actually from = another user) but there is also one ERROR due to old snapshots = (first line). But I actually turned off hs_feedback before first ERROR = and turned it on after it. So it seems to work expectedly.

Does it actually mean that I could get such = conflicts (due to relation locks, for example) even in repeatable read = or serializable? I mean, is there any dependency between transaction = isolation level on standby and conflicts with recovery?

And am I right that the only way not to = have confl_lock is to increase = max_standby_streaming_delay?



Andres


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make = changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


--
May the force be with you=E2=80=A6

= --Apple-Mail=_81369D19-1129-49AB-82D4-6B55C01C572F--