]> git.ipfire.org Git - thirdparty/pdns.git/commit
auth: Enforce a strict maximum size for the packet and records caches 8736/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 17 Jan 2020 13:56:27 +0000 (14:56 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Fri, 14 Feb 2020 19:24:57 +0000 (20:24 +0100)
commite0a1a5f4faac0fbf760824793559c8de32f7840b
treebac0cdc3a9115dc8f6f926578df615a953704d4e
parentceeed0ad5c4a8b886e3b4ee7b255907e367fcab4
auth: Enforce a strict maximum size for the packet and records caches

Before this change, both the query and packet caches in the authoritative
server can exceed their maximum size by a lot, until the next cleaning
cycle.
This is particularly nasty since the current cleaning algorithm will
never remove entries from the cache until they expire, as opposed to
what we do in the recursor, for example, where we nuke the least-recently
used entries, even if they are still valid, when the cache is full.
This commit changes that by removing the least recently inserted or
updated entry from the cache after inserting a new one when the cache
is full, thus enforcing the maximum size more strictly.

Note that this is really the least recently inserted/updated and not
the least recently used one, as is done in the recursor. Having a
proper LRU in the auth would require acquering a write lock for a
simple lookup, instead of a potentially concurrent read-lock at the
moment. We might want to consider changing that at some point, as
a LRU might be fairer and the lock contention might be very small
since the caches are sharded.

(cherry picked from commit d2814f81c77709d628a3fc036aff96ccc8a74c64)
pdns/auth-packetcache.cc
pdns/auth-packetcache.hh
pdns/auth-querycache.cc
pdns/auth-querycache.hh