On Sun, Dec 27, 2015 at 1:27 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Michael Paquier <michael.paquier@gmail.com> writes:
>> On Sat, Dec 26, 2015 at 7:10 AM, Jeff Janes <jeff.janes@gmail.com> wrote:
>> What do you think about the attached?
>
> Don't like that as-is, because dropping and re-acquiring the index lock
> presents a race condition: the checks you made might not apply anymore.
> Admittedly, the odds of a problem are very small, but it's still an
> insecure coding pattern.
>
> I hesitate to produce code without having consumed any caffeine yet,
> but maybe we could do it like this:
>
> [...]
I see, thanks! The lesson is learnt.
--
Michael