Skip to content

Commit 8bbf1f4

Browse files
committed
tests: minor fixes and comments for test_minrecpoint_on_replica()
1 parent 841e608 commit 8bbf1f4

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed

tests/pgpro2068.py

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ class BugTest(ProbackupTest, unittest.TestCase):
1616
def test_minrecpoint_on_replica(self):
1717
"""
1818
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
2219
"""
2320
fname = self.id().split('.')[3]
2421
node = self.make_simple_node(
@@ -43,6 +40,7 @@ def test_minrecpoint_on_replica(self):
4340
self.backup_node(
4441
backup_dir, 'node', node, options=['--stream'])
4542

43+
# start replica
4644
replica = self.make_simple_node(
4745
base_dir=os.path.join(module_name, fname, 'replica'))
4846
replica.cleanup()
@@ -57,6 +55,7 @@ def test_minrecpoint_on_replica(self):
5755
replica.append_conf(
5856
'postgresql.auto.conf', 'restart_after_crash = off')
5957

58+
# we need those later
6059
node.safe_psql(
6160
"postgres",
6261
"CREATE EXTENSION plpythonu")
@@ -65,29 +64,25 @@ def test_minrecpoint_on_replica(self):
6564
"postgres",
6665
"CREATE EXTENSION pageinspect")
6766

68-
69-
# pg_last_wal_replay_lsn
7067
replica.slow_start(replica=True)
7168

72-
69+
# generate some data
7370
node.pgbench_init(scale=10)
74-
7571
pgbench = node.pgbench(
7672
stdout=subprocess.PIPE,
7773
stderr=subprocess.STDOUT,
78-
options=["-c", "4", "-T", "20"]
79-
)
74+
options=["-c", "4", "-T", "20"])
8075
pgbench.wait()
8176
pgbench.stdout.close()
8277

8378

79+
# generate some more data and leave it in background
8480
pgbench = node.pgbench(
8581
stdout=subprocess.PIPE,
8682
stderr=subprocess.STDOUT,
87-
options=["-c", "4", "-T", "30"]
88-
)
83+
options=["-c", "4", "-T", "30"])
8984

90-
# select pid from pg_stat_activity where backend_type in ('walreceiver', 'checkpointer', 'background writer', 'startup') ;
85+
# get pids of background workers
9186
startup_pid = replica.safe_psql(
9287
'postgres',
9388
"select pid from pg_stat_activity where backend_type = 'startup'").rstrip()
@@ -100,34 +95,31 @@ def test_minrecpoint_on_replica(self):
10095
'postgres',
10196
"select pid from pg_stat_activity where backend_type = 'background writer'").rstrip()
10297

98+
# wait for shared_buffer to be filled with dirty data
10399
sleep(5)
104100

105-
# startup process
106-
# checkpointer
107-
# writer process
108-
109-
# block checkpointer on UpdateLastRemovedPtr
101+
# break checkpointer on UpdateLastRemovedPtr
110102
gdb_checkpointer = self.gdb_attach(checkpointer_pid)
111103
gdb_checkpointer.set_breakpoint('UpdateLastRemovedPtr')
112104
gdb_checkpointer.continue_execution_until_break()
113105

114-
# block recovery in on UpdateMinRecoveryPoint
106+
# break recovery on UpdateControlFile
115107
gdb_recovery = self.gdb_attach(startup_pid)
116108
gdb_recovery.set_breakpoint('UpdateMinRecoveryPoint')
117109
gdb_recovery.continue_execution_until_break()
118110
gdb_recovery.set_breakpoint('UpdateControlFile')
119111
gdb_recovery.continue_execution_until_break()
120112

121-
# stop bgwriter
122-
# gdb_bgwriter = self.gdb_attach(bgwriter_pid)
123-
113+
# stop data generation
124114
pgbench.wait()
125115
pgbench.stdout.close()
126116

117+
# kill someone, we need a crash
127118
os.kill(int(bgwriter_pid), 9)
128119
gdb_recovery._execute('detach')
129120
gdb_checkpointer._execute('detach')
130121

122+
# just to be sure
131123
try:
132124
replica.stop(['-m', 'immediate', '-D', replica.data_dir])
133125
except:
@@ -136,13 +128,8 @@ def test_minrecpoint_on_replica(self):
136128
# Promote replica with 'immediate' target action
137129
replica.append_conf(
138130
'recovery.conf', "recovery_target = 'immediate'")
139-
140131
replica.append_conf(
141132
'recovery.conf', "recovery_target_action = 'promote'")
142-
143-
#os.remove(os.path.join(replica.data_dir, 'postmaster.pid'))
144-
145-
# sleep(5)
146133
replica.slow_start()
147134

148135
script = '''
@@ -166,6 +153,7 @@ def test_minrecpoint_on_replica(self):
166153
$$ LANGUAGE plpythonu;
167154
'''
168155

156+
# Find blocks from future
169157
replica.safe_psql(
170158
'postgres',
171159
script)

0 commit comments

Comments
 (0)