aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2022-07-15 01:23:29 +1200
committerThomas Munro <tmunro@postgresql.org>2022-07-15 02:00:09 +1200
commit80845b7c0b2cf0a26e44d7906d63cddbb4dd586c (patch)
tree9d571d87955fface85ab7cea51c72107c5e3ad04
parent7c0eb3c622eb0882f460805109f244679b340964 (diff)
downloadpostgresql-80845b7c0b2cf0a26e44d7906d63cddbb4dd586c.tar.gz
postgresql-80845b7c0b2cf0a26e44d7906d63cddbb4dd586c.zip
Don't clobber postmaster sigmask in dsm_impl_resize.
Commit 4518c798 intended to block signals in regular backends that allocate DSM segments, but dsm_impl_resize() is also reached by dsm_postmaster_startup(). It's not OK to clobber the postmaster's signal mask, so only manipulate the signal mask when under the postmaster. Back-patch to all releases, like 4518c798. Discussion: https://postgr.es/m/CA%2BhUKGKNpK%3D2OMeea_AZwpLg7Bm4%3DgYWk7eDjZ5F6YbozfOf8w%40mail.gmail.com
-rw-r--r--src/backend/storage/ipc/dsm_impl.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/backend/storage/ipc/dsm_impl.c b/src/backend/storage/ipc/dsm_impl.c
index 258d47bcfac..0247d13a913 100644
--- a/src/backend/storage/ipc/dsm_impl.c
+++ b/src/backend/storage/ipc/dsm_impl.c
@@ -362,7 +362,8 @@ dsm_impl_posix_resize(int fd, off_t size)
* allowed SIGUSR1 to interrupt us repeatedly (for example, due to recovery
* conflicts), the retry loop might never succeed.
*/
- PG_SETMASK(&BlockSig);
+ if (IsUnderPostmaster)
+ PG_SETMASK(&BlockSig);
pgstat_report_wait_start(WAIT_EVENT_DSM_ALLOCATE);
#if defined(HAVE_POSIX_FALLOCATE) && defined(__linux__)
@@ -398,9 +399,12 @@ dsm_impl_posix_resize(int fd, off_t size)
#endif
pgstat_report_wait_end();
- save_errno = errno;
- PG_SETMASK(&UnBlockSig);
- errno = save_errno;
+ if (IsUnderPostmaster)
+ {
+ save_errno = errno;
+ PG_SETMASK(&UnBlockSig);
+ errno = save_errno;
+ }
return rc;
}