Re: [PATCH] Proposed: Have SPI_connect fail if there is no current snapshot

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: [PATCH] Proposed: Have SPI_connect fail if there is no current snapshot
Date: 2005-08-14 17:02:54
Message-ID: 680.1124038974@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Martijn van Oosterhout <kleptog(at)svana(dot)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

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Andreas Pflug 2005-08-14 17:11:34 Re: [HACKERS] For review: Server instrumentation patch
Previous Message Tom Lane 2005-08-14 16:58:55 Re: [HACKERS] For review: Server instrumentation patch