forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb04aeb0
committed
Add assertions that we hold some relevant lock during relation open.
Opening a relation with no lock at all is unsafe; there's no guaranteethat we'll see a consistent state of the relevant catalog entries.While use of MVCC scans to read the catalogs partially addresses thatcomplaint, it's still possible to switch to a new catalog snapshotpartway through loading the relcache entry. Moreover, whether or notyou trust the reasoning behind sometimes using less thanAccessExclusiveLock for ALTER TABLE, that reasoning is certainly notvalid if concurrent users of the table don't hold a lock correspondingto the operation they want to perform.Hence, add some assertion-build-only checks that require any callerof relation_open(x, NoLock) to hold at least AccessShareLock. Thisisn't a full solution, since we can't verify that the lock level issemantically appropriate for the action --- but it's definitely ofsome use, because it's already caught two bugs.We can also assert that callers of addRangeTableEntryForRelation()hold at least the lock level specified for the new RTE.Amit Langote and Tom LaneDiscussion:https://postgr.es/m/16565.1538327894@sss.pgh.pa.us1 parentb66827c commitb04aeb0
File tree
7 files changed
+95
-3
lines changed- src
- backend
- access/heap
- parser
- storage/lmgr
- include/storage
7 files changed
+95
-3
lines changedLines changed: 14 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1137 | 1137 |
| |
1138 | 1138 |
| |
1139 | 1139 |
| |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
1140 | 1148 |
| |
1141 | 1149 |
| |
1142 | 1150 |
| |
| |||
1183 | 1191 |
| |
1184 | 1192 |
| |
1185 | 1193 |
| |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
1186 | 1198 |
| |
1187 | 1199 |
| |
1188 | 1200 |
| |
| |||
8084 | 8096 |
| |
8085 | 8097 |
| |
8086 | 8098 |
| |
| 8099 | + | |
| 8100 | + | |
8087 | 8101 |
| |
8088 | 8102 |
| |
8089 | 8103 |
| |
|
Lines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
28 | 28 |
| |
29 | 29 |
| |
30 | 30 |
| |
| 31 | + | |
31 | 32 |
| |
32 | 33 |
| |
33 | 34 |
| |
| |||
1272 | 1273 |
| |
1273 | 1274 |
| |
1274 | 1275 |
| |
1275 |
| - | |
| 1276 | + | |
1276 | 1277 |
| |
1277 | 1278 |
| |
1278 | 1279 |
| |
| |||
1295 | 1296 |
| |
1296 | 1297 |
| |
1297 | 1298 |
| |
| 1299 | + | |
1298 | 1300 |
| |
1299 | 1301 |
| |
1300 | 1302 |
| |
|
Lines changed: 45 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
287 | 287 |
| |
288 | 288 |
| |
289 | 289 |
| |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
290 | 335 |
| |
291 | 336 |
| |
292 | 337 |
| |
|
Lines changed: 24 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
563 | 563 |
| |
564 | 564 |
| |
565 | 565 |
| |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
566 | 590 |
| |
567 | 591 |
| |
568 | 592 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
45 | 45 |
| |
46 | 46 |
| |
47 | 47 |
| |
| 48 | + | |
| 49 | + | |
48 | 50 |
| |
49 | 51 |
| |
50 | 52 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
540 | 540 |
| |
541 | 541 |
| |
542 | 542 |
| |
| 543 | + | |
543 | 544 |
| |
544 | 545 |
| |
545 | 546 |
| |
|
Lines changed: 6 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
45 | 45 |
| |
46 | 46 |
| |
47 | 47 |
| |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
48 | 52 |
| |
49 | 53 |
| |
50 | 54 |
| |
51 |
| - | |
52 |
| - | |
| 55 | + | |
| 56 | + | |
53 | 57 |
| |
54 | 58 |
| |
55 | 59 |
|
0 commit comments
Comments
(0)