mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-30 01:07:20 +02:00
The regression tests for contrib/test_decoding regularly failed on postgres instances that were very slow. Either because the hardware itself was slow or because very expensive debugging options like CLOBBER_CACHE_ALWAYS were used. The reason they failed was just that some additional transactions were decoded. Analyze and vacuum, triggered by autovac. To fix just add a option to test_decoding to only display transactions in which a change was actually displayed. That's not pretty because it removes information from the tests; but better than constantly failing tests in very likely harmless ways. Backpatch to 9.4 where logical decoding was introduced. Discussion: 20140629142511.GA26930@awork2.anarazel.de
42 lines
1.4 KiB
PL/PgSQL
42 lines
1.4 KiB
PL/PgSQL
-- predictability
|
|
SET synchronous_commit = on;
|
|
|
|
-- fail because we're creating a slot while in an xact with xid
|
|
BEGIN;
|
|
SELECT txid_current() = 0;
|
|
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
|
|
ROLLBACK;
|
|
|
|
-- fail because we're creating a slot while in an subxact whose topxact has a xid
|
|
BEGIN;
|
|
SELECT txid_current() = 0;
|
|
SAVEPOINT barf;
|
|
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
|
|
ROLLBACK TO SAVEPOINT barf;
|
|
ROLLBACK;
|
|
|
|
-- succeed, outside tx.
|
|
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
|
|
SELECT 'stop' FROM pg_drop_replication_slot('regression_slot');
|
|
|
|
-- succeed, in tx without xid.
|
|
BEGIN;
|
|
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
|
|
COMMIT;
|
|
|
|
CREATE TABLE nobarf(id serial primary key, data text);
|
|
INSERT INTO nobarf(data) VALUES('1');
|
|
|
|
-- decoding works in transaction with xid
|
|
BEGIN;
|
|
SELECT txid_current() = 0;
|
|
-- don't show yet, haven't committed
|
|
INSERT INTO nobarf(data) VALUES('2');
|
|
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
|
COMMIT;
|
|
|
|
INSERT INTO nobarf(data) VALUES('3');
|
|
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
|
|
|
SELECT 'stop' FROM pg_drop_replication_slot('regression_slot');
|