Repository navigation
[MOD-17631] Add a hide_user_data_from_log accessor to global_config - #10924
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## memark-global-config-wrapper #10924 +/- ##
================================================================
+ Coverage 78.87% 82.19% +3.32%
================================================================
Files 636 636
Lines 82247 82247
Branches 37485 37485
================================================================
+ Hits 64870 67607 +2737
+ Misses 17030 14293 -2737
Partials 347 347
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Rust code that wants a RediSearch setting has to read the RSGlobalConfig extern static, which is unsafe at every call site. Six such reads had grown across four crates, each carrying its own safety argument, and those arguments disagreed with src/config.c: numericCompress, prioritizeIntersectUnionChildren and maxAggregateResults are all registered without REDISMODULE_CONFIG_IMMUTABLE, so CONFIG SET can change them while queries run, yet the comments claimed the fields were fixed at load time. The new crate holds the read in one place. It hands back RSConfig by value rather than a reference, because a &'static RSConfig would assert that nothing writes the static while it lives, which CONFIG SET violates from client threads. The copy is a plain unsynchronised load, matching what the C readers of the same fields do; it can tear against a concurrent write, and removing that race needs the C side to store the fields atomically. Returning the whole struct also lets a caller that needs several settings take one snapshot instead of one read per field, so an operation cannot observe a setting changing halfway through. query_eval_ffi::eval_config does exactly that. Co-Authored-By: Claude Opus 5 <[email protected]>
Review of the wrapper turned up three claims that overstate what a by-value snapshot buys. `get`'s SAFETY comment established liveness and the absence of a reference but not the third precondition for reading a `static mut`, that no other thread writes it — which is exactly the one that does not hold, as the doc comment directly above it already said. The comment now names the race instead of leaving the two in contradiction. For the same reason a snapshot cannot make an operation immune to a concurrent `CONFIG SET`: the struct copy is not atomic, so it narrows the window rather than closing it. `eval_config` additionally called itself the single point where the evaluator reads the global config, which `resolve_scorer` disproves two functions further down. Also mark `get` `#[inline]`, so that a caller wanting one field does not pay for an out-of-line call returning the whole struct in builds without LTO. Co-Authored-By: Claude Opus 5 <[email protected]>
`global_config::get()` returned the whole `RSConfig`. The copy is not atomic, so it did not make the fields it returned agree with one another, while copying a large struct and handing back owned pointers no caller had asked for — among them `defaultScorer`, which `FT.CONFIG SET DEFAULT_SCORER` frees. Replace it with one accessor per field, generated from a macro so a new field cannot be added without the shared safety argument covering it. `default_scorer` is written out rather than generated: it returns `Option<NonNull<c_char>>`, putting the unset case in the type instead of leaving every caller to null-check, and its doc carries the hazard no pointer type can express — the string can be freed while a caller still holds it. Co-Authored-By: Claude Opus 5 <[email protected]>
The `hide-user-data-from-log` Redis server configuration decides whether index, field and key names and query terms are obfuscated before they are logged. Reading it through the crate keeps the Rust side of the logging paths free of a raw read of the `RSGlobalConfig` static. Co-Authored-By: Claude Opus 5 <[email protected]>
88bd547 to
82b3526
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 82b35265bf
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|



Describe the changes in the pull request
global_config([MOD-17631] Add safe global_config crate #10915) covers the settings Rust already read, but nothideUserDataFromLog— the flag that decides whether index, field and key names and query terms are obfuscated before they reach the log. Every one of its ~40 readers is still in C.hide_user_data_from_log()accessor alongside the existing ones. It is a plainboolfield, so it goes through the same macro and inherits the crate's shared safety argument.Which additional issues this PR fixes
Main objects this PR modified
global_config— one new entry in theconfig_accessors!invocation.Mark if applicable
Release Notes
Worth a reviewer's attention
Unlike the settings already exposed, this one is not an
FT.CONFIGknob: it is thehide-user-data-from-logRedis server configuration, whichonUpdatedHideUserDataFromLogsmirrors into
RSGlobalConfigfrom the config-change event. The doc comment says so, so that areader does not go looking for it in
FT.CONFIG GET.Stacked on #10915; review that one first, and this diff on its own is six lines.