Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed two bugs in decompression sorted merge code #5774

Merged
merged 1 commit into from Jun 12, 2023

Conversation

jnidzwetzki
Copy link
Member

@jnidzwetzki jnidzwetzki commented Jun 12, 2023

SQLSmith found two bugs in the compression sorted merge code.

  • The unused_batch_states are not initialized properly. Therefore, non-existing unused batch states can be part of the BMS. This patch fixes the initialization.

  • For performance reasons, We reuse the same TupleDesc across all TupleTableSlots. PostgreSQL sometimes uses TupleDesc data structures with active reference counting. The way we use the TupleDesc structures collides with the reference counting of PostgreSQL. This patch introduces a private TupleDesc copy without reference counting.

Link to failed SQLSmith run: https://github.com/timescale/timescaledb/actions/runs/5233117820/jobs/9448359165

@jnidzwetzki jnidzwetzki changed the title Fix two bugs in decompression sorted merge code Fixed two bugs in decompression sorted merge code Jun 12, 2023
SQLSmith found two bugs in the compression sorted merge code.

* The unused_batch_states are not initialized properly. Therefore,
  non-existing unused batch states can be part of the BMS. This patch
  fixes the initialization.

* For performance reasons, We reuse the same TupleDesc across all
  TupleTableSlots. PostgreSQL sometimes uses TupleDesc data structures
  with active reference counting. The way we use the TupleDesc
  structures collides with the reference counting of PostgreSQL. This
  patch introduces a private TupleDesc copy without reference counting.
@codecov
Copy link

codecov bot commented Jun 12, 2023

Codecov Report

Merging #5774 (48d8ce1) into main (4dce87a) will increase coverage by 7.47%.
The diff coverage is 91.30%.

@@            Coverage Diff             @@
##             main    #5774      +/-   ##
==========================================
+ Coverage   80.39%   87.86%   +7.47%     
==========================================
  Files         239      239              
  Lines       48760    55478    +6718     
  Branches    12220    12287      +67     
==========================================
+ Hits        39199    48745    +9546     
- Misses       4187     4837     +650     
+ Partials     5374     1896    -3478     
Impacted Files Coverage Δ
tsl/src/nodes/decompress_chunk/exec.c 92.94% <91.30%> (+11.74%) ⬆️

... and 222 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jnidzwetzki jnidzwetzki marked this pull request as ready for review June 12, 2023 15:26
@jnidzwetzki jnidzwetzki enabled auto-merge (rebase) June 12, 2023 18:14
@jnidzwetzki jnidzwetzki merged commit 9c7ae3e into timescale:main Jun 12, 2023
43 checks passed
@akuzm akuzm added the bug label Jul 18, 2023
@timescale-automation
Copy link

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

Git status

HEAD detached at origin/2.11.x
You are currently cherry-picking commit 9c7ae3e8a.
  (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/bugfix_5774
	modified:   tsl/src/nodes/decompress_chunk/exec.c
	modified:   tsl/test/expected/compression_sorted_merge-12.out
	modified:   tsl/test/expected/compression_sorted_merge-13.out
	modified:   tsl/test/expected/compression_sorted_merge-14.out
	modified:   tsl/test/expected/compression_sorted_merge-15.out
	modified:   tsl/test/sql/compression_sorted_merge.sql.in

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   tsl/src/nodes/decompress_chunk/exec.h


Job log

@timescale-automation timescale-automation added the auto-backport-not-done Automated backport of this PR has failed non-retriably (e.g. conflicts) label Jul 18, 2023
konskov added a commit to konskov/timescaledb that referenced this pull request Aug 9, 2023
This release contains bug fixes since the 2.11.0 release.
We recommend that you upgrade at the next available opportunity.

**Features**
* timescale#5909 CREATE INDEX ONLY ON hypertable creates index on chunks
* timescale#5923 Feature flags for TimescaleDB features
**Bugfixes**
* timescale#5680 Fix DISTINCT query with JOIN on multiple segmentby columns
* timescale#5774 Fixed two bugs in decompression sorted merge code
* timescale#5786 Ensure pg_config --cppflags are passed
* timescale#5906 Fix quoting owners in sql scripts.
* timescale#5912 Fix crash in 1-step integer policy creation
**Thanks**
* @mrksngl for submitting a PR to fix extension upgrade scripts
* @ericdevries for reporting an issue with DISTINCT queries using
segmentby columns of compressed hypertable
konskov added a commit to konskov/timescaledb that referenced this pull request Aug 9, 2023
This release contains bug fixes since the 2.11.1 release.
We recommend that you upgrade at the next available opportunity.

**Features**
* timescale#5909 CREATE INDEX ONLY ON hypertable creates index on chunks
* timescale#5923 Feature flags for TimescaleDB features
**Bugfixes**
* timescale#5680 Fix DISTINCT query with JOIN on multiple segmentby columns
* timescale#5774 Fixed two bugs in decompression sorted merge code
* timescale#5786 Ensure pg_config --cppflags are passed
* timescale#5906 Fix quoting owners in sql scripts.
* timescale#5912 Fix crash in 1-step integer policy creation
**Thanks**
* @mrksngl for submitting a PR to fix extension upgrade scripts
* @ericdevries for reporting an issue with DISTINCT queries using
segmentby columns of compressed hypertable
@konskov konskov mentioned this pull request Aug 9, 2023
konskov added a commit to konskov/timescaledb that referenced this pull request Aug 9, 2023
This release contains bug fixes since the 2.11.1 release.
We recommend that you upgrade at the next available opportunity.

**Features**
* timescale#5909 CREATE INDEX ONLY ON hypertable creates index on chunks
* timescale#5923 Feature flags for TimescaleDB features

**Bugfixes**
* timescale#5680 Fix DISTINCT query with JOIN on multiple segmentby columns
* timescale#5774 Fixed two bugs in decompression sorted merge code
* timescale#5786 Ensure pg_config --cppflags are passed
* timescale#5906 Fix quoting owners in sql scripts.
* timescale#5912 Fix crash in 1-step integer policy creation

**Thanks**
* @mrksngl for submitting a PR to fix extension upgrade scripts
* @ericdevries for reporting an issue with DISTINCT queries using
segmentby columns of compressed hypertable
konskov added a commit to konskov/timescaledb that referenced this pull request Aug 9, 2023
This release contains bug fixes since the 2.11.1 release.
We recommend that you upgrade at the next available opportunity.

**Features**
* timescale#5909 CREATE INDEX ONLY ON hypertable creates index on chunks
* timescale#5923 Feature flags for TimescaleDB features

**Bugfixes**
* timescale#5680 Fix DISTINCT query with JOIN on multiple segmentby columns
* timescale#5774 Fixed two bugs in decompression sorted merge code
* timescale#5786 Ensure pg_config --cppflags are passed
* timescale#5906 Fix quoting owners in sql scripts.
* timescale#5912 Fix crash in 1-step integer policy creation

**Thanks**
* @mrksngl for submitting a PR to fix extension upgrade scripts
* @ericdevries for reporting an issue with DISTINCT queries using
segmentby columns of compressed hypertable
konskov added a commit to konskov/timescaledb that referenced this pull request Aug 9, 2023
This release contains bug fixes since the 2.11.1 release.
We recommend that you upgrade at the next available opportunity.

**Features**
* timescale#5909 CREATE INDEX ONLY ON hypertable creates index on chunks
* timescale#5923 Feature flags for TimescaleDB features

**Bugfixes**
* timescale#5680 Fix DISTINCT query with JOIN on multiple segmentby columns
* timescale#5774 Fixed two bugs in decompression sorted merge code
* timescale#5786 Ensure pg_config --cppflags are passed
* timescale#5906 Fix quoting owners in sql scripts.
* timescale#5912 Fix crash in 1-step integer policy creation

**Thanks**
* @mrksngl for submitting a PR to fix extension upgrade scripts
* @ericdevries for reporting an issue with DISTINCT queries using
segmentby columns of compressed hypertable
konskov added a commit to konskov/timescaledb that referenced this pull request Aug 9, 2023
This release contains bug fixes since the 2.11.1 release.
We recommend that you upgrade at the next available opportunity.

**Features**
* timescale#5909 CREATE INDEX ONLY ON hypertable creates index on chunks
* timescale#5923 Feature flags for TimescaleDB features

**Bugfixes**
* timescale#5680 Fix DISTINCT query with JOIN on multiple segmentby columns
* timescale#5774 Fixed two bugs in decompression sorted merge code
* timescale#5786 Ensure pg_config --cppflags are passed
* timescale#5906 Fix quoting owners in sql scripts.
* timescale#5912 Fix crash in 1-step integer policy creation

**Thanks**
* @mrksngl for submitting a PR to fix extension upgrade scripts
* @ericdevries for reporting an issue with DISTINCT queries using
segmentby columns of compressed hypertable
konskov added a commit to konskov/timescaledb that referenced this pull request Aug 9, 2023
This release contains bug fixes since the 2.11.1 release.
We recommend that you upgrade at the next available opportunity.

**Features**
* timescale#5923 Feature flags for TimescaleDB features

**Bugfixes**
* timescale#5680 Fix DISTINCT query with JOIN on multiple segmentby columns
* timescale#5774 Fixed two bugs in decompression sorted merge code
* timescale#5786 Ensure pg_config --cppflags are passed
* timescale#5906 Fix quoting owners in sql scripts.
* timescale#5912 Fix crash in 1-step integer policy creation

**Thanks**
* @mrksngl for submitting a PR to fix extension upgrade scripts
* @ericdevries for reporting an issue with DISTINCT queries using
segmentby columns of compressed hypertable
konskov added a commit to konskov/timescaledb that referenced this pull request Aug 9, 2023
This release contains bug fixes since the 2.11.1 release.
We recommend that you upgrade at the next available opportunity.

**Features**
* timescale#5923 Feature flags for TimescaleDB features

**Bugfixes**
* timescale#5680 Fix DISTINCT query with JOIN on multiple segmentby columns
* timescale#5774 Fixed two bugs in decompression sorted merge code
* timescale#5786 Ensure pg_config --cppflags are passed
* timescale#5906 Fix quoting owners in sql scripts.
* timescale#5912 Fix crash in 1-step integer policy creation

**Thanks**
* @mrksngl for submitting a PR to fix extension upgrade scripts
* @ericdevries for reporting an issue with DISTINCT queries using
segmentby columns of compressed hypertable
konskov added a commit that referenced this pull request Aug 9, 2023
This release contains bug fixes since the 2.11.1 release.
We recommend that you upgrade at the next available opportunity.

**Features**
* #5923 Feature flags for TimescaleDB features

**Bugfixes**
* #5680 Fix DISTINCT query with JOIN on multiple segmentby columns
* #5774 Fixed two bugs in decompression sorted merge code
* #5786 Ensure pg_config --cppflags are passed
* #5906 Fix quoting owners in sql scripts.
* #5912 Fix crash in 1-step integer policy creation

**Thanks**
* @mrksngl for submitting a PR to fix extension upgrade scripts
* @ericdevries for reporting an issue with DISTINCT queries using
segmentby columns of compressed hypertable
konskov added a commit to konskov/timescaledb that referenced this pull request Aug 10, 2023
This release contains bug fixes since the 2.11.1 release.
We recommend that you upgrade at the next available opportunity.

**Features**
* timescale#5923 Feature flags for TimescaleDB features

**Bugfixes**
* timescale#5680 Fix DISTINCT query with JOIN on multiple segmentby columns
* timescale#5774 Fixed two bugs in decompression sorted merge code
* timescale#5786 Ensure pg_config --cppflags are passed
* timescale#5906 Fix quoting owners in sql scripts.
* timescale#5912 Fix crash in 1-step integer policy creation

**Thanks**
* @mrksngl for submitting a PR to fix extension upgrade scripts
* @ericdevries for reporting an issue with DISTINCT queries using
segmentby columns of compressed hypertable
konskov added a commit to konskov/timescaledb that referenced this pull request Aug 10, 2023
This release contains bug fixes since the 2.11.1 release.
We recommend that you upgrade at the next available opportunity.

**Features**
* timescale#5923 Feature flags for TimescaleDB features

**Bugfixes**
* timescale#5680 Fix DISTINCT query with JOIN on multiple segmentby columns
* timescale#5774 Fixed two bugs in decompression sorted merge code
* timescale#5786 Ensure pg_config --cppflags are passed
* timescale#5906 Fix quoting owners in sql scripts.
* timescale#5912 Fix crash in 1-step integer policy creation

**Thanks**
* @mrksngl for submitting a PR to fix extension upgrade scripts
* @ericdevries for reporting an issue with DISTINCT queries using
segmentby columns of compressed hypertable
konskov added a commit that referenced this pull request Aug 10, 2023
This release contains bug fixes since the 2.11.1 release.
We recommend that you upgrade at the next available opportunity.

**Features**
* #5923 Feature flags for TimescaleDB features

**Bugfixes**
* #5680 Fix DISTINCT query with JOIN on multiple segmentby columns
* #5774 Fixed two bugs in decompression sorted merge code
* #5786 Ensure pg_config --cppflags are passed
* #5906 Fix quoting owners in sql scripts.
* #5912 Fix crash in 1-step integer policy creation

**Thanks**
* @mrksngl for submitting a PR to fix extension upgrade scripts
* @ericdevries for reporting an issue with DISTINCT queries using
segmentby columns of compressed hypertable
svenklemm pushed a commit that referenced this pull request Aug 15, 2023
This release contains bug fixes since the 2.11.1 release.
We recommend that you upgrade at the next available opportunity.

**Features**
* #5923 Feature flags for TimescaleDB features

**Bugfixes**
* #5680 Fix DISTINCT query with JOIN on multiple segmentby columns
* #5774 Fixed two bugs in decompression sorted merge code
* #5786 Ensure pg_config --cppflags are passed
* #5906 Fix quoting owners in sql scripts.
* #5912 Fix crash in 1-step integer policy creation

**Thanks**
* @mrksngl for submitting a PR to fix extension upgrade scripts
* @ericdevries for reporting an issue with DISTINCT queries using
segmentby columns of compressed hypertable
konskov added a commit that referenced this pull request Aug 16, 2023
This release contains bug fixes since the 2.11.1 release.
We recommend that you upgrade at the next available opportunity.

**Features**
* #5923 Feature flags for TimescaleDB features

**Bugfixes**
* #5680 Fix DISTINCT query with JOIN on multiple segmentby columns
* #5774 Fixed two bugs in decompression sorted merge code
* #5786 Ensure pg_config --cppflags are passed
* #5906 Fix quoting owners in sql scripts.
* #5912 Fix crash in 1-step integer policy creation

**Thanks**
* @mrksngl for submitting a PR to fix extension upgrade scripts
* @ericdevries for reporting an issue with DISTINCT queries using
segmentby columns of compressed hypertable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport-not-done Automated backport of this PR has failed non-retriably (e.g. conflicts) backported-2.11.x bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants