pgsql: pgrowlocks: Use GetActiveSnapshot() rather than SnapshotNow.

From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: pgrowlocks: Use GetActiveSnapshot() rather than SnapshotNow.
Date: 2013-07-22 20:22:13
Message-ID: E1V1McX-0001gG-JG@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

pgrowlocks: Use GetActiveSnapshot() rather than SnapshotNow.

Per discussion, it's desirable to eliminate all remaining uses of
SnapshotNow, because it has unpleasant semantics: race conditions
can result in seeing multiple versions of a concurrently updated
row, or none at all. By using GetActiveSnapshot() here, callers
will see exactly those rows that would have been visible if the
invoking query had scanned the table using, for example, a SELECT
statement.

This is slightly different from the old behavior, because commits
that happen concurrently with the scan will not affect the results.
In REPEATABLE READ or SERIALIZABLE modes, where transaction
snapshots are used, commits that have happened since the start of
the transaction will also not affect the results. It is hoped
that this minor incompatibility will be thought an improvement,
or at least no worse than what we did before.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/2e44770fa39051f404f7d94fed557b359b1dba3c

Modified Files
--------------
contrib/pgrowlocks/pgrowlocks.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2013-07-22 22:01:50 Re: [COMMITTERS] pgsql: Add support for REFRESH MATERIALIZED VIEW CONCURRENTLY.
Previous Message Robert Haas 2013-07-22 19:50:38 Re: [COMMITTERS] pgsql: Allow background workers to be started dynamically.