Commit 3fc73a3
committed
fix(tables): rename the column last so a failed write leaves it untouched
Greptile's remaining concern: the pre-flight guards read a schema snapshot, so
a column-type change landing concurrently can still make a later write fail —
and with the rename running first, that failure returned an error with the
rename already committed.
Guards cannot close that window; each write is its own locked transaction and
only the write itself sees the authoritative state. Ordering can. The rename is
the one write that is purely cosmetic, so it now runs last: a failed typed
write leaves the column entirely untouched, and a failed rename leaves the
typed change applied under the old name — the recoverable half. The typed
writes target the column's current name, since no rename has happened yet.
Tests cover both directions: a typed write rejected mid-flight must not rename,
and a successful one must rename strictly after. Verified to fail under the
previous ordering.1 parent 522cc62 commit 3fc73a3
3 files changed
Lines changed: 72 additions & 39 deletions
File tree
- apps/sim/app/api
- table/[tableId]/columns
- v1/tables/[tableId]/columns
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
114 | 136 | | |
115 | 137 | | |
116 | 138 | | |
| |||
130 | 152 | | |
131 | 153 | | |
132 | 154 | | |
133 | | - | |
| 155 | + | |
134 | 156 | | |
135 | 157 | | |
136 | 158 | | |
| |||
145 | 167 | | |
146 | 168 | | |
147 | 169 | | |
148 | | - | |
149 | | - | |
150 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
151 | 173 | | |
152 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
153 | 178 | | |
154 | 179 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
140 | 138 | | |
141 | 139 | | |
142 | 140 | | |
| |||
166 | 164 | | |
167 | 165 | | |
168 | 166 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | 167 | | |
177 | 168 | | |
178 | 169 | | |
179 | 170 | | |
180 | | - | |
| 171 | + | |
181 | 172 | | |
182 | 173 | | |
183 | 174 | | |
| |||
195 | 186 | | |
196 | 187 | | |
197 | 188 | | |
198 | | - | |
| 189 | + | |
199 | 190 | | |
200 | 191 | | |
201 | 192 | | |
| |||
204 | 195 | | |
205 | 196 | | |
206 | 197 | | |
207 | | - | |
| 198 | + | |
208 | 199 | | |
209 | 200 | | |
210 | 201 | | |
| |||
219 | 210 | | |
220 | 211 | | |
221 | 212 | | |
222 | | - | |
| 213 | + | |
223 | 214 | | |
224 | 215 | | |
225 | 216 | | |
226 | 217 | | |
227 | 218 | | |
228 | 219 | | |
229 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
230 | 234 | | |
231 | 235 | | |
232 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
174 | 172 | | |
175 | 173 | | |
176 | 174 | | |
| |||
200 | 198 | | |
201 | 199 | | |
202 | 200 | | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | 201 | | |
211 | 202 | | |
212 | 203 | | |
213 | 204 | | |
214 | | - | |
| 205 | + | |
215 | 206 | | |
216 | 207 | | |
217 | 208 | | |
| |||
229 | 220 | | |
230 | 221 | | |
231 | 222 | | |
232 | | - | |
| 223 | + | |
233 | 224 | | |
234 | 225 | | |
235 | 226 | | |
| |||
238 | 229 | | |
239 | 230 | | |
240 | 231 | | |
241 | | - | |
| 232 | + | |
242 | 233 | | |
243 | 234 | | |
244 | 235 | | |
| |||
253 | 244 | | |
254 | 245 | | |
255 | 246 | | |
256 | | - | |
| 247 | + | |
257 | 248 | | |
258 | 249 | | |
259 | 250 | | |
260 | 251 | | |
261 | 252 | | |
262 | 253 | | |
263 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
264 | 268 | | |
265 | 269 | | |
266 | 270 | | |
| |||
0 commit comments