Kevin Grittner <kgrittn@ymail.com> writes:
> Thanks to Thomas Munro joining me in a 2.5 day marathon hunt for
> this bug, we have found it and squashed it with the attached patch.
> ...
> These checks are about as close to free as you can get if the
> transaction doing the check is not serializable; it doesn't even
> need to take out a LW lock to determine there is nothing to be
> done. The reason given in the comment still has merit for
> serializable transactions; even for them the check is orders of
> magnitude cheaper than a WAL logged tuple insert. It only requires
> an occasional serialization failure detection there to come out
> ahead. So rather than move the existing check, we added a recheck
> after.
> Barring objections I will push this tomorrow, including
> back-patching it to all supported branches.
I'm okay with the substance of the patch, but that's a pretty miserable
excuse for fixing the comments. Both the initial checks and the rechecks
ought to have at least a couple of sentences recapping the logic you gave
us here.
regards, tom lane