Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc47f498

Browse files
committed
Stabilize NOTIFY behavior by transmitting notifies before ReadyForQuery.
This patch ensures that, if any notify messages were received duringa just-finished transaction, they get sent to the frontend just beforenot just after the ReadyForQuery message. With libpq and other clientlibraries that act similarly, this guarantees that the client will seethe notify messages as available as soon as it thinks the transactionis done.This probably makes no difference in practice, since in realisticuse-cases the application would have to cope with asynchronousarrival of notify events anyhow. However, it makes it a lot easierto build cross-session-notify test cases with stable behavior.I'm a bit surprised now that we've not seen any buildfarm instabilitywith the test cases added by commitb10f40b. Tests that I intendto add in an upcoming bug fix are definitely unstable without this.Back-patch to 9.6, which is as far back as we can do NOTIFY testingwith the isolationtester infrastructure.Discussion:https://postgr.es/m/13881.1574557302@sss.pgh.pa.us
1 parent7d4c311 commitc47f498

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

‎src/backend/commands/async.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,11 +1720,13 @@ HandleNotifyInterrupt(void)
17201720
/*
17211721
* ProcessNotifyInterrupt
17221722
*
1723-
*This is called just after waiting for a frontend command. If a
1724-
*interrupt arrives (via HandleNotifyInterrupt()) while reading, the
1725-
*read will be interrupted via the process's latch, and this routine
1726-
*will get called. If we are truly idle (ie, *not* inside a transaction
1727-
*block), process the incoming notifies.
1723+
*This is called if we see notifyInterruptPending set, just before
1724+
*transmitting ReadyForQuery at the end of a frontend command, and
1725+
*also if a notify signal occurs while reading from the frontend.
1726+
*HandleNotifyInterrupt() will cause the read to be interrupted
1727+
*via the process's latch, and this routine will get called.
1728+
*If we are truly idle (ie, *not* inside a transaction block),
1729+
*process the incoming notifies.
17281730
*/
17291731
void
17301732
ProcessNotifyInterrupt(void)

‎src/backend/tcop/postgres.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4153,7 +4153,18 @@ PostgresMain(int argc, char *argv[],
41534153
}
41544154
else
41554155
{
4156+
/* Send out notify signals and transmit self-notifies */
41564157
ProcessCompletedNotifies();
4158+
4159+
/*
4160+
* Also process incoming notifies, if any. This is mostly to
4161+
* ensure stable behavior in tests: if any notifies were
4162+
* received during the just-finished transaction, they'll be
4163+
* seen by the client before ReadyForQuery is.
4164+
*/
4165+
if (notifyInterruptPending)
4166+
ProcessNotifyInterrupt();
4167+
41574168
pgstat_report_stat(false);
41584169

41594170
set_ps_display("idle", false);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp