forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6f3820f
committed
Fix race condition in TupleDescCompactAttr assert code
5983a4c added CompactAttribute as an abbreviated alternative toFormData_pg_attribute to allow more cache-friendly processing in tasksrelated to TupleDescs. That commit contained some assert-only code tocheck that the CompactAttribute had been populated correctly, however,the method used to do that checking caused the TupleDesc'sCompactAttribute to be zeroed before it was repopulated and compared tothe snapshot taken before the memset call. This caused issues as the typecache caches TupleDescs in shared memory which can be used by multiplebackend processes at the same time. There was a window of time betweenthe zero and repopulation of the CompactAttribute where another processwould mistakenly think that the CompactAttribute is invalid due to thememset.To fix this, instead of taking a snapshot of the CompactAttribute andcalling populate_compact_attribute() and comparing the snapshot to thefreshly populated TupleDesc's CompactAttribute, refactor things so wecan just populate a temporary CompactAttribute on the stack. This waywe don't touch the TupleDesc's memory.Reported-by: Alexander Lakhin, SQLsmithDiscussion:https://postgr.es/m/ca3a256a-5d12-42db-aabe-a75a030d9fb9@gmail.com1 parent38da053 commit6f3820f
2 files changed
+69
-31
lines changedLines changed: 62 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
57 | 57 |
| |
58 | 58 |
| |
59 | 59 |
| |
60 |
| - | |
61 |
| - | |
62 |
| - | |
63 |
| - | |
| 60 | + | |
| 61 | + | |
64 | 62 |
| |
65 |
| - | |
66 |
| - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
67 | 66 |
| |
68 |
| - | |
69 |
| - | |
70 |
| - | |
71 | 67 |
| |
72 | 68 |
| |
73 | 69 |
| |
| |||
101 | 97 |
| |
102 | 98 |
| |
103 | 99 |
| |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
104 | 157 |
| |
105 | 158 |
| |
106 | 159 |
| |
|
Lines changed: 7 additions & 22 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
158 | 158 |
| |
159 | 159 |
| |
160 | 160 |
| |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
161 | 165 |
| |
162 | 166 |
| |
163 | 167 |
| |
164 | 168 |
| |
165 | 169 |
| |
166 | 170 |
| |
167 | 171 |
| |
168 |
| - | |
169 |
| - | |
170 | 172 |
| |
171 |
| - | |
172 |
| - | |
173 |
| - | |
174 |
| - | |
175 |
| - | |
176 |
| - | |
177 |
| - | |
178 |
| - | |
179 |
| - | |
180 |
| - | |
181 |
| - | |
182 |
| - | |
183 |
| - | |
184 |
| - | |
185 |
| - | |
186 |
| - | |
187 |
| - | |
188 |
| - | |
| 173 | + | |
189 | 174 |
| |
190 |
| - | |
191 |
| - | |
| 175 | + | |
| 176 | + | |
192 | 177 |
| |
193 | 178 |
| |
194 | 179 |
| |
|
0 commit comments
Comments
(0)