Repository navigation
fix: Prevent the async FDv2 data system from writing to a persistent store after close - #589
Merged
Conversation
…store after close
There was a problem hiding this comment.
Risk: low.
Automated risk review (dry run): Low
This PR would be automatically approved.
Why: Narrow, tested port of the existing sync FDv2 store wrapper’s post-close write guard into _AsyncFeatureStoreClientWrapper in ldclient/impl/datasystem/async_fdv2.py, with coverage in ldclient/testing/impl/datasystem/test_async_fdv2.py. Cursor Bugbot completed successfully with no findings.
If you disagree with this review, share this PR in #feedback-agent-approvals or submit a changes-requested review explaining why.
Sent by Cursor Approval Agent: Dry-Run PR Approver
kinyoklion
approved these changes
Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
The async FDv2 data system's store wrapper ignored its closed flag for writes, so
init,upsertanddeletecould still reach a persistent store afterclose(). The sync wrapper has refused writes after close since the FDv1 data system was removed (#573). This ports the same guard to the async wrapper.close()hold one async lock. A write that starts after close does nothing:upsertanddeletereturnFalseandinitreturns without writing.close()waits for a write in progress before it closes the store.No live path is known today, because
stop_allcancels the data source tasks before the store closes. A task that outlives the 5s stop timeout could still write, and this closes that gap.Note
Overview
The async FDv2
_AsyncFeatureStoreClientWrappernow matches the sync store wrapper’s close semantics: anAsyncLockserializesinit,upsert,delete, andclose().init/upsert/deleterun through a new_writehelper that no-ops when the wrapper is already closed (upsert/deletereturnFalse;initreturns without touching the inner store).close()takes the same lock before setting_closed, so it blocks until any in-flight write finishes, then proceeds with poller shutdown and innerclose().Tests cover post-close writes not reaching the fake store and
close()waiting on a slowupsert.Reviewed by Cursor Bugbot for commit 8364980. Bugbot is set up for automated code reviews on this repo. Configure here.