Commit 7e20016
Log duplicate string map option keys
Summary:
Review context
This child responds to the following comment from Anton (`alikhtarov`) on D113813215:
> Consider logging on duplicates/empty keys to MC_FAILURES or similar
What this addresses:
`parseStringMapOption()` resolves duplicate keys silently — regular `string_map` options keep the first value, `--additional-config-params` keeps the last. Neither policy surfaced the discarded value, so a config typo, or a template that substitutes into a key already present (e.g. `%PROC_NAME%:a,cmd:b` when the process is named `cmd`), just disappeared.
Duplicates are now logged as a `Category::kInvalidOption` failure naming the key, the value used, and the value ignored. Detection uses a `find()` before insert instead of branching between `emplace()` and `insert_or_assign()`, so both parsing policies share one log statement. Which value wins is unchanged.
Where these land, and a caveat:
`LOG_FAILURE` reaches `mc_failures` through `ScubaFailureLogger` once `initFailureLogger()` has registered the `scubaMcFailure` handler. String map options are parsed before that point — `updateFromDict()` and the `--additional-config-params` merge both run earlier in `setupStandaloneMcrouter()`, and embedded clients build `McrouterOptions` before `CarbonRouterInstance::init()`. So at standalone startup these reach stderr/glog, not scuba.
That is the same behavior as every other option-parse failure: the `Unknown option name` `LOG_FAILURE` in `updateFromDict()` has the identical ordering. I prototyped deferring just these reports through a collect-and-flush helper, but it meant process-wide state and a lock that no other log site here needs, for one call site. The fix that actually pays for itself is buffering pre-handler failures inside `LogFailure` and replaying them to handlers as they register, which fixes the whole class at once — happy to write that as a follow-up if you want duplicates in scuba specifically.
What this does not address:
Empty pairs, the other half of the comment. They already throw for regular `string_map` options; the silent skip is limited to `--additional-config-params`. Happy to add that too.
Reviewed By: djvaporize
Differential Revision: D114799408
fbshipit-source-id: 76daf3d0029f7aed85e56f2901db91fb504fc5561 parent 95c4ee0 commit 7e20016
1 file changed
Lines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
56 | | - | |
| 54 | + | |
| 55 | + | |
57 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
58 | 69 | | |
59 | 70 | | |
60 | 71 | | |
| |||
0 commit comments