@@ -16,9 +16,6 @@ class BugTest(ProbackupTest, unittest.TestCase):
16
16
def test_minrecpoint_on_replica (self ):
17
17
"""
18
18
https://jira.postgrespro.ru/browse/PGPRO-2068
19
- make node without archive support, make backup which should fail
20
- check that backup status equal to ERROR
21
- check that no files where copied to backup catalogue
22
19
"""
23
20
fname = self .id ().split ('.' )[3 ]
24
21
node = self .make_simple_node (
@@ -43,6 +40,7 @@ def test_minrecpoint_on_replica(self):
43
40
self .backup_node (
44
41
backup_dir , 'node' , node , options = ['--stream' ])
45
42
43
+ # start replica
46
44
replica = self .make_simple_node (
47
45
base_dir = os .path .join (module_name , fname , 'replica' ))
48
46
replica .cleanup ()
@@ -57,6 +55,7 @@ def test_minrecpoint_on_replica(self):
57
55
replica .append_conf (
58
56
'postgresql.auto.conf' , 'restart_after_crash = off' )
59
57
58
+ # we need those later
60
59
node .safe_psql (
61
60
"postgres" ,
62
61
"CREATE EXTENSION plpythonu" )
@@ -65,29 +64,25 @@ def test_minrecpoint_on_replica(self):
65
64
"postgres" ,
66
65
"CREATE EXTENSION pageinspect" )
67
66
68
-
69
- # pg_last_wal_replay_lsn
70
67
replica .slow_start (replica = True )
71
68
72
-
69
+ # generate some data
73
70
node .pgbench_init (scale = 10 )
74
-
75
71
pgbench = node .pgbench (
76
72
stdout = subprocess .PIPE ,
77
73
stderr = subprocess .STDOUT ,
78
- options = ["-c" , "4" , "-T" , "20" ]
79
- )
74
+ options = ["-c" , "4" , "-T" , "20" ])
80
75
pgbench .wait ()
81
76
pgbench .stdout .close ()
82
77
83
78
79
+ # generate some more data and leave it in background
84
80
pgbench = node .pgbench (
85
81
stdout = subprocess .PIPE ,
86
82
stderr = subprocess .STDOUT ,
87
- options = ["-c" , "4" , "-T" , "30" ]
88
- )
83
+ options = ["-c" , "4" , "-T" , "30" ])
89
84
90
- # select pid from pg_stat_activity where backend_type in ('walreceiver', 'checkpointer', ' background writer', 'startup') ;
85
+ # get pids of background workers
91
86
startup_pid = replica .safe_psql (
92
87
'postgres' ,
93
88
"select pid from pg_stat_activity where backend_type = 'startup'" ).rstrip ()
@@ -100,34 +95,31 @@ def test_minrecpoint_on_replica(self):
100
95
'postgres' ,
101
96
"select pid from pg_stat_activity where backend_type = 'background writer'" ).rstrip ()
102
97
98
+ # wait for shared_buffer to be filled with dirty data
103
99
sleep (5 )
104
100
105
- # startup process
106
- # checkpointer
107
- # writer process
108
-
109
- # block checkpointer on UpdateLastRemovedPtr
101
+ # break checkpointer on UpdateLastRemovedPtr
110
102
gdb_checkpointer = self .gdb_attach (checkpointer_pid )
111
103
gdb_checkpointer .set_breakpoint ('UpdateLastRemovedPtr' )
112
104
gdb_checkpointer .continue_execution_until_break ()
113
105
114
- # block recovery in on UpdateMinRecoveryPoint
106
+ # break recovery on UpdateControlFile
115
107
gdb_recovery = self .gdb_attach (startup_pid )
116
108
gdb_recovery .set_breakpoint ('UpdateMinRecoveryPoint' )
117
109
gdb_recovery .continue_execution_until_break ()
118
110
gdb_recovery .set_breakpoint ('UpdateControlFile' )
119
111
gdb_recovery .continue_execution_until_break ()
120
112
121
- # stop bgwriter
122
- # gdb_bgwriter = self.gdb_attach(bgwriter_pid)
123
-
113
+ # stop data generation
124
114
pgbench .wait ()
125
115
pgbench .stdout .close ()
126
116
117
+ # kill someone, we need a crash
127
118
os .kill (int (bgwriter_pid ), 9 )
128
119
gdb_recovery ._execute ('detach' )
129
120
gdb_checkpointer ._execute ('detach' )
130
121
122
+ # just to be sure
131
123
try :
132
124
replica .stop (['-m' , 'immediate' , '-D' , replica .data_dir ])
133
125
except :
@@ -136,13 +128,8 @@ def test_minrecpoint_on_replica(self):
136
128
# Promote replica with 'immediate' target action
137
129
replica .append_conf (
138
130
'recovery.conf' , "recovery_target = 'immediate'" )
139
-
140
131
replica .append_conf (
141
132
'recovery.conf' , "recovery_target_action = 'promote'" )
142
-
143
- #os.remove(os.path.join(replica.data_dir, 'postmaster.pid'))
144
-
145
- # sleep(5)
146
133
replica .slow_start ()
147
134
148
135
script = '''
@@ -166,6 +153,7 @@ def test_minrecpoint_on_replica(self):
166
153
$$ LANGUAGE plpythonu;
167
154
'''
168
155
156
+ # Find blocks from future
169
157
replica .safe_psql (
170
158
'postgres' ,
171
159
script )
0 commit comments