postgresql/src/include
Andres Freund 8e293e689b aio: Make AIO more compatible with valgrind
In some edge cases valgrind flags issues with the memory referenced by
IOs. All of the cases addressed in this change are false positives.

Most of the false positives are caused by UnpinBuffer[NoOwner] marking buffer
data as inaccessible. This happens even though the AIO subsystem still holds a
pin. That's good, there shouldn't be accesses to the buffer outside of AIO
related code until it is pinned by "user" code again. But it requires some
explicit work - if the buffer is not pinned by the current backend, we need to
explicitly mark the buffer data accessible/inaccessible while executing
completion callbacks.

That however causes a cascading issue in IO workers: After the completion
callbacks for a buffer is executed, the page is marked as inaccessible. If
subsequently the same worker is executing IO targeting the same buffer, we
would get an error, as the memory is still marked inaccessible. To avoid that,
we need to explicitly mark the memory as accessible in IO workers.

Another issue is that IO executed in workers or via io_uring will not mark
memory as DEFINED. In the case of workers that is because valgrind does not
track memory definedness across processes. For io_uring that is because
valgrind does not understand io_uring, and therefore its IOs never mark memory
as defined, whether the completions are processed in the defining process or
in another context.  It's not entirely clear how to best solve that. The
current user of AIO is not affected, as it explicitly marks buffers as DEFINED
& NOACCESS anyway.  Defer solving this issue until we have a user with
different needs.

Per buildfarm animal skink.

Reviewed-by: Noah Misch <noah@leadboat.com>
Co-authored-by: Noah Misch <noah@leadboat.com>
Discussion: https://postgr.es/m/3pd4322mogfmdd5nln3zphdwhtmq3rzdldqjwb2sfqzcgs22lf@ok2gletdaoe6
2025-04-07 15:20:30 -04:00
..
access Allow NOT NULL constraints to be added as NOT VALID 2025-04-07 19:19:50 +02:00
archive Update copyright for 2025 2025-01-01 11:21:55 -05:00
backup Update copyright for 2025 2025-01-01 11:21:55 -05:00
bootstrap pg_noreturn to replace pg_attribute_noreturn() 2025-03-13 12:37:26 +01:00
catalog Fix erroneous construction of functions' dependencies on transforms. 2025-04-07 13:31:37 -04:00
commands Add an additional hook for EXPLAIN option validation. 2025-03-20 13:47:55 -04:00
common Update Unicode data to Unicode 16.0.0 2025-04-03 12:00:09 +02:00
datatype Avoid using timezone Asia/Manila in regression tests. 2025-01-20 15:47:53 -05:00
executor Change SQL-language functions to use the plan cache. 2025-04-02 14:06:02 -04:00
fe_utils add new list type simple_oid_string_list to fe-utils/simple_list 2025-04-04 16:01:22 -04:00
foreign Update copyright for 2025 2025-01-01 11:21:55 -05:00
jit Fix grammatical typos around possessive "its" 2025-01-29 14:39:14 +07:00
lib Use PRI?64 instead of "ll?" in format strings (continued). 2025-03-29 10:43:57 +01:00
libpq Add local-address escape "%L" to log_line_prefix. 2025-04-07 11:06:05 -04:00
mb pg_noreturn to replace pg_attribute_noreturn() 2025-03-13 12:37:26 +01:00
nodes Convert PathKey to use CompareType 2025-04-04 11:22:20 +02:00
optimizer Convert 'x IN (VALUES ...)' to 'x = ANY ...' then appropriate 2025-04-04 16:01:50 +03:00
parser Extend ALTER DEFAULT PRIVILEGES to define default privileges for large objects. 2025-04-04 19:02:17 +09:00
partitioning Fix incorrect #endif comment 2025-03-10 13:36:04 +13:00
pch Update copyright for 2025 2025-01-01 11:21:55 -05:00
port Compute CRC32C using AVX-512 instructions where available 2025-04-06 14:04:30 +07:00
portability Update copyright for 2025 2025-01-01 11:21:55 -05:00
postmaster pg_noreturn to replace pg_attribute_noreturn() 2025-03-13 12:37:26 +01:00
regex Update copyright for 2025 2025-01-01 11:21:55 -05:00
replication Use standard die() signal handler in walreceiver 2025-04-04 12:38:32 +03:00
rewrite Eliminate code duplication in replace_rte_variables callbacks 2025-02-25 16:11:34 +09:00
snowball Update to latest Snowball sources. 2025-02-18 21:13:54 -05:00
statistics Stats: use schemaname/relname instead of regclass. 2025-03-25 11:16:06 -07:00
storage aio: Make AIO more compatible with valgrind 2025-04-07 15:20:30 -04:00
tcop Improve error message when standby does accept connections. 2025-04-02 15:13:01 +09:00
tsearch Update copyright for 2025 2025-01-01 11:21:55 -05:00
utils Relax ordering-related hardcoded btree requirements in planning 2025-04-06 14:43:51 +02:00
.gitignore Use <stdint.h> and <inttypes.h> for c.h integers. 2024-12-04 15:05:38 +13:00
c.h Revert "Use workaround of __builtin_setjmp only on MINGW on MSVCRT" 2025-04-07 11:01:15 -04:00
fmgr.h Avoid mixing designated and non-designated field initializers. 2025-03-27 11:06:30 -04:00
funcapi.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
getopt_long.h IWYU widely useful pragmas 2025-01-15 18:57:53 +01:00
Makefile Use <stdint.h> and <inttypes.h> for c.h integers. 2024-12-04 15:05:38 +13:00
meson.build Update copyright for 2025 2025-01-01 11:21:55 -05:00
miscadmin.h Make cancel request keys longer 2025-04-02 16:41:48 +03:00
pg_config.h.in Compute CRC32C using AVX-512 instructions where available 2025-04-06 14:04:30 +07:00
pg_config_manual.h Avoid invalidating all RelationSyncCache entries on publication rename. 2025-03-13 09:16:33 +05:30
pg_getopt.h IWYU widely useful pragmas 2025-01-15 18:57:53 +01:00
pg_trace.h IWYU widely useful pragmas 2025-01-15 18:57:53 +01:00
pgstat.h pgstat: Allow checksum errors to be reported in critical sections 2025-03-30 16:12:04 -04:00
pgtar.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
pgtime.h Seek zone abbreviations in the IANA data before timezone_abbreviations. 2025-01-16 14:11:19 -05:00
port.h Add timingsafe_bcmp(), for constant-time memory comparison 2025-04-02 15:32:40 +03:00
postgres.h IWYU widely useful pragmas 2025-01-15 18:57:53 +01:00
postgres_ext.h libpq: Deprecate pg_int64. 2025-03-25 21:40:00 +13:00
postgres_fe.h IWYU widely useful pragmas 2025-01-15 18:57:53 +01:00
varatt.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
windowapi.h Update copyright for 2025 2025-01-01 11:21:55 -05:00