RE: squid rebuilds cache for three days

From: Robin Bowes <[email protected]>
Date: Thu, 10 Jun 1999 14:26:00 +0100

Hi Pavel,

From the kernel config file:

#
# The `maxusers' parameter controls the static sizing of a number of
# internal system tables by a complicated formula defined in param.c.
#
maxusers 10

and from param.c:

/* maximum # of mbuf clusters */
#ifndef NMBCLUSTERS
#define NMBCLUSTERS (512 + MAXUSERS * 16)
#endif
int nmbclusters = NMBCLUSTERS;

So, you need to up maxusers in your kernel and rebuild. It may be
possible to change this value "on-te-fly" but if it is, I don't know how
to do it.

Regarding the long cache rebuild time, I had a similar problem.
 Squid-2.2.STABLE2 on FreeBSD 3.x.

I found that there were two issues involved:

1. I wasn't shutting down the squid process cleanly so it needed to
rebuild every time the machine was shutdown. This is a problem with
FreeBSD since it has rather primitive init scripts compared to the
SysV-style startup/shutdown scripts on Linux.

2. I didn't have enought RAM in the machine so it got so far through the
re-build and started swapping heavily. This is possibly why it's taking
so long for the cache to re-build.

The solution I found was two-fold:

1. MAke sure squid is shutdown cleanly when FreeBSD is shutdown. I did
this like this:
a. modified /etc/rc.shutdown to contain the following:

!/bin/sh
# $Id: rc.shutdown,v 1.1 1997/08/02 00:22:45 davidn Exp $

# site-specific closing actions for daemons run by init on shutdown
# or before going single-user from multi-user.
# Output and errors are directed to console by init, and the
# console is the controlling terminal.

stty status '^T'

# Set shell to ignore SIGINT (2), but not children;
# shell catches SIGQUIT (3) and returns to single user after fsck.
trap : 2
trap : 3 # shouldn't be needed

HOME=/; export HOME
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
export PATH

echo -n Shutting down daemon processes:

# Insert shutdown procedures here

# pull in rc.conf to set $local_startup
if [ if /etc/defaults/rc.conf ]; then
        . /etc/defaults/rc.conf
elif [ -f /etc/rc.conf ]; then
        . /etc/rc.conf
fi

# for each valid dir in $local_startup, search for init scripts matching
*.sh
        echo -n 'Local package shutdown:'
        for dir in ${local_startup}; do
                [ -d ${dir} ] && for script in ${dir}/*.sh; do
                        [ -x ${script} ] && \
                                (trap 'exit 1' 2 ; ${script} stop ; echo
 -n)
                done
        done
echo '.'
exit 0

b. modified all my scripts in $(local_startup) to take a start|stop
parameter (ie like SysV)
I use DJB's daemontools package and my squid.sh looks like this:

#! /bin/sh -
#
# description: Start, stop, restart, reload, and otherwise signal squid
\
# Makes heavy use of parts of DJB's daemontools package \
# It also relies upon daemontools.functions for 91.04982% \
# of the grunt work.
#
# customize
PROG=squid # what program?
DIR=/var/lock/$PROG # a directory for
supervise to use
LOGDIR=/var/log/$PROG # directory for
logs
LOGUSER=squid # user to own
logs
INITDIR=/usr/local/etc/rc.d # location of
initscripts
WAIT=30 # time (secs) to
wait for the program to exit
                                                        # (used by stop()
in daemontools.functions
CONF=/usr/local/etc/squid/squid.conf # program config
file to use
PROGOPTS=-NsY # options to
program

# Grab the daemontools init functions
. $INITDIR/daemontools.functions
export PATH=/usr/local/sbin:/usr/local/bin:$PATH

start() {
    if check; then
        echo "$PROG is already running"
    else
        echo -n "Starting $PROG..."
        supervise $DIR $PROG $PROGOPTS $CONF >> $LOGDIR/$PROG.out &
        echo "done"
    fi
}

case "$1" in
    start)
        start
    ;;
    stop)
        stop
    ;;
    restart)
        restart
    ;;
    status)
        status
    ;;
    help)
        help
    ;;
    *)
        signal $1
    ;;
esac

c. Shutdown the FreeBSD box by sending a SIGTERM to the init process, ie
"kill -TERM 1", rather than using "the shutdown command". This causes
/etc/rc.shutdown to be executed and squid is terminated cleanly.

2. The solution to this problem is easy: put more RAM in the machine :o)

HTH,

R.

>
> Hello,
>
> I have a problem with Squid-2.2.STABLE2 on FreeBSD 2.2.6.
> (Pentium100 / 64M
> / 2G SCSI disk)
>
> Sometimes I get the message in /var/log/messages: "Out of
> mbuf clusters -
> increase maxusers!"
> I've increase maxusers to 512 (maximum possible number).
> But at July 8 I have following line in /var/log/messages:
>
> Jun 8 16:18:46 mink /kernel: Out of mbuf clusters - increase
> maxusers!
>
> and computer restarts automatically.
>
> After computer's start up squid try to rebuild cache. Three
> days (!) past -
> Squid's still rebuilding cache...
>
> What is in cache.log (look at the date!):
>
> 1999/06/08 16:22:16| Starting Squid Cache version 2.2.STABLE2 for
> i386-unknown-freebsd2.2.6...
> 1999/06/08 16:22:16| Process ID 237
> 1999/06/08 16:22:16| With 3240 file descriptors available
> 1999/06/08 16:22:16| Performing DNS Tests...
> 1999/06/08 16:22:16| Successful DNS name lookup tests...
> 1999/06/08 16:22:16| helperOpenServers: Starting 5
> 'dnsserver' processes
> 1999/06/08 16:22:16| Unlinkd pipe opened on FD 13
> 1999/06/08 16:22:16| Swap maxSize 409600 KB, estimated 31507 objects
> 1999/06/08 16:22:16| Target number of buckets: 630
> 1999/06/08 16:22:16| Using 8192 Store buckets, replacement
> runs every 10
> seconds
> 1999/06/08 16:22:16| Max Mem size: 4096 KB
> 1999/06/08 16:22:16| Max Swap size: 409600 KB
> 1999/06/08 16:22:16| Rebuilding storage in Cache Dir #0 (DIRTY)
> 1999/06/08 16:22:16| Set Current Directory to /var/spool/squid.cache
> 1999/06/08 16:22:16| Loaded Icons.
> 1999/06/08 16:22:16| Accepting HTTP connections on port 80, FD 37.
> 1999/06/08 16:22:16| Ready to serve requests.
> 1999/06/08 16:22:21| Restarting Squid Cache (version 2.2.STABLE2)...
> 1999/06/08 16:22:21| FD 37 Closing HTTP connection
> 1999/06/08 16:22:21| Cache dir '/var/spool/squid.cache' size remains
> unchanged at 409600 KB
> 1999/06/08 16:22:21| helperOpenServers: Starting 5
> 'dnsserver' processes
> 1999/06/08 16:22:21| Accepting HTTP connections on port 80, FD 5.
> 1999/06/08 16:22:21| Ready to serve requests.
> 1999/06/08 16:22:27| 65536 Entries read so far.
> 1999/06/08 16:22:34| 131072 Entries read so far.
> 1999/06/08 16:22:47| 196608 Entries read so far.
> 1999/06/08 16:23:04| 262144 Entries read so far.
> 1999/06/08 16:23:20| 327680 Entries read so far.
> 1999/06/08 16:23:40| 393216 Entries read so far.
> 1999/06/08 16:24:06| 458752 Entries read so far.
> 1999/06/08 16:24:43| 524288 Entries read so far.
> 1999/06/08 16:25:45| 589824 Entries read so far.
> 1999/06/08 16:58:58| WARNING: filemap utilization at 88%
> Consider decreasing store_avg_object_size in squid.conf
> [...skip...]
> 1999/06/08 18:08:23| 655360 Entries read so far.
> 1999/06/09 00:01:06| Not currently OK to rewrite swap log.
> 1999/06/09 00:01:06| storeDirWriteCleanLogs: Operation aborted.
> 1999/06/09 00:01:06| storeLogRotate: Rotating.
> 1999/06/09 00:01:06| accessLogRotate: Rotating
> 1999/06/09 01:48:28| 720896 Entries read so far.
> [...skip...]
> 1999/06/10 00:01:12| Not currently OK to rewrite swap log.
> 1999/06/10 00:01:12| storeDirWriteCleanLogs: Operation aborted.
> 1999/06/10 00:01:12| storeLogRotate: Rotating.
> 1999/06/10 00:01:12| accessLogRotate: Rotating
> 1999/06/10 00:06:22| 786432 Entries read so far.
> [...skip...]
>
> Today is July 10 and squid is still rebuilding cache!
>
> What I sould do?
>
> Yours sincerely,
> Pavel
>
> ----------------------------------------------------------------
> Pavel P. Zabortsev e-mail: ppz@cdu.elektra.ru
> Software engineer, Postmaster voice: 927-9523, 26-23 (corp)
> CDO UPS of Russia fax: 220-6542
> Moscow, Russia ICQ: 15371542
> ----------------------------------------------------------------
>
>
>
>
 --
Robin Bowes, System Development Manager, Equal Opportunities Commission,
Room 405A, Overseas House, Quay St., Manchester, M3 3HN, UK.
Tel: +44 (0) 161 838 8321 Fax: +44 (0) 161 835 1657
Received on Thu Jun 10 1999 - 07:55:02 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:46:50 MST