Re: per backend WAL statistics - Mailing list pgsql-hackers

From Alexander Lakhin
Subject Re: per backend WAL statistics
Date
Msg-id f1788cc0-253a-4a3a-aee0-1b8ab9538736@gmail.com
Whole thread Raw
In response to Re: per backend WAL statistics  (Michael Paquier <michael@paquier.xyz>)
Responses Re: per backend WAL statistics
List pgsql-hackers
Hello Michael,

11.03.2025 02:06, Michael Paquier wrote:
And I guess that we're OK here, so applied.  That should be the last
one.

Please try the following query:
BEGIN;
SET LOCAL stats_fetch_consistency = snapshot;
SELECT * FROM pg_stat_get_backend_wal(pg_backend_pid());

with sanitizers (or under Valgrind). When I run it, I get:
2025-03-28 18:38:08.259 UTC [3415399] LOG:  statement: SELECT * FROM pg_stat_get_backend_wal(pg_backend_pid());
=================================================================
==3415399==ERROR: AddressSanitizer: heap-use-after-free on address 0x53100003c83c at pc 0x556e3d2d9967 bp 0x7ffda3cd2350 sp 0x7ffda3cd2340
READ of size 4 at 0x53100003c83c thread T0
    #0 0x556e3d2d9966 in pgstat_fetch_stat_backend_by_pid .../src/backend/utils/activity/pgstat_backend.c:136
    #1 0x556e3d53b671 in pg_stat_get_backend_wal .../src/backend/utils/adt/pgstatfuncs.c:1673
    #2 0x556e3cb14045 in ExecMakeTableFunctionResult .../src/backend/executor/execSRF.c:234
    #3 0x556e3cb6c0fd in FunctionNext .../src/backend/executor/nodeFunctionscan.c:94
    #4 0x556e3cb171d2 in ExecScanFetch ../../../src/include/executor/execScan.h:126
    #5 0x556e3cb171d2 in ExecScanExtended ../../../src/include/executor/execScan.h:170
    #6 0x556e3cb171d2 in ExecScan .../src/backend/executor/execScan.c:59
    #7 0x556e3cb6bbf7 in ExecFunctionScan .../src/backend/executor/nodeFunctionscan.c:269
    #8 0x556e3cb0aba9 in ExecProcNodeFirst .../src/backend/executor/execProcnode.c:469
...

Reproduced starting from 76def4cdd.

Best regards,
Alexander Lakhin
Neon (https://neon.tech)

pgsql-hackers by date:

Previous
From: Nico Williams
Date:
Subject: Re: Remove restrictions in recursive query
Next
From: Robert Haas
Date:
Subject: Re: Proposal: Progressive explain