Skip to content

Commit 4869a56

Browse files
committed
[PBCKP-336] Fix segno calculation.
It were lost during fork-name detection fix at eaf3b14 . And since there were no basic test for this, it were not detected.
1 parent b17669c commit 4869a56

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

src/dir.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1786,13 +1786,16 @@ is_forkname(char *name, size_t *pos, const char *forkname)
17861786
}
17871787

17881788
#define OIDCHARS 10
1789+
#define MAXSEGNO (((uint64_t)1<<32)/RELSEG_SIZE-1)
1790+
#define SEGNOCHARS 5 /* when BLCKSZ == (1<<15) */
17891791

17901792
/* Set forkName if possible */
17911793
bool
17921794
set_forkname(pgFile *file)
17931795
{
17941796
size_t i = 0;
17951797
uint64_t oid = 0; /* use 64bit to not check for overflow in a loop */
1798+
uint64_t segno = 0;
17961799

17971800
/* pretend it is not relation file */
17981801
file->relOid = 0;
@@ -1823,8 +1826,15 @@ set_forkname(pgFile *file)
18231826
/* /^\d+(_(vm|fsm|init|ptrack))?\.\d+$/ */
18241827
if (file->name[i] == '.' && isdigit(file->name[i+1]))
18251828
{
1829+
size_t start = i+1;
18261830
for (i++; isdigit(file->name[i]); i++)
1827-
;
1831+
{
1832+
if (i == start && file->name[i] == '0')
1833+
return false;
1834+
segno = segno * 10 + file->name[i] - '0';
1835+
}
1836+
if (i - start > SEGNOCHARS || segno > MAXSEGNO)
1837+
return false;
18281838
}
18291839

18301840
/* CFS "fork name" */
@@ -1843,6 +1853,7 @@ set_forkname(pgFile *file)
18431853
}
18441854

18451855
file->relOid = oid;
1856+
file->segno = segno;
18461857
file->is_datafile = file->forkName == none;
18471858
return true;
18481859
}

tests/backup.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,38 @@
1313

1414
class BackupTest(ProbackupTest, unittest.TestCase):
1515

16+
def test_basic_full_backup(self):
17+
"""
18+
Just test full backup with at least two segments
19+
"""
20+
fname = self.id().split('.')[3]
21+
node = self.make_simple_node(
22+
base_dir=os.path.join(module_name, fname, 'node'),
23+
initdb_params=['--data-checksums'],
24+
# we need to write a lot. Lets speedup a bit.
25+
pg_options={"fsync": "off", "synchronous_commit": "off"})
26+
27+
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
28+
self.init_pb(backup_dir)
29+
self.add_instance(backup_dir, 'node', node)
30+
self.set_archiving(backup_dir, 'node', node)
31+
node.slow_start()
32+
33+
# Fill with data
34+
# Have to use scale=100 to create second segment.
35+
node.pgbench_init(scale=100, no_vacuum=True)
36+
37+
# FULL
38+
backup_id = self.backup_node(backup_dir, 'node', node)
39+
40+
out = self.validate_pb(backup_dir, 'node', backup_id)
41+
self.assertIn(
42+
"INFO: Backup {0} is valid".format(backup_id),
43+
out)
44+
45+
# Clean after yourself
46+
self.del_test_dir(module_name, fname)
47+
1648
# @unittest.skip("skip")
1749
# @unittest.expectedFailure
1850
# PGPRO-707

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy