Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbbdf5ca

Browse files
committed
[PGPRO-5421] fix for test test_archive_push_sanity
1 parent3529a17 commitbbdf5ca

File tree

7 files changed

+35
-25
lines changed

7 files changed

+35
-25
lines changed

‎src/backup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ check_system_identifiers(PGconn *conn, const char *pgdata)
943943
uint64system_id_conn;
944944
uint64system_id_pgdata;
945945

946-
system_id_pgdata=get_system_identifier(pgdata,FIO_DB_HOST);
946+
system_id_pgdata=get_system_identifier(pgdata,FIO_DB_HOST, false);
947947
system_id_conn=get_remote_system_identifier(conn);
948948

949949
/* for checkdb check only system_id_pgdata and system_id_conn */

‎src/catchup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ catchup_init_state(PGNodeInfo*source_node_info, const char *source_pgdata, cons
4848

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

5454
strlcpy(current.program_version,PROGRAM_VERSION,sizeof(current.program_version));
@@ -163,15 +163,15 @@ catchup_preflight_checks(PGNodeInfo *source_node_info, PGconn *source_conn,
163163
uint64source_conn_id,source_id,dest_id;
164164

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

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

172172
if (current.backup_mode!=BACKUP_MODE_FULL)
173173
{
174-
dest_id=get_system_identifier(dest_pgdata,FIO_LOCAL_HOST);
174+
dest_id=get_system_identifier(dest_pgdata,FIO_LOCAL_HOST, false);
175175
if (source_conn_id!=dest_id)
176176
elog(ERROR,"Database identifiers mismatch: we connected to DB id %lu, but in \"%s\" we found id %lu",
177177
source_conn_id,dest_pgdata,dest_id);

‎src/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ do_add_instance(InstanceState *instanceState, InstanceConfig *instance)
5757
"(-D, --pgdata)");
5858

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

‎src/pg_probackup.c

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -801,17 +801,21 @@ main(int argc, char *argv[])
801801
{
802802
/* Check archive-push parameters and construct archive_push_xlog_dir
803803
*
804-
* There are3 cases:
804+
* There are4 cases:
805805
* 1. no --wal-file-path specified -- use cwd, ./PG_XLOG_DIR for wal files
806806
* (and ./PG_XLOG_DIR/archive_status for .done files inside do_archive_push())
807807
* in this case we can use batches and threads
808808
* 2. --wal-file-path is specified and it is the same dir as stored in pg_probackup.conf (instance_config.pgdata)
809809
* in this case we can use this path, as well as batches and thread
810-
* 3. --wal-file-path is specified and it is different from instance_config.pgdata
810+
* 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
811+
* in this case we can use this path, as well as batches and thread
812+
* (replica for example, see test_archive_push_sanity)
813+
* 4. --wal-file-path is specified and it is different from instance_config.pgdata and no control file found
811814
* disable optimizations and work with user specified path
812815
*/
813816
boolcheck_system_id= true;
814817
uint64system_id;
818+
charcurrent_dir[MAXPGPATH];
815819

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

830+
if (!getcwd(current_dir,sizeof(current_dir)))
831+
elog(ERROR,"getcwd() error");
832+
826833
if (wal_file_path==NULL)
827834
{
828835
/* 1st case */
829-
charcurrent_dir[MAXPGPATH];
830-
if (!getcwd(current_dir,sizeof(current_dir)))
831-
elog(ERROR,"getcwd() error");
832-
833-
system_id=get_system_identifier(current_dir,FIO_DB_HOST);
836+
system_id=get_system_identifier(current_dir,FIO_DB_HOST, false);
834837
join_path_components(archive_push_xlog_dir,current_dir,XLOGDIR);
835838
}
836839
else
@@ -849,24 +852,31 @@ main(int argc, char *argv[])
849852
if (fio_is_same_file(stripped_wal_file_path,archive_push_xlog_dir, true,FIO_DB_HOST))
850853
{
851854
/* 2nd case */
852-
system_id=get_system_identifier(instance_config.pgdata,FIO_DB_HOST);
855+
system_id=get_system_identifier(instance_config.pgdata,FIO_DB_HOST, false);
853856
/* archive_push_xlog_dir already have right value */
854857
}
855858
else
856859
{
857-
/* 3rd case */
858-
check_system_id= false;
859860
if (strlen(stripped_wal_file_path)<MAXPGPATH)
860861
strncpy(archive_push_xlog_dir,stripped_wal_file_path,MAXPGPATH);
861862
else
862863
elog(ERROR,"Value specified to --wal_file_path is too long");
863864

864-
if (batch_size>1||num_threads>1|| !no_ready_rename)
865+
system_id=get_system_identifier(current_dir,FIO_DB_HOST, true);
866+
/* 3rd case if control file present -- i.e. system_id != 0 */
867+
868+
if (system_id==0)
865869
{
866-
elog(WARNING,"Supplied --wal_file_path is outside pgdata, force safe values for options: --batch-size=1 -j 1 --no-ready-rename");
867-
batch_size=1;
868-
num_threads=1;
869-
no_ready_rename= true;
870+
/* 4th case */
871+
check_system_id= false;
872+
873+
if (batch_size>1||num_threads>1|| !no_ready_rename)
874+
{
875+
elog(WARNING,"Supplied --wal_file_path is outside pgdata, force safe values for options: --batch-size=1 -j 1 --no-ready-rename");
876+
batch_size=1;
877+
num_threads=1;
878+
no_ready_rename= true;
879+
}
870880
}
871881
}
872882
pfree(stripped_wal_file_path);

‎src/pg_probackup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ extern XLogRecPtr get_next_record_lsn(const char *archivedir, XLogSegNosegno, T
11531153
externTimeLineIDget_current_timeline(PGconn*conn);
11541154
externTimeLineIDget_current_timeline_from_control(constchar*pgdata_path,fio_locationlocation,boolsafe);
11551155
externXLogRecPtrget_checkpoint_location(PGconn*conn);
1156-
externuint64get_system_identifier(constchar*pgdata_path,fio_locationlocation);
1156+
externuint64get_system_identifier(constchar*pgdata_path,fio_locationlocation,boolsafe);
11571157
externuint64get_remote_system_identifier(PGconn*conn);
11581158
externuint32get_data_checksum_version(boolsafe);
11591159
externpg_crc32cget_pgcontrol_checksum(constchar*pgdata_path);

‎src/restore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2186,7 +2186,7 @@ check_incremental_compatibility(const char *pgdata, uint64 system_identifier,
21862186
*/
21872187
elog(INFO,"Trying to read pg_control file in destination directory");
21882188

2189-
system_id_pgdata=get_system_identifier(pgdata,FIO_DB_HOST);
2189+
system_id_pgdata=get_system_identifier(pgdata,FIO_DB_HOST, false);
21902190

21912191
if (system_id_pgdata==instance_config.system_identifier)
21922192
system_id_match= true;

‎src/util.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,15 @@ get_checkpoint_location(PGconn *conn)
247247
}
248248

249249
uint64
250-
get_system_identifier(constchar*pgdata_path,fio_locationlocation)
250+
get_system_identifier(constchar*pgdata_path,fio_locationlocation,boolsafe)
251251
{
252252
ControlFileDataControlFile;
253253
char*buffer;
254254
size_tsize;
255255

256256
/* First fetch file... */
257-
buffer=slurpFile(pgdata_path,XLOG_CONTROL_FILE,&size,false,location);
258-
if (buffer==NULL)
257+
buffer=slurpFile(pgdata_path,XLOG_CONTROL_FILE,&size,safe,location);
258+
if (safe&&buffer==NULL)
259259
return0;
260260
digestControlFile(&ControlFile,buffer,size);
261261
pg_free(buffer);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp