Re: Race condition between hot standby and restoring a FPW

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Race condition between hot standby and restoring a FPW
Date: 2014-11-12 15:47:34
Message-ID: 4351.1415807254@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> writes:
> On 11/12/2014 05:20 PM, Tom Lane wrote:
>> On reconsideration I think the "RBM_ZERO returns page already locked"
>> alternative may be the less ugly. That has the advantage that any code
>> that doesn't get updated will fail clearly and reliably.

> Yeah, I'm leaning to that approach as well. It's made more ugly by the
> fact that you sometimes need a cleanup lock on the buffer, so the caller
> will somehow need to specify whether to get a cleanup lock or a normal
> exclusive lock. Maybe add yet another mode, RBM_ZERO_WITH_CLEANUP_LOCK.
> Could also rename RBM_ZERO to e.g. RBM_ZERO_AND_LOCK, to make any code
> that's not updated to break even more obviously, at compile-time.

Yeah, I was considering suggesting changing the name of the mode too.
+1 for solving the lock-type problem with 2 modes.

(You could also consider leaving RBM_ZERO in place with its current
semantics, but I think what you've shown here is that there is no
safe way to use it, so probably that's not what we should do.)

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2014-11-12 15:59:49 Re: what does this mean: "running xacts with xcnt == 0"
Previous Message Heikki Linnakangas 2014-11-12 15:29:42 Re: Race condition between hot standby and restoring a FPW