Re: [PATCH] Proposed: Have SPI_connect fail if there is no current snapshot - Mailing list pgsql-patches

From Tom Lane
Subject Re: [PATCH] Proposed: Have SPI_connect fail if there is no current snapshot
Date
Msg-id 680.1124038974@sss.pgh.pa.us
Whole thread Raw
In response to Re: [PATCH] Proposed: Have SPI_connect fail if there is no current snapshot  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-patches
Martijn van Oosterhout <kleptog@svana.org> writes:
> You can lock a table even while you have no valid snapshot?

Certainly.  In serializable mode, you really need to be able to take out
locks before the snapshot is set --- TFM explains:

    Note also that if one is relying on explicit locking to prevent
    concurrent changes, one should use Read Committed mode, or in
    Serializable mode be careful to obtain the lock(s) before performing
    queries. A lock obtained by a serializable transaction guarantees that
    no other transactions modifying the table are still running, but if the
    snapshot seen by the transaction predates obtaining the lock, it may
    predate some now-committed changes in the table. A serializable
    transaction's snapshot is actually frozen at the start of its first
    query or data-modification command (SELECT, INSERT, UPDATE, or DELETE),
    so it's possible to obtain locks explicitly before the snapshot is
    frozen.

            regards, tom lane

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] For review: Server instrumentation patch
Next
From: Andreas Pflug
Date:
Subject: Re: [HACKERS] For review: Server instrumentation patch