Re: [GENERAL] LISTEN considered dangerous

2006-08-04 Thread Flemming Frandsen
On Thu, 3 Aug 2006, Martijn van Oosterhout wrote: There is no reason to assume that there would be any overhead in storing a list of outstanding events for your connection compared to today. Err, yes there would. Think about it: for that example to work, the server would have to store

Re: [GENERAL] LISTEN considered dangerous

2006-08-04 Thread Martijn van Oosterhout
On Fri, Aug 04, 2006 at 10:24:43AM +0200, Flemming Frandsen wrote: On Thu, 3 Aug 2006, Martijn van Oosterhout wrote: Err, yes there would. Think about it: for that example to work, the server would have to store every notify that happened until your transaction completed. That's exactly

Re: [GENERAL] LISTEN considered dangerous

2006-08-04 Thread Flemming Frandsen
On Fri, 4 Aug 2006, Martijn van Oosterhout wrote: Really? Even pg_dump cares? Or your maintainence scripts (VACUUM/ANALYZE)? Ok, those clients don't, but you rarely have many vacuum/pg_dump processes going on at the same time, so storing the events for them and throwing them away is not that

Re: [GENERAL] LISTEN considered dangerous

2006-08-03 Thread Martijn van Oosterhout
On Thu, Aug 03, 2006 at 12:43:47AM +0200, Flemming Frandsen wrote: On Wed, 2 Aug 2006, Tom Lane wrote: Flemming Frandsen [EMAIL PROTECTED] writes: The listen should simply listen for events issued at the start of the transaction it's executed in. BEGIN; SELECT

Re: [GENERAL] LISTEN considered dangerous

2006-08-03 Thread Ian Harding
On 8/2/06, Flemming Frandsen [EMAIL PROTECTED] wrote: Ian Harding wrote: NOTIFY interacts with SQL transactions in some important ways. Firstly, if a NOTIFY is executed inside a transaction, the notify events are not delivered until and unless the transaction is committed. This is

Re: [GENERAL] LISTEN considered dangerous

2006-08-02 Thread Tom Lane
Martijn van Oosterhout kleptog@svana.org writes: It's slightly surprising though. I havn't seen anyone else complain about this before though. The only way to fix this is to make the LISTEN completely atransactional, so NOTIFY can see uncomitted LISTENs also. There isn't anything very

Re: [GENERAL] LISTEN considered dangerous

2006-08-02 Thread Flemming Frandsen
Martijn van Oosterhout wrote: A: BEGIN A: SELECT * FROM foo and cache the result. A: LISTEN foochange B: BEGIN B: update foo B: NOTIFY foochange B: COMMIT A: COMMIT Eh? At the point the LISTEN is run, the NOTIFY hasn't committed, so a row is inserted. At the time the NOTIFY is

Re: [GENERAL] LISTEN considered dangerous

2006-08-02 Thread Flemming Frandsen
Tom Lane wrote: However, I'm unconvinced that the OP's complaint is valid. I'm unconvinced that I've stated the problem clearly enough. I would still expect any reimplementation of notify messaging to honor the principle that a LISTEN doesn't take effect till you commit. Naturally, the

Re: [GENERAL] LISTEN considered dangerous

2006-08-02 Thread Harald Fuchs
In article [EMAIL PROTECTED], Flemming Frandsen [EMAIL PROTECTED] writes: I would still expect any reimplementation of notify messaging to honor the principle that a LISTEN doesn't take effect till you commit. Naturally, the listen should not do anything at all when followed by a rollback.

Re: [GENERAL] LISTEN considered dangerous

2006-08-02 Thread Tom Lane
Flemming Frandsen [EMAIL PROTECTED] writes: The listen should simply listen for events issued at the start of the transaction it's executed in. BEGIN; SELECT sleep(10); LISTEN foo; No, I don't think so. regards, tom lane

Re: [GENERAL] LISTEN considered dangerous

2006-08-02 Thread Oisin Glynn
Tom Lane wrote: Flemming Frandsen [EMAIL PROTECTED] writes: The listen should simply listen for events issued at the start of the transaction it's executed in. BEGIN; SELECT sleep(10); LISTEN foo; No, I don't think so. regards,

Re: [GENERAL] LISTEN considered dangerous

2006-08-02 Thread Greg Stark
Tom Lane [EMAIL PROTECTED] writes: I would still expect any reimplementation of notify messaging to honor the principle that a LISTEN doesn't take effect till you commit. Otherwise, what of BEGIN; LISTEN foo; ROLLBACK; ? If I get some events for foo after this I'd

Re: [GENERAL] LISTEN considered dangerous

2006-08-02 Thread Martijn van Oosterhout
On Wed, Aug 02, 2006 at 09:15:46AM -0400, Oisin Glynn wrote: I was just about to say that if someone was to do the following they would get the previously commited state of foo after the sleep not how foo looked before the sleep otherwise every begin would need an entire DB snapshot to be

Re: [GENERAL] LISTEN considered dangerous

2006-08-02 Thread Vivek Khera
On Aug 2, 2006, at 2:07 AM, Tom Lane wrote: that the OP's complaint is valid. I would still expect any reimplementation of notify messaging to honor the principle that a LISTEN doesn't take effect till you commit. Otherwise, what of Well, it would break our usage of LISTEN/NOTIFY if they

Re: [GENERAL] LISTEN considered dangerous

2006-08-02 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-08-02 07:57:55 +0200: I'm bothered by listen listening from the end of the transaction in stead of the start of the transaction. Sorry if this isn't what you're after, instead just a question: Why don't you issue the LISTEN in a separate transaction before

Re: [GENERAL] LISTEN considered dangerous

2006-08-02 Thread Flemming Frandsen
On 2 Aug 2006, Harald Fuchs wrote: all events that have happened after the snapshot that the transaction represents (the start of the transaction). Here you're contradicting yourself. In your second paragraph you state that LISTEN should get events unless later cancelled by a ROLLBACK.

Re: [GENERAL] LISTEN considered dangerous

2006-08-02 Thread Flemming Frandsen
On Wed, 2 Aug 2006, Tom Lane wrote: Flemming Frandsen [EMAIL PROTECTED] writes: The listen should simply listen for events issued at the start of the transaction it's executed in. BEGIN; SELECT sleep(10); LISTEN foo; No, I don't think so. And why would that

Re: [GENERAL] LISTEN considered dangerous

2006-08-02 Thread Flemming Frandsen
On Wed, 2 Aug 2006, Roman Neuhauser wrote: I'm bothered by listen listening from the end of the transaction in stead of the start of the transaction. Sorry if this isn't what you're after, instead just a question: Why don't you issue the LISTEN in a separate transaction before

[GENERAL] LISTEN considered dangerous

2006-08-01 Thread Flemming Frandsen
I have an application that does aggresive caching of data pulled from the database, it even keeps the objects cached between transactions. Normally this works very well and when the cache is warmed up about 90% of the database time is saved. However that leaves the problem of how to notice

Re: [GENERAL] LISTEN considered dangerous

2006-08-01 Thread Karsten Hilbert
On Tue, Aug 01, 2006 at 07:16:39PM +0200, Flemming Frandsen wrote: This way we could even have wildcard listens, imagine doing a listen % and getting all the generated events:) That'd be awesome. Along with a data field in the listen structure, please :-) Karsten -- GPG key ID E4071346 @

Re: [GENERAL] LISTEN considered dangerous

2006-08-01 Thread Ian Harding
On 8/1/06, Flemming Frandsen [EMAIL PROTECTED] wrote: I have an application that does aggresive caching of data pulled from the database, it even keeps the objects cached between transactions. Normally this works very well and when the cache is warmed up about 90% of the database time is saved.

Re: [GENERAL] LISTEN considered dangerous

2006-08-01 Thread Gregory Stark
Ian Harding [EMAIL PROTECTED] writes: However that just doesn't work, because listen is broken, allow me to illustrate, here A and B are two clients: A: BEGIN A: SELECT * FROM foo and cache the result. A: LISTEN foochange B: BEGIN B: update foo B: NOTIFY foochange B: COMMIT

Re: [GENERAL] LISTEN considered dangerous

2006-08-01 Thread Martijn van Oosterhout
On Tue, Aug 01, 2006 at 07:50:19PM -0400, Gregory Stark wrote: However that just doesn't work, because listen is broken, allow me to illustrate, here A and B are two clients: A: BEGIN A: SELECT * FROM foo and cache the result. A: LISTEN foochange B: BEGIN B: update foo

Re: [GENERAL] LISTEN considered dangerous

2006-08-01 Thread Flemming Frandsen
Ian Harding wrote: NOTIFY interacts with SQL transactions in some important ways. Firstly, if a NOTIFY is executed inside a transaction, the notify events are not delivered until and unless the transaction is committed. This is appropriate, since if the transaction is aborted, all the commands