timescale / timescaledb

An open-source time-series SQL database optimized for fast ingest and complex queries. Packaged as a PostgreSQL extension.
https://www.timescale.com/
Other
16.8k stars 852 forks source link

Fix scankey where consttype is different from var #7055

Closed nikkhils closed 1 week ago

nikkhils commented 1 week ago

When we decide to use an indexscan on the segment-by column for any query for decompression, then it's possible that the RHS constant type is not the same as the variable on the LHS of the comparison.

A typical example is "int8 = int4" comparison. While this works ok on 64 bit instances, it can crash on i386 ones. The issue is in the scankey that we build for segment-by columns. Even though we specify the valid "opcode" for cases where the arguments types don't match we also need to specify the "sk_subtype" appropriately.

Fixes #7039

nikkhils commented 1 week ago

Looks like you forgot to add the actual code change

Yup. I wanted to verify that the i386 test fails with this test addition. It does! 💯

nikkhils commented 1 week ago

I assume you did this to verify that the test reproduces the crash and that you will add the fix in another commit later?

heh. Both of you did the review so fast!

Actual fix added now. Please check @erimatnor @svenklemm

svenklemm commented 1 week ago

Does this not affect batch decompression in a similar way? @akuzm

akuzm commented 1 week ago

Does this not affect batch decompression in a similar way? @akuzm

Which part exactly? If you're thinking about cross-type operators in vectorized filters, these should work fine.

codecov[bot] commented 1 week ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 81.77%. Comparing base (59f50f2) to head (cea495e). Report is 221 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #7055 +/- ## ========================================== + Coverage 80.06% 81.77% +1.71% ========================================== Files 190 200 +10 Lines 37181 37243 +62 Branches 9450 9705 +255 ========================================== + Hits 29770 30457 +687 + Misses 2997 2883 -114 + Partials 4414 3903 -511 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

timescale-automation commented 1 week ago

Automated backport to 2.15.x not done: cherry-pick failed.

Git status

HEAD detached at origin/2.15.x
You are currently cherry-picking commit 271053692.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
    new file:   .unreleased/fix_7055
    modified:   tsl/test/expected/compression.out
    modified:   tsl/test/sql/compression.sql

Unmerged paths:
  (use "git add <file>..." to mark resolution)
    both modified:   tsl/src/compression/compression.c

Job log