Skip to content

Pgpro 5421. --wal-file-path option #437

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 25 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
01c06e5
Added tests for --wal-file-path
dlepikhova Aug 31, 2021
2d13474
Reterned wal-file-path option
dlepikhova Sep 1, 2021
fcb4dae
Fix tests for checking wal-file-path option
dlepikhova Sep 3, 2021
8dd36c1
Fix test_wal_file_path_3 for checking option wal-file-path setted by …
dlepikhova Sep 16, 2021
3b87069
Fixes for --wal-file-path option
dlepikhova Sep 27, 2021
4e66821
Added pg_probackup.log reading for checking --wal-file-path option
dlepikhova Oct 4, 2021
e1edfa4
Added warnings for -j and --batch-size setted while --wal-file-path d…
dlepikhova Oct 4, 2021
b3e9072
[Issue #439] skip unsupported tests in 9.5 (tests with backups from r…
kulaginm Oct 11, 2021
b48ef46
Merge branch 'master' into PGPRO-5421
kulaginm Oct 11, 2021
4be96c6
[Issue #439] revert .travis.yml
kulaginm Oct 11, 2021
bf0936c
Merge branch 'issue_439' into PGPRO-5421
kulaginm Oct 11, 2021
3500e9f
Used an existing code fragment copying one file into one stream inste…
dlepikhova Oct 15, 2021
b3c2673
Merge branch 'master' into PGPRO-5421
kulaginm Nov 15, 2021
17bd528
[PGPRO-5421] cleanup patch code
kulaginm Nov 15, 2021
f601238
[PGPRO-5421] modify test_wal_file_path_3 test to prevent pushing wal …
kulaginm Nov 15, 2021
5bc3fb2
[PGPRO-5421] fix test_wal_file_path_3 portability
kulaginm Nov 15, 2021
a9f3e80
[PGPRO-5421] rewrite --wal-file-path logic and tests
kulaginm Nov 15, 2021
3529a17
[PGPRO-5421] fix test_waldir_outside_pgdata_archiving for 9.6
kulaginm Nov 16, 2021
bbdf5ca
[PGPRO-5421] fix for test test_archive_push_sanity
kulaginm Nov 18, 2021
f73a5d9
Fixes in src/help.c about the list keys of archive-push command
dlepikhova Nov 18, 2021
0efb8e6
Fix in expected/option_help.out to pass tests correctly
dlepikhova Nov 18, 2021
4194d7e
Added clarifications about --wal-file-path to doc/pgprobackup.xml
dlepikhova Nov 19, 2021
7972cf7
Fixes if tests/archive.py for passing tests on Windows
dlepikhova Nov 19, 2021
5cd1e16
[DOC][PGPRO-5421] [skip travis] Slightly edited the documentation update
indrups Nov 19, 2021
bb3d425
[ci skip] remove travis checks before merge
kulaginm Nov 22, 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
Prev Previous commit
Next Next commit
[PGPRO-5421] fix for test test_archive_push_sanity
  • Loading branch information
kulaginm committed Nov 18, 2021
commit bbdf5cadad62786d4acd5af2313e90dbee01b869
2 changes: 1 addition & 1 deletion src/backup.c
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ check_system_identifiers(PGconn *conn, const char *pgdata)
uint64 system_id_conn;
uint64 system_id_pgdata;

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

/* for checkdb check only system_id_pgdata and system_id_conn */
Expand Down
6 changes: 3 additions & 3 deletions src/catchup.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ catchup_init_state(PGNodeInfo *source_node_info, const char *source_pgdata, cons

/* Get WAL segments size and system ID of source PG instance */
instance_config.xlog_seg_size = get_xlog_seg_size(source_pgdata);
instance_config.system_identifier = get_system_identifier(source_pgdata, FIO_DB_HOST);
instance_config.system_identifier = get_system_identifier(source_pgdata, FIO_DB_HOST, false);
current.start_time = time(NULL);

strlcpy(current.program_version, PROGRAM_VERSION, sizeof(current.program_version));
Expand Down Expand Up @@ -163,15 +163,15 @@ catchup_preflight_checks(PGNodeInfo *source_node_info, PGconn *source_conn,
uint64 source_conn_id, source_id, dest_id;

source_conn_id = get_remote_system_identifier(source_conn);
source_id = get_system_identifier(source_pgdata, FIO_DB_HOST); /* same as instance_config.system_identifier */
source_id = get_system_identifier(source_pgdata, FIO_DB_HOST, false); /* same as instance_config.system_identifier */

if (source_conn_id != source_id)
elog(ERROR, "Database identifiers mismatch: we connected to DB id %lu, but in \"%s\" we found id %lu",
source_conn_id, source_pgdata, source_id);

if (current.backup_mode != BACKUP_MODE_FULL)
{
dest_id = get_system_identifier(dest_pgdata, FIO_LOCAL_HOST);
dest_id = get_system_identifier(dest_pgdata, FIO_LOCAL_HOST, false);
if (source_conn_id != dest_id)
elog(ERROR, "Database identifiers mismatch: we connected to DB id %lu, but in \"%s\" we found id %lu",
source_conn_id, dest_pgdata, dest_id);
Expand Down
2 changes: 1 addition & 1 deletion src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ do_add_instance(InstanceState *instanceState, InstanceConfig *instance)
"(-D, --pgdata)");

/* Read system_identifier from PGDATA */
instance->system_identifier = get_system_identifier(instance->pgdata, FIO_DB_HOST);
instance->system_identifier = get_system_identifier(instance->pgdata, FIO_DB_HOST, false);
/* Starting from PostgreSQL 11 read WAL segment size from PGDATA */
instance->xlog_seg_size = get_xlog_seg_size(instance->pgdata);

Expand Down
40 changes: 25 additions & 15 deletions src/pg_probackup.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,17 +801,21 @@ main(int argc, char *argv[])
{
/* Check archive-push parameters and construct archive_push_xlog_dir
*
* There are 3 cases:
* There are 4 cases:
* 1. no --wal-file-path specified -- use cwd, ./PG_XLOG_DIR for wal files
* (and ./PG_XLOG_DIR/archive_status for .done files inside do_archive_push())
* in this case we can use batches and threads
* 2. --wal-file-path is specified and it is the same dir as stored in pg_probackup.conf (instance_config.pgdata)
* in this case we can use this path, as well as batches and thread
* 3. --wal-file-path is specified and it is different from instance_config.pgdata
* 3. --wal-file-path is specified and it isn't same dir as stored in pg_probackup.conf but control file present with correct system_id
* in this case we can use this path, as well as batches and thread
* (replica for example, see test_archive_push_sanity)
* 4. --wal-file-path is specified and it is different from instance_config.pgdata and no control file found
* disable optimizations and work with user specified path
*/
bool check_system_id = true;
uint64 system_id;
char current_dir[MAXPGPATH];

if (wal_file_name == NULL)
elog(ERROR, "Required parameter is not specified: --wal-file-name %%f");
Expand All @@ -823,14 +827,13 @@ main(int argc, char *argv[])
if (instance_config.compress_alg == PGLZ_COMPRESS)
elog(ERROR, "Cannot use pglz for WAL compression");

if (!getcwd(current_dir, sizeof(current_dir)))
elog(ERROR, "getcwd() error");

if (wal_file_path == NULL)
{
/* 1st case */
char current_dir[MAXPGPATH];
if (!getcwd(current_dir, sizeof(current_dir)))
elog(ERROR, "getcwd() error");

system_id = get_system_identifier(current_dir, FIO_DB_HOST);
system_id = get_system_identifier(current_dir, FIO_DB_HOST, false);
join_path_components(archive_push_xlog_dir, current_dir, XLOGDIR);
}
else
Expand All @@ -849,24 +852,31 @@ main(int argc, char *argv[])
if (fio_is_same_file(stripped_wal_file_path, archive_push_xlog_dir, true, FIO_DB_HOST))
{
/* 2nd case */
system_id = get_system_identifier(instance_config.pgdata, FIO_DB_HOST);
system_id = get_system_identifier(instance_config.pgdata, FIO_DB_HOST, false);
/* archive_push_xlog_dir already have right value */
}
else
{
/* 3rd case */
check_system_id = false;
if (strlen(stripped_wal_file_path) < MAXPGPATH)
strncpy(archive_push_xlog_dir, stripped_wal_file_path, MAXPGPATH);
else
elog(ERROR, "Value specified to --wal_file_path is too long");

if (batch_size > 1 || num_threads > 1 || !no_ready_rename)
system_id = get_system_identifier(current_dir, FIO_DB_HOST, true);
/* 3rd case if control file present -- i.e. system_id != 0 */

if (system_id == 0)
{
elog(WARNING, "Supplied --wal_file_path is outside pgdata, force safe values for options: --batch-size=1 -j 1 --no-ready-rename");
batch_size = 1;
num_threads = 1;
no_ready_rename = true;
/* 4th case */
check_system_id = false;

if (batch_size > 1 || num_threads > 1 || !no_ready_rename)
{
elog(WARNING, "Supplied --wal_file_path is outside pgdata, force safe values for options: --batch-size=1 -j 1 --no-ready-rename");
batch_size = 1;
num_threads = 1;
no_ready_rename = true;
}
}
}
pfree(stripped_wal_file_path);
Expand Down
2 changes: 1 addition & 1 deletion src/pg_probackup.h
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ extern XLogRecPtr get_next_record_lsn(const char *archivedir, XLogSegNo segno, T
extern TimeLineID get_current_timeline(PGconn *conn);
extern TimeLineID get_current_timeline_from_control(const char *pgdata_path, fio_location location, bool safe);
extern XLogRecPtr get_checkpoint_location(PGconn *conn);
extern uint64 get_system_identifier(const char *pgdata_path, fio_location location);
extern uint64 get_system_identifier(const char *pgdata_path, fio_location location, bool safe);
extern uint64 get_remote_system_identifier(PGconn *conn);
extern uint32 get_data_checksum_version(bool safe);
extern pg_crc32c get_pgcontrol_checksum(const char *pgdata_path);
Expand Down
2 changes: 1 addition & 1 deletion src/restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -2186,7 +2186,7 @@ check_incremental_compatibility(const char *pgdata, uint64 system_identifier,
*/
elog(INFO, "Trying to read pg_control file in destination directory");

system_id_pgdata = get_system_identifier(pgdata, FIO_DB_HOST);
system_id_pgdata = get_system_identifier(pgdata, FIO_DB_HOST, false);

if (system_id_pgdata == instance_config.system_identifier)
system_id_match = true;
Expand Down
6 changes: 3 additions & 3 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,15 @@ get_checkpoint_location(PGconn *conn)
}

uint64
get_system_identifier(const char *pgdata_path, fio_location location)
get_system_identifier(const char *pgdata_path, fio_location location, bool safe)
{
ControlFileData ControlFile;
char *buffer;
size_t size;

/* First fetch file... */
buffer = slurpFile(pgdata_path, XLOG_CONTROL_FILE, &size, false, location);
if (buffer == NULL)
buffer = slurpFile(pgdata_path, XLOG_CONTROL_FILE, &size, safe, location);
if (safe && buffer == NULL)
return 0;
digestControlFile(&ControlFile, buffer, size);
pg_free(buffer);
Expand Down