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

Commitaa6facb

Browse files
committed
cleanup
1 parent18c3bbe commitaa6facb

File tree

2 files changed

+39
-41
lines changed

2 files changed

+39
-41
lines changed

‎contrib/pg_probackup/backup.c

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,25 +1113,26 @@ backup_cleanup(bool fatal, void *userdata)
11131113
staticlong
11141114
file_size(constchar*file)
11151115
{
1116-
structstatst;
1117-
stat(file,&st);
1118-
elog(NOTICE,"file_size(). %lu",st.st_size);
1119-
returnst.st_size;
1120-
// longr;
1121-
// FILE *f = fopen(file, "r");
1122-
//
1123-
// if (!f)
1124-
// {
1125-
// elog(ERROR, "pg_probackup: could not open file \"%s\" for reading: %s\n",
1126-
// file, strerror(errno));
1127-
// return -1;
1128-
// }
1129-
// fseek(f, 0, SEEK_END);
1130-
// r = ftell(f);
1131-
// fclose(f);
1132-
// return r;
1116+
longr;
1117+
FILE*f=fopen(file,"r");
1118+
1119+
if (!f)
1120+
{
1121+
elog(ERROR,"pg_probackup: could not open file \"%s\" for reading: %s\n",
1122+
file,strerror(errno));
1123+
return-1;
1124+
}
1125+
fseek(f,0,SEEK_END);
1126+
r=ftell(f);
1127+
fclose(f);
1128+
returnr;
11331129
}
11341130

1131+
/*
1132+
* Find corresponding file in previous backup.
1133+
* Compare generations and return true if we don't need full copy
1134+
* of the file, but just part of it.
1135+
*/
11351136
bool
11361137
backup_compressed_file_partially(pgFile*file,void*arg,size_t*skip_size)
11371138
{
@@ -1147,35 +1148,29 @@ backup_compressed_file_partially(pgFile *file, void *arg, size_t *skip_size)
11471148
if (p)
11481149
prev_file=*p;
11491150

1150-
elog(NOTICE,"file '%s' generation: prev %d, now %d",
1151-
file->path,prev_file->generation,file->generation);
1152-
11531151
/* If file's gc generation has changed since last backup, just copy it*/
1154-
if (prev_file
1155-
&&prev_file->generation==file->generation)
1152+
if (prev_file&&prev_file->generation==file->generation)
11561153
{
11571154
current_file_size=file_size(file->path);
11581155

1159-
elog(NOTICE,"prev->write_size %lu, current_file_size %lu",
1160-
prev_file->write_size,current_file_size);
1161-
11621156
if (prev_file->write_size==BYTES_INVALID)
11631157
return false;
11641158

11651159
*skip_size=prev_file->write_size;
11661160

11671161
if (current_file_size >=prev_file->write_size)
11681162
{
1169-
elog(NOTICE,"Backuppart of thefile. %s: %lu",
1170-
file->path,current_file_size-*skip_size);
1163+
elog(LOG,"Backup file %spartially: prev_size %lu, current_size %lu",
1164+
file->path,prev_file->write_size,current_file_size);
11711165
result= true;
11721166
}
11731167
else
1174-
elog(ERROR,"Somethingwent wrong. current_file_size %lu, prev %lu",
1175-
current_file_size,prev_file->write_size);
1168+
elog(ERROR,"Somethingis wrong with %s. current_file_size %lu, prev %lu",
1169+
file->path,current_file_size,prev_file->write_size);
11761170
}
11771171
else
1178-
elog(NOTICE,"Copy full file. Generations are different");
1172+
elog(LOG,"Copy full %s. Generations are different: old=%d; new=%d",
1173+
file->path,prev_file->generation,file->generation);
11791174
}
11801175

11811176
returnresult;
@@ -1368,14 +1363,14 @@ add_files(parray *files, const char *root, bool add_root, bool is_pgdata)
13681363
relative=file->path+strlen(root)+1;
13691364
if (is_pgdata&&
13701365
!path_is_prefix_of_path("base",relative)&&
1371-
/*!path_is_prefix_of_path("global", relative) &&*/
1366+
/*!path_is_prefix_of_path("global", relative) &&*///TODO What's wrong with this line?
13721367
!path_is_prefix_of_path("pg_tblspc",relative))
13731368
continue;
13741369

13751370
/* Get file name from path */
13761371
fname=last_dir_separator(relative);
13771372

1378-
/* Remove temp tables */
1373+
/* Remove temp tablesfrom the list*/
13791374
if (fname[0]=='t'&&isdigit(fname[1]))
13801375
{
13811376
pgFileFree(file);
@@ -1385,7 +1380,7 @@ add_files(parray *files, const char *root, bool add_root, bool is_pgdata)
13851380
}
13861381

13871382
path_len=strlen(file->path);
1388-
/* Get link ptrack file torealations files */
1383+
/* Get link ptrack file torelations files */
13891384
if (path_len>6&&strncmp(file->path+(path_len-6),"ptrack",6)==0)
13901385
{
13911386
pgFile*search_file;
@@ -1394,20 +1389,21 @@ add_files(parray *files, const char *root, bool add_root, bool is_pgdata)
13941389
while(true) {
13951390
pgFiletmp_file;
13961391
tmp_file.path=pg_strdup(file->path);
1397-
/* I hope segno not more than 999999 */
1392+
1393+
/* Segno fits into 6 digits since it is not more than 4000 */
13981394
if (segno>0)
13991395
sprintf(tmp_file.path+path_len-7,".%d",segno);
14001396
else
14011397
tmp_file.path[path_len-7]='\0';
14021398

14031399
pre_search_file= (pgFile**)parray_bsearch(list_file,&tmp_file,pgFileComparePath);
14041400

1405-
if (is_compressed_data_file(&tmp_file,list_file))
1406-
{
1407-
elog(NOTICE,"file %s is compressed, don't remove it from list",tmp_file.path);
1408-
pg_free(tmp_file.path);
1409-
break;
1410-
}
1401+
//if (is_compressed_data_file(&tmp_file, list_file))
1402+
//{
1403+
//elog(NOTICE, "file %s is compressed, don't remove it from list", tmp_file.path);
1404+
//pg_free(tmp_file.path);
1405+
//break;
1406+
//}
14111407

14121408
if (pre_search_file!=NULL)
14131409
{
@@ -1422,6 +1418,7 @@ add_files(parray *files, const char *root, bool add_root, bool is_pgdata)
14221418
segno++;
14231419
}
14241420

1421+
/* Remove ptrack file itself from backup list */
14251422
pgFileFree(file);
14261423
parray_remove(list_file,i);
14271424
i--;

‎contrib/pg_probackup/data.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,10 +700,11 @@ restore_data_file(const char *from_root,
700700
fclose(out);
701701
}
702702

703-
703+
/* */
704704
bool
705705
is_compressed_data_file(pgFile*file,parray*file_list)
706706
{
707+
//return (file->generation != -1);
707708
pgFilemap_file;
708709
pgFile**pre_search_file;
709710

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp