Skip to content

.NET server SDK: an expired flag's cache reload blocks request threads and retries failures one at a time #419

Open

Description

@dgioulakis

.NET server SDK: a flag's cache reload blocks request threads, and failed reloads are retried one waiter at a time

Versions: LaunchDarkly.ServerSdk 8.11.0, LaunchDarkly.ServerSdk.Redis 5.1.1, LaunchDarkly.OpenFeature.ServerProvider 2.1.2, .NET 10. Streaming data source, Redis persistent store, 60 s cache TTL.

What we saw: after moving to StackExchange.Redis 3, which by default reads replies on the shared .NET thread pool (instead of a dedicated thread pool in v2), our production pods were restarted for thread-pool starvation with CPU near idle. The restart we traced began when two flags' cache entries expired. Redis timeouts for the same flag keys then repeated exactly 5 s apart.

Cause in the SDK:

  • An expired entry is evicted rather than refreshed. The next evaluation reloads it synchronously under a per-key lock (LaunchDarkly.Cache, CacheImpl.MaybeComputeValue), and every other evaluation of that flag blocks a thread on that lock.
  • A failed load caches nothing, so each waiter reloads in turn. The Nth waiter waits N times the store timeout.
  • An async store doesn't avoid this. PersistentStoreAsyncAdapter blocks with StartNew(...).Unwrap().GetAwaiter().GetResult(), so the read also needs pool threads while the caller is blocked.

Asks:

  1. Bring the Java SDK's StaleValuesPolicy (REFRESH, REFRESH_ASYNC) to .NET: serve the cached value while one background refresh runs, and keep it if the refresh fails.
  2. Share one load's result with every concurrent waiter, including a failure.
  3. Provide an async evaluation path all the way through, so waiting evaluations don't hold threads.

Question: when every process streams, do you recommend CacheForever, given its warning about stale data when processes share a store?

We've worked around it for now by turning on StackExchange.Redis's DedicatedThreads option.

Activity

  1. tanderson-ld commented on Nov 20, 2026

    @tanderson-ld
    Contributor

    Hi @dgioulakis , we'll dig in and get back to you shortly.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions