Thread View: news.software.nntp
5 messages
5 total messages
Started by Brad Knowles
Fri, 10 Dec 1999 00:00
Question regarding INN's use of the newsgroups file...
Author: Brad Knowles
Date: Fri, 10 Dec 1999 00:00
Date: Fri, 10 Dec 1999 00:00
45 lines
2543 bytes
2543 bytes
Folks,
I've done some searches, tried to look in the INN documentation, and
haven't really turned up anything on this.
I know that INN opens the active file and keeps it open, and
constantly makes changes to it as articles come in, etc.... But what
about the newsgroups file? Could it be updated and then safely slid
into place with commands like this:
cd /usr/local/news/db
[ make newsgroups.new file ]
ln newsgroups newsgroups.old
ln -f newsgroups.new newsgroups
rm newsgroups.new
You can do this with processes that re-open the file each time they
need to access it, because the ln is an atomic operation, and when the
process goes to open the file it will definitively either get the old
version (which it can safely hold open for a while, even if the file is
renamed), or it will get the new version -- it won't get a truncated
file, nor will it get some mish-mash of the two.
Or would I need to update the file and then do something like a
"ctlinnd reload newsgroups"?
I ask because I'm helping to work on a project that will create a
new way to maintain and synchronize active files, and which should be
adaptable to all of the major news servers. For the moment, we're
working on INN, but once we've got the process working correctly, I'll
adapt it to Diablo and there are others who will adapt it to bCandid,
etc....
Thanks!
--
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>
Are you a USENET news server administrator outside of North America or
Western Europe? Would you like a newsfeed from a site in the Freenix
Top 65? If so, please contact me via private e-mail for details.
Re: Question regarding INN's use of the newsgroups file...
Author: Andrew Gierth
Date: Fri, 10 Dec 1999 00:00
Date: Fri, 10 Dec 1999 00:00
28 lines
1615 bytes
1615 bytes
>>>>> "Brad" == Brad Knowles <brad@shub-internet.org> writes: Brad> ln -f newsgroups.new newsgroups Brad> You can do this with processes that re-open the file each Brad> time they need to access it, because the ln is an atomic Brad> operation, no, actually, it's not. (ln -f uses separate unlink() and link() calls) The right way to do this is: ln -f newsgroups newsgroups.old mv newsgroups.new newsgroups Brad> Or would I need to update the file and then do something like a Brad> "ctlinnd reload newsgroups"? No. The newsgroups file is opened and closed within the scope of each LIST NEWSGROUPS command, it's not held incore, and innd never touches it at all AFAIK. -- Andrew.
Re: Question regarding INN's use of the newsgroups file...
Author: Brad Knowles
Date: Fri, 10 Dec 1999 00:00
Date: Fri, 10 Dec 1999 00:00
34 lines
2027 bytes
2027 bytes
In article <87iu26kdcu.fsf@erlenstar.demon.co.uk>, Andrew Gierth
<andrew@erlenstar.demon.co.uk> wrote:
> no, actually, it's not. (ln -f uses separate unlink() and link() calls)
Fascinating. Absolutely fascinating. I was introduced to that
method a number of years ago, and I believe it was by some people who I
have a great deal of respect for their skills, knowledge, and especially
their paranoia. ;-)
> The right way to do this is:
>
> ln -f newsgroups newsgroups.old
> mv newsgroups.new newsgroups
Cool. Glad to know this.
> The newsgroups file is opened and closed within the scope of each
> LIST NEWSGROUPS command, it's not held incore, and innd never touches
> it at all AFAIK.
While that's bad news for INN, that's good news for me.
Thanks for the info!
--
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>
Are you a USENET news server administrator outside of North America or
Western Europe? Would you like a newsfeed from a site in the Freenix
Top 65? If so, please contact me via private e-mail for details.
Re: Question regarding INN's use of the newsgroups file...
Author: bill davidsen
Date: Mon, 13 Dec 1999 00:00
Date: Mon, 13 Dec 1999 00:00
43 lines
2474 bytes
2474 bytes
In article <87iu26kdcu.fsf@erlenstar.demon.co.uk>, Andrew Gierth <andrew@erlenstar.demon.co.uk> wrote: | >>>>> "Brad" == Brad Knowles <brad@shub-internet.org> writes: | | Brad> ln -f newsgroups.new newsgroups | | Brad> You can do this with processes that re-open the file each | Brad> time they need to access it, because the ln is an atomic | Brad> operation, | | no, actually, it's not. (ln -f uses separate unlink() and link() calls) | | The right way to do this is: | | ln -f newsgroups newsgroups.old | mv newsgroups.new newsgroups This may be implementation dependent. Looking at several UNIX implementations, I didn't see and statements that this is atomic, and only Linux promised (in the rename() system call) that the destination name would always be valid if it existed before the rename().\ On newer UNIX versions which have a rename() system call, I would bet the target is always valid, but I bet there's a moment where the old name is also valid. And on older versions, I'm pretty sure that mv would have to do an unlink of the 'newsgroups' file, a link of 'newsgroups.new' to 'newsgroups,' and then an unlink of 'newsgroups.new.' Reality is what the o/s does, not what POSIX or X/OPEN say should happen. BTW: I'm not disagreeing about mv being a good way to do the operation from a command line. I just don't think it's a foolproof as it might seem. -- bill davidsen <davidsen@tmr.com> CTO, TMR Associates, Inc When taking small children to a carnival, always have them go potty *before* you let them go on the rides, and let them eat all the junk food and candy *after*.
Re: Question regarding INN's use of the newsgroups file...
Author: Andrew Gierth
Date: Mon, 13 Dec 1999 00:00
Date: Mon, 13 Dec 1999 00:00
48 lines
2635 bytes
2635 bytes
>>>>> "bill" == bill davidsen <davidsen@tmr.com> writes:
> | The right way to do this is:
> |
> | ln -f newsgroups newsgroups.old
> | mv newsgroups.new newsgroups
bill> This may be implementation dependent.
Only in the sense that _very_ old implementations may not provide
the necessary guarantee.
The single unix spec says this:
If the link named by the new argument exists, it is removed and
old renamed to new. In this case, a link named new will remain
visible to other processes throughout the renaming operation and
will refer either to the file referred to by new or old before the
operation began
which I believe it adopted directly from the POSIX spec.
(That guarantee, and the ability to rename directories, are the only
reasons for the rename() syscall to exist at all.)
bill> Looking at several UNIX implementations, I didn't see and
bill> statements that this is atomic, and only Linux promised (in the
bill> rename() system call) that the destination name would always be
bill> valid if it existed before the rename().\
You'll find that same promise in the rename() docs of virtually every
system (it's there in FreeBSD and Solaris, for example, and I remember
it from older systems like SCO 3.2v4, HP-UX 9, and AIX 3.2).
bill> On newer UNIX versions which have a rename() system call,
(where "newer" means "less than 12 years old")
bill> I would bet the target is always valid, but I bet there's a
bill> moment where the old name is also valid.
I don't think it's possible to tell. (i.e. see if you can find a code
path that would produce different results)
--
Andrew.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads