@@ -1106,6 +1106,7 @@ LIMIT %d", TASK_BATCH_SIZE);
11061106
11071107 PopActiveSnapshot ();
11081108 CommitTransactionCommand ();
1109+ pgstat_report_stat (false);
11091110 return ;
11101111 }
11111112
@@ -1195,6 +1196,7 @@ LIMIT %d", TASK_BATCH_SIZE);
11951196 ereport (ERROR , (errmsg ("SPI_finish failed" )));
11961197 PopActiveSnapshot ();
11971198 CommitTransactionCommand ();
1199+ pgstat_report_stat (false);
11981200 }
11991201
12001202 /* Now process the tasks. */
@@ -1511,8 +1513,8 @@ run_command(char *command, int rc)
15111513 SPI_connect ();
15121514 PushActiveSnapshot (GetTransactionSnapshot ());
15131515 pgstat_report_activity (STATE_RUNNING , command );
1514-
15151516 ret = SPI_execute (command , false, 0 );
1517+ pgstat_report_activity (STATE_IDLE , NULL );
15161518 if (ret != rc )
15171519 elog (ERROR , "command failed: %s" , command );
15181520
@@ -1528,9 +1530,7 @@ run_command(char *command, int rc)
15281530 SPI_finish ();
15291531 PopActiveSnapshot ();
15301532 CommitTransactionCommand ();
1531-
15321533 pgstat_report_stat (false);
1533- pgstat_report_activity (STATE_IDLE , NULL );
15341534
15351535 return ntup ;
15361536}
0 commit comments