Martijn van Oosterhout <> 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

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply via email to