Backport to 2.15.x: #6931: Do not decompress batches for COPY with potentially invalid slot #6946
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an automated backport of #6931: Do not decompress batches for COPY with potentially invalid slot.
The original issue is #6540.
This PR will be merged automatically after all the relevant CI checks pass. If this fix should not be backported, or will be backported manually, just close this PR. You can use the backport branch to add your changes, it won't be modified automatically anymore.
For more details, please see the documentation
Original description
Do not decompress batches for COPY with potentially invalid slot
We don't have to decompress anything more when we re-lookup the chunk insert state on COPY buffer flush. Moreover,
ChunkInsertState.slots[0]
is incorrect slot type fordecompress_batches_for_insert()
, because it is a chunk slot, not a hypertable slot. This can lead to rare errors when the chunk insert states go out of cache.Just don't do this unnecessary lookup, and move decompression to a separate function for clarity. Add an assertion and test that detect the slot type mismatch on main.
There was a related fix that improved the situation for empty copy buffers, but not for wrong slot type #6117
Fixes #6540