提交 f26b5799 编写于 作者: T Taylor Vesely

Fix ps display issues

Without this change, ps display of postmaster child processes may get
mangled.  E.g.

postgres: 15432, gpadmin isolation2test [local] con14 cmd52 con14 cm?~??????X???

This change uses the GPDB specific function get_real_act_ps_display()
to get the ps display string before it is modified.

This change also sets Gp_role of FTS daemon process to utility instead
of the default value of dispatch.  That prevents appending "conXXX" to
FTS daemon's ps display.
Co-authored-by: NAsim R P <apraveen@pivotal.io>
上级 d97eee65
......@@ -72,6 +72,7 @@
/* maximum number of segments */
#define MAX_NUM_OF_SEGMENTS 32768
bool am_ftsprobe = false;
bool am_ftshandler = false;
#define GpConfigHistoryRelName "gp_configuration_history"
......@@ -81,7 +82,6 @@ bool am_ftshandler = false;
* STATIC VARIABLES
*/
static bool am_ftsprobe = false;
static bool skipFtsProbe = false;
static volatile bool shutdown_requested = false;
......
......@@ -84,9 +84,8 @@ static bool SyncRepQueueIsOrderedByLSN(int mode);
void
SyncRepWaitForLSN(XLogRecPtr XactCommitLSN)
{
const char *old_status;
char *old_status_saved = NULL;
int len=0;
char *new_status = NULL;
const char *old_status;
int mode = SyncRepWaitMode;
bool syncStandbyPresent = false;
int i = 0;
......@@ -204,16 +203,19 @@ SyncRepWaitForLSN(XLogRecPtr XactCommitLSN)
/* Alter ps display to show waiting for sync rep. */
if (update_process_title)
{
char activitymsg[35];
int len;
snprintf(activitymsg, sizeof(activitymsg), " waiting for %X/%X replication",
old_status = get_real_act_ps_display(&len);
/*
* The 32 represents the bytes in the string " waiting for %X/%X", as
* in upstream. The 12 represents GPDB specific " replication" suffix.
*/
new_status = (char *) palloc(len + 32 + 12 + 1);
memcpy(new_status, old_status, len);
sprintf(new_status + len, " waiting for %X/%X replication",
XactCommitLSN.xlogid, XactCommitLSN.xrecoff);
old_status = get_ps_display(&len);
old_status_saved = (char *) palloc(len + 1);
Assert (old_status_saved);
memcpy(old_status_saved, old_status, len);
set_ps_display(activitymsg, false);
set_ps_display(new_status, false);
new_status[len] = '\0'; /* truncate off " waiting ..." */
}
/* Inform this backend is waiting for replication to pg_stat_activity */
......@@ -340,11 +342,11 @@ SyncRepWaitForLSN(XLogRecPtr XactCommitLSN)
MyProc->waitLSN.xlogid = 0;
MyProc->waitLSN.xrecoff = 0;
if (update_process_title)
if (new_status)
{
Assert(old_status_saved);
set_ps_display(old_status_saved, false);
pfree(old_status_saved);
/* Reset ps display */
set_ps_display(new_status, false);
pfree(new_status);
}
/* Now inform no more waiting for replication */
......
......@@ -218,7 +218,7 @@ ResolveRecoveryConflictWithVirtualXIDs(VirtualTransactionId *waitlist,
const char *old_status;
int len;
old_status = get_ps_display(&len);
old_status = get_real_act_ps_display(&len);
new_status = (char *) palloc(len + 8 + 1);
memcpy(new_status, old_status, len);
strcpy(new_status + len, " waiting");
......
......@@ -277,11 +277,12 @@ InitProcess(void)
int i;
/*
* Autovacuum, WAL sender and FTS handler processes are marked as
* GP_ROLE_UTILITY to prevent unwanted GP_ROLE_DISPATCH MyProc settings
* Autovacuum, WAL sender, FTS handler and FTS daemon processes are marked
* as GP_ROLE_UTILITY to prevent unwanted GP_ROLE_DISPATCH MyProc settings
* such as mppSessionId being valid and mppIsWriter set to true.
*/
if (IsAutoVacuumWorkerProcess() || am_walsender || am_ftshandler)
if (IsAutoVacuumWorkerProcess() || am_walsender || am_ftshandler ||
am_ftsprobe)
Gp_role = GP_ROLE_UTILITY;
/*
......
......@@ -1022,7 +1022,7 @@ ResWaitOnLock(LOCALLOCK *locallock, ResourceOwner owner, ResPortalIncrement *inc
/* Report change to waiting status */
if (update_process_title)
{
old_status = get_ps_display(&len);
old_status = get_real_act_ps_display(&len);
new_status = (char *) palloc(len + 8 + 1);
memcpy(new_status, old_status, len);
strcpy(new_status + len, " queuing");
......
......@@ -43,6 +43,7 @@ typedef struct FtsResponse
bool RequestRetry;
} FtsResponse;
extern bool am_ftsprobe;
extern bool am_ftshandler;
extern bool am_mirror;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册