Skip to content

Commit ae275dc

Browse files
committed
[PBCKP-232] remove 9.5-9.6 support, part 2
1 parent 822111e commit ae275dc

20 files changed

+295
-1003
lines changed

.travis.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ env:
3232
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE PTRACK_PATCH_PG_BRANCH=REL_12_STABLE
3333
- PG_VERSION=11 PG_BRANCH=REL_11_STABLE PTRACK_PATCH_PG_BRANCH=REL_11_STABLE
3434
- PG_VERSION=10 PG_BRANCH=REL_10_STABLE
35-
- PG_VERSION=9.6 PG_BRANCH=REL9_6_STABLE
36-
- PG_VERSION=9.5 PG_BRANCH=REL9_5_STABLE
3735
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=OFF MODE=archive
3836
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=REL_13_STABLE MODE=backup
3937
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=REL_13_STABLE MODE=catchup
@@ -52,8 +50,6 @@ env:
5250
jobs:
5351
allow_failures:
5452
- if: env(PG_BRANCH) = master
55-
- if: env(PG_BRANCH) = REL9_6_STABLE
56-
- if: env(PG_BRANCH) = REL9_5_STABLE
5753
# - if: env(MODE) IN (archive, backup, delta, locking, merge, replica, retention, restore)
5854

5955
# Only run CI for master branch commits to limit our travis usage

src/backup.c

Lines changed: 45 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ parray *backup_files_list = NULL;
3232
/* We need critical section for datapagemap_add() in case of using threads */
3333
static pthread_mutex_t backup_pagemap_mutex = PTHREAD_MUTEX_INITIALIZER;
3434

35-
// TODO: move to PGnodeInfo
36-
bool exclusive_backup = false;
37-
3835
/* Is pg_start_backup() was executed */
3936
bool backup_in_progress = false;
4037

@@ -80,7 +77,7 @@ backup_stopbackup_callback(bool fatal, void *userdata)
8077
{
8178
elog(WARNING, "backup in progress, stop backup");
8279
/* don't care about stop_lsn in case of error */
83-
pg_stop_backup_send(st->conn, st->server_version, current.from_replica, exclusive_backup, NULL);
80+
pg_stop_backup_send(st->conn, st->server_version, current.from_replica, NULL);
8481
}
8582
}
8683

@@ -493,10 +490,10 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
493490
/* Notify end of backup */
494491
pg_stop_backup(instanceState, &current, backup_conn, nodeInfo);
495492

496-
/* In case of backup from replica >= 9.6 we must fix minRecPoint,
493+
/* In case of backup from replica we must fix minRecPoint,
497494
* First we must find pg_control in backup_files_list.
498495
*/
499-
if (current.from_replica && !exclusive_backup)
496+
if (current.from_replica)
500497
{
501498
pgFile *pg_control = NULL;
502499

@@ -781,11 +778,6 @@ do_backup(InstanceState *instanceState, pgSetBackupParams *set_backup_params,
781778
}
782779
}
783780

784-
if (current.from_replica && exclusive_backup)
785-
/* Check master connection options */
786-
if (instance_config.master_conn_opt.pghost == NULL)
787-
elog(ERROR, "Options for connection to master must be provided to perform backup from replica");
788-
789781
/* add note to backup if requested */
790782
if (set_backup_params && set_backup_params->note)
791783
add_note(&current, set_backup_params->note);
@@ -866,22 +858,12 @@ check_server_version(PGconn *conn, PGNodeInfo *nodeInfo)
866858
elog(ERROR, "Unknown server version %d", nodeInfo->server_version);
867859

868860
if (nodeInfo->server_version < 100000)
869-
sprintf(nodeInfo->server_version_str, "%d.%d",
870-
nodeInfo->server_version / 10000,
871-
(nodeInfo->server_version / 100) % 100);
872-
else
873-
sprintf(nodeInfo->server_version_str, "%d",
874-
nodeInfo->server_version / 10000);
875-
876-
if (nodeInfo->server_version < 90500)
877861
elog(ERROR,
878862
"server version is %s, must be %s or higher",
879-
nodeInfo->server_version_str, "9.5");
863+
nodeInfo->server_version_str, "10");
880864

881-
if (current.from_replica && nodeInfo->server_version < 90600)
882-
elog(ERROR,
883-
"server version is %s, must be %s or higher for backup from replica",
884-
nodeInfo->server_version_str, "9.6");
865+
sprintf(nodeInfo->server_version_str, "%d",
866+
nodeInfo->server_version / 10000);
885867

886868
if (nodeInfo->pgpro_support)
887869
res = pgut_execute(conn, "SELECT pg_catalog.pgpro_edition()", 0, NULL);
@@ -922,9 +904,6 @@ check_server_version(PGconn *conn, PGNodeInfo *nodeInfo)
922904

923905
if (res)
924906
PQclear(res);
925-
926-
/* Do exclusive backup only for PostgreSQL 9.5 */
927-
exclusive_backup = nodeInfo->server_version < 90600;
928907
}
929908

930909
/*
@@ -1006,16 +985,10 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup,
1006985

1007986
/* 2nd argument is 'fast'*/
1008987
params[1] = smooth ? "false" : "true";
1009-
if (!exclusive_backup)
1010-
res = pgut_execute(conn,
1011-
"SELECT pg_catalog.pg_start_backup($1, $2, false)",
1012-
2,
1013-
params);
1014-
else
1015-
res = pgut_execute(conn,
1016-
"SELECT pg_catalog.pg_start_backup($1, $2)",
1017-
2,
1018-
params);
988+
res = pgut_execute(conn,
989+
"SELECT pg_catalog.pg_start_backup($1, $2, false)",
990+
2,
991+
params);
1019992

1020993
/*
1021994
* Set flag that pg_start_backup() was called. If an error will happen it
@@ -1034,14 +1007,10 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup,
10341007
PQclear(res);
10351008

10361009
if ((!backup->stream || backup->backup_mode == BACKUP_MODE_DIFF_PAGE) &&
1037-
!backup->from_replica &&
1038-
!(nodeInfo->server_version < 90600 &&
1039-
!nodeInfo->is_superuser))
1010+
!backup->from_replica)
10401011
/*
10411012
* Switch to a new WAL segment. It is necessary to get archived WAL
10421013
* segment, which includes start LSN of current backup.
1043-
* Don`t do this for replica backups and for PG 9.5 if pguser is not superuser
1044-
* (because in 9.5 only superuser can switch WAL)
10451014
*/
10461015
pg_switch_wal(conn);
10471016
}
@@ -1546,20 +1515,9 @@ pg_create_restore_point(PGconn *conn, time_t backup_start_time)
15461515
}
15471516

15481517
void
1549-
pg_stop_backup_send(PGconn *conn, int server_version, bool is_started_on_replica, bool is_exclusive, char **query_text)
1518+
pg_stop_backup_send(PGconn *conn, int server_version, bool is_started_on_replica, char **query_text)
15501519
{
15511520
static const char
1552-
stop_exlusive_backup_query[] =
1553-
/*
1554-
* Stop the non-exclusive backup. Besides stop_lsn it returns from
1555-
* pg_stop_backup(false) copy of the backup label and tablespace map
1556-
* so they can be written to disk by the caller.
1557-
* TODO, question: add NULLs as backup_label and tablespace_map?
1558-
*/
1559-
"SELECT"
1560-
" pg_catalog.txid_snapshot_xmax(pg_catalog.txid_current_snapshot()),"
1561-
" current_timestamp(0)::timestamptz,"
1562-
" pg_catalog.pg_stop_backup() as lsn",
15631521
stop_backup_on_master_query[] =
15641522
"SELECT"
15651523
" pg_catalog.txid_snapshot_xmax(pg_catalog.txid_current_snapshot()),"
@@ -1568,16 +1526,8 @@ pg_stop_backup_send(PGconn *conn, int server_version, bool is_started_on_replica
15681526
" labelfile,"
15691527
" spcmapfile"
15701528
" FROM pg_catalog.pg_stop_backup(false, false)",
1571-
stop_backup_on_master_before10_query[] =
1572-
"SELECT"
1573-
" pg_catalog.txid_snapshot_xmax(pg_catalog.txid_current_snapshot()),"
1574-
" current_timestamp(0)::timestamptz,"
1575-
" lsn,"
1576-
" labelfile,"
1577-
" spcmapfile"
1578-
" FROM pg_catalog.pg_stop_backup(false)",
15791529
/*
1580-
* In case of backup from replica >= 9.6 we do not trust minRecPoint
1530+
* In case of backup from replica we do not trust minRecPoint
15811531
* and stop_backup LSN, so we use latest replayed LSN as STOP LSN.
15821532
*/
15831533
stop_backup_on_replica_query[] =
@@ -1587,28 +1537,12 @@ pg_stop_backup_send(PGconn *conn, int server_version, bool is_started_on_replica
15871537
" pg_catalog.pg_last_wal_replay_lsn(),"
15881538
" labelfile,"
15891539
" spcmapfile"
1590-
" FROM pg_catalog.pg_stop_backup(false, false)",
1591-
stop_backup_on_replica_before10_query[] =
1592-
"SELECT"
1593-
" pg_catalog.txid_snapshot_xmax(pg_catalog.txid_current_snapshot()),"
1594-
" current_timestamp(0)::timestamptz,"
1595-
" pg_catalog.pg_last_xlog_replay_location(),"
1596-
" labelfile,"
1597-
" spcmapfile"
1598-
" FROM pg_catalog.pg_stop_backup(false)";
1540+
" FROM pg_catalog.pg_stop_backup(false, false)";
15991541

16001542
const char * const stop_backup_query =
1601-
is_exclusive ?
1602-
stop_exlusive_backup_query :
1603-
server_version >= 100000 ?
1604-
(is_started_on_replica ?
1543+
is_started_on_replica ?
16051544
stop_backup_on_replica_query :
1606-
stop_backup_on_master_query
1607-
) :
1608-
(is_started_on_replica ?
1609-
stop_backup_on_replica_before10_query :
1610-
stop_backup_on_master_before10_query
1611-
);
1545+
stop_backup_on_master_query;
16121546
bool sent = false;
16131547

16141548
/* Make proper timestamp format for parse_time(recovery_time) */
@@ -1641,7 +1575,7 @@ pg_stop_backup_send(PGconn *conn, int server_version, bool is_started_on_replica
16411575
*/
16421576
void
16431577
pg_stop_backup_consume(PGconn *conn, int server_version,
1644-
bool is_exclusive, uint32 timeout, const char *query_text,
1578+
uint32 timeout, const char *query_text,
16451579
PGStopBackupResult *result)
16461580
{
16471581
PGresult *query_result;
@@ -1743,28 +1677,18 @@ pg_stop_backup_consume(PGconn *conn, int server_version,
17431677
/* get backup_label_content */
17441678
result->backup_label_content = NULL;
17451679
// if (!PQgetisnull(query_result, 0, backup_label_colno))
1746-
if (!is_exclusive)
1747-
{
1748-
result->backup_label_content_len = PQgetlength(query_result, 0, backup_label_colno);
1749-
if (result->backup_label_content_len > 0)
1750-
result->backup_label_content = pgut_strndup(PQgetvalue(query_result, 0, backup_label_colno),
1751-
result->backup_label_content_len);
1752-
} else {
1753-
result->backup_label_content_len = 0;
1754-
}
1680+
result->backup_label_content_len = PQgetlength(query_result, 0, backup_label_colno);
1681+
if (result->backup_label_content_len > 0)
1682+
result->backup_label_content = pgut_strndup(PQgetvalue(query_result, 0, backup_label_colno),
1683+
result->backup_label_content_len);
17551684

17561685
/* get tablespace_map_content */
17571686
result->tablespace_map_content = NULL;
17581687
// if (!PQgetisnull(query_result, 0, tablespace_map_colno))
1759-
if (!is_exclusive)
1760-
{
1761-
result->tablespace_map_content_len = PQgetlength(query_result, 0, tablespace_map_colno);
1762-
if (result->tablespace_map_content_len > 0)
1763-
result->tablespace_map_content = pgut_strndup(PQgetvalue(query_result, 0, tablespace_map_colno),
1764-
result->tablespace_map_content_len);
1765-
} else {
1766-
result->tablespace_map_content_len = 0;
1767-
}
1688+
result->tablespace_map_content_len = PQgetlength(query_result, 0, tablespace_map_colno);
1689+
if (result->tablespace_map_content_len > 0)
1690+
result->tablespace_map_content = pgut_strndup(PQgetvalue(query_result, 0, tablespace_map_colno),
1691+
result->tablespace_map_content_len);
17681692
}
17691693

17701694
/*
@@ -1832,21 +1756,18 @@ pg_stop_backup(InstanceState *instanceState, pgBackup *backup, PGconn *pg_startb
18321756

18331757
/* Create restore point
18341758
* Only if backup is from master.
1835-
* For PG 9.5 create restore point only if pguser is superuser.
18361759
*/
1837-
if (!backup->from_replica &&
1838-
!(nodeInfo->server_version < 90600 &&
1839-
!nodeInfo->is_superuser)) //TODO: check correctness
1760+
if (!backup->from_replica)
18401761
pg_create_restore_point(pg_startbackup_conn, backup->start_time);
18411762

18421763
/* Execute pg_stop_backup using PostgreSQL connection */
1843-
pg_stop_backup_send(pg_startbackup_conn, nodeInfo->server_version, backup->from_replica, exclusive_backup, &query_text);
1764+
pg_stop_backup_send(pg_startbackup_conn, nodeInfo->server_version, backup->from_replica, &query_text);
18441765

18451766
/*
18461767
* Wait for the result of pg_stop_backup(), but no longer than
18471768
* archive_timeout seconds
18481769
*/
1849-
pg_stop_backup_consume(pg_startbackup_conn, nodeInfo->server_version, exclusive_backup, timeout, query_text, &stop_backup_result);
1770+
pg_stop_backup_consume(pg_startbackup_conn, nodeInfo->server_version, timeout, query_text, &stop_backup_result);
18501771

18511772
if (backup->stream)
18521773
{
@@ -1859,28 +1780,25 @@ pg_stop_backup(InstanceState *instanceState, pgBackup *backup, PGconn *pg_startb
18591780
wait_wal_and_calculate_stop_lsn(xlog_path, stop_backup_result.lsn, backup);
18601781

18611782
/* Write backup_label and tablespace_map */
1862-
if (!exclusive_backup)
1783+
Assert(stop_backup_result.backup_label_content != NULL);
1784+
1785+
/* Write backup_label */
1786+
pg_stop_backup_write_file_helper(backup->database_dir, PG_BACKUP_LABEL_FILE, "backup label",
1787+
stop_backup_result.backup_label_content, stop_backup_result.backup_label_content_len,
1788+
backup_files_list);
1789+
free(stop_backup_result.backup_label_content);
1790+
stop_backup_result.backup_label_content = NULL;
1791+
stop_backup_result.backup_label_content_len = 0;
1792+
1793+
/* Write tablespace_map */
1794+
if (stop_backup_result.tablespace_map_content != NULL)
18631795
{
1864-
Assert(stop_backup_result.backup_label_content != NULL);
1865-
1866-
/* Write backup_label */
1867-
pg_stop_backup_write_file_helper(backup->database_dir, PG_BACKUP_LABEL_FILE, "backup label",
1868-
stop_backup_result.backup_label_content, stop_backup_result.backup_label_content_len,
1796+
pg_stop_backup_write_file_helper(backup->database_dir, PG_TABLESPACE_MAP_FILE, "tablespace map",
1797+
stop_backup_result.tablespace_map_content, stop_backup_result.tablespace_map_content_len,
18691798
backup_files_list);
1870-
free(stop_backup_result.backup_label_content);
1871-
stop_backup_result.backup_label_content = NULL;
1872-
stop_backup_result.backup_label_content_len = 0;
1873-
1874-
/* Write tablespace_map */
1875-
if (stop_backup_result.tablespace_map_content != NULL)
1876-
{
1877-
pg_stop_backup_write_file_helper(backup->database_dir, PG_TABLESPACE_MAP_FILE, "tablespace map",
1878-
stop_backup_result.tablespace_map_content, stop_backup_result.tablespace_map_content_len,
1879-
backup_files_list);
1880-
free(stop_backup_result.tablespace_map_content);
1881-
stop_backup_result.tablespace_map_content = NULL;
1882-
stop_backup_result.tablespace_map_content_len = 0;
1883-
}
1799+
free(stop_backup_result.tablespace_map_content);
1800+
stop_backup_result.tablespace_map_content = NULL;
1801+
stop_backup_result.tablespace_map_content_len = 0;
18841802
}
18851803

18861804
if (backup->stream)

src/catchup.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ catchup_preflight_checks(PGNodeInfo *source_node_info, PGconn *source_conn,
185185
elog(ERROR, "Ptrack is disabled");
186186
}
187187

188-
if (current.from_replica && exclusive_backup)
189-
elog(ERROR, "Catchup from standby is only available for PostgreSQL >= 9.6");
190-
191188
/* check that we don't overwrite tablespace in source pgdata */
192189
catchup_check_tablespaces_existance_in_tbsmapping(source_conn);
193190

@@ -1012,13 +1009,13 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
10121009
pg_silent_client_messages(source_conn);
10131010

10141011
/* Execute pg_stop_backup using PostgreSQL connection */
1015-
pg_stop_backup_send(source_conn, source_node_info.server_version, current.from_replica, exclusive_backup, &stop_backup_query_text);
1012+
pg_stop_backup_send(source_conn, source_node_info.server_version, current.from_replica, &stop_backup_query_text);
10161013

10171014
/*
10181015
* Wait for the result of pg_stop_backup(), but no longer than
10191016
* archive_timeout seconds
10201017
*/
1021-
pg_stop_backup_consume(source_conn, source_node_info.server_version, exclusive_backup, timeout, stop_backup_query_text, &stop_backup_result);
1018+
pg_stop_backup_consume(source_conn, source_node_info.server_version, timeout, stop_backup_query_text, &stop_backup_result);
10221019

10231020
/* Cleanup */
10241021
pg_free(stop_backup_query_text);
@@ -1076,12 +1073,10 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
10761073
}
10771074

10781075
/*
1079-
* In case of backup from replica >= 9.6 we must fix minRecPoint
1076+
* In case of backup from replica we must fix minRecPoint
10801077
*/
1081-
if (current.from_replica && !exclusive_backup)
1082-
{
1078+
if (current.from_replica)
10831079
set_min_recovery_point(source_pg_control_file, dest_pgdata, current.stop_lsn);
1084-
}
10851080

10861081
/* close ssh session in main thread */
10871082
fio_disconnect();

src/dir.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@ static char *pgdata_exclude_files[] =
8383
"probackup_recovery.conf",
8484
"recovery.signal",
8585
"standby.signal",
86-
NULL
87-
};
8886

89-
static char *pgdata_exclude_files_non_exclusive[] =
90-
{
9187
/*skip in non-exclusive backup */
9288
"backup_label",
9389
"tablespace_map",
@@ -571,18 +567,6 @@ dir_check_file(pgFile *file, bool backup_logs)
571567
/* Check if we need to exclude file by name */
572568
if (S_ISREG(file->mode))
573569
{
574-
if (!exclusive_backup)
575-
{
576-
for (i = 0; pgdata_exclude_files_non_exclusive[i]; i++)
577-
if (strcmp(file->rel_path,
578-
pgdata_exclude_files_non_exclusive[i]) == 0)
579-
{
580-
/* Skip */
581-
elog(VERBOSE, "Excluding file: %s", file->name);
582-
return CHECK_FALSE;
583-
}
584-
}
585-
586570
for (i = 0; pgdata_exclude_files[i]; i++)
587571
if (strcmp(file->rel_path, pgdata_exclude_files[i]) == 0)
588572
{

0 commit comments

Comments
 (0)