News for hackers. Stuff that matters.
Re:RethinkDB 2.1 beta: automatic failover with Raft by coffeemug on Thursday July 16, 2015 @02:37PM (#9899086)
Hey guys, Slava @ RethinkDB here. I'll be around all day to answer questions.

We're super-excited about this beta. We've been working on Raft, automatic failover, and all the relevant enhancements for over a year. It's a massive engineering project that's getting very close to production quality, and it feels so good to finally get it into people's (proverbial) hands!

Re:RethinkDB 2.1 beta: automatic failover with Raft by scott_karana on Thursday July 16, 2015 @02:53PM (#9899187)
Congratulations! Have you been testing this with Jepsen internally, out of curiosity? :)
Re:RethinkDB 2.1 beta: automatic failover with Raft by coffeemug on Thursday July 16, 2015 @02:55PM (#9899201)
Yes, of course! We've also been working with Kyle to understand the Jepsen codebase better. RethinkDB does really well on the Jepsen tests in our internal testing. Of course it's up to Kyle to have the final word :)
Re:RethinkDB 2.1 beta: automatic failover with Raft by chrisfosterelli on Thursday July 16, 2015 @06:49PM (#9900349)
Hi Slava. Excuse me if this is a beginner's question, but on your FAQ[0] page the author argues that it makes more sense for the primary to not failover because this avoids split-brain problems during netsplits.

If you've switched to this new Raft algorithm, does this address the split-brain problem? What will now happen if a netsplit occurs and two primaries are elected, then rejoined?

[0] http://rethinkdb.com/docs/architecture/#cap-theorem

Re:RethinkDB 2.1 beta: automatic failover with Raft by coffeemug on Thursday July 16, 2015 @07:23PM (#9900464)
Chris, I think we didn't communicate this well. When we were first building RethinkDB we looked at other similar products and noticed that they don't perform well in split-brain scenarios, and allow all kinds of errors and issues to creep in. For examples of this, just read Aphyr's posts that review various distributed systems.

So we thought, first, let's build a system based on manual failover, make that really solid, learn as much as possible about real-world use cases, and then build automatic failover on top of that.

This process took a couple of years, and we're finally at a point where we can ship automatic failover that we're confident will behave correctly in real-world (and theoretical) scenarios (modulo bugs that may not have been uncovered in testing).

To answer your specific question, if a netsplit occurs, two primaries could never be elected. There will be a primary either one side, or the other side of the split, so rejoining will not be a problem.

In practice, however, this is more subtle -- what if there is a netsplit, one side maintains its primary, and the other side elects a new one? What if the user writes to both primaries on either side? What happens after the cluster rejoins? In this specific case, we solve this by requiring the majority of the replicas to acknowledge writes by default before the write acknowledgement is sent to the client.

These questions can get really, really subtle -- (for example, what happens if there are multiple cascading netsplits in your cluster?) We wanted to take the time to understand these problems much better before we build automated failover, so we went with a manual failover system first.

Re:RethinkDB 2.1 beta: automatic failover with Raft by chrisfosterelli on Thursday July 16, 2015 @07:30PM (#9900499)
> In practice, however, this is more subtle -- what if there is a netsplit, one side maintains its primary, and the other side elects a new one? What if the user writes to both primaries on either side? What happens after the cluster rejoins? In this specific case, we solve this by requiring the majority of the replicas to acknowledge writes by default before the write acknowledgement is sent to the client.

That's the particular case that I was curious about, that solution makes a lot of sense. I suppose that would also mean that if an outage takes out more than half of your replicas then you will loose all write-abilities (unless I'm mistaken), but that's probably better than the potential mess that could ensue.

Do these write requests to nodes that have no route to a primary simply "hang", or are they rejected by the daemon?

Re:RethinkDB 2.1 beta: automatic failover with Raft by coffeemug on Thursday July 16, 2015 @07:38PM (#9900533)
> That's the particular case that I was curious about, that solution makes a lot of sense. I suppose that would also mean that if an outage takes out more than half of your replicas then you will loose all write-abilities

That's correct. We've built in an "emergency repair" provisions into the product to handle cases like this, should they happen, but that requires manual intervention. (In general, if you lose more than half of your servers, you want to intervene manually anyway)

> Do these write requests to nodes that have no route to a primary simply "hang", or are they rejected by the daemon?

They time out via normal TCP mechanisms and get rejected.

Re:RethinkDB 2.1 beta: automatic failover with Raft by chrisfosterelli on Thursday July 16, 2015 @07:52PM (#9900591)
Sounds like you guys are taking a pretty reasonable approach to all this, thanks for letting me pick your brain!
Re:RethinkDB 2.1 beta: automatic failover with Raft by fweespeech on Thursday July 16, 2015 @03:06PM (#9899264)
Are you aiming for production quality over WAN or LAN?

Obviously latency is an issue but I'm not sure with the way RethinkDB replicates what the performance penalty would be for WAN in terms of write latency.

Re:RethinkDB 2.1 beta: automatic failover with Raft by coffeemug on Thursday July 16, 2015 @03:10PM (#9899285)
We are aiming for production quality WAN deployments. Many of our customers run RethinkDB in the cloud, and the latency between cloud regions can be quite punishing.

We'll document this setup better, but the replication options allow you to safely specify the set of nodes that need sync and async replication (so you can have sync replication for closely connected nodes in a datacenter, and async replication across datacenters).

Re:RethinkDB 2.1 beta: automatic failover with Raft by fweespeech on Friday July 17, 2015 @09:21AM (#9902563)
Thanks for the response. :)
Re:RethinkDB 2.1 beta: automatic failover with Raft by mononcqc on Friday July 17, 2015 @06:34AM (#9902053)
Have you dealt with mitigating Asymmetric partitions in Raft? http://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-857.pdf shows that a single defective node has the potential to entirely render a Raft cluster useless, specifically in the case of asymmetric partitions:

> The mobile devices will often be disconnected from the majority of other devices, thus running election after election without being able to gain enough votes. When these devices rejoin the network, they will force a new election as their term will be much higher than the leader. This leads to frequently disconnected devices becoming the leader when reattached to the network, thus causing regular unavailability of the system when they leave again.

> [...]

> It is also interesting to consider the impact of a single node being behind an asymmetric partition [...] This node will repeatedly re-run elections as it will not be able to receive incoming messages, each RequestVotes will have a higher term than the last, forcing the leader to step down.

Specifically, they required to add client request caches, exposing serial transaction IDs in every single record and log entry, specific timeouts and measures for livelock bugs this introduced, which include replacing an entry by a noop value to be replicated on some read-only operation done at a later time. On top of this, these modifications may end up reducing the serializability constructs to bring it closer to what a Master-Follower replication may give in a DB -- i.e. it doesn't guarantee one true serializable sequence of commits anymore, but only that the state replication will be consistent across all nodes

Re:RethinkDB 2.1 beta: automatic failover with Raft by danielmewes on Friday July 17, 2015 @10:48PM (#9906396)
We haven't added special logic for handling such cases. I think having servers with particularly unstable connectivity in a RethinkDB cluster is really uncommon though. If you want to run a RethinkDB server on your mobile device that's a different scenario of course...
Re:RethinkDB 2.1 beta: automatic failover with Raft by mononcqc on Saturday July 18, 2015 @08:54AM (#9907429)
Well the problem is obvious in mobile devices, but any asymmetric netsplit will result in a single node taking down your cluster for as long as the netsplit lasts.
Re:RethinkDB 2.1 beta: automatic failover with Raft by danielmewes on Monday July 20, 2015 @02:14PM (#9917905)
Ah, I have to check how we behave in that case. Thanks for the pointers.
Re:RethinkDB 2.1 beta: automatic failover with Raft by danielmewes on Monday July 20, 2015 @06:28PM (#9919537)
If I understand that scenario correctly, it assumes that there is a node that can successfully send messages to the other nodes in the cluster, but cannot receive any responses.

Since RethinkDB uses TCP connections, this shouldn't usually happen (since the TCP acknowledgements wouldn't get through either). The exception might be a layer 5 router / firewall somewhere in the network that allows the TCP connection to work, but only passes the data stream through in one direction. RethinkDB is partially protected against this case, because we use bidirectional heartbeats on top of the same TCP connection that is used for Raft traffic. The heartbeat usually ensures that the other host is still alive and reachable. In this case, the node that cannot receive any responses from the remaining cluster would get a heartbeat timeout after a couple of seconds, and disconnect from the remaining servers. This is turn should limit further damage and allow the Raft cluster to proceed.

Please let me know if I'm missing something else.

Edit: There might still be some problems with non-transitive connectivity, where one node can talk to only parts of the cluster. We have built in some protection against this, but don't always handle that case well.

Re:RethinkDB 2.1 beta: automatic failover with Raft by karlgrz on Thursday July 16, 2015 @02:49PM (#9899159)
This is so timely, I am really excited to get this new version out on our nodes to kick the tires!
Re:RethinkDB 2.1 beta: automatic failover with Raft by lemevi on Thursday July 16, 2015 @04:05PM (#9899574)
Do you have any plans for windows support for your server?
Re:RethinkDB 2.1 beta: automatic failover with Raft by coffeemug on Thursday July 16, 2015 @04:07PM (#9899587)
Yes, coming soon. See https://github.com/rethinkdb/rethinkdb/issues/1100 to track development progress.
Re:RethinkDB 2.1 beta: automatic failover with Raft by v3ss0n on Thursday July 16, 2015 @04:10PM (#9899612)
Awesomeness , Confirmed.