Plan 9 from Bell Labs’s /usr/web/sources/contrib/mospak/ndb-dns-reload-stale/README

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


ndb-dns-reload-stale: every ndb reload leaves an old copy of each local record

When ndb/dns -s rereads its database, db2cache in
sys/src/cmd/ndb/dblookup.c runs

	dnagedb		set expire = 0 on every db record
	dbfile2cache	attach a fresh copy of every db record
	dnauthdb	mark the fresh ones authoritative
	dnageall	free what has timed out

The old copies in the server's own area are authoritative and the
fresh ones are not yet, so rrattach1 treats them as different and
keeps both.  dnauthdb then turns each old copy into an ordinary
cached record (db = 0) and leaves it for dnageall to free.  That
never happens: the default target disables dnageall, and dnage
skips names marked keep.  Each reload therefore adds one more copy
of every local record, until the server restarts.  A record
removed from the database also stays.

The fix deletes the old copies in dnauthdb, where they are found.

Apply
	cd /
	ape/patch -p0 < /path/to/ndb-dns-reload-stale/ndb-dns-reload-stale.diff

Rebuild
	cd /sys/src/cmd/ndb && mk dns.safeinstall

	The old binary is kept as /$objtype/bin/ndb/odns.  Then restart
	ndb/dns; rebooting is simplest.

Verification
	for(i in 1 2 3) echo refresh >/net/dns
	echo dump >/net/dns
	sed -n '/^<host>$/,/^[^	]/p' /lib/ndb/dnsdump

	<host> is any name in the server's own area.  Before: one more
	copy of each record per refresh, the extra ones marked N.
	After: one copy of each, marked A D.

The same change was made in 9front in 2013 (commit 66a2bb2).

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.