forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit49d9cfc
committed
Fix replay of create database records on standby
Crash recovery on standby may encounter missing directories whenreplaying create database WAL records. Prior to this patch, the standbywould fail to recover in such a case. However, the directories could belegitimately missing. Consider a sequence of WAL records as follows: CREATE DATABASE DROP DATABASE DROP TABLESPACEIf, after replaying the last WAL record and removing the tablespacedirectory, the standby crashes and has to replay the create databaserecord again, the crash recovery must be able to move on.This patch adds a mechanism similar to invalid-page tracking, to keep atally of missing directories during crash recovery. If all the missingdirectory references are matched with corresponding drop records at theend of crash recovery, the standby can safely continue following theprimary.Backpatch to 13, at least for now. The bug is older, but fixing it inolder branches requires more careful study of the interactions withcommite6d8069, which appeared in 13.A new TAP test file is added to verify the condition. However, becauseit depends on commitd6d317d, it can only be added to branchmaster. I (Álvaro) manually verified that the code behaves as expectedin branch 14. It's a bit nervous-making to leave the code uncovered bytests in older branches, but leaving the bug unfixed is even worse.Also, the main reason this fix took so long is precisely that wecouldn't agree on a good strategy to approach testing for the bug, soperhaps this is the best we can do.Diagnosed-by: Paul Guo <paulguo@gmail.com>Author: Paul Guo <paulguo@gmail.com>Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>Author: Asim R Praveen <apraveen@pivotal.io>Discussion:https://postgr.es/m/CAEET0ZGx9AvioViLf7nbR_8tH9-=27DN5xWJ2P9-ROH16e4JUA@mail.gmail.com1 parentc64fb69 commit49d9cfc
File tree
7 files changed
+311
-1
lines changed- src
- backend
- access/transam
- commands
- include/access
- test/recovery/t
- tools/pgindent
7 files changed
+311
-1
lines changedLines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2047 | 2047 |
| |
2048 | 2048 |
| |
2049 | 2049 |
| |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
2050 | 2056 |
| |
2051 | 2057 |
| |
2052 | 2058 |
| |
|
Lines changed: 158 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
54 | 54 |
| |
55 | 55 |
| |
56 | 56 |
| |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
57 | 215 |
| |
58 | 216 |
| |
59 | 217 |
| |
| |||
79 | 237 |
| |
80 | 238 |
| |
81 | 239 |
| |
82 |
| - | |
83 | 240 |
| |
84 | 241 |
| |
85 | 242 |
| |
|
Lines changed: 57 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
| 33 | + | |
33 | 34 |
| |
34 | 35 |
| |
35 | 36 |
| |
| |||
2483 | 2484 |
| |
2484 | 2485 |
| |
2485 | 2486 |
| |
| 2487 | + | |
2486 | 2488 |
| |
| 2489 | + | |
2487 | 2490 |
| |
2488 | 2491 |
| |
2489 | 2492 |
| |
| |||
2501 | 2504 |
| |
2502 | 2505 |
| |
2503 | 2506 |
| |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
| 2520 | + | |
| 2521 | + | |
| 2522 | + | |
| 2523 | + | |
| 2524 | + | |
| 2525 | + | |
| 2526 | + | |
| 2527 | + | |
| 2528 | + | |
| 2529 | + | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
| 2533 | + | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
| 2540 | + | |
| 2541 | + | |
| 2542 | + | |
| 2543 | + | |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
2504 | 2557 |
| |
2505 | 2558 |
| |
2506 | 2559 |
| |
| |||
2563 | 2616 |
| |
2564 | 2617 |
| |
2565 | 2618 |
| |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
2566 | 2623 |
| |
2567 | 2624 |
| |
2568 | 2625 |
| |
|
Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
57 | 57 |
| |
58 | 58 |
| |
59 | 59 |
| |
| 60 | + | |
60 | 61 |
| |
61 | 62 |
| |
62 | 63 |
| |
| |||
1574 | 1575 |
| |
1575 | 1576 |
| |
1576 | 1577 |
| |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
1577 | 1594 |
| |
1578 | 1595 |
| |
1579 | 1596 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
65 | 65 |
| |
66 | 66 |
| |
67 | 67 |
| |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
68 | 72 |
| |
69 | 73 |
| |
70 | 74 |
| |
|
Lines changed: 67 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + |
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3736 | 3736 |
| |
3737 | 3737 |
| |
3738 | 3738 |
| |
| 3739 | + | |
| 3740 | + | |
3739 | 3741 |
| |
3740 | 3742 |
| |
3741 | 3743 |
| |
|
0 commit comments
Comments
(0)