Re: Listen / Notify - what to do when the queue is full - Mailing list pgsql-hackers

From Joachim Wieland
Subject Re: Listen / Notify - what to do when the queue is full
Date
Msg-id dc7b844e1002151121y98a9b22lef2cd32d6596261e@mail.gmail.com
Whole thread Raw
In response to Re: Listen / Notify - what to do when the queue is full  (Simon Riggs <simon@2ndQuadrant.com>)
Responses Re: Listen / Notify - what to do when the queue is full
List pgsql-hackers
On Mon, Feb 15, 2010 at 1:48 PM, Simon Riggs <simon@2ndquadrant.com> wrote:
> On Mon, 2010-02-15 at 12:59 +0100, Joachim Wieland wrote:
>> I have tested it already. The point where it currently fails is the
>> following line:
>>
>>       qe->xid = GetCurrentTransactionId();
>
> That's a shame. So it will never work in Hot Standby mode unless you can
> think of a different way.

We could probably fake this on the Hot Standby in the following way:

We introduce a commit record for every notifying transaction and write
it into the queue itself. So right before writing anything else, we
write an entry which informs readers that the following records are
not yet committed. Then we write the actual notifications and commit.
In post-commit we return back to the commit record and flip its
status. Reading backends would stop at the commit record and we'd
signal them so that they can continue. This actually plays nicely with
Tom's intent to not have interleaved notifications in the queue (makes
things a bit easier but would probably work either way)...

However we'd need to make sure that we clean up that commit record
even if something weird happens (similar to TransactionIdDidAbort()
returning true) in order to allow the readers to proceed.

Comments?


Joachim


pgsql-hackers by date:

Previous
From: Greg Smith
Date:
Subject: Re: psycopg2 license changed
Next
From: Jeroen Vermeulen
Date:
Subject: Re: Avoiding bad prepared-statement plans.