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

Commitf025b90

Browse files
committed
Rewrite fio_gz* support
1 parentf0cbfb7 commitf025b90

File tree

4 files changed

+226
-74
lines changed

4 files changed

+226
-74
lines changed

‎src/data.c‎

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,6 @@ push_wal_file(const char *from_path, const char *to_path, bool is_compress,
11021102
#ifdefHAVE_LIBZ
11031103
chargz_to_path[MAXPGPATH];
11041104
gzFilegz_out=NULL;
1105-
intgz_tmp=-1;
11061105

11071106
if (is_compress)
11081107
{
@@ -1135,14 +1134,10 @@ push_wal_file(const char *from_path, const char *to_path, bool is_compress,
11351134
{
11361135
snprintf(to_path_temp,sizeof(to_path_temp),"%s.partial",gz_to_path);
11371136

1138-
gz_out=fio_gzopen(to_path_temp,PG_BINARY_W,&gz_tmp,FIO_BACKUP_HOST);
1137+
gz_out=fio_gzopen(to_path_temp,PG_BINARY_W,instance_config.compress_level,FIO_BACKUP_HOST);
11391138
if (gz_out==NULL)
11401139
elog(ERROR,"Cannot open destination temporary WAL file \"%s\": %s",
11411140
to_path_temp,strerror(errno));
1142-
if (gzsetparams(gz_out,instance_config.compress_level,Z_DEFAULT_STRATEGY)!=Z_OK)
1143-
elog(ERROR,"Cannot set compression level %d to file \"%s\": %s",
1144-
instance_config.compress_level,to_path_temp,
1145-
get_gz_error(gz_out,errno));
11461141
}
11471142
else
11481143
#endif
@@ -1176,7 +1171,7 @@ push_wal_file(const char *from_path, const char *to_path, bool is_compress,
11761171
#ifdefHAVE_LIBZ
11771172
if (is_compress)
11781173
{
1179-
if (gzwrite(gz_out,buf,read_len)!=read_len)
1174+
if (fio_gzwrite(gz_out,buf,read_len)!=read_len)
11801175
{
11811176
errno_temp=errno;
11821177
fio_unlink(to_path_temp,FIO_BACKUP_HOST);
@@ -1204,7 +1199,7 @@ push_wal_file(const char *from_path, const char *to_path, bool is_compress,
12041199
#ifdefHAVE_LIBZ
12051200
if (is_compress)
12061201
{
1207-
if (fio_gzclose(gz_out,to_path_temp,gz_tmp)!=0)
1202+
if (fio_gzclose(gz_out)!=0)
12081203
{
12091204
errno_temp=errno;
12101205
fio_unlink(to_path_temp,FIO_BACKUP_HOST);
@@ -1696,10 +1691,9 @@ fileEqualCRC(const char *path1, const char *path2, bool path2_is_compressed)
16961691
{
16971692
charbuf [1024];
16981693
gzFilegz_in=NULL;
1699-
intgz_tmp=-1;
17001694

17011695
INIT_FILE_CRC32(true,crc2);
1702-
gz_in=fio_gzopen(path2,PG_BINARY_R,&gz_tmp,FIO_BACKUP_HOST);
1696+
gz_in=fio_gzopen(path2,PG_BINARY_R,Z_DEFAULT_COMPRESSION,FIO_BACKUP_HOST);
17031697
if (gz_in==NULL)
17041698
/* File cannot be read */
17051699
elog(ERROR,
@@ -1709,20 +1703,20 @@ fileEqualCRC(const char *path1, const char *path2, bool path2_is_compressed)
17091703
for (;;)
17101704
{
17111705
size_tread_len=0;
1712-
read_len=gzread(gz_in,buf,sizeof(buf));
1713-
if (read_len!=sizeof(buf)&& !gzeof(gz_in))
1706+
read_len=fio_gzread(gz_in,buf,sizeof(buf));
1707+
if (read_len!=sizeof(buf)&& !fio_gzeof(gz_in))
17141708
/* An error occurred while reading the file */
17151709
elog(ERROR,
17161710
"Cannot compare WAL file \"%s\" with compressed \"%s\"",
17171711
path1,path2);
17181712

17191713
COMP_FILE_CRC32(true,crc2,buf,read_len);
1720-
if (gzeof(gz_in)||read_len==0)
1714+
if (fio_gzeof(gz_in)||read_len==0)
17211715
break;
17221716
}
17231717
FIN_FILE_CRC32(true,crc2);
17241718

1725-
if (fio_gzclose(gz_in,path2,gz_tmp)!=0)
1719+
if (fio_gzclose(gz_in)!=0)
17261720
elog(ERROR,"Cannot close compressed WAL file \"%s\": %s",
17271721
path2,get_gz_error(gz_in,errno));
17281722
}

‎src/parsexlog.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ typedef struct XLogPageReadPrivate
108108
#ifdefHAVE_LIBZ
109109
gzFilegz_xlogfile;
110110
chargz_xlogpath[MAXPGPATH];
111-
intgz_tmp;
112111
#endif
113112
}XLogPageReadPrivate;
114113

@@ -1020,7 +1019,7 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
10201019

10211020
private_data->xlogexists= true;
10221021
private_data->gz_xlogfile=fio_gzopen(private_data->gz_xlogpath,
1023-
"rb",&private_data->gz_tmp,private_data->location);
1022+
"rb",-1,private_data->location);
10241023
if (private_data->gz_xlogfile==NULL)
10251024
{
10261025
elog(WARNING,"Thread [%d]: Could not open compressed WAL segment \"%s\": %s",
@@ -1072,7 +1071,7 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
10721071
#ifdefHAVE_LIBZ
10731072
else
10741073
{
1075-
if (gzseek(private_data->gz_xlogfile, (z_off_t)targetPageOff,SEEK_SET)==-1)
1074+
if (fio_gzseek(private_data->gz_xlogfile, (z_off_t)targetPageOff,SEEK_SET)==-1)
10761075
{
10771076
elog(WARNING,"Thread [%d]: Could not seek in compressed WAL segment \"%s\": %s",
10781077
private_data->thread_num,
@@ -1081,7 +1080,7 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
10811080
return-1;
10821081
}
10831082

1084-
if (gzread(private_data->gz_xlogfile,readBuf,XLOG_BLCKSZ)!=XLOG_BLCKSZ)
1083+
if (fio_gzread(private_data->gz_xlogfile,readBuf,XLOG_BLCKSZ)!=XLOG_BLCKSZ)
10851084
{
10861085
elog(WARNING,"Thread [%d]: Could not read from compressed WAL segment \"%s\": %s",
10871086
private_data->thread_num,
@@ -1147,7 +1146,7 @@ CleanupXLogPageRead(XLogReaderState *xlogreader)
11471146
#ifdefHAVE_LIBZ
11481147
elseif (private_data->gz_xlogfile!= NULL)
11491148
{
1150-
fio_gzclose(private_data->gz_xlogfile,private_data->gz_xlogpath,private_data->gz_tmp);
1149+
fio_gzclose(private_data->gz_xlogfile);
11511150
private_data->gz_xlogfile=NULL;
11521151
}
11531152
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp