mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-30 17:41:16 +02:00
Add TAP tests for 2PC post-commit callbacks of multixacts at recovery
The current set of TAP tests for two-phase transactions include some coverage for post-commit callbacks of multixact, but it lacked tests for testing the recovery of those callbacks. This commit adds some tests with soft and hard restarts in this case, using transactions which include DDLs. Author: Michael Paquier Reviewed-by: Oleksii Kliukin Discussion: https://postgr.es/m/20190221055431.GO15532@paquier.xyz
This commit is contained in:
parent
ab5fcf2b04
commit
b108676708
@ -4,7 +4,7 @@ use warnings;
|
||||
|
||||
use PostgresNode;
|
||||
use TestLib;
|
||||
use Test::More tests => 20;
|
||||
use Test::More tests => 24;
|
||||
|
||||
my $psql_out = '';
|
||||
my $psql_rc = '';
|
||||
@ -334,6 +334,60 @@ $cur_standby->psql(
|
||||
stdout => \$psql_out);
|
||||
is($psql_out, '1', "Replay prepared transaction with DDL");
|
||||
|
||||
###############################################################################
|
||||
# Check recovery of prepared transaction with DDL inside after a hard restart
|
||||
# of the master.
|
||||
###############################################################################
|
||||
|
||||
$cur_master->psql(
|
||||
'postgres', "
|
||||
BEGIN;
|
||||
CREATE TABLE t_009_tbl3 (id int, msg text);
|
||||
SAVEPOINT s1;
|
||||
INSERT INTO t_009_tbl3 VALUES (28, 'issued to ${cur_master_name}');
|
||||
PREPARE TRANSACTION 'xact_009_14';
|
||||
BEGIN;
|
||||
CREATE TABLE t_009_tbl4 (id int, msg text);
|
||||
SAVEPOINT s1;
|
||||
INSERT INTO t_009_tbl4 VALUES (29, 'issued to ${cur_master_name}');
|
||||
PREPARE TRANSACTION 'xact_009_15';");
|
||||
|
||||
$cur_master->teardown_node;
|
||||
$cur_master->start;
|
||||
|
||||
$psql_rc = $cur_master->psql('postgres', "COMMIT PREPARED 'xact_009_14'");
|
||||
is($psql_rc, '0', 'Commit prepared transaction after teardown');
|
||||
|
||||
$psql_rc = $cur_master->psql('postgres', "ROLLBACK PREPARED 'xact_009_15'");
|
||||
is($psql_rc, '0', 'Rollback prepared transaction after teardown');
|
||||
|
||||
###############################################################################
|
||||
# Check recovery of prepared transaction with DDL inside after a soft restart
|
||||
# of the master.
|
||||
###############################################################################
|
||||
|
||||
$cur_master->psql(
|
||||
'postgres', "
|
||||
BEGIN;
|
||||
CREATE TABLE t_009_tbl5 (id int, msg text);
|
||||
SAVEPOINT s1;
|
||||
INSERT INTO t_009_tbl5 VALUES (30, 'issued to ${cur_master_name}');
|
||||
PREPARE TRANSACTION 'xact_009_16';
|
||||
BEGIN;
|
||||
CREATE TABLE t_009_tbl6 (id int, msg text);
|
||||
SAVEPOINT s1;
|
||||
INSERT INTO t_009_tbl6 VALUES (31, 'issued to ${cur_master_name}');
|
||||
PREPARE TRANSACTION 'xact_009_17';");
|
||||
|
||||
$cur_master->stop;
|
||||
$cur_master->start;
|
||||
|
||||
$psql_rc = $cur_master->psql('postgres', "COMMIT PREPARED 'xact_009_16'");
|
||||
is($psql_rc, '0', 'Commit prepared transaction after restart');
|
||||
|
||||
$psql_rc = $cur_master->psql('postgres', "ROLLBACK PREPARED 'xact_009_17'");
|
||||
is($psql_rc, '0', 'Rollback prepared transaction after restart');
|
||||
|
||||
###############################################################################
|
||||
# Verify expected data appears on both servers.
|
||||
###############################################################################
|
||||
|
Loading…
Reference in New Issue
Block a user