pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAtt 6+ messages / 1 participants [nested] [flat]
* pgsql: Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAtt @ 2019-05-10 18:57 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2019-05-10 18:57 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAttach. There's a very old race condition in our code to see whether a pre-existing shared memory segment is still in use by a conflicting postmaster: it's possible for the other postmaster to remove the segment in between our shmctl() and shmat() calls. It's a narrow window, and there's no risk unless both postmasters are using the same port number, but that's possible during parallelized "make check" tests. (Note that while the TAP tests take some pains to choose a randomized port number, pg_regress doesn't.) If it does happen, we treated that as an unexpected case and errored out. To fix, allow EINVAL to be treated as segment-not-present, and the same for EIDRM on Linux. AFAICS, the considerations here are basically identical to the checks for acceptable shmctl() failures, so I documented and coded it that way. While at it, adjust PGSharedMemoryAttach's API to remove its undocumented dependency on UsedShmemSegAddr in favor of passing the attach address explicitly. This makes it easier to be sure we're using a null shmaddr when probing for segment conflicts (thus avoiding questions about what EINVAL means). I don't think there was a bug there, but it required fragile assumptions about the state of UsedShmemSegAddr during PGSharedMemoryIsInUse. Commit c09850992 may have made this failure more probable by applying the conflicting-segment tests more often. Hence, back-patch to all supported branches, as that was. Discussion: https://postgr.es/m/22224.1557340366@sss.pgh.pa.us Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/610747d86e46ae6e94b7288393d08823cc39b498 Modified Files -------------- src/backend/port/sysv_shmem.c | 70 +++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 23 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAtt @ 2019-05-10 18:57 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2019-05-10 18:57 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAttach. There's a very old race condition in our code to see whether a pre-existing shared memory segment is still in use by a conflicting postmaster: it's possible for the other postmaster to remove the segment in between our shmctl() and shmat() calls. It's a narrow window, and there's no risk unless both postmasters are using the same port number, but that's possible during parallelized "make check" tests. (Note that while the TAP tests take some pains to choose a randomized port number, pg_regress doesn't.) If it does happen, we treated that as an unexpected case and errored out. To fix, allow EINVAL to be treated as segment-not-present, and the same for EIDRM on Linux. AFAICS, the considerations here are basically identical to the checks for acceptable shmctl() failures, so I documented and coded it that way. While at it, adjust PGSharedMemoryAttach's API to remove its undocumented dependency on UsedShmemSegAddr in favor of passing the attach address explicitly. This makes it easier to be sure we're using a null shmaddr when probing for segment conflicts (thus avoiding questions about what EINVAL means). I don't think there was a bug there, but it required fragile assumptions about the state of UsedShmemSegAddr during PGSharedMemoryIsInUse. Commit c09850992 may have made this failure more probable by applying the conflicting-segment tests more often. Hence, back-patch to all supported branches, as that was. Discussion: https://postgr.es/m/22224.1557340366@sss.pgh.pa.us Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/a73c8caea46c703fcd90e17e28b6a9223ea24bd0 Modified Files -------------- src/backend/port/sysv_shmem.c | 70 +++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 23 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAtt @ 2019-05-10 18:57 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2019-05-10 18:57 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAttach. There's a very old race condition in our code to see whether a pre-existing shared memory segment is still in use by a conflicting postmaster: it's possible for the other postmaster to remove the segment in between our shmctl() and shmat() calls. It's a narrow window, and there's no risk unless both postmasters are using the same port number, but that's possible during parallelized "make check" tests. (Note that while the TAP tests take some pains to choose a randomized port number, pg_regress doesn't.) If it does happen, we treated that as an unexpected case and errored out. To fix, allow EINVAL to be treated as segment-not-present, and the same for EIDRM on Linux. AFAICS, the considerations here are basically identical to the checks for acceptable shmctl() failures, so I documented and coded it that way. While at it, adjust PGSharedMemoryAttach's API to remove its undocumented dependency on UsedShmemSegAddr in favor of passing the attach address explicitly. This makes it easier to be sure we're using a null shmaddr when probing for segment conflicts (thus avoiding questions about what EINVAL means). I don't think there was a bug there, but it required fragile assumptions about the state of UsedShmemSegAddr during PGSharedMemoryIsInUse. Commit c09850992 may have made this failure more probable by applying the conflicting-segment tests more often. Hence, back-patch to all supported branches, as that was. Discussion: https://postgr.es/m/22224.1557340366@sss.pgh.pa.us Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/3dcf45af560eeeef8d4ed4255a8d13ef16764dc4 Modified Files -------------- src/backend/port/sysv_shmem.c | 70 +++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 23 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAtt @ 2019-05-10 18:57 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2019-05-10 18:57 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAttach. There's a very old race condition in our code to see whether a pre-existing shared memory segment is still in use by a conflicting postmaster: it's possible for the other postmaster to remove the segment in between our shmctl() and shmat() calls. It's a narrow window, and there's no risk unless both postmasters are using the same port number, but that's possible during parallelized "make check" tests. (Note that while the TAP tests take some pains to choose a randomized port number, pg_regress doesn't.) If it does happen, we treated that as an unexpected case and errored out. To fix, allow EINVAL to be treated as segment-not-present, and the same for EIDRM on Linux. AFAICS, the considerations here are basically identical to the checks for acceptable shmctl() failures, so I documented and coded it that way. While at it, adjust PGSharedMemoryAttach's API to remove its undocumented dependency on UsedShmemSegAddr in favor of passing the attach address explicitly. This makes it easier to be sure we're using a null shmaddr when probing for segment conflicts (thus avoiding questions about what EINVAL means). I don't think there was a bug there, but it required fragile assumptions about the state of UsedShmemSegAddr during PGSharedMemoryIsInUse. Commit c09850992 may have made this failure more probable by applying the conflicting-segment tests more often. Hence, back-patch to all supported branches, as that was. Discussion: https://postgr.es/m/22224.1557340366@sss.pgh.pa.us Branch ------ REL9_4_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/b1cde67a4f94ada93eb314c7751e998377a0fa6a Modified Files -------------- src/backend/port/sysv_shmem.c | 70 +++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 23 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAtt @ 2019-05-10 18:57 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2019-05-10 18:57 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAttach. There's a very old race condition in our code to see whether a pre-existing shared memory segment is still in use by a conflicting postmaster: it's possible for the other postmaster to remove the segment in between our shmctl() and shmat() calls. It's a narrow window, and there's no risk unless both postmasters are using the same port number, but that's possible during parallelized "make check" tests. (Note that while the TAP tests take some pains to choose a randomized port number, pg_regress doesn't.) If it does happen, we treated that as an unexpected case and errored out. To fix, allow EINVAL to be treated as segment-not-present, and the same for EIDRM on Linux. AFAICS, the considerations here are basically identical to the checks for acceptable shmctl() failures, so I documented and coded it that way. While at it, adjust PGSharedMemoryAttach's API to remove its undocumented dependency on UsedShmemSegAddr in favor of passing the attach address explicitly. This makes it easier to be sure we're using a null shmaddr when probing for segment conflicts (thus avoiding questions about what EINVAL means). I don't think there was a bug there, but it required fragile assumptions about the state of UsedShmemSegAddr during PGSharedMemoryIsInUse. Commit c09850992 may have made this failure more probable by applying the conflicting-segment tests more often. Hence, back-patch to all supported branches, as that was. Discussion: https://postgr.es/m/22224.1557340366@sss.pgh.pa.us Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/803f90ab795b6bc170ba517cdd0dfddc85a5f961 Modified Files -------------- src/backend/port/sysv_shmem.c | 70 +++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 23 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAtt @ 2019-05-10 18:57 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2019-05-10 18:57 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAttach. There's a very old race condition in our code to see whether a pre-existing shared memory segment is still in use by a conflicting postmaster: it's possible for the other postmaster to remove the segment in between our shmctl() and shmat() calls. It's a narrow window, and there's no risk unless both postmasters are using the same port number, but that's possible during parallelized "make check" tests. (Note that while the TAP tests take some pains to choose a randomized port number, pg_regress doesn't.) If it does happen, we treated that as an unexpected case and errored out. To fix, allow EINVAL to be treated as segment-not-present, and the same for EIDRM on Linux. AFAICS, the considerations here are basically identical to the checks for acceptable shmctl() failures, so I documented and coded it that way. While at it, adjust PGSharedMemoryAttach's API to remove its undocumented dependency on UsedShmemSegAddr in favor of passing the attach address explicitly. This makes it easier to be sure we're using a null shmaddr when probing for segment conflicts (thus avoiding questions about what EINVAL means). I don't think there was a bug there, but it required fragile assumptions about the state of UsedShmemSegAddr during PGSharedMemoryIsInUse. Commit c09850992 may have made this failure more probable by applying the conflicting-segment tests more often. Hence, back-patch to all supported branches, as that was. Discussion: https://postgr.es/m/22224.1557340366@sss.pgh.pa.us Branch ------ REL9_5_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/91a05390c33c74c8a6bbc7f89d77fe3a8ac5098f Modified Files -------------- src/backend/port/sysv_shmem.c | 70 +++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 23 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2019-05-10 18:57 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2019-05-10 18:57 pgsql: Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAtt Tom Lane <tgl@sss.pgh.pa.us> 2019-05-10 18:57 pgsql: Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAtt Tom Lane <tgl@sss.pgh.pa.us> 2019-05-10 18:57 pgsql: Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAtt Tom Lane <tgl@sss.pgh.pa.us> 2019-05-10 18:57 pgsql: Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAtt Tom Lane <tgl@sss.pgh.pa.us> 2019-05-10 18:57 pgsql: Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAtt Tom Lane <tgl@sss.pgh.pa.us> 2019-05-10 18:57 pgsql: Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAtt Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox