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

Remove signal-unsafe calls from signal handlers #4199

Merged
merged 1 commit into from
Mar 30, 2022

Conversation

mkindahl
Copy link
Contributor

@mkindahl mkindahl commented Mar 29, 2022

Functions elog and ereport are unsafe to use in signal handlers
since they call malloc. This commit removes them from signal
handlers.

Fixes #4200

@mkindahl mkindahl force-pushed the fix-signal-handlers branch from 4b138c4 to 1d9f428 Compare March 29, 2022 16:26
@mkindahl mkindahl self-assigned this Mar 29, 2022
@codecov
Copy link

codecov bot commented Mar 29, 2022

Codecov Report

Merging #4199 (a9e5594) into main (347b45f) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4199   +/-   ##
=======================================
  Coverage   90.76%   90.76%           
=======================================
  Files         215      215           
  Lines       39494    39494           
=======================================
  Hits        35845    35845           
  Misses       3649     3649           
Impacted Files Coverage Δ
src/bgw/job.c 92.95% <100.00%> (+0.01%) ⬆️
src/bgw/scheduler.c 83.91% <100.00%> (ø)
src/loader/bgw_launcher.c 91.97% <100.00%> (ø)
tsl/src/bgw_policy/job.c 88.01% <0.00%> (-0.05%) ⬇️

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 347b45f...a9e5594. Read the comment docs.

@mkindahl mkindahl force-pushed the fix-signal-handlers branch from 1d9f428 to f47ad0b Compare March 29, 2022 17:03
@mkindahl mkindahl marked this pull request as ready for review March 30, 2022 06:57
@mkindahl mkindahl requested a review from a team as a code owner March 30, 2022 06:57
@mkindahl mkindahl requested review from nikkhils and akuzm and removed request for a team March 30, 2022 06:57
@mkindahl mkindahl force-pushed the fix-signal-handlers branch from f47ad0b to aa560e2 Compare March 30, 2022 07:03
Functions `elog` and `ereport` are unsafe to use in signal handlers
since they call `malloc`. This commit removes them from signal
handlers.

Fixes timescale#4200
@mkindahl mkindahl force-pushed the fix-signal-handlers branch from aa560e2 to a9e5594 Compare March 30, 2022 08:02
@mkindahl mkindahl merged commit 81b71b6 into timescale:main Mar 30, 2022
@mkindahl mkindahl deleted the fix-signal-handlers branch March 30, 2022 11:37
@mkindahl mkindahl added this to the TimescaleDB 2.6.1 milestone Apr 7, 2022
RafiaSabih added a commit to RafiaSabih/timescaledb that referenced this pull request Apr 8, 2022
This release is patch release. We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#4121 Fix RENAME TO/SET SCHEMA on distributed hypertable
* timescale#4122 Fix segfault on INSERT into distributed hypertable
* timescale#4142 Ignore invalid relid when deleting hypertable
* timescale#4159 Fix ADD COLUMN IF NOT EXISTS error on compressed hypertable
* timescale#4161 Fix memory handling during scans
* timescale#4176 Fix remote EXPLAIN with parameterized queries
* timescale#4181 Fix spelling errors and omissions
* timescale#4186 Fix owner change for distributed hypertable
* timescale#4192 Abort sessions after extension reload
* timescale#4193 Fix relcache callback handling causing crashes
* timescale#4199 Remove signal-unsafe calls from signal handlers
* timescale#4219 Do not modify aggregation state in finalize

**Thanks**
* @abrownsword for reporting a crash in the telemetry reporter
* @daydayup863 for reporting issue with remote explain
RafiaSabih added a commit to RafiaSabih/timescaledb that referenced this pull request Apr 11, 2022
This release is patch release. We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#4121 Fix RENAME TO/SET SCHEMA on distributed hypertable
* timescale#4122 Fix segfault on INSERT into distributed hypertable
* timescale#4142 Ignore invalid relid when deleting hypertable
* timescale#4159 Fix ADD COLUMN IF NOT EXISTS error on compressed hypertable
* timescale#4161 Fix memory handling during scans
* timescale#4176 Fix remote EXPLAIN with parameterized queries
* timescale#4181 Fix spelling errors and omissions
* timescale#4186 Fix owner change for distributed hypertable
* timescale#4192 Abort sessions after extension reload
* timescale#4193 Fix relcache callback handling causing crashes
* timescale#4199 Remove signal-unsafe calls from signal handlers
* timescale#4219 Do not modify aggregation state in finalize

**Thanks**
* @abrownsword for reporting a crash in the telemetry reporter
* @daydayup863 for reporting issue with remote explain
RafiaSabih added a commit to RafiaSabih/timescaledb that referenced this pull request Apr 11, 2022
This release is patch release. We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#4121 Fix RENAME TO/SET SCHEMA on distributed hypertable
* timescale#4122 Fix segfault on INSERT into distributed hypertable
* timescale#4142 Ignore invalid relid when deleting hypertable
* timescale#4159 Fix ADD COLUMN IF NOT EXISTS error on compressed hypertable
* timescale#4161 Fix memory handling during scans
* timescale#4176 Fix remote EXPLAIN with parameterized queries
* timescale#4181 Fix spelling errors and omissions
* timescale#4186 Fix owner change for distributed hypertable
* timescale#4192 Abort sessions after extension reload
* timescale#4193 Fix relcache callback handling causing crashes
* timescale#4199 Remove signal-unsafe calls from signal handlers
* timescale#4219 Do not modify aggregation state in finalize

**Thanks**
* @abrownsword for reporting a crash in the telemetry reporter
* @daydayup863 for reporting issue with remote explain
RafiaSabih added a commit to RafiaSabih/timescaledb that referenced this pull request Apr 11, 2022
This release is patch release. We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#4121 Fix RENAME TO/SET SCHEMA on distributed hypertable
* timescale#4122 Fix segfault on INSERT into distributed hypertable
* timescale#4142 Ignore invalid relid when deleting hypertable
* timescale#4159 Fix ADD COLUMN IF NOT EXISTS error on compressed hypertable
* timescale#4161 Fix memory handling during scans
* timescale#4176 Fix remote EXPLAIN with parameterized queries
* timescale#4181 Fix spelling errors and omissions
* timescale#4186 Fix owner change for distributed hypertable
* timescale#4192 Abort sessions after extension reload
* timescale#4193 Fix relcache callback handling causing crashes
* timescale#4199 Remove signal-unsafe calls from signal handlers
* timescale#4219 Do not modify aggregation state in finalize

**Thanks**
* @abrownsword for reporting a crash in the telemetry reporter
* @daydayup863 for reporting issue with remote explain
svenklemm pushed a commit to RafiaSabih/timescaledb that referenced this pull request Apr 11, 2022
This release is a patch release. We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#4121 Fix RENAME TO/SET SCHEMA on distributed hypertable
* timescale#4122 Fix segfault on INSERT into distributed hypertable
* timescale#4142 Ignore invalid relid when deleting hypertable
* timescale#4159 Fix ADD COLUMN IF NOT EXISTS error on compressed hypertable
* timescale#4161 Fix memory handling during scans
* timescale#4176 Fix remote EXPLAIN with parameterized queries
* timescale#4181 Fix spelling errors and omissions
* timescale#4186 Fix owner change for distributed hypertable
* timescale#4192 Abort sessions after extension reload
* timescale#4193 Fix relcache callback handling causing crashes
* timescale#4199 Remove signal-unsafe calls from signal handlers
* timescale#4219 Do not modify aggregation state in finalize

**Thanks**
* @abrownsword for reporting a crash in the telemetry reporter
* @daydayup863 for reporting issue with remote explain
svenklemm pushed a commit that referenced this pull request Apr 11, 2022
This release is a patch release. We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* #4121 Fix RENAME TO/SET SCHEMA on distributed hypertable
* #4122 Fix segfault on INSERT into distributed hypertable
* #4142 Ignore invalid relid when deleting hypertable
* #4159 Fix ADD COLUMN IF NOT EXISTS error on compressed hypertable
* #4161 Fix memory handling during scans
* #4176 Fix remote EXPLAIN with parameterized queries
* #4181 Fix spelling errors and omissions
* #4186 Fix owner change for distributed hypertable
* #4192 Abort sessions after extension reload
* #4193 Fix relcache callback handling causing crashes
* #4199 Remove signal-unsafe calls from signal handlers
* #4219 Do not modify aggregation state in finalize

**Thanks**
* @abrownsword for reporting a crash in the telemetry reporter
* @daydayup863 for reporting issue with remote explain
mkindahl added a commit to mkindahl/timescaledb that referenced this pull request May 12, 2022
In timescale#4199 existing calls of `ereport` were replaced with calls of
`write_stderr` to eliminate the use of signal-unsafe calls, in
particular calls to `malloc`. Unfortunately, `write_stderr` contains a
call to `vfprintf`, which allocates memory as well, occationally
causing servers that are shutting down to become unresponsive.

Since the existing signal handlers just called `die` after printing out
a useful message, this commit fixes this by using `die` as a signal
handler.

Fixes timescale#4200
mkindahl added a commit to mkindahl/timescaledb that referenced this pull request May 12, 2022
In timescale#4199 existing calls of `ereport` were replaced with calls of
`write_stderr` to eliminate the use of signal-unsafe calls, in
particular calls to `malloc`. Unfortunately, `write_stderr` contains a
call to `vfprintf`, which allocates memory as well, occationally
causing servers that are shutting down to become unresponsive.

Since the existing signal handlers just called `die` after printing out
a useful message, this commit fixes this by using `die` as a signal
handler.

Fixes timescale#4200
mkindahl added a commit that referenced this pull request May 12, 2022
In #4199 existing calls of `ereport` were replaced with calls of
`write_stderr` to eliminate the use of signal-unsafe calls, in
particular calls to `malloc`. Unfortunately, `write_stderr` contains a
call to `vfprintf`, which allocates memory as well, occationally
causing servers that are shutting down to become unresponsive.

Since the existing signal handlers just called `die` after printing out
a useful message, this commit fixes this by using `die` as a signal
handler.

Fixes #4200
@mkindahl mkindahl added the bug label May 13, 2022
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]: Shutdown stalled waiting for TimescaleDB Background Worker Scheduler
3 participants