Skip to content

Commit a05f40e

Browse files
committed
Don't clobber postmaster sigmask in dsm_impl_resize.
Commit 4518c79 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 4518c79. Discussion: https://postgr.es/m/CA%2BhUKGKNpK%3D2OMeea_AZwpLg7Bm4%3DgYWk7eDjZ5F6YbozfOf8w%40mail.gmail.com
1 parent ff78bf7 commit a05f40e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/backend/storage/ipc/dsm_impl.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,8 @@ dsm_impl_posix_resize(int fd, off_t size)
352352
* allowed SIGUSR1 to interrupt us repeatedly (for example, due to recovery
353353
* conflicts), the retry loop might never succeed.
354354
*/
355-
PG_SETMASK(&BlockSig);
355+
if (IsUnderPostmaster)
356+
PG_SETMASK(&BlockSig);
356357

357358
/* Truncate (or extend) the file to the requested size. */
358359
do
@@ -390,9 +391,12 @@ dsm_impl_posix_resize(int fd, off_t size)
390391
}
391392
#endif /* HAVE_POSIX_FALLOCATE && __linux__ */
392393

393-
save_errno = errno;
394-
PG_SETMASK(&UnBlockSig);
395-
errno = save_errno;
394+
if (IsUnderPostmaster)
395+
{
396+
save_errno = errno;
397+
PG_SETMASK(&UnBlockSig);
398+
errno = save_errno;
399+
}
396400

397401
return rc;
398402
}

0 commit comments

Comments
 (0)