forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf99870d
committed
Fix corruption of toast indexes with REINDEX CONCURRENTLY
REINDEX CONCURRENTLY run on a toast index or a toast relation couldcorrupt the target indexes rebuilt, as a backend running in parallelthat manipulates toast values would directly release the lock on thetoast relation when its local operation is done, rather than releasingthe lock once the transaction that manipulated the toast valuescommitted.The fix done here is simple: we now hold a ROW EXCLUSIVE lock on thetoast relation when saving or deleting a toast value until thetransaction working on them is committed, so as a concurrent reindexhappening in parallel would be able to wait for any activity and see anynew rows inserted (or deleted).An isolation test is added to check after the case fixed here, which isa bit fancy by design as it relies on allow_system_table_mods to renamethe toast table and its index to fixed names. This way, it is possibleto reindex them directly without any dependency on the OID of theunderlying relation. Note that this could not use a DO block either, asREINDEX CONCURRENTLY cannot be run in a transaction block. The test isbackpatched down to 13, where it is possible, thanks toc4a7a39, to useallow_system_table_mods in a test suite.Reported-by: Alexey ErmakovAnalyzed-by: Andres Freund, Noah MischAuthor: Michael PaquierReviewed-by: Nathan BossartDiscussion:https://postgr.es/m/17268-d2fb426e0895abd4@postgresql.orgBackpatch-through: 121 parentedc2332 commitf99870d
File tree
4 files changed
+905
-6
lines changed- src
- backend/access/common
- test/isolation
- expected
- specs
4 files changed
+905
-6
lines changedLines changed: 10 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
359 | 359 |
| |
360 | 360 |
| |
361 | 361 |
| |
362 |
| - | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
363 | 365 |
| |
364 |
| - | |
365 |
| - | |
| 366 | + | |
| 367 | + | |
366 | 368 |
| |
367 | 369 |
| |
368 | 370 |
| |
| |||
439 | 441 |
| |
440 | 442 |
| |
441 | 443 |
| |
442 |
| - | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
443 | 447 |
| |
444 | 448 |
| |
445 |
| - | |
446 |
| - | |
| 449 | + | |
| 450 | + | |
447 | 451 |
| |
448 | 452 |
| |
449 | 453 |
| |
|
0 commit comments
Comments
(0)