StackExchange / StackExchange/StackExchange.Redis

Can't write to slave

Open
#354 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

⚙️ area:API ➕ enhancement
Dominant language
C#
Stars
6.2k
Forks
1.6k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

I have a slave with slave-read-only set to no but when I attempt to do a SADD to it I got a No connection is available to service this operation.

at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor`1 processor, ServerEndPoint server) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:line 1857
at StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor`1 processor, ServerEndPoint server) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\RedisBase.cs:line 80
at StackExchange.Redis.RedisDatabase.SetAdd(RedisKey key, RedisValue[] values, CommandFlags flags) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\RedisDatabase.cs:line 921

When I issue SMEMBERS it works fine, I'm assuming it's a write problem.

Inspecting the variables while debugging, I noticed that the Server object has SlaveReadOnly set to false as expected, but there's AllowSlaveWrites also set to false. I don't know how those are set (or what exactly they affect), but I forcefully changed AllowSlaveWrites to true with no luck.

Setting abortConnect=false on configuration string didn't help either.

If I set the instance to master everything works fine.
It's reproducible in my development machine where the redis configuration is pretty much vanilla.
This is not an intermittent error, I get it as soon I start my application.

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 SADD and SMEMBERS entry points in StackExchange/Redis/RedisDatabase.cs, then trace ConnectionMultiplexer.ExecuteSyncImpl in ConnectionMultiplexer.cs around line 1857. Reproduce the commands against a Redis slave and inspect how SlaveReadOnly and AllowSlaveWrites affect server selection. Done means the cause of the write failure is identified and SADD behavior is corrected or clearly documented with coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, redis
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.