-- reset stats for one slot, others should be unaffected SELECT pg_stat_reset_replication_slot('regression_slot_stats1'); SELECT slot_name, spill_txns = 0AS spill_txns, spill_count = 0AS spill_count, total_txns > 0AS total_txns, total_bytes > 0AS total_bytes FROM pg_stat_replication_slots ORDERBY slot_name;
-- reset stats for all slots SELECT pg_stat_reset_replication_slot(NULL); SELECT slot_name, spill_txns = 0AS spill_txns, spill_count = 0AS spill_count, total_txns > 0AS total_txns, total_bytes > 0AS total_bytes FROM pg_stat_replication_slots ORDERBY slot_name;
-- verify accessing/resetting stats for non-existent slot does something reasonable SELECT * FROM pg_stat_get_replication_slot('do-not-exist'); SELECT pg_stat_reset_replication_slot('do-not-exist'); SELECT * FROM pg_stat_get_replication_slot('do-not-exist');
-- spilling the xact
BEGIN; INSERTINTO stats_test SELECT'serialize-topbig--1:'||g.i FROM generate_series(1, 5000) g(i); COMMIT; SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot_stats1', NULL, NULL, 'skip-empty-xacts', '1');
-- Check stats. We can't test the exact stats count as that can vary if any -- background transaction (say by autovacuum) happens in parallel to the main -- transaction. SELECT pg_stat_force_next_flush(); SELECT slot_name, spill_txns > 0AS spill_txns, spill_count > 0AS spill_count FROM pg_stat_replication_slots;
-- The INSERT changes are large enough to be spilled but will not be, because -- the transaction is aborted. The logical decoding skips collecting further -- changes too. The transaction is prepared to make sure the decoding processes -- the aborted transaction.
BEGIN; INSERTINTO stats_test SELECT'serialize-toobig--1:'||g.i FROM generate_series(1, 5000) g(i);
PREPARE TRANSACTION 'test1_abort';
ROLLBACK PREPARED 'test1_abort'; SELECT count(*) FROM pg_logical_slot_get_changes('regression_slot_stats4_twophase', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
-- Verify that the decoding doesn't spill already-aborted transaction's changes. SELECT pg_stat_force_next_flush(); SELECT slot_name, spill_txns, spill_count FROM pg_stat_replication_slots WHERE slot_name = 'regression_slot_stats4_twophase';
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.