Hi Simon, Hi all,


if (!logged && (wait_s > 0 || wait_us > 500000))
{
const char *oldactivitymsg;
int len;

oldactivitymsg = get_ps_display(&len);
snprintf(waitactivitymsg, sizeof(waitactivitymsg),
"waiting for max_standby_delay (%u s)",
MaxStandbyDelay);
set_ps_display(waitactivitymsg, false);
if (len > 100)
len = 100;
memcpy(waitactivitymsg, oldactivitymsg, len);

pgstat_report_waiting(true);

logged = true;
}
..
if (logged)
{
set_ps_display(waitactivitymsg, false);
pgstat_report_waiting(false);
}

That doesnt work because get_ps_display returns the internal buffer. This
leads to the situation that after conflict resolution the
"waiting for max_standby_delay ..."
message is displayed until the next segment starts where its replaced
again by the
"... recovering ..." line.

Additionally the old code may print unintialized memory if get_ps_display
returns a string without a \0 terminator.

The attached patch fixes that.

Andres

Search Discussions

  • Simon Riggs at Feb 13, 2010 at 4:34 pm
    Committed, thanks.
    On Sun, 2010-02-07 at 21:47 +0100, Andres Freund wrote:
    Hi Simon, Hi all,


    if (!logged && (wait_s > 0 || wait_us > 500000))
    {
    const char *oldactivitymsg;
    int len;

    oldactivitymsg = get_ps_display(&len);
    snprintf(waitactivitymsg, sizeof(waitactivitymsg),
    "waiting for max_standby_delay (%u s)",
    MaxStandbyDelay);
    set_ps_display(waitactivitymsg, false);
    if (len > 100)
    len = 100;
    memcpy(waitactivitymsg, oldactivitymsg, len);

    pgstat_report_waiting(true);

    logged = true;
    }
    ..
    if (logged)
    {
    set_ps_display(waitactivitymsg, false);
    pgstat_report_waiting(false);
    }

    That doesnt work because get_ps_display returns the internal buffer. This
    leads to the situation that after conflict resolution the
    "waiting for max_standby_delay ..."
    message is displayed until the next segment starts where its replaced
    again by the
    "... recovering ..." line.

    Additionally the old code may print unintialized memory if get_ps_display
    returns a string without a \0 terminator.

    The attached patch fixes that.

    Andres
    --
    Simon Riggs www.2ndQuadrant.com

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-hackers @
categoriespostgresql
postedFeb 7, '10 at 8:47p
activeFeb 13, '10 at 4:34p
posts2
users2
websitepostgresql.org...
irc#postgresql

2 users in discussion

Andres Freund: 1 post Simon Riggs: 1 post

People

Translate

site design / logo © 2021 Grokbase