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

Commita997235

Browse files
author
Artur Zakirov
committed
Remove sanityChecks(). Fix add_files()
1 parent492a856 commita997235

File tree

6 files changed

+132
-126
lines changed

6 files changed

+132
-126
lines changed

‎backup.c

Lines changed: 80 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@ do_backup_database(parray *backup_list, bool smooth_checkpoint)
126126
/* Initialize size summary */
127127
current.data_bytes=0;
128128

129-
/* do some checks on the node */
130-
sanityChecks();
131-
132129
/*
133130
* Obtain current timeline by scanning control file, theh LSN
134131
* obtained at output of pg_start_backup or pg_stop_backup does
@@ -152,11 +149,9 @@ do_backup_database(parray *backup_list, bool smooth_checkpoint)
152149
if (current.backup_mode==BACKUP_MODE_DIFF_PAGE||
153150
current.backup_mode==BACKUP_MODE_DIFF_PTRACK)
154151
{
155-
pgBackup*prev_backup;
156-
157152
prev_backup=catalog_get_last_data_backup(backup_list,current.tli);
158153
if (prev_backup==NULL)
159-
elog(ERROR,"Timeline has changed since last full backup."
154+
elog(ERROR,"Timeline has changed since last full backup."
160155
"Create new full backup before an incremental one.");
161156
}
162157

@@ -233,8 +228,7 @@ do_backup_database(parray *backup_list, bool smooth_checkpoint)
233228
if (current.backup_mode==BACKUP_MODE_DIFF_PAGE||
234229
current.backup_mode==BACKUP_MODE_DIFF_PTRACK)
235230
{
236-
/* find last completed database backup */
237-
prev_backup=catalog_get_last_data_backup(backup_list,current.tli);
231+
Assert(prev_backup);
238232
pgBackupGetPath(prev_backup,prev_file_txt,lengthof(prev_file_txt),
239233
DATABASE_FILE_LIST);
240234
prev_files=dir_read_file_list(pgdata,prev_file_txt);
@@ -1337,21 +1331,21 @@ backup_files(void *arg)
13371331
staticvoid
13381332
add_files(parray*files,constchar*root,booladd_root,boolis_pgdata)
13391333
{
1340-
parray*list_file;
1341-
inti;
1334+
parray*list_file;
1335+
size_ti;
13421336

13431337
list_file=parray_new();
13441338

13451339
/* list files with the logical path. omit $PGDATA */
13461340
dir_list_file(list_file,root, true, true,add_root);
13471341

13481342
/* mark files that are possible datafile as 'datafile' */
1349-
for (i=0;i<(int)parray_num(list_file);i++)
1343+
for (i=0;i<parray_num(list_file);i++)
13501344
{
1351-
pgFile*file= (pgFile*)parray_get(list_file,i);
1352-
char*relative;
1353-
char*fname;
1354-
intpath_len;
1345+
pgFile*file= (pgFile*)parray_get(list_file,i);
1346+
char*relative;
1347+
char*fname;
1348+
size_tpath_len;
13551349

13561350
/* data file must be a regular file */
13571351
if (!S_ISREG(file->mode))
@@ -1367,6 +1361,10 @@ add_files(parray *files, const char *root, bool add_root, bool is_pgdata)
13671361

13681362
/* Get file name from path */
13691363
fname=last_dir_separator(relative);
1364+
if (fname==NULL)
1365+
fname=relative;
1366+
else
1367+
fname++;
13701368

13711369
/* Remove temp tables from the list */
13721370
if (fname[0]=='t'&&isdigit(fname[1]))
@@ -1379,32 +1377,41 @@ add_files(parray *files, const char *root, bool add_root, bool is_pgdata)
13791377

13801378
path_len=strlen(file->path);
13811379
/* Get link ptrack file to relations files */
1382-
if (path_len>6&&strncmp(file->path+(path_len-6),"ptrack",6)==0)
1380+
if (path_len>6&&
1381+
strncmp(file->path+ (path_len-6),"ptrack",6)==0)
13831382
{
1384-
pgFile*search_file;
1385-
pgFile**pre_search_file;
1386-
intsegno=0;
1387-
while(true) {
1388-
pgFiletmp_file;
1383+
pgFile*search_file;
1384+
pgFile**pre_search_file;
1385+
intsegno=0;
1386+
1387+
while (true)
1388+
{
1389+
pgFiletmp_file;
1390+
13891391
tmp_file.path=pg_strdup(file->path);
13901392

13911393
/* Segno fits into 6 digits since it is not more than 4000 */
13921394
if (segno>0)
1393-
sprintf(tmp_file.path+path_len-7,".%d",segno);
1395+
sprintf(tmp_file.path+path_len-7,".%d",segno);
13941396
else
1395-
tmp_file.path[path_len-7]='\0';
1397+
tmp_file.path[path_len-7]='\0';
13961398

1397-
pre_search_file= (pgFile**)parray_bsearch(list_file,&tmp_file,pgFileComparePath);
1399+
pre_search_file= (pgFile**)parray_bsearch(list_file,
1400+
&tmp_file,
1401+
pgFileComparePath);
13981402

13991403
if (pre_search_file!=NULL)
14001404
{
14011405
search_file=*pre_search_file;
14021406
search_file->ptrack_path=pg_strdup(file->path);
14031407
search_file->segno=segno;
1404-
}else {
1408+
}
1409+
else
1410+
{
14051411
pg_free(tmp_file.path);
14061412
break;
14071413
}
1414+
14081415
pg_free(tmp_file.path);
14091416
segno++;
14101417
}
@@ -1413,63 +1420,24 @@ add_files(parray *files, const char *root, bool add_root, bool is_pgdata)
14131420
pgFileFree(file);
14141421
parray_remove(list_file,i);
14151422
i--;
1416-
continue;
14171423
}
1418-
14191424
/* compress map file it is not data file */
1420-
if (path_len>4&&strncmp(file->path+(path_len-4),".cfm",4)==0)
1421-
continue;
1422-
1423-
/* name of data file start with digit */
1424-
if (fname==NULL)
1425-
fname=relative;
1426-
else
1427-
fname++;
1428-
if (!isdigit(fname[0]))
1429-
continue;
1430-
1431-
file->is_datafile= true;
1425+
elseif (path_len>4&&
1426+
strncmp(file->path+ (path_len-4),".cfm",4)==0)
14321427
{
1433-
intfind_dot;
1434-
intcheck_digit;
1435-
char*text_segno;
1436-
for(find_dot=path_len-1;file->path[find_dot]!='.'&&find_dot >=0;find_dot--);
1437-
if (find_dot <=0)
1438-
continue;
1439-
1440-
text_segno=file->path+find_dot+1;
1441-
for(check_digit=0;text_segno[check_digit]!='\0';check_digit++)
1442-
if (!isdigit(text_segno[check_digit]))
1443-
{
1444-
check_digit=-1;
1445-
break;
1446-
}
1447-
1448-
if (check_digit==-1)
1449-
continue;
1450-
1451-
file->segno= (int)strtol(text_segno,NULL,10);
1452-
}
1453-
}
1428+
pgFile**pre_search_file;
1429+
pgFiletmp_file;
14541430

1455-
/* mark cfs relations as not data */
1456-
for (i=0;i< (int)parray_num(list_file);i++)
1457-
{
1458-
pgFile*file= (pgFile*)parray_get(list_file,i);
1459-
intpath_len= (int)strlen(file->path);
1460-
1461-
if (path_len>4&&strncmp(file->path+(path_len-4),".cfm",4)==0)
1462-
{
1463-
pgFile**pre_search_file;
1464-
pgFiletmp_file;
14651431
tmp_file.path=pg_strdup(file->path);
1466-
tmp_file.path[path_len-4]='\0';
1432+
tmp_file.path[path_len-4]='\0';
14671433
pre_search_file= (pgFile**)parray_bsearch(list_file,
1468-
&tmp_file,pgFileComparePath);
1434+
&tmp_file,
1435+
pgFileComparePath);
14691436
if (pre_search_file!=NULL)
14701437
{
1471-
FileMap*map;
1472-
intmd=open(file->path,O_RDWR|PG_BINARY,0);
1438+
FileMap*map;
1439+
intmd=open(file->path,O_RDWR|PG_BINARY,0);
1440+
14731441
if (md<0)
14741442
elog(ERROR,"add_files(). cannot open cfm file '%s'",file->path);
14751443

@@ -1485,16 +1453,51 @@ add_files(parray *files, const char *root, bool add_root, bool is_pgdata)
14851453
(*pre_search_file)->is_datafile= false;
14861454

14871455
if (cfs_munmap(map)<0)
1488-
elog(LOG,"add_files(). CFS failed to unmap file %s: %m",file->path);
1456+
elog(LOG,"add_files(). CFS failed to unmap file %s: %m",
1457+
file->path);
14891458
if (close(md)<0)
1490-
elog(LOG,"add_files(). CFS failed to close file %s: %m",file->path);
1459+
elog(LOG,"add_files(). CFS failed to close file %s: %m",
1460+
file->path);
14911461
}
14921462
else
1493-
elog(ERROR,"corresponding segment '%s' is not found",tmp_file.path);
1463+
elog(ERROR,"corresponding segment '%s' is not found",
1464+
tmp_file.path);
14941465

14951466
pg_free(tmp_file.path);
14961467
}
1468+
/* name of data file start with digit */
1469+
elseif (isdigit(fname[0]))
1470+
{
1471+
intfind_dot;
1472+
intcheck_digit;
1473+
char*text_segno;
1474+
1475+
file->is_datafile= true;
1476+
1477+
/*
1478+
* Find segment number.
1479+
*/
1480+
1481+
for (find_dot= (int)path_len-1;
1482+
file->path[find_dot]!='.'&&find_dot >=0;
1483+
find_dot--);
1484+
/* There is not segment number */
1485+
if (find_dot <=0)
1486+
continue;
1487+
1488+
text_segno=file->path+find_dot+1;
1489+
for (check_digit=0;text_segno[check_digit]!='\0';check_digit++)
1490+
if (!isdigit(text_segno[check_digit]))
1491+
{
1492+
check_digit=-1;
1493+
break;
1494+
}
1495+
1496+
if (check_digit!=-1)
1497+
file->segno= (int)strtol(text_segno,NULL,10);
1498+
}
14971499
}
1500+
14981501
parray_concat(files,list_file);
14991502
}
15001503

‎delete.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ pgBackupDeleteFiles(pgBackup *backup)
283283
parray_qsort(files,pgFileComparePathDesc);
284284
for (i=0;i<parray_num(files);i++)
285285
{
286-
pgFile*file= (pgFile*)parray_get(files,i);
286+
pgFile*file= (pgFile*)parray_get(files,i);
287287

288288
/* print progress */
289289
elog(LOG,"delete file(%zd/%lu) \"%s\"",i+1,

‎dir.c

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -249,50 +249,50 @@ BlackListCompare(const void *str1, const void *str2)
249249
* List files, symbolic links and directories in the directory "root" and add
250250
* pgFile objects to "files". We add "root" to "files" if add_root is true.
251251
*
252-
* If the sub-directory name is in "exclude" list, the sub-directory itself is
253-
* listed but the contents of the sub-directory is ignored.
254-
*
255252
* When omit_symlink is true, symbolic link is ignored and only file or
256253
* directory llnked to will be listed.
257254
*/
258255
void
259256
dir_list_file(parray*files,constchar*root,boolexclude,boolomit_symlink,
260257
booladd_root)
261258
{
262-
charpath[MAXPGPATH];
263-
charbuf[MAXPGPATH*2];
264-
charblack_item[MAXPGPATH*2];
265-
parray*black_list=NULL;
259+
parray*black_list=NULL;
260+
charpath[MAXPGPATH];
266261

267262
join_path_components(path,backup_path,PG_BLACK_LIST);
268-
if (root&&pgdata&&strcmp(root,pgdata)==0&&
269-
fileExists(path))
263+
/* List files with black list */
264+
if (root&&pgdata&&strcmp(root,pgdata)==0&&fileExists(path))
270265
{
271-
FILE*black_list_file=NULL;
266+
FILE*black_list_file=NULL;
267+
charbuf[MAXPGPATH*2];
268+
charblack_item[MAXPGPATH*2];
269+
272270
black_list=parray_new();
273271
black_list_file=fopen(path,"r");
272+
274273
if (black_list_file==NULL)
275-
elog(ERROR,"cannot open black_list: %s",
276-
strerror(errno));
274+
elog(ERROR,"cannot open black_list: %s",strerror(errno));
275+
277276
while (fgets(buf,lengthof(buf),black_list_file)!=NULL)
278277
{
279278
join_path_components(black_item,pgdata,buf);
279+
280280
if (black_item[strlen(black_item)-1]=='\n')
281281
black_item[strlen(black_item)-1]='\0';
282+
282283
if (black_item[0]=='#'||black_item[0]=='\0')
283284
continue;
285+
284286
parray_append(black_list,black_item);
285287
}
288+
286289
fclose(black_list_file);
287290
parray_qsort(black_list,BlackListCompare);
288-
dir_list_file_internal(files,root,exclude,omit_symlink,add_root,black_list);
289-
parray_qsort(files,pgFileComparePath);
290-
}
291-
else
292-
{
293-
dir_list_file_internal(files,root,exclude,omit_symlink,add_root,NULL);
294-
parray_qsort(files,pgFileComparePath);
295291
}
292+
293+
dir_list_file_internal(files,root,exclude,omit_symlink,add_root,
294+
black_list);
295+
parray_qsort(files,pgFileComparePath);
296296
}
297297

298298
void
@@ -561,7 +561,8 @@ dir_print_file_list(FILE *out, const parray *files, const char *root, const char
561561
fprintf(out," %s",timestamp);
562562
}
563563

564-
fprintf(out," %d %d\n",file->generation,file->is_partial_copy);
564+
fprintf(out," "UINT64_FORMAT" %d\n",
565+
file->generation,file->is_partial_copy);
565566
}
566567
}
567568

@@ -681,30 +682,34 @@ dir_read_file_list(const char *root, const char *file_txt)
681682
returnfiles;
682683
}
683684

684-
/* copy contents of directory from_root into to_root */
685+
/*
686+
* Copy contents of directory from_root into to_root.
687+
*/
685688
void
686689
dir_copy_files(constchar*from_root,constchar*to_root)
687690
{
688-
inti;
689-
parray*files=parray_new();
691+
size_ti;
692+
parray*files=parray_new();
690693

691694
/* don't copy root directory */
692695
dir_list_file(files,from_root, false, true, false);
693696

694697
for (i=0;i<parray_num(files);i++)
695698
{
696-
pgFile*file= (pgFile*)parray_get(files,i);
699+
pgFile*file= (pgFile*)parray_get(files,i);
697700

698701
if (S_ISDIR(file->mode))
699702
{
700-
charto_path[MAXPGPATH];
701-
join_path_components(to_path,to_root,file->path+strlen(from_root)+1);
703+
charto_path[MAXPGPATH];
704+
705+
join_path_components(to_path,to_root,
706+
file->path+strlen(from_root)+1);
707+
702708
if (verbose&& !check)
703709
elog(LOG,"creating directory \"%s\"",
704710
file->path+strlen(from_root)+1);
705711
if (!check)
706712
dir_create_dir(to_path,DIR_PERMISSION);
707-
continue;
708713
}
709714
elseif (S_ISREG(file->mode))
710715
{

‎pg_probackup.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ typedef struct pgFile
7070
char*path;/* path of the file */
7171
char*ptrack_path;
7272
intsegno;/* Segment number for ptrack */
73-
intgeneration;/* Generation of compressed file.
73+
uint64generation;/* Generation of compressed file.
7474
* -1 for non-compressed files */
75-
intis_partial_copy;/* for compressed files.
76-
* 1 if backed up via copy_file_partly() */
75+
intis_partial_copy;/* for compressed files.
76+
* 1 if backed up via copy_file_partly() */
7777
volatileuint32lock;
7878
datapagemap_tpagemap;
7979
}pgFile;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp