You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add get_with_version for atomic content+version reads
Summary:
Adds `ConfigHandle::get_with_version(&self) -> (Arc<T>, Option<ConfigVersionInfo>)`, an accessor that returns the config contents together with the version metadata (`version` string + `mod_time`) they were parsed from, read atomically from one snapshot.
**The skew problem.** Today a `RegisteredConfigEntity`'s deserialized contents live in a tokio watch channel while `version`/`mod_time` live in a separate `RwLock<CachedConfigEntity>`. `refresh()` sends the new contents to the channel *before* committing the new version to the lock, so calling `get()` and then reading the version separately can pair new contents with the old version (or vice versa) for one refresh cycle.
**The fix.** `CachedConfigEntity` now also carries the deserialized `Arc<T>`, committed in the same write-lock critical section as `version`/`mod_time`; `get_with_version` reads all three under a single read-lock acquisition, so the returned pair always corresponds. `get()` semantics and the watch-channel behavior are unchanged (the extra `Arc` in the lock is just another reference to the same allocation).
**The Fixed contract.** Handles backed by static configs (`from_json`, `default`, `From<T>`) have no version, so the version half is `Option`-typed and they return `(contents, None)` — never a sentinel string. `ConfigVersionInfo` is `#[non_exhaustive]` so future fields (e.g. mutation id) can be added without breaking callers.
Also adds `TestSource::insert_config_with_version` so tests can exercise non-empty versions (`insert_config` previously hardcoded `version: String::new()` and now delegates).
**Consumer.** This is Diff A1 of the Task 32 stack (Mononoke: decouple startup from legacy tier blobs; design doc: configerator `source/scm/mononoke/docs/plans/2026-08-17-task32-blob-decouple-design-final.md`). Mononoke's per-repo config provenance (Diff B) will call this accessor at parse time and log the config version to scuba.
Reviewed By: YousefSalama
Differential Revision: D116321758
fbshipit-source-id: fab12e34e2f2da92da257d62b1a5fbf749685e9d
0 commit comments