Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit babef40

Browse files
committed
Teach walsender to update its process title for replication commands.
Because the code path taken for SQL commands executed in a walsender will update the process title, we pretty much have to update the title for replication commands as well. Otherwise, the title shows "idle" for the rest of a logical walsender's lifetime once it's executed any SQL command. Playing with this, I confirm that a walsender now typically spends most of its life reporting walsender postgres [local] START_REPLICATION Considering this in isolation, it might be better to have it say walsender postgres [local] sending replication data However, consistency with the other cases seems to be a stronger argument. In passing, remove duplicative pgstat_report_activity call. Discussion: https://postgr.es/m/880181.1600026471@sss.pgh.pa.us
1 parent add1058 commit babef40

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/backend/replication/walsender.c

+12-2
Original file line numberDiff line numberDiff line change
@@ -1616,25 +1616,29 @@ exec_replication_command(const char *cmd_string)
16161616
{
16171617
case T_IdentifySystemCmd:
16181618
cmdtag = "IDENTIFY_SYSTEM";
1619+
set_ps_display(cmdtag);
16191620
IdentifySystem();
16201621
EndReplicationCommand(cmdtag);
16211622
break;
16221623

16231624
case T_BaseBackupCmd:
16241625
cmdtag = "BASE_BACKUP";
1626+
set_ps_display(cmdtag);
16251627
PreventInTransactionBlock(true, cmdtag);
16261628
SendBaseBackup((BaseBackupCmd *) cmd_node);
16271629
EndReplicationCommand(cmdtag);
16281630
break;
16291631

16301632
case T_CreateReplicationSlotCmd:
16311633
cmdtag = "CREATE_REPLICATION_SLOT";
1634+
set_ps_display(cmdtag);
16321635
CreateReplicationSlot((CreateReplicationSlotCmd *) cmd_node);
16331636
EndReplicationCommand(cmdtag);
16341637
break;
16351638

16361639
case T_DropReplicationSlotCmd:
16371640
cmdtag = "DROP_REPLICATION_SLOT";
1641+
set_ps_display(cmdtag);
16381642
DropReplicationSlot((DropReplicationSlotCmd *) cmd_node);
16391643
EndReplicationCommand(cmdtag);
16401644
break;
@@ -1644,6 +1648,7 @@ exec_replication_command(const char *cmd_string)
16441648
StartReplicationCmd *cmd = (StartReplicationCmd *) cmd_node;
16451649

16461650
cmdtag = "START_REPLICATION";
1651+
set_ps_display(cmdtag);
16471652
PreventInTransactionBlock(true, cmdtag);
16481653

16491654
if (cmd->kind == REPLICATION_KIND_PHYSICAL)
@@ -1659,6 +1664,7 @@ exec_replication_command(const char *cmd_string)
16591664

16601665
case T_TimeLineHistoryCmd:
16611666
cmdtag = "TIMELINE_HISTORY";
1667+
set_ps_display(cmdtag);
16621668
PreventInTransactionBlock(true, cmdtag);
16631669
SendTimeLineHistory((TimeLineHistoryCmd *) cmd_node);
16641670
EndReplicationCommand(cmdtag);
@@ -1670,6 +1676,7 @@ exec_replication_command(const char *cmd_string)
16701676
VariableShowStmt *n = (VariableShowStmt *) cmd_node;
16711677

16721678
cmdtag = "SHOW";
1679+
set_ps_display(cmdtag);
16731680

16741681
/* syscache access needs a transaction environment */
16751682
StartTransactionCommand();
@@ -1688,8 +1695,11 @@ exec_replication_command(const char *cmd_string)
16881695
MemoryContextSwitchTo(old_context);
16891696
MemoryContextDelete(cmd_context);
16901697

1691-
/* Report to pgstat that this process is now idle */
1692-
pgstat_report_activity(STATE_IDLE, NULL);
1698+
/*
1699+
* We need not update ps display or pg_stat_activity, because PostgresMain
1700+
* will reset those to "idle". But we must reset debug_query_string to
1701+
* ensure it doesn't become a dangling pointer.
1702+
*/
16931703
debug_query_string = NULL;
16941704

16951705
return true;

0 commit comments

Comments
 (0)