Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbabef40

Browse files
committed
Teach walsender to update its process title for replication commands.
Because the code path taken for SQL commands executed in a walsenderwill update the process title, we pretty much have to update thetitle for replication commands as well. Otherwise, the title shows"idle" for the rest of a logical walsender's lifetime once it'sexecuted any SQL command.Playing with this, I confirm that a walsender now typically spendsmost of its life reportingwalsender postgres [local] START_REPLICATIONConsidering this in isolation, it might be better to have it saywalsender postgres [local] sending replication dataHowever, consistency with the other cases seems to be a strongerargument.In passing, remove duplicative pgstat_report_activity call.Discussion:https://postgr.es/m/880181.1600026471@sss.pgh.pa.us
1 parentadd1058 commitbabef40

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

‎src/backend/replication/walsender.c

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

16231624
caseT_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
caseT_CreateReplicationSlotCmd:
16311633
cmdtag="CREATE_REPLICATION_SLOT";
1634+
set_ps_display(cmdtag);
16321635
CreateReplicationSlot((CreateReplicationSlotCmd*)cmd_node);
16331636
EndReplicationCommand(cmdtag);
16341637
break;
16351638

16361639
caseT_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
caseT_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)

[8]ページ先頭

©2009-2025 Movatter.jp