Skip to content

Commit 8eccf76

Browse files
Improvements to ps message of startup process during Hot Standby.
Message is reset earlier and potential bug avoided. Andres Freund
1 parent dd428c7 commit 8eccf76

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/backend/storage/ipc/standby.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1994, Regents of the University of California
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/storage/ipc/standby.c,v 1.12 2010/02/13 01:32:19 sriggs Exp $
14+
* $PostgreSQL: pgsql/src/backend/storage/ipc/standby.c,v 1.13 2010/02/13 16:29:38 sriggs Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -164,6 +164,7 @@ ResolveRecoveryConflictWithVirtualXIDs(VirtualTransactionId *waitlist,
164164
ProcSignalReason reason)
165165
{
166166
char waitactivitymsg[100];
167+
char oldactivitymsg[101];
167168

168169
while (VirtualTransactionIdIsValid(*waitlist))
169170
{
@@ -186,17 +187,21 @@ ResolveRecoveryConflictWithVirtualXIDs(VirtualTransactionId *waitlist,
186187
TimestampDifference(waitStart, now, &wait_s, &wait_us);
187188
if (!logged && (wait_s > 0 || wait_us > 500000))
188189
{
189-
const char *oldactivitymsg;
190+
const char *oldactivitymsgp;
190191
int len;
191192

192-
oldactivitymsg = get_ps_display(&len);
193+
oldactivitymsgp = get_ps_display(&len);
194+
195+
if (len > 100)
196+
len = 100;
197+
198+
memcpy(oldactivitymsg, oldactivitymsgp, len);
199+
oldactivitymsg[len] = 0;
200+
193201
snprintf(waitactivitymsg, sizeof(waitactivitymsg),
194202
"waiting for max_standby_delay (%u s)",
195203
MaxStandbyDelay);
196204
set_ps_display(waitactivitymsg, false);
197-
if (len > 100)
198-
len = 100;
199-
memcpy(waitactivitymsg, oldactivitymsg, len);
200205

201206
pgstat_report_waiting(true);
202207

@@ -226,7 +231,7 @@ ResolveRecoveryConflictWithVirtualXIDs(VirtualTransactionId *waitlist,
226231
/* Reset ps display */
227232
if (logged)
228233
{
229-
set_ps_display(waitactivitymsg, false);
234+
set_ps_display(oldactivitymsg, false);
230235
pgstat_report_waiting(false);
231236
}
232237

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy