forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb50991e
committed
Fix more crash-safe visibility map bugs, and improve comments.
In lazy_scan_heap, we could issue bogus warnings about incorrectinformation in the visibility map, because we checked the visibilitymap bit before locking the heap page, creating a race condition. Fixby rechecking the visibility map bit before we complain. Rejiggersome related logic so that we rely on the possibly-outdatedall_visible_according_to_vm value as little as possible.In heap_multi_insert, it's not safe to clear the visibility map bitbefore beginning the critical section. The visibility map is notcrash-safe unless we treat clearing the bit as a critical operation.Specifically, if the transaction were to error out after we set thebit and before entering the critical section, we could end up writingthe heap page to disk (with the bit cleared) and crashing before thevisibility map page made it to disk. That would be bad. heap_inserthas this correct, but somehow the order of operations got rearrangedwhen heap_multi_insert was added.Also, add some more comments to visibilitymap_test, lazy_scan_heap,and IndexOnlyNext, expounding on concurrency issues.Per extensive code review by Andres Freund, and further review by TomLane, who also made the original report about the bogus warnings.1 parent92135ea commitb50991e
File tree
4 files changed
+61
-15
lines changed- src/backend
- access/heap
- commands
- executor
4 files changed
+61
-15
lines changedLines changed: 9 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2149 | 2149 |
| |
2150 | 2150 |
| |
2151 | 2151 |
| |
2152 |
| - | |
2153 |
| - | |
2154 |
| - | |
2155 |
| - | |
2156 |
| - | |
2157 |
| - | |
2158 |
| - | |
2159 |
| - | |
2160 |
| - | |
2161 | 2152 |
| |
2162 | 2153 |
| |
2163 | 2154 |
| |
| |||
2172 | 2163 |
| |
2173 | 2164 |
| |
2174 | 2165 |
| |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
2175 | 2175 |
| |
2176 | 2176 |
| |
2177 | 2177 |
| |
|
Lines changed: 10 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
293 | 293 |
| |
294 | 294 |
| |
295 | 295 |
| |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
296 | 303 |
| |
297 | 304 |
| |
298 | 305 |
| |
| |||
327 | 334 |
| |
328 | 335 |
| |
329 | 336 |
| |
330 |
| - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
331 | 340 |
| |
332 | 341 |
| |
333 | 342 |
| |
|
Lines changed: 29 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
419 | 419 |
| |
420 | 420 |
| |
421 | 421 |
| |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
422 | 431 |
| |
423 | 432 |
| |
424 | 433 |
| |
| |||
852 | 861 |
| |
853 | 862 |
| |
854 | 863 |
| |
855 |
| - | |
| 864 | + | |
856 | 865 |
| |
857 | 866 |
| |
858 | 867 |
| |
859 | 868 |
| |
860 | 869 |
| |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
861 | 883 |
| |
862 |
| - | |
863 |
| - | |
864 | 884 |
| |
865 | 885 |
| |
866 | 886 |
| |
867 | 887 |
| |
868 |
| - | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
869 | 892 |
| |
870 |
| - | |
| 893 | + | |
| 894 | + | |
871 | 895 |
| |
872 | 896 |
| |
873 | 897 |
| |
|
Lines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
82 | 82 |
| |
83 | 83 |
| |
84 | 84 |
| |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
85 | 98 |
| |
86 | 99 |
| |
87 | 100 |
| |
|
0 commit comments
Comments
(0)