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

Commitf45f87f

Browse files
committed
Merge branch 'REL_2_5'
2 parents2b9c9b1 +d29b005 commitf45f87f

32 files changed

+1592
-609
lines changed

‎doc/pgprobackup.xml

Lines changed: 478 additions & 346 deletions
Large diffs are not rendered by default.

‎po/ru.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ msgstr ""
811811
#:src/help.c:360src/help.c:521src/help.c:588src/help.c:635src/help.c:715
812812
#:src/help.c:761src/help.c:833
813813
#,c-format
814-
msgid" directory for file logging (default:BACKUP_PATH/log)\n"
814+
msgid" directory for file logging (default:BACKUP_DIR/log)\n"
815815
msgstr""
816816

817817
#:src/help.c:361src/help.c:522src/help.c:589src/help.c:636src/help.c:716

‎src/archive.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static parray *setup_push_filelist(const char *archive_status_dir,
113113
* set archive_command to
114114
* 'pg_probackup archive-push -B /home/anastasia/backup --wal-file-name %f',
115115
* to move backups into arclog_path.
116-
* Where archlog_path is $BACKUP_PATH/wal/instance_name
116+
* Where archlog_path is $BACKUP_DIR/wal/instance_name
117117
*/
118118
void
119119
do_archive_push(InstanceState*instanceState,InstanceConfig*instance,char*pg_xlog_dir,
@@ -1126,7 +1126,7 @@ do_archive_get(InstanceState *instanceState, InstanceConfig *instance, const cha
11261126
join_path_components(absolute_wal_file_path,current_dir,wal_file_path);
11271127

11281128
/* full filepath to WAL file in archive directory.
1129-
* $BACKUP_PATH/wal/instance_name/000000010000000000000001 */
1129+
* $BACKUP_DIR/wal/instance_name/000000010000000000000001 */
11301130
join_path_components(backup_wal_file_path,instanceState->instance_wal_subdir_path,wal_file_name);
11311131

11321132
INSTR_TIME_SET_CURRENT(start_time);

‎src/backup.c

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
122122
charpretty_time[20];
123123
charpretty_bytes[20];
124124

125+
pgFile*src_pg_control_file=NULL;
126+
125127
elog(INFO,"Database backup start");
126128
if(current.external_dir_str)
127129
{
@@ -424,6 +426,24 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
424426

425427
}
426428

429+
/*
430+
* find pg_control file
431+
* We'll copy it last
432+
*/
433+
{
434+
intcontrol_file_elem_index;
435+
pgFilesearch_key;
436+
MemSet(&search_key,0,sizeof(pgFile));
437+
/* pgFileCompareRelPathWithExternal uses only .rel_path and .external_dir_num for comparision */
438+
search_key.rel_path=XLOG_CONTROL_FILE;
439+
search_key.external_dir_num=0;
440+
control_file_elem_index=parray_bsearch_index(backup_files_list,&search_key,pgFileCompareRelPathWithExternal);
441+
442+
if (control_file_elem_index<0)
443+
elog(ERROR,"File \"%s\" not found in PGDATA %s",XLOG_CONTROL_FILE,current.database_dir);
444+
src_pg_control_file= (pgFile*)parray_get(backup_files_list,control_file_elem_index);
445+
}
446+
427447
/* setup thread locks */
428448
pfilearray_clear_locks(backup_files_list);
429449

@@ -483,6 +503,26 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
483503
backup_isok= false;
484504
}
485505

506+
/* copy pg_control at very end */
507+
if (backup_isok)
508+
{
509+
510+
elog(progress ?INFO :LOG,"Progress: Backup file \"%s\"",
511+
src_pg_control_file->rel_path);
512+
513+
charfrom_fullpath[MAXPGPATH];
514+
charto_fullpath[MAXPGPATH];
515+
join_path_components(from_fullpath,instance_config.pgdata,src_pg_control_file->rel_path);
516+
join_path_components(to_fullpath,current.database_dir,src_pg_control_file->rel_path);
517+
518+
backup_non_data_file(src_pg_control_file,NULL,
519+
from_fullpath,to_fullpath,
520+
current.backup_mode,current.parent_backup,
521+
true);
522+
}
523+
524+
525+
486526
time(&end_time);
487527
pretty_time_interval(difftime(end_time,start_time),
488528
pretty_time,lengthof(pretty_time));
@@ -510,17 +550,8 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
510550
{
511551
pgFile*pg_control=NULL;
512552

513-
for (i=0;i<parray_num(backup_files_list);i++)
514-
{
515-
pgFile*tmp_file= (pgFile*)parray_get(backup_files_list,i);
553+
pg_control=src_pg_control_file;
516554

517-
if (tmp_file->external_dir_num==0&&
518-
(strcmp(tmp_file->rel_path,XLOG_CONTROL_FILE)==0))
519-
{
520-
pg_control=tmp_file;
521-
break;
522-
}
523-
}
524555

525556
if (!pg_control)
526557
elog(ERROR,"Failed to find file \"%s\" in backup filelist.",
@@ -2076,6 +2107,13 @@ backup_files(void *arg)
20762107
/* We have already copied all directories */
20772108
if (S_ISDIR(file->mode))
20782109
continue;
2110+
/*
2111+
* Don't copy the pg_control file now, we'll copy it last
2112+
*/
2113+
if(file->external_dir_num==0&&pg_strcasecmp(file->rel_path,XLOG_CONTROL_FILE)==0)
2114+
{
2115+
continue;
2116+
}
20792117

20802118
if (arguments->thread_num==1)
20812119
{

‎src/catalog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ get_multi_timeline_parent(parray *backup_list, parray *tli_list,
14371437
}
14381438

14391439
/*
1440-
* Create backup directory in $BACKUP_PATH
1440+
* Create backup directory in $BACKUP_DIR
14411441
* (with proposed backup->backup_id)
14421442
* and initialize this directory.
14431443
* If creation of directory fails, then

‎src/catchup.c

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,13 @@ catchup_preflight_checks(PGNodeInfo *source_node_info, PGconn *source_conn,
171171

172172
if (current.backup_mode!=BACKUP_MODE_FULL)
173173
{
174-
dest_id=get_system_identifier(dest_pgdata,FIO_LOCAL_HOST, false);
174+
ControlFileDatadst_control;
175+
get_control_file_or_back_file(dest_pgdata,FIO_LOCAL_HOST,&dst_control);
176+
dest_id=dst_control.system_identifier;
177+
175178
if (source_conn_id!=dest_id)
176-
elog(ERROR,"Database identifiers mismatch: we connected to DB id %lu, but in \"%s\" we found id %lu",
177-
source_conn_id,dest_pgdata,dest_id);
179+
elog(ERROR,"Database identifiers mismatch: we connected to DB id %llu, but in \"%s\" we found id %llu",
180+
(long long)source_conn_id,dest_pgdata,(long long)dest_id);
178181
}
179182
}
180183

@@ -640,6 +643,9 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
640643
ssize_ttransfered_walfiles_bytes=0;
641644
charpretty_source_bytes[20];
642645

646+
chardest_pg_control_fullpath[MAXPGPATH];
647+
chardest_pg_control_bak_fullpath[MAXPGPATH];
648+
643649
source_conn=catchup_init_state(&source_node_info,source_pgdata,dest_pgdata);
644650
catchup_preflight_checks(&source_node_info,source_conn,source_pgdata,dest_pgdata);
645651

@@ -935,6 +941,9 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
935941
Assert(file->external_dir_num==0);
936942
if (pg_strcasecmp(file->name,RELMAPPER_FILENAME)==0)
937943
redundant= true;
944+
/* global/pg_control.pbk.bak is always keeped, because it's needed for restart failed incremental restore */
945+
if (pg_strcasecmp(file->rel_path,XLOG_CONTROL_BAK_FILE)==0)
946+
redundant= false;
938947

939948
/* if file does not exists in destination list, then we can safely unlink it */
940949
if (redundant)
@@ -966,6 +975,28 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
966975
if (dest_filelist)
967976
parray_qsort(dest_filelist,pgFileCompareRelPathWithExternal);
968977

978+
join_path_components(dest_pg_control_fullpath,dest_pgdata,XLOG_CONTROL_FILE);
979+
join_path_components(dest_pg_control_bak_fullpath,dest_pgdata,XLOG_CONTROL_BAK_FILE);
980+
/*
981+
* rename (if it exist) dest control file before restoring
982+
* if it doesn't exist, that mean, that we already restoring in a previously failed
983+
* pgdata, where XLOG_CONTROL_BAK_FILE exist
984+
*/
985+
if (current.backup_mode!=BACKUP_MODE_FULL&& !dry_run)
986+
{
987+
if (!fio_access(dest_pg_control_fullpath,F_OK,FIO_LOCAL_HOST))
988+
{
989+
pgFile*dst_control;
990+
dst_control=pgFileNew(dest_pg_control_bak_fullpath,XLOG_CONTROL_BAK_FILE,
991+
true,0,FIO_BACKUP_HOST);
992+
993+
if(!fio_access(dest_pg_control_bak_fullpath,F_OK,FIO_LOCAL_HOST))
994+
fio_delete(dst_control->mode,dest_pg_control_bak_fullpath,FIO_LOCAL_HOST);
995+
fio_rename(dest_pg_control_fullpath,dest_pg_control_bak_fullpath,FIO_LOCAL_HOST);
996+
pgFileFree(dst_control);
997+
}
998+
}
999+
9691000
/* run copy threads */
9701001
elog(INFO,"Start transferring data files");
9711002
time(&start_time);
@@ -985,6 +1016,15 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
9851016
copy_pgcontrol_file(from_fullpath,FIO_DB_HOST,
9861017
to_fullpath,FIO_LOCAL_HOST,source_pg_control_file);
9871018
transfered_datafiles_bytes+=source_pg_control_file->size;
1019+
1020+
/* Now backup control file can be deled */
1021+
if (current.backup_mode!=BACKUP_MODE_FULL&& !fio_access(dest_pg_control_bak_fullpath,F_OK,FIO_LOCAL_HOST)){
1022+
pgFile*dst_control;
1023+
dst_control=pgFileNew(dest_pg_control_bak_fullpath,XLOG_CONTROL_BAK_FILE,
1024+
true,0,FIO_BACKUP_HOST);
1025+
fio_delete(dst_control->mode,dest_pg_control_bak_fullpath,FIO_LOCAL_HOST);
1026+
pgFileFree(dst_control);
1027+
}
9881028
}
9891029

9901030
if (!catchup_isok&& !dry_run)

‎src/configure.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,18 +269,21 @@ static const char *current_group = NULL;
269269
* Show configure options including default values.
270270
*/
271271
void
272-
do_show_config(void)
272+
do_show_config(boolshow_base_units)
273273
{
274274
inti;
275275

276276
show_configure_start();
277277

278278
for (i=0;instance_options[i].type;i++)
279279
{
280+
if (show_base_units&&strchr("bBiIuU",instance_options[i].type)&&instance_options[i].get_value==*option_get_value)
281+
instance_options[i].flags |=GET_VAL_IN_BASE_UNITS;/* Set flag */
280282
if (show_format==SHOW_PLAIN)
281283
show_configure_plain(&instance_options[i]);
282284
else
283285
show_configure_json(&instance_options[i]);
286+
instance_options[i].flags &= ~(GET_VAL_IN_BASE_UNITS);/* Reset flag. It was resetted in option_get_value(). Probably this reset isn't needed */
284287
}
285288

286289
show_configure_end();
@@ -801,6 +804,6 @@ show_configure_json(ConfigOption *opt)
801804
return;
802805

803806
json_add_value(&show_buf,opt->lname,value,json_level,
804-
true);
807+
!(opt->flags&GET_VAL_IN_BASE_UNITS));
805808
pfree(value);
806809
}

‎src/data.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,7 +2490,10 @@ write_page_headers(BackupPageHeader2 *headers, pgFile *file, HeaderMap *hdr_map,
24902490
file->rel_path,file->hdr_off,z_len,file->hdr_crc);
24912491

24922492
if (fwrite(zheaders,1,z_len,hdr_map->fp)!=z_len)
2493+
{
2494+
pthread_mutex_unlock(&(hdr_map->mutex));
24932495
elog(ERROR,"Cannot write to file \"%s\": %s",map_path,strerror(errno));
2496+
}
24942497

24952498
file->hdr_size=z_len;/* save the length of compressed headers */
24962499
hdr_map->offset+=z_len;/* update current offset in map */

‎src/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1867,4 +1867,4 @@ set_forkname(pgFile *file)
18671867
file->segno=segno;
18681868
file->is_datafile=file->forkName==none;
18691869
return true;
1870-
}
1870+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp