Re: [PATCHES] pg_autovacuum integration proof of concept patch

2004-06-08 Thread Euler Taveira de Oliveira
Hi Matthew,

 What have you done specifically?  FYI, I will have the GUC variables 
 done done today or tomorrow, and I have started on the new system tables 
 already.
 
Almost everything. In a couple of days it will be done, then I send it for
review.


-- 
Euler Taveira de Oliveira
euler (at) ufgnet.ufg.br
Desenvolvedor Web e Administrador de Sistemas
UFGNet - Universidade Federal de Goiás

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [PATCHES] pg_autovacuum integration proof of concept patch

2004-06-07 Thread Euler Taveira de Oliveira
Hi Matthew,

Cool. Last week I just take a look at it and have some ideas.

 I have been working on integrating pg_autovacuum into the backend.  I
 have used Tom's recent work on the bgwriter as an example.  This patch
 accomplishes the following:
 
 * pg_autovacuum is now started and stopped by the postmaster
 * pg_autovacuum is no longer a stand alone executable
 * pg_autovacuum now uses elog
 
 I am submitting this patch for review to make sure that I'm headed in
 the right direction, so please give it a cursory glance and tell me if
 you see any glaring problems.
 
Yep. You're in the right direction.

 I am planning on doing much more in the next few days including:
 * creating pg_autovacuum related guc variables
 * create a new system table for pg_autovacuum settings
 * alter pg_class (or create another new system table) to store
 additional per table pg_autovacuum data which will allow per table
 settings and persistent data
 
I just made some of this. If you want to exchanges ideas, drop me a line.

I'll try to get what you've done and integrate it with what i've done.


-- 
Euler Taveira de Oliveira
euler (at) ufgnet.ufg.br
Desenvolvedor Web e Administrador de Sistemas
UFGNet - Universidade Federal de Goiás

---(end of broadcast)---
TIP 8: explain analyze is your friend


[PATCHES] pg_autovacuum integration proof of concept patch

2004-06-06 Thread Matthew T. O'Connor
I have been working on integrating pg_autovacuum into the backend.  I
have used Tom's recent work on the bgwriter as an example.  This patch
accomplishes the following:

* pg_autovacuum is now started and stopped by the postmaster
* pg_autovacuum is no longer a stand alone executable
* pg_autovacuum now uses elog

I am submitting this patch for review to make sure that I'm headed in
the right direction, so please give it a cursory glance and tell me if
you see any glaring problems.

I am planning on doing much more in the next few days including:
* creating pg_autovacuum related guc variables
* create a new system table for pg_autovacuum settings
* alter pg_class (or create another new system table) to store
additional per table pg_autovacuum data which will allow per table
settings and persistent data

To use this patch, move pg_autovacuum.c into src/backend/postmaster,
move pg_autovacuum.h into src/include/postmaster and apply the patch.

Matthew O'Connor

ps, I am hoping to get this work in before feature freeze.
*** ./src/backend/bootstrap/bootstrap.c.orig	2004-06-05 15:32:02.0 -0400
--- ./src/backend/bootstrap/bootstrap.c	2004-06-05 15:33:13.0 -0400
***
*** 34,39 
--- 34,40 
  #include libpq/pqsignal.h
  #include miscadmin.h
  #include postmaster/bgwriter.h
+ #include postmaster/pg_autovacuum.h
  #include storage/freespace.h
  #include storage/ipc.h
  #include storage/pg_shmem.h
***
*** 358,363 
--- 359,367 
  			case BS_XLOG_BGWRITER:
  statmsg = writer process;
  break;
+ 			case BS_XLOG_AUTOVAC:
+ statmsg = auto vacuum process;
+ break;
  			default:
  statmsg = ??? process;
  break;
***
*** 394,399 
--- 398,406 
  			case BS_XLOG_BGWRITER:
  InitDummyProcess(DUMMY_PROC_BGWRITER);
  break;
+ 			case BS_XLOG_AUTOVAC:
+ InitDummyProcess(DUMMY_PROC_AUTOVAC);
+ break;
  
  			default:
  InitDummyProcess(DUMMY_PROC_DEFAULT);
***
*** 430,435 
--- 437,448 
  			BackgroundWriterMain();
  			proc_exit(1);		/* should never return */
  
+ 		case BS_XLOG_AUTOVAC:
+ 			/* don't set signals, autovac has its own agenda */
+ 			InitXLOGAccess();
+ 			AutoVacMain();
+ 			proc_exit(1);		/* should never return */
+ 		
  		default:
  			elog(PANIC, unrecognized XLOG op: %d, xlogop);
  			proc_exit(1);
*** ./src/backend/Makefile.orig	2004-06-07 01:21:43.515373849 -0400
--- ./src/backend/Makefile	2004-06-05 13:46:24.0 -0400
***
*** 29,41 
  
  ##
  
! all: submake-libpgport postgres $(POSTGRES_IMP)
  
  ifneq ($(PORTNAME), cygwin)
  ifneq ($(PORTNAME), win32)
  
  postgres: $(OBJS)
! 	$(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o $@
  
  endif
  endif
--- 29,41 
  
  ##
  
! all: submake-libpgport submake-libpq postgres $(POSTGRES_IMP)
  
  ifneq ($(PORTNAME), cygwin)
  ifneq ($(PORTNAME), win32)
  
  postgres: $(OBJS)
! 	$(CC) $(CFLAGS) $(LDFLAGS) -I $(libpq_srcdir) $(export_dynamic) $^ $(LIBS)  $(libpq) -o $@
  
  endif
  endif
*** ./src/backend/postmaster/Makefile.orig	2004-06-05 00:58:08.0 -0400
--- ./src/backend/postmaster/Makefile	2004-06-05 13:45:20.0 -0400
***
*** 12,18 
  top_builddir = ../../..
  include $(top_builddir)/src/Makefile.global
  
! OBJS = postmaster.o bgwriter.o pgstat.o
  
  all: SUBSYS.o
  
--- 12,18 
  top_builddir = ../../..
  include $(top_builddir)/src/Makefile.global
  
! OBJS = postmaster.o bgwriter.o pgstat.o pg_autovacuum.o
  
  all: SUBSYS.o
  
*** ./src/backend/postmaster/pg_autovacuum.c.orig	2004-06-07 00:39:57.0 -0400
--- ./src/backend/postmaster/pg_autovacuum.c	2004-06-07 00:35:51.0 -0400
***
*** 1,65 
! /* pg_autovacuum.c
   * All the code for the pg_autovacuum program
   * (c) 2003 Matthew T. O'Connor
   * Revisions by Christopher B. Browne, Liberty RMS
   */
  
! #include pg_autovacuum.h
  
- FILE	   *LOGOUTPUT;
  char		logbuffer[4096];
  
! static void
! log_entry(const char *logentry)
  {
! 	time_t		curtime;
! 	struct tm  *loctime;
! 	char		timebuffer[128];
! 
! 	curtime = time(NULL);
! 	loctime = localtime(curtime);
! 	strftime(timebuffer, sizeof(timebuffer), %Y-%m-%d %H:%M:%S %Z, loctime);
! 	fprintf(LOGOUTPUT, [%s] %s\n, timebuffer, logentry);
  }
  
  /*
!  * Function used to detach the pg_autovacuum daemon from the tty and go into
!  * the background.
   *
!  * This code is mostly ripped directly from pm_dameonize in postmaster.c with
!  * unneeded code removed.
   */
  static void
! daemonize()
  {
! 	pid_t		pid;
  
! 	pid = fork();
! 	if (pid == (pid_t) -1)
! 	{
! 		log_entry(Error: cannot disassociate from controlling TTY);
! 		fflush(LOGOUTPUT);
! 		_exit(1);
! 	}
! 	else if (pid)
! 	{			/* parent */
! 		/* Parent should just exit, without doing any atexit cleanup */
!