Re: NOTIFY does not work as expected
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Andrey <parihaaraka@gmail.com>, Jeff Janes <jeff.janes@gmail.com>,
Pg Bugs <pgsql-bugs@postgresql.org>
Date: 2018-10-19T17:36:31Z
Lists: pgsql-bugs
Attachments
- 0001-server-notify-fix-2.patch (text/x-diff) patch 0001
I wrote: > Andres Freund <andres@anarazel.de> writes: >> That distinction was introduced because people (IIRC you actually) were >> worried that we'd be less likely to get error messages out to the >> client. Especially when you check unconditionally before actually doing >> the write, it's going to be far less likely that we are able to send >> something out to the client. > Far less likely than what? If we got a ProcDie signal we'd more often > than not have handled it long before reaching here. If we hadn't, though, > we could arrive here with ProcDiePending set but the latch clear, in which > case we fail to honor the interrupt until the client does something. > Don't really think that's acceptable :-(. I'm also not seeing why it's > okay to commit ProcDie hara-kiri immediately if the socket is > write-blocked but not otherwise --- the two cases are going to look about > the same from the client side. I spent some more time thinking about this. It's possible to fix the bug while preserving the current behavior for ProcDiePending if we adjust the ProcessClientXXXInterrupt code to set the process latch in the cases where ProcDiePending is true but we're not waiting for the socket to come ready. See attached variant of 0001. I am not, however, convinced that this is better rather than just more complicated. If we're willing to accept a ProcDie interrupt during secure_read at all, I don't see why not to do it even if we got some data. We'll accept the interrupt anyway the next time something happens to do CHECK_FOR_INTERRUPTS; and it's unlikely that that would not be till after we'd completed the query, so the net effect is just going to be that we waste some cycles first. Likewise, I see little merit in holding off ProcDie during secure_write. If we could try to postpone the interrupt until a message boundary, so as to avoid losing protocol sync, there would be value in that --- but this code is at the wrong level to implement any such behavior, and it's not trying to. So we still have the situation that the interrupt service is being postponed without any identifiable gain in predictability of behavior. In short, I don't think that the existing logic here does anything useful to meet the concern I had, and so I wouldn't mind throwing it away. regards, tom lane PS: this patch extends the ProcessClientXXXInterrupt API to distinguish before/during/after calls. As written, there are only two behaviors so we could've stuck with the bool API, but I thought this was clearer.
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