Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit68b77a0

Browse files
authored
[PBCKP-150] Reading buffer is flushed each time we verify the checksum. (#487)
The race condition is covered with a unit-test, the buffer is flushednow so each of 300 reads requests the data from the disc.
1 parent4b2df86 commit68b77a0

File tree

5 files changed

+88
-1
lines changed

5 files changed

+88
-1
lines changed

‎.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ env:
4747
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=REL_13_STABLE MODE=replica
4848
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=OFF MODE=retention
4949
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=REL_13_STABLE MODE=restore
50+
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=REL_13_STABLE MODE=time_consuming
5051

5152
jobs:
5253
allow_failures:

‎src/data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ prepare_page(pgFile *file, XLogRecPtr prev_backup_start_lsn,
349349
Assert(false);
350350
}
351351
}
352+
/* avoid re-reading once buffered data, flushing on further attempts, see PBCKP-150 */
353+
fflush(in);
352354
}
353355

354356
/*

‎tests/Readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Run suit of basic simple tests:
4141
Run ptrack tests:
4242
export PG_PROBACKUP_PTRACK=ON
4343
44+
Run long (time consuming) tests:
45+
export PG_PROBACKUP_LONG=ON
4446
4547
Usage:
4648
sudo echo 0 > /proc/sys/kernel/yama/ptrace_scope

‎tests/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
compression,page,ptrack,archive,exclude,cfs_backup,cfs_restore, \
88
cfs_validate_backup,auth_test,time_stamp,logging, \
99
locking,remote,external,config,checkdb,set_backup,incr_restore, \
10-
catchup,CVE_2018_1058
10+
catchup,CVE_2018_1058,time_consuming
1111

1212

1313
defload_tests(loader,tests,pattern):
@@ -21,6 +21,12 @@ def load_tests(loader, tests, pattern):
2121
ifos.environ['PG_PROBACKUP_PTRACK']=='ON':
2222
suite.addTests(loader.loadTestsFromModule(ptrack))
2323

24+
# PG_PROBACKUP_LONG section for tests that are long
25+
# by design e.g. they contain loops, sleeps and so on
26+
if'PG_PROBACKUP_LONG'inos.environ:
27+
ifos.environ['PG_PROBACKUP_LONG']=='ON':
28+
suite.addTests(loader.loadTestsFromModule(time_consuming))
29+
2430
# suite.addTests(loader.loadTestsFromModule(auth_test))
2531
suite.addTests(loader.loadTestsFromModule(archive))
2632
suite.addTests(loader.loadTestsFromModule(backup))

‎tests/time_consuming.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
importos
2+
importunittest
3+
from .helpers.ptrack_helpersimportProbackupTest
4+
importsubprocess
5+
fromtimeimportsleep
6+
7+
module_name='time_consuming'
8+
9+
classTimeConsumingTests(ProbackupTest,unittest.TestCase):
10+
deftest_pbckp150(self):
11+
"""
12+
https://jira.postgrespro.ru/browse/PBCKP-150
13+
create a node filled with pgbench
14+
create FULL backup followed by PTRACK backup
15+
run pgbench, vacuum VERBOSE FULL and ptrack backups in parallel
16+
"""
17+
# init node
18+
fname=self.id().split('.')[3]
19+
node=self.make_simple_node(
20+
base_dir=os.path.join(module_name,fname,'node'),
21+
set_replication=True,
22+
initdb_params=['--data-checksums'])
23+
node.append_conf('postgresql.conf',
24+
"""
25+
max_connections = 100
26+
wal_keep_size = 16000
27+
ptrack.map_size = 1
28+
shared_preload_libraries='ptrack'
29+
log_statement = 'none'
30+
fsync = off
31+
log_checkpoints = on
32+
autovacuum = off
33+
""")
34+
35+
# init probackup and add an instance
36+
backup_dir=os.path.join(self.tmp_path,module_name,fname,'backup')
37+
self.init_pb(backup_dir)
38+
self.add_instance(backup_dir,'node',node)
39+
40+
# run the node and init ptrack
41+
node.slow_start()
42+
node.safe_psql("postgres","CREATE EXTENSION ptrack")
43+
# populate it with pgbench
44+
node.pgbench_init(scale=5)
45+
46+
# FULL backup followed by PTRACK backup
47+
self.backup_node(backup_dir,'node',node,options=['--stream'])
48+
self.backup_node(backup_dir,'node',node,backup_type='ptrack',options=['--stream'])
49+
50+
# run ordinary pgbench scenario to imitate some activity and another pgbench for vacuuming in parallel
51+
nBenchDuration=30
52+
pgbench=node.pgbench(options=['-c','20','-j','8','-T',str(nBenchDuration)])
53+
withopen('/tmp/pbckp150vacuum.sql','w')asf:
54+
f.write('VACUUM (FULL) pgbench_accounts, pgbench_tellers, pgbench_history; SELECT pg_sleep(1);\n')
55+
pgbenchval=node.pgbench(options=['-c','1','-f','/tmp/pbckp150vacuum.sql','-T',str(nBenchDuration)])
56+
57+
# several PTRACK backups
58+
foriinrange(nBenchDuration):
59+
print("[{}] backing up PTRACK diff...".format(i+1))
60+
self.backup_node(backup_dir,'node',node,backup_type='ptrack',options=['--stream','--log-level-console','VERBOSE'])
61+
sleep(0.1)
62+
# if the activity pgbench has finished, stop backing up
63+
ifpgbench.poll()isnotNone:
64+
break
65+
66+
pgbench.kill()
67+
pgbenchval.kill()
68+
pgbench.wait()
69+
pgbenchval.wait()
70+
71+
backups=self.show_pb(backup_dir,'node')
72+
forbinbackups:
73+
self.assertEqual("OK",b['status'])
74+
75+
# Clean after yourself
76+
self.del_test_dir(module_name,fname)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp