Thread: archiver ps display

archiver ps display

From
Simon Riggs
Date:
Now that we have set archiver messages to DEBUG levels, there's no easy
way of seeing what file we are on.

Patch to set ps display for archiver enclosed, intended for 8.3

Before archive_command
postgres: archiver process   archiving 00000001000000000000000B

After archive_command
postgres: archiver process   archived 00000001000000000000000B

So the behaviour of the startup process and archiver are now
symmetrical, allowing it to be used for replication monitoring.

--
  Simon Riggs
  2ndQuadrant  http://www.2ndQuadrant.com

Attachment

Re: archiver ps display

From
Tom Lane
Date:
Simon Riggs <simon@2ndquadrant.com> writes:
> Patch to set ps display for archiver enclosed, intended for 8.3

I think this is a good idea.  However, experimentation here showed that
at least on some machines (like HPUX), there's a pretty tight limit
before ps cuts off the display, and the more verbose messages discussed
on -hackers cause the last few digits of the filename to be cut off.
Which makes the display just about entirely useless.  So I went with
these messages:

archiving %s
last was %s
failed on %s

We might need to make it even briefer, perhaps

at: %s
last: %s
failed: %s

depending on reports from the field.

Applied patch attached.

            regards, tom lane

Index: pgarch.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/postmaster/pgarch.c,v
retrieving revision 1.35
diff -c -r1.35 pgarch.c
*** pgarch.c    12 Dec 2007 16:53:14 -0000    1.35
--- pgarch.c    18 Dec 2007 00:47:42 -0000
***************
*** 414,419 ****
--- 414,420 ----
  {
      char        xlogarchcmd[MAXPGPATH];
      char        pathname[MAXPGPATH];
+     char        activitymsg[MAXFNAMELEN + 16];
      char       *dp;
      char       *endp;
      const char *sp;
***************
*** 471,476 ****
--- 472,482 ----
      ereport(DEBUG3,
              (errmsg_internal("executing archive command \"%s\"",
                               xlogarchcmd)));
+
+     /* Report archive activity in PS display */
+     snprintf(activitymsg, sizeof(activitymsg), "archiving %s", xlog);
+     set_ps_display(activitymsg, false);
+
      rc = system(xlogarchcmd);
      if (rc != 0)
      {
***************
*** 527,537 ****
--- 533,549 ----
                                 xlogarchcmd)));
          }

+         snprintf(activitymsg, sizeof(activitymsg), "failed on %s", xlog);
+         set_ps_display(activitymsg, false);
+
          return false;
      }
      ereport(DEBUG1,
              (errmsg("archived transaction log file \"%s\"", xlog)));

+     snprintf(activitymsg, sizeof(activitymsg), "last was %s", xlog);
+     set_ps_display(activitymsg, false);
+
      return true;
  }


Re: archiver ps display

From
Simon Riggs
Date:
On Mon, 2007-12-17 at 19:54 -0500, Tom Lane wrote:
> Simon Riggs <simon@2ndquadrant.com> writes:
> > Patch to set ps display for archiver enclosed, intended for 8.3
>
> I think this is a good idea.  However, experimentation here showed that
> at least on some machines (like HPUX), there's a pretty tight limit
> before ps cuts off the display, and the more verbose messages discussed
> on -hackers cause the last few digits of the filename to be cut off.

Yeh, there's some command to extend the display, but few people use it,
so we're better off with the shorter display, I think.

> Which makes the display just about entirely useless.  So I went with
> these messages:
>
> archiving %s
> last was %s
> failed on %s

Looks good to me. Thanks.

--
  Simon Riggs
  2ndQuadrant  http://www.2ndQuadrant.com