Skip to content

Commit 8daffee

Browse files
committed
Detect ptrack support and remove disable ptrack option.
1 parent cd9a119 commit 8daffee

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

backup.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ static bool pg_is_standby(void);
6565
static void get_lsn(PGconn *conn, PGresult *res, XLogRecPtr *lsn, bool stop_backup);
6666
static void get_xid(PGresult *res, uint32 *xid);
6767
static void pg_ptrack_clear(void);
68+
static bool pg_ptrack_support(void);
6869
static char *pg_ptrack_get_and_clear(Oid tablespace_oid,
6970
Oid db_oid,
7071
Oid rel_oid,
@@ -106,6 +107,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
106107
pthread_t backup_threads[num_threads];
107108
pthread_t stream_thread;
108109
backup_files_args *backup_threads_args[num_threads];
110+
bool is_ptrack_support;
109111

110112

111113
/* repack the options */
@@ -131,6 +133,10 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
131133
*/
132134
current.tli = get_current_timeline(false);
133135

136+
is_ptrack_support = pg_ptrack_support();
137+
if (current.backup_mode == BACKUP_MODE_DIFF_PTRACK && !is_ptrack_support)
138+
elog(ERROR, "Current Postgres instance is not support ptrack");
139+
134140
/*
135141
* In differential backup mode, check if there is an already-validated
136142
* full backup on current timeline.
@@ -148,7 +154,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
148154
}
149155

150156
/* clear ptrack files for FULL and DIFF backup */
151-
if (current.backup_mode != BACKUP_MODE_DIFF_PTRACK && !disable_ptrack_clear)
157+
if (current.backup_mode != BACKUP_MODE_DIFF_PTRACK && is_ptrack_support)
152158
pg_ptrack_clear();
153159

154160
/* notify start of backup to PostgreSQL server */
@@ -635,6 +641,21 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
635641
PQclear(res);
636642
}
637643

644+
static bool
645+
pg_ptrack_support(void)
646+
{
647+
PGresult *res_db;
648+
reconnect();
649+
res_db = execute("SELECT proname FROM pg_proc WHERE proname='pg_ptrack_clear'", 0, NULL);
650+
if (PQntuples(res_db) == 0)
651+
{
652+
PQclear(res_db);
653+
disconnect();
654+
return false;
655+
}
656+
return true;
657+
}
658+
638659
static void
639660
pg_ptrack_clear(void)
640661
{

expected/option.out

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Backup options:
2626
--validate validate backup after taking it
2727
--keep-data-generations=N keep GENERATION of full data backup
2828
--keep-data-days=DAY keep enough data backup to recover to DAY days age
29-
--disable-ptrack-clear disable clear ptrack for postgres without ptrack
3029
--backup-pg-log start backup pg_log directory
3130
--from-replica use non exclusive start backup for replica
3231

pg_arman.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ static int keep_data_days = KEEP_INFINITE;
3737
int num_threads = 1;
3838
bool stream_wal = false;
3939
bool from_replica = false;
40-
bool disable_ptrack_clear = false;
4140
static bool backup_logs = false;
4241
static bool backup_validate = false;
4342
bool progress = false;
@@ -66,7 +65,6 @@ static pgut_option options[] =
6665
{ 'b', 8, "stream", &stream_wal },
6766
{ 'b', 11, "progress", &progress },
6867
/* backup options */
69-
{ 'b', 9, "disable-ptrack-clear", &disable_ptrack_clear },
7068
{ 'b', 10, "backup-pg-log", &backup_logs },
7169
{ 'f', 'b', "backup-mode", opt_backup_mode, SOURCE_ENV },
7270
{ 'b', 'C', "smooth-checkpoint", &smooth_checkpoint, SOURCE_ENV },
@@ -255,7 +253,6 @@ pgut_help(bool details)
255253
printf(_(" --validate validate backup after taking it\n"));
256254
printf(_(" --keep-data-generations=N keep GENERATION of full data backup\n"));
257255
printf(_(" --keep-data-days=DAY keep enough data backup to recover to DAY days age\n"));
258-
printf(_(" --disable-ptrack-clear disable clear ptrack for postgres without ptrack\n"));
259256
printf(_(" --backup-pg-log start backup pg_log directory\n"));
260257
printf(_(" --from-replica use non exclusive start backup for replica\n"));
261258
printf(_("\nRestore options:\n"));

pg_arman.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ extern parray *backup_files_list;
213213
extern int num_threads;
214214
extern bool stream_wal;
215215
extern bool from_replica;
216-
extern bool disable_ptrack_clear;
217216
extern bool progress;
218217

219218
/* in backup.c */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy