You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pgstat: add/extend tests for resetting various kinds of stats.
- subscriber stats reset path was untested
- slot stat sreset path for all slots was untested
- pg_stat_database.sessions etc was untested
- pg_stat_reset_shared() was untested, for any kind of shared stats
- pg_stat_reset() was untested
Author: Melanie Plageman <melanieplageman@gmail.com>
Author: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/20220303021600.hs34ghqcw6zcokdh@alap3.anarazel.de
SELECT slot_name, spill_txns = 0 AS spill_txns, spill_count = 0 AS spill_count, total_txns > 0 AS total_txns, total_bytes > 0 AS total_bytes FROM pg_stat_replication_slots;
SELECT slot_name, spill_txns = 0 AS spill_txns, spill_count = 0 AS spill_count, total_txns > 0 AS total_txns, total_bytes > 0 AS total_bytes FROM pg_stat_replication_slots ORDER BY slot_name;
SELECT slot_name, spill_txns = 0 AS spill_txns, spill_count = 0 AS spill_count, total_txns > 0 AS total_txns, total_bytes > 0 AS total_bytes FROM pg_stat_replication_slots ORDER BY slot_name;
SELECT slot_name, spill_txns = 0 AS spill_txns, spill_count = 0 AS spill_count, total_txns > 0 AS total_txns, total_bytes > 0 AS total_bytes FROM pg_stat_replication_slots ORDER BY slot_name;
qq(SELECT stats_reset > '$reset1'::timestamptz, total_bytes = 0 FROM pg_stat_replication_slots WHERE slot_name = '$stats_test_slot1')
235
+
), qq(t|t), qq(Check that reset timestamp is later after the second reset of stats for slot '$stats_test_slot1' and confirm total_bytes was set to 0.));
236
+
237
+
# Check that test slot 2 has NULL in reset timestamp
238
+
is($node_primary->safe_psql(
239
+
'postgres',
240
+
qq(SELECT stats_reset IS NULL FROM pg_stat_replication_slots WHERE slot_name = '$stats_test_slot2')
241
+
), qq(t), qq(Stats_reset is NULL for slot '$stats_test_slot2' before reset.));
242
+
243
+
# Get reset value again for test slot 1
244
+
$reset1 = $node_primary->safe_psql(
245
+
'postgres',
246
+
qq(SELECT stats_reset FROM pg_stat_replication_slots WHERE slot_name = '$stats_test_slot1')
247
+
);
248
+
249
+
# Reset stats for all replication slots
250
+
$node_primary->safe_psql(
251
+
'postgres',
252
+
qq(SELECT pg_stat_reset_replication_slot(NULL))
253
+
);
254
+
255
+
# Check that test slot 2 reset timestamp is no longer NULL after reset
256
+
is($node_primary->safe_psql(
257
+
'postgres',
258
+
qq(SELECT stats_reset IS NOT NULL FROM pg_stat_replication_slots WHERE slot_name = '$stats_test_slot2')
259
+
), qq(t), qq(Stats_reset is not NULL for slot '$stats_test_slot2' after reset all.));
260
+
261
+
is($node_primary->safe_psql(
262
+
'postgres',
263
+
qq(SELECT stats_reset > '$reset1'::timestamptz FROM pg_stat_replication_slots WHERE slot_name = '$stats_test_slot1')
264
+
), qq(t), qq(Check that reset timestamp is later after resetting stats for slot '$stats_test_slot1' again.));
0 commit comments