Content-Length: 265332 | pFad | http://github.com/tonybelloni/postgres/commit/2e44770fa39051f404f7d94fed557b359b1dba3c

A3 pgrowlocks: Use GetActiveSnapshot() rather than SnapshotNow. · tonybelloni/postgres@2e44770 · GitHub
Skip to content

Commit 2e44770

Browse files
committed
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.
1 parent f40a318 commit 2e44770

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

contrib/pgrowlocks/pgrowlocks.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "utils/acl.h"
3636
#include "utils/builtins.h"
3737
#include "utils/rel.h"
38+
#include "utils/snapmgr.h"
3839
#include "utils/tqual.h"
3940

4041

@@ -106,7 +107,7 @@ pgrowlocks(PG_FUNCTION_ARGS)
106107
aclcheck_error(aclresult, ACL_KIND_CLASS,
107108
RelationGetRelationName(rel));
108109

109-
scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
110+
scan = heap_beginscan(rel, GetActiveSnapshot(), 0, NULL);
110111
mydata = palloc(sizeof(*mydata));
111112
mydata->rel = rel;
112113
mydata->scan = scan;

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/tonybelloni/postgres/commit/2e44770fa39051f404f7d94fed557b359b1dba3c

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy