pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix race in dsm_attach() when handles are reused. 6+ messages / 1 participants [nested] [flat]
* pgsql: Fix race in dsm_attach() when handles are reused. @ 2019-02-15 02:05 Thomas Munro <tmunro@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Thomas Munro @ 2019-02-15 02:05 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix race in dsm_attach() when handles are reused. DSM handle values can be reused as soon as the underlying shared memory object has been destroyed. That means that for a brief moment we might have two DSM slots with the same handle. While trying to attach, if we encounter a slot with refcnt == 1, meaning that it is currently being destroyed, we should continue our search in case the same handle exists in another slot. The race manifested as a rare "dsa_area could not attach to segment" error, and was more likely in 10 and 11 due to the lack of distinct seed for random() in parallel workers. It was made very unlikely in in master by commit 197e4af9, and older releases don't usually create new DSM segments in background workers so it was also unlikely there. This fixes the root cause of bug report #15585, in which the error could also sometimes result in a self-deadlock in the error path. It's not yet clear if further changes are needed to avoid that failure mode. Back-patch to 9.4, where dsm.c arrived. Author: Thomas Munro Reported-by: Justin Pryzby, Sergei Kornilov Discussion: https://postgr.es/m/20190207014719.GJ29720@telsasoft.com Discussion: https://postgr.es/m/15585-324ff6a93a18da46@postgresql.org Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/6c0fb941892519ad6b8873e99c4001404fb9a128 Modified Files -------------- src/backend/storage/ipc/dsm.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix race in dsm_attach() when handles are reused. @ 2019-02-15 02:05 Thomas Munro <tmunro@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Thomas Munro @ 2019-02-15 02:05 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix race in dsm_attach() when handles are reused. DSM handle values can be reused as soon as the underlying shared memory object has been destroyed. That means that for a brief moment we might have two DSM slots with the same handle. While trying to attach, if we encounter a slot with refcnt == 1, meaning that it is currently being destroyed, we should continue our search in case the same handle exists in another slot. The race manifested as a rare "dsa_area could not attach to segment" error, and was more likely in 10 and 11 due to the lack of distinct seed for random() in parallel workers. It was made very unlikely in in master by commit 197e4af9, and older releases don't usually create new DSM segments in background workers so it was also unlikely there. This fixes the root cause of bug report #15585, in which the error could also sometimes result in a self-deadlock in the error path. It's not yet clear if further changes are needed to avoid that failure mode. Back-patch to 9.4, where dsm.c arrived. Author: Thomas Munro Reported-by: Justin Pryzby, Sergei Kornilov Discussion: https://postgr.es/m/20190207014719.GJ29720@telsasoft.com Discussion: https://postgr.es/m/15585-324ff6a93a18da46@postgresql.org Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/faf132449c0cafd31fe9f14bbf29ca0318a89058 Modified Files -------------- src/backend/storage/ipc/dsm.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix race in dsm_attach() when handles are reused. @ 2019-02-15 02:06 Thomas Munro <tmunro@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Thomas Munro @ 2019-02-15 02:06 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix race in dsm_attach() when handles are reused. DSM handle values can be reused as soon as the underlying shared memory object has been destroyed. That means that for a brief moment we might have two DSM slots with the same handle. While trying to attach, if we encounter a slot with refcnt == 1, meaning that it is currently being destroyed, we should continue our search in case the same handle exists in another slot. The race manifested as a rare "dsa_area could not attach to segment" error, and was more likely in 10 and 11 due to the lack of distinct seed for random() in parallel workers. It was made very unlikely in in master by commit 197e4af9, and older releases don't usually create new DSM segments in background workers so it was also unlikely there. This fixes the root cause of bug report #15585, in which the error could also sometimes result in a self-deadlock in the error path. It's not yet clear if further changes are needed to avoid that failure mode. Back-patch to 9.4, where dsm.c arrived. Author: Thomas Munro Reported-by: Justin Pryzby, Sergei Kornilov Discussion: https://postgr.es/m/20190207014719.GJ29720@telsasoft.com Discussion: https://postgr.es/m/15585-324ff6a93a18da46@postgresql.org Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/cb3d674e1709362d84b5e25c94e690e98599a33c Modified Files -------------- src/backend/storage/ipc/dsm.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix race in dsm_attach() when handles are reused. @ 2019-02-15 02:06 Thomas Munro <tmunro@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Thomas Munro @ 2019-02-15 02:06 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix race in dsm_attach() when handles are reused. DSM handle values can be reused as soon as the underlying shared memory object has been destroyed. That means that for a brief moment we might have two DSM slots with the same handle. While trying to attach, if we encounter a slot with refcnt == 1, meaning that it is currently being destroyed, we should continue our search in case the same handle exists in another slot. The race manifested as a rare "dsa_area could not attach to segment" error, and was more likely in 10 and 11 due to the lack of distinct seed for random() in parallel workers. It was made very unlikely in in master by commit 197e4af9, and older releases don't usually create new DSM segments in background workers so it was also unlikely there. This fixes the root cause of bug report #15585, in which the error could also sometimes result in a self-deadlock in the error path. It's not yet clear if further changes are needed to avoid that failure mode. Back-patch to 9.4, where dsm.c arrived. Author: Thomas Munro Reported-by: Justin Pryzby, Sergei Kornilov Discussion: https://postgr.es/m/20190207014719.GJ29720@telsasoft.com Discussion: https://postgr.es/m/15585-324ff6a93a18da46@postgresql.org Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/cb0680573f7b49865d6c87bc29ed675bbd3a790a Modified Files -------------- src/backend/storage/ipc/dsm.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix race in dsm_attach() when handles are reused. @ 2019-02-15 02:07 Thomas Munro <tmunro@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Thomas Munro @ 2019-02-15 02:07 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix race in dsm_attach() when handles are reused. DSM handle values can be reused as soon as the underlying shared memory object has been destroyed. That means that for a brief moment we might have two DSM slots with the same handle. While trying to attach, if we encounter a slot with refcnt == 1, meaning that it is currently being destroyed, we should continue our search in case the same handle exists in another slot. The race manifested as a rare "dsa_area could not attach to segment" error, and was more likely in 10 and 11 due to the lack of distinct seed for random() in parallel workers. It was made very unlikely in in master by commit 197e4af9, and older releases don't usually create new DSM segments in background workers so it was also unlikely there. This fixes the root cause of bug report #15585, in which the error could also sometimes result in a self-deadlock in the error path. It's not yet clear if further changes are needed to avoid that failure mode. Back-patch to 9.4, where dsm.c arrived. Author: Thomas Munro Reported-by: Justin Pryzby, Sergei Kornilov Discussion: https://postgr.es/m/20190207014719.GJ29720@telsasoft.com Discussion: https://postgr.es/m/15585-324ff6a93a18da46@postgresql.org Branch ------ REL9_5_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/b7c8766d34803b5ad7d371625aa994f4648f7845 Modified Files -------------- src/backend/storage/ipc/dsm.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix race in dsm_attach() when handles are reused. @ 2019-02-15 02:07 Thomas Munro <tmunro@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Thomas Munro @ 2019-02-15 02:07 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix race in dsm_attach() when handles are reused. DSM handle values can be reused as soon as the underlying shared memory object has been destroyed. That means that for a brief moment we might have two DSM slots with the same handle. While trying to attach, if we encounter a slot with refcnt == 1, meaning that it is currently being destroyed, we should continue our search in case the same handle exists in another slot. The race manifested as a rare "dsa_area could not attach to segment" error, and was more likely in 10 and 11 due to the lack of distinct seed for random() in parallel workers. It was made very unlikely in in master by commit 197e4af9, and older releases don't usually create new DSM segments in background workers so it was also unlikely there. This fixes the root cause of bug report #15585, in which the error could also sometimes result in a self-deadlock in the error path. It's not yet clear if further changes are needed to avoid that failure mode. Back-patch to 9.4, where dsm.c arrived. Author: Thomas Munro Reported-by: Justin Pryzby, Sergei Kornilov Discussion: https://postgr.es/m/20190207014719.GJ29720@telsasoft.com Discussion: https://postgr.es/m/15585-324ff6a93a18da46@postgresql.org Branch ------ REL9_4_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/bd195071fd2be49392bf1993397f638d96315ee0 Modified Files -------------- src/backend/storage/ipc/dsm.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2019-02-15 02:07 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2019-02-15 02:05 pgsql: Fix race in dsm_attach() when handles are reused. Thomas Munro <tmunro@postgresql.org> 2019-02-15 02:05 pgsql: Fix race in dsm_attach() when handles are reused. Thomas Munro <tmunro@postgresql.org> 2019-02-15 02:06 pgsql: Fix race in dsm_attach() when handles are reused. Thomas Munro <tmunro@postgresql.org> 2019-02-15 02:06 pgsql: Fix race in dsm_attach() when handles are reused. Thomas Munro <tmunro@postgresql.org> 2019-02-15 02:07 pgsql: Fix race in dsm_attach() when handles are reused. Thomas Munro <tmunro@postgresql.org> 2019-02-15 02:07 pgsql: Fix race in dsm_attach() when handles are reused. Thomas Munro <tmunro@postgresql.org>
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