From: Remi Gacogne Date: Mon, 22 Mar 2021 13:48:13 +0000 (+0100) Subject: dnsdist: Check that we have more cache entries than shards X-Git-Tag: rec-4.6.0-alpha0~7^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f1ed01516da2585fea83229dd50b64e1e5cc4a85;p=thirdparty%2Fpdns.git dnsdist: Check that we have more cache entries than shards --- diff --git a/pdns/dnsdistdist/dnsdist-lua-bindings-packetcache.cc b/pdns/dnsdistdist/dnsdist-lua-bindings-packetcache.cc index b57d66062d..79c58d558c 100644 --- a/pdns/dnsdistdist/dnsdist-lua-bindings-packetcache.cc +++ b/pdns/dnsdistdist/dnsdist-lua-bindings-packetcache.cc @@ -24,6 +24,7 @@ #include #include "config.h" +#include "dolog.hh" #include "dnsdist.hh" #include "dnsdist-lua.hh" @@ -91,6 +92,12 @@ void setupLuaBindingsPacketCache(LuaContext& luaCtx) } } + if (maxEntries < numberOfShards) { + warnlog("The number of entries (%d) in the packet cache is smaller than the number of shards (%d), decreasing the number of shards to %d", maxEntries, numberOfShards, maxEntries); + g_outputBuffer += "The number of entries (" + std::to_string(maxEntries) + " in the packet cache is smaller than the number of shards (" + std::to_string(numberOfShards) + "), decreasing the number of shards to " + std::to_string(maxEntries); + numberOfShards = maxEntries; + } + auto res = std::make_shared(maxEntries, maxTTL, minTTL, tempFailTTL, maxNegativeTTL, staleTTL, dontAge, numberOfShards, deferrableInsertLock, ecsParsing); res->setKeepStaleData(keepStaleData);