Re: dsm_unpin_segment

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: dsm_unpin_segment
Date: 2016-08-09 00:37:23
Message-ID: CAEepm=2Y+0Lv9r+k4WRMrjRd_bK6HdJ9XZFeay+3EgHfCCWW9w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Aug 9, 2016 at 12:22 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Mon, Aug 8, 2016 at 7:33 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com> writes:
>>> Please find attached a patch to add a corresponding operation
>>> 'dsm_unpin_segment'. This gives you a way to ask for the segment to
>>> survive only until you decide to unpin it, at which point the usual
>>> reference counting semantics apply again. It decrements the reference
>>> count, undoing the effect of dsm_pin_segment and destroying the
>>> segment if appropriate.
>>
>> What happens if dsm_unpin_segment is called more times than
>> dsm_pin_segment? Seems like you could try to destroy a segment that
>> still has processes attached.
>
> Calling dsm_pin_segment more than once is not supported and has never
> been supported. As the comments explain:
>
> * This function should not be called more than once per segment;
> * on Windows, doing so will create unnecessary handles which will
> * consume system resources to no benefit.
>
> Therefore, I don't see the problem. You can pin a segment that is not
> pinned, and you can unpin a segment that is pinned. You may not
> re-pin a segment that is already pinned, nor unpin a segment that is
> not pinned. If you try to do so, you are using the API contrary to
> specification, and if it breaks (as it will) you get to keep both
> pieces.
>
> We could add the reference counting behavior for which you are asking,
> but that seems to be an entirely new feature for which I know of no
> demand.

Yeah, I was considering unbalanced pin/unpin requests to be a
programming error. To be more defensive about that, how about I add a
boolean 'pinned' to dsm_control_item, and elog(ERROR, ...) if it's not
in the expected state when you try to pin or unpin?

--
Thomas Munro
http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-08-09 00:53:44 Re: dsm_unpin_segment
Previous Message Robert Haas 2016-08-09 00:22:53 Re: dsm_unpin_segment