]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Don't clobber postmaster sigmask in dsm_impl_resize.
authorThomas Munro <tmunro@postgresql.org>
Thu, 14 Jul 2022 13:23:29 +0000 (01:23 +1200)
committerThomas Munro <tmunro@postgresql.org>
Thu, 14 Jul 2022 14:08:27 +0000 (02:08 +1200)
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

src/backend/storage/ipc/dsm_impl.c

index d72c7dae2b9209a4d4f185a0ef5afc00ad1893ee..b21af306c9375213eac57cba0d627ebb1012e3c7 100644 (file)
@@ -416,7 +416,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);
 
        /* Truncate (or extend) the file to the requested size. */
        do
@@ -454,9 +455,12 @@ dsm_impl_posix_resize(int fd, off_t size)
        }
 #endif                                                 /* HAVE_POSIX_FALLOCATE && __linux__ */
 
-       save_errno = errno;
-       PG_SETMASK(&UnBlockSig);
-       errno = save_errno;
+       if (IsUnderPostmaster)
+       {
+               save_errno = errno;
+               PG_SETMASK(&UnBlockSig);
+               errno = save_errno;
+       }
 
        return rc;
 }