- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit2225168
committed
Detect internal GiST page splits correctly during index build.
As we descend the GiST tree during insertion, we modify any downlinks onthe way down to include the new tuple we're about to insert (if they don'tcover it already). Modifying an existing downlink might cause an internalpage to split, if the new downlink tuple is larger than the old one. Ifthat happens, we need to back up to the parent and re-choose a page toinsert to. We used to detect that situation, thanks to the NSN-LSNinterlock normally used to detect concurrent page splits, but that gotbroken by commit9155580. With that commit, we now use a dummy constantLSN value for every page during index build, so the LSN-NSN interlock nolonger works. I thought that was OK because there can't be any otherbackends modifying the index during index build, but missed that theinsertion itself can modify the page we're inserting to. The consequencewas that we would sometimes insert the new tuple to an incorrect page, onewhose downlink doesn't cover the new tuple.To fix, add a flag to the stack that keeps track of the state whiledescending tree, to indicate that a page was split, and that we need toretry the descend from the parent.Thomas Munro first reported that the contrib/intarray regression test wasfailing occasionally on the buildfarm after commit9155580. The failurewas intermittent, because the gistchoose() function is not deterministic,and would only occasionally create the right circumstances for this bug tocause the failure.Patch by Anastasia Lubennikova, with some changes by me to make it workcorrectly also when the internal page split also causes the "grandparent"to be split.Discussion:https://www.postgresql.org/message-id/CA%2BhUKGJRzLo7tZExWfSbwM3XuK7aAK7FhdBV0FLkbUG%2BW0v0zg%40mail.gmail.com1 parente95d550 commit2225168
2 files changed
+40
-0
lines changedLines changed: 33 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
639 | 639 |
| |
640 | 640 |
| |
641 | 641 |
| |
| 642 | + | |
642 | 643 |
| |
643 | 644 |
| |
644 | 645 |
| |
| |||
651 | 652 |
| |
652 | 653 |
| |
653 | 654 |
| |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
654 | 670 |
| |
655 | 671 |
| |
656 | 672 |
| |
| |||
1376 | 1392 |
| |
1377 | 1393 |
| |
1378 | 1394 |
| |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
1379 | 1412 |
| |
1380 | 1413 |
| |
1381 | 1414 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
215 | 215 |
| |
216 | 216 |
| |
217 | 217 |
| |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
218 | 225 |
| |
219 | 226 |
| |
220 | 227 |
| |
|
0 commit comments
Comments
(0)