forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit681dbe7
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 parentef5a3b9 commit681dbe7
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 changedLines changed: 7 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
158 | 158 |
| |
159 | 159 |
| |
160 | 160 |
| |
161 |
| - | |
162 |
| - | |
163 |
| - | |
| 161 | + | |
| 162 | + | |
164 | 163 |
| |
165 | 164 |
| |
166 | 165 |
| |
| |||
201 | 200 |
| |
202 | 201 |
| |
203 | 202 |
| |
| 203 | + | |
204 | 204 |
| |
205 | 205 |
| |
206 |
| - | |
207 |
| - | |
208 |
| - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
209 | 210 |
| |
210 | 211 |
| |
211 | 212 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4299 | 4299 |
| |
4300 | 4300 |
| |
4301 | 4301 |
| |
4302 |
| - | |
| 4302 | + | |
4303 | 4303 |
| |
4304 |
| - | |
4305 | 4304 |
| |
4306 | 4305 |
| |
4307 | 4306 |
| |
|
Lines changed: 1 addition & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3562 | 3562 |
| |
3563 | 3563 |
| |
3564 | 3564 |
| |
3565 |
| - | |
| 3565 | + | |
3566 | 3566 |
| |
3567 |
| - | |
3568 |
| - | |
3569 |
| - | |
3570 |
| - | |
3571 | 3567 |
| |
3572 | 3568 |
| |
3573 | 3569 |
| |
|
Lines changed: 12 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
234 | 234 |
| |
235 | 235 |
| |
236 | 236 |
| |
237 |
| - | |
| 237 | + | |
| 238 | + | |
238 | 239 |
| |
239 | 240 |
| |
240 | 241 |
| |
241 | 242 |
| |
242 | 243 |
| |
243 | 244 |
| |
244 | 245 |
| |
245 |
| - | |
246 |
| - | |
| 246 | + | |
| 247 | + | |
247 | 248 |
| |
248 | 249 |
| |
249 | 250 |
| |
| |||
262 | 263 |
| |
263 | 264 |
| |
264 | 265 |
| |
265 |
| - | |
266 |
| - | |
| 266 | + | |
| 267 | + | |
267 | 268 |
| |
268 | 269 |
| |
269 | 270 |
| |
| |||
317 | 318 |
| |
318 | 319 |
| |
319 | 320 |
| |
| 321 | + | |
| 322 | + | |
| 323 | + | |
320 | 324 |
| |
| 325 | + | |
321 | 326 |
| |
322 | 327 |
| |
323 | 328 |
| |
324 | 329 |
| |
325 | 330 |
| |
326 | 331 |
| |
327 | 332 |
| |
| 333 | + | |
| 334 | + | |
328 | 335 |
| |
329 | 336 |
| |
330 | 337 |
| |
|
Lines changed: 37 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
204 | 204 |
| |
205 | 205 |
| |
206 | 206 |
| |
207 |
| - | |
208 |
| - | |
209 |
| - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
210 | 210 |
| |
| 211 | + | |
| 212 | + | |
211 | 213 |
| |
212 | 214 |
| |
213 | 215 |
| |
214 | 216 |
| |
| 217 | + | |
| 218 | + | |
| 219 | + | |
215 | 220 |
| |
216 | 221 |
| |
217 | 222 |
| |
| |||
345 | 350 |
| |
346 | 351 |
| |
347 | 352 |
| |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
348 | 365 |
| |
349 | 366 |
| |
350 | 367 |
| |
| |||
425 | 442 |
| |
426 | 443 |
| |
427 | 444 |
| |
428 |
| - | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
429 | 448 |
| |
| 449 | + | |
430 | 450 |
| |
431 | 451 |
| |
432 | 452 |
| |
| |||
453 | 473 |
| |
454 | 474 |
| |
455 | 475 |
| |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
456 | 489 |
| |
457 | 490 |
| |
458 | 491 |
| |
|
Lines changed: 8 additions & 3 deletions
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)