Skip to content

Commit cce59bc

Browse files
kulaginmgsmolk
andauthored
Remove ptrack-1.* support (#398)
* Remove ptrack-1.* support * [PR #398] review feedback * [PR #398] remove conn_arg from backup_files_arg Co-authored-by: Grigory Smolkin <[email protected]>
1 parent 97b23c4 commit cce59bc

13 files changed

+352
-1207
lines changed

doc/pgprobackup.xml

+1-29
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ GRANT SELECT ON TABLE pg_catalog.pg_database TO backup;
11621162
</para>
11631163
<note>
11641164
<para>
1165-
PTRACK versions lower than 2.0 are deprecated. Postgres Pro Standard and Postgres Pro Enterprise
1165+
PTRACK versions lower than 2.0 are deprecated and not supported. Postgres Pro Standard and Postgres Pro Enterprise
11661166
versions starting with 11.9.1 contain PTRACK 2.0. Upgrade your server to avoid issues in backups
11671167
that you will take in future and be sure to take fresh backups of your clusters with the upgraded
11681168
PTRACK since the backups taken with PTRACK 1.x might be corrupt.
@@ -1218,34 +1218,6 @@ CREATE EXTENSION ptrack;
12181218
</para>
12191219
</note>
12201220

1221-
<para>
1222-
For older <productname>PostgreSQL</productname> versions,
1223-
PTRACK required taking backups in the exclusive mode
1224-
to provide exclusive access to bitmaps with changed blocks.
1225-
To set up PTRACK backups for <productname>PostgreSQL</productname> 10
1226-
or lower, do the following:
1227-
</para>
1228-
<orderedlist>
1229-
<listitem>
1230-
<para>
1231-
Set the <parameter>ptrack_enable</parameter> parameter to
1232-
<literal>on</literal>.
1233-
</para>
1234-
</listitem>
1235-
<listitem>
1236-
<para>
1237-
Grant the right to execute <application>PTRACK</application>
1238-
functions to the <literal>backup</literal> role
1239-
<emphasis role="strong">in every database</emphasis> of the
1240-
cluster:
1241-
</para>
1242-
<programlisting>
1243-
GRANT EXECUTE ON FUNCTION pg_catalog.pg_ptrack_clear() TO backup;
1244-
GRANT EXECUTE ON FUNCTION pg_catalog.pg_ptrack_get_and_clear(oid, oid) TO backup;
1245-
</programlisting>
1246-
</listitem>
1247-
</orderedlist>
1248-
12491221
</refsect2>
12501222
</refsect1>
12511223

src/backup.c

+21-50
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
125125
check_external_for_tablespaces(external_dirs, backup_conn);
126126
}
127127

128-
/* Clear ptrack files for not PTRACK backups */
129-
if (current.backup_mode != BACKUP_MODE_DIFF_PTRACK && nodeInfo->is_ptrack_enable)
130-
pg_ptrack_clear(backup_conn, nodeInfo->ptrack_version_num);
131-
132128
/* notify start of backup to PostgreSQL server */
133129
time2iso(label, lengthof(label), current.start_time, false);
134130
strncat(label, " with pg_probackup", lengthof(label) -
@@ -217,29 +213,14 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
217213
{
218214
XLogRecPtr ptrack_lsn = get_last_ptrack_lsn(backup_conn, nodeInfo);
219215

220-
if (nodeInfo->ptrack_version_num < 200)
216+
// new ptrack (>=2.0) is more robust and checks Start LSN
217+
if (ptrack_lsn > prev_backup->start_lsn || ptrack_lsn == InvalidXLogRecPtr)
221218
{
222-
// backward compatibility kludge: use Stop LSN for ptrack 1.x,
223-
if (ptrack_lsn > prev_backup->stop_lsn || ptrack_lsn == InvalidXLogRecPtr)
224-
{
225-
elog(ERROR, "LSN from ptrack_control %X/%X differs from Stop LSN of previous backup %X/%X.\n"
226-
"Create new full backup before an incremental one.",
227-
(uint32) (ptrack_lsn >> 32), (uint32) (ptrack_lsn),
228-
(uint32) (prev_backup->stop_lsn >> 32),
229-
(uint32) (prev_backup->stop_lsn));
230-
}
231-
}
232-
else
233-
{
234-
// new ptrack is more robust and checks Start LSN
235-
if (ptrack_lsn > prev_backup->start_lsn || ptrack_lsn == InvalidXLogRecPtr)
236-
{
237-
elog(ERROR, "LSN from ptrack_control %X/%X is greater than Start LSN of previous backup %X/%X.\n"
238-
"Create new full backup before an incremental one.",
239-
(uint32) (ptrack_lsn >> 32), (uint32) (ptrack_lsn),
240-
(uint32) (prev_backup->start_lsn >> 32),
241-
(uint32) (prev_backup->start_lsn));
242-
}
219+
elog(ERROR, "LSN from ptrack_control %X/%X is greater than Start LSN of previous backup %X/%X.\n"
220+
"Create new full backup before an incremental one.",
221+
(uint32) (ptrack_lsn >> 32), (uint32) (ptrack_lsn),
222+
(uint32) (prev_backup->start_lsn >> 32),
223+
(uint32) (prev_backup->start_lsn));
243224
}
244225
}
245226

@@ -407,15 +388,10 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
407388
/*
408389
* Build the page map from ptrack information.
409390
*/
410-
if (nodeInfo->ptrack_version_num >= 200)
411-
make_pagemap_from_ptrack_2(backup_files_list, backup_conn,
412-
nodeInfo->ptrack_schema,
413-
nodeInfo->ptrack_version_num,
414-
prev_backup_start_lsn);
415-
else if (nodeInfo->ptrack_version_num == 105 ||
416-
nodeInfo->ptrack_version_num == 106 ||
417-
nodeInfo->ptrack_version_num == 107)
418-
make_pagemap_from_ptrack_1(backup_files_list, backup_conn);
391+
make_pagemap_from_ptrack_2(backup_files_list, backup_conn,
392+
nodeInfo->ptrack_schema,
393+
nodeInfo->ptrack_version_num,
394+
prev_backup_start_lsn);
419395
}
420396

421397
time(&end_time);
@@ -490,8 +466,6 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
490466
arg->files_list = backup_files_list;
491467
arg->prev_filelist = prev_backup_filelist;
492468
arg->prev_start_lsn = prev_backup_start_lsn;
493-
arg->conn_arg.conn = NULL;
494-
arg->conn_arg.cancel_conn = NULL;
495469
arg->hdr_map = &(current.hdr_map);
496470
arg->thread_num = i+1;
497471
/* By default there are some error */
@@ -816,6 +790,7 @@ do_backup(InstanceState *instanceState, pgSetBackupParams *set_backup_params,
816790

817791
if (current.backup_mode == BACKUP_MODE_DIFF_PTRACK)
818792
{
793+
/* ptrack_version_num < 2.0 was already checked in get_ptrack_version() */
819794
if (nodeInfo.ptrack_version_num == 0)
820795
elog(ERROR, "This PostgreSQL instance does not support ptrack");
821796
else
@@ -2085,15 +2060,15 @@ backup_files(void *arg)
20852060
/* backup file */
20862061
if (file->is_datafile && !file->is_cfs)
20872062
{
2088-
backup_data_file(&(arguments->conn_arg), file, from_fullpath, to_fullpath,
2089-
arguments->prev_start_lsn,
2090-
current.backup_mode,
2091-
instance_config.compress_alg,
2092-
instance_config.compress_level,
2093-
arguments->nodeInfo->checksum_version,
2094-
arguments->nodeInfo->ptrack_version_num,
2095-
arguments->nodeInfo->ptrack_schema,
2096-
arguments->hdr_map, false);
2063+
backup_data_file(file, from_fullpath, to_fullpath,
2064+
arguments->prev_start_lsn,
2065+
current.backup_mode,
2066+
instance_config.compress_alg,
2067+
instance_config.compress_level,
2068+
arguments->nodeInfo->checksum_version,
2069+
arguments->nodeInfo->ptrack_version_num,
2070+
arguments->nodeInfo->ptrack_schema,
2071+
arguments->hdr_map, false);
20972072
}
20982073
else
20992074
{
@@ -2117,10 +2092,6 @@ backup_files(void *arg)
21172092
/* ssh connection to longer needed */
21182093
fio_disconnect();
21192094

2120-
/* Close connection */
2121-
if (arguments->conn_arg.conn)
2122-
pgut_disconnect(arguments->conn_arg.conn);
2123-
21242095
/* Data files transferring is successful */
21252096
arguments->ret = 0;
21262097

0 commit comments

Comments
 (0)