From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Joachim Wieland <joe(at)mcknight(dot)de> |
Cc: | Jeff Davis <pgsql(at)j-davis(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Smith <greg(at)2ndquadrant(dot)com>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org, Arnaud Betremieux <arnaud(dot)betremieux(at)keyconsulting(dot)fr> |
Subject: | Re: Listen / Notify - what to do when the queue is full |
Date: | 2010-02-07 05:18:25 |
Message-ID: | 603c8f071002062118j5863c3a2sbd9c667f8a435dc7@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Feb 3, 2010 at 4:34 AM, Joachim Wieland <joe(at)mcknight(dot)de> wrote:
> On Wed, Feb 3, 2010 at 2:05 AM, Jeff Davis <pgsql(at)j-davis(dot)com> wrote:
>>> Thanks, very well spotted... Actually the same is true for LISTEN... I
>>> have reworked the patch to do the changes to listenChannels only in
>>> the post-commit functions.
>>
>> I'm worried that this creates the opposite problem: that a LISTEN
>> transaction might commit before a NOTIFY transaction, and yet miss the
>> notification.
>
> See the following comment and let me know if you agree...
>
> ! /*
> ! * Exec_ListenBeforeCommit --- subroutine for AtCommit_NotifyBeforeCommit
> ! *
> ! * Note that we do only set our pointer here and do not yet add the channel to
> ! * listenChannels. Since our transaction could still roll back we do this only
> ! * after commit. We know that our tail pointer won't move between here and
> ! * directly after commit, so we won't miss a notification.
> ! */
>
> However this introduces a new problem when an initial LISTEN aborts:
> Then we are not listening to anything but for other backends it looks
> like we were. This is tracked by the boolean variable
> backendExecutesInitialListen and gets cleaned up in AtAbort_Notify().
>
>
>> It seems safest to me to add a backend (LISTEN) to the list before
>> commit, and remove a backend (UNLISTEN) after commit. That way we are
>> sure to only receive spurious notifications, and can't miss any.
>
> If a LISTEN aborted we would not only receive a few spurious
> notifications from it but would receive notifications on this channel
> forever even though we have never executed LISTEN on it successfully.
Jeff, do you think this patch is ready for committer? If so, please
mark it as such on commitfest.postgresql.org - otherwise, please
clarify what you think the action items are.
Thanks,
...Robert
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2010-02-07 05:27:22 | Re: damage control mode |
Previous Message | Robert Haas | 2010-02-07 05:13:15 | Re: [HACKERS] Re: Faster CREATE DATABASE by delaying fsync (was 8.4.1 ubuntu karmic slow createdb) |