Re: REL_11_STABLE: dsm.c - cannot unpin a segment that is not pinned

Justin Pryzby <pryzby@telsasoft.com>

From: Justin Pryzby <pryzby@telsasoft.com>
To: Thomas Munro <thomas.munro@enterprisedb.com>
Cc: pgsql-hackers@postgresql.org
Date: 2019-02-17T19:41:45Z
Lists: pgsql-hackers
On Sat, Feb 16, 2019 at 09:16:01PM +1300, Thomas Munro wrote:
> On Sat, Feb 16, 2019 at 5:31 PM Justin Pryzby <pryzby@telsasoft.com> wrote:
> > Thanks, will leave it spinning overnight.

No errors in ~36 hours (126 CPU-hrs), so that seems to work.  Thanks.

> > Do you know if any of the others should also be changed ?
> 
> Good question, let me double check...
> 
> > $ grep 'refcnt == 0' src/backend/storage/ipc/dsm.c
> >                 if (refcnt == 0)
> 
> That's dsm_cleanup_using_control_segment() and runs when starting up
> before any workers can be running to clean up after a preceding crash,
> so it's OK (if it's 1, meaning we crashed while that slot was going
> away, we'll try to destroy it again, which is correct).  Good.
> 
> >                 if (dsm_control->item[i].refcnt == 0)
> 
> That's dsm_postmaster_shutdown(), similar but at shutdown time, run by
> the postmaster, and it errs on the side of trying to destroy.  Good.
> 
> >                 if (dsm_control->item[i].refcnt == 0)
> 
> That's dsm_create(), and it's looking specifically for a free slot,
> and that's 0 only, it'll step over used/active (refcnt > 1) and
> used/going-away (refcnt == 1).  Good.


Commits

  1. Fix inconsistent out-of-memory error reporting in dsa.c.

  2. Fix race in dsm_unpin_segment() when handles are reused.

  3. Fix race in dsm_attach() when handles are reused.

  4. Fix rare dsa_allocate() failures due to freepage.c corruption.

  5. Add WL_EXIT_ON_PM_DEATH pseudo-event.