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