- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit22655aa
committed
Fix bulk table extension when copying into multiple partitions
When COPYing into a partitioned table that does now permit the use oftable_multi_insert(), we could error out with ERROR: could not read block NN in file "base/...": read only 0 of 8192 bytesbecause BulkInsertState->next_free was not reset between partitions. Thisproblem occurred only when not able to use table_multi_insert(), as adedicated BulkInsertState for each partition is used in that case.The bug was introduced in00d1e02, but it was hard to hit at that point,as commonly bulk relation extension is not used when not usingtable_multi_insert(). It became more likely after82a4eda, which expandedthe use of bulk extension.To fix the bug, reset the bulk relation extension state in BulkInsertState inReleaseBulkInsertStatePin(). That was added (inb1ecb9b) to tackle a verysimilar issue. Obviously the name is not quite correct, but there might beexternal callers, and bulk insert state needs to be reset in precisely in thesituations that ReleaseBulkInsertStatePin() already needed to be called.Medium term the better fix likely is to disallow reusing BulkInsertStateacross relations.Add a test that, without the fix, reproduces #18130 in mostconfigurations. The test also catches the problem fixed inb1ecb9b whenrun with small shared_buffers.Reported-by: Ivan Kolombet <enderstd@gmail.com>Analyzed-by: Tom Lane <tgl@sss.pgh.pa.us>Analyzed-by: Andres Freund <andres@anarazel.de>Bug: #18130Discussion:https://postgr.es/m/18130-7a86a7356a75209d%40postgresql.orgDiscussion:https://postgr.es/m/257696.1695670946%40sss.pgh.pa.usBackpatch: 16-1 parent8d140c5 commit22655aa
3 files changed
+85
-0
lines changedLines changed: 11 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1792 | 1792 |
| |
1793 | 1793 |
| |
1794 | 1794 |
| |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
1795 | 1806 |
| |
1796 | 1807 |
| |
1797 | 1808 |
| |
|
Lines changed: 37 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
257 | 257 |
| |
258 | 258 |
| |
259 | 259 |
| |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + |
Lines changed: 37 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
283 | 283 |
| |
284 | 284 |
| |
285 | 285 |
| |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + |
0 commit comments
Comments
(0)