Re: NOTIFY does not work as expected
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Jeff Janes <jeff.janes@gmail.com>, Andrey <parihaaraka@gmail.com>, Pg Bugs <pgsql-bugs@postgresql.org>
Date: 2018-07-03T19:09:18Z
Lists: pgsql-bugs
On 2018-07-03 14:27:04 -0400, Tom Lane wrote: > Jeff Janes <jeff.janes@gmail.com> writes: > > Further diagnosis here is that in the "working" case the client receives a > > single packet from the server containing both the pg_sleep response, and > > async response, in that order, and the client processes both of them. In > > the "broken" case, the client receives a single packet from the server > > containing the pg_sleep response, and processes it, and then blocks on user > > input. The async response is immediately available in the next packet if > > the client would ask for it, but the client doesn't do so. > > This suggests that 4f85fde8e introduced an extra output-flush operation > into the code path, ie it must be flushing the output buffer to the client > after ReadyForQuery and then again after emitting the Notify. Hm. There's indeed a /* * Must flush the notify messages to ensure frontend gets them promptly. */ pq_flush(); in ProcessIncomingNotify(). But that was there before, too. And I don't see any argument why it'd be a good idea to remove it? > > If I am diagnosing the right problem, this still doesn't seem like a bug to > > me. > > Well, it seems undesirable to me, both because it implies network traffic > inefficiency and because clients don't seem to be expecting it. A report after ~3 years doesn't strike me as a huge argument for that, and it doesn't seem crazy to believe it'd hurt some users changing that. And when would you avoid flushing? > We have another recent complaint that seems to be possibly the > same thing, bug #15255. That seems more related to the logical replication apply code than anything? Greetings, Andres Freund
Commits
-
Client-side fixes for delayed NOTIFY receipt.
- ecc59e31a81e 10.6 landed
- d30d27a52818 11.1 landed
- ac3be116a798 9.5.15 landed
- 4247db62522f 12.0 landed
- 34aad21cbf03 9.6.11 landed
-
Server-side fix for delayed NOTIFY and SIGTERM processing.
- f4941666afc6 9.5.15 landed
- cbab94077e12 9.6.11 landed
- 7aaeb7b45ac7 11.1 landed
- 3bdef6d21131 10.6 landed
- 2ddb9149d14d 12.0 landed
-
Introduce and use infrastructure for interrupt processing during client reads.
- 4f85fde8eb86 9.5.0 cited