- Notifications
You must be signed in to change notification settings - Fork28
Commitf69c959
committed
Do not decode TOAST data for table rewrites
During table rewrites (VACUUM FULL and CLUSTER), the main heap is loggedusing XLOG / FPI records, and thus (correctly) ignored in decoding.But the associated TOAST table is WAL-logged as plain INSERT records,and so was logically decoded and passed to reorder buffer.That has severe consequences with TOAST tables of non-trivial size.Firstly, reorder buffer has to keep all those changes, possibly spillingthem to a file, incurring I/O costs and disk space.Secondly, ReoderBufferCommit() was stashing all those TOAST chunks intoa hash table, which got discarded only after processing the row from themain heap. But as the main heap is not decoded for rewrites, this neverhappened, so all the TOAST data accumulated in memory, resulting eitherin excessive memory consumption or OOM.The fix is simple, as commite9edc1b already introduced infrastructure(namely HEAP_INSERT_NO_LOGICAL flag) to skip logical decoding of TOASTtables, but it only applied it to system tables. So simply use it forall TOAST data in raw_heap_insert().That would however solve only the memory consumption issue - the TOASTchanges would still be decoded and added to the reorder buffer, andspilled to disk (although without TOAST tuple data, so much smaller).But we can solve that by tweaking DecodeInsert() to just ignore suchINSERT records altogether, using XLH_INSERT_CONTAINS_NEW_TUPLE flag,instead of skipping them later in ReorderBufferCommit().Review: Masahiko SawadaDiscussion:https://www.postgresql.org/message-id/flat/1a17c643-e9af-3dba-486b-fbe31bc1823a%402ndquadrant.comBackpatch: 9.4-, where logical decoding was introduced1 parentd1ce4ed commitf69c959
File tree
3 files changed
+24
-24
lines changed- src/backend
- access/heap
- replication/logical
3 files changed
+24
-24
lines changedLines changed: 4 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
659 | 659 |
| |
660 | 660 |
| |
661 | 661 |
| |
662 |
| - | |
663 |
| - | |
664 |
| - | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
665 | 665 |
| |
666 |
| - | |
667 |
| - | |
| 666 | + | |
668 | 667 |
| |
669 | 668 |
| |
670 | 669 |
| |
|
Lines changed: 15 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
665 | 665 |
| |
666 | 666 |
| |
667 | 667 |
| |
| 668 | + | |
| 669 | + | |
| 670 | + | |
668 | 671 |
| |
669 | 672 |
| |
670 | 673 |
| |
671 | 674 |
| |
672 | 675 |
| |
673 | 676 |
| |
674 | 677 |
| |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
675 | 685 |
| |
676 | 686 |
| |
677 | 687 |
| |
| |||
690 | 700 |
| |
691 | 701 |
| |
692 | 702 |
| |
693 |
| - | |
694 |
| - | |
695 |
| - | |
696 |
| - | |
697 |
| - | |
| 703 | + | |
| 704 | + | |
698 | 705 |
| |
699 |
| - | |
700 |
| - | |
| 706 | + | |
| 707 | + | |
701 | 708 |
| |
702 |
| - | |
703 |
| - | |
| 709 | + | |
704 | 710 |
| |
705 | 711 |
| |
706 | 712 |
| |
|
Lines changed: 5 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1598 | 1598 |
| |
1599 | 1599 |
| |
1600 | 1600 |
| |
1601 |
| - | |
1602 |
| - | |
1603 |
| - | |
1604 |
| - | |
1605 | 1601 |
| |
1606 |
| - | |
1607 |
| - | |
1608 |
| - | |
1609 |
| - | |
1610 |
| - | |
1611 |
| - | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
1612 | 1607 |
| |
1613 | 1608 |
| |
1614 | 1609 |
| |
|
0 commit comments
Comments
(0)