|
4 | 4 | from datetime import datetime, timedelta
|
5 | 5 | import subprocess
|
6 | 6 | import time
|
7 |
| -import ipdb |
8 | 7 |
|
9 | 8 | module_name = 'page'
|
10 | 9 |
|
@@ -558,14 +557,72 @@ def test_parallel_pagemap(self):
|
558 | 557 | # Fill instance with data and make several WAL segments ...
|
559 | 558 | node.safe_psql("postgres", "create table test (id int)")
|
560 | 559 | for x in range(0, 8):
|
561 |
| - node.safe_psql("postgres", |
| 560 | + node.safe_psql( |
| 561 | + "postgres", |
562 | 562 | "insert into test select i from generate_series(1,100) s(i)")
|
563 | 563 | self.switch_wal_segment(node)
|
564 | 564 | count1 = node.safe_psql("postgres", "select count(*) from test")
|
565 | 565 |
|
566 | 566 | # ... and do page backup with parallel pagemap
|
567 |
| - self.backup_node(backup_dir, 'node', node, backup_type="page", |
568 |
| - options=["-j", "4"]) |
| 567 | + self.backup_node( |
| 568 | + backup_dir, 'node', node, backup_type="page", options=["-j", "4"]) |
| 569 | + show_backup = self.show_pb(backup_dir, 'node')[1] |
| 570 | + |
| 571 | + self.assertEqual(show_backup['status'], "OK") |
| 572 | + self.assertEqual(show_backup['backup-mode'], "PAGE") |
| 573 | + |
| 574 | + # Drop node and restore it |
| 575 | + node.cleanup() |
| 576 | + self.restore_node(backup_dir, 'node', node) |
| 577 | + node.start() |
| 578 | + |
| 579 | + # Check restored node |
| 580 | + count2 = node.safe_psql("postgres", "select count(*) from test") |
| 581 | + |
| 582 | + self.assertEqual(count1, count2) |
| 583 | + |
| 584 | + # Clean after yourself |
| 585 | + node.cleanup() |
| 586 | + self.del_test_dir(module_name, fname) |
| 587 | + |
| 588 | + def test_parallel_pagemap_1(self): |
| 589 | + """ |
| 590 | + Test for parallel WAL segments reading, during which pagemap is built |
| 591 | + """ |
| 592 | + fname = self.id().split('.')[3] |
| 593 | + backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') |
| 594 | + |
| 595 | + # Initialize instance and backup directory |
| 596 | + node = self.make_simple_node( |
| 597 | + base_dir="{0}/{1}/node".format(module_name, fname), |
| 598 | + initdb_params=['--data-checksums'], |
| 599 | + pg_options={} |
| 600 | + ) |
| 601 | + |
| 602 | + self.init_pb(backup_dir) |
| 603 | + self.add_instance(backup_dir, 'node', node) |
| 604 | + self.set_archiving(backup_dir, 'node', node) |
| 605 | + node.start() |
| 606 | + |
| 607 | + # Do full backup |
| 608 | + self.backup_node(backup_dir, 'node', node) |
| 609 | + show_backup = self.show_pb(backup_dir, 'node')[0] |
| 610 | + |
| 611 | + self.assertEqual(show_backup['status'], "OK") |
| 612 | + self.assertEqual(show_backup['backup-mode'], "FULL") |
| 613 | + |
| 614 | + # Fill instance with data and make several WAL segments ... |
| 615 | + node.pgbench_init(scale=10) |
| 616 | + |
| 617 | + # do page backup in single thread |
| 618 | + page_id = self.backup_node( |
| 619 | + backup_dir, 'node', node, backup_type="page") |
| 620 | + |
| 621 | + self.delete_pb(backup_dir, 'node', page_id) |
| 622 | + |
| 623 | + # ... and do page backup with parallel pagemap |
| 624 | + self.backup_node( |
| 625 | + backup_dir, 'node', node, backup_type="page", options=["-j", "4"]) |
569 | 626 | show_backup = self.show_pb(backup_dir, 'node')[1]
|
570 | 627 |
|
571 | 628 | self.assertEqual(show_backup['status'], "OK")
|
|
0 commit comments