Skip to content

fix: Rewrite the persistent store after it recovers from an outage - #530

Draft
keelerm84 wants to merge 2 commits into
mainfrom
mk/SDK-3812/fdv2-store-outage-recovery
Draft

keelerm84 wants to merge 2 commits into
mainfrom
mk/SDK-3812/fdv2-store-outage-recovery

Conversation

@keelerm84

@keelerm84 keelerm84 commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

SDK-3812. Found while reviewing the work for #504, which depends on this fix.

Describe the solution you've provided

FDv2 registers a data store status listener that should rewrite the persistent store from in-memory data when the store comes back available but stale. The listener was built with define_singleton_method(:update) { persistent_store_outage_recovery(...) }. Inside that block self is the listener object, so every status change raised NoMethodError. Broadcaster logs and swallows listener errors, so the store was never rewritten after a Redis/DynamoDB/Consul outage.

The listener now calls the recovery method through a Method object bound to the FDv2 instance.

The existing specs called send(:persistent_store_outage_recovery) directly, which is why they missed this. The new spec pushes a stale status through data_store_status_provider.update_status, so it goes through the broadcaster. It fails without the fix.

Two follow-ups that only matter once the listener runs:

  • A store can report itself available while every write fails (Redis at maxmemory with noeviction, an oversized DynamoDB item). Each recovery rewrite then failed, the wrapper marked the store unavailable, and its poller checked availability again with no delay. The result was a tight loop of full rewrites, each holding the store lock. FeatureStoreClientWrapperV2 now waits one 0.5 s poll interval before its first check, as Go (dataStoreStatusPoller) and Java (PersistentDataStoreStatusManager) do. That allows at most one recovery attempt per 0.5 s.
  • persistent_store_outage_recovery returns early after stop. stop closes the store before shutting down the executor that delivers status changes, so a queued recovery could call init on a closed store.

Additional context

python-server-sdk has a related bug: _persistent_store_outage_recovery in ldclient/impl/datasystem/fdv2.py is defined but never registered as a listener. That is tracked separately and not fixed here.

The FDv2 data store status listener called persistent_store_outage_recovery
from a block passed to define_singleton_method, where self is the listener
object. Every status change raised NoMethodError, which the broadcaster
logged and swallowed, so FDv2 never rewrote Redis/DynamoDB/Consul after an
outage. Call the method through a Method object bound to the FDv2 instance,
and add a spec that drives recovery through the status broadcaster.

SDK-3812
…stop

A store can report itself available while every write fails (Redis at
maxmemory with noeviction, an oversized DynamoDB item). Now that the
recovery listener runs, each recovery rewrites the store, the write fails,
the wrapper marks the store unavailable, and its poller checked
availability again with no delay. That made a tight loop of full rewrites,
each holding the store lock. Wait one poll interval before the first
availability check, as the Go and Java SDKs do, which bounds the cycle to
one attempt per 0.5 s.

FDv2#stop closes the store before shutting down the executor that delivers
status changes, so a queued recovery could call init on a closed store.
Return early once stopped.

SDK-3812

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant