Skip to content

Commit 85b3003

Browse files
committed
Merge branch 'master' into stable
2 parents 2440638 + 3fe942f commit 85b3003

File tree

3 files changed

+118
-10
lines changed

3 files changed

+118
-10
lines changed

src/parsexlog.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ extractPageMap(const char *archivedir, XLogRecPtr startpoint, TimeLineID tli,
305305
/* By default there is some error */
306306
thread_args[i].ret = 1;
307307

308+
threads_need++;
309+
308310
/* Adjust startpoint to the next thread */
309311
if (nextSegNoToRead == 0)
310312
XLByteToSeg(startpoint, nextSegNoToRead);
@@ -317,10 +319,6 @@ extractPageMap(const char *archivedir, XLogRecPtr startpoint, TimeLineID tli,
317319
if (nextSegNoToRead > endSegNo)
318320
break;
319321
XLogSegNoOffsetToRecPtr(nextSegNoToRead, 0, startpoint);
320-
/* Skip over the page header */
321-
startpoint += SizeOfXLogLongPHD;
322-
323-
threads_need++;
324322
}
325323

326324
/* Run threads */

tests/merge.py

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ def test_merge_ptrack_truncate(self):
375375
'wal_level': 'replica',
376376
'max_wal_senders': '2',
377377
'checkpoint_timeout': '300s',
378-
'autovacuum': 'off'
378+
'autovacuum': 'off',
379+
'ptrack_enable': 'on'
379380
}
380381
)
381382
node_restored = self.make_simple_node(
@@ -410,7 +411,7 @@ def test_merge_ptrack_truncate(self):
410411
"vacuum t_heap")
411412

412413
self.backup_node(
413-
backup_dir, 'node', node, backup_type='delta')
414+
backup_dir, 'node', node, backup_type='ptrack')
414415

415416
if self.paranoia:
416417
pgdata = self.pgdata_content(node.data_dir)
@@ -452,3 +453,92 @@ def test_merge_ptrack_truncate(self):
452453

453454
# Clean after yourself
454455
self.del_test_dir(module_name, fname)
456+
457+
# @unittest.skip("skip")
458+
def test_merge_delta_delete(self):
459+
"""
460+
Make node, create tablespace with table, take full backup,
461+
alter tablespace location, take delta backup, restore database.
462+
"""
463+
fname = self.id().split('.')[3]
464+
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
465+
node = self.make_simple_node(
466+
base_dir="{0}/{1}/node".format(module_name, fname),
467+
set_replication=True, initdb_params=['--data-checksums'],
468+
pg_options={
469+
'wal_level': 'replica',
470+
'max_wal_senders': '2',
471+
'checkpoint_timeout': '30s',
472+
'autovacuum': 'off'
473+
}
474+
)
475+
476+
self.init_pb(backup_dir)
477+
self.add_instance(backup_dir, 'node', node)
478+
self.set_archiving(backup_dir, 'node', node)
479+
node.start()
480+
481+
self.create_tblspace_in_node(node, 'somedata')
482+
483+
# FULL backup
484+
self.backup_node(backup_dir, 'node', node, options=["--stream"])
485+
486+
node.safe_psql(
487+
"postgres",
488+
"create table t_heap tablespace somedata as select i as id,"
489+
" md5(i::text) as text, md5(i::text)::tsvector as tsvector"
490+
" from generate_series(0,100) i"
491+
)
492+
493+
node.safe_psql(
494+
"postgres",
495+
"delete from t_heap"
496+
)
497+
498+
node.safe_psql(
499+
"postgres",
500+
"vacuum t_heap"
501+
)
502+
503+
# DELTA BACKUP
504+
self.backup_node(
505+
backup_dir, 'node', node,
506+
backup_type='delta',
507+
options=["--stream"]
508+
)
509+
510+
if self.paranoia:
511+
pgdata = self.pgdata_content(node.data_dir)
512+
513+
backup_id = self.show_pb(backup_dir, "node")[1]["id"]
514+
self.merge_backup(backup_dir, "node", backup_id)
515+
516+
# RESTORE
517+
node_restored = self.make_simple_node(
518+
base_dir="{0}/{1}/node_restored".format(module_name, fname)
519+
)
520+
node_restored.cleanup()
521+
522+
self.restore_node(
523+
backup_dir, 'node', node_restored,
524+
options=[
525+
"-j", "4",
526+
"-T", "{0}={1}".format(
527+
self.get_tblspace_path(node, 'somedata'),
528+
self.get_tblspace_path(node_restored, 'somedata')
529+
)
530+
]
531+
)
532+
533+
# GET RESTORED PGDATA AND COMPARE
534+
if self.paranoia:
535+
pgdata_restored = self.pgdata_content(node_restored.data_dir)
536+
self.compare_pgdata(pgdata, pgdata_restored)
537+
538+
# START RESTORED NODE
539+
node_restored.append_conf(
540+
'postgresql.auto.conf', 'port = {0}'.format(node_restored.port))
541+
node_restored.start()
542+
543+
# Clean after yourself
544+
self.del_test_dir(module_name, fname)

tests/page.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ def test_page_stream(self):
149149
page_result = node.execute("postgres", "SELECT * FROM t_heap")
150150
page_backup_id = self.backup_node(
151151
backup_dir, 'node', node,
152-
backup_type='page', options=['--stream'])
152+
backup_type='page', options=['--stream', '-j', '4'])
153+
154+
if self.paranoia:
155+
pgdata = self.pgdata_content(node.data_dir)
153156

154157
# Drop Node
155158
node.cleanup()
@@ -162,6 +165,12 @@ def test_page_stream(self):
162165
backup_id=full_backup_id, options=["-j", "4"]),
163166
'\n Unexpected Error Message: {0}\n'
164167
' CMD: {1}'.format(repr(self.output), self.cmd))
168+
169+
# GET RESTORED PGDATA AND COMPARE
170+
if self.paranoia:
171+
pgdata_restored = self.pgdata_content(node.data_dir)
172+
self.compare_pgdata(pgdata, pgdata_restored)
173+
165174
node.slow_start()
166175
full_result_new = node.execute("postgres", "SELECT * FROM t_heap")
167176
self.assertEqual(full_result, full_result_new)
@@ -211,7 +220,7 @@ def test_page_archive(self):
211220
node.safe_psql(
212221
"postgres",
213222
"create table t_heap as select i as id, md5(i::text) as text, "
214-
"md5(i::text)::tsvector as tsvector from generate_series(0,1) i")
223+
"md5(i::text)::tsvector as tsvector from generate_series(0,100) i")
215224
full_result = node.execute("postgres", "SELECT * FROM t_heap")
216225
full_backup_id = self.backup_node(
217226
backup_dir, 'node', node, backup_type='full')
@@ -221,10 +230,14 @@ def test_page_archive(self):
221230
"postgres",
222231
"insert into t_heap select i as id, "
223232
"md5(i::text) as text, md5(i::text)::tsvector as tsvector "
224-
"from generate_series(0,2) i")
233+
"from generate_series(100, 200) i")
225234
page_result = node.execute("postgres", "SELECT * FROM t_heap")
226235
page_backup_id = self.backup_node(
227-
backup_dir, 'node', node, backup_type='page')
236+
backup_dir, 'node', node,
237+
backup_type='page', options=["-j", "4"])
238+
239+
if self.paranoia:
240+
pgdata = self.pgdata_content(node.data_dir)
228241

229242
# Drop Node
230243
node.cleanup()
@@ -241,6 +254,7 @@ def test_page_archive(self):
241254
"--recovery-target-action=promote"]),
242255
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
243256
repr(self.output), self.cmd))
257+
244258
node.slow_start()
245259

246260
full_result_new = node.execute("postgres", "SELECT * FROM t_heap")
@@ -259,6 +273,12 @@ def test_page_archive(self):
259273
"--recovery-target-action=promote"]),
260274
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
261275
repr(self.output), self.cmd))
276+
277+
# GET RESTORED PGDATA AND COMPARE
278+
if self.paranoia:
279+
pgdata_restored = self.pgdata_content(node.data_dir)
280+
self.compare_pgdata(pgdata, pgdata_restored)
281+
262282
node.slow_start()
263283

264284
page_result_new = node.execute("postgres", "SELECT * FROM t_heap")

0 commit comments

Comments
 (0)