forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit98f58a3
committed
Fix Hot-Standby initialization of clog and subtrans.
These bugs can cause data loss on standbys started with hot_standby=on atthe moment they start to accept read only queries, by marking committedtransactions as uncommited. The likelihood of such corruptions is smallunless the primary has a high transaction rate.5a031a5 fixed bugs in HS's startup logicby maintaining less state until at least STANDBY_SNAPSHOT_PENDING statewas reached, missing the fact that both clog and subtrans are written tobefore that. This only failed to fail in common cases because the usageof ExtendCLOG in procarray.c was superflous since clog extensions areactually WAL logged.f44eedc/I then tried to fix the missingextensions of pg_subtrans due to the former commit's changes - which arenot WAL logged - by performing the extensions when switching to a state> STANDBY_INITIALIZED and not performing xid assignments before that -again missing the fact that ExtendCLOG is unneccessary - but screwed uptwice: Once because latestObservedXid wasn't updated anymore in thatstate due to the earlier commit and once by having an off-by-one error inthe loop performing extensions. This means that whenever aCLOG_XACTS_PER_PAGE (32768 with default settings) boundary was crossedbetween the start of the checkpoint recovery started from and the firstxl_running_xact record old transactions commit bits in pg_clog could beoverwritten if they started and committed in that window.Fix this mess by not performing ExtendCLOG() in HS at all anymore sinceit's unneeded and evidently dangerous and by performing subtransextensions even before reaching STANDBY_SNAPSHOT_PENDING.Analysis and patch by Andres Freund. Reported by Christophe Pettus.Backpatch down to 9.0, like the previous commit that caused this.1 parent1a3d104 commit98f58a3
2 files changed
+41
-29
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
622 | 622 |
| |
623 | 623 |
| |
624 | 624 |
| |
625 |
| - | |
| 625 | + | |
626 | 626 |
| |
627 | 627 |
| |
628 | 628 |
| |
|
Lines changed: 40 additions & 28 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
473 | 473 |
| |
474 | 474 |
| |
475 | 475 |
| |
476 |
| - | |
| 476 | + | |
477 | 477 |
| |
478 | 478 |
| |
479 | 479 |
| |
| |||
483 | 483 |
| |
484 | 484 |
| |
485 | 485 |
| |
486 |
| - | |
487 |
| - | |
488 |
| - | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
489 | 490 |
| |
490 | 491 |
| |
491 | 492 |
| |
| |||
661 | 662 |
| |
662 | 663 |
| |
663 | 664 |
| |
664 |
| - | |
665 |
| - | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
666 | 673 |
| |
667 | 674 |
| |
| 675 | + | |
668 | 676 |
| |
669 | 677 |
| |
670 |
| - | |
671 | 678 |
| |
672 |
| - | |
673 | 679 |
| |
674 | 680 |
| |
| 681 | + | |
675 | 682 |
| |
676 | 683 |
| |
677 | 684 |
| |
| |||
756 | 763 |
| |
757 | 764 |
| |
758 | 765 |
| |
759 |
| - | |
760 |
| - | |
761 |
| - | |
762 |
| - | |
763 | 766 |
| |
764 | 767 |
| |
765 | 768 |
| |
| |||
786 | 789 |
| |
787 | 790 |
| |
788 | 791 |
| |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
789 | 796 |
| |
790 | 797 |
| |
791 | 798 |
| |
| |||
2661 | 2668 |
| |
2662 | 2669 |
| |
2663 | 2670 |
| |
| 2671 | + | |
2664 | 2672 |
| |
2665 | 2673 |
| |
2666 | 2674 |
| |
2667 | 2675 |
| |
2668 |
| - | |
2669 |
| - | |
2670 |
| - | |
2671 |
| - | |
2672 |
| - | |
2673 |
| - | |
2674 |
| - | |
2675 |
| - | |
2676 | 2676 |
| |
2677 | 2677 |
| |
2678 | 2678 |
| |
| |||
2683 | 2683 |
| |
2684 | 2684 |
| |
2685 | 2685 |
| |
2686 |
| - | |
2687 |
| - | |
2688 |
| - | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
2689 | 2693 |
| |
2690 | 2694 |
| |
2691 |
| - | |
2692 |
| - | |
| 2695 | + | |
2693 | 2696 |
| |
2694 |
| - | |
| 2697 | + | |
2695 | 2698 |
| |
| 2699 | + | |
| 2700 | + | |
2696 | 2701 |
| |
2697 |
| - | |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
2698 | 2710 |
| |
2699 | 2711 |
| |
2700 | 2712 |
| |
2701 |
| - | |
| 2713 | + | |
2702 | 2714 |
| |
2703 | 2715 |
| |
2704 | 2716 |
| |
|
0 commit comments
Comments
(0)