Re: autovacuum launcher using InitPostgres - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: autovacuum launcher using InitPostgres
Date
Msg-id 20090831161855.GI6060@alvh.no-ip.org
Whole thread Raw
In response to Re: autovacuum launcher using InitPostgres  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: autovacuum launcher using InitPostgres
List pgsql-hackers
Tom Lane wrote:
> Alvaro Herrera <alvherre@commandprompt.com> writes:
> > How about this?
>
> I think the accounting for the AV launcher in shmem allocation is a bit
> confused yet --- for instance, isn't MaxBackends already including the
> launcher?  I wonder if it would be cleaner to include the launcher in
> the autovacuum_max_workers parameter, and increase the min/default
> values of that by one.

Huh, yeah, sorry about that -- fixed here.  I think the name of the
param, which includes "worker", precludes from raising the values.

Changes between v2 and v3:

diff -u src/backend/storage/lmgr/proc.c src/backend/storage/lmgr/proc.c
--- src/backend/storage/lmgr/proc.c     31 Aug 2009 13:36:56 -0000
+++ src/backend/storage/lmgr/proc.c     31 Aug 2009 16:14:08 -0000
@@ -103,7 +103,7 @@
        /* AuxiliaryProcs */
        size = add_size(size, mul_size(NUM_AUXILIARY_PROCS, sizeof(PGPROC)));
        /* MyProcs, including autovacuum workers and launcher */
-       size = add_size(size, mul_size(MaxBackends + 1, sizeof(PGPROC)));
+       size = add_size(size, mul_size(MaxBackends, sizeof(PGPROC)));
        /* ProcStructLock */
        size = add_size(size, sizeof(slock_t));

@@ -192,6 +192,7 @@
                ProcGlobal->freeProcs = &procs[i];
        }

+       /* note: the "+1" here accounts for the autovac launcher */
        procs = (PGPROC *) ShmemAlloc((autovacuum_max_workers + 1) * sizeof(PGPROC));
        if (!procs)
                ereport(FATAL,
diff -u src/backend/utils/misc/guc.c src/backend/utils/misc/guc.c
--- src/backend/utils/misc/guc.c        31 Aug 2009 03:07:47 -0000
+++ src/backend/utils/misc/guc.c        31 Aug 2009 16:12:56 -0000
@@ -7570,7 +7570,7 @@
 static bool
 assign_maxconnections(int newval, bool doit, GucSource source)
 {
-       if (newval + autovacuum_max_workers > INT_MAX / 4)
+       if (newval + autovacuum_max_workers + 1 > INT_MAX / 4)
                return false;

        if (doit)


--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: autovacuum launcher using InitPostgres
Next
From: Tom Lane
Date:
Subject: Re: autovacuum launcher using InitPostgres