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

Commit45220ba

Browse files
committed
add is_partial_backup flag
1 parentaa6facb commit45220ba

File tree

4 files changed

+21
-64
lines changed

4 files changed

+21
-64
lines changed

‎contrib/pg_probackup/backup.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ backup_files(void *arg)
12861286
continue;
12871287
}
12881288
}
1289-
elseif (is_compressed_data_file(file,arguments->files))
1289+
elseif (is_compressed_data_file(file))
12901290
{
12911291
size_tskip_size=0;
12921292
if (backup_compressed_file_partially(file,arguments,&skip_size))
@@ -1398,13 +1398,6 @@ add_files(parray *files, const char *root, bool add_root, bool is_pgdata)
13981398

13991399
pre_search_file= (pgFile**)parray_bsearch(list_file,&tmp_file,pgFileComparePath);
14001400

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-
// }
1407-
14081401
if (pre_search_file!=NULL)
14091402
{
14101403
search_file=*pre_search_file;

‎contrib/pg_probackup/data.c

Lines changed: 11 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -513,43 +513,12 @@ restore_compressed_file(const char *from_root,
513513
constchar*to_root,
514514
pgFile*file)
515515
{
516-
charto_path[MAXPGPATH];
517-
pgFiletmp_file;
518-
519-
join_path_components(to_path,to_root,file->path+strlen(from_root)+1);
520-
tmp_file.path=psprintf("%s.cfm",to_path);
521-
522-
FileMap*map;
523-
intmd=open(tmp_file.path,O_RDWR|PG_BINARY,0);
524-
if (md<0)
525-
{
526-
elog(LOG,"restore_compressed_file(). cannot open cfm file '%s'",tmp_file.path);
527-
copy_file(from_root,to_root,file);
528-
pfree(tmp_file.path);
529-
return;
530-
}
531-
532-
elog(NOTICE,"restore_compressed_file(). map %s",tmp_file.path);
533-
map=cfs_mmap(md);
534-
if (map==MAP_FAILED)
535-
{
536-
elog(LOG,"restore_compressed_file(). cfs_compression_ration failed to map file %s: %m",tmp_file.path);
537-
if (close(md)<0)
538-
elog(LOG,"restore_compressed_file(). CFS failed to close file %s: %m",tmp_file.path);
539-
pfree(tmp_file.path);
540-
return;
541-
}
542-
543-
if (map->generation!=file->generation)
516+
if (file->is_partial_copy==0)
544517
copy_file(from_root,to_root,file);
545-
else
518+
elseif (file->is_partial_copy==1)
546519
restore_file_partly(from_root,to_root,file);
547-
548-
if (cfs_munmap(map)<0)
549-
elog(LOG,"restore_compressed_file(). CFS failed to unmap file %s: %m",tmp_file.path);
550-
if (close(md)<0)
551-
elog(LOG,"restore_compressed_file(). CFS failed to close file %s: %m",tmp_file.path);
552-
pfree(tmp_file.path);
520+
else
521+
elog(ERROR,"restore_compressed_file()");
553522
}
554523

555524
/*
@@ -700,22 +669,14 @@ restore_data_file(const char *from_root,
700669
fclose(out);
701670
}
702671

703-
/* */
672+
/* If someone's want to use this function before correct
673+
* generation values is set, he can look up for corresponding
674+
* .cfm file in the file_list
675+
*/
704676
bool
705-
is_compressed_data_file(pgFile*file,parray*file_list)
677+
is_compressed_data_file(pgFile*file)
706678
{
707-
//return (file->generation != -1);
708-
pgFilemap_file;
709-
pgFile**pre_search_file;
710-
711-
map_file.path=psprintf("%s.cfm",file->path);
712-
pre_search_file= (pgFile**)parray_bsearch(file_list,&map_file,pgFileComparePath);
713-
pg_free(map_file.path);
714-
715-
if (pre_search_file!=NULL)
716-
return true;
717-
718-
return false;
679+
return (file->generation!=-1);
719680
}
720681

721682
bool
@@ -958,10 +919,8 @@ copy_file_partly(const char *from_root, const char *to_root,
958919
strerror(errno_tmp));
959920
}
960921

922+
file->is_partial_copy=1;
961923
elog(NOTICE,"copy_file_partly(). %s file->write_size %lu",to_path,file->write_size);
962-
// pgFile newfile;
963-
// newfile.path = pg_strdup(to_path);
964-
// file->crc = pgFileGetCRC(&newfile);
965924

966925
fclose(in);
967926
fclose(out);

‎contrib/pg_probackup/dir.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ pgFileNew(const char *path, bool omit_symlink)
9393
file->segno=0;
9494
file->path=pgut_malloc(strlen(path)+1);
9595
file->generation=-1;
96+
file->is_partial_copy=0;
9697
strcpy(file->path,path);/* enough buffer size guaranteed */
9798

9899
returnfile;
@@ -523,7 +524,7 @@ dir_print_file_list(FILE *out, const parray *files, const char *root, const char
523524
fprintf(out," %s",timestamp);
524525
}
525526

526-
fprintf(out," %d\n",file->generation);
527+
fprintf(out," %d %d\n",file->generation,file->is_partial_copy);
527528
}
528529
}
529530

@@ -550,18 +551,19 @@ dir_read_file_list(const char *root, const char *file_txt)
550551
charpath[MAXPGPATH];
551552
chartype;
552553
intgeneration;
554+
intis_partial_copy;
553555
unsigned longwrite_size;
554556
pg_crc32crc;
555557
unsignedintmode;/* bit length of mode_t depends on platforms */
556558
structtmtm;
557559
pgFile*file;
558560

559561
memset(&tm,0,sizeof(tm));
560-
if (sscanf(buf,"%s %c %lu %u %o %d-%d-%d %d:%d:%d %d",
562+
if (sscanf(buf,"%s %c %lu %u %o %d-%d-%d %d:%d:%d %d %d",
561563
path,&type,&write_size,&crc,&mode,
562564
&tm.tm_year,&tm.tm_mon,&tm.tm_mday,
563565
&tm.tm_hour,&tm.tm_min,&tm.tm_sec,
564-
&generation)!=12)
566+
&generation,&is_partial_copy)!=13)
565567
{
566568
elog(ERROR,"invalid format found in \"%s\"",
567569
file_txt);
@@ -587,6 +589,7 @@ dir_read_file_list(const char *root, const char *file_txt)
587589
((type=='f'||type=='F') ?S_IFREG :
588590
type=='d' ?S_IFDIR :type=='l' ?S_IFLNK :0);
589591
file->generation=generation;
592+
file->is_partial_copy=is_partial_copy;
590593
file->size=0;
591594
file->read_size=0;
592595
file->write_size=write_size;

‎contrib/pg_probackup/pg_probackup.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ typedef struct pgFile
7373
intsegno;/* Segment number for ptrack */
7474
intgeneration;/* Generation of compressed file.
7575
* -1 for non-compressed files */
76+
intis_partial_copy;/* for compressed files.
77+
* 1 if backed up via copy_file_partly() */
7678
volatileuint32lock;
7779
datapagemap_tpagemap;
7880
}pgFile;
@@ -317,7 +319,7 @@ extern bool backup_data_file(const char *from_root, const char *to_root,
317319
pgFile*file,constXLogRecPtr*lsn);
318320
externvoidrestore_data_file(constchar*from_root,constchar*to_root,
319321
pgFile*file,pgBackup*backup);
320-
externboolis_compressed_data_file(pgFile*file,parray*file_list);
322+
externboolis_compressed_data_file(pgFile*file);
321323
externboolbackup_compressed_file_partially(pgFile*file,
322324
void*arg,
323325
size_t*skip_size);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp