@@ -13,66 +13,66 @@ sub run_test
13
13
my $test_mode = shift ;
14
14
15
15
RewindTest::setup_cluster($test_mode );
16
- RewindTest::start_master ();
16
+ RewindTest::start_primary ();
17
17
18
- # Create a test table and insert a row in master .
19
- master_psql (" CREATE TABLE tbl1 (d text)" );
20
- master_psql (" INSERT INTO tbl1 VALUES ('in master ')" );
18
+ # Create a test table and insert a row in primary .
19
+ primary_psql (" CREATE TABLE tbl1 (d text)" );
20
+ primary_psql (" INSERT INTO tbl1 VALUES ('in primary ')" );
21
21
22
22
# This test table will be used to test truncation, i.e. the table
23
- # is extended in the old master after promotion
24
- master_psql (" CREATE TABLE trunc_tbl (d text)" );
25
- master_psql (" INSERT INTO trunc_tbl VALUES ('in master ')" );
23
+ # is extended in the old primary after promotion
24
+ primary_psql (" CREATE TABLE trunc_tbl (d text)" );
25
+ primary_psql (" INSERT INTO trunc_tbl VALUES ('in primary ')" );
26
26
27
27
# This test table will be used to test the "copy-tail" case, i.e. the
28
- # table is truncated in the old master after promotion
29
- master_psql (" CREATE TABLE tail_tbl (id integer, d text)" );
30
- master_psql (" INSERT INTO tail_tbl VALUES (0, 'in master ')" );
28
+ # table is truncated in the old primary after promotion
29
+ primary_psql (" CREATE TABLE tail_tbl (id integer, d text)" );
30
+ primary_psql (" INSERT INTO tail_tbl VALUES (0, 'in primary ')" );
31
31
32
- master_psql (" CHECKPOINT" );
32
+ primary_psql (" CHECKPOINT" );
33
33
34
34
RewindTest::create_standby($test_mode );
35
35
36
- # Insert additional data on master that will be replicated to standby
37
- master_psql (" INSERT INTO tbl1 values ('in master , before promotion')" );
38
- master_psql (
39
- " INSERT INTO trunc_tbl values ('in master , before promotion')" );
40
- master_psql (
41
- " INSERT INTO tail_tbl SELECT g, 'in master , before promotion: ' || g FROM generate_series(1, 10000) g"
36
+ # Insert additional data on primary that will be replicated to standby
37
+ primary_psql (" INSERT INTO tbl1 values ('in primary , before promotion')" );
38
+ primary_psql (
39
+ " INSERT INTO trunc_tbl values ('in primary , before promotion')" );
40
+ primary_psql (
41
+ " INSERT INTO tail_tbl SELECT g, 'in primary , before promotion: ' || g FROM generate_series(1, 10000) g"
42
42
);
43
43
44
- master_psql (' CHECKPOINT' );
44
+ primary_psql (' CHECKPOINT' );
45
45
46
46
RewindTest::promote_standby();
47
47
48
- # Insert a row in the old master . This causes the master and standby
48
+ # Insert a row in the old primary . This causes the primary and standby
49
49
# to have "diverged", it's no longer possible to just apply the
50
- # standy's logs over master directory - you need to rewind.
51
- master_psql (" INSERT INTO tbl1 VALUES ('in master , after promotion')" );
50
+ # standy's logs over primary directory - you need to rewind.
51
+ primary_psql (" INSERT INTO tbl1 VALUES ('in primary , after promotion')" );
52
52
53
53
# Also insert a new row in the standby, which won't be present in the
54
- # old master .
54
+ # old primary .
55
55
standby_psql(" INSERT INTO tbl1 VALUES ('in standby, after promotion')" );
56
56
57
57
# Insert enough rows to trunc_tbl to extend the file. pg_rewind should
58
58
# truncate it back to the old size.
59
- master_psql (
60
- " INSERT INTO trunc_tbl SELECT 'in master , after promotion: ' || g FROM generate_series(1, 10000) g"
59
+ primary_psql (
60
+ " INSERT INTO trunc_tbl SELECT 'in primary , after promotion: ' || g FROM generate_series(1, 10000) g"
61
61
);
62
62
63
63
# Truncate tail_tbl. pg_rewind should copy back the truncated part
64
64
# (We cannot use an actual TRUNCATE command here, as that creates a
65
65
# whole new relfilenode)
66
- master_psql (" DELETE FROM tail_tbl WHERE id > 10" );
67
- master_psql (" VACUUM tail_tbl" );
66
+ primary_psql (" DELETE FROM tail_tbl WHERE id > 10" );
67
+ primary_psql (" VACUUM tail_tbl" );
68
68
69
69
# Before running pg_rewind, do a couple of extra tests with several
70
70
# option combinations. As the code paths taken by those tests
71
71
# do not change for the "local" and "remote" modes, just run them
72
72
# in "local" mode for simplicity's sake.
73
73
if ($test_mode eq ' local' )
74
74
{
75
- my $master_pgdata = $node_master -> data_dir;
75
+ my $primary_pgdata = $node_primary -> data_dir;
76
76
my $standby_pgdata = $node_standby -> data_dir;
77
77
78
78
# First check that pg_rewind fails if the target cluster is
@@ -82,7 +82,7 @@ sub run_test
82
82
[
83
83
' pg_rewind' , ' --debug' ,
84
84
' --source-pgdata' , $standby_pgdata ,
85
- ' --target-pgdata' , $master_pgdata ,
85
+ ' --target-pgdata' , $primary_pgdata ,
86
86
' --no-sync'
87
87
],
88
88
' pg_rewind with running target' );
@@ -94,20 +94,20 @@ sub run_test
94
94
[
95
95
' pg_rewind' , ' --debug' ,
96
96
' --source-pgdata' , $standby_pgdata ,
97
- ' --target-pgdata' , $master_pgdata ,
97
+ ' --target-pgdata' , $primary_pgdata ,
98
98
' --no-sync' , ' --no-ensure-shutdown'
99
99
],
100
100
' pg_rewind --no-ensure-shutdown with running target' );
101
101
102
102
# Stop the target, and attempt to run with a local source
103
103
# still running. This fails as pg_rewind requires to have
104
104
# a source cleanly stopped.
105
- $node_master -> stop;
105
+ $node_primary -> stop;
106
106
command_fails(
107
107
[
108
108
' pg_rewind' , ' --debug' ,
109
109
' --source-pgdata' , $standby_pgdata ,
110
- ' --target-pgdata' , $master_pgdata ,
110
+ ' --target-pgdata' , $primary_pgdata ,
111
111
' --no-sync' , ' --no-ensure-shutdown'
112
112
],
113
113
' pg_rewind with unexpected running source' );
@@ -121,30 +121,30 @@ sub run_test
121
121
[
122
122
' pg_rewind' , ' --debug' ,
123
123
' --source-pgdata' , $standby_pgdata ,
124
- ' --target-pgdata' , $master_pgdata ,
124
+ ' --target-pgdata' , $primary_pgdata ,
125
125
' --no-sync' , ' --dry-run'
126
126
],
127
127
' pg_rewind --dry-run' );
128
128
129
129
# Both clusters need to be alive moving forward.
130
130
$node_standby -> start;
131
- $node_master -> start;
131
+ $node_primary -> start;
132
132
}
133
133
134
134
RewindTest::run_pg_rewind($test_mode );
135
135
136
136
check_query(
137
137
' SELECT * FROM tbl1' ,
138
- qq( in master
139
- in master , before promotion
138
+ qq( in primary
139
+ in primary , before promotion
140
140
in standby, after promotion
141
141
) ,
142
142
' table content' );
143
143
144
144
check_query(
145
145
' SELECT * FROM trunc_tbl' ,
146
- qq( in master
147
- in master , before promotion
146
+ qq( in primary
147
+ in primary , before promotion
148
148
) ,
149
149
' truncation' );
150
150
@@ -160,7 +160,7 @@ sub run_test
160
160
skip " unix-style permissions not supported on Windows" , 1
161
161
if ($windows_os );
162
162
163
- ok(check_mode_recursive($node_master -> data_dir(), 0700, 0600),
163
+ ok(check_mode_recursive($node_primary -> data_dir(), 0700, 0600),
164
164
' check PGDATA permissions' );
165
165
}
166
166
0 commit comments