Commit 81c4508
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, which
could 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. More
importantly, this avoids renumbering the other enum values, which would
cause even bigger confusion in extensions that use ReadBufferExtended, but
haven't been recompiled.
Backpatch to all supported versions; this has been racy since hot standby
was introduced.1 parent 35fed51 commit 81c4508
File tree
5 files changed
+78
-32
lines changed- src
- backend
- access
- hash
- heap
- transam
- storage/buffer
- include/storage
5 files changed
+78
-32
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 | |
|---|---|---|---|
| |||
7556 | 7556 | | |
7557 | 7557 | | |
7558 | 7558 | | |
7559 | | - | |
| 7559 | + | |
7560 | 7560 | | |
7561 | 7561 | | |
7562 | 7562 | | |
| |||
7683 | 7683 | | |
7684 | 7684 | | |
7685 | 7685 | | |
7686 | | - | |
| 7686 | + | |
7687 | 7687 | | |
7688 | 7688 | | |
7689 | 7689 | | |
| |||
7876 | 7876 | | |
7877 | 7877 | | |
7878 | 7878 | | |
7879 | | - | |
| 7879 | + | |
7880 | 7880 | | |
7881 | 7881 | | |
7882 | 7882 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
291 | | - | |
292 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
293 | 297 | | |
294 | 298 | | |
295 | 299 | | |
| |||
312 | 316 | | |
313 | 317 | | |
314 | 318 | | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
319 | 326 | | |
320 | 327 | | |
321 | 328 | | |
| |||
341 | 348 | | |
342 | 349 | | |
343 | 350 | | |
344 | | - | |
| 351 | + | |
| 352 | + | |
345 | 353 | | |
346 | 354 | | |
347 | 355 | | |
348 | 356 | | |
349 | 357 | | |
350 | 358 | | |
351 | 359 | | |
352 | | - | |
353 | | - | |
| 360 | + | |
| 361 | + | |
354 | 362 | | |
355 | 363 | | |
356 | 364 | | |
| |||
369 | 377 | | |
370 | 378 | | |
371 | 379 | | |
372 | | - | |
373 | | - | |
| 380 | + | |
| 381 | + | |
374 | 382 | | |
375 | 383 | | |
376 | 384 | | |
| |||
424 | 432 | | |
425 | 433 | | |
426 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
427 | 438 | | |
| 439 | + | |
428 | 440 | | |
429 | 441 | | |
430 | 442 | | |
431 | 443 | | |
432 | 444 | | |
433 | 445 | | |
434 | 446 | | |
| 447 | + | |
| 448 | + | |
435 | 449 | | |
436 | 450 | | |
437 | 451 | | |
| |||
537 | 551 | | |
538 | 552 | | |
539 | 553 | | |
540 | | - | |
| 554 | + | |
541 | 555 | | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | 556 | | |
547 | 557 | | |
548 | 558 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
499 | 499 | | |
500 | 500 | | |
501 | 501 | | |
502 | | - | |
503 | | - | |
504 | | - | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
505 | 505 | | |
| 506 | + | |
| 507 | + | |
506 | 508 | | |
507 | 509 | | |
508 | 510 | | |
509 | 511 | | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
510 | 515 | | |
511 | 516 | | |
512 | 517 | | |
| |||
648 | 653 | | |
649 | 654 | | |
650 | 655 | | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
651 | 668 | | |
652 | 669 | | |
653 | 670 | | |
| |||
729 | 746 | | |
730 | 747 | | |
731 | 748 | | |
732 | | - | |
| 749 | + | |
733 | 750 | | |
734 | 751 | | |
735 | 752 | | |
| |||
771 | 788 | | |
772 | 789 | | |
773 | 790 | | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
774 | 807 | | |
775 | 808 | | |
776 | 809 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
0 commit comments