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

Commit377d1b9

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 parent2950544 commit377d1b9

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
@@ -1721,11 +1721,13 @@ HandleNotifyInterrupt(void)
17211721
/*
17221722
* ProcessNotifyInterrupt
17231723
*
1724-
*This is called just after waiting for a frontend command. If a
1725-
*interrupt arrives (via HandleNotifyInterrupt()) while reading, the
1726-
*read will be interrupted via the process's latch, and this routine
1727-
*will get called. If we are truly idle (ie, *not* inside a transaction
1728-
*block), process the incoming notifies.
1724+
*This is called if we see notifyInterruptPending set, just before
1725+
*transmitting ReadyForQuery at the end of a frontend command, and
1726+
*also if a notify signal occurs while reading from the frontend.
1727+
*HandleNotifyInterrupt() will cause the read to be interrupted
1728+
*via the process's latch, and this routine will get called.
1729+
*If we are truly idle (ie, *not* inside a transaction block),
1730+
*process the incoming notifies.
17291731
*/
17301732
void
17311733
ProcessNotifyInterrupt(void)

‎src/backend/tcop/postgres.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4099,7 +4099,18 @@ PostgresMain(int argc, char *argv[],
40994099
}
41004100
else
41014101
{
4102+
/* Send out notify signals and transmit self-notifies */
41024103
ProcessCompletedNotifies();
4104+
4105+
/*
4106+
* Also process incoming notifies, if any. This is mostly to
4107+
* ensure stable behavior in tests: if any notifies were
4108+
* received during the just-finished transaction, they'll be
4109+
* seen by the client before ReadyForQuery is.
4110+
*/
4111+
if (notifyInterruptPending)
4112+
ProcessNotifyInterrupt();
4113+
41034114
pgstat_report_stat(false);
41044115

41054116
set_ps_display("idle", false);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp