1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-07-15 07:04:14 +02:00

Teach pg_probackup to work with ptrack 2.1

This commit is contained in:
Alexey Kondratov
2020-04-22 19:30:39 +03:00
committed by Grigory Smolkin
parent 61b476bb31
commit 583ffaaa30
5 changed files with 18 additions and 14 deletions

View File

@ -1168,12 +1168,12 @@ CREATE EXTENSION ptrack;
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
To enable tracking page updates, set <varname>ptrack_map_size</varname> To enable tracking page updates, set <varname>ptrack.map_size</varname>
parameter to a positive integer and restart the server. parameter to a positive integer and restart the server.
</para> </para>
<para> <para>
For optimal performance, it is recommended to set For optimal performance, it is recommended to set
<varname>ptrack_map_size</varname> to <varname>ptrack.map_size</varname> to
<literal><replaceable>N</replaceable> / 1024</literal>, where <literal><replaceable>N</replaceable> / 1024</literal>, where
<replaceable>N</replaceable> is the size of the <replaceable>N</replaceable> is the size of the
<productname>PostgreSQL</productname> cluster, in MB. If you set this <productname>PostgreSQL</productname> cluster, in MB. If you set this
@ -1181,7 +1181,7 @@ CREATE EXTENSION ptrack;
together, which leads to false-positive results when tracking changed together, which leads to false-positive results when tracking changed
blocks and increases the incremental backup size as unchanged blocks blocks and increases the incremental backup size as unchanged blocks
can also be copied into the incremental backup. can also be copied into the incremental backup.
Setting <varname>ptrack_map_size</varname> to a higher value Setting <varname>ptrack.map_size</varname> to a higher value
does not affect PTRACK operation. The maximum allowed value is 1024. does not affect PTRACK operation. The maximum allowed value is 1024.
</para> </para>
</listitem> </listitem>
@ -1201,11 +1201,11 @@ GRANT EXECUTE ON FUNCTION pg_ptrack_get_block(oid, oid, oid, bigint) TO backup;
<note> <note>
<para> <para>
If you change the <varname>ptrack_map_size</varname> parameter value, If you change the <varname>ptrack.map_size</varname> parameter value,
the previously created PTRACK map file is cleared, the previously created PTRACK map file is cleared,
and tracking newly changed blocks starts from scratch. Thus, you have and tracking newly changed blocks starts from scratch. Thus, you have
to retake a full backup before taking incremental PTRACK backups after to retake a full backup before taking incremental PTRACK backups after
changing <varname>ptrack_map_size</varname>. changing <varname>ptrack.map_size</varname>.
</para> </para>
</note> </note>

View File

@ -436,7 +436,7 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync)
/* /*
* Build the page map from ptrack information. * Build the page map from ptrack information.
*/ */
if (nodeInfo->ptrack_version_num == 20) if (nodeInfo->ptrack_version_num >= 20)
make_pagemap_from_ptrack_2(backup_files_list, backup_conn, make_pagemap_from_ptrack_2(backup_files_list, backup_conn,
nodeInfo->ptrack_schema, nodeInfo->ptrack_schema,
prev_backup_start_lsn); prev_backup_start_lsn);

View File

@ -204,6 +204,8 @@ get_ptrack_version(PGconn *backup_conn, PGNodeInfo *nodeInfo)
nodeInfo->ptrack_version_num = 17; nodeInfo->ptrack_version_num = 17;
else if (strcmp(ptrack_version_str, "2.0") == 0) else if (strcmp(ptrack_version_str, "2.0") == 0)
nodeInfo->ptrack_version_num = 20; nodeInfo->ptrack_version_num = 20;
else if (strcmp(ptrack_version_str, "2.1") == 0)
nodeInfo->ptrack_version_num = 21;
else 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 1.5 or upper. Current version is %s",
ptrack_version_str); ptrack_version_str);
@ -572,7 +574,7 @@ pg_ptrack_enable2(PGconn *backup_conn)
{ {
PGresult *res_db; PGresult *res_db;
res_db = pgut_execute(backup_conn, "SHOW ptrack_map_size", 0, NULL); res_db = pgut_execute(backup_conn, "SHOW ptrack.map_size", 0, NULL);
if (strcmp(PQgetvalue(res_db, 0, 0), "0") == 0) if (strcmp(PQgetvalue(res_db, 0, 0), "0") == 0)
{ {

View File

@ -366,7 +366,8 @@ class ProbackupTest(object):
if ptrack_enable: if ptrack_enable:
if node.major_version > 11: if node.major_version > 11:
options['ptrack_map_size'] = '128MB' options['ptrack.map_size'] = '128'
options['shared_preload_libraries'] = 'ptrack'
else: else:
options['ptrack_enable'] = 'on' options['ptrack_enable'] = 'on'

View File

@ -269,7 +269,8 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
base_dir=os.path.join(module_name, fname, 'node'), base_dir=os.path.join(module_name, fname, 'node'),
set_replication=True, initdb_params=['--data-checksums'], set_replication=True, initdb_params=['--data-checksums'],
pg_options={ pg_options={
'checkpoint_timeout': '30s'}) 'checkpoint_timeout': '30s',
'shared_preload_libraries': 'ptrack'})
self.init_pb(backup_dir) self.init_pb(backup_dir)
self.add_instance(backup_dir, 'node', node) self.add_instance(backup_dir, 'node', node)
@ -336,16 +337,16 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# DISABLE PTRACK # DISABLE PTRACK
if node.major_version >= 12: if node.major_version >= 12:
node.safe_psql('postgres', "alter system set ptrack_map_size to 0") node.safe_psql('postgres', "alter system set ptrack.map_size to 0")
else: else:
node.safe_psql('postgres', "alter system set ptrack_enable to off") node.safe_psql('postgres', "alter system set ptrack_enable to off")
node.stop() node.stop()
node.slow_start() node.slow_start()
# ENABLE PTRACK # ENABLE PTRACK
if node.major_version >= 12: if node.major_version >= 12:
node.safe_psql('postgres', "alter system set ptrack_map_size to '128MB'") 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: else:
node.safe_psql('postgres', "alter system set ptrack_enable to on") node.safe_psql('postgres', "alter system set ptrack_enable to on")
node.stop() node.stop()
@ -4054,7 +4055,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
'FATAL: incorrect checksum of file "{0}"'.format(ptrack_map), 'FATAL: incorrect checksum of file "{0}"'.format(ptrack_map),
log_content) log_content)
self.set_auto_conf(node, {'ptrack_map_size': '0'}) self.set_auto_conf(node, {'ptrack.map_size': '0'})
node.slow_start() node.slow_start()
@ -4082,7 +4083,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
node.stop(['-m', 'immediate', '-D', node.data_dir]) node.stop(['-m', 'immediate', '-D', node.data_dir])
self.set_auto_conf(node, {'ptrack_map_size': '32'}) self.set_auto_conf(node, {'ptrack.map_size': '32', 'shared_preload_libraries': 'ptrack'})
node.slow_start() node.slow_start()