Re: Serializable read only deferrable- implications

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Michael Lewis <mlewis(at)entrata(dot)com>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Serializable read only deferrable- implications
Date: 2022-03-08 20:17:20
Message-ID: CAKFQuwb=2FLmWQmD0+MuG8DxUUs8g6wB4kbSn-2coUKipWGJeg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Mar 8, 2022 at 11:47 AM Michael Lewis <mlewis(at)entrata(dot)com> wrote:

>
> Thanks to you both. If other concurrent sessions are using default
> isolation level of Read committed, would putting long running reports
> (read-only) into that read-only serializable deferrable mode be impactful
> at all?
>

I'm tending to agree that this documentation could be improved (I too am
not totally fluent on how the different modes interact with each other).
In this specific case the docs say:
"When all three of these properties are selected for a transaction, the
transaction may block when first acquiring its snapshot,..."
They fail to say what they are blocking on and thus what has to occur in
the system before the lock can be acquired and the transaction continues
onward. I suspect it is simply that any not yet committed transactions
become committed or reverted. Whether those transactions were run under
serializable, read committed, or repeatable read would be immaterial.

> The documentation says that a transaction ID is only assigned to a
> connection once a write is done, but is the assignment or not of a txn id
> actually impactful on anything?
>

I ask partly because it doesn't seem possible to reset that once assigned,
> through discard all; or something else like that which might be used by a
> connection pooler such as pg bouncer. is there any way to check if a
> session has "done writes/updates up to this point"? It
> seems pg_my_temp_schema() also returns the same value even after 'discard
> temp' or 'discard all' is executed. That was surprising to me, but would it
> be considered an issue by anyone?
>

I'm getting an impression that you have confusion regarding transactions
and sessions, since all of this concurrency stuff only cares about the
transactions but you now start talking about session state and comparing
what you would see at initial login versus what you see after resetting.

The temporary schema for a session is assigned once the first temporary
object is created. At which point that assignment of the random temporary
schema is fixed for the duration of the session. It never gets reset as
there is no point.

Whether a session has done "write/updates up to this point" is likewise not
something that can be readily ascertained nor, from what I can tell, would
doing so be a useful exercise. There may be some reason to inspect whether
a transaction has performed a write/update, but even that seems unlikely.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Lucas 2022-03-09 07:03:11 Postgres migration from 9.2 to 14
Previous Message hubert depesz lubaczewski 2022-03-08 20:15:59 Re: Interesting fail when migrating Pg from Ubuntu Bionic to Focal