Questions regarding notify processing.

From: Terry Lee Tucker <terry(at)esc1(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Questions regarding notify processing.
Date: 2005-02-24 16:13:43
Message-ID: 200502241113.43442.terry@esc1.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello List:

I am working on the proper method for Notification processing. The application
interface is X-Windows and I am using the database socket as an alternate
input source to the X-Server. I have a callback that fires when there is data
to read on the socket. Here is the setup:

/* This callback fires when there is data to read on the database socket. */
void DbInputCB (XtPointer clientData, int *source, XtInputId *id)
{
.
.
CheckForNotifies (ctrl);
.
.
.
}

/* This function processes NOTIFY messages. */
void CheckForNotifies (Controls *ctrl)
{
PQflush (ctrl->sys->conn); // always flush it first ;o)

PQconsumeInput (ctrl->sys->conn); // suck up queued input
while ((ctrl->notify = PQnotifies (ctrl->sys->conn)) != NULL)
{
/* If you are interested in receiving any NOTICE data, you will
* have to have this function defined locally. */
if (ctrl->main->backEndNotify)
{
void (*p) () = (void *) ctrl->main->backEndNotify;
(*p) (ctrl); // call the function
}
PQfreemem (ctrl->notify); // free the memory
}
}

All this works great except for certain cases where one of the notify
messages, the one I'm really interested in, gets spooled, queued, or
something and is not delivered until I send another notification, after the
fact, from another client; then, I finally get the message delivered along
with the one I just sent. I have a certain interface that registers an
interest in APPT_MADE. I have a trigger that, when the final appointment is
made, issues a NOTIFY for those interested. The operation that created the
appointment is performed as an Asynchronous command with PQsendQuery due to
the fact that there may be two sql commands in the sql string, depending on
what the user does. The interface allows editing of two different tables
simultaneously. The message sent by the trigger fired as a result of the
update does not get delivered unless I send another notify, then, it is
delivered, along with the one I just sent. I tried calling CheckForNotifies()
from the interface code after the save operation, but then, after two back to
back updates, or sometimes just one, the PQsendQuery call hangs up. The only
way to "unhang it" is to issue a NOTIFY from another client, which allows
PQsendQuery to continue.

Obviously, something is blocking. Also, I don't understand why the APPT_MADE
message does not get delivered. Any pointers would be appreciated.

Thanks...

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Shelby Cain 2005-02-24 16:16:24 Re: stats collector appears to be dying
Previous Message Geoffrey KRETZ 2005-02-24 16:09:31 Re: PGS 7.4.x PREPARE statement