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

Commitbf68b79

Browse files
committed
Refactor ps_status.c API
The init_ps_display() arguments were mostly lies by now, so to matchtypical usage, just use one argument and let the caller assemble itfrom multiple sources if necessary. The only user of the additionalarguments is BackendInitialize(), which was already doing stringassembly on the caller side anyway.Remove the second argument of set_ps_display() ("force") and justhandle that in init_ps_display() internally.BackendInitialize() also used to set the initial status as"authentication", but that was very far from where authenticationactually happened. So now it's set to "initializing" and then"authentication" just before the actual call toClientAuthentication().Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>Reviewed-by: Kuntal Ghosh <kuntalghosh.2007@gmail.com>Reviewed-by: Alvaro Herrera <alvherre@2ndquadrant.com>Discussion:https://www.postgresql.org/message-id/flat/c65e5196-4f04-4ead-9353-6088c19615a3@2ndquadrant.com
1 parent899a04f commitbf68b79

File tree

19 files changed

+71
-71
lines changed

19 files changed

+71
-71
lines changed

‎src/backend/access/transam/xlog.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3648,7 +3648,7 @@ XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli,
36483648
/* Report recovery progress in PS display */
36493649
snprintf(activitymsg,sizeof(activitymsg),"waiting for %s",
36503650
xlogfname);
3651-
set_ps_display(activitymsg, false);
3651+
set_ps_display(activitymsg);
36523652

36533653
restoredFromArchive=RestoreArchivedFile(path,xlogfname,
36543654
"RECOVERYXLOG",
@@ -3691,7 +3691,7 @@ XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli,
36913691
/* Report recovery progress in PS display */
36923692
snprintf(activitymsg,sizeof(activitymsg),"recovering %s",
36933693
xlogfname);
3694-
set_ps_display(activitymsg, false);
3694+
set_ps_display(activitymsg);
36953695

36963696
/* Track source of data in assorted state variables */
36973697
readSource=source;

‎src/backend/bootstrap/bootstrap.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ AuxiliaryProcessMain(int argc, char *argv[])
342342
statmsg="??? process";
343343
break;
344344
}
345-
init_ps_display(statmsg,"","","");
345+
init_ps_display(statmsg);
346346
}
347347

348348
/* Acquire configuration parameters, unless inherited from postmaster */

‎src/backend/commands/async.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2225,7 +2225,7 @@ ProcessIncomingNotify(void)
22252225
if (Trace_notify)
22262226
elog(DEBUG1,"ProcessIncomingNotify");
22272227

2228-
set_ps_display("notify interrupt", false);
2228+
set_ps_display("notify interrupt");
22292229

22302230
/*
22312231
* We must run asyncQueueReadAllNotifications inside a transaction, else
@@ -2242,7 +2242,7 @@ ProcessIncomingNotify(void)
22422242
*/
22432243
pq_flush();
22442244

2245-
set_ps_display("idle", false);
2245+
set_ps_display("idle");
22462246

22472247
if (Trace_notify)
22482248
elog(DEBUG1,"ProcessIncomingNotify: done");

‎src/backend/postmaster/autovacuum.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ AutoVacLauncherMain(int argc, char *argv[])
434434
am_autovacuum_launcher= true;
435435

436436
/* Identify myself via ps */
437-
init_ps_display(pgstat_get_backend_desc(B_AUTOVAC_LAUNCHER),"","","");
437+
init_ps_display(pgstat_get_backend_desc(B_AUTOVAC_LAUNCHER));
438438

439439
ereport(DEBUG1,
440440
(errmsg("autovacuum launcher started")));
@@ -1507,7 +1507,7 @@ AutoVacWorkerMain(int argc, char *argv[])
15071507
am_autovacuum_worker= true;
15081508

15091509
/* Identify myself via ps */
1510-
init_ps_display(pgstat_get_backend_desc(B_AUTOVAC_WORKER),"","","");
1510+
init_ps_display(pgstat_get_backend_desc(B_AUTOVAC_WORKER));
15111511

15121512
SetProcessingMode(InitProcessing);
15131513

@@ -1680,7 +1680,7 @@ AutoVacWorkerMain(int argc, char *argv[])
16801680
*/
16811681
InitPostgres(NULL,dbid,NULL,InvalidOid,dbname, false);
16821682
SetProcessingMode(NormalProcessing);
1683-
set_ps_display(dbname, false);
1683+
set_ps_display(dbname);
16841684
ereport(DEBUG1,
16851685
(errmsg("autovacuum: processing database \"%s\"",dbname)));
16861686

‎src/backend/postmaster/bgworker.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ StartBackgroundWorker(void)
689689
IsBackgroundWorker= true;
690690

691691
/* Identify myself via ps */
692-
init_ps_display(worker->bgw_name,"","","");
692+
init_ps_display(worker->bgw_name);
693693

694694
/*
695695
* If we're not supposed to have shared memory access, then detach from

‎src/backend/postmaster/pgarch.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ PgArchiverMain(int argc, char *argv[])
241241
/*
242242
* Identify myself via ps
243243
*/
244-
init_ps_display("archiver","","","");
244+
init_ps_display("archiver");
245245

246246
pgarch_MainLoop();
247247

@@ -584,7 +584,7 @@ pgarch_archiveXlog(char *xlog)
584584

585585
/* Report archive activity in PS display */
586586
snprintf(activitymsg,sizeof(activitymsg),"archiving %s",xlog);
587-
set_ps_display(activitymsg, false);
587+
set_ps_display(activitymsg);
588588

589589
rc=system(xlogarchcmd);
590590
if (rc!=0)
@@ -634,14 +634,14 @@ pgarch_archiveXlog(char *xlog)
634634
}
635635

636636
snprintf(activitymsg,sizeof(activitymsg),"failed on %s",xlog);
637-
set_ps_display(activitymsg, false);
637+
set_ps_display(activitymsg);
638638

639639
return false;
640640
}
641641
elog(DEBUG1,"archived write-ahead log file \"%s\"",xlog);
642642

643643
snprintf(activitymsg,sizeof(activitymsg),"last was %s",xlog);
644-
set_ps_display(activitymsg, false);
644+
set_ps_display(activitymsg);
645645

646646
return true;
647647
}

‎src/backend/postmaster/pgstat.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4450,7 +4450,7 @@ PgstatCollectorMain(int argc, char *argv[])
44504450
/*
44514451
* Identify myself via ps
44524452
*/
4453-
init_ps_display("stats collector","","","");
4453+
init_ps_display("stats collector");
44544454

44554455
/*
44564456
* Read in existing stats files or initialize the stats to zero.

‎src/backend/postmaster/postmaster.c‎

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4282,7 +4282,7 @@ BackendInitialize(Port *port)
42824282
intret;
42834283
charremote_host[NI_MAXHOST];
42844284
charremote_port[NI_MAXSERV];
4285-
charremote_ps_data[NI_MAXHOST];
4285+
StringInfoDataps_data;
42864286

42874287
/* Save port etc. for ps status */
42884288
MyProcPort=port;
@@ -4346,10 +4346,6 @@ BackendInitialize(Port *port)
43464346
ereport(WARNING,
43474347
(errmsg_internal("pg_getnameinfo_all() failed: %s",
43484348
gai_strerror(ret))));
4349-
if (remote_port[0]=='\0')
4350-
snprintf(remote_ps_data,sizeof(remote_ps_data),"%s",remote_host);
4351-
else
4352-
snprintf(remote_ps_data,sizeof(remote_ps_data),"%s(%s)",remote_host,remote_port);
43534349

43544350
/*
43554351
* Save remote_host and remote_port in port structure (after this, they
@@ -4423,21 +4419,21 @@ BackendInitialize(Port *port)
44234419
/*
44244420
* Now that we have the user and database name, we can set the process
44254421
* title for ps. It's good to do this as early as possible in startup.
4426-
*
4427-
* For a walsender, the ps display is set in the following form:
4428-
*
4429-
* postgres: walsender <user> <host> <activity>
4430-
*
4431-
* To achieve that, we pass "walsender" as username and username as dbname
4432-
* to init_ps_display(). XXX: should add a new variant of
4433-
* init_ps_display() to avoid abusing the parameters like this.
44344422
*/
4423+
initStringInfo(&ps_data);
44354424
if (am_walsender)
4436-
init_ps_display(pgstat_get_backend_desc(B_WAL_SENDER),port->user_name,remote_ps_data,
4437-
update_process_title ?"authentication" :"");
4438-
else
4439-
init_ps_display(port->user_name,port->database_name,remote_ps_data,
4440-
update_process_title ?"authentication" :"");
4425+
appendStringInfo(&ps_data,"%s ",pgstat_get_backend_desc(B_WAL_SENDER));
4426+
appendStringInfo(&ps_data,"%s ",port->user_name);
4427+
if (!am_walsender)
4428+
appendStringInfo(&ps_data,"%s ",port->database_name);
4429+
appendStringInfo(&ps_data,"%s",port->remote_host);
4430+
if (port->remote_port[0]!='\0')
4431+
appendStringInfo(&ps_data,"(%s)",port->remote_port);
4432+
4433+
init_ps_display(ps_data.data);
4434+
pfree(ps_data.data);
4435+
4436+
set_ps_display("initializing");
44414437

44424438
/*
44434439
* Disable the timeout, and prevent SIGTERM/SIGQUIT again.

‎src/backend/postmaster/syslogger.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ SysLoggerMain(int argc, char *argv[])
179179

180180
am_syslogger= true;
181181

182-
init_ps_display("logger","","","");
182+
init_ps_display("logger");
183183

184184
/*
185185
* If we restarted, our stderr is already redirected into our own input

‎src/backend/replication/basebackup.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ SendBaseBackup(BaseBackupCmd *cmd)
828828

829829
snprintf(activitymsg,sizeof(activitymsg),"sending backup \"%s\"",
830830
opt.label);
831-
set_ps_display(activitymsg, false);
831+
set_ps_display(activitymsg);
832832
}
833833

834834
perform_base_backup(&opt);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp