]> granicus.if.org Git - postgresql/commit
Fix race in dsm_unpin_segment() when handles are reused.
authorThomas Munro <tmunro@postgresql.org>
Sun, 17 Feb 2019 20:53:26 +0000 (09:53 +1300)
committerThomas Munro <tmunro@postgresql.org>
Sun, 17 Feb 2019 20:58:29 +0000 (09:58 +1300)
commit0b55aaacec313c309e21f63d9ff5733c3f8ab813
treea231f56cca57dfc3b1cb5bc708dbb218c636608a
parentbc6d7eb689a2d083df981dfd10c65d1a9d32ca64
Fix race in dsm_unpin_segment() when handles are reused.

Teach dsm_unpin_segment() to skip segments that are in the process
of being destroyed by another backend, when searching for a handle.
Such a segment cannot possibly be the one we are looking for, even
if its handle matches.  Another slot might hold a recently created
segment that has the same handle value by coincidence, and we need
to keep searching for that one.

The bug caused rare "cannot unpin a segment that is not pinned"
errors on 10 and 11.  Similar to commit 6c0fb941 for dsm_attach().

Back-patch to 10, where dsm_unpin_segment() landed.

Author: Thomas Munro
Reported-by: Justin Pryzby
Tested-by: Justin Pryzby (along with other recent DSA/DSM fixes)
Discussion: https://postgr.es/m/20190216023854.GF30291@telsasoft.com
src/backend/storage/ipc/dsm.c