Re: [PATCHES] archiver ps display

2007-12-17 Thread Tom Lane
Simon Riggs [EMAIL PROTECTED] 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.c12 Dec 2007 16:53:14 -  1.35
--- pgarch.c18 Dec 2007 00:47:42 -
***
*** 414,419 
--- 414,420 
  {
charxlogarchcmd[MAXPGPATH];
charpathname[MAXPGPATH];
+   charactivitymsg[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;
  }
  

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


[PATCHES] archiver ps display

2007-12-12 Thread Simon Riggs
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 0001000B

After archive_command
postgres: archiver process   archived 0001000B

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
Index: src/backend/postmaster/pgarch.c
===
RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/backend/postmaster/pgarch.c,v
retrieving revision 1.34
diff -c -r1.34 pgarch.c
*** src/backend/postmaster/pgarch.c	12 Dec 2007 09:39:54 -	1.34
--- src/backend/postmaster/pgarch.c	12 Dec 2007 21:01:52 -
***
*** 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 command execution in PS display */
+ 	snprintf(activitymsg, sizeof(activitymsg), archiving %s, xlog);
+ 	set_ps_display(activitymsg, false);
+ 
  	rc = system(xlogarchcmd);
  	if (rc != 0)
  	{
***
*** 519,524 
--- 525,533 
  	ereport(DEBUG1,
  			(errmsg(archived transaction log file \%s\, xlog)));
  
+ 	snprintf(activitymsg, sizeof(activitymsg), archived %s, xlog);
+ 	set_ps_display(activitymsg, false);
+ 
  	return true;
  }
  

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly