From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andrey <parihaaraka(at)gmail(dot)com> |
Cc: | Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, andres(at)anarazel(dot)de, Pg Bugs <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: NOTIFY does not work as expected |
Date: | 2018-10-18 22:39:34 |
Message-ID: | 29914.1539902374@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Andrey <parihaaraka(at)gmail(dot)com> writes:
> Hello. I beg your pardon, but the problem is still in 10.5. May we expect
> it to be fixed in 11?
Nope :-(. However, I got around to looking at this problem, and I concur
with Jeff's diagnosis: the code around ProcessClientReadInterrupt is
buggy because it does not account for the possibility that the process
latch was cleared some time ago while unhandled interrupt-pending flags
remain set. There are some other issues too:
1. ProcessClientWriteInterrupt has the same problem.
2. I don't believe the "blocked" vs "not-blocked" distinction one bit.
At best, it creates race-condition-like changes in behavior depending
on exactly when a signal arrives vs when data arrives or is sent.
At worst, I think it creates the same problem it's purporting to solve,
ie failure to respond to ProcDiePending at all. I think the
before/during/after calls to ProcessClientXXXInterrupt should just all
behave the same and always be willing to execute ProcDiePending.
3. We've got bugs on the client side too. The documentation is pretty
clear that libpq users ought to call PQconsumeInput before PQnotifies,
but psql had not read the manual at all. Also, most callers were
calling PQconsumeInput only once and then looping on PQnotifies, which
assumes not-very-safely that we could only see at most one TCP packet
worth of notify messages at a time. That's even less safe now that
we have "payload" strings than it was before. So we ought to adjust
the code and documentation to recommend doing another PQconsumeInput
inside the loop. (Congratulations to dblink for getting this right.)
In short, I think we need something like the attached. With these
patches, psql consistently reports the notification promptly (for
me anyway).
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
0001-server-notify-fix.patch | text/x-diff | 5.3 KB |
0002-client-notify-fix.patch | text/x-diff | 3.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2018-10-18 22:46:08 | Re: NOTIFY does not work as expected |
Previous Message | PG Bug reporting form | 2018-10-18 18:36:42 | BUG #15438: Standby corruption after "Too many open files in system" error |