-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Resolve and switch master from sentinel. #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@CamW I want to use your solution within our project and need to know if you successfully run changes in production and if master switch on failure works as expected? |
|
@psulek Yes, we have been running the changes in production since shortly after that commit, so for almost a year now. Master switch on failure has been working and we've found no issues with it. This version is getting a little old now though, I've been meaning to merge it in with the latest official Stack Exchange version. Also note, we're still running redis version 2.8. I'll try to find time to merge in the latest changes this week. Let me know if you need any help. |
|
@CamW thanks for reply. So you want to merge your commit to latest SE.Redis version? This will be great! Btw we have redis 3.x servers but i hope it should work with it too. |
|
@CamW As i see in commit, you just utilize single sentinel server. Do you plan to add support for multiple sentinel servers? |
|
Multiple sentinel servers are already supported, if you have a look at the On 20 July 2015 at 10:01, Peter Šulek [email protected] wrote:
|
|
Yes, that's right I do want to merge the latest changes in, I'll let you Cameron Waldron
|
|
Does method "GetConfiguredMasterForService" or other iterate all sentinel servers to detect master redis? I mean if majority of sentinels agree on same master, that redis server will act as master? Or other code which skip faling sentinel server and ask another working sentinel server for master? |
|
The "GetConfiguredMasterForService" method makes parallel calls to all Cameron Waldron
|
|
Thanks, i understand that. Really thanks for that contribution! |
|
Any update on merge? Is it already in main branch? |
|
@CamW any chance you can merge the latest master? |
|
@CamW I'm experiencing problems with this solution after merge with current master branch (12th of August 2015). When master-switch occurs , then your code block: "fight" with internal Will you have time to try your code with current latest master branch and post update? |
…ge.Redis Conflicts: MigratedBookSleeveTestSuite/MigratedBookSleeveTestSuite.csproj StackExchange.Redis.Tests/StackExchange.Redis.Tests.csproj StackExchange.Redis/StackExchange/Redis/ConfigurationOptions.cs StackExchange.Redis/StackExchange/Redis/ConnectionMultiplexer.cs
|
@psulek I performed the merge when we discussed it several weeks ago but haven't had a chance to test so I didn't commit it but I have committed now (still not tested). You or @chester89 are welcome to have a look at my latest push and let me know if there are any issues. |
|
@CamW Thanks a lot, i will test it right now a let you know. |
|
@CamW I test your latest merge and it still failing on same problem described above. Long problem description: In your unit test I managed to work for me when i change But anyway there should be some way to ensure that reconfiguration of master happens ALWAYS when needed and will not be blocked. I just created sample Console app to demonstrate the problem, found it on my GitHub-StackExchange.Redis.SentinelTests. @CamW if you have time to look at it and try to "fix" it somehow i will buy you a beer. I try it myself to fix it but without success. |
|
Hi Everyone, I tried redis master/slave server setup (slave - readonly) where there are 4 sentinels (1 in master server , 2 in slave and 2 witness sentinels in 2 separate servers). Instead of connecting to sentinels from the client to know who is the master, i configured my connection multiplexer as mentioned below Whenever the master goes down and the slave is elected as a master , the redis client connects to the current master. It tested this automatic failover serveral times and it works fine. Is there any reason on why client must connect to the sentinels ? Below is an extract from https://github.com/StackExchange/StackExchange.Redis/blob/8e6c8c0d281862df01ce47eef0c2efa536959f95/Docs/Basics.md "A more complicated scenario might involve a master/slave setup; for this usage, simply specify all the desired nodes that make up that logical redis tier (it will automatically identify the master): |
|
Thanks for contributing to the discussion, @ranjithvikram. The trouble I encountered with attempting to use the automatic master detection when I last tried it, in the December 2014 to January 2015 state, was thus:
If the underlying behavior of this client software has changed, that would be great news. Maybe the software, on failure of a write operation, could poll the set of servers it has to determine which is the new master. That might be an alternate way to solve this problem that does not require integrating Sentinel, although this strategy has its own pitfalls. I'm going to go read some of the source code now to better educate myself on what is really happening under the hood. |
|
@obscurerichard Thanks for the details provided. What you said is correct. I looked into the code and found that after every failure, the connectionmultiplexer reconfigures and connects to the newly elected Master. Refer : PhysicalBridge.OnConnectionFailed(PhysicalConnection connection, ConnectionFailureType failureType, Exception innerException) In both the approaches(connecting to sentinels/connecting to logical redis tier), there will be write failures until the sentinels elects the new master. This is well known. Other than this, can you tell me what are the pitfalls in this approach? |
|
In a split brain cluster partition situation, where the sentinels have elected a new master, but the old master still thinks it is a master, this reliance on the clients to poll the set of servers fails. This will lead to a possibly extended period of lost writes when the cluster heals. That's why you really want to talk to the sentinels in order to figure out who the real master of the cluster is. |
|
Using sentinels over direct list of master servers has another benefit. For example we have 2 masters(and some slaves) and 3 sentinels watching on them. But anytime we need to "hot plug" another master server, we can do this without stopping our application and add new master endpoint to app config. Instead we add new master to redis sentinel configs. After adding new master to sentinel, if any/all of old masters fails, sentinel will switch to new master just plugged in and our application stay alive. |
|
@psulek I can't reproduce the error you're seeing using your test app.
|
|
@CamW , my answers:
Hopes this helps |
|
Not closing this out to close the idea, just consolidating PRs. Working on #692 to get Sentinel support in soon. |
So I've had a first go at putting service resolution and master switching based on sentinel messages into the client. I read #22 and http://redis.io/topics/sentinel-clients before getting started. While I tried to follow Marc's advice I ran into some trouble (possibly just because I'm unfamiliar with the code base) around having multiple server types in the same ConnectionMultiplexer.
I decided instead to do it with one multiplexer for sentinel servers and another for the standard redis servers. The issues I ran into were mostly down to config of the multiplexer and that you would often want different config for the sentinels and actual redis servers. Examples of this: Password, Admin, Tie Breaking.
Also there is a single CommandMap which would need to be switched around depending on which type of server you're communicating with.
Let me know what you think. I'm happy to look at reworking this if you have some ideas.
Thanks
Cameron.