Use HTAB for replication slot statistics.
Amit Kapila <akapila@postgresql.org>
Use HTAB for replication slot statistics. Previously, we used to use the array of size max_replication_slots to store stats for replication slots. But that had two problems in the cases where a message for dropping a slot gets lost: 1) the stats for the new slot are not recorded if the array is full and 2) writing beyond the end of the array if the user reduces the max_replication_slots. This commit uses HTAB for replication slot statistics, resolving both problems. Now, pgstat_vacuum_stat() search for all the dead replication slots in stats hashtable and tell the collector to remove them. To avoid showing the stats for the already-dropped slots, pg_stat_replication_slots view searches slot stats by the slot name taken from pg_replication_slots. Also, we send a message for creating a slot at slot creation, initializing the stats. This reduces the possibility that the stats are accumulated into the old slot stats when a message for dropping a slot gets lost. Reported-by: Andres Freund Author: Sawada Masahiko, test case by Vignesh C Reviewed-by: Amit Kapila, Vignesh C, Dilip Kumar Discussion: https://postgr.es/m/20210319185247.ldebgpdaxsowiflw@alap3.anarazel.de
Files
| Path | Change | +/− |
|---|---|---|
| contrib/test_decoding/t/001_repl_stats.pl | modified | +54 −15 |
| src/backend/catalog/system_views.sql | modified | +16 −14 |
| src/backend/postmaster/pgstat.c | modified | +196 −144 |
| src/backend/replication/logical/logical.c | modified | +1 −1 |
| src/backend/replication/slot.c | modified | +15 −13 |
| src/backend/utils/adt/pgstatfuncs.c | modified | +88 −58 |
| src/include/catalog/catversion.h | modified | +1 −1 |
| src/include/catalog/pg_proc.dat | modified | +7 −7 |
| src/include/pgstat.h | modified | +6 −4 |
| src/include/replication/slot.h | modified | +1 −1 |
| src/test/regress/expected/rules.out | modified | +3 −1 |
| src/tools/pgindent/typedefs.list | modified | +1 −1 |
Discussion
- Replication slot stats misgivings 201 messages · 2021-03-19 → 2021-05-25