@@ -121,7 +121,6 @@ backup_data_page(pgFile *file, XLogRecPtr prev_backup_start_lsn,
121
121
size_t read_len = 0 ;
122
122
XLogRecPtr page_lsn ;
123
123
int try_checksum = 100 ;
124
- bool is_zero_page = false;
125
124
126
125
header .block = blknum ;
127
126
offset = blknum * BLCKSZ ;
@@ -152,30 +151,29 @@ backup_data_page(pgFile *file, XLogRecPtr prev_backup_start_lsn,
152
151
int i ;
153
152
/* Check if the page is zeroed. */
154
153
for (i = 0 ; i < BLCKSZ && page .data [i ] == 0 ; i ++ );
154
+
155
+ /* Page is zeroed. No need to check header and checksum. */
155
156
if (i == BLCKSZ )
156
157
{
157
- is_zero_page = true;
158
- try_checksum = 0 ;
159
158
elog (LOG , "File: %s blknum %u, empty page" , file -> path , blknum );
159
+ break ;
160
160
}
161
161
162
162
/*
163
163
* If page is not completely empty and we couldn't parse it,
164
164
* try again several times. If it didn't help, throw error
165
165
*/
166
- if (!is_zero_page )
166
+
167
+ /* Try to read and verify this page again several times. */
168
+ if (try_checksum )
167
169
{
168
- /* Try to read and verify this page again several times. */
169
- if (try_checksum )
170
- {
171
- elog (WARNING , "File: %s blknum %u have wrong page header, try again" ,
172
- file -> path , blknum );
173
- usleep (100 );
174
- continue ;
175
- }
176
- else
177
- elog (ERROR , "File: %s blknum %u have wrong page header." , file -> path , blknum );
170
+ elog (WARNING , "File: %s blknum %u have wrong page header, try again" ,
171
+ file -> path , blknum );
172
+ usleep (100 );
173
+ continue ;
178
174
}
175
+ else
176
+ elog (ERROR , "File: %s blknum %u have wrong page header." , file -> path , blknum );
179
177
}
180
178
181
179
/* If the page hasn't changed since previous backup, don't backup it. */
@@ -188,25 +186,31 @@ backup_data_page(pgFile *file, XLogRecPtr prev_backup_start_lsn,
188
186
}
189
187
190
188
/* Verify checksum */
191
- if (current .checksum_version && ! is_zero_page )
189
+ if (current .checksum_version )
192
190
{
193
191
/*
194
192
* If checksum is wrong, sleep a bit and then try again
195
193
* several times. If it didn't help, throw error
196
194
*/
197
- if (pg_checksum_page (page .data , file -> segno * RELSEG_SIZE + blknum ) != ((PageHeader ) page .data )-> pd_checksum )
195
+ if (pg_checksum_page (page .data , file -> segno * RELSEG_SIZE + blknum )
196
+ != ((PageHeader ) page .data )-> pd_checksum )
198
197
{
199
198
if (try_checksum )
200
199
{
201
200
elog (WARNING , "File: %s blknum %u have wrong checksum, try again" ,
202
201
file -> path , blknum );
203
202
usleep (100 );
203
+ continue ;
204
204
}
205
205
else
206
206
elog (ERROR , "File: %s blknum %u have wrong checksum." ,
207
207
file -> path , blknum );
208
208
}
209
+ else
210
+ break ; /* page header and checksum are correct */
209
211
}
212
+ else
213
+ break ; /* page header is correct and checksum check is disabled */
210
214
}
211
215
212
216
file -> read_size += read_len ;
0 commit comments