From f1ed01516da2585fea83229dd50b64e1e5cc4a85 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 22 Mar 2021 14:48:13 +0100 Subject: [PATCH] dnsdist: Check that we have more cache entries than shards --- pdns/dnsdistdist/dnsdist-lua-bindings-packetcache.cc | 7 +++++++ 1 file changed, 7 insertions(+) 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); -- 2.47.2