forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0bef1c0
committed
Re-think predicate locking on GIN indexes.
The principle behind the locking was not very well thought-out, and notdocumented. Add a section in the README to explain how it's supposed towork, and change the code so that it actually works that way.This fixes two bugs:1. If fast update was turned on concurrently, subsequent inserts to the pending list would not conflict with predicate locks that were acquired earlier, on entry pages. The included 'predicate-gin-fastupdate' test demonstrates that. To fix, make all scans acquire a predicate lock on the metapage. That lock represents a scan of the pending list, whether or not there is a pending list at the moment. Forget about the optimization to skip locking/checking for locks, when fastupdate=off.2. If a scan finds no match, it still needs to lock the entry page. The point of predicate locks is to lock the gabs between values, whether or not there is a match. The included 'predicate-gin-nomatch' test tests that case.In addition to those two bug fixes, this removes some unnecessary locking,following the principle laid out in the README. Because all items ina posting tree have the same key value, a lock on the posting tree root isenough to cover all the items. (With a very large posting tree, it wouldpossibly be better to lock the posting tree leaf pages instead, so that a"skip scan" with a query like "A & B", you could avoid unnecessary conflictif a new tuple is inserted with A but !B. But let's keep this simple.)Also, some spelling fixes.Author: Heikki Linnakangas with some editorization by meReview: Andrey Borodin, Alexander KorotkovDiscussion:https://www.postgresql.org/message-id/0b3ad2c2-2692-62a9-3a04-5724f2af9114@iki.fi1 parent7d86799 commit0bef1c0
File tree
18 files changed
+251
-117
lines changed- src
- backend
- access
- gin
- gist
- storage/lmgr
- include/access
- test/isolation
- expected
- specs
18 files changed
+251
-117
lines changedLines changed: 34 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
331 | 331 |
| |
332 | 332 |
| |
333 | 333 |
| |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
334 | 368 |
| |
335 | 369 |
| |
336 | 370 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
84 | 84 |
| |
85 | 85 |
| |
86 | 86 |
| |
| 87 | + | |
| 88 | + | |
| 89 | + | |
87 | 90 |
| |
88 | 91 |
| |
89 | 92 |
| |
|
Lines changed: 3 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1812 | 1812 |
| |
1813 | 1813 |
| |
1814 | 1814 |
| |
1815 |
| - | |
1816 |
| - | |
| 1815 | + | |
| 1816 | + | |
1817 | 1817 |
| |
1818 | 1818 |
| |
1819 | 1819 |
| |
| |||
1864 | 1864 |
| |
1865 | 1865 |
| |
1866 | 1866 |
| |
1867 |
| - | |
| 1867 | + | |
1868 | 1868 |
| |
1869 | 1869 |
| |
1870 | 1870 |
| |
| |||
1911 | 1911 |
| |
1912 | 1912 |
| |
1913 | 1913 |
| |
1914 |
| - | |
1915 | 1914 |
| |
1916 | 1915 |
| |
1917 | 1916 |
| |
|
Lines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
31 | 31 |
| |
32 | 32 |
| |
33 | 33 |
| |
| 34 | + | |
34 | 35 |
| |
35 | 36 |
| |
36 | 37 |
| |
| |||
245 | 246 |
| |
246 | 247 |
| |
247 | 248 |
| |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
248 | 256 |
| |
249 | 257 |
| |
250 | 258 |
| |
|
Lines changed: 54 additions & 62 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
35 | 35 |
| |
36 | 36 |
| |
37 | 37 |
| |
38 |
| - | |
39 |
| - | |
40 |
| - | |
41 |
| - | |
42 |
| - | |
43 |
| - | |
44 |
| - | |
45 |
| - | |
46 |
| - | |
47 |
| - | |
48 |
| - | |
49 |
| - | |
50 |
| - | |
51 |
| - | |
52 | 38 |
| |
53 | 39 |
| |
54 | 40 |
| |
| |||
68 | 54 |
| |
69 | 55 |
| |
70 | 56 |
| |
71 |
| - | |
| 57 | + | |
72 | 58 |
| |
73 | 59 |
| |
74 | 60 |
| |
| |||
100 | 86 |
| |
101 | 87 |
| |
102 | 88 |
| |
103 |
| - | |
104 |
| - | |
105 |
| - | |
106 |
| - | |
107 |
| - | |
108 | 89 |
| |
109 | 90 |
| |
110 | 91 |
| |
| |||
158 | 139 |
| |
159 | 140 |
| |
160 | 141 |
| |
161 |
| - | |
| 142 | + | |
162 | 143 |
| |
163 | 144 |
| |
164 | 145 |
| |
| |||
253 | 234 |
| |
254 | 235 |
| |
255 | 236 |
| |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
256 | 244 |
| |
257 | 245 |
| |
258 | 246 |
| |
| |||
400 | 388 |
| |
401 | 389 |
| |
402 | 390 |
| |
403 |
| - | |
404 |
| - | |
405 |
| - | |
406 |
| - | |
407 | 391 |
| |
408 | 392 |
| |
409 | 393 |
| |
410 | 394 |
| |
411 | 395 |
| |
412 | 396 |
| |
413 | 397 |
| |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
414 | 405 |
| |
415 | 406 |
| |
416 | 407 |
| |
| |||
425 | 416 |
| |
426 | 417 |
| |
427 | 418 |
| |
428 |
| - | |
429 |
| - | |
430 |
| - | |
431 |
| - | |
432 |
| - | |
433 |
| - | |
434 | 419 |
| |
435 | 420 |
| |
436 | 421 |
| |
| |||
452 | 437 |
| |
453 | 438 |
| |
454 | 439 |
| |
455 |
| - | |
| 440 | + | |
456 | 441 |
| |
457 |
| - | |
458 |
| - | |
459 |
| - | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
460 | 458 |
| |
461 |
| - | |
| 459 | + | |
| 460 | + | |
462 | 461 |
| |
463 | 462 |
| |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
464 | 472 |
| |
465 | 473 |
| |
466 | 474 |
| |
| |||
533 | 541 |
| |
534 | 542 |
| |
535 | 543 |
| |
536 |
| - | |
| 544 | + | |
537 | 545 |
| |
538 | 546 |
| |
539 | 547 |
| |
| |||
673 | 681 |
| |
674 | 682 |
| |
675 | 683 |
| |
676 |
| - | |
677 |
| - | |
678 | 684 |
| |
679 | 685 |
| |
680 | 686 |
| |
| |||
719 | 725 |
| |
720 | 726 |
| |
721 | 727 |
| |
722 |
| - | |
723 |
| - | |
724 |
| - | |
725 |
| - | |
726 | 728 |
| |
727 | 729 |
| |
728 | 730 |
| |
| |||
1084 | 1086 |
| |
1085 | 1087 |
| |
1086 | 1088 |
| |
1087 |
| - | |
1088 |
| - | |
| 1089 | + | |
| 1090 | + | |
1089 | 1091 |
| |
1090 | 1092 |
| |
1091 | 1093 |
| |
| |||
1746 | 1748 |
| |
1747 | 1749 |
| |
1748 | 1750 |
| |
1749 |
| - | |
1750 |
| - | |
| 1751 | + | |
1751 | 1752 |
| |
1752 | 1753 |
| |
1753 | 1754 |
| |
| |||
1764 | 1765 |
| |
1765 | 1766 |
| |
1766 | 1767 |
| |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
1767 | 1774 |
| |
1768 | 1775 |
| |
1769 | 1776 |
| |
| |||
1777 | 1784 |
| |
1778 | 1785 |
| |
1779 | 1786 |
| |
1780 |
| - | |
1781 |
| - | |
1782 |
| - | |
1783 |
| - | |
1784 |
| - | |
1785 |
| - | |
1786 |
| - | |
1787 |
| - | |
1788 |
| - | |
1789 | 1787 |
| |
1790 | 1788 |
| |
1791 | 1789 |
| |
1792 |
| - | |
1793 |
| - | |
1794 |
| - | |
1795 |
| - | |
1796 |
| - | |
1797 |
| - | |
1798 | 1790 |
| |
1799 | 1791 |
| |
1800 | 1792 |
| |
|
Lines changed: 2 additions & 24 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
219 | 219 |
| |
220 | 220 |
| |
221 | 221 |
| |
222 |
| - | |
| 222 | + | |
223 | 223 |
| |
224 | 224 |
| |
225 | 225 |
| |
| |||
228 | 228 |
| |
229 | 229 |
| |
230 | 230 |
| |
231 |
| - | |
| 231 | + | |
232 | 232 |
| |
233 | 233 |
| |
234 | 234 |
| |
| |||
517 | 517 |
| |
518 | 518 |
| |
519 | 519 |
| |
520 |
| - | |
521 |
| - | |
522 |
| - | |
523 |
| - | |
524 |
| - | |
525 |
| - | |
526 |
| - | |
527 |
| - | |
528 |
| - | |
529 |
| - | |
530 |
| - | |
531 |
| - | |
532 | 520 |
| |
533 | 521 |
| |
534 | 522 |
| |
| |||
539 | 527 |
| |
540 | 528 |
| |
541 | 529 |
| |
542 |
| - | |
543 |
| - | |
544 |
| - | |
545 |
| - | |
546 |
| - | |
547 |
| - | |
548 |
| - | |
549 |
| - | |
550 |
| - | |
551 |
| - | |
552 | 530 |
| |
553 | 531 |
| |
554 | 532 |
| |
|
0 commit comments
Comments
(0)