Article View: news.software.nntp
Article #17805INN: a better renumber
From: Jeff Garzik
Date: Fri, 16 May 1997 00:00
Date: Fri, 16 May 1997 00:00
296 lines
7869 bytes
7869 bytes
This is a multi-part message in MIME format.
--------------5EFABD63269DFDBD1FCE56AC
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Renumbering the active file is a thorny issue. The renumber step during
expire completely locks up innd while it scans through each and every
newsgroup listed in the active file to see if the low and high water
marks have been updated. Inbound and outbound feeds are stopped dead in
the water. New readers connect but get no login banner. Depending on
the number of newsgroups, the renumber step could take anywhere from 3
to 30 minutes.
There are a couple source patches to deal with this problem at
ftp://ftp.isc.org/isc/inn/unoff-patches/ but none really appealed to me.
I have created a shell script and a Perl script combo that
- fixes the renumber problem (eg. innd dead until renum done)
- requires no source patching or recompilation
- renumbers more correctly than INN itself
The shell script "renum-active", attached below, is called at some point
in time when incoming news flow can be interrupted. It throttles the
server, runs the attached Perl script "getnuminfo" to build a new active
file, and reloads the new active file into innd when complete.
To install it,
0) install the files in the proper locations
1) pass the "norenumber" flag to news.daily during expire,
to disable renumbering
2) edit the paths at the top of renum-active to be correct
3) edit the two values at the top of getnuminfo to be correct
4) have cron call renum-active whenever news will be impacted least
A couple notes, too...
* makeactive (the -o flag) duplicates most of what 'getnuminfo' does --
build the new active file -- but it is less accurate about the
information retrieved. getnuminfo's output and checking appears to be
more correct than makeactive, including...
* innd and makeactive both fail to correctly handle the special case of
a newsgroup with an all-numeric name, such as alt.2600.414. While
testing, the logs show innd "correcting" my work:
May 16 00:42:28 innd: SERVER renumber alt.2600 lo from 69737 to 414
May 16 00:46:47 innd: SERVER renumber alt.music lo from 2159 to 311
My script correctly set the low water mark of alt.2600 to article
#69737, but innd found the newsgroup alt/2600/414 and assumed it was an
article.
* this process appears to take about 5% longer than the normal innd
renumber process. This doesn't bother me, since my server is now
reachable 24 hours a day for the first time ever.
* This can probably be applied to Netscape News and INN 1.4 as well as
the test bed, INN 1.5.1.
Jeff
--------------5EFABD63269DFDBD1FCE56AC
Content-Type: text/plain; charset=us-ascii; name="renum-active"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="renum-active"
#!/bin/sh
#
# renum-active -- by Jeff Garzik <jeff.garzik@spinne.com>
# 5/16/1997
#
ACTIVEDIR=/var/news/etc
ACTIVEFN=active
NEWSUID=news
NEWSGID=news
ACTIVEPERM=0664
GETNUMINFO=/usr/news/local/bin/getnuminfo
CTLINND=/usr/news/bin/ctlinnd
cd $ACTIVEDIR
if [ ! -s $ACTIVEFN ]; then
echo renum-active: ERROR: Cannot find active file $ACTIVEDIR/$ACTIVEFN
exit 1
fi
if [ ! -r $ACTIVEFN ]; then
echo renum-active: ERROR: Cannot access active file $ACTIVEDIR/$ACTIVEFN
exit 1
fi
if $CTLINND -s -t 120 throttle 'Renumbering active file'; then
sleep 1
else
echo renum-active: ERROR: Cannot throttle server
exit 1
fi
if $GETNUMINFO $ACTIVEFN > active.new
then
if [ ! -s active.new ]; then
echo renum-active: ERROR: Cannot find renumber information
exit 1
fi
if [ ! -r active.new ]; then
echo renum-active: ERROR: Cannot access renumber information
exit 1
fi
rm -f active.old
ln $ACTIVEFN active.old
rm $ACTIVEFN
ln active.new $ACTIVEFN
rm active.new
$CTLINND -s -t 120 reload active 'Update after renumber'
$CTLINND -s -t 120 go ''
else
echo renum-active: ERROR: Cannot get renumber information
$CTLINND -s -t 120 go ''
exit 1
fi
--------------5EFABD63269DFDBD1FCE56AC
Content-Type: text/plain; charset=us-ascii; name="getnuminfo"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="getnuminfo"
#!/usr/local/bin/perl
#
# getnuminfo -- by Jeff Garzik <jeff.garzik@spinne.com>
# 5/16/1997
#
use strict;
# base spool directory, where articles live
my $Spool = "/var/news/spool/articles";
# number of digits in active file numbers
my $ActDigits = 10;
################################################################
my (%group_low, %group_high, %group_rest, @groupnames);
my %exception;
my $ActiveFormat = sprintf("%%s %%0%du %%0%du %%s\n", $ActDigits, $ActDigits);
&input_active;
print STDERR "loaded ", $#groupnames + 1, " groups from active file\n";
chdir $Spool || die "Cannot chdir to $Spool: $!\n";
&renumber_active;
&output_active;
exit(0);
sub add_exception {
my ($group) = @_;
my (@tmp, $parent, $s, $frag);
@tmp = split(/\./, $group);
$parent = '';
while (@tmp) {
$frag = shift @tmp;
if ($frag =~ /^\d+$/o) {
$s = substr($parent, 0, length($parent) - 1);
if ($exception{$s}) {
$exception{$s} .= "\t$frag";
} else {
$exception{$s} = $frag;
}
}
$parent .= "$frag.";
}
}
sub output_active {
foreach (@groupnames) {
printf($ActiveFormat, $_, $group_high{$_},
$group_low{$_}, $group_rest{$_});
}
}
sub renumber_active {
my ($group, $i);
$i = 0;
foreach $group (@groupnames) {
&renumber_group($group);
$i++;
print STDERR "Renumbered $i groups\n"
if (($i % 1000) == 0);
}
}
sub renumber_group {
my ($curgroup) = @_;
my ($dir, @files, $fn, @numgroups);
my ($high, $low, $newname);
$dir = $curgroup;
$dir =~ s/\./\//g;
return if (!opendir(DIR, $dir));
@files = readdir(DIR);
closedir(DIR);
@files = grep (/^\d+$/o, @files);
return unless (@files);
$high = $group_high{$curgroup};
$low = $high + 1;
foreach $fn (@files) {
if ($exception{$curgroup}) {
my (@tmp) = split("\t", $exception{$curgroup});
my ($n, $found);
foreach $n (@tmp) {
$found = 1 if ($n == $fn);
}
next if $found;
}
$low = $fn if ($fn < $low);
$high = $fn if ($fn > $high);
}
$group_low{$curgroup} = $low;
$group_high{$curgroup} = $high;
}
sub input_active {
my ($name, $high, $low, $rest);
my (@special);
if ((! $ARGV[0]) || (! -s $ARGV[0]) || (! -r $ARGV[0])) {
print STDERR "Cannot find or access active file: $ARGV[0]\n";
exit(1);
}
open(ACT, $ARGV[0]) || die "Cannot open active file $ARGV[0]: $!\n";
while (<ACT>) {
next unless
(($name, $high, $low, $rest) = /^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s*$/o);
$group_high{$name} = $high;
$group_low{$name} = $high + 1;
$group_rest{$name} = $rest;
push(@groupnames, $name);
}
close(ACT);
@groupnames = sort @groupnames;
@special = grep (/\.\d+\./o, @groupnames);
push(@special, grep (/\.\d+$/o, @groupnames));
foreach $name (@special) {
&add_exception($name);
}
}
--------------5EFABD63269DFDBD1FCE56AC--
Technical Details
Message-ID:
<337BF788.5DB61A91@spinne.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <337BF788.5DB61A91@spinne.com> Subject: INN: a better renumber Date: Fri, 16 May 1997 00:00:00 +0000 From: Jeff Garzik <jeff.garzik@spinne.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 241839454 Organization: Spinne http://spinne.com Newsgroups: news.software.nntp