Commit 9414e41e authored by Peter Eisentraut's avatar Peter Eisentraut

Fix logical replication launcher wake up and reset

After the logical replication launcher was told to wake up at
commit (for example, by a CREATE SUBSCRIPTION command), the flag to wake
up was not reset, so it would be woken up at every following commit as
well.  So fix that by resetting the flag.

Also, we don't need to wake up anything if the transaction was rolled
back.  Just reset the flag in that case.

Author: Masahiko Sawada <sawada.mshk@gmail.com>
Reported-by: default avatarFujii Masao <masao.fujii@gmail.com>
parent e180c8aa
...@@ -2138,7 +2138,7 @@ CommitTransaction(void) ...@@ -2138,7 +2138,7 @@ CommitTransaction(void)
AtEOXact_HashTables(true); AtEOXact_HashTables(true);
AtEOXact_PgStat(true); AtEOXact_PgStat(true);
AtEOXact_Snapshot(true, false); AtEOXact_Snapshot(true, false);
AtCommit_ApplyLauncher(); AtEOXact_ApplyLauncher(true);
pgstat_report_xact_timestamp(0); pgstat_report_xact_timestamp(0);
CurrentResourceOwner = NULL; CurrentResourceOwner = NULL;
...@@ -2612,6 +2612,7 @@ AbortTransaction(void) ...@@ -2612,6 +2612,7 @@ AbortTransaction(void)
AtEOXact_ComboCid(); AtEOXact_ComboCid();
AtEOXact_HashTables(false); AtEOXact_HashTables(false);
AtEOXact_PgStat(false); AtEOXact_PgStat(false);
AtEOXact_ApplyLauncher(false);
pgstat_report_xact_timestamp(0); pgstat_report_xact_timestamp(0);
} }
......
...@@ -748,10 +748,12 @@ ApplyLauncherShmemInit(void) ...@@ -748,10 +748,12 @@ ApplyLauncherShmemInit(void)
* Wakeup the launcher on commit if requested. * Wakeup the launcher on commit if requested.
*/ */
void void
AtCommit_ApplyLauncher(void) AtEOXact_ApplyLauncher(bool isCommit)
{ {
if (on_commit_launcher_wakeup) if (isCommit && on_commit_launcher_wakeup)
ApplyLauncherWakeup(); ApplyLauncherWakeup();
on_commit_launcher_wakeup = false;
} }
/* /*
......
...@@ -22,6 +22,6 @@ extern Size ApplyLauncherShmemSize(void); ...@@ -22,6 +22,6 @@ extern Size ApplyLauncherShmemSize(void);
extern void ApplyLauncherShmemInit(void); extern void ApplyLauncherShmemInit(void);
extern void ApplyLauncherWakeupAtCommit(void); extern void ApplyLauncherWakeupAtCommit(void);
extern void AtCommit_ApplyLauncher(void); extern void AtEOXact_ApplyLauncher(bool isCommit);
#endif /* LOGICALLAUNCHER_H */ #endif /* LOGICALLAUNCHER_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment