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

Commited47e49

Browse files
committed
Merge branch 'REL_2_5-some-fixes' into REL_2_5
2 parentsc7e6d5c +51a141c commited47e49

File tree

11 files changed

+89
-65
lines changed

11 files changed

+89
-65
lines changed

‎src/archive.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,8 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
512512
pg_crc32crc32_src;
513513
pg_crc32crc32_dst;
514514

515-
crc32_src=fio_get_crc32(from_fullpath,FIO_DB_HOST, false);
516-
crc32_dst=fio_get_crc32(to_fullpath,FIO_BACKUP_HOST, false);
515+
crc32_src=fio_get_crc32(from_fullpath,FIO_DB_HOST, false, false);
516+
crc32_dst=fio_get_crc32(to_fullpath,FIO_BACKUP_HOST, false, false);
517517

518518
if (crc32_src==crc32_dst)
519519
{
@@ -760,9 +760,8 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
760760
pg_crc32crc32_src;
761761
pg_crc32crc32_dst;
762762

763-
/* TODO: what if one of them goes missing? */
764-
crc32_src=fio_get_crc32(from_fullpath,FIO_DB_HOST, false);
765-
crc32_dst=fio_get_crc32(to_fullpath_gz,FIO_BACKUP_HOST, true);
763+
crc32_src=fio_get_crc32(from_fullpath,FIO_DB_HOST, false, false);
764+
crc32_dst=fio_get_crc32(to_fullpath_gz,FIO_BACKUP_HOST, true, false);
766765

767766
if (crc32_src==crc32_dst)
768767
{

‎src/catalog.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,9 @@ get_backup_filelist(pgBackup *backup, bool strict)
11321132
if (get_control_value_int64(buf,"hdr_size",&hdr_size, false))
11331133
file->hdr_size= (int)hdr_size;
11341134

1135+
if (file->external_dir_num==0)
1136+
set_forkname(file);
1137+
11351138
parray_append(files,file);
11361139
}
11371140

@@ -2488,7 +2491,7 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
24882491
charcontrol_path[MAXPGPATH];
24892492
charcontrol_path_temp[MAXPGPATH];
24902493
size_ti=0;
2491-
#defineBUFFERSZ 1024*1024
2494+
#defineBUFFERSZ(1024*1024)
24922495
char*buf;
24932496
int64backup_size_on_disk=0;
24942497
int64uncompressed_size_on_disk=0;

‎src/data.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -801,8 +801,11 @@ backup_non_data_file(pgFile *file, pgFile *prev_file,
801801
(prev_file&&file->exists_in_prev&&
802802
file->mtime <=parent_backup_time))
803803
{
804-
805-
file->crc=fio_get_crc32(from_fullpath,FIO_DB_HOST, false);
804+
/*
805+
* file could be deleted under our feets.
806+
* But then backup_non_data_file_internal will handle it safely
807+
*/
808+
file->crc=fio_get_crc32(from_fullpath,FIO_DB_HOST, false, true);
806809

807810
/* ...and checksum is the same... */
808811
if (EQ_TRADITIONAL_CRC32(file->crc,prev_file->crc))
@@ -1327,7 +1330,7 @@ restore_non_data_file(parray *parent_chain, pgBackup *dest_backup,
13271330
if (already_exists)
13281331
{
13291332
/* compare checksums of already existing file and backup file */
1330-
pg_crc32file_crc=fio_get_crc32(to_fullpath,FIO_DB_HOST, false);
1333+
pg_crc32file_crc=fio_get_crc32(to_fullpath,FIO_DB_HOST, false, false);
13311334

13321335
if (file_crc==tmp_file->crc)
13331336
{

‎src/dir.c

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -758,57 +758,22 @@ dir_check_file(pgFile *file, bool backup_logs)
758758
returnCHECK_FALSE;
759759
elseif (isdigit(file->name[0]))
760760
{
761-
char*fork_name;
762-
intlen;
763-
charsuffix[MAXPGPATH];
761+
set_forkname(file);
764762

765-
fork_name=strstr(file->name,"_");
766-
if (fork_name)
767-
{
768-
/* Auxiliary fork of the relfile */
769-
if (strcmp(fork_name,"_vm")==0)
770-
file->forkName=vm;
771-
772-
elseif (strcmp(fork_name,"_fsm")==0)
773-
file->forkName=fsm;
774-
775-
elseif (strcmp(fork_name,"_cfm")==0)
776-
file->forkName=cfm;
777-
778-
elseif (strcmp(fork_name,"_ptrack")==0)
779-
file->forkName=ptrack;
780-
781-
elseif (strcmp(fork_name,"_init")==0)
782-
file->forkName=init;
783-
784-
// extract relOid for certain forks
785-
if (file->forkName==vm||
786-
file->forkName==fsm||
787-
file->forkName==init||
788-
file->forkName==cfm)
789-
{
790-
// sanity
791-
if (sscanf(file->name,"%u_*",&(file->relOid))!=1)
792-
file->relOid=0;
793-
}
763+
if (file->forkName==ptrack)/* Compatibility with left-overs from ptrack1 */
764+
returnCHECK_FALSE;
765+
elseif (file->forkName!=none)
766+
returnCHECK_TRUE;
794767

795-
/* Do not backup ptrack files */
796-
if (file->forkName==ptrack)
797-
returnCHECK_FALSE;
798-
}
799-
else
768+
/* Set is_datafile flag */
800769
{
770+
charsuffix[MAXFNAMELEN];
801771

802-
len=strlen(file->name);
803-
/* reloid.cfm */
804-
if (len>3&&strcmp(file->name+len-3,"cfm")==0)
805-
returnCHECK_TRUE;
806-
772+
/* check if file is datafile */
807773
sscanf_res=sscanf(file->name,"%u.%d.%s",&(file->relOid),
808774
&(file->segno),suffix);
809-
if (sscanf_res==0)
810-
elog(ERROR,"Cannot parse file name \"%s\"",file->name);
811-
elseif (sscanf_res==1||sscanf_res==2)
775+
Assert(sscanf_res>0);/* since first char is digit */
776+
if (sscanf_res==1||sscanf_res==2)
812777
file->is_datafile= true;
813778
}
814779
}
@@ -1954,3 +1919,35 @@ pfilearray_clear_locks(parray *file_list)
19541919
pg_atomic_clear_flag(&file->lock);
19551920
}
19561921
}
1922+
1923+
/* Set forkName if possible */
1924+
void
1925+
set_forkname(pgFile*file)
1926+
{
1927+
intname_len=strlen(file->name);
1928+
1929+
/* Auxiliary fork of the relfile */
1930+
if (name_len>3&&strcmp(file->name+name_len-3,"_vm")==0)
1931+
file->forkName=vm;
1932+
1933+
elseif (name_len>4&&strcmp(file->name+name_len-4,"_fsm")==0)
1934+
file->forkName=fsm;
1935+
1936+
elseif (name_len>4&&strcmp(file->name+name_len-4,".cfm")==0)
1937+
file->forkName=cfm;
1938+
1939+
elseif (name_len>5&&strcmp(file->name+name_len-5,"_init")==0)
1940+
file->forkName=init;
1941+
1942+
elseif (name_len>7&&strcmp(file->name+name_len-7,"_ptrack")==0)
1943+
file->forkName=ptrack;
1944+
1945+
// extract relOid for certain forks
1946+
1947+
if ((file->forkName==vm||
1948+
file->forkName==fsm||
1949+
file->forkName==init||
1950+
file->forkName==cfm)&&
1951+
(sscanf(file->name,"%u*",&(file->relOid))!=1))
1952+
file->relOid=0;
1953+
}

‎src/pg_probackup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ bool perm_slot = false;
8888
/* backup options */
8989
boolbackup_logs= false;
9090
boolsmooth_checkpoint;
91-
char*remote_agent;
91+
boolremote_agent= false;
9292
staticchar*backup_note=NULL;
9393
/* catchup options */
9494
staticchar*catchup_source_pgdata=NULL;
@@ -361,6 +361,7 @@ main(int argc, char *argv[])
361361
elog(ERROR,"Version mismatch, pg_probackup binary with version '%s' "
362362
"is launched as an agent for pg_probackup binary with version '%s'",
363363
PROGRAM_VERSION,argv[2]);
364+
remote_agent= true;
364365
fio_communicate(STDIN_FILENO,STDOUT_FILENO);
365366
return0;
366367
caseHELP_CMD:

‎src/pg_probackup.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ typedef enum CompressAlg
215215

216216
typedefenumForkName
217217
{
218+
none,
218219
vm,
219220
fsm,
220221
cfm,
@@ -798,7 +799,7 @@ extern bool perm_slot;
798799
externboolsmooth_checkpoint;
799800

800801
/* remote probackup options */
801-
externchar*remote_agent;
802+
externboolremote_agent;
802803

803804
externboolexclusive_backup;
804805

@@ -1091,6 +1092,7 @@ extern int pgCompareString(const void *str1, const void *str2);
10911092
externintpgPrefixCompareString(constvoid*str1,constvoid*str2);
10921093
externintpgCompareOid(constvoid*f1,constvoid*f2);
10931094
externvoidpfilearray_clear_locks(parray*file_list);
1095+
externvoidset_forkname(pgFile*file);
10941096

10951097
/* in data.c */
10961098
externboolcheck_data_file(ConnectionArgs*arguments,pgFile*file,

‎src/utils/configuration.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,6 @@ config_get_opt(int argc, char **argv, ConfigOption cmd_options[],
531531
opt=option_find(c,options);
532532

533533
if (opt
534-
&& !remote_agent
535534
&&opt->allowed<SOURCE_CMD&&opt->allowed!=SOURCE_CMD_STRICT)
536535
elog(ERROR,"Option %s cannot be specified in command line",
537536
opt->lname);

‎src/utils/file.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,9 +1355,15 @@ fio_sync(char const* path, fio_location location)
13551355
}
13561356
}
13571357

1358+
enum {
1359+
GET_CRC32_DECOMPRESS=1,
1360+
GET_CRC32_MISSING_OK=2
1361+
};
1362+
13581363
/* Get crc32 of file */
13591364
pg_crc32
1360-
fio_get_crc32(constchar*file_path,fio_locationlocation,booldecompress)
1365+
fio_get_crc32(constchar*file_path,fio_locationlocation,
1366+
booldecompress,boolmissing_ok)
13611367
{
13621368
if (fio_is_remote(location))
13631369
{
@@ -1370,7 +1376,9 @@ fio_get_crc32(const char *file_path, fio_location location, bool decompress)
13701376
hdr.arg=0;
13711377

13721378
if (decompress)
1373-
hdr.arg=1;
1379+
hdr.arg=GET_CRC32_DECOMPRESS;
1380+
if (missing_ok)
1381+
hdr.arg |=GET_CRC32_MISSING_OK;
13741382

13751383
IO_CHECK(fio_write_all(fio_stdout,&hdr,sizeof(hdr)),sizeof(hdr));
13761384
IO_CHECK(fio_write_all(fio_stdout,file_path,path_len),path_len);
@@ -1381,9 +1389,9 @@ fio_get_crc32(const char *file_path, fio_location location, bool decompress)
13811389
else
13821390
{
13831391
if (decompress)
1384-
returnpgFileGetCRCgz(file_path, true,true);
1392+
returnpgFileGetCRCgz(file_path, true,missing_ok);
13851393
else
1386-
returnpgFileGetCRC(file_path, true,true);
1394+
returnpgFileGetCRC(file_path, true,missing_ok);
13871395
}
13881396
}
13891397

@@ -3380,10 +3388,10 @@ fio_communicate(int in, int out)
33803388
break;
33813389
caseFIO_GET_CRC32:
33823390
/* calculate crc32 for a file */
3383-
if (hdr.arg==1)
3384-
crc=pgFileGetCRCgz(buf, true,true);
3391+
if ((hdr.arg&GET_CRC32_DECOMPRESS))
3392+
crc=pgFileGetCRCgz(buf, true,(hdr.arg&GET_CRC32_MISSING_OK)!=0);
33853393
else
3386-
crc=pgFileGetCRC(buf, true,true);
3394+
crc=pgFileGetCRC(buf, true,(hdr.arg&GET_CRC32_MISSING_OK)!=0);
33873395
IO_CHECK(fio_write_all(out,&crc,sizeof(crc)),sizeof(crc));
33883396
break;
33893397
caseFIO_GET_CHECKSUM_MAP:

‎src/utils/file.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ extern int fio_truncate(int fd, off_t size);
120120
externintfio_close(intfd);
121121
externvoidfio_disconnect(void);
122122
externintfio_sync(charconst*path,fio_locationlocation);
123-
externpg_crc32fio_get_crc32(constchar*file_path,fio_locationlocation,booldecompress);
123+
externpg_crc32fio_get_crc32(constchar*file_path,fio_locationlocation,
124+
booldecompress,boolmissing_ok);
124125

125126
externintfio_rename(charconst*old_path,charconst*new_path,fio_locationlocation);
126127
externintfio_symlink(charconst*target,charconst*link_path,booloverwrite,fio_locationlocation);

‎tests/cfs_backup.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,11 @@ def test_delete_random_cfm_file_from_tablespace_dir(self):
995995
"FROM generate_series(0,256) i".format('t1',tblspace_name)
996996
)
997997

998+
self.node.safe_psql(
999+
"postgres",
1000+
"CHECKPOINT"
1001+
)
1002+
9981003
list_cmf=find_by_extensions(
9991004
[self.get_tblspace_path(self.node,tblspace_name)],
10001005
['.cfm'])
@@ -1044,6 +1049,11 @@ def test_delete_random_data_file_from_tablespace_dir(self):
10441049
"FROM generate_series(0,256) i".format('t1',tblspace_name)
10451050
)
10461051

1052+
self.node.safe_psql(
1053+
"postgres",
1054+
"CHECKPOINT"
1055+
)
1056+
10471057
list_data_files=find_by_pattern(
10481058
[self.get_tblspace_path(self.node,tblspace_name)],
10491059
'^.*/\d+$')

‎tests/cfs_restore.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def test_restore_empty_tablespace_from_fullbackup(self):
103103
"postgres",
104104
"SELECT * FROM pg_tablespace WHERE spcname='{0}'".format(tblspace_name)
105105
)
106+
tblspace=str(tblspace)
106107
self.assertTrue(
107108
tblspace_nameintblspaceand"compression=true"intblspace,
108109
"ERROR: The tablespace not restored or it restored without compressions"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp