With this commit, the number of (packet)cache entries can be changed at runtime, although the effect may not be immediate in case of shrinking the cache.
static bool g_gettagNeedsEDNSOptions{false};
static time_t g_statisticsInterval;
static bool g_useIncomingECS;
+std::atomic<uint32_t> g_maxCacheEntries, g_maxPacketCacheEntries;
RecursorControlChannel s_rcc; // only active in thread 0
RecursorStats g_stats;
if(now.tv_sec - last_prune > (time_t)(5 + t_id)) {
DTime dt;
dt.setTimeval(now);
- t_RC->doPrune(); // this function is local to a thread, so fine anyhow
- t_packetCache->doPruneTo(::arg().asNum("max-packetcache-entries") / g_numWorkerThreads);
+ t_RC->doPrune(g_maxCacheEntries / g_numThreads); // this function is local to a thread, so fine anyhow
+ t_packetCache->doPruneTo(g_maxPacketCacheEntries / g_numWorkerThreads);
- SyncRes::pruneNegCache(::arg().asNum("max-cache-entries") / (g_numWorkerThreads * 10));
+ SyncRes::pruneNegCache(g_maxCacheEntries / (g_numWorkerThreads * 10));
if(!((cleanCounter++)%40)) { // this is a full scan!
time_t limit=now.tv_sec-300;
g_dnssecLogBogus = ::arg().mustDo("dnssec-log-bogus");
g_maxNSEC3Iterations = ::arg().asNum("nsec3-max-iterations");
+ g_maxCacheEntries = ::arg().asNum("max-cache-entries");
+ g_maxPacketCacheEntries = ::arg().asNum("max-packetcache-entries");
+
try {
loadRecursorLuaConfig(::arg()["lua-config-file"], ::arg().mustDo("daemon"));
}
return "New minimum TTL: " + std::to_string(SyncRes::s_minimumTTL) + "\n";
}
+template<typename T>
+string setMaxCacheEntries(T begin, T end)
+{
+ if(end-begin != 1)
+ return "Need to supply new cache size\n";
+ g_maxCacheEntries = pdns_stou(*begin);
+ return "New minimum TTL: " + std::to_string(g_maxCacheEntries) + "\n";
+}
+
+template<typename T>
+string setMaxPacketCacheEntries(T begin, T end)
+{
+ if(end-begin != 1)
+ return "Need to supply new packet cache size\n";
+ g_maxPacketCacheEntries = pdns_stou(*begin);
+ return "New minimum TTL: " + std::to_string(g_maxPacketCacheEntries) + "\n";
+}
+
static uint64_t getSysTimeMsec()
{
"reload-lua-script [filename] (re)load Lua script\n"
"reload-lua-config [filename] (re)load Lua configuration file\n"
"reload-zones reload all auth and forward zones\n"
+"set-max-cache-entries value set new maximum cache size"
+"set-max-packetcache-entries val set new maximum packet cache size"
"set-minimum-ttl value set minimum-ttl-override\n"
"set-carbon-server set a carbon server for telemetry\n"
"set-dnssec-log-bogus SETTING enable (SETTING=yes) or disable (SETTING=no) logging of DNSSEC validation failures\n"
return reloadAuthAndForwards();
}
+ if(cmd=="set-max-cache-entries") {
+ return setMaxCacheEntries(begin, end);
+ }
+ if(cmd=="set-max-packetcache-entries") {
+ return setMaxPacketCacheEntries(begin, end);
+ }
+
if(cmd=="set-minimum-ttl") {
return setMinimumTTL(begin, end);
}
pruneCollection(*this, d_cache, keep);
}
-void MemRecursorCache::doPrune(void)
-{
- unsigned int maxCached=::arg().asNum("max-cache-entries") / g_numThreads;
- doPrune(maxCached);
-}
void replace(time_t, const DNSName &qname, const QType& qt, const vector<DNSRecord>& content, const vector<shared_ptr<RRSIGRecordContent>>& signatures, const std::vector<std::shared_ptr<DNSRecord>>& authorityRecs, bool auth, boost::optional<Netmask> ednsmask=boost::none, vState state=Indeterminate);
- void doPrune(void);
void doPrune(unsigned int keep);
uint64_t doDump(int fd);
DNSSEC validation failures and to 'no' or 'off' to disable logging these
failures.
+set-max-cache-entries *NUM*
+ Change the maximum number of entries in the DNS cache. If reduced, the
+ cache size will start shrinking to this number as part of the normal
+ cache purging process, which might take a while.
+
+set-max-packetcache-entries *NUM*
+ Change the maximum number of entries in the packet cache. If reduced, the
+ cache size will start shrinking to this number as part of the normal
+ cache purging process, which might take a while.
+
set-minimum-ttl *NUM*
Set minimum-ttl-override to *NUM*.
extern RecursorStats g_stats;
extern unsigned int g_numThreads;
extern uint16_t g_outgoingEDNSBufsize;
+extern std::atomic<uint32_t> g_maxCacheEntries, g_maxPacketCacheEntries;
std::string reloadAuthAndForwards();