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

Commit0e11c87

Browse files
committed
fix skipping pages which hasn't changed since prev backup
1 parent1eff9fc commit0e11c87

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

‎data.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static void
5656
backup_data_page(pgFile*file,XLogRecPtrprev_backup_start_lsn,
5757
BlockNumberblknum,BlockNumbernblocks,
5858
FILE*in,FILE*out,
59-
pg_crc32*crc)
59+
pg_crc32*crc,int*n_skipped)
6060
{
6161
BackupPageHeaderheader;
6262
off_toffset;
@@ -134,7 +134,10 @@ backup_data_page(pgFile *file, XLogRecPtr prev_backup_start_lsn,
134134
if (!XLogRecPtrIsInvalid(prev_backup_start_lsn)
135135
&& !XLogRecPtrIsInvalid(page_lsn)
136136
&&page_lsn<prev_backup_start_lsn)
137+
{
138+
*n_skipped+=1;
137139
return;
140+
}
138141

139142
/* Verify checksum */
140143
if(current.checksum_version&& !is_zero_page)
@@ -195,6 +198,8 @@ backup_data_file(const char *from_root, const char *to_root,
195198
FILE*out;
196199
BlockNumberblknum=0;
197200
BlockNumbernblocks=0;
201+
intn_blocks_skipped=0;
202+
intn_blocks_read=0;
198203

199204
/* reset size summary */
200205
file->read_size=0;
@@ -253,26 +258,24 @@ backup_data_file(const char *from_root, const char *to_root,
253258
if (file->pagemap.bitmapsize==0)
254259
{
255260
for (blknum=0;blknum<nblocks;blknum++)
261+
{
256262
backup_data_page(file,prev_backup_start_lsn,blknum,
257-
nblocks,in,out,&(file->crc));
263+
nblocks,in,out,&(file->crc),&n_blocks_skipped);
264+
n_blocks_read++;
265+
}
258266
}
259267
else
260268
{
261269
datapagemap_iterator_t*iter;
262270
iter=datapagemap_iterate(&file->pagemap);
263271
while (datapagemap_next(iter,&blknum))
272+
{
264273
backup_data_page(file,prev_backup_start_lsn,blknum,
265-
nblocks,in,out,&(file->crc));
274+
nblocks,in,out,&(file->crc),&n_blocks_skipped);
275+
n_blocks_read++;
276+
}
266277

267278
pg_free(iter);
268-
/*
269-
* If we have pagemap then file can't be a zero size.
270-
* Otherwise, we will clear the last file.
271-
* Increase read_size to delete after.
272-
* TODO rewrite this code
273-
*/
274-
if (file->read_size==0)
275-
file->read_size++;
276279
}
277280

278281
/* update file permission */
@@ -294,8 +297,11 @@ backup_data_file(const char *from_root, const char *to_root,
294297
if (file->read_size==0)
295298
file->is_datafile= false;
296299

297-
/* We do not backup if all pages skipped. */
298-
if (file->write_size==0&&file->read_size>0)
300+
/*
301+
* If we have pagemap then file can't be a zero size.
302+
* Otherwise, we will clear the last file.
303+
*/
304+
if (n_blocks_read==n_blocks_skipped)
299305
{
300306
if (remove(to_path)==-1)
301307
elog(ERROR,"cannot remove file \"%s\": %s",to_path,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp