forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit3dbb317
committed
Fix potential assertion failure when reindexing a pg_class index.
When reindexing individual indexes on pg_class it was possible toeither trigger an assertion failure:TRAP: FailedAssertion("!(!ReindexIsProcessingIndex(((index)->rd_id)))That's because reindex_index() called SetReindexProcessing() - whichenables an asserts ensuring no index insertions happen into the index- before calling RelationSetNewRelfilenode(). That not correct forindexes on pg_class, because RelationSetNewRelfilenode() updates therelevant pg_class row, which needs to update the indexes.The are two reasons this wasn't noticed earlier. Firstly the bugdoesn't trigger when reindexing all of pg_class, as reindex_relationhas code "hiding" all yet-to-be-reindexed indexes. Secondly, the bugonly triggers when the the update to pg_class doesn't turn out to be aHOT update - otherwise there's no index insertion to trigger thebug. Most of the time there's enough space, making this bug hard totrigger.To fix, move RelationSetNewRelfilenode() to before theSetReindexProcessing() (and, together with some other code, to outsideof the PG_TRY()).To make sure the error checking intended by SetReindexProcessing() ismore robust, modify CatalogIndexInsert() to checkReindexIsProcessingIndex() even when the update is a HOT update.Also add a few regression tests for REINDEXing of system catalogs.The last two improvements would have prevented some of the issuesfixed in5c15606 from being introduced in the first place.Reported-By: Michael PaquierDiagnosed-By: Tom Lane and Andres FreundAuthor: Andres FreundReviewed-By: Tom LaneDiscussion:https://postgr.es/m/20190418011430.GA19133@paquier.xyzBackpatch: 9.4-, the bug is present in all branches1 parent5c15606 commit3dbb317
File tree
6 files changed
+90
-19
lines changed- contrib/test_decoding
- expected
- sql
- src
- backend/catalog
- test/regress
- expected
- sql
6 files changed
+90
-19
lines changedLines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
103 | 103 |
| |
104 | 104 |
| |
105 | 105 |
| |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
106 | 110 |
| |
107 | 111 |
| |
108 | 112 |
| |
|
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
74 | 74 |
| |
75 | 75 |
| |
76 | 76 |
| |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
77 | 82 |
| |
78 | 83 |
| |
79 | 84 |
| |
|
Lines changed: 23 additions & 17 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3316 | 3316 |
| |
3317 | 3317 |
| |
3318 | 3318 |
| |
| 3319 | + | |
| 3320 | + | |
| 3321 | + | |
| 3322 | + | |
| 3323 | + | |
| 3324 | + | |
| 3325 | + | |
| 3326 | + | |
| 3327 | + | |
| 3328 | + | |
| 3329 | + | |
| 3330 | + | |
| 3331 | + | |
| 3332 | + | |
| 3333 | + | |
| 3334 | + | |
| 3335 | + | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
3319 | 3342 |
| |
3320 | 3343 |
| |
3321 | 3344 |
| |
3322 | 3345 |
| |
3323 | 3346 |
| |
3324 |
| - | |
3325 |
| - | |
3326 |
| - | |
3327 |
| - | |
3328 |
| - | |
3329 |
| - | |
3330 |
| - | |
3331 |
| - | |
3332 |
| - | |
3333 |
| - | |
3334 |
| - | |
3335 |
| - | |
3336 |
| - | |
3337 |
| - | |
3338 |
| - | |
3339 |
| - | |
3340 |
| - | |
3341 | 3347 |
| |
3342 | 3348 |
| |
3343 | 3349 |
| |
|
Lines changed: 19 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
82 | 82 |
| |
83 | 83 |
| |
84 | 84 |
| |
85 |
| - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
86 | 91 |
| |
87 | 92 |
| |
| 93 | + | |
88 | 94 |
| |
89 | 95 |
| |
90 | 96 |
| |
| |||
107 | 113 |
| |
108 | 114 |
| |
109 | 115 |
| |
| 116 | + | |
110 | 117 |
| |
111 | 118 |
| |
| 119 | + | |
112 | 120 |
| |
113 | 121 |
| |
114 | 122 |
| |
| |||
121 | 129 |
| |
122 | 130 |
| |
123 | 131 |
| |
124 |
| - | |
| 132 | + | |
125 | 133 |
| |
126 | 134 |
| |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
127 | 144 |
| |
128 | 145 |
| |
129 | 146 |
| |
|
Lines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1939 | 1939 |
| |
1940 | 1940 |
| |
1941 | 1941 |
| |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
1942 | 1960 |
| |
1943 | 1961 |
| |
1944 | 1962 |
| |
|
Lines changed: 21 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
747 | 747 |
| |
748 | 748 |
| |
749 | 749 |
| |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
750 | 771 |
| |
751 | 772 |
| |
752 | 773 |
| |
|
0 commit comments
Comments
(0)