Skip to content

Update hrw handling of geo DB files to allow varying mmdb across rules.#13025

Draft
cmcfarlen wants to merge 3 commits intoapache:masterfrom
cmcfarlen:refix-hrw-mmdb-load
Draft

Update hrw handling of geo DB files to allow varying mmdb across rules.#13025
cmcfarlen wants to merge 3 commits intoapache:masterfrom
cmcfarlen:refix-hrw-mmdb-load

Conversation

@cmcfarlen
Copy link
Copy Markdown
Contributor

@cmcfarlen cmcfarlen commented Mar 27, 2026

PR #12855 reintroduced a bug that would cause remap rules with header_rewrite plugins configured with mmdb files to never load the mmdb file. This is because the call_once utilitized to initialize the file is a global to the plugin, so applies to every remap instance. This means the first remap instance to load the mmdb will also set it for every other remap instance. If you call call_once without a path, then any remap instances that call mmdb after will silently fail to load.

See $11812 and #12126

Edit:

I decided to try my idea for better handling of mmdb files. The last commit of this PR does just that and allows remap rules with hrw to specify different geo db files rather than the current "first wins" approach. It also avoids the call_once issue that has cause initialization issues in the past.

@cmcfarlen cmcfarlen added this to the 11.0.0 milestone Mar 27, 2026
@cmcfarlen cmcfarlen requested a review from bneradt March 27, 2026 01:00
@cmcfarlen cmcfarlen self-assigned this Mar 27, 2026
@cmcfarlen cmcfarlen added Bug header_rewrite header_rewrite plugin labels Mar 27, 2026
@cmcfarlen
Copy link
Copy Markdown
Contributor Author

[approve ci autest 1 2]

@cmcfarlen
Copy link
Copy Markdown
Contributor Author

We'll have to fix this another way as this breaks the fix for running plugins. Converting to draft.

@cmcfarlen cmcfarlen marked this pull request as draft March 27, 2026 13:47
cmcfarlen and others added 2 commits March 27, 2026 08:54
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.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cmcfarlen
Copy link
Copy Markdown
Contributor Author

This last commit handles the geo db init completely differently, but avoids the call_once issue and allows for rules to vary the mmdb file used.

@cmcfarlen cmcfarlen changed the title Restore old behavior to only call geo init with a geopath Update hrw handling of geo DB files to allow varying mmdb across rules. Mar 27, 2026
Copy link
Copy Markdown
Contributor

@bneradt bneradt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug header_rewrite header_rewrite plugin

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants