mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2024-11-24 08:52:38 +02:00
Merge branch 'ptrack_to_delta'
This commit is contained in:
commit
fc74e7dc2f
14
src/ptrack.c
14
src/ptrack.c
@ -202,9 +202,21 @@ get_ptrack_version(PGconn *backup_conn, PGNodeInfo *nodeInfo)
|
||||
else if (strcmp(ptrack_version_str, "2.1") == 0)
|
||||
nodeInfo->ptrack_version_num = 21;
|
||||
else
|
||||
elog(WARNING, "Update your ptrack to the version 1.5 or upper. Current version is %s",
|
||||
elog(WARNING, "Update your ptrack to the version 2.1 or upper. Current version is %s",
|
||||
ptrack_version_str);
|
||||
|
||||
/* ptrack 1.X is buggy, so fall back to DELTA backup strategy for safety */
|
||||
if (nodeInfo->ptrack_version_num >= 15 && nodeInfo->ptrack_version_num < 20)
|
||||
{
|
||||
if (current.backup_mode == BACKUP_MODE_DIFF_PTRACK)
|
||||
{
|
||||
elog(WARNING, "Update your ptrack to the version 2.1 or upper. Current version is %s. "
|
||||
"Fall back to DELTA backup.",
|
||||
ptrack_version_str);
|
||||
current.backup_mode = BACKUP_MODE_DIFF_DELTA;
|
||||
}
|
||||
}
|
||||
|
||||
PQclear(res_db);
|
||||
}
|
||||
|
||||
|
@ -365,7 +365,7 @@ class ProbackupTest(object):
|
||||
options['max_wal_senders'] = 10
|
||||
|
||||
if ptrack_enable:
|
||||
if node.major_version > 11:
|
||||
if node.major_version >= 11:
|
||||
options['ptrack.map_size'] = '128'
|
||||
options['shared_preload_libraries'] = 'ptrack'
|
||||
else:
|
||||
|
376
tests/ptrack.py
376
tests/ptrack.py
@ -15,6 +15,200 @@ module_name = 'ptrack'
|
||||
|
||||
class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
# @unittest.skip("skip")
|
||||
def test_ptrack_stop_pg(self):
|
||||
"""
|
||||
create node, take full backup,
|
||||
restart node, check that ptrack backup
|
||||
can be taken
|
||||
"""
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
node = self.make_simple_node(
|
||||
base_dir=os.path.join(module_name, fname, 'node'),
|
||||
set_replication=True,
|
||||
ptrack_enable=True,
|
||||
initdb_params=['--data-checksums'])
|
||||
|
||||
self.init_pb(backup_dir)
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
|
||||
node.pgbench_init(scale=1)
|
||||
|
||||
# FULL backup
|
||||
self.backup_node(backup_dir, 'node', node, options=['--stream'])
|
||||
|
||||
node.stop()
|
||||
node.slow_start()
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
backup_type='ptrack', options=['--stream'])
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
# @unittest.skip("skip")
|
||||
def test_ptrack_multi_timeline_backup(self):
|
||||
"""
|
||||
t2 /------P2
|
||||
t1 ------F---*-----P1
|
||||
"""
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
node = self.make_simple_node(
|
||||
base_dir=os.path.join(module_name, fname, 'node'),
|
||||
set_replication=True,
|
||||
ptrack_enable=True,
|
||||
initdb_params=['--data-checksums'],
|
||||
pg_options={'autovacuum': 'off'})
|
||||
|
||||
self.init_pb(backup_dir)
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
self.set_archiving(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
|
||||
node.pgbench_init(scale=5)
|
||||
|
||||
# FULL backup
|
||||
full_id = self.backup_node(backup_dir, 'node', node)
|
||||
|
||||
pgbench = node.pgbench(options=['-T', '30', '-c', '1', '--no-vacuum'])
|
||||
sleep(15)
|
||||
|
||||
xid = node.safe_psql(
|
||||
'postgres',
|
||||
'SELECT txid_current()').rstrip()
|
||||
pgbench.wait()
|
||||
|
||||
self.backup_node(backup_dir, 'node', node, backup_type='ptrack')
|
||||
|
||||
node.cleanup()
|
||||
|
||||
# Restore from full backup to create Timeline 2
|
||||
print(self.restore_node(
|
||||
backup_dir, 'node', node,
|
||||
options=[
|
||||
'--recovery-target-xid={0}'.format(xid),
|
||||
'--recovery-target-action=promote']))
|
||||
|
||||
node.slow_start()
|
||||
|
||||
pgbench = node.pgbench(options=['-T', '10', '-c', '1', '--no-vacuum'])
|
||||
pgbench.wait()
|
||||
|
||||
self.backup_node(backup_dir, 'node', node, backup_type='ptrack')
|
||||
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
node.cleanup()
|
||||
|
||||
self.restore_node(backup_dir, 'node', node)
|
||||
|
||||
pgdata_restored = self.pgdata_content(node.data_dir)
|
||||
self.compare_pgdata(pgdata, pgdata_restored)
|
||||
|
||||
node.slow_start()
|
||||
|
||||
balance = node.safe_psql(
|
||||
'postgres',
|
||||
'select (select sum(tbalance) from pgbench_tellers) - '
|
||||
'( select sum(bbalance) from pgbench_branches) + '
|
||||
'( select sum(abalance) from pgbench_accounts ) - '
|
||||
'(select sum(delta) from pgbench_history) as must_be_zero').rstrip()
|
||||
|
||||
self.assertEqual('0', balance)
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
# @unittest.skip("skip")
|
||||
def test_ptrack_multi_timeline_backup_1(self):
|
||||
"""
|
||||
t2 /------
|
||||
t1 ---F---P1---*
|
||||
|
||||
# delete P1
|
||||
t2 /------P2
|
||||
t1 ---F--------*
|
||||
"""
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
node = self.make_simple_node(
|
||||
base_dir=os.path.join(module_name, fname, 'node'),
|
||||
set_replication=True,
|
||||
ptrack_enable=True,
|
||||
initdb_params=['--data-checksums'],
|
||||
pg_options={'autovacuum': 'off'})
|
||||
|
||||
self.init_pb(backup_dir)
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
self.set_archiving(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
|
||||
node.pgbench_init(scale=5)
|
||||
|
||||
# FULL backup
|
||||
full_id = self.backup_node(backup_dir, 'node', node)
|
||||
|
||||
pgbench = node.pgbench(options=['-T', '10', '-c', '1', '--no-vacuum'])
|
||||
pgbench.wait()
|
||||
|
||||
ptrack_id = self.backup_node(backup_dir, 'node', node, backup_type='ptrack')
|
||||
node.cleanup()
|
||||
|
||||
self.restore_node(backup_dir, 'node', node)
|
||||
|
||||
node.slow_start()
|
||||
|
||||
pgbench = node.pgbench(options=['-T', '10', '-c', '1', '--no-vacuum'])
|
||||
pgbench.wait()
|
||||
|
||||
# delete old PTRACK backup
|
||||
self.delete_pb(backup_dir, 'node', backup_id=ptrack_id)
|
||||
|
||||
# take new PTRACK backup
|
||||
self.backup_node(backup_dir, 'node', node, backup_type='ptrack')
|
||||
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
node.cleanup()
|
||||
|
||||
self.restore_node(backup_dir, 'node', node)
|
||||
|
||||
pgdata_restored = self.pgdata_content(node.data_dir)
|
||||
self.compare_pgdata(pgdata, pgdata_restored)
|
||||
|
||||
node.slow_start()
|
||||
|
||||
balance = node.safe_psql(
|
||||
'postgres',
|
||||
'select (select sum(tbalance) from pgbench_tellers) - '
|
||||
'( select sum(bbalance) from pgbench_branches) + '
|
||||
'( select sum(abalance) from pgbench_accounts ) - '
|
||||
'(select sum(delta) from pgbench_history) as must_be_zero').rstrip()
|
||||
|
||||
self.assertEqual('0', balance)
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
# @unittest.skip("skip")
|
||||
def test_ptrack_eat_my_data(self):
|
||||
"""
|
||||
@ -33,7 +227,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.set_archiving(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -113,7 +307,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -291,7 +485,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
"GRANT EXECUTE ON FUNCTION pg_catalog.txid_snapshot_xmax(txid_snapshot) TO backup;"
|
||||
)
|
||||
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
fnames = [
|
||||
'pg_catalog.oideq(oid, oid)',
|
||||
'pg_catalog.ptrack_version()',
|
||||
@ -357,7 +551,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -408,7 +602,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -417,7 +611,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.backup_node(backup_dir, 'node', node, options=['--stream'])
|
||||
|
||||
# DISABLE PTRACK
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql('postgres', "alter system set ptrack.map_size to 0")
|
||||
else:
|
||||
node.safe_psql('postgres', "alter system set ptrack_enable to off")
|
||||
@ -425,7 +619,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
node.slow_start()
|
||||
|
||||
# ENABLE PTRACK
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql('postgres', "alter system set ptrack.map_size to '128'")
|
||||
node.safe_psql('postgres', "alter system set shared_preload_libraries to 'ptrack'")
|
||||
else:
|
||||
@ -478,7 +672,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -539,7 +733,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
self.create_tblspace_in_node(node, 'somedata')
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -629,7 +823,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
self.create_tblspace_in_node(node, 'somedata')
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -710,7 +904,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
self.skipTest("skip --- we do not need ptrack_get_block for ptrack 2.*")
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
@ -786,7 +980,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -879,7 +1073,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.set_archiving(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -1215,7 +1409,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -1335,7 +1529,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -1435,7 +1629,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -1529,7 +1723,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -1601,7 +1795,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -1698,7 +1892,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -1816,7 +2010,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -1829,7 +2023,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.backup_node(backup_dir, 'node', node, options=['--stream'])
|
||||
|
||||
# PTRACK STUFF
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
idx_ptrack = {'type': 'heap'}
|
||||
idx_ptrack['path'] = self.get_fork_path(node, 'pgbench_accounts')
|
||||
idx_ptrack['old_size'] = self.get_fork_size(node, 'pgbench_accounts')
|
||||
@ -1842,7 +2036,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
node.safe_psql("postgres", "checkpoint")
|
||||
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
idx_ptrack['new_size'] = self.get_fork_size(
|
||||
node,
|
||||
'pgbench_accounts')
|
||||
@ -2233,7 +2427,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -2260,7 +2454,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
node.safe_psql('postgres', 'vacuum t_heap')
|
||||
node.safe_psql('postgres', 'checkpoint')
|
||||
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
for i in idx_ptrack:
|
||||
# get size of heap and indexes. size calculated in pages
|
||||
idx_ptrack[i]['old_size'] = self.get_fork_size(node, i)
|
||||
@ -2278,7 +2472,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
node.safe_psql('postgres', 'checkpoint')
|
||||
|
||||
# CHECK PTRACK SANITY
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
self.check_ptrack_map_sanity(node, idx_ptrack)
|
||||
|
||||
# Clean after yourself
|
||||
@ -2298,7 +2492,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -2339,7 +2533,20 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
node.safe_psql('postgres', 'checkpoint')
|
||||
|
||||
# CHECK PTRACK SANITY
|
||||
self.check_ptrack_map_sanity(node, idx_ptrack)
|
||||
if node.major_version < 11:
|
||||
self.check_ptrack_map_sanity(node, idx_ptrack)
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
backup_type='ptrack', options=['-j10', '--stream'])
|
||||
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
node.cleanup()
|
||||
|
||||
self.restore_node(backup_dir, 'node', node)
|
||||
|
||||
pgdata_restored = self.pgdata_content(node.data_dir)
|
||||
self.compare_pgdata(pgdata, pgdata_restored)
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
@ -2358,7 +2565,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'master', master)
|
||||
master.slow_start()
|
||||
|
||||
if master.major_version >= 12:
|
||||
if master.major_version >= 11:
|
||||
master.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -2420,7 +2627,23 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
replica.safe_psql('postgres', 'checkpoint')
|
||||
|
||||
# CHECK PTRACK SANITY
|
||||
self.check_ptrack_map_sanity(replica, idx_ptrack)
|
||||
if master.major_version < 11:
|
||||
self.check_ptrack_map_sanity(replica, idx_ptrack)
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'replica', replica,
|
||||
backup_type='ptrack', options=['-j10', '--stream'])
|
||||
|
||||
pgdata = self.pgdata_content(replica.data_dir)
|
||||
|
||||
node = self.make_simple_node(
|
||||
base_dir=os.path.join(module_name, fname, 'node'))
|
||||
node.cleanup()
|
||||
|
||||
self.restore_node(backup_dir, 'replica', node)
|
||||
|
||||
pgdata_restored = self.pgdata_content(replica.data_dir)
|
||||
self.compare_pgdata(pgdata, pgdata_restored)
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
@ -2438,7 +2661,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'master', master)
|
||||
master.slow_start()
|
||||
|
||||
if master.major_version >= 12:
|
||||
if master.major_version >= 11:
|
||||
master.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -2498,13 +2721,13 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
master.safe_psql('postgres', 'DELETE FROM t_heap WHERE id%2 = 1')
|
||||
master.safe_psql('postgres', 'CLUSTER t_heap USING t_gist')
|
||||
|
||||
if master.major_version < 12:
|
||||
if master.major_version < 11:
|
||||
master.safe_psql('postgres', 'CHECKPOINT')
|
||||
|
||||
# Sync master and replica
|
||||
self.wait_until_replica_catch_with_master(master, replica)
|
||||
|
||||
if master.major_version < 12:
|
||||
if master.major_version < 11:
|
||||
replica.safe_psql('postgres', 'CHECKPOINT')
|
||||
self.check_ptrack_map_sanity(replica, idx_ptrack)
|
||||
|
||||
@ -2546,7 +2769,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -2621,15 +2844,14 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
set_replication=True,
|
||||
initdb_params=['--data-checksums'],
|
||||
ptrack_enable=True,
|
||||
pg_options={
|
||||
'autovacuum': 'off'})
|
||||
pg_options={'autovacuum': 'off'})
|
||||
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
self.init_pb(backup_dir)
|
||||
self.add_instance(backup_dir, 'master', master)
|
||||
master.slow_start()
|
||||
|
||||
if master.major_version >= 12:
|
||||
if master.major_version >= 11:
|
||||
master.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -2722,7 +2944,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -2738,7 +2960,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
"md5(repeat(i::text,10))::tsvector as tsvector "
|
||||
"from generate_series(0,2560) i")
|
||||
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
for i in idx_ptrack:
|
||||
if idx_ptrack[i]['type'] != 'heap' and idx_ptrack[i]['type'] != 'seq':
|
||||
node.safe_psql(
|
||||
@ -2754,7 +2976,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
node.safe_psql('postgres', 'truncate t_heap')
|
||||
node.safe_psql('postgres', 'checkpoint')
|
||||
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
for i in idx_ptrack:
|
||||
# get fork size and calculate it in pages
|
||||
idx_ptrack[i]['old_size'] = self.get_fork_size(node, i)
|
||||
@ -2771,7 +2993,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
for i in idx_ptrack:
|
||||
idx_ptrack[i]['ptrack'] = self.get_ptrack_bits_per_page_for_fork(
|
||||
node, idx_ptrack[i]['path'], [idx_ptrack[i]['old_size']])
|
||||
@ -2801,14 +3023,15 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
pg_options={
|
||||
'max_wal_size': '32MB',
|
||||
'archive_timeout': '10s',
|
||||
'checkpoint_timeout': '30s'})
|
||||
'checkpoint_timeout': '30s',
|
||||
'autovacuum': 'off'})
|
||||
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
self.init_pb(backup_dir)
|
||||
self.add_instance(backup_dir, 'master', master)
|
||||
master.slow_start()
|
||||
|
||||
if master.major_version >= 12:
|
||||
if master.major_version >= 11:
|
||||
master.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -2846,7 +3069,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.wait_until_replica_catch_with_master(master, replica)
|
||||
replica.safe_psql('postgres', 'checkpoint')
|
||||
|
||||
if replica.major_version < 12:
|
||||
if replica.major_version < 11:
|
||||
for i in idx_ptrack:
|
||||
# get fork size and calculate it in pages
|
||||
idx_ptrack[i]['old_size'] = self.get_fork_size(replica, i)
|
||||
@ -2866,7 +3089,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
'--master-db=postgres',
|
||||
'--master-port={0}'.format(master.port)])
|
||||
|
||||
if replica.major_version < 12:
|
||||
if replica.major_version < 11:
|
||||
for i in idx_ptrack:
|
||||
idx_ptrack[i]['ptrack'] = self.get_ptrack_bits_per_page_for_fork(
|
||||
replica, idx_ptrack[i]['path'], [idx_ptrack[i]['old_size']])
|
||||
@ -2876,7 +3099,6 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
# Sync master and replica
|
||||
self.wait_until_replica_catch_with_master(master, replica)
|
||||
replica.safe_psql('postgres', 'checkpoint')
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'replica', replica, backup_type='ptrack',
|
||||
@ -2916,7 +3138,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -2948,7 +3170,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, options=['-j10', '--stream'])
|
||||
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
for i in idx_ptrack:
|
||||
# get fork size and calculate it in pages
|
||||
idx_ptrack[i]['old_size'] = self.get_fork_size(node, i)
|
||||
@ -2967,7 +3189,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
node.safe_psql('postgres', 'checkpoint')
|
||||
|
||||
# CHECK PTRACK SANITY
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
self.check_ptrack_map_sanity(node, idx_ptrack)
|
||||
|
||||
self.backup_node(
|
||||
@ -3005,7 +3227,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'master', master)
|
||||
master.slow_start()
|
||||
|
||||
if master.major_version >= 12:
|
||||
if master.major_version >= 11:
|
||||
master.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -3053,7 +3275,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
'--master-port={0}'.format(master.port),
|
||||
'--stream'])
|
||||
|
||||
if replica.major_version < 12:
|
||||
if replica.major_version < 11:
|
||||
for i in idx_ptrack:
|
||||
# get fork size and calculate it in pages
|
||||
idx_ptrack[i]['old_size'] = self.get_fork_size(replica, i)
|
||||
@ -3076,7 +3298,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
replica.safe_psql('postgres', 'checkpoint')
|
||||
|
||||
# CHECK PTRACK SANITY
|
||||
if replica.major_version < 12:
|
||||
if replica.major_version < 11:
|
||||
self.check_ptrack_map_sanity(master, idx_ptrack)
|
||||
|
||||
self.backup_node(
|
||||
@ -3112,7 +3334,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -3145,7 +3367,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
node.safe_psql('postgres', 'vacuum freeze t_heap')
|
||||
node.safe_psql('postgres', 'checkpoint')
|
||||
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
for i in idx_ptrack:
|
||||
# get size of heap and indexes. size calculated in pages
|
||||
idx_ptrack[i]['old_size'] = self.get_fork_size(node, i)
|
||||
@ -3156,7 +3378,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
idx_ptrack[i]['path'], idx_ptrack[i]['old_size'])
|
||||
|
||||
# CHECK PTRACK SANITY
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
self.check_ptrack_map_sanity(node, idx_ptrack)
|
||||
|
||||
self.backup_node(
|
||||
@ -3191,7 +3413,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'master', master)
|
||||
master.slow_start()
|
||||
|
||||
if master.major_version >= 12:
|
||||
if master.major_version >= 11:
|
||||
master.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -3240,7 +3462,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
'--master-port={0}'.format(master.port),
|
||||
'--stream'])
|
||||
|
||||
if replica.major_version < 12:
|
||||
if replica.major_version < 11:
|
||||
for i in idx_ptrack:
|
||||
# get size of heap and indexes. size calculated in pages
|
||||
idx_ptrack[i]['old_size'] = self.get_fork_size(replica, i)
|
||||
@ -3258,7 +3480,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
replica.safe_psql('postgres', 'checkpoint')
|
||||
|
||||
# CHECK PTRACK SANITY
|
||||
if replica.major_version < 12:
|
||||
if replica.major_version < 11:
|
||||
self.check_ptrack_map_sanity(master, idx_ptrack)
|
||||
|
||||
self.backup_node(
|
||||
@ -3291,7 +3513,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -3321,7 +3543,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, options=['-j10', '--stream'])
|
||||
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
for i in idx_ptrack:
|
||||
# get size of heap and indexes. size calculated in pages
|
||||
idx_ptrack[i]['old_size'] = self.get_fork_size(node, i)
|
||||
@ -3335,7 +3557,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
node.safe_psql('postgres', 'checkpoint')
|
||||
|
||||
# CHECK PTRACK SANITY
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
self.check_ptrack_map_sanity(node, idx_ptrack)
|
||||
|
||||
self.backup_node(
|
||||
@ -3370,7 +3592,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -3399,7 +3621,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, options=['-j10', '--stream'])
|
||||
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
for i in idx_ptrack:
|
||||
# get size of heap and indexes. size calculated in pages
|
||||
idx_ptrack[i]['old_size'] = self.get_fork_size(node, i)
|
||||
@ -3413,7 +3635,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
node.safe_psql('postgres', 'vacuum full t_heap')
|
||||
node.safe_psql('postgres', 'checkpoint')
|
||||
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
self.check_ptrack_map_sanity(node, idx_ptrack)
|
||||
|
||||
self.backup_node(
|
||||
@ -3451,7 +3673,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'master', master)
|
||||
master.slow_start()
|
||||
|
||||
if master.major_version >= 12:
|
||||
if master.major_version >= 11:
|
||||
master.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -3475,7 +3697,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
"md5(i::text) as text, md5(repeat(i::text,10))::tsvector as "
|
||||
"tsvector from generate_series(0,256000) i")
|
||||
|
||||
if master.major_version < 12:
|
||||
if master.major_version < 11:
|
||||
for i in idx_ptrack:
|
||||
if idx_ptrack[i]['type'] != 'heap' and idx_ptrack[i]['type'] != 'seq':
|
||||
master.safe_psql(
|
||||
@ -3502,7 +3724,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
'--master-port={0}'.format(master.port),
|
||||
'--stream'])
|
||||
|
||||
if replica.major_version < 12:
|
||||
if replica.major_version < 11:
|
||||
for i in idx_ptrack:
|
||||
# get size of heap and indexes. size calculated in pages
|
||||
idx_ptrack[i]['old_size'] = self.get_fork_size(replica, i)
|
||||
@ -3520,7 +3742,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.wait_until_replica_catch_with_master(master, replica)
|
||||
replica.safe_psql('postgres', 'checkpoint')
|
||||
|
||||
if replica.major_version < 12:
|
||||
if replica.major_version < 11:
|
||||
self.check_ptrack_map_sanity(master, idx_ptrack)
|
||||
|
||||
self.backup_node(
|
||||
@ -3553,7 +3775,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -3567,7 +3789,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
"md5(repeat(i::text,10))::tsvector as tsvector "
|
||||
"from generate_series(0,2560) i")
|
||||
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
for i in idx_ptrack:
|
||||
if idx_ptrack[i]['type'] != 'heap' and idx_ptrack[i]['type'] != 'seq':
|
||||
node.safe_psql(
|
||||
@ -3580,7 +3802,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, options=['-j10', '--stream'])
|
||||
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
for i in idx_ptrack:
|
||||
# get size of heap and indexes. size calculated in pages
|
||||
idx_ptrack[i]['old_size'] = self.get_fork_size(node, i)
|
||||
@ -3595,7 +3817,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
node.safe_psql('postgres', 'CHECKPOINT')
|
||||
|
||||
# CHECK PTRACK SANITY
|
||||
if node.major_version < 12:
|
||||
if node.major_version < 11:
|
||||
self.check_ptrack_map_sanity(node, idx_ptrack)
|
||||
|
||||
self.backup_node(
|
||||
@ -3631,7 +3853,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'master', master)
|
||||
master.slow_start()
|
||||
|
||||
if master.major_version >= 12:
|
||||
if master.major_version >= 11:
|
||||
master.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -3679,7 +3901,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
]
|
||||
)
|
||||
|
||||
if master.major_version < 12:
|
||||
if master.major_version < 11:
|
||||
for i in idx_ptrack:
|
||||
# get size of heap and indexes. size calculated in pages
|
||||
idx_ptrack[i]['old_size'] = self.get_fork_size(replica, i)
|
||||
@ -3698,7 +3920,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
replica.safe_psql('postgres', 'CHECKPOINT')
|
||||
|
||||
# CHECK PTRACK SANITY
|
||||
if master.major_version < 12:
|
||||
if master.major_version < 11:
|
||||
self.check_ptrack_map_sanity(master, idx_ptrack)
|
||||
|
||||
self.backup_node(
|
||||
@ -3891,7 +4113,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -3941,7 +4163,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
@ -4067,7 +4289,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
if node.major_version >= 12:
|
||||
if node.major_version >= 11:
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"CREATE EXTENSION ptrack")
|
||||
|
Loading…
Reference in New Issue
Block a user