{"action":"opened","issue":{"url":"https://api.github.com/repos/StackExchange/StackExchange.Redis/issues/282","labels_url":"https://api.github.com/repos/StackExchange/StackExchange.Redis/issues/282/labels{/name}","comments_url":"https://api.github.com/repos/StackExchange/StackExchange.Redis/issues/282/comments","events_url":"https://api.github.com/repos/StackExchange/StackExchange.Redis/issues/282/events","html_url":"https://github.com/StackExchange/StackExchange.Redis/issues/282","id":107482321,"number":282,"title":"\"Command cannot be issued to a slave\" after a Redis cluster failover","user":{"login":"actionthomas","id":1763624,"avatar_url":"https://avatars.githubusercontent.com/u/1763624?v=3","gravatar_id":"","url":"https://api.github.com/users/actionthomas","html_url":"https://github.com/actionthomas","followers_url":"https://api.github.com/users/actionthomas/followers","following_url":"https://api.github.com/users/actionthomas/following{/other_user}","gists_url":"https://api.github.com/users/actionthomas/gists{/gist_id}","starred_url":"https://api.github.com/users/actionthomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/actionthomas/subscriptions","organizations_url":"https://api.github.com/users/actionthomas/orgs","repos_url":"https://api.github.com/users/actionthomas/repos","events_url":"https://api.github.com/users/actionthomas/events{/privacy}","received_events_url":"https://api.github.com/users/actionthomas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-21T10:16:04Z","updated_at":"2015-09-21T10:16:04Z","closed_at":null,"body":"I'm currently testing failover with the latest client version (1.0.481).\r\nWhen Redis performs a failover (for testing purposes, I'm issuing the \"cluster failover\" command manually), if I try to make a Write operation, the client throws a `MasterOnly` exception.\r\nBut on the Redis side, master and slaves have changed.\r\n\r\nMy setup : a 6 instances redis cluster.\r\n```prose\r\n127.0.0.1:6379> cluster nodes\r\n4b1bc1008e8efae3b34a71a9370d544d3c08caea 10.9.28.73:6381 master - 0 144282823222\r\n8 25 connected 5461-10922\r\n60c6a00e1d72f91e3faee4206a1202fa653b78bd 10.9.28.74:6379 myself,slave 4b1bc1008e\r\n8efae3b34a71a9370d544d3c08caea 0 0 24 connected\r\n0b8378cca831e69118b066f78485cc5ee22a86d3 10.9.28.74:6380 slave bfe3865e346c5cee1\r\ne6c754701569ed45423b114 0 1442828232556 4 connected\r\n2943a1c1f78a60729ccb1b2c2f2fb96ad4600ede 10.9.28.73:6380 master - 0 144282823190\r\n0 2 connected 10923-16383\r\nbfe3865e346c5cee1e6c754701569ed45423b114 10.9.28.73:6379 master - 0 144282823146\r\n4 1 connected 0-5460\r\n1e7ce773ae14cba010b0d6e5390fd9e7305f40af 10.9.28.74:6381 slave 2943a1c1f78a60729\r\nccb1b2c2f2fb96ad4600ede 0 1442828232992 6 connected\r\n```\r\nThe C# test client :\r\n```csharp\r\nprivate static void Main(string[] args)\r\n{\r\n            var mpx = ConnectionMultiplexer.Connect(\"10.9.28.73:6379,10.9.28.73:6380,10.9.28.74:6379,10.9.28.74:6380,10.9.28.73:6381,10.9.28.74:6381\", Console.Out);\r\n            var db = mpx.GetDatabase();\r\n\r\n             while (true)\r\n            {\r\n                try\r\n                {\r\n                    db = mpx.GetDatabase();\r\n                    db.KeyExpire(\"test\", TimeSpan.FromMinutes(1));\r\n                }\r\n                catch (Exception ex)\r\n                {\r\n                    Console.Write(ex);\r\n                }\r\n            }\r\n}\r\n```\r\nAfter issuing the failover command, here are the nodes :\r\n```prose\r\n127.0.0.1:6379> cluster nodes\r\n4b1bc1008e8efae3b34a71a9370d544d3c08caea 10.9.28.73:6381 slave 60c6a00e1d72f91e3\r\nfaee4206a1202fa653b78bd 0 1442829978122 28 connected\r\n60c6a00e1d72f91e3faee4206a1202fa653b78bd 10.9.28.74:6379 myself,master - 0 0 28\r\nconnected 5461-10922\r\n0b8378cca831e69118b066f78485cc5ee22a86d3 10.9.28.74:6380 slave bfe3865e346c5cee1\r\ne6c754701569ed45423b114 0 1442829977686 4 connected\r\n2943a1c1f78a60729ccb1b2c2f2fb96ad4600ede 10.9.28.73:6380 master - 0 144282997845\r\n0 2 connected 10923-16383\r\nbfe3865e346c5cee1e6c754701569ed45423b114 10.9.28.73:6379 master - 0 144282997801\r\n3 1 connected 0-5460\r\n1e7ce773ae14cba010b0d6e5390fd9e7305f40af 10.9.28.74:6381 slave 2943a1c1f78a60729\r\nccb1b2c2f2fb96ad4600ede 0 1442829979214 6 connected\r\n```\r\n(10.9.28.74:6379 is now a master). \r\nThe client catches the exception\r\n```prose\r\nStackExchange.Redis.RedisConnectionException: ProtocolFailure on EXPIRE ---> StackExchange.Redis.RedisCommandException: Command cannot be issued to a slave: EXPIRE test\r\n   à StackExchange.Redis.PhysicalBridge.WriteMessageToServer(PhysicalConnection connection, Message message) dans C:\\Repos\\StackExchange.Redis\\StackExchange.Redis\\StackExchange\\Redis\\PhysicalBridge.cs:ligne 766\r\n   --- Fin de la trace de la pile d'exception interne ---\r\n   à StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor`1 processor, ServerEndPoint server) dans C:\\Repos\\StackExchange.Redis\\StackExchange.Redis\\StackExchange\\Redis\\ConnectionMultiplexer.cs:ligne 1935\r\n   à StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor`1 processor, ServerEndPoint server) dans C:\\Repos\\StackExchange.Redis\\StackExchange.Redis\\StackExchange\\Redis\\RedisBase.cs:ligne 80\r\n   à StackExchange.Redis.RedisDatabase.KeyExpire(RedisKey key, Nullable`1 expiry, CommandFlags flags) dans C:\\Repos\\StackExchange.Redis\\StackExchange.Redis\\StackExchange\\Redis\\RedisDatabase.cs:ligne 420\r\n   à test.Program.Main(String[] args) dans test\\Program.cs:ligne 62\r\n```\r\nHere is the verbose output of the Redis client :\r\n```prose\r\nRead sockets: 1\r\nMore bytes available: 29 (29)\r\nError: MOVED 6918 10.9.28.74:6379\r\nMatching result...\r\nResponse to: [0]:EXPIRE test (BooleanProcessor)\r\nNow pending: 1\r\nRequesting write: 10.9.28.74:6379/Interactive\r\nWriting queue from bridge\r\nNow pending: 0\r\nWriting: [0]:EXPIRE test (BooleanProcessor)\r\nEXPIRE re-issued to 10.9.28.74:6379\r\nProcessed: 1\r\nBuffer exhausted\r\nWrite failed: Command cannot be issued to a slave: EXPIRE test\r\nPulsed\r\nCompleted synchronously: [0]:EXPIRE test (BooleanProcessor)\r\n```\r\nIt looks like the client holds a sort of static list of servers with their associated running modes ; which is not updated after a failover.\r\nThanks for your help."}}