You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "cmcfarlen (via GitHub)" <gi...@apache.org> on 2026/03/30 22:55:23 UTC

[PR] Support per-remap geo DB handles in header_rewrite [trafficserver]

cmcfarlen opened a new pull request, #13042:
URL: https://github.com/apache/trafficserver/pull/13042

   Replace the single global geo DB handle with a cache of handles keyed by path, allowing different remap rules to use different MMDB files via --geo-db-path. The handle is threaded through RulesConfig -> Resources -> ConditionGeo::get_geo_*() methods. The cache deduplicates when multiple rules share the same path.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support per-remap geo DB handles in header_rewrite [trafficserver]

Posted by "bneradt (via GitHub)" <gi...@apache.org>.
bneradt commented on PR #13042:
URL: https://github.com/apache/trafficserver/pull/13042#issuecomment-4165064429

   [approve ci autest 0]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support per-remap geo DB handles in header_rewrite [trafficserver]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #13042:
URL: https://github.com/apache/trafficserver/pull/13042#discussion_r3012597641


##########
plugins/header_rewrite/conditions_geo_maxmind.cc:
##########
@@ -23,17 +23,25 @@
 
 #include <unistd.h>
 #include <arpa/inet.h>
+#include <map>
+#include <mutex>
+#include <string>
 
 #include "ts/ts.h"
 
 #include "conditions_geo.h"
 
 #include <maxminddb.h>
 
-MMDB_s *gMaxMindDB = nullptr;
-
 enum class MmdbSchema { NESTED, FLAT };
-static MmdbSchema gMmdbSchema = MmdbSchema::NESTED;
+
+struct MmdbHandle {
+  MMDB_s     db;
+  MmdbSchema schema = MmdbSchema::NESTED;
+};
+
+static std::map<std::string, MmdbHandle *> gMmdbCache;
+static std::mutex                          gMmdbCacheMutex;
 

Review Comment:
   The new MaxMind handle cache stores heap-allocated MmdbHandle instances (and their MMDB_s mmaps) for the lifetime of the process, but there is no corresponding MMDB_close()/delete path. This can lead to unbounded growth in mapped memory / open files if remap instances are recreated over time with different --geo-db-path values. Consider adding reference counting and cleanup (e.g., close+erase when the last RulesConfig using a path is deleted), or a bounded/evicting cache with explicit teardown on shutdown/reload.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support per-remap geo DB handles in header_rewrite [trafficserver]

Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen merged PR #13042:
URL: https://github.com/apache/trafficserver/pull/13042


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org