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

Appearance settings

Commit 196a70b

Browse filesBrowse files
committed
Fixes for ptrack tests (test_ptrack_vacuum, test_ptrack_vacuum_bits_frozen, test_ptrack_vacuum_bits_visibility):
this is workaround for spgist metadata update bug (PGPRO-5707)
1 parent fd4b75a commit 196a70b
Copy full SHA for 196a70b

File tree

2 files changed

+51
-21
lines changed
Filter options

2 files changed

+51
-21
lines changed

‎tests/helpers/ptrack_helpers.py

Copy file name to clipboardExpand all lines: tests/helpers/ptrack_helpers.py
+44-18Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,8 +1714,30 @@ def pgdata_content(self, pgdata, ignore_ptrack=True, exclude_dirs=None):
17141714

17151715
return directory_dict
17161716

1717-
def compare_pgdata(self, original_pgdata, restored_pgdata):
1718-
""" return dict with directory content. DO IT BEFORE RECOVERY"""
1717+
def get_known_bugs_comparision_exclusion_dict(self, node):
1718+
""" get dict of known datafiles difference, that can be used in compare_pgdata() """
1719+
comparision_exclusion_dict = dict()
1720+
1721+
# bug in spgist metapage update (PGPRO-5707)
1722+
spgist_filelist = node.safe_psql(
1723+
"postgres",
1724+
"SELECT pg_catalog.pg_relation_filepath(pg_class.oid) "
1725+
"FROM pg_am, pg_class "
1726+
"WHERE pg_am.amname = 'spgist' "
1727+
"AND pg_class.relam = pg_am.oid"
1728+
).decode('utf-8').rstrip().splitlines()
1729+
for filename in spgist_filelist:
1730+
comparision_exclusion_dict[filename] = set([0])
1731+
1732+
return comparision_exclusion_dict
1733+
1734+
1735+
def compare_pgdata(self, original_pgdata, restored_pgdata, exclusion_dict = dict()):
1736+
"""
1737+
return dict with directory content. DO IT BEFORE RECOVERY
1738+
exclusion_dict is used for exclude files (and it block_no) from comparision
1739+
it is a dict with relative filenames as keys and set of block numbers as values
1740+
"""
17191741
fail = False
17201742
error_message = 'Restored PGDATA is not equal to original!\n'
17211743

@@ -1777,16 +1799,17 @@ def compare_pgdata(self, original_pgdata, restored_pgdata):
17771799
original_pgdata['files'][file]['md5'] !=
17781800
restored_pgdata['files'][file]['md5']
17791801
):
1780-
fail = True
1781-
error_message += (
1782-
'\nFile Checksumm mismatch.\n'
1783-
'File_old: {0}\nChecksumm_old: {1}\n'
1784-
'File_new: {2}\nChecksumm_new: {3}\n').format(
1785-
os.path.join(original_pgdata['pgdata'], file),
1786-
original_pgdata['files'][file]['md5'],
1787-
os.path.join(restored_pgdata['pgdata'], file),
1788-
restored_pgdata['files'][file]['md5']
1789-
)
1802+
if file not in exclusion_dict:
1803+
fail = True
1804+
error_message += (
1805+
'\nFile Checksum mismatch.\n'
1806+
'File_old: {0}\nChecksum_old: {1}\n'
1807+
'File_new: {2}\nChecksum_new: {3}\n').format(
1808+
os.path.join(original_pgdata['pgdata'], file),
1809+
original_pgdata['files'][file]['md5'],
1810+
os.path.join(restored_pgdata['pgdata'], file),
1811+
restored_pgdata['files'][file]['md5']
1812+
)
17901813

17911814
if original_pgdata['files'][file]['is_datafile']:
17921815
for page in original_pgdata['files'][file]['md5_per_page']:
@@ -1802,13 +1825,16 @@ def compare_pgdata(self, original_pgdata, restored_pgdata):
18021825
)
18031826
continue
18041827

1805-
if original_pgdata['files'][file][
1806-
'md5_per_page'][page] != restored_pgdata[
1807-
'files'][file]['md5_per_page'][page]:
1828+
if not (file in exclusion_dict and page in exclusion_dict[file]):
1829+
if (
1830+
original_pgdata['files'][file]['md5_per_page'][page] !=
1831+
restored_pgdata['files'][file]['md5_per_page'][page]
1832+
):
1833+
fail = True
18081834
error_message += (
1809-
'\n Page checksumm mismatch: {0}\n '
1810-
' PAGE Checksumm_old: {1}\n '
1811-
' PAGE Checksumm_new: {2}\n '
1835+
'\n Page checksum mismatch: {0}\n '
1836+
' PAGE Checksum_old: {1}\n '
1837+
' PAGE Checksum_new: {2}\n '
18121838
' File: {3}\n'
18131839
).format(
18141840
page,

‎tests/ptrack.py

Copy file name to clipboardExpand all lines: tests/ptrack.py
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3210,6 +3210,8 @@ def test_ptrack_vacuum(self):
32103210
idx_ptrack[i]['type'],
32113211
idx_ptrack[i]['column']))
32123212

3213+
comparision_exclusion = self.get_known_bugs_comparision_exclusion_dict(node)
3214+
32133215
node.safe_psql('postgres', 'vacuum t_heap')
32143216
node.safe_psql('postgres', 'checkpoint')
32153217

@@ -3253,7 +3255,7 @@ def test_ptrack_vacuum(self):
32533255
self.restore_node(backup_dir, 'node', node)
32543256

32553257
pgdata_restored = self.pgdata_content(node.data_dir)
3256-
self.compare_pgdata(pgdata, pgdata_restored)
3258+
self.compare_pgdata(pgdata, pgdata_restored, comparision_exclusion)
32573259

32583260
# Clean after yourself
32593261
self.del_test_dir(module_name, self.fname)
@@ -3403,6 +3405,7 @@ def test_ptrack_vacuum_bits_frozen(self):
34033405
idx_ptrack[i]['type'],
34043406
idx_ptrack[i]['column']))
34053407

3408+
comparision_exclusion = self.get_known_bugs_comparision_exclusion_dict(node)
34063409
node.safe_psql('postgres', 'checkpoint')
34073410

34083411
self.backup_node(
@@ -3438,7 +3441,7 @@ def test_ptrack_vacuum_bits_frozen(self):
34383441
self.restore_node(backup_dir, 'node', node)
34393442

34403443
pgdata_restored = self.pgdata_content(node.data_dir)
3441-
self.compare_pgdata(pgdata, pgdata_restored)
3444+
self.compare_pgdata(pgdata, pgdata_restored, comparision_exclusion)
34423445

34433446
# Clean after yourself
34443447
self.del_test_dir(module_name, self.fname)
@@ -3579,6 +3582,7 @@ def test_ptrack_vacuum_bits_visibility(self):
35793582
i, idx_ptrack[i]['relation'],
35803583
idx_ptrack[i]['type'], idx_ptrack[i]['column']))
35813584

3585+
comparision_exclusion = self.get_known_bugs_comparision_exclusion_dict(node)
35823586
node.safe_psql('postgres', 'checkpoint')
35833587

35843588
self.backup_node(
@@ -3614,7 +3618,7 @@ def test_ptrack_vacuum_bits_visibility(self):
36143618
self.restore_node(backup_dir, 'node', node)
36153619

36163620
pgdata_restored = self.pgdata_content(node.data_dir)
3617-
self.compare_pgdata(pgdata, pgdata_restored)
3621+
self.compare_pgdata(pgdata, pgdata_restored, comparision_exclusion)
36183622

36193623
# Clean after yourself
36203624
self.del_test_dir(module_name, self.fname)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.