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

Commit59d0911

Browse files
author
itagaki.takahiro
committed
Fix a critical bug that pg_rman cannot restore database from incremental backup. Backup itself worked correctly, but restore command broke database files.
git-svn-id:http://pg-rman.googlecode.com/svn/trunk@25 182aca00-e38e-11de-a668-6fd11605f5ce
1 parentbc5717b commit59d0911

File tree

9 files changed

+194
-195
lines changed

9 files changed

+194
-195
lines changed

‎backup.c

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static void backup_cleanup(bool fatal, void *userdata);
3030
staticvoiddelete_old_files(constchar*root,parray*files,intkeep_files,
3131
intkeep_days,intserver_version,boolis_arclog);
3232
staticvoidbackup_files(constchar*from_root,constchar*to_root,
33-
parray*files,parray*prev_files,XLogRecPtr*lsn,boolcompress_data);
33+
parray*files,parray*prev_files,constXLogRecPtr*lsn,boolcompress);
3434
staticparray*do_backup_database(parray*backup_list,boolsmooth_checkpoint);
3535
staticparray*do_backup_arclog(parray*backup_list);
3636
staticparray*do_backup_srvlog(parray*backup_list);
@@ -137,7 +137,7 @@ do_backup_database(parray *backup_list, bool smooth_checkpoint)
137137
files=parray_new();
138138
dir_list_file(files,pgdata,pgdata_exclude, true, false);
139139

140-
/* mark filesas 'datafile' which are under base/global/pg_tblspc */
140+
/* mark filesthat are possible datafile as 'datafile' */
141141
for (i=0;i<parray_num(files);i++)
142142
{
143143
pgFile*file= (pgFile*)parray_get(files,i);
@@ -148,7 +148,7 @@ do_backup_database(parray *backup_list, bool smooth_checkpoint)
148148
if (!S_ISREG(file->mode))
149149
continue;
150150

151-
/* data files are under base/global/pg_tblspc */
151+
/* data files are under"base", "global", or "pg_tblspc" */
152152
relative=file->path+strlen(pgdata)+1;
153153
if (!path_is_prefix_of_path("base",relative)&&
154154
!path_is_prefix_of_path("global",relative)&&
@@ -214,16 +214,16 @@ do_backup_database(parray *backup_list, bool smooth_checkpoint)
214214
staticparray*
215215
do_backup_arclog(parray*backup_list)
216216
{
217-
inti;
218-
parray*files;
219-
parray*prev_files=NULL;/* file list of previous database backup */
220-
FILE*fp;
221-
charpath[MAXPGPATH];
222-
chartimeline_dir[MAXPGPATH];
223-
charprev_file_txt[MAXPGPATH];
224-
pgBackup*prev_backup;
225-
int64arclog_write_bytes=0;
226-
charlast_wal[MAXPGPATH];
217+
inti;
218+
parray*files;
219+
parray*prev_files=NULL;/* file list of previous database backup */
220+
FILE*fp;
221+
charpath[MAXPGPATH];
222+
chartimeline_dir[MAXPGPATH];
223+
charprev_file_txt[MAXPGPATH];
224+
pgBackup*prev_backup;
225+
int64arclog_write_bytes=0;
226+
charlast_wal[MAXPGPATH];
227227

228228
if (!HAVE_ARCLOG(&current))
229229
returnNULL;
@@ -345,14 +345,14 @@ do_backup_arclog(parray *backup_list)
345345
staticparray*
346346
do_backup_srvlog(parray*backup_list)
347347
{
348-
inti;
349-
parray*files;
350-
parray*prev_files=NULL;/* file list of previous database backup */
351-
FILE*fp;
352-
charpath[MAXPGPATH];
353-
charprev_file_txt[MAXPGPATH];
354-
pgBackup*prev_backup;
355-
int64srvlog_write_bytes=0;
348+
inti;
349+
parray*files;
350+
parray*prev_files=NULL;/* file list of previous database backup */
351+
FILE*fp;
352+
charpath[MAXPGPATH];
353+
charprev_file_txt[MAXPGPATH];
354+
pgBackup*prev_backup;
355+
int64srvlog_write_bytes=0;
356356

357357
if (!current.with_serverlog)
358358
returnNULL;
@@ -818,10 +818,14 @@ backup_cleanup(bool fatal, void *userdata)
818818

819819
/* take incremental backup. */
820820
staticvoid
821-
backup_files(constchar*from_root,constchar*to_root,parray*files,
822-
parray*prev_files,XLogRecPtr*lsn,boolcompress_data)
821+
backup_files(constchar*from_root,
822+
constchar*to_root,
823+
parray*files,
824+
parray*prev_files,
825+
constXLogRecPtr*lsn,
826+
boolcompress)
823827
{
824-
inti;
828+
inti;
825829
structtimevaltv;
826830

827831
/* sort pathname ascending */
@@ -832,8 +836,9 @@ backup_files(const char *from_root, const char *to_root, parray *files,
832836
/* backup a file or create a directory */
833837
for (i=0;i<parray_num(files);i++)
834838
{
835-
intret;
836-
structstatbuf;
839+
intret;
840+
structstatbuf;
841+
837842
pgFile*file= (pgFile*)parray_get(files,i);
838843

839844
/* check for interrupt */
@@ -869,6 +874,7 @@ backup_files(const char *from_root, const char *to_root, parray *files,
869874
if (S_ISDIR(buf.st_mode))
870875
{
871876
chardirpath[MAXPGPATH];
877+
872878
snprintf(dirpath,lengthof(dirpath),"%s/%s",to_root,
873879
file->path+strlen(from_root)+1);
874880
if (!check)
@@ -918,7 +924,7 @@ backup_files(const char *from_root, const char *to_root, parray *files,
918924
/* copy the file into backup */
919925
if (file->is_datafile)
920926
{
921-
backup_data_file(from_root,to_root,file,lsn,compress_data);
927+
backup_data_file(from_root,to_root,file,lsn,compress);
922928
if (file->write_size==0&&file->read_size>0)
923929
{
924930
/* record as skipped file in file_xxx.txt */
@@ -930,7 +936,7 @@ backup_files(const char *from_root, const char *to_root, parray *files,
930936
}
931937
else
932938
copy_file(from_root,to_root,file,
933-
compress_data ?COMPRESSION :NO_COMPRESSION);
939+
compress ?COMPRESSION :NO_COMPRESSION);
934940

935941
if (verbose)
936942
{
@@ -965,11 +971,10 @@ delete_old_files(const char *root,
965971
intserver_version,
966972
boolis_arclog)
967973
{
968-
inti;
969-
intj;
970-
intfile_num=0;
971-
time_tdays_threashold=
972-
current.start_time- (keep_days*60*60*24);
974+
inti;
975+
intj;
976+
intfile_num=0;
977+
time_tdays_threshold=current.start_time- (keep_days*60*60*24);
973978

974979
if (verbose)
975980
{
@@ -990,7 +995,7 @@ delete_old_files(const char *root,
990995
root,files_str,days_str);
991996
}
992997

993-
/* delete files which satisfy bothcondition */
998+
/* delete files which satisfy bothconditions */
994999
if (keep_files==KEEP_INFINITE||keep_days==KEEP_INFINITE)
9951000
{
9961001
elog(LOG,"%s() infinite",__FUNCTION__);
@@ -1003,7 +1008,7 @@ delete_old_files(const char *root,
10031008
pgFile*file= (pgFile*)parray_get(files,i);
10041009

10051010
elog(LOG,"%s() %s",__FUNCTION__,file->path);
1006-
/* Deletecomplete WAL only. */
1011+
/* Deletecompleted WALs only. */
10071012
if (is_arclog&& !xlog_is_complete_wal(file,server_version))
10081013
{
10091014
elog(LOG,"%s() not complete WAL",__FUNCTION__);
@@ -1013,17 +1018,17 @@ delete_old_files(const char *root,
10131018
file_num++;
10141019

10151020
/*
1016-
* If the mtime of the file is older than thethreashold and there are
1021+
* If the mtime of the file is older than thethreshold and there are
10171022
* enough number of files newer than the files, delete the file.
10181023
*/
1019-
if (file->mtime >=days_threashold)
1024+
if (file->mtime >=days_threshold)
10201025
{
10211026
elog(LOG,"%s() %lu is not older than %lu",__FUNCTION__,
1022-
file->mtime,days_threashold);
1027+
file->mtime,days_threshold);
10231028
continue;
10241029
}
10251030
elog(LOG,"%s() %lu is older than %lu",__FUNCTION__,
1026-
file->mtime,days_threashold);
1031+
file->mtime,days_threshold);
10271032

10281033
if (file_num <=keep_files)
10291034
{
@@ -1035,7 +1040,7 @@ delete_old_files(const char *root,
10351040
if (verbose)
10361041
printf(_("delete \"%s\"\n"),file->path+strlen(root)+1);
10371042

1038-
/* delete corresponding backup history file ifany */
1043+
/* delete corresponding backup history file ifexists */
10391044
file= (pgFile*)parray_remove(files,i);
10401045
for (j=parray_num(files)-1;j >=0;j--)
10411046
{

‎catalog.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ catalog_get_backup_list(const pgBackupRange *range)
247247
pgBackup*
248248
catalog_get_last_data_backup(parray*backup_list)
249249
{
250-
inti;
251-
pgBackup*backup=NULL;
250+
inti;
251+
pgBackup*backup=NULL;
252252

253253
/* backup_list is sorted in order of descending ID */
254254
for (i=0;i<parray_num(backup_list);i++)
@@ -269,8 +269,8 @@ catalog_get_last_data_backup(parray *backup_list)
269269
pgBackup*
270270
catalog_get_last_arclog_backup(parray*backup_list)
271271
{
272-
inti;
273-
pgBackup*backup=NULL;
272+
inti;
273+
pgBackup*backup=NULL;
274274

275275
/* backup_list is sorted in order of descending ID */
276276
for (i=0;i<parray_num(backup_list);i++)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp