aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/dbsize.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2022-10-08 09:33:23 -0700
committerAndres Freund <andres@anarazel.de>2022-10-08 09:43:29 -0700
commit06dbd619bfbfe03fefa7223838690d4012f874ad (patch)
tree8ebd1f854d2c65fc9dfe7a615bf2105a9f4b414d /src/backend/utils/adt/dbsize.c
parente4c61bedcb791fe79fdc4e96a3a7ab59b0dbacaf (diff)
downloadpostgresql-06dbd619bfbfe03fefa7223838690d4012f874ad.tar.gz
postgresql-06dbd619bfbfe03fefa7223838690d4012f874ad.zip
pgstat: Prevent stats reset from corrupting slotname by removing slotname
Previously PgStat_StatReplSlotEntry contained the slotname, which was mainly used when writing out the stats during shutdown, to identify the slot in the serialized data (at runtime the index in ReplicationSlotCtl->replication_slots is used, but that can change during a restart). Unfortunately the slotname was overwritten when the slot's stats were reset. That turned out to only cause "real" problems if the slot was active during the reset, triggering an assertion failure at the next pgstat_report_replslot(). In other paths the stats were re-initialized during pgstat_acquire_replslot(). Fix this by removing slotname from PgStat_StatReplSlotEntry. Instead we can get the slot's name from the slot itself. Besides fixing a bug, this also is architecturally cleaner (a name is not really statistics). This is safe because stats, for a slot removed while shut down, will not be restored at startup. In 15 the slotname is not removed, but renamed, to avoid changing the stats format. In master, bump PGSTAT_FILE_FORMAT_ID. This commit does not contain a test for the fix. I think this can only be tested by a tap test starting pg_recvlogical in the background and checking pg_recvlogical's output. That type of test is notoriously hard to be reliable, so committing it shortly before the release is wrapped seems like a bad idea. Reported-by: Jaime Casanova <jcasanov@systemguards.com.ec> Author: Andres Freund <andres@anarazel.de> Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Discussion: https://postgr.es/m/YxfagaTXUNa9ggLb@ahch-to Backpatch: 15-, where the bug was introduced in 5891c7a8ed8f
Diffstat (limited to 'src/backend/utils/adt/dbsize.c')
0 files changed, 0 insertions, 0 deletions