forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit7b6ec86
committed
Fix risk of deadlock failure while dropping a partitioned index.
DROP INDEX needs to lock the index's table before the index itself,else it will deadlock against ordinary queries that acquire therelation locks in that order. This is correctly mechanized forplain indexes by RangeVarCallbackForDropRelation; but in the case ofa partitioned index, we neglected to lock the child tables in advanceof locking the child indexes. We can fix that by traversing theinheritance tree and acquiring the needed locks in RemoveRelations,after we have acquired our locks on the parent partitioned table andindex.While at it, do some refactoring to eliminate confusion betweenthe actual and expected relkind in RangeVarCallbackForDropRelation.We can save a couple of syscache lookups too, by having that functionpass back info that RemoveRelations will need.Back-patch to v11 where partitioned indexes were added.Jimmy Yih, Gaurab Dey, Tom LaneDiscussion:https://postgr.es/m/BYAPR05MB645402330042E17D91A70C12BD5F9@BYAPR05MB6454.namprd05.prod.outlook.com1 parent1f8bc44 commit7b6ec86
File tree
4 files changed
+191
-18
lines changed- src
- backend/commands
- test/isolation
- expected
- specs
4 files changed
+191
-18
lines changedLines changed: 43 additions & 18 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
295 | 295 |
| |
296 | 296 |
| |
297 | 297 |
| |
| 298 | + | |
298 | 299 |
| |
299 | 300 |
| |
300 |
| - | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
301 | 305 |
| |
302 | 306 |
| |
303 |
| - | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
304 | 310 |
| |
305 | 311 |
| |
306 | 312 |
| |
| |||
1416 | 1422 |
| |
1417 | 1423 |
| |
1418 | 1424 |
| |
1419 |
| - | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
1420 | 1429 |
| |
1421 | 1430 |
| |
1422 |
| - | |
| 1431 | + | |
1423 | 1432 |
| |
1424 | 1433 |
| |
1425 | 1434 |
| |
| |||
1433 | 1442 |
| |
1434 | 1443 |
| |
1435 | 1444 |
| |
1436 |
| - | |
| 1445 | + | |
1437 | 1446 |
| |
1438 | 1447 |
| |
1439 |
| - | |
| 1448 | + | |
1440 | 1449 |
| |
1441 | 1450 |
| |
1442 | 1451 |
| |
| |||
1448 | 1457 |
| |
1449 | 1458 |
| |
1450 | 1459 |
| |
1451 |
| - | |
| 1460 | + | |
1452 | 1461 |
| |
1453 | 1462 |
| |
1454 | 1463 |
| |
1455 | 1464 |
| |
1456 | 1465 |
| |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
1457 | 1478 |
| |
1458 | 1479 |
| |
1459 | 1480 |
| |
| |||
1479 | 1500 |
| |
1480 | 1501 |
| |
1481 | 1502 |
| |
1482 |
| - | |
1483 | 1503 |
| |
1484 | 1504 |
| |
1485 | 1505 |
| |
1486 | 1506 |
| |
1487 | 1507 |
| |
1488 | 1508 |
| |
1489 | 1509 |
| |
1490 |
| - | |
1491 |
| - | |
1492 |
| - | |
| 1510 | + | |
1493 | 1511 |
| |
1494 | 1512 |
| |
1495 | 1513 |
| |
| |||
1523 | 1541 |
| |
1524 | 1542 |
| |
1525 | 1543 |
| |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
1526 | 1548 |
| |
1527 | 1549 |
| |
1528 | 1550 |
| |
| |||
1538 | 1560 |
| |
1539 | 1561 |
| |
1540 | 1562 |
| |
1541 |
| - | |
1542 |
| - | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
1543 | 1566 |
| |
1544 | 1567 |
| |
1545 | 1568 |
| |
1546 | 1569 |
| |
1547 |
| - | |
| 1570 | + | |
| 1571 | + | |
1548 | 1572 |
| |
1549 | 1573 |
| |
1550 | 1574 |
| |
| |||
1553 | 1577 |
| |
1554 | 1578 |
| |
1555 | 1579 |
| |
1556 |
| - | |
| 1580 | + | |
1557 | 1581 |
| |
1558 | 1582 |
| |
1559 | 1583 |
| |
| |||
1589 | 1613 |
| |
1590 | 1614 |
| |
1591 | 1615 |
| |
1592 |
| - | |
| 1616 | + | |
| 1617 | + | |
1593 | 1618 |
| |
1594 |
| - | |
| 1619 | + | |
1595 | 1620 |
| |
1596 | 1621 |
| |
1597 | 1622 |
| |
| |||
1602 | 1627 |
| |
1603 | 1628 |
| |
1604 | 1629 |
| |
1605 |
| - | |
| 1630 | + | |
1606 | 1631 |
| |
1607 | 1632 |
| |
1608 | 1633 |
| |
|
Lines changed: 100 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 | + | |
| 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 | + |
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
90 | 90 |
| |
91 | 91 |
| |
92 | 92 |
| |
| 93 | + | |
93 | 94 |
| |
94 | 95 |
| |
95 | 96 |
| |
|
Lines changed: 47 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 | + |
0 commit comments
Comments
(0)