StackExchange / StackExchange/StackExchange.Redis

Is there a way to execute individual commands with FailFast behavior?

Open
#2,645 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
6.2k
Forks
1.6k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

I have some logic using the RedLock algorithm to fire commands against multiple servers and recover if some servers are down. I recently updated from 2.2.4 to 2.7.17, and some of my tests are failing because the redis client now takes much longer to return when the server is disconnected. Switching the multiplexer to use BacklogPolicy.FailFast fixes this, but in general I want the new policy, just not for these particular operations where I want to fail quickly.

Is there a recommended way to achieve this? Should I be calling IDatabase.IsConnected() before every fail fast request and bailing if that returns false or is that going to hurt performance/have different semantics? If there's no way to achieve this, would it make sense to add a CommandFlags option to support it?

The way I simulate a downed server in my tests is as follows:

  • Launch a Redis process
  • Connect to it via a multiplexer
  • Grab an IDatabase instance off the multiplexer
  • Kill the Redis process with multiplexer.GetServer(...).Shutdown(ShutdownMode.Never);

Thanks for creating and maintaining this great library!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the BacklogPolicy.FailFast behavior, IDatabase.IsConnected(), and CommandFlags, then review the reported Redis shutdown reproduction. Determine whether per-command fail-fast behavior is supported or needs an API change, and document the recommended approach or the decision on adding a CommandFlags option.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, redis
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.