diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 441445927e..8ddf77b5f7 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -2996,6 +2996,8 @@ CommitTransactionCommand(void)
 			s->blockState = TBLOCK_DEFAULT;
 			if (s->chain)
 			{
+				ProcessNotifiesAndStat();
+
 				StartTransaction();
 				s->blockState = TBLOCK_INPROGRESS;
 				s->chain = false;
@@ -3022,6 +3024,8 @@ CommitTransactionCommand(void)
 			s->blockState = TBLOCK_DEFAULT;
 			if (s->chain)
 			{
+				ProcessNotifiesAndStat();
+
 				StartTransaction();
 				s->blockState = TBLOCK_INPROGRESS;
 				s->chain = false;
@@ -3040,6 +3044,8 @@ CommitTransactionCommand(void)
 			s->blockState = TBLOCK_DEFAULT;
 			if (s->chain)
 			{
+				ProcessNotifiesAndStat();
+
 				StartTransaction();
 				s->blockState = TBLOCK_INPROGRESS;
 				s->chain = false;
@@ -3107,6 +3113,8 @@ CommitTransactionCommand(void)
 				s->blockState = TBLOCK_DEFAULT;
 				if (s->chain)
 				{
+					ProcessNotifiesAndStat();
+
 					StartTransaction();
 					s->blockState = TBLOCK_INPROGRESS;
 					s->chain = false;
@@ -6118,3 +6126,21 @@ MarkSubTransactionAssigned(void)
 
 	CurrentTransactionState->assigned = true;
 }
+
+void
+ProcessNotifiesAndStat(void)
+{
+	/* Send out notify signals and transmit self-notifies */
+	ProcessCompletedNotifies();
+
+	/*
+	 * Also process incoming notifies, if any.  This is mostly to
+	 * ensure stable behavior in tests: if any notifies were
+	 * received during the just-finished transaction, they'll be
+	 * seen by the client before ReadyForQuery is.
+	 */
+	if (notifyInterruptPending)
+		ProcessNotifyInterrupt();
+
+	pgstat_report_stat(false);
+}
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 8cea10c901..076b7f4c07 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -4371,19 +4371,7 @@ PostgresMain(int argc, char *argv[],
 			}
 			else
 			{
-				/* Send out notify signals and transmit self-notifies */
-				ProcessCompletedNotifies();
-
-				/*
-				 * Also process incoming notifies, if any.  This is mostly to
-				 * ensure stable behavior in tests: if any notifies were
-				 * received during the just-finished transaction, they'll be
-				 * seen by the client before ReadyForQuery is.
-				 */
-				if (notifyInterruptPending)
-					ProcessNotifyInterrupt();
-
-				pgstat_report_stat(false);
+				ProcessNotifiesAndStat();
 
 				set_ps_display("idle");
 				pgstat_report_activity(STATE_IDLE, NULL);
diff --git a/src/include/access/xact.h b/src/include/access/xact.h
index 134f6862da..8336c80e5f 100644
--- a/src/include/access/xact.h
+++ b/src/include/access/xact.h
@@ -467,4 +467,6 @@ extern void EnterParallelMode(void);
 extern void ExitParallelMode(void);
 extern bool IsInParallelMode(void);
 
+extern void ProcessNotifiesAndStat(void);
+
 #endif							/* XACT_H */
