Re: our checks for read-only queries are not great - Mailing list pgsql-hackers

From Robert Haas
Subject Re: our checks for read-only queries are not great
Date
Msg-id CA+TgmoZhNVe=A+3suiyZVA+416Ccw-1tD93emzhMbqTBCGT7Kg@mail.gmail.com
Whole thread Raw
In response to Re: our checks for read-only queries are not great  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Responses Re: our checks for read-only queries are not great  (Stephen Frost <sfrost@snowman.net>)
List pgsql-hackers
On Wed, Jan 15, 2020 at 10:25 AM Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
> Well, if the transaction was declared read-only, then committing it
> (directly or 2PC) shouldn't change anything.  This appears to be a
> circular argument.

I don't think it's a circular argument. Suppose that someone decrees
that, as of 5pm Eastern time, no more read-write transactions are
permitted. And because the person issuing the decree has a lot of
power, everybody obeys. Now, every pg_dump taken after that time will
be semantically equivalent to every other pg_dump taken after that
time, with one tiny exception. That exception is that someone could
still do COMMIT PREPARED of a read-write transaction that was prepared
before 5pm. If the goal of the powerful person who issued the decree
was to make sure that the database couldn't change - e.g. so they
could COPY each table individually without keeping a snapshot open and
still get a consistent backup - they might fail to achieve it if, as
of the moment of the freeze, there are some prepared write
transactions.

I'm not saying we have to change the behavior or anything. I'm just
saying that there seems to be one, and only one, way to make the
apparent contents of the database change in a read-only transaction
right now. And that's a COMMIT PREPARED of a read-write transaction.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: David Zhang
Date:
Subject: Re: Making psql error out on output failures
Next
From: Stephen Frost
Date:
Subject: Re: our checks for read-only queries are not great