Skip to content

fix: Log the cached-data evaluation warning only once per client - #520

Merged
kinyoklion merged 1 commit into
mainfrom
rlamb/log-cached-data-warning-once
Sep 15, 2026
Merged

kinyoklion merged 1 commit into
mainfrom
rlamb/log-cached-data-warning-once

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Sep 11, 2026

Copy link
Copy Markdown
Member

Summary

When data availability is CACHED, every evaluation and every all_flags_state() call logs a warning that the client is using last known values from the feature store. While the client stays in that state, this floods the log with one line per evaluation.

Each of these messages now logs once per client instance. LDClient and AsyncLDClient each hold two flags, one for the evaluation message and one for the all_flags_state() message. The messages say that they are logged once.

In LDClient, a threading.Lock guards the set of each flag. The lock is reached only inside the CACHED branch and only until the flag is set, so the normal evaluation path never touches it. Python has no lock-free atomic flag in the standard library. In AsyncLDClient, a plain boolean is enough because one event loop runs the client and no await separates the check and the set.

The sibling messages for the DEFAULTS case and the availability check itself are unchanged.


Note

Overview
Stops log flooding when the SDK serves flags from cached store data before the data source has reached REFRESHED. Warnings for variation / evaluation and for all_flags_state() now emit once per client instead of on every call, with copy noting "This message is logged once."

LDClient adds per-message boolean flags guarded by a threading.Lock (double-checked) so concurrent evaluations only log once. AsyncLDClient uses the same two flags without a lock, relying on single-threaded event-loop semantics between check and set.

Behavior when data is unavailable (non-CACHED) is unchanged. Tests simulate cached-but-uninitialized clients and assert a single warning per message type after repeated calls.

Reviewed by Cursor Bugbot for commit 08b2230. Bugbot is set up for automated code reviews on this repo. Configure here.

@kinyoklion
kinyoklion marked this pull request as ready for review September 15, 2026 17:48
@kinyoklion
kinyoklion requested a review from a team as a code owner September 15, 2026 17:48
@kinyoklion
kinyoklion merged commit 59ce998 into main Sep 15, 2026
25 of 27 checks passed
@kinyoklion
kinyoklion deleted the rlamb/log-cached-data-warning-once branch September 15, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants