Skip to content

fix: Write FDv2 data back to the persistent store after a store outage - #503

Open
kinyoklion wants to merge 1 commit into
mainfrom
rlamb/sdk-3704/store-write-back
Open

kinyoklion wants to merge 1 commit into
mainfrom
rlamb/sdk-3704/store-write-back

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

After a persistent store outage, the FDv2 data system never wrote its in-memory data back to the store. The status listener calls persistent_store_outage_recovery from a block given to define_singleton_method, where self is the listener, so each call raised NoMethodError, which the broadcaster logged and dropped. The listener now calls the method through a Method object. The write-back also left out deleted items, because InMemoryFeatureStoreV2#all filters them, and tombstones carried a Symbol key, which made the DynamoDB store put and delete the same item in one batch. Both are fixed. The contract test service now advertises persistent-data-store-recovery and gives the harness Consul DSN to the Consul store; without these the store recovery tests do not run, and the Consul ones bypass the harness store proxy.

Still failing: persistent data store/dynamodb/store recovery/retries write back after another failure. The AWS client retries the cut write-back request itself and reports success, so the SDK never starts a fresh write-back. Whether client retries should count as a failed write-back is a separate question.

Testing: the new specs fail without the change; the v3 store recovery contract tests go from 2/18 to 17/18 passing.

SDK-3704

Opened from termag


Note

Overview
Fixes FDv2 persistent store recovery so in-memory state is written back when the store comes online with stale data, and so recovery listeners actually run.

The outage listener now invokes persistent_store_outage_recovery through a bound Method instead of calling it on the listener object (which previously raised NoMethodError and skipped write-back). Store#commit persists deletions by using new all_including_deleted and encoding delete tombstones with string keys, preventing resurrected items and DynamoDB put/delete conflicts.

Contract harness changes advertise persistent-data-store-recovery and normalize Consul DSNs to http://host:port URLs. Specs cover tombstone commits and status-driven recovery write-back.

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

When a persistent store becomes available again after an outage, the FDv2
data system must write its in-memory data back to the store. The status
listener that starts the write-back called persistent_store_outage_recovery
from a block given to define_singleton_method, where self is the listener
object, so every call raised NoMethodError and the write-back never ran.
The listener now calls the method through a Method object.

The write-back also left out deleted items, because InMemoryFeatureStoreV2#all
filters them, so a flag deleted during the outage lost its tombstone. Store#commit
now writes deleted items too. Tombstones now carry the key as a String, as
other items do; with a Symbol key, the DynamoDB store wrote and deleted the
same item in one batch and the write-back failed.

The contract test service now advertises persistent-data-store-recovery and
passes the Consul DSN to the Consul store, so that the store recovery tests
run and the Consul tests use the store address that the harness gives.

Generated-by: termag
@kinyoklion
kinyoklion marked this pull request as ready for review November 20, 2026 18:38
@kinyoklion
kinyoklion requested a review from a team as a code owner November 20, 2026 18:38

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: medium.

Automated risk review (dry run): Medium

This PR would not be automatically approved. Human approval required.

Why: Persistent-store write-back after an FDv2 outage is a data-correctness change in lib/ldclient-rb/impl/data_system/fdv2.rb and lib/ldclient-rb/impl/data_store/store.rb (tombstones and the recovery listener), so this is not a narrow low-risk fix. Human review is needed, and no reviewers were assigned.

If you disagree with this review, share this PR in #feedback-agent-approvals or submit a changes-requested review explaining why.

Open in Web View Automation 

Sent by Cursor Approval Agent: Dry-Run PR Approver

@cursor cursor Bot added the risk:medium label Nov 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant