Re: Listen / Notify - what to do when the queue is full

Alvaro Herrera <alvherre@commandprompt.com>

From: Alvaro Herrera <alvherre@commandprompt.com>
To: Joachim Wieland <joe@mcknight.de>
Cc: Jeff Davis <pgsql@j-davis.com>, Tom Lane <tgl@sss.pgh.pa.us>, Greg Smith <greg@2ndquadrant.com>, Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>, "Florian G. Pflug" <fgp@phlo.org>, Josh Berkus <josh@agliodbs.com>, pgsql-hackers@postgresql.org, Arnaud Betremieux <arnaud.betremieux@keyconsulting.fr>
Date: 2010-02-08T16:16:32Z
Lists: pgsql-hackers
Joachim Wieland wrote:

> + typedef struct AsyncQueueEntry
> + {
> + 	/*
> + 	 * this record has the maximal length, but usually we limit it to
> + 	 * AsyncQueueEntryEmptySize + strlen(payload).
> + 	 */
> + 	Size			length;
> + 	Oid				dboid;
> + 	TransactionId	xid;
> + 	int32			srcPid;
> + 	char			channel[NAMEDATALEN];
> + 	char			payload[NOTIFY_PAYLOAD_MAX_LENGTH];
> + } AsyncQueueEntry;
> + #define AsyncQueueEntryEmptySize \
> + 	 (sizeof(AsyncQueueEntry) - NOTIFY_PAYLOAD_MAX_LENGTH + 1)

These are the on-disk notifications, right?  It seems to me a bit
wasteful to store channel name always as NAMEDATALEN bytes.  Can we
truncate it at its strlen?  I realize that this would cause the struct
definition to be uglier (you will no longer be able to have both channel
and payload pointers, only a char[1] pointer to a data area to which you
write both).  Typical channel names should be short, so IMHO this is
worthwhile.  Besides, I think the uglification of code this causes
should be fairly contained ...

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support