forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit7eab804
committed
Fix race condition between hot standby and restoring a full-page image.
There was a window in RestoreBackupBlock where a page would be zeroed out,but not yet locked. If a backend pinned and locked the page in that window,it saw the zeroed page instead of the old page or new page contents, whichcould lead to missing rows in a result set, or errors.To fix, replace RBM_ZERO with RBM_ZERO_AND_LOCK, which atomically pins,zeroes, and locks the page, if it's not in the buffer cache already.In stable branches, the old RBM_ZERO constant is renamed to RBM_DO_NOT_USE,to avoid breaking any 3rd party extensions that might use RBM_ZERO. Moreimportantly, this avoids renumbering the other enum values, which wouldcause even bigger confusion in extensions that use ReadBufferExtended, buthaven't been recompiled.Backpatch to all supported versions; this has been racy since hot standbywas introduced.1 parentd47fff3 commit7eab804
File tree
6 files changed
+66
-25
lines changed- src
- backend
- access
- hash
- heap
- transam
- storage/buffer
- include/storage
6 files changed
+66
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
159 | | - | |
160 | | - | |
| 158 | + | |
| 159 | + | |
161 | 160 | | |
162 | 161 | | |
163 | 162 | | |
| |||
198 | 197 | | |
199 | 198 | | |
200 | 199 | | |
| 200 | + | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
204 | | - | |
205 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
206 | 207 | | |
207 | 208 | | |
208 | 209 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4884 | 4884 | | |
4885 | 4885 | | |
4886 | 4886 | | |
4887 | | - | |
| 4887 | + | |
4888 | 4888 | | |
4889 | | - | |
4890 | 4889 | | |
4891 | 4890 | | |
4892 | 4891 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3813 | 3813 | | |
3814 | 3814 | | |
3815 | 3815 | | |
3816 | | - | |
| 3816 | + | |
3817 | 3817 | | |
3818 | | - | |
3819 | | - | |
3820 | | - | |
3821 | | - | |
3822 | 3818 | | |
3823 | 3819 | | |
3824 | 3820 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
| 260 | + | |
| 261 | + | |
261 | 262 | | |
262 | 263 | | |
263 | 264 | | |
264 | 265 | | |
265 | 266 | | |
266 | 267 | | |
267 | 268 | | |
268 | | - | |
269 | | - | |
| 269 | + | |
| 270 | + | |
270 | 271 | | |
271 | 272 | | |
272 | 273 | | |
| |||
285 | 286 | | |
286 | 287 | | |
287 | 288 | | |
288 | | - | |
289 | | - | |
| 289 | + | |
| 290 | + | |
290 | 291 | | |
291 | 292 | | |
292 | 293 | | |
| |||
340 | 341 | | |
341 | 342 | | |
342 | 343 | | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
343 | 347 | | |
| 348 | + | |
344 | 349 | | |
345 | 350 | | |
346 | 351 | | |
347 | 352 | | |
348 | 353 | | |
349 | 354 | | |
350 | 355 | | |
| 356 | + | |
| 357 | + | |
351 | 358 | | |
352 | 359 | | |
353 | 360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
214 | | - | |
215 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
216 | 216 | | |
| 217 | + | |
| 218 | + | |
217 | 219 | | |
218 | 220 | | |
219 | 221 | | |
220 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
221 | 226 | | |
222 | 227 | | |
223 | 228 | | |
| |||
359 | 364 | | |
360 | 365 | | |
361 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
362 | 379 | | |
363 | 380 | | |
364 | 381 | | |
| |||
439 | 456 | | |
440 | 457 | | |
441 | 458 | | |
442 | | - | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
443 | 462 | | |
| 463 | + | |
444 | 464 | | |
445 | 465 | | |
446 | 466 | | |
| |||
481 | 501 | | |
482 | 502 | | |
483 | 503 | | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
484 | 517 | | |
485 | 518 | | |
486 | 519 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
43 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
| |||
0 commit comments
Comments
(0)