pgstat: prevent fix pgstat_reinit_entry() from zeroing out lwlock.
authorAndres Freund <andres@anarazel.de>
Thu, 7 Apr 2022 06:35:56 +0000 (23:35 -0700)
committerAndres Freund <andres@anarazel.de>
Thu, 7 Apr 2022 06:35:56 +0000 (23:35 -0700)
Zeroing out an lwlock in a normal build turns out to not trigger any alarms,
if nobody can use the lwlock at that moment (as the case here). But with
--disable-spinlocks --disable-atomics, the sema field needs to be initialized.

We probably should make sure that this fails on more common configurations as
well...

Per buildfarm animal rorqual

src/backend/utils/activity/pgstat_shmem.c

index a32740b2f6edbd68de87b120da2d27bccb0c20b8..b270c504ea6b25827144d21ae6b5af8f4b2320ed 100644 (file)
@@ -292,8 +292,8 @@ pgstat_reinit_entry(PgStat_Kind kind, PgStatShared_HashEntry *shhashent)
 
    /* reinitialize content */
    Assert(shheader->magic == 0xdeadbeef);
-   memset(shheader, 0, pgstat_get_kind_info(shhashent->key.kind)->shared_size);
-   shheader->magic = 0xdeadbeef;
+   memset(pgstat_get_entry_data(kind, shheader), 0,
+          pgstat_get_entry_len(kind));
 
    return shheader;
 }