]> granicus.if.org Git - postgresql/commitdiff
Fix logical replication launcher wake up and reset
authorPeter Eisentraut <peter_e@gmx.net>
Mon, 1 May 2017 14:18:09 +0000 (10:18 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Mon, 1 May 2017 14:18:09 +0000 (10:18 -0400)
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: Fujii Masao <masao.fujii@gmail.com>
src/backend/access/transam/xact.c
src/backend/replication/logical/launcher.c
src/include/replication/logicallauncher.h

index 605639b0c3d57011ba4eba3a4497583a58f443ba..a3ff1b22f07ef47ce6bee3d199153ccb027c02d8 100644 (file)
@@ -2138,7 +2138,7 @@ CommitTransaction(void)
        AtEOXact_HashTables(true);
        AtEOXact_PgStat(true);
        AtEOXact_Snapshot(true, false);
-       AtCommit_ApplyLauncher();
+       AtEOXact_ApplyLauncher(true);
        pgstat_report_xact_timestamp(0);
 
        CurrentResourceOwner = NULL;
@@ -2612,6 +2612,7 @@ AbortTransaction(void)
                AtEOXact_ComboCid();
                AtEOXact_HashTables(false);
                AtEOXact_PgStat(false);
+               AtEOXact_ApplyLauncher(false);
                pgstat_report_xact_timestamp(0);
        }
 
index f5058d5a9acdfa09b98f097a6c9ffe65415d68aa..09c87d7c53a8013e21f73a379f111f8fe92e17e8 100644 (file)
@@ -748,10 +748,12 @@ ApplyLauncherShmemInit(void)
  * Wakeup the launcher on commit if requested.
  */
 void
-AtCommit_ApplyLauncher(void)
+AtEOXact_ApplyLauncher(bool isCommit)
 {
-       if (on_commit_launcher_wakeup)
+       if (isCommit && on_commit_launcher_wakeup)
                ApplyLauncherWakeup();
+
+       on_commit_launcher_wakeup = false;
 }
 
 /*
index 0c2bf03a5fe9f98d0039edceafb561dfecea8122..fb3c2f53709b3c2b0f431f59a3f3695da694e5bf 100644 (file)
@@ -22,6 +22,6 @@ extern Size ApplyLauncherShmemSize(void);
 extern void ApplyLauncherShmemInit(void);
 
 extern void ApplyLauncherWakeupAtCommit(void);
-extern void AtCommit_ApplyLauncher(void);
+extern void AtEOXact_ApplyLauncher(bool isCommit);
 
 #endif   /* LOGICALLAUNCHER_H */