]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix shared memory size of template code for custom fixed-sized pgstats
authorMichael Paquier <michael@paquier.xyz>
Mon, 6 Apr 2026 23:24:32 +0000 (08:24 +0900)
committerMichael Paquier <michael@paquier.xyz>
Mon, 6 Apr 2026 23:24:32 +0000 (08:24 +0900)
On HEAD, the template code for custom fixed-sized pgstats is in the test
module test_custom_stats.  On REL_18_STABLE, this code lives in the test
module injection_points.

Both cases were underestimating the size of the shared memory area
required for the storage of the stats data, using a single entry rather
than the whole area.  This underestimation meant that there was no
memory allocated for the LWLock required for the stats, and even more.
This problem would be also misleading for extension developers looking
at this code.

This issue has been noticed while digging into a different bug reported
by Heikki Linnakangas, showing that the underestimation was causing
failures in the TAP tests of the test modules for 32-bit builds.  The
other issue reported, related to the memory allocation of custom
fixed-sized pgstats, will be fixed in a follow-up commit.

Discussion: https://postgr.es/m/adMk_lWbnz3HDOA8@paquier.xyz
Backpatch-through: 18

src/test/modules/test_custom_stats/test_custom_fixed_stats.c

index f9e7c7172802cd55b661d995569d6187949f1ee0..a066ce117a6d43c0abe0e78d2ce31a1f4df34aa7 100644 (file)
@@ -50,7 +50,7 @@ static const PgStat_KindInfo custom_stats = {
        .fixed_amount = true,           /* exactly one entry */
        .write_to_file = true,          /* persist to stats file */
 
-       .shared_size = sizeof(PgStat_StatCustomFixedEntry),
+       .shared_size = sizeof(PgStatShared_CustomFixedEntry),
        .shared_data_off = offsetof(PgStatShared_CustomFixedEntry, stats),
        .shared_data_len = sizeof(((PgStatShared_CustomFixedEntry *) 0)->stats),