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

Segfault when executing IMMUTABLE functions #4493

Merged
merged 1 commit into from Jul 5, 2022

Conversation

fabriziomello
Copy link
Contributor

@fabriziomello fabriziomello commented Jul 5, 2022

Executing an IMMUTABLE function that has parameters and exception
handling block multiple times in the same transaction causes a null
pointer segfault when try to reset a non-initialized ts_baserel_info.

Fixed it by preventing to reset a non-initialized ts_baserel_info.

Fixes #4489

@codecov
Copy link

codecov bot commented Jul 5, 2022

Codecov Report

Merging #4493 (68e33d7) into main (0b76a8e) will decrease coverage by 0.01%.
The diff coverage is 95.83%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4493      +/-   ##
==========================================
- Coverage   90.79%   90.77%   -0.02%     
==========================================
  Files         221      222       +1     
  Lines       41003    41084      +81     
==========================================
+ Hits        37228    37296      +68     
- Misses       3775     3788      +13     
Impacted Files Coverage Δ
src/chunk.h 100.00% <ø> (ø)
tsl/src/chunk_copy.c 93.40% <92.85%> (+0.50%) ⬆️
src/telemetry/replication.c 93.75% <93.75%> (ø)
src/chunk.c 94.59% <95.23%> (+0.14%) ⬆️
src/nodes/chunk_insert_state.c 97.62% <100.00%> (ø)
src/planner/planner.c 95.24% <100.00%> (ø)
src/telemetry/telemetry.c 83.06% <100.00%> (+0.74%) ⬆️
tsl/src/compression/api.c 95.70% <100.00%> (+0.15%) ⬆️
src/bgw/scheduler.c 82.89% <0.00%> (-3.54%) ⬇️
src/bgw/job.c 93.14% <0.00%> (-0.29%) ⬇️
... and 4 more

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 a608d7d...68e33d7. Read the comment docs.

@fabriziomello fabriziomello force-pushed the issue/4489 branch 2 times, most recently from bfc4542 to 6ef1e67 Compare July 5, 2022 14:58
@fabriziomello fabriziomello changed the title Draft PR Exception when executing IMMUTABLE functions Jul 5, 2022
@fabriziomello fabriziomello self-assigned this Jul 5, 2022
@fabriziomello fabriziomello added bug segfault Segmentation fault labels Jul 5, 2022
@fabriziomello fabriziomello changed the title Exception when executing IMMUTABLE functions Segfault when executing IMMUTABLE functions Jul 5, 2022
@fabriziomello fabriziomello added this to the TimescaleDB 2.7.1 milestone Jul 5, 2022
@fabriziomello fabriziomello marked this pull request as ready for review July 5, 2022 15:01
@fabriziomello fabriziomello requested a review from a team as a code owner July 5, 2022 15:01
@fabriziomello fabriziomello requested review from RafiaSabih and akuzm and removed request for a team July 5, 2022 15:01
@fabriziomello fabriziomello enabled auto-merge (rebase) July 5, 2022 15:03
Copy link
Contributor

@mkindahl mkindahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Executing an IMMUTABLE function that has parameters and exception
handling block multiple times in the same transaction causes a null
pointer segfault when try to reset a non-initialized ts_baserel_info.

Fixed it by preventing to reset a non-initialized `ts_baserel_info`.

Fixes timescale#4489
@fabriziomello fabriziomello merged commit 335f298 into timescale:main Jul 5, 2022
@mkindahl mkindahl mentioned this pull request Jul 5, 2022
mkindahl added a commit that referenced this pull request Jul 7, 2022
This release is a patch release. We recommend that you upgrade at the
next available opportunity.

**Bugfixes**
* #4494 Handle timescaledb versions aptly in multinode
* #4493 Segfault when executing IMMUTABLE functions
* #4482 Fix race conditions during chunk (de)compression
* #4367 Improved buffer management in the copy operator
* #4375 Don't ask for orderby column if default already set
* #4400 Use our implementation of `find_em_expr_for_rel` for PG15+
* #4408 Fix crash during insert into distributed hypertable
* #4411 Add `shmem_request_hook`
* #4437 Fix segfault in subscription_exec
* #4442 Fix perms in copy/move chunk
* #4450 Retain hypertable ownership on `attach_data_node`
* #4451 Repair numeric partial state on the fly
* #4463 Fix empty bytea handlng with distributed tables
* #4469 Better superuser handling for `move_chunk`

**Features**
* #4244 Function telemetry
* #4287 Add internal api for foreign table chunk
* #4470 Block drop chunk if chunk is in frozen state
* #4464 Add internal api to associate a hypertable with custom jobs

**Thanks**
* @xin-hedera Finding bug in empty bytea values for distributed tables
* @jflambert for reporting a bug with IMMUTABLE functions
* @nikugogoi for reporting a bug with CTEs and upserts on distributed hypertables
mkindahl added a commit that referenced this pull request Jul 7, 2022
This release is a patch release. We recommend that you upgrade at the
next available opportunity.

**Bugfixes**
* #4494 Handle timescaledb versions aptly in multinode
* #4493 Segfault when executing IMMUTABLE functions
* #4482 Fix race conditions during chunk (de)compression
* #4367 Improved buffer management in the copy operator
* #4375 Don't ask for orderby column if default already set
* #4400 Use our implementation of `find_em_expr_for_rel` for PG15+
* #4408 Fix crash during insert into distributed hypertable
* #4411 Add `shmem_request_hook`
* #4437 Fix segfault in subscription_exec
* #4442 Fix perms in copy/move chunk
* #4450 Retain hypertable ownership on `attach_data_node`
* #4451 Repair numeric partial state on the fly
* #4463 Fix empty bytea handlng with distributed tables
* #4469 Better superuser handling for `move_chunk`

**Features**
* #4244 Function telemetry
* #4287 Add internal api for foreign table chunk
* #4470 Block drop chunk if chunk is in frozen state
* #4464 Add internal api to associate a hypertable with custom jobs

**Thanks**
* @xin-hedera Finding bug in empty bytea values for distributed tables
* @jflambert for reporting a bug with IMMUTABLE functions
* @nikugogoi for reporting a bug with CTEs and upserts on distributed hypertables
mkindahl added a commit that referenced this pull request Jul 7, 2022
This release is a patch release. We recommend that you upgrade at the
next available opportunity.

**Bugfixes**
* #4494 Handle timescaledb versions aptly in multinode
* #4493 Segfault when executing IMMUTABLE functions
* #4482 Fix race conditions during chunk (de)compression
* #4367 Improved buffer management in the copy operator
* #4375 Don't ask for orderby column if default already set
* #4400 Use our implementation of `find_em_expr_for_rel` for PG15+
* #4408 Fix crash during insert into distributed hypertable
* #4411 Add `shmem_request_hook`
* #4437 Fix segfault in subscription_exec
* #4442 Fix perms in copy/move chunk
* #4450 Retain hypertable ownership on `attach_data_node`
* #4451 Repair numeric partial state on the fly
* #4463 Fix empty bytea handlng with distributed tables
* #4469 Better superuser handling for `move_chunk`

**Features**
* #4244 Function telemetry
* #4287 Add internal api for foreign table chunk
* #4470 Block drop chunk if chunk is in frozen state
* #4464 Add internal api to associate a hypertable with custom jobs

**Thanks**
* @xin-hedera Finding bug in empty bytea values for distributed tables
* @jflambert for reporting a bug with IMMUTABLE functions
* @nikugogoi for reporting a bug with CTEs and upserts on distributed hypertables
mkindahl added a commit that referenced this pull request Jul 7, 2022
This release is a patch release. We recommend that you upgrade at the
next available opportunity.

**Bugfixes**
* #4494 Handle timescaledb versions aptly in multinode
* #4493 Segfault when executing IMMUTABLE functions
* #4482 Fix race conditions during chunk (de)compression
* #4367 Improved buffer management in the copy operator
* #4375 Don't ask for orderby column if default already set
* #4400 Use our implementation of `find_em_expr_for_rel` for PG15+
* #4408 Fix crash during insert into distributed hypertable
* #4411 Add `shmem_request_hook`
* #4437 Fix segfault in subscription_exec
* #4442 Fix perms in copy/move chunk
* #4450 Retain hypertable ownership on `attach_data_node`
* #4451 Repair numeric partial state on the fly
* #4463 Fix empty bytea handlng with distributed tables
* #4469 Better superuser handling for `move_chunk`

**Features**
* #4244 Function telemetry
* #4287 Add internal api for foreign table chunk
* #4470 Block drop chunk if chunk is in frozen state
* #4464 Add internal api to associate a hypertable with custom jobs

**Thanks**
* @xin-hedera Finding bug in empty bytea values for distributed tables
* @jflambert for reporting a bug with IMMUTABLE functions
* @nikugogoi for reporting a bug with CTEs and upserts on distributed hypertables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: 2.7.0 crashes when executing multiple IMMUTABLE functions (2.6.0 was fine)
4 participants