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

Fix chunk exclusion for space partitions in SELECT FOR UPDATE queries #4685

Merged
merged 2 commits into from Sep 11, 2022

Conversation

svenklemm
Copy link
Member

@svenklemm svenklemm commented Sep 9, 2022

Since we do not use our own hypertable expansion for SELECT FOR UPDATE
queries we need to make sure to add the extra information necessary to
get hashed space partitions with the native postgres inheritance
expansion working.

Fixes #4683

Disable-check: commit-count

@codecov
Copy link

codecov bot commented Sep 9, 2022

Codecov Report

Merging #4685 (59a7629) into main (6de9795) will decrease coverage by 0.03%.
The diff coverage is 82.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4685      +/-   ##
==========================================
- Coverage   90.85%   90.82%   -0.04%     
==========================================
  Files         224      224              
  Lines       42326    42344      +18     
==========================================
+ Hits        38455    38457       +2     
- Misses       3871     3887      +16     
Impacted Files Coverage Δ
src/planner/space_constraint.c 93.87% <81.81%> (-2.28%) ⬇️
src/planner/planner.c 95.59% <100.00%> (+<0.01%) ⬆️
src/bgw/scheduler.c 83.62% <0.00%> (-2.93%) ⬇️
tsl/src/nodes/data_node_dispatch.c 96.49% <0.00%> (-0.24%) ⬇️
src/bgw/job.c 94.58% <0.00%> (-0.23%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6de9795...59a7629. Read the comment docs.

Since we do not use our own hypertable expansion for SELECT FOR UPDATE
queries we need to make sure to add the extra information necessary to
get hashed space partitions with the native postgres inheritance
expansion working.
This patch adjusts the operator logic for valid space dimension
constraints to no longer look for an exact match on both sides
of the operator but instead allow mismatched datatypes.

Previously a constraint like `col = value` would require `col`
and `value` to have matching datatype with this change `col` and
`value` can be different datatype as long as they have equality
operator in btree family.

Mismatching datatype can happen commonly when using int8 columns
and comparing them with integer literals. Integer literals default
to int4 so the datatypes would not match unless special care has
been taken in writing the constraints and therefore the optimization
would never apply in those cases.
@svenklemm svenklemm merged commit a26a597 into timescale:main Sep 11, 2022
@jnidzwetzki jnidzwetzki mentioned this pull request Oct 5, 2022
jnidzwetzki added a commit to jnidzwetzki/timescaledb that referenced this pull request Oct 5, 2022
This release is a patch release. We recommend that you upgrade at the
next available opportunity.

**Bugfixes**
* timescale#4454 Keep locks after reading job status
* timescale#4658 Fix error when querying a compressed hypertable with compress_segmentby on an enum column
* timescale#4671 Fix a possible error while flushing the COPY data
* timescale#4675 Fix bad TupleTableSlot drop
* timescale#4676 Fix a deadlock when decompressing chunks and performing SELECTs
* timescale#4685 Fix chunk exclusion for space partitions in SELECT FOR UPDATE queries
* timescale#4694 Change parameter names of cagg_migrate procedure
* timescale#4698 Do not use row-by-row fetcher for parameterized plans
* timescale#4711 Remove support for procedures as custom checks
* timescale#4712 Fix assertion failure in constify_now
* timescale#4713 Fix Continuous Aggregate migration policies
* timescale#4720 Fix chunk exclusion for prepared statements and dst changes
* timescale#4726 Fix gapfill function signature
* timescale#4737 Fix join on time column of compressed chunk
* timescale#4738 Fix error when waiting for remote COPY to finish
* timescale#4739 Fix continuous aggregate migrate check constraint
* timescale#4760 Fix segfault when INNER JOINing hypertables
* timescale#4767 Fix permission issues on index creation for CAggs

**Thanks**
* @boxhock and @cocowalla for reporting a segfault when JOINing hypertables
* @carobme for reporting constraint error during continuous aggregate migration
* @choisnetm, @dustinsorensen, @jayadevanm and @joeyberkovitz for reporting a problem with JOINs on compressed hypertables
* @daniel-k for reporting a background worker crash
* @justinpryzby for reporting an error when compressing very wide tables
* @maxtwardowski for reporting problems with chunk exclusion and space partitions
* @yuezhihan for reporting GROUP BY error when having compress_segmentby on an enum column
jnidzwetzki added a commit to jnidzwetzki/timescaledb that referenced this pull request Oct 5, 2022
This release is a patch release. We recommend that you upgrade at the
next available opportunity.

**Bugfixes**
* timescale#4454 Keep locks after reading job status
* timescale#4658 Fix error when querying a compressed hypertable with compress_segmentby on an enum column
* timescale#4671 Fix a possible error while flushing the COPY data
* timescale#4675 Fix bad TupleTableSlot drop
* timescale#4676 Fix a deadlock when decompressing chunks and performing SELECTs
* timescale#4685 Fix chunk exclusion for space partitions in SELECT FOR UPDATE queries
* timescale#4694 Change parameter names of cagg_migrate procedure
* timescale#4698 Do not use row-by-row fetcher for parameterized plans
* timescale#4711 Remove support for procedures as custom checks
* timescale#4712 Fix assertion failure in constify_now
* timescale#4713 Fix Continuous Aggregate migration policies
* timescale#4720 Fix chunk exclusion for prepared statements and dst changes
* timescale#4726 Fix gapfill function signature
* timescale#4737 Fix join on time column of compressed chunk
* timescale#4738 Fix error when waiting for remote COPY to finish
* timescale#4739 Fix continuous aggregate migrate check constraint
* timescale#4760 Fix segfault when INNER JOINing hypertables
* timescale#4767 Fix permission issues on index creation for CAggs

**Thanks**
* @boxhock and @cocowalla for reporting a segfault when JOINing hypertables
* @carobme for reporting constraint error during continuous aggregate migration
* @choisnetm, @dustinsorensen, @jayadevanm and @joeyberkovitz for reporting a problem with JOINs on compressed hypertables
* @daniel-k for reporting a background worker crash
* @justinpryzby for reporting an error when compressing very wide tables
* @maxtwardowski for reporting problems with chunk exclusion and space partitions
* @yuezhihan for reporting GROUP BY error when having compress_segmentby on an enum column
jnidzwetzki added a commit to jnidzwetzki/timescaledb that referenced this pull request Oct 5, 2022
This release is a patch release. We recommend that you upgrade at the
next available opportunity.

**Bugfixes**
* timescale#4454 Keep locks after reading job status
* timescale#4658 Fix error when querying a compressed hypertable with compress_segmentby on an enum column
* timescale#4671 Fix a possible error while flushing the COPY data
* timescale#4675 Fix bad TupleTableSlot drop
* timescale#4676 Fix a deadlock when decompressing chunks and performing SELECTs
* timescale#4685 Fix chunk exclusion for space partitions in SELECT FOR UPDATE queries
* timescale#4694 Change parameter names of cagg_migrate procedure
* timescale#4698 Do not use row-by-row fetcher for parameterized plans
* timescale#4711 Remove support for procedures as custom checks
* timescale#4712 Fix assertion failure in constify_now
* timescale#4713 Fix Continuous Aggregate migration policies
* timescale#4720 Fix chunk exclusion for prepared statements and dst changes
* timescale#4726 Fix gapfill function signature
* timescale#4737 Fix join on time column of compressed chunk
* timescale#4738 Fix error when waiting for remote COPY to finish
* timescale#4739 Fix continuous aggregate migrate check constraint
* timescale#4760 Fix segfault when INNER JOINing hypertables
* timescale#4767 Fix permission issues on index creation for CAggs

**Thanks**
* @boxhock and @cocowalla for reporting a segfault when JOINing hypertables
* @carobme for reporting constraint error during continuous aggregate migration
* @choisnetm, @dustinsorensen, @jayadevanm and @joeyberkovitz for reporting a problem with JOINs on compressed hypertables
* @daniel-k for reporting a background worker crash
* @justinpryzby for reporting an error when compressing very wide tables
* @maxtwardowski for reporting problems with chunk exclusion and space partitions
* @yuezhihan for reporting GROUP BY error when having compress_segmentby on an enum column
jnidzwetzki added a commit to jnidzwetzki/timescaledb that referenced this pull request Oct 5, 2022
This release is a patch release. We recommend that you upgrade at the
next available opportunity.

**Bugfixes**
* timescale#4454 Keep locks after reading job status
* timescale#4658 Fix error when querying a compressed hypertable with compress_segmentby on an enum column
* timescale#4671 Fix a possible error while flushing the COPY data
* timescale#4675 Fix bad TupleTableSlot drop
* timescale#4676 Fix a deadlock when decompressing chunks and performing SELECTs
* timescale#4685 Fix chunk exclusion for space partitions in SELECT FOR UPDATE queries
* timescale#4694 Change parameter names of cagg_migrate procedure
* timescale#4698 Do not use row-by-row fetcher for parameterized plans
* timescale#4711 Remove support for procedures as custom checks
* timescale#4712 Fix assertion failure in constify_now
* timescale#4713 Fix Continuous Aggregate migration policies
* timescale#4720 Fix chunk exclusion for prepared statements and dst changes
* timescale#4726 Fix gapfill function signature
* timescale#4737 Fix join on time column of compressed chunk
* timescale#4738 Fix error when waiting for remote COPY to finish
* timescale#4739 Fix continuous aggregate migrate check constraint
* timescale#4760 Fix segfault when INNER JOINing hypertables
* timescale#4767 Fix permission issues on index creation for CAggs

**Thanks**
* @boxhock and @cocowalla for reporting a segfault when JOINing hypertables
* @carobme for reporting constraint error during continuous aggregate migration
* @choisnetm, @dustinsorensen, @jayadevanm and @joeyberkovitz for reporting a problem with JOINs on compressed hypertables
* @daniel-k for reporting a background worker crash
* @justinpryzby for reporting an error when compressing very wide tables
* @maxtwardowski for reporting problems with chunk exclusion and space partitions
* @yuezhihan for reporting GROUP BY error when having compress_segmentby on an enum column
jnidzwetzki added a commit to jnidzwetzki/timescaledb that referenced this pull request Oct 5, 2022
This release is a patch release. We recommend that you upgrade at the
next available opportunity.

**Bugfixes**
* timescale#4454 Keep locks after reading job status
* timescale#4658 Fix error when querying a compressed hypertable with compress_segmentby on an enum column
* timescale#4671 Fix a possible error while flushing the COPY data
* timescale#4675 Fix bad TupleTableSlot drop
* timescale#4676 Fix a deadlock when decompressing chunks and performing SELECTs
* timescale#4685 Fix chunk exclusion for space partitions in SELECT FOR UPDATE queries
* timescale#4694 Change parameter names of cagg_migrate procedure
* timescale#4698 Do not use row-by-row fetcher for parameterized plans
* timescale#4711 Remove support for procedures as custom checks
* timescale#4712 Fix assertion failure in constify_now
* timescale#4713 Fix Continuous Aggregate migration policies
* timescale#4720 Fix chunk exclusion for prepared statements and dst changes
* timescale#4726 Fix gapfill function signature
* timescale#4737 Fix join on time column of compressed chunk
* timescale#4738 Fix error when waiting for remote COPY to finish
* timescale#4739 Fix continuous aggregate migrate check constraint
* timescale#4760 Fix segfault when INNER JOINing hypertables
* timescale#4767 Fix permission issues on index creation for CAggs

**Thanks**
* @boxhock and @cocowalla for reporting a segfault when JOINing hypertables
* @carobme for reporting constraint error during continuous aggregate migration
* @choisnetm, @dustinsorensen, @jayadevanm and @joeyberkovitz for reporting a problem with JOINs on compressed hypertables
* @daniel-k for reporting a background worker crash
* @justinpryzby for reporting an error when compressing very wide tables
* @maxtwardowski for reporting problems with chunk exclusion and space partitions
* @yuezhihan for reporting GROUP BY error when having compress_segmentby on an enum column
jnidzwetzki added a commit to jnidzwetzki/timescaledb that referenced this pull request Oct 5, 2022
This release is a patch release. We recommend that you upgrade at the
next available opportunity.

**Bugfixes**
* timescale#4454 Keep locks after reading job status
* timescale#4658 Fix error when querying a compressed hypertable with compress_segmentby on an enum column
* timescale#4671 Fix a possible error while flushing the COPY data
* timescale#4675 Fix bad TupleTableSlot drop
* timescale#4676 Fix a deadlock when decompressing chunks and performing SELECTs
* timescale#4685 Fix chunk exclusion for space partitions in SELECT FOR UPDATE queries
* timescale#4694 Change parameter names of cagg_migrate procedure
* timescale#4698 Do not use row-by-row fetcher for parameterized plans
* timescale#4711 Remove support for procedures as custom checks
* timescale#4712 Fix assertion failure in constify_now
* timescale#4713 Fix Continuous Aggregate migration policies
* timescale#4720 Fix chunk exclusion for prepared statements and dst changes
* timescale#4726 Fix gapfill function signature
* timescale#4737 Fix join on time column of compressed chunk
* timescale#4738 Fix error when waiting for remote COPY to finish
* timescale#4739 Fix continuous aggregate migrate check constraint
* timescale#4760 Fix segfault when INNER JOINing hypertables
* timescale#4767 Fix permission issues on index creation for CAggs

**Thanks**
* @boxhock and @cocowalla for reporting a segfault when JOINing hypertables
* @carobme for reporting constraint error during continuous aggregate migration
* @choisnetm, @dustinsorensen, @jayadevanm and @joeyberkovitz for reporting a problem with JOINs on compressed hypertables
* @daniel-k for reporting a background worker crash
* @justinpryzby for reporting an error when compressing very wide tables
* @maxtwardowski for reporting problems with chunk exclusion and space partitions
* @yuezhihan for reporting GROUP BY error when having compress_segmentby on an enum column
jnidzwetzki added a commit to jnidzwetzki/timescaledb that referenced this pull request Oct 5, 2022
This release is a patch release. We recommend that you upgrade at the
next available opportunity.

**Bugfixes**
* timescale#4454 Keep locks after reading job status
* timescale#4658 Fix error when querying a compressed hypertable with compress_segmentby on an enum column
* timescale#4671 Fix a possible error while flushing the COPY data
* timescale#4675 Fix bad TupleTableSlot drop
* timescale#4676 Fix a deadlock when decompressing chunks and performing SELECTs
* timescale#4685 Fix chunk exclusion for space partitions in SELECT FOR UPDATE queries
* timescale#4694 Change parameter names of cagg_migrate procedure
* timescale#4698 Do not use row-by-row fetcher for parameterized plans
* timescale#4711 Remove support for procedures as custom checks
* timescale#4712 Fix assertion failure in constify_now
* timescale#4713 Fix Continuous Aggregate migration policies
* timescale#4720 Fix chunk exclusion for prepared statements and dst changes
* timescale#4726 Fix gapfill function signature
* timescale#4737 Fix join on time column of compressed chunk
* timescale#4738 Fix error when waiting for remote COPY to finish
* timescale#4739 Fix continuous aggregate migrate check constraint
* timescale#4760 Fix segfault when INNER JOINing hypertables
* timescale#4767 Fix permission issues on index creation for CAggs

**Thanks**
* @boxhock and @cocowalla for reporting a segfault when JOINing hypertables
* @carobme for reporting constraint error during continuous aggregate migration
* @choisnetm, @dustinsorensen, @jayadevanm and @joeyberkovitz for reporting a problem with JOINs on compressed hypertables
* @daniel-k for reporting a background worker crash
* @justinpryzby for reporting an error when compressing very wide tables
* @maxtwardowski for reporting problems with chunk exclusion and space partitions
* @yuezhihan for reporting GROUP BY error when having compress_segmentby on an enum column
jnidzwetzki added a commit to jnidzwetzki/timescaledb that referenced this pull request Oct 5, 2022
This release is a patch release. We recommend that you upgrade at the
next available opportunity.

**Bugfixes**
* timescale#4454 Keep locks after reading job status
* timescale#4658 Fix error when querying a compressed hypertable with compress_segmentby on an enum column
* timescale#4671 Fix a possible error while flushing the COPY data
* timescale#4675 Fix bad TupleTableSlot drop
* timescale#4676 Fix a deadlock when decompressing chunks and performing SELECTs
* timescale#4685 Fix chunk exclusion for space partitions in SELECT FOR UPDATE queries
* timescale#4694 Change parameter names of cagg_migrate procedure
* timescale#4698 Do not use row-by-row fetcher for parameterized plans
* timescale#4711 Remove support for procedures as custom checks
* timescale#4712 Fix assertion failure in constify_now
* timescale#4713 Fix Continuous Aggregate migration policies
* timescale#4720 Fix chunk exclusion for prepared statements and dst changes
* timescale#4726 Fix gapfill function signature
* timescale#4737 Fix join on time column of compressed chunk
* timescale#4738 Fix error when waiting for remote COPY to finish
* timescale#4739 Fix continuous aggregate migrate check constraint
* timescale#4760 Fix segfault when INNER JOINing hypertables
* timescale#4767 Fix permission issues on index creation for CAggs

**Thanks**
* @boxhock and @cocowalla for reporting a segfault when JOINing hypertables
* @carobme for reporting constraint error during continuous aggregate migration
* @choisnetm, @dustinsorensen, @jayadevanm and @joeyberkovitz for reporting a problem with JOINs on compressed hypertables
* @daniel-k for reporting a background worker crash
* @justinpryzby for reporting an error when compressing very wide tables
* @maxtwardowski for reporting problems with chunk exclusion and space partitions
* @yuezhihan for reporting GROUP BY error when having compress_segmentby on an enum column
jnidzwetzki added a commit that referenced this pull request Oct 5, 2022
This release is a patch release. We recommend that you upgrade at the
next available opportunity.

**Bugfixes**
* #4454 Keep locks after reading job status
* #4658 Fix error when querying a compressed hypertable with compress_segmentby on an enum column
* #4671 Fix a possible error while flushing the COPY data
* #4675 Fix bad TupleTableSlot drop
* #4676 Fix a deadlock when decompressing chunks and performing SELECTs
* #4685 Fix chunk exclusion for space partitions in SELECT FOR UPDATE queries
* #4694 Change parameter names of cagg_migrate procedure
* #4698 Do not use row-by-row fetcher for parameterized plans
* #4711 Remove support for procedures as custom checks
* #4712 Fix assertion failure in constify_now
* #4713 Fix Continuous Aggregate migration policies
* #4720 Fix chunk exclusion for prepared statements and dst changes
* #4726 Fix gapfill function signature
* #4737 Fix join on time column of compressed chunk
* #4738 Fix error when waiting for remote COPY to finish
* #4739 Fix continuous aggregate migrate check constraint
* #4760 Fix segfault when INNER JOINing hypertables
* #4767 Fix permission issues on index creation for CAggs

**Thanks**
* @boxhock and @cocowalla for reporting a segfault when JOINing hypertables
* @carobme for reporting constraint error during continuous aggregate migration
* @choisnetm, @dustinsorensen, @jayadevanm and @joeyberkovitz for reporting a problem with JOINs on compressed hypertables
* @daniel-k for reporting a background worker crash
* @justinpryzby for reporting an error when compressing very wide tables
* @maxtwardowski for reporting problems with chunk exclusion and space partitions
* @yuezhihan for reporting GROUP BY error when having compress_segmentby on an enum column
jnidzwetzki added a commit that referenced this pull request Oct 6, 2022
This release is a patch release. We recommend that you upgrade at the
next available opportunity.

**Bugfixes**
* #4454 Keep locks after reading job status
* #4658 Fix error when querying a compressed hypertable with compress_segmentby on an enum column
* #4671 Fix a possible error while flushing the COPY data
* #4675 Fix bad TupleTableSlot drop
* #4676 Fix a deadlock when decompressing chunks and performing SELECTs
* #4685 Fix chunk exclusion for space partitions in SELECT FOR UPDATE queries
* #4694 Change parameter names of cagg_migrate procedure
* #4698 Do not use row-by-row fetcher for parameterized plans
* #4711 Remove support for procedures as custom checks
* #4712 Fix assertion failure in constify_now
* #4713 Fix Continuous Aggregate migration policies
* #4720 Fix chunk exclusion for prepared statements and dst changes
* #4726 Fix gapfill function signature
* #4737 Fix join on time column of compressed chunk
* #4738 Fix error when waiting for remote COPY to finish
* #4739 Fix continuous aggregate migrate check constraint
* #4760 Fix segfault when INNER JOINing hypertables
* #4767 Fix permission issues on index creation for CAggs

**Thanks**
* @boxhock and @cocowalla for reporting a segfault when JOINing hypertables
* @carobme for reporting constraint error during continuous aggregate migration
* @choisnetm, @dustinsorensen, @jayadevanm and @joeyberkovitz for reporting a problem with JOINs on compressed hypertables
* @daniel-k for reporting a background worker crash
* @justinpryzby for reporting an error when compressing very wide tables
* @maxtwardowski for reporting problems with chunk exclusion and space partitions
* @yuezhihan for reporting GROUP BY error when having compress_segmentby on an enum column
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: SELECT FOR UPDATE on a space-partitioned hypertable scans through all chunks
3 participants