Skip to content

Catchup command implementation #392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 73 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
51e20d9
fix forgotten in 29adb5b comment
kulaginm Feb 1, 2021
c4a8488
porting catchup to release_2_5 branch
kulaginm May 14, 2021
3d2bcda
Merge branch 'master' into release_2_5-pgpro-4850
gsmolk May 15, 2021
69db990
use correct args for wait_wal_lsn()
gsmolk May 15, 2021
6a3c3d3
[Issue #277] review, some improvements, refactoring and overhaul, sev…
gsmolk May 16, 2021
2afa159
[Issue #277] run catchup test in remote mode only if envvar PGPROBACK…
gsmolk May 16, 2021
2f843a7
[Issue #227] Remove support of ptrack1.x, clean up redundant code in …
gsmolk May 16, 2021
2f8617d
cosmetic changes
kulaginm May 18, 2021
61f167c
rename pg_checksum_enable() to pg_is_checksum_enabled
kulaginm May 18, 2021
30543b2
remove unused instanceState from pg_start_backup()
kulaginm May 24, 2021
1657fee
Refactor wait_wal_lsn(): remove unused pgBackup * parameter and repla…
kulaginm May 24, 2021
fffa8b1
Refactor pg_stop_backup(): remove useless conn variable
kulaginm May 24, 2021
ed5d71e
Make some functions and variables (from backup.c) accessible from oth…
kulaginm May 24, 2021
f7196e8
Remove some references to global stream_wal variable
kulaginm May 24, 2021
bd9cd9f
remove unused variable externaldir
kulaginm May 24, 2021
1793c68
Yet another split of pg_stop_backup(): separate verification of stop_…
kulaginm May 24, 2021
a13a23f
Merge branch 'release_2_5-pgpro-5018' into release_2_5-pgpro-4850
kulaginm May 24, 2021
7415e6c
Merge branch 'release_2_5-pg_stop_backup-decomposition2' into release…
kulaginm May 24, 2021
02aa321
catchup update #1
kulaginm May 24, 2021
24bd657
make separate function for node creation in catchup tests (make_empty…
kulaginm May 24, 2021
eab58c1
simple delta catchup test
kulaginm May 24, 2021
9efea2b
Remove get_min_recovery_point() and use get_redo() instead
kulaginm May 24, 2021
1c1a89c
catchup update #2
kulaginm May 25, 2021
d7e2606
catchup update #3 (tablespace mapping fix)
kulaginm May 25, 2021
2c8b7e9
create pfilearray_clear_locks() helper function
kulaginm May 26, 2021
bbacdf0
Merge remote-tracking branch 'origin/release_2_5-pg_stop_backup-decom…
kulaginm May 26, 2021
50cd84d
followup for 02aa32107433c34f6f7f264585e051cc7b5dbab1
kulaginm May 26, 2021
bc2f392
catchup update #4 (fix removed files)
kulaginm May 26, 2021
55ee681
Merge remote-tracking branch 'origin/release_2_5' into release_2_5-pg…
kulaginm May 27, 2021
05c451e
test stabilization
kulaginm May 27, 2021
fd7571b
test_tablefile_truncation added
kulaginm May 27, 2021
72b5bba
Improve catchup help
kulaginm May 28, 2021
bee476c
pg_control now is synced last
kulaginm May 31, 2021
74cd21a
apply lubennikovaav review.patch
kulaginm May 31, 2021
271cf16
indent correction as noted by Roman Zharkov
kulaginm May 31, 2021
8e03b8d
Review answer #1
kulaginm May 31, 2021
b294557
typo
kulaginm Jun 1, 2021
2e3adf1
check emptyness of dest_pgdata
kulaginm Jun 1, 2021
861ddd3
check that user uses tablespace_mapping
kulaginm Jun 1, 2021
e865c83
fix destination file existance
kulaginm Jun 2, 2021
2598c99
Print octal permissions in tests compare_pgdata()
kulaginm Jun 2, 2021
746a1a5
fix local delta backup
kulaginm Jun 2, 2021
2cceb71
Review answer #2
kulaginm Jun 2, 2021
803a7e3
add more catchup preflight checks
kulaginm Jun 3, 2021
5b46f09
rename cmdline parameters, remove annoyng message
kulaginm Jun 3, 2021
18c4b46
one more review pass
lubennikovaav Jun 7, 2021
19ace74
Merge remote-tracking branch 'origin/release_2_5' into release_2_5-pg…
kulaginm Jun 7, 2021
01fe2f9
Additional tablespace checks
kulaginm Jun 7, 2021
39df7ac
[DOC] Added documentation for catchup command
indrups Jun 7, 2021
fc76038
Proofread catchup messages
indrups Jun 7, 2021
132ec94
fix lost lost --no-color option in docs
kulaginm Jun 7, 2021
dc8d425
Merge branch 'release_2_5-pgpro-4850' of https://github.com/postgresp…
kulaginm Jun 7, 2021
ce34427
Pure language refinement
indrups Jun 7, 2021
5089400
fix datafile truncation bug
kulaginm Jun 7, 2021
3e43d00
Wording in documentation refined from techwriters' feedback
indrups Jun 8, 2021
55c114f
bugfix: remove unnecessary tablespace_map file write
kulaginm Jun 8, 2021
8a9c6ce
Merge branch 'release_2_5-pgpro-4850' of https://github.com/postgresp…
kulaginm Jun 8, 2021
9cde0f9
Modify tablespace preflight checks (as per comment by Roman Zharkov)
kulaginm Jun 8, 2021
1ab642a
typo
kulaginm Jun 9, 2021
6240c9f
bugfix: fix incorrect pg_control reading (as per comment by Roman Zha…
kulaginm Jun 9, 2021
1a48b0a
bugfix: add additional cmdline check (reported by Roman Zharkov)
kulaginm Jun 9, 2021
1811eb7
refine catchup tests
kulaginm Jun 10, 2021
629b732
more checks and tests
kulaginm Jun 10, 2021
b15fcf6
refine test_same_db_id test
kulaginm Jun 10, 2021
ba22e2e
split do_catchup_instance() into parts #1
kulaginm Jun 10, 2021
8d3fb16
TLI tests and TLI check fix
kulaginm Jun 10, 2021
6b6086f
postgres-9.5 compability fix
kulaginm Jun 11, 2021
ff444b3
rename tests (include simple tests to basic suite)
kulaginm Jun 11, 2021
83ccabc
add comment of future improvements
kulaginm Jun 11, 2021
4a2419a
Merge remote-tracking branch 'origin/release_2_5' into release_2_5-pg…
kulaginm Jun 14, 2021
d987131
fix help message
kulaginm Jun 15, 2021
68cfd5b
[DOC] Documentation updated upon feedback from Probackup team
indrups Jun 16, 2021
de58e46
Merge branch 'release_2_5' into release_2_5-pgpro-4850
gsmolk Jun 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ OBJS = src/utils/configuration.o src/utils/json.o src/utils/logger.o \
OBJS += src/archive.o src/backup.o src/catalog.o src/checkdb.o src/configure.o src/data.o \
src/delete.o src/dir.o src/fetch.o src/help.o src/init.o src/merge.o \
src/parsexlog.o src/ptrack.o src/pg_probackup.o src/restore.o src/show.o src/stream.o \
src/util.o src/validate.o src/datapagemap.o
src/util.o src/validate.o src/datapagemap.o src/catchup.o

# borrowed files
OBJS += src/pg_crc.o src/receivelog.o src/streamutil.o \
Expand Down
282 changes: 279 additions & 3 deletions doc/pgprobackup.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ do_archive_push(InstanceState *instanceState, InstanceConfig *instance, char *wa
elog(ERROR, "getcwd() error");

/* verify that archive-push --instance parameter is valid */
system_id = get_system_identifier(current_dir);
system_id = get_system_identifier(current_dir, FIO_DB_HOST);

if (instance->pgdata == NULL)
elog(ERROR, "Cannot read pg_probackup.conf for this instance");
Expand Down
78 changes: 48 additions & 30 deletions src/backup.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
{
int i;
char external_prefix[MAXPGPATH]; /* Temp value. Used as template */
char dst_backup_path[MAXPGPATH];
char label[1024];
XLogRecPtr prev_backup_start_lsn = InvalidXLogRecPtr;

Expand Down Expand Up @@ -137,7 +136,7 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
#if PG_VERSION_NUM >= 90600
current.tli = get_current_timeline(backup_conn);
#else
current.tli = get_current_timeline_from_control(false);
current.tli = get_current_timeline_from_control(instance_config.pgdata, FIO_DB_HOST, false);
#endif

/*
Expand Down Expand Up @@ -258,17 +257,19 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
/* start stream replication */
if (current.stream)
{
join_path_components(dst_backup_path, current.database_dir, PG_XLOG_DIR);
fio_mkdir(dst_backup_path, DIR_PERMISSION, FIO_BACKUP_HOST);
char stream_xlog_path[MAXPGPATH];

start_WAL_streaming(backup_conn, dst_backup_path, &instance_config.conn_opt,
join_path_components(stream_xlog_path, current.database_dir, PG_XLOG_DIR);
fio_mkdir(stream_xlog_path, DIR_PERMISSION, FIO_BACKUP_HOST);

start_WAL_streaming(backup_conn, stream_xlog_path, &instance_config.conn_opt,
current.start_lsn, current.tli);

/* Make sure that WAL streaming is working
* PAGE backup in stream mode is waited twice, first for
* segment in WAL archive and then for streamed segment
*/
wait_wal_lsn(dst_backup_path, current.start_lsn, true, current.tli, false, true, ERROR, true);
wait_wal_lsn(stream_xlog_path, current.start_lsn, true, current.tli, false, true, ERROR, true);
}

/* initialize backup's file list */
Expand Down Expand Up @@ -315,23 +316,7 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
elog(ERROR, "PGDATA is almost empty. Either it was concurrently deleted or "
"pg_probackup do not possess sufficient permissions to list PGDATA content");

/* Calculate pgdata_bytes */
for (i = 0; i < parray_num(backup_files_list); i++)
{
pgFile *file = (pgFile *) parray_get(backup_files_list, i);

if (file->external_dir_num != 0)
continue;

if (S_ISDIR(file->mode))
{
current.pgdata_bytes += 4096;
continue;
}

current.pgdata_bytes += file->size;
}

current.pgdata_bytes += calculate_datasize_of_filelist(backup_files_list);
pretty_size(current.pgdata_bytes, pretty_bytes, lengthof(pretty_bytes));
elog(INFO, "PGDATA size: %s", pretty_bytes);

Expand Down Expand Up @@ -697,7 +682,7 @@ pgdata_basic_setup(ConnectionOptions conn_opt, PGNodeInfo *nodeInfo)

if (nodeInfo->is_superuser)
elog(WARNING, "Current PostgreSQL role is superuser. "
"It is not recommended to run backup or checkdb as superuser.");
"It is not recommended to run pg_probackup under superuser.");

strlcpy(current.server_version, nodeInfo->server_version_str,
sizeof(current.server_version));
Expand Down Expand Up @@ -786,7 +771,7 @@ do_backup(InstanceState *instanceState, pgSetBackupParams *set_backup_params,
// elog(WARNING, "ptrack_version_num %d", ptrack_version_num);

if (nodeInfo.ptrack_version_num > 0)
nodeInfo.is_ptrack_enable = pg_ptrack_enable(backup_conn, nodeInfo.ptrack_version_num);
nodeInfo.is_ptrack_enabled = pg_is_ptrack_enabled(backup_conn, nodeInfo.ptrack_version_num);

if (current.backup_mode == BACKUP_MODE_DIFF_PTRACK)
{
Expand All @@ -795,7 +780,7 @@ do_backup(InstanceState *instanceState, pgSetBackupParams *set_backup_params,
elog(ERROR, "This PostgreSQL instance does not support ptrack");
else
{
if (!nodeInfo.is_ptrack_enable)
if (!nodeInfo.is_ptrack_enabled)
elog(ERROR, "Ptrack is disabled");
}
}
Expand Down Expand Up @@ -953,12 +938,12 @@ check_server_version(PGconn *conn, PGNodeInfo *nodeInfo)
* All system identifiers must be equal.
*/
void
check_system_identifiers(PGconn *conn, char *pgdata)
check_system_identifiers(PGconn *conn, const char *pgdata)
{
uint64 system_id_conn;
uint64 system_id_pgdata;

system_id_pgdata = get_system_identifier(pgdata);
system_id_pgdata = get_system_identifier(pgdata, FIO_DB_HOST);
system_id_conn = get_remote_system_identifier(conn);

/* for checkdb check only system_id_pgdata and system_id_conn */
Expand Down Expand Up @@ -1069,7 +1054,7 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup,
* Switch to a new WAL segment. It should be called only for master.
* For PG 9.5 it should be called only if pguser is superuser.
*/
static void
void
pg_switch_wal(PGconn *conn)
{
PGresult *res;
Expand Down Expand Up @@ -2282,7 +2267,7 @@ process_block_change(ForkNumber forknum, RelFileNode rnode, BlockNumber blkno)

}

static void
void
check_external_for_tablespaces(parray *external_list, PGconn *backup_conn)
{
PGresult *res;
Expand Down Expand Up @@ -2346,3 +2331,36 @@ check_external_for_tablespaces(parray *external_list, PGconn *backup_conn)
}
}
}

/*
* Calculate pgdata_bytes
* accepts (parray *) of (pgFile *)
*/
int64
calculate_datasize_of_filelist(parray *filelist)
{
int64 bytes = 0;
int i;

/* parray_num don't check for NULL */
if (filelist == NULL)
return 0;

for (i = 0; i < parray_num(filelist); i++)
{
pgFile *file = (pgFile *) parray_get(filelist, i);

if (file->external_dir_num != 0)
continue;

if (S_ISDIR(file->mode))
{
// TODO is a dir always 4K?
bytes += 4096;
continue;
}

bytes += file->size;
}
return bytes;
}
2 changes: 1 addition & 1 deletion src/catalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -2883,7 +2883,7 @@ pgNodeInit(PGNodeInfo *node)
node->server_version_str[0] = '\0';

node->ptrack_version_num = 0;
node->is_ptrack_enable = false;
node->is_ptrack_enabled = false;
node->ptrack_schema = NULL;
}

Expand Down
Loading