]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix SMP mgr:userhash, mgr:sourcehash, and mgr:carp reports (#1844)
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 21 Jun 2024 21:47:04 +0000 (21:47 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 21 Jun 2024 21:47:16 +0000 (21:47 +0000)
    ERROR: Squid BUG: cannot aggregate mgr:userhash:
        check failed: cmd->profile != nullptr
        exception location: cache_manager.cc(102) createRequestedAction

Since 2010 commit 7de94c8c, only worker processes made RegisterAction()
calls associated with the affected cache manager reports. Coordinator
process needs these registrations as well because it uses Mgr::Action
code while iterating report-generating kids[^1].

When fixed Coordinator asks a disker process for an Action report, that
process must recognize the action as well (even when disker has no
information to supply) to avoid triggering similar Action lookup BUGs.

[^1]: Coordinator mostly needs Mgr::Action for stats aggregation, but
even non-aggregating actions (like the fixed three) need registered
Mgr::ActionProfile objects for Coordinator to know whether to aggregate.

src/carp.cc
src/carp.h
src/main.cc
src/peer_sourcehash.cc
src/peer_sourcehash.h
src/peer_userhash.cc
src/peer_userhash.h
src/tests/stub_carp.cc

index 7327f20dc48ded2f6c765f347b14f241ff4b4585..ffc2cf3a1dc9a7884f2cc2b2bdb115c07255bb97 100644 (file)
@@ -9,6 +9,7 @@
 /* DEBUG: section 39    Cache Array Routing Protocol */
 
 #include "squid.h"
+#include "base/RunnersRegistry.h"
 #include "CachePeer.h"
 #include "CachePeers.h"
 #include "carp.h"
@@ -47,7 +48,7 @@ carpRegisterWithCacheManager(void)
     Mgr::RegisterAction("carp", "CARP information", carpCachemgr, 0, 1);
 }
 
-void
+static void
 carpInit(void)
 {
     int W = 0;
@@ -134,6 +135,17 @@ carpInit(void)
     CarpPeers().assign(rawCarpPeers.begin(), rawCarpPeers.end());
 }
 
+/// reacts to RegisteredRunner events relevant to this module
+class CarpRr: public RegisteredRunner
+{
+public:
+    /* RegisteredRunner API */
+    void useConfig() override { carpInit(); }
+    void syncConfig() override { carpInit(); }
+};
+
+DefineRunnerRegistrator(CarpRr);
+
 CachePeer *
 carpSelectParent(PeerSelector *ps)
 {
index 35f2f28c236ce6c3a0831531aa87991784a71066..fde0468ee5707963f79a11f30d1c7f97216f86f2 100644 (file)
@@ -14,7 +14,6 @@
 class CachePeer;
 class PeerSelector;
 
-void carpInit(void);
 CachePeer *carpSelectParent(PeerSelector *);
 
 #endif /* SQUID_SRC_CARP_H */
index 60744a813191da8259cd872576803b1c614623b6..782bacb5984ba6c325435e58f3e55228aa738e77 100644 (file)
@@ -22,7 +22,6 @@
 #include "base/TextException.h"
 #include "cache_cf.h"
 #include "CachePeer.h"
-#include "carp.h"
 #include "client_db.h"
 #include "client_side.h"
 #include "comm.h"
@@ -61,8 +60,6 @@
 #include "parser/Tokenizer.h"
 #include "Parsing.h"
 #include "pconn.h"
-#include "peer_sourcehash.h"
-#include "peer_userhash.h"
 #include "PeerSelectState.h"
 #include "protos.h"
 #include "redirect.h"
@@ -808,12 +805,6 @@ serverConnectionsOpen(void)
         asnInit();
         Acl::Node::Initialize();
         peerSelectInit();
-
-        carpInit();
-#if USE_AUTH
-        peerUserHashInit();
-#endif
-        peerSourceHashInit();
     }
 }
 
@@ -1454,10 +1445,12 @@ RegisterModules()
     // RegisteredRunner event handlers should not depend on handler call order
     // and, hence, should not depend on the registration call order below.
 
+    CallRunnerRegistrator(CarpRr);
     CallRunnerRegistrator(ClientDbRr);
     CallRunnerRegistrator(CollapsedForwardingRr);
     CallRunnerRegistrator(MemStoreRr);
     CallRunnerRegistrator(PeerPoolMgrsRr);
+    CallRunnerRegistrator(PeerSourceHashRr);
     CallRunnerRegistrator(SharedMemPagesRr);
     CallRunnerRegistrator(SharedSessionCacheRr);
     CallRunnerRegistrator(TransientsRr);
@@ -1471,6 +1464,10 @@ RegisterModules()
     CallRunnerRegistrator(NtlmAuthRr);
 #endif
 
+#if USE_AUTH
+    CallRunnerRegistrator(PeerUserHashRr);
+#endif
+
 #if USE_OPENSSL
     CallRunnerRegistrator(sslBumpCfgRr);
 #endif
index a47cf06caf163910242e58c57913289b145f2a60..f8a6f8c9e4f85591e659b5d8b498d5832d59cbe4 100644 (file)
@@ -9,6 +9,7 @@
 /* DEBUG: section 39    Peer source hash based selection */
 
 #include "squid.h"
+#include "base/RunnersRegistry.h"
 #include "CachePeer.h"
 #include "CachePeers.h"
 #include "HttpRequest.h"
@@ -42,7 +43,7 @@ peerSortWeight(const void *a, const void *b)
     return (*p1)->weight - (*p2)->weight;
 }
 
-void
+static void
 peerSourceHashInit(void)
 {
     int W = 0;
@@ -127,6 +128,17 @@ peerSourceHashInit(void)
     SourceHashPeers().assign(rawSourceHashPeers.begin(), rawSourceHashPeers.end());
 }
 
+/// reacts to RegisteredRunner events relevant to this module
+class PeerSourceHashRr: public RegisteredRunner
+{
+public:
+    /* RegisteredRunner API */
+    void useConfig() override { peerSourceHashInit(); }
+    void syncConfig() override { peerSourceHashInit(); }
+};
+
+DefineRunnerRegistrator(PeerSourceHashRr);
+
 static void
 peerSourceHashRegisterWithCacheManager(void)
 {
index dbffd28a4debf70f2c6e22b36121fc263f0e5cf2..797a621ea7e68569acfd6f999fd68af13b0ae3c3 100644 (file)
@@ -14,7 +14,6 @@
 class CachePeer;
 class PeerSelector;
 
-void peerSourceHashInit(void);
 CachePeer * peerSourceHashSelectParent(PeerSelector*);
 
 #endif /* SQUID_SRC_PEER_SOURCEHASH_H */
index f76b1ae4b724c63a52621cd1b5bfe6d26509ef00..1e1251b5690a78978665910aba958b5072732386 100644 (file)
@@ -13,6 +13,7 @@
 #if USE_AUTH
 
 #include "auth/UserRequest.h"
+#include "base/RunnersRegistry.h"
 #include "CachePeer.h"
 #include "CachePeers.h"
 #include "globals.h"
@@ -47,7 +48,7 @@ peerSortWeight(const void *a, const void *b)
     return (*p1)->weight - (*p2)->weight;
 }
 
-void
+static void
 peerUserHashInit(void)
 {
     int W = 0;
@@ -139,6 +140,17 @@ peerUserHashRegisterWithCacheManager(void)
                         0, 1);
 }
 
+/// reacts to RegisteredRunner events relevant to this module
+class PeerUserHashRr: public RegisteredRunner
+{
+public:
+    /* RegisteredRunner API */
+    void useConfig() override { peerUserHashInit(); }
+    void syncConfig() override { peerUserHashInit(); }
+};
+
+DefineRunnerRegistrator(PeerUserHashRr);
+
 CachePeer *
 peerUserHashSelectParent(PeerSelector *ps)
 {
index 82908b83784d2fd6432ff8d0ddec7c71a10e5088..678458e462bfd557bbc769dc1941389739ea44e1 100644 (file)
 #define SQUID_SRC_PEER_USERHASH_H
 
 class CachePeer;
-class HttpRequest;
 class PeerSelector;
 
-void peerUserHashInit(void);
 CachePeer * peerUserHashSelectParent(PeerSelector *);
 
 #endif /* SQUID_SRC_PEER_USERHASH_H */
index 35270c2d8268af93564d11597ef6d4c3d877c92c..d6ecd95434d9fbe6859de391b299602aca966329 100644 (file)
@@ -13,9 +13,5 @@
 
 #include "carp.h"
 
-class CachePeer;
-class PeerSelector;
-
-void carpInit(void) STUB
 CachePeer *carpSelectParent(PeerSelector *) STUB_RETVAL(nullptr)