2 # Test pg_rewind when the target's pg_xlog directory is a symlink.
7 use File::Path qw(rmtree);
12 plan skip_all => 'symlinks not supported on Windows';
24 my $test_mode = shift;
26 my $master_xlogdir = "${TestLib::tmp_check}/xlog_master";
28 rmtree($master_xlogdir);
29 RewindTest::setup_cluster();
31 my $test_master_datadir = $node_master->data_dir;
33 # turn pg_xlog into a symlink
34 print("moving $test_master_datadir/pg_xlog to $master_xlogdir\n");
35 move("$test_master_datadir/pg_xlog", $master_xlogdir) or die;
36 symlink($master_xlogdir, "$test_master_datadir/pg_xlog") or die;
38 RewindTest::start_master();
40 # Create a test table and insert a row in master.
41 master_psql("CREATE TABLE tbl1 (d text)");
42 master_psql("INSERT INTO tbl1 VALUES ('in master')");
44 master_psql("CHECKPOINT");
46 RewindTest::create_standby();
48 # Insert additional data on master that will be replicated to standby
49 master_psql("INSERT INTO tbl1 values ('in master, before promotion')");
51 master_psql('CHECKPOINT');
53 RewindTest::promote_standby();
55 # Insert a row in the old master. This causes the master and standby
56 # to have "diverged", it's no longer possible to just apply the
57 # standy's logs over master directory - you need to rewind.
58 master_psql("INSERT INTO tbl1 VALUES ('in master, after promotion')");
60 # Also insert a new row in the standby, which won't be present in the
62 standby_psql("INSERT INTO tbl1 VALUES ('in standby, after promotion')");
64 RewindTest::run_pg_rewind($test_mode);
69 in master, before promotion
70 in standby, after promotion
74 RewindTest::clean_rewind_test();
77 # Run the test in both modes