pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Grittner <kgrittn@gmail.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Ants Aasma <ants.aasma@eesti.ee>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: Noah Misch <noah@leadboat.com>
Cc: Kevin Grittner <kgrittn@postgresql.org>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Cc: pgsql-committers@postgresql.org <pgsql-committers@postgresql.org>
Subject: Re: Re: [COMMITTERS] pgsql: Avoid extra locks in GetSnapshotData if old_snapshot_threshold <
Date: Wed, 15 Jun 2016 13:42:19 -0500
Message-ID: <CACjxUsORHHKuuJ5XoQ+eapdbVD+Pt0yuddEosh44EBPfH2bqDg@mail.gmail.com> (raw)
In-Reply-To: <CA+TgmoYewY=tYAgqcB9vM+z1LADHa7tovPQ1axK0W7NHGPhCSQ@mail.gmail.com>
References: <20160416205630.puxsglckxi3sn5ec@alap3.anarazel.de>
	<CAA4eK1JihZepuTasniqrHcsha0umwjeke_ay3AckpGMH4QdJ_g@mail.gmail.com>
	<171569342.34745.1461078735421@RIA>
	<CA+CSw_tqckBCfrTgMyQOBGscM=5t7qYzBS94udGUOFWiOLeHbw@mail.gmail.com>
	<CACjxUsNO=fwsug6yWUcbt=SW5ZjGBqA35ToWgN8LMoAMMMaS3A@mail.gmail.com>
	<20160506220728.bgyxet73t6s3hjiw@alap3.anarazel.de>
	<CACjxUsNmsE-c+NzDbeEX82najPs4CdhPm9MpDep1-VeEUXwegw@mail.gmail.com>
	<20160507004844.wbze4nhjqa67io2a@alap3.anarazel.de>
	<CACjxUsOwwoCsyrspbCviuYCW7zvBviHpTMLXTHY5zzD-F=CHMQ@mail.gmail.com>
	<CACjxUsNs5eomM0v_0PQ9kz3CbfGEBg4H_Bh-fT4nwcyw0jdJSQ@mail.gmail.com>
	<20160524170058.6fhenruilde4xza4@alap3.anarazel.de>
	<CACjxUsN7VNe_q0xGA7xfoTM_yqQXpqOTjhk4CQ479fQthhEFfg@mail.gmail.com>
	<CA+TgmobmG1GxtEzQhnorXnknzbJ_fWvu7Hb5p_Zn6N6jibrkLA@mail.gmail.com>
	<CACjxUsMAFcCC8gWttOfHF=-1xC98fXehThwykvsJT9Jh2=GULg@mail.gmail.com>
	<CA+TgmoZ2uFekmgJHM__LYkhUKtq4-Arh5OOLpsy+YY-6-0W58g@mail.gmail.com>
	<CACjxUsPUY1j9u+i74G35WWrBscv8S87xx8v0-jE0=ZStRWpzDA@mail.gmail.com>
	<CA+TgmoYewY=tYAgqcB9vM+z1LADHa7tovPQ1axK0W7NHGPhCSQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

On Wed, Jun 15, 2016 at 1:29 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Wed, Jun 15, 2016 at 1:44 PM, Kevin Grittner <kgrittn@gmail.com>
> wrote:>> So what happens in this scenario:
>>> 1. ANALYZE runs really slowly - maybe the user-defined function it's
>>> running for the expression index is extremely long-running.
>>> 2. Eventually, the snapshot for ANALYZE is older than the configured
>>> value of snapshot_too_old.
>>> 3. Then, ANALYZE selects a page with an LSN new enough that it might
>>> have been pruned.
>>>
>>> Presumably, the ANALYZE ought to error out in this scenario, just as
>>> it would in any other situation where an old snapshot sees a new page.
>>> No?
>>
>> The test I showed creates a situation which (to ANALYZE) is
>> identical to what you describe -- ANALYZE sees a page with an LSN
>> recent enough that it could have been (and actually has been)
>> pruned.  Why would it be better for the ANALYZE to fail than to
>> complete?
>
> As I understand it, the reason we need to sometimes give "ERROR:
> snapshot too old" after early pruning is because we might otherwise
> give the wrong answer.
>
> Maybe I'm confused.

In the scenario that you describe, ANALYZE is coming up with
statistics to use in query planning, and the numbers are not
expected to always be 100% accurate.  I can think of conditions
which might prevail when seeing the recent LSN.

(1)  The recent LSN is from a cause having nothing to do with the
STO feature, like DML.  As things stand, the behavior is the same
as without the patch -- the rows are counted just the same as
always.  If we did as you suggest, we instead would abort ANALYZE
and have stale statistics.

(2)  The recent LSN is related to STO pruning.  The dead rows are
gone forever, and will not be counted.  This seems more correct
than counting them, even if it were possible, and also superior to
aborting the ANALYZE and leaving stale statistics.

Of course, a subset of (1) is the case that the rows can be
early-pruned at the next opportunity.  In such a case ANALYZE is
still counting them according to the rules that we had before the
snapshot too old feature.  If someone wants to argue that those
rules are wrong, that seems like material for a separate patch.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


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



view thread (195+ messages)  latest in thread

Message-ID: <CACjxUsORHHKuuJ5XoQ+eapdbVD+Pt0yuddEosh44EBPfH2bqDg@mail.gmail.com>
Permalink:  ../CACjxUsORHHKuuJ5XoQ+eapdbVD+Pt0yuddEosh44EBPfH2bqDg@mail.gmail.com/
Also on:    postgresql.org/message-id/CACjxUsORHHKuuJ5XoQ+eapdbVD+Pt0yuddEosh44EBPfH2bqDg@mail.gmail.com

 · 

reply

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-committers@postgresql.org
  Cc: kgrittn@gmail.com, robertmhaas@gmail.com, andres@anarazel.de, ants.aasma@eesti.ee, amit.kapila16@gmail.com, noah@leadboat.com, kgrittn@postgresql.org, pgsql-hackers@postgresql.org
  Subject: Re: [COMMITTERS] pgsql: Avoid extra locks in GetSnapshotData if old_snapshot_threshold <
  In-Reply-To: <CACjxUsORHHKuuJ5XoQ+eapdbVD+Pt0yuddEosh44EBPfH2bqDg@mail.gmail.com>
  References: <20160416205630.puxsglckxi3sn5ec@alap3.anarazel.de> <CACjxUsNO=fwsug6yWUcbt=SW5ZjGBqA35ToWgN8LMoAMMMaS3A@mail.gmail.com> <20160506220728.bgyxet73t6s3hjiw@alap3.anarazel.de> <CACjxUsNmsE-c+NzDbeEX82najPs4CdhPm9MpDep1-VeEUXwegw@mail.gmail.com> <20160507004844.wbze4nhjqa67io2a@alap3.anarazel.de> <CACjxUsOwwoCsyrspbCviuYCW7zvBviHpTMLXTHY5zzD-F=CHMQ@mail.gmail.com> <CACjxUsNs5eomM0v_0PQ9kz3CbfGEBg4H_Bh-fT4nwcyw0jdJSQ@mail.gmail.com> <20160524170058.6fhenruilde4xza4@alap3.anarazel.de> <CACjxUsN7VNe_q0xGA7xfoTM_yqQXpqOTjhk4CQ479fQthhEFfg@mail.gmail.com> <CA+TgmobmG1GxtEzQhnorXnknzbJ_fWvu7Hb5p_Zn6N6jibrkLA@mail.gmail.com> <CACjxUsMAFcCC8gWttOfHF=-1xC98fXehThwykvsJT9Jh2=GULg@mail.gmail.com> <CA+TgmoZ2uFekmgJHM__LYkhUKtq4-Arh5OOLpsy+YY-6-0W58g@mail.gmail.com> <CACjxUsPUY1j9u+i74G35WWrBscv8S87xx8v0-jE0=ZStRWpzDA@mail.gmail.com> <CA+TgmoYewY=tYAgqcB9vM+z1LADHa7tovPQ1axK0W7NHGPhCSQ@mail.gmail.com> <CACjxUsORHHKuuJ5XoQ+eapdbVD+Pt0yuddEosh44EBPfH2bqDg@mail.gmail.com>

* 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