postgresql/src/backend/access
Peter Geoghegan 4a70f829d8 Add nbtree Valgrind buffer lock checks.
Holding just a buffer pin (with no buffer lock) on an nbtree buffer/page
provides very weak guarantees, especially compared to heapam, where it's
often safe to read a page while only holding a buffer pin.  This commit
has Valgrind enforce the following rule: it is never okay to access an
nbtree buffer without holding both a pin and a lock on the buffer.

A draft version of this patch detected questionable code that was
cleaned up by commits fa7ff642 and 7154aa16.  The code in question used
to access an nbtree buffer page's special/opaque area with no buffer
lock (only a buffer pin).  This practice (which isn't obviously unsafe)
is hereby formally disallowed in nbtree.  There doesn't seem to be any
reason to allow it, and banning it keeps things simple for Valgrind.

The new checks are implemented by adding custom nbtree client requests
(located in LockBuffer() wrapper functions); these requests are
"superimposed" on top of the generic bufmgr.c Valgrind client requests
added by commit 1e0dfd16.  No custom resource management cleanup code is
needed to undo the effects of marking buffers as non-accessible under
this scheme.

Author: Peter Geoghegan
Reviewed-By: Anastasia Lubennikova, Georgios Kokolatos
Discussion: https://postgr.es/m/CAH2-WzkLgyN3zBvRZ1pkNJThC=xi_0gpWRUb_45eexLH1+k2_Q@mail.gmail.com
2020-07-21 15:50:58 -07:00
..
brin Remove WARNING message from brin_desummarize_range 2020-07-09 20:13:25 -04:00
common code: replace 'master' with 'primary' where appropriate. 2020-07-08 12:57:23 -07:00
gin Modify additional power 2 calculations to use new helper functions 2020-04-08 18:29:51 +12:00
gist code: replace 'master' with 'primary' where appropriate. 2020-07-08 12:57:23 -07:00
hash Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
heap Avoid harmless Valgrind no-buffer-pin errors. 2020-07-19 16:12:51 -07:00
index Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
nbtree Add nbtree Valgrind buffer lock checks. 2020-07-21 15:50:58 -07:00
rmgrdesc Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
spgist Fix masking of SP-GiST pages during xlog consistency check 2020-06-20 17:34:51 +03:00
table Fix misuse of table_index_fetch_tuple_check(). 2020-06-25 10:55:28 -07:00
tablesample Move src/backend/utils/hash/hashfn.c to src/common 2020-02-27 09:25:41 +05:30
transam Rename wal_keep_segments to wal_keep_size. 2020-07-20 13:30:18 +09:00
Makefile Introduce access/{table.h, relation.h}, for generic functions from heapam.h. 2019-01-21 10:51:36 -08:00