forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit8076c00
committed
Assert that a snapshot is active or registered before it's used
The comment in GetTransactionSnapshot() said that you "should callRegisterSnapshot or PushActiveSnapshot on the returned snap if it isto be used very long". That felt too unclear to me. Make the commentmore strongly worded.To enforce that rule and to catch potential bugs where a snapshotmight get invalidated while it's still in use, add an assertion toHeapTupleSatisfiesMVCC() to check that the snapshot is registered orpushed to active stack. No new bugs were found by this, but it seemslike good future-proofing. It's not a great place for the check;HeapTupleSatisfiesMVCC() is in fact safe to call with an unregisteredsnapshot, and the assertion won't catch other unsafe uses. But it goesa long way in practice.Fix a few cases that were playing fast and loose with that and justassumed that the snapshot cannot be invalidated during a scan. Thoseassumptions were not wrong, but they're not performance critical, solet's drop the excuses and just register the snapshot. These werefalse positives found by the new assertion.Discussion:https://www.postgresql.org/message-id/7c56f180-b9e1-481e-8c1d-efa63de3ecbb@iki.fi1 parentbd65cb3 commit8076c00
File tree
5 files changed
+26
-17
lines changed- src/backend
- access
- heap
- index
- commands
- utils
- cache
- time
5 files changed
+26
-17
lines changedLines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
962 | 962 |
| |
963 | 963 |
| |
964 | 964 |
| |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
965 | 974 |
| |
966 | 975 |
| |
967 | 976 |
| |
|
Lines changed: 2 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
577 | 577 |
| |
578 | 578 |
| |
579 | 579 |
| |
580 |
| - | |
581 |
| - | |
582 |
| - | |
583 |
| - | |
584 |
| - | |
585 |
| - | |
586 | 580 |
| |
| 581 | + | |
587 | 582 |
| |
588 | 583 |
| |
589 | 584 |
| |
590 | 585 |
| |
| 586 | + | |
591 | 587 |
| |
592 | 588 |
| |
593 | 589 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
288 | 288 |
| |
289 | 289 |
| |
290 | 290 |
| |
291 |
| - | |
| 291 | + | |
292 | 292 |
| |
293 | 293 |
| |
294 | 294 |
| |
| |||
313 | 313 |
| |
314 | 314 |
| |
315 | 315 |
| |
| 316 | + | |
316 | 317 |
| |
317 | 318 |
| |
318 | 319 |
| |
|
Lines changed: 9 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
371 | 371 |
| |
372 | 372 |
| |
373 | 373 |
| |
374 |
| - | |
375 |
| - | |
376 |
| - | |
377 |
| - | |
378 |
| - | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
379 | 378 |
| |
380 | 379 |
| |
381 |
| - | |
| 380 | + | |
382 | 381 |
| |
383 | 382 |
| |
384 | 383 |
| |
| |||
395 | 394 |
| |
396 | 395 |
| |
397 | 396 |
| |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
398 | 401 |
| |
399 | 402 |
| |
400 | 403 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
203 | 203 |
| |
204 | 204 |
| |
205 | 205 |
| |
206 |
| - | |
207 |
| - | |
208 |
| - | |
209 |
| - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
210 | 210 |
| |
211 | 211 |
| |
212 | 212 |
| |
|
0 commit comments
Comments
(0)