Commit b1086767 authored by Michael Paquier's avatar Michael Paquier

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
parent ab5fcf2b
...@@ -4,7 +4,7 @@ use warnings; ...@@ -4,7 +4,7 @@ use warnings;
use PostgresNode; use PostgresNode;
use TestLib; use TestLib;
use Test::More tests => 20; use Test::More tests => 24;
my $psql_out = ''; my $psql_out = '';
my $psql_rc = ''; my $psql_rc = '';
...@@ -334,6 +334,60 @@ $cur_standby->psql( ...@@ -334,6 +334,60 @@ $cur_standby->psql(
stdout => \$psql_out); stdout => \$psql_out);
is($psql_out, '1', "Replay prepared transaction with DDL"); 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. # Verify expected data appears on both servers.
############################################################################### ###############################################################################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment