minimum_master_nodes does not prevent split-brain if splits are intersecting #2488

Closed
saj opened this Issue Dec 17, 2012 · 103 comments

Projects

None yet
@saj
saj commented Dec 17, 2012

G'day,

I'm using ElasticSearch 0.19.11 with the unicast Zen discovery protocol.

With this setup, I can easily split a 3-node cluster into two 'hemispheres' (continuing with the brain metaphor) with one node acting as a participant in both hemispheres. I believe this to be a significant problem, because now minimum_master_nodes is incapable of preventing certain split-brain scenarios.

Here's what my 3-node test cluster looked like before I broke it:

Here's what the cluster looked like after simulating a communications failure between nodes (2) and (3):

Here's what seems to have happened immediately after the split:

  1. Node (2) and (3) lose contact with one another. (zen-disco-node_failed ... reason failed to ping)
  2. Node (2), still master of the left hemisphere, notes the disappearance of node (3) and broadcasts an advisory message to all of its followers. Node (1) takes note of the advisory.
  3. Node (3) has now lost contact with its old master and decides to hold an election. It declares itself winner of the election. On declaring itself, it assumes master role of the right hemisphere, then broadcasts an advisory message to all of its followers. Node (1) takes note of this advisory, too.

At this point, I can't say I know what to expect to find on node (1). If I query both masters for a list of nodes, I see node (1) in both clusters.

Let's look at minimum_master_nodes as it applies to this test cluster. Assume I had set minimum_master_nodes to 2. Had node (3) been completely isolated from nodes (1) and (2), I would not have run into this problem. The left hemisphere would have enough nodes to satisfy the constraint; the right hemisphere would not. This would continue to work for larger clusters (with an appropriately larger value for minimum_master_nodes).

The problem with minimum_master_nodes is that it does not work when the split brains are intersecting, as in my example above. Even on a larger cluster of, say, 7 nodes with minimum_master_nodes set to 4, all that needs to happen is for the 'right' two nodes to lose contact with one another (a master election has to take place) for the cluster to split.

Is there anything that can be done to detect the intersecting split on node (1)?

Would #1057 help?

Am I missing something obvious? :)

@moscht
moscht commented Dec 18, 2012

We also had at some point a similar issue, where minimum_master_nodes did not prevent the cluster from having two different views of the nodes at the same time.

As our indices were created automatically, some of the indices were created twice, once in every half of the cluster with the two masters broadcasting different states, and after a full cluster restart some shards were unable to be allocated, as the state has been mixed up. This was on 0.17. so I am not sure, if data would still be lost, as the state is now saved with the shards. But the other question is what happens when an index exists twice in the cluster (as it has been created on every master).

I think we should have a method to recover from such a situation. As I don't know how the zen discovery works exactly, I can not say how to solve it, but IMHO a node should only be in one cluster, in your second image node 1 should either be with 2, preventing 3 from becoming master, or with node 3, preventing 2 from staying master.

@tallpsmith

see Issue #2117 as well, I'm not sure if the Unicast discovery is making it worse for you, but I think we captured the underlying problem over on that issue, but would like your thoughts too.

@saj
saj commented Dec 20, 2012

From #2117:

The split brain occurs if the nodeId(UUID) of the disconnected node is such that the disconnected node picks itself as the next logical master while pinging the other nodes(NodeFaultDetection).

Ditto.

The split brain only occurs on the second time that the node is disconnected/isolated.

I see a split on the first partial isolation. To me, these bug reports look like two different problems.

@trollybaz

I believe I ran into this issue yesterday in a 3 node cluster- a node elects itself master when the current master is disconnected from it. The remaining partipant node toggles between having the other nodes as its master before settling on one. Is this what you saw @saj?

@saj
saj commented Apr 3, 2013

Yes, @trollybaz.

I ended up working around the problem (in testing) by using elasticsearch-zookeeper in place of Zen discovery. We already had reliable Zookeeper infrastructure up for other applications, so this approach made a whole lot of sense to me. I was unable to reproduce the problem with the Zookeeper discovery module.

@tallpsmith

I'm pretty sure we're suffering from this in certain situations, and I don't think that it's limited to unicast discovery.

We've had some bad networking, some Virtual Machine stalls (result of SAN issues, or VMWare doing weird stuff), or even heavy GC activity can cause enough pauses for aspects of the split brain to occur.

We were originally running pre-0.19.5 which contained an important fix for an edge case I thought we were suffering from, but since moving to 0.19.10 we've had at least one split brain (VMware->SAN related) that caused 1 of the 3 ES nodes to lose touch with the master, and declare itself master, while still then maintaing links back to other nodes.

I'm going to be tweaking our ES logging config to output DEBUG level discovery to a separate file so that I can properly trace these cases, but there have just been too many of these not to consider ES not handling these adversarial environment cases.

I believe #2117 is still an issue and is an interesting edge case, but I think this issue here best represents the majority of the issues people are having. My gut/intuition seems to indicate that the probability of this issue occurring does drop with a larger cluster, so the 3-node, minimum_master_node=2 is the most prevalent case.

It seems like when the 'split brain' new master connects to it's known child nodes, any node that already has an upstream connection to an existing master probably should be flagging it as a problem, and telling the newly connected master node "hey, I don't think you fully understand the cluster situation".

@brusic
Contributor
brusic commented Apr 5, 2013

I believe there are two issues at hand. One being the possible culprits for a node being disconnected from the cluster: network issues, large GC, discover bug, etc... The other issue, and the more important one IMHO, is the failure in the master election process to detect that a node belongs to two separate clusters (with different masters). Clusters should embrace node failures for whatever reason, but master election needs to be rock solid. Tough problem in systems without an authoritative process such as ZooKeeper.

To add more data to the issue: I have seen the issue on two different 0.20RC1 clusters. One having eight nodes, the other with four.

@tallpsmith

I'm not sure the former is really something ES should be actively dealing with, the latter I agree, and is the main point here, in how ES detects and recovers from cases where 2 masters have been elected.

There was supposed to have been some code in, I think, 0.19.5 that 'recovers' from this state by choosing the side that has the most recent ClusterStatus object (see Issue #2042) , but it doesn't appear in practice to be working as expected, because we get these child nodes accepting connections from multiple masters.

I think gathering the discovery-level DEBUG logging from the multiple nodes and presenting it here is the only way to get further traction on this case.

It's possible going through the steps in Issue #2117 may uncover edge cases related to this one (even though the source conditions are different); at least it might be a reproducible case to explore.

@s1monw nudge - have you had a chance to look into #2117 at all... ? :)

@brusic
Contributor
brusic commented Apr 5, 2013

Paul, I agree that the former is not something to focus on. Should have stated that. :) The beauty of many of the new big data systems is that they embrace failure. Nodes will come and go, either due to errors or just simple maintenance. #2117 might have a different source condition, but the recovery process after the fact should be identical.

I have enabled DEBUG logging at the discovery level and I can pinpoint when a node has left/joined a cluster, but I still have no insights on the election process.

@tallpsmith

suffered from this the other day when an accidental provisioning error had a 4GB ES Heap instance running on a 4GB O/S memory, which was always going to end up in trouble. The node swapped, process hung, and the intersection issue described here happened.

Yes, the provisioning error could have been avoided, yes, probably use of mlockall may have prevented the destined-to-die-a-horrible-swap-death, but there's other scenarios that could cause a hung process (bad I/O causing stalls for example) where the way ES handles the cluster state is poor, and leads to this problem.

we hope very much someone is looking hard into ways to make ES a bit more resilient when facing these situations to improve data integrity... (goes on bended knees while pleading)

@otisg
otisg commented May 24, 2013

Btw. why not adopt ZK, which I believe would make this situation impossible(?)? I don't love the extra process/management that the use of ZK would imply..... though maybe it could be embedded, like in SolrCloud, to work around that?

@brusic
Contributor
brusic commented May 24, 2013

From my understanding, the single embedded Zookeeper model is not ideal for production and that a full Zookeeper cluster is preferred. Never tried myself, so I cannot personally comment.

@s1monw
Contributor
s1monw commented May 24, 2013

FYI - there is a zookeeper plugin for ES

@otisg
otisg commented May 24, 2013

Oh, I didn't mean to imply a single embedded ZK. I meant N of them in different ES processes. Right Simon, there is the plugin, but I suspect people are afraid of using it because it's not clear if it's 100% maintained, if it works with the latest ES and such. So my Q is really about adopting something like that and supporting it officially. Is that a possibility?

@mpalmer
mpalmer commented May 24, 2013

@otisg: The problem with the ZK plugin is that with clients being part of the cluster, they need to know about ZK in order to be able to discover the servers in the cluster. Some client libraries (such as the one used by the application that started this bug report -- I'm a colleague of Saj's) doesn't support ZK discovery. In order for ZK to be a useful alternative in general, there either needs to be universal support of ZK in client libraries, or a backwards-compatible way for non-ZK-aware client libraries to discover the servers (perhaps a ZK-to-Zen translator or something... I don't know, I've got bugger-all knowledge of how ES actually works under the hood).

@aochsner
Contributor

We've gotten into this situation twice now in our QA environment. 3 nodes. minimum_master_nodes = 2. Log flies at https://gist.github.com/aochsner/5749640 (sorry they are big and repetitive).

We are on 0.9.0 and using multicast

As a bit of a walkthrough. sthapqa02 was the master and all it noticed was that sthapqa01 went bye bye and never rejoined. According to sthapqa02, the cluster was sthapqa02 (itself) and sthapqa03.

sthapqa01 is what appeared to have problems. It couldn't reach sthapqa02 and decided to create a cluster between itself and sthapqa03.

sthapqa03 went along w/ sthapqa01 to create a cluster and didn't notify sthapqa02.

So 01 and 03 are in a cluster and 02 thinks it's in a cluster w/ 03.

@kimchy
Member
kimchy commented Aug 13, 2013

just an update that this behaves much better in 0.90.3 with dedicated master nodes deployment, but we are working on a better implementation down the road (with potential constraints on requiring fixed dedicated master nodes by the nature of some consensus algo impls, we will see how it goes...).

@tallpsmith

@kimchy that sounds promising, I would love to to understand more of the changes in that 0.90.x series that is in this area to understand what movements are going on ? Is there a commit hash you could point to that you can remember that I could peek at ?

By dedicated master node, do you mean nodes that just perform the master role, and not data role? (so additional nodes on top of existing data nodes). This would sort of mimic how adding Zookeeper as a Master Election co-ordinator works?

@phungleson
Contributor

@kimchy Does 0.90.2 has the same features or they are only available in 0.90.3?

@brusic
Contributor
brusic commented Aug 14, 2013

Shay, thanks for the update.

For us, the problem has gone away with the adoption of 0.90.2. The actual underlying problem might not have been fixed, but the improved memory usage with elasticsearch 0.90/Lucene 4 has eliminated large GCs, which probably were the root cause of our disconnections. No disconnections means no need to elect another master.

@btiernay

This situation happened to us recently running 0.90.1 with minimum_master_nodes set to N/2 + 1, with N = 15. I'm not sure what the root cause was, but this shows that such a scenario is probable in larger clusters as well.

@trevorreeves

We have been frequently experiencing this 'mix brain' issue in several of our clusters - up to 3 or 4 times a week. We have always had dedicated master eligible nodes (i.e. master=true, data=false), correctly configured minimum_master_nodes and have recently moved to 0.90.3, and seen no improvement in the situation.

As a side note, the initial cause of the disruption to our cluster is 'something' to do with the network links between the nodes I imagine - one of the master eligible nodes occasionally loses connectivity with the master node briefly - "transport disconnected (with verified connect)" is all we get in the logs. We haven't figured out this issue yet (something is killing the tcp connection?), but this explains the frequency with which we are affected by this bug as it seems its a double hit due to the inability for the cluster to recover itself correctly when this disconnect occurs.

@kimchy Is there any latest status on the 'better implementation down the road' and when it might be delivered?

Sounds like zookeeper is our reluctant interim solution.

@tallpsmith

just as I was beginning plans to go to a set of dedicated master-only nodes I ready @trevorreeves post where he's still hitting the same problem. Doh!

Our situation appears to be IOWait related, in that a master node (also a data-node) hits an issue that causes extensive IOWait (a _scroll based search can trigger this, we already cap the # streams and Mb/second recovery rate through settings), the JVM becomes unresponsive. The other nodes that are doing the Master Fault Detection are configured with 3 x 30 second ping timeouts, all of which fail, and then they give up on the master.

I'm not really sure what is stalling the master node JVM, particularly when I'm positive it's not GC related, it's definitely linked to heavy IOWait. We have one node in one installation with a 'tenuous' connection to a NetApp storage backing the volume used by the ES local disk image, and that seems to be the underlying root of our issues, but it is the way the ES cluster is failing to recover from this situation and not properly reestabling a consensus on the cluster that causes issues (I don't mind any weirdness during times of whacky IO patterns that form the split brain so much as I dislike the way ES is failing to keep track of who thinks who's who in the cluster).

At this point, it does seem like the Zookeeper based discovery/cluster management plugin is the most reliable way, though I'm not looking forward to setting up that up to be honest.

@nik9000
Contributor
nik9000 commented Nov 21, 2013

We haven't hit this but this report is worrying - is this being worked on? This is the kind of thing that'd make us switch to Zookeeper.

@brusic
Contributor
brusic commented Nov 21, 2013

Just wanted to point out to Nik a comment in the other related issue: #2117 (comment)

"Unfortunately, this situation can in-fact occur with zen discovery at this point. We are working on a fix for this issue which might take a bit until we have something that can bring a solid solution for this."

I wonder what has happened since then and if their findings correspond to my scenario.

For my clusters, split-brains always occur when a node becomes isolated and then elects themselves as master. More visibility (logging) of the election process would be helpful. Re-discovery would be helpful as well since I rarely see the cluster self heal despite being in erroneous situations (nodes belongs to two clusters_. I am on version 0.90.2, so I am not sure if I am perhaps missing a critical update although I do scan the issues and commits.

@aphyr
aphyr commented Dec 11, 2013

Could you do me a huge favor and not patch this until, like, May or so? I need to finish some other things before the next installation of Jepsen. ;-)

@bitsofinfo
Contributor

Is there any update on this or timeline for when it will be fixed?

@mayurkup

Ran into this very problem on a 4 node cluster.

Node 1 and Node 2 got disconnected and elected themselves as masters,
Node 3 and 4 remained followers for both Node 1 and Node 2.

We do not have the option of running ZK.

Does anyone know the election process is governed (I know it runs off the Praxos Consensus algorithm) but in layman's term does each follower vote exactly once or do they case multiple votes?

@amitelad7

We just ran into this problem on a 41 data node and 5 master node cluster running 0.90.9
@kimchy is your recommendation to use zookeeper and not zen?

@mayurkup

@amitelad7
You have a few options running at Zen, you can increases the fd timeouts/retries/intervals if your network/node is unresponsive. The other option is to explicitly define master nodes, but in the case of yours where you have 5 masters it may get tricky.

@mycrEEpy

We experienced this problem in our test environment because of tcp connections (heartbeat?) getting dropped by a firewall after some time leading to the "transport disconnected (with verified connect)" error which results in a split brain as described in this issue.

I configured the "net.ipv4.tcp_keepalive_time" variable in the /etc/sysctl.conf to a lower value (e.g. 600 equals 10 minutes) which fixed the problem for us. No disconnects, no new master election, no split brain.

But giving my +1 for this issue to get fixed asap as it could still occur.

@nikicat
nikicat commented Mar 13, 2014

👍

@AeroNotix

Out of interest are you all running ES on EC2?

@amitelad7

we're running on a private cloud of our own

@AeroNotix

@amitelad7 oh man >< Even worse.

41 nodes? Crazy. Did you try lowering the TCP keepalive setting like @mycrEEpy mentioned?

@amitelad7

it's actually been quite stable over the past few weeks so we havent worked on further optimizations :)

@AeroNotix

@amitelad7 what does "quite stable" mean? :)

@brusic
Contributor
brusic commented Mar 24, 2014

We are also running on a private cloud.

Part of our problem was incorrect Elasticsearch documentation. The docs listed the default ping timeout as 2s, so in an effort to improve the cluster, we raised the value to 5s. In reality the default is 30s, so I was actually lowering the value. The documentation is now fixed. We are now more resilient to network failures.

@AeroNotix

@aphyr did you do any analysis using Jepsen on Elasticsearch?

@aphyr
aphyr commented Mar 26, 2014

Still pending. Been a bit overwhelmed.

@aphyr
aphyr commented Apr 13, 2014

I can confirm that partitions with nodes that can see both sides of the cluster reliably induce ElasticSearch split brain after about a hundred seconds. A bunch of ES guarantees seem to go out the window at that point; for instance, conditional puts can succeed against both primaries, leading to independent version histories and the loss of some or all conflicting updates to a key.

splitbrain

Here's a log showing the full invocation/completion history for five clients (one for each of five nodes) performing CaS operations on a single document via conditional update with version. https://gist.github.com/aphyr/10565113.

In this test, roughly a third of all writes are lost--many failed or were indeterminate due to the initial cluster transition. In the limit as t->infinity, the lost write fraction converges to 1/2.

@aphyr
aphyr commented Apr 13, 2014

It's actually much worse than I realized. Because ElasticSearch allocates IDs sequentially instead of using k-ordered flake IDs, any split-brain scenario guarantees that two inserts on different primaries will use the same ID--and when merged, one document silently clobbers the other. In this short test where the set is built by inserting one document per integer, with ES-assigned IDs, the cluster drops about a third of all documents inserted. The lost fraction converges to 1/2 as the duration of the split-brain rises.

https://gist.github.com/aphyr/10566411

@kimchy
Member
kimchy commented Apr 13, 2014

@aphyr thanks for running it!, we started a couple of weeks ago a branch to try and address some of these problems here: https://github.com/elasticsearch/elasticsearch/tree/feature/improve_zen (at least in the context of zen), but by far the work has just started. The good news is that we now have a test infra support to simulate these problems in ES (by having simulated transport/network later).

I see you pushed your Jepsen work on Elasticsearch, so we will make sure to run it as well, thanks!

@AeroNotix

@kimchy perhaps jepsen should just be integrated into your test suite or ran as part of your CI server's tests. I'm not sure I can find a decent reason to replicate these kinds of tests.

@kimchy
Member
kimchy commented Apr 13, 2014

@AeroNotix the benefit of doing similar tests in our test infrastructure is how simple they are to write and run to verify behavior. Check this test for example: https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/discovery/DiscoveryWithNetworkFailuresTests.java, this is a simple test, easy to run using our integration tests, without needing to setup Jespen or external dependencies. By having such a test, every time you run our test suite, those are run as well, without needing to have a more complex setup.

Having said that, writing respective tests that simulate certain behaviors does not exclude running Jespen as well, which we plan to do.

@aphyr
aphyr commented Apr 13, 2014

And yeah, I'm glad to see virtualized networking as a part of the Elasticsearch test suite. Definitely faster, and lets you explore a broader space of failure modes than Jepsen. Jepsen can only treat these systems as black boxes, so there are all sorts of timing/stochastic bugs I can't reach easily.

@kimchy
Member
kimchy commented Apr 13, 2014

@aphyr thanks!, we still have a way to go in terms of development on mentioned branch, but we will make sure to running the Jespen tests and analyzing them as well (though they do seem to trigger the behavior mentioned here, which we also managed to simulate using our (new) test infra) and report back!

Btw, your work is highly appreciated!, and I think you mentioned that you were looking for contributions back to your project, can you point me at the right place to do so?

@aphyr
aphyr commented Apr 13, 2014

Thanks for the kind words, @kimchy, and thanks for all your hard work on ElasticSearch as well!

Jepsen is starting to coalesce around a new set of testing primitives, but a lot of stuff is up in the air and there's basically no documentation at this point. When I get a little breathing room after this talk I'll be sure to put up a proper contributing guide and clean up the API a bit.

The biggest issue for me right now is the fact that Knossos doesn't have a good strategy for dealing with hung processes, which invoke a request but are unable to determine if it succeeded or failed. N hung processes multiply runtime by a factor of n!, so I'd really appreciate any help folks could give in working around that! Entry point to the linearizability checker is here: https://github.com/aphyr/knossos/blob/master/src/knossos/core.clj#L344-L358

@kimchy
Member
kimchy commented Apr 13, 2014

@aphyr will check it out! (don't want to derail this thread, so mailed you about it)

@kimchy kimchy was assigned by s1monw Apr 14, 2014
@aphyr
aphyr commented Apr 20, 2014

Because ElasticSearch allocates IDs sequentially instead of using k-ordered flake IDs,

Scratch that, I think was wrong. Misread the wireshark traces; it looks like Elasticsearch is actually generating UUIDs and then discarding all the data on one side of the partition anyway. I assumed no sane database would do that and that it had to be due to record conflict. I think it's either generating the same UUIDs on both sides of the split, or it's throwing away data without looking to see if it's cleanly mergeable.

@kimchy
Member
kimchy commented Apr 22, 2014

@aphyr the way ES works is when minimum master nodes is breached, it will not allow for writes until it is resolved. The bug this issue points to is the problem we have in the mentioned case with handling minimum master nodes. It took us some time to build the infra to be able to reproduce it in our test infrastructure, and as mentioned, we are working on fixing scenario to properly handle the case.

@shikhar
Contributor
shikhar commented May 14, 2014

fwiw another discovery plugin that is built with avoiding split-brains in mind: https://github.com/shikhar/eskka

verifying this using jepsen is on the agenda

@AeroNotix

@shikhar how's it going with the Jepsen testing? I could help you with that.

@shikhar
Contributor
shikhar commented May 22, 2014

@AeroNotix that'd be awesome! let's take this to shikhar/eskka#6

@brusic
Contributor
brusic commented May 22, 2014

Kevin Kluge at Elasticsearch informed me that they are perhaps not looking into Paxos/RAFT consensus, but are instead working on improving zen discovery. There is a branch on git with the improvements:

https://github.com/elasticsearch/elasticsearch/tree/feature/improve_zen

@masumsoft

Is it possible to get rid of this situation by somehow dynamically updating the minimum_master_nodes configuration based on current state of the cluster?

@AeroNotix

@brusic It seems very headstrong to be rolling your own distributed consensus algorithm.

@AeroNotix

@masumsoft Explain further, what you're suggesting sounds like reducing the number of members required to create a cluster, I don't see how that fixes a split-brain.

@ejsarge-gr

@brusic I'm very glad Elasticsearch is looking into this issue but I would agree with @AeroNotix. If the leader election algorithm isn't based on a peer-reviewed published algorithm why would we have trust that it is reliable in every case? The insight from @aphyr's Jepsen work is that distributed concurrency defects are incredibly hard to find via testing.

@otisg
otisg commented May 26, 2014

Not to get too philosophical here, but one could have said the same thing some 5 years ago when @kimchy started working on ES - why do it - there was already Solr and it was working perfectly find for pretty much everyone on the planet. +1 for innovation.

@XANi
XANi commented May 28, 2014

@otisg if it is actual innovation sure, but if there is already working and tested solution to a problem and if "invented" solution is not working very well to a point of making users lose their data because of it... just use tried and tested one, at least till your "invention" is proven and working

@shikhar
Contributor
shikhar commented Jun 14, 2014

@aphyr

I can confirm that partitions with nodes that can see both sides of the cluster reliably induce ElasticSearch split brain after about a hundred seconds

I can confirm that even when using

   :nemesis   (nemesis/partition-halves)

where there is a clear majority partition -- I am able to see multiple masters (e.g. n1,n2 report n2 is master; n3,n4,n5 report n5 is master). The test fails with acknowledged writes lost.

@kimchy
Member
kimchy commented Jun 16, 2014

FYI, the improved_zen branch already contains a fix for this issue, we are letting it bake as this is a delicate change, and we are working on adding more test scenarios (aside from the one detailed in this issue) to make sure. The plan is to aim at getting this into 1.3. We have not yet ran Jespen (which simulates the same scenario we already simulate in our test), but we will do it as well.

@AeroNotix

@kimchy any comments on the underlying consensus algorithm?

@nilsga
nilsga commented Jul 23, 2014

Did the improve_zen branch make it to 1.3?

@kimchy
Member
kimchy commented Jul 23, 2014

@nilsga no, we are making great progress on it, and the plan now is to try and get it to 1.4...

@AeroNotix

@kimchy any comments on the underlying consensus algorithm?

@kimchy
Member
kimchy commented Jul 23, 2014

@AeroNotix the main change there is that we fixed the bug in our gossip protocol to elect a master while maintaing the minimum master nodes criteria. This will ensure (validated through our testing) that the mentioned split brain will not happen. This is the most urgent fix we are aiming to provide with improve_zen (also, thanks to the new simulated testing infra, we have uncovered several other bugs already, some fixed in 1.x/master, others only in improve_zen).

@AeroNotix

Does the code in improve_zen branch still suffer from split-brains?

@kimchy
Member
kimchy commented Jul 23, 2014

@AeroNotix the fix is in, and not based on our current testing, but we are still writing and performing more tests, some resulting in more improvements to it (easy to see the commits being done on it): https://github.com/elasticsearch/elasticsearch/commits/feature/improve_zen

@AeroNotix

Forgive me here but, pointing me at a branch to have me figure out your consensus algorithm makes things extremely difficult for me to learn whether I can base my usage of ElasticSearch on good grounds.

Do you have a formalized specification of your consensus algorithm so that I may learn more about it?

@kimchy
Member
kimchy commented Jul 24, 2014

@AeroNotix it wasn't clear to me what you are after, a proper documentation of the protocol we use for the leader election is also on our list of TODOs (zen discovery deals with what we call the cluster level state and leader election).

@AeroNotix

Essentially I am after a non-code implementation of your protocol so that I may compare it to something which is formally verified.

@mihasya
mihasya commented Jul 25, 2014

Really happy to see this ticket with code and recent updates as the 3rd search result for "elasticsearch jepsen" after reading @aphyr's post. It is REALLY REALLY REALLY good that you guys are taking this seriously and actually addressing it. It makes me feel good about the choice to use ES, even if I'm quite a bit more scared about it now than I was 3 hours ago 😁. I have a couple of questions:

  1. Now that these issues have been identified, is there any place that they are documented? Has any documentation been put together which correctly describes ES in CAP terms? e.g., not counting error responses as _A_vailable, indicating the scenarios in which _C_onsistency is compromised, etc? I would like to encourage you to be very honest and up-front about this stuff. It will not make the project look bad, but good on the contrary. People that don't care and just want to use it as a loose search engine will continue to pile data into it and likely won't even read that doc. People that DO care (like me) will appreciate the honesty. I may choose not to run ElasticSearch based on those characteristics, but IMO that's better for everyone than me running ES, losing data, then using something else anyway after burning a bunch of time and posting a bunch of angry bug reports.
  2. What are the perceived advantages of ZenDisco over other more mature, well defined, and well tested leader election protocols? As an early user, abused, and extender of Cassandra (0.6 and on), I can tell you that getting cluster liveness right is simultaneously difficult and critical. Getting it wrong will cause your users much grief (and looks like already has). Are alternatives being explored? It looks like there's a ZooKeeper plugin available, but I've also seen comments indicating it's not supported. Is that true? Is there any hope that it'll one day fly again? I see this fork from an ES core team member with fairly recent commits that claims compatibility with 1.1 - is anyone using this successfully? Is it tested regularly along with ZenDisco? Is the plan to continue supporting it for future versions?
  3. How can I/we help in this particular area? No promises, as we have a tiny tiny engineering team (one of the appeals of ES was precisely the ease of going from 0 to having the ability to throw JSON into it and peel out), but perhaps we can help test some alternative implementations? Maybe said ZK plugin?
@pilvitaneli

@kimchy I've been running jepsen tests on improve_zen branch quite regularly and four nemeses (isolate-self-primaries-nemesis, nemesis/partition-random-halves, nemesis/partition-halves, nemesis/partitioner nemesis/bridge) seem to transiently fail, i.e. 2-4 runs out of ten seem to result in some lost documents. One nemesis (nemesis/partition-random-node) hasn't failed in a few thousand successive runs, so would consider that scenario to be fixed.

@kimchy
Member
kimchy commented Aug 19, 2014

@pilvitaneli thanks for the effort!, we have been running it as well on our end. In short, we verified that the split brain doesn't seem to happen anymore, but still need some work around the replication logic in addition to it to strengthen certain failure cases. We identified the case, but our hope is to push improve zen with the fix to split brain as soon as possible, and then progress on the replication aspect.

We are in the final stages of tests on improve_zen, now mainly doing 100s nodes tests type verifications, since improve zen now does a round of gossip on master failure, and we had to work on optimizing the resource usage in that case.

I hope that in the next few days we will publish a new resiliency status page (writing it now, took some time, summer... :) ). The resiliency status page would shed light and be a good place to aggregate all the effort going into any aspect of resiliency in ES (there is much work done except for this issue), on the work that has already been done, work that is in progress, and things that we know about still left to be done.

@bleskes bleskes added a commit to bleskes/elasticsearch that referenced this issue Sep 1, 2014
@bleskes bleskes [Discovery] accumulated improvements to ZenDiscovery
Merging the accumulated work from the feautre/improve_zen branch. Here are the highlights of the changes:

__Testing infra__
- Networking:
    - all symmetric partitioning
    - dropping packets
    - hard disconnects
    - Jepsen Tests
- Single node service disruptions:
    - Long GC / Halt
    - Slow cluster state updates
- Discovery settings
    - Easy to setup unicast with partial host list

__Zen Discovery__
- Pinging after master loss (no local elects)
- Fixes the split brain issue: #2488
- Batching join requests
- More resilient joining process (wait on a publish from master)

Closes #7493
598854d
@bleskes bleskes added a commit to bleskes/elasticsearch that referenced this issue Sep 1, 2014
@bleskes bleskes [Discovery] accumulated improvements to ZenDiscovery
Merging the accumulated work from the feature/improve_zen branch. Here are the highlights of the changes:

__Testing infra__
- Networking:
    - all symmetric partitioning
    - dropping packets
    - hard disconnects
    - Jepsen Tests
- Single node service disruptions:
    - Long GC / Halt
    - Slow cluster state updates
- Discovery settings
    - Easy to setup unicast with partial host list

__Zen Discovery__
- Pinging after master loss (no local elects)
- Fixes the split brain issue: #2488
- Batching join requests
- More resilient joining process (wait on a publish from master)

Closes #7493
51b89f7
@bleskes
Member
bleskes commented Sep 1, 2014

I'm closing this issue, as it is solved, as specified, by the changes made in #7493. Of course, there is more work to be done and the effort continues.

Thx for all the input and discussion.

@bleskes bleskes closed this Sep 1, 2014
@AeroNotix

@bleskes so it's 100% fixed?

@bleskes
Member
bleskes commented Sep 1, 2014

this issue (partial network splits causing split brain) is fixed now, yes.

@AeroNotix

Interesting, will have to confirm that myself with Jepsen tests.

@shikhar
Contributor
shikhar commented Sep 1, 2014

still need some work around the replication logic in addition to it to strengthen certain failure cases

is there an issue(s) open for this?

@bleskes
Member
bleskes commented Sep 1, 2014

@AeroNotix sure, let me know what you run into. Do note though that Jepsen tests more then what stated in this issue. For example, how the document replication model.

@shikhar there more then one thing to do. I think the best way to follow the work is through the resiliency label.

@mschirrmeister

Is there an eta when 1.4 is released, or will it even go into the next 1.3.x update?

@kimchy
Member
kimchy commented Sep 1, 2014

@shikhar things take a bit longer than expected, but expect issue(s) for the rest of the known work to be open in the next few days, as well as the status page I talked about (just came back from vacation personally :) ).

@kimchy
Member
kimchy commented Sep 1, 2014

@mschirrmeister this feature is not planned to be back ported to 1.3, its too big of a change. No concrete ETA for 1.4, hopefully we will have a release (possibly first in Beta form) in the next couple of weeks.

@bleskes
Member
bleskes commented Sep 3, 2014

@shikhar FYI - I opened a ticket for the issue we discussed above: #7572

@shikhar
Contributor
shikhar commented Sep 3, 2014

thanks @bleskes!

@kelaban
kelaban commented Oct 15, 2014

@kimchy, has the behavior of minimum number of master nodes changed in the new implementation, stated here? As I currently understand the setting, if there is less than N nodes available no cluster will exist (reads or writes)

@kimchy
Member
kimchy commented Oct 15, 2014

@kelaban the "previous" behavior is the same as the current one, when N nodes are not available, then that side of the cluster becomes blocked. In the new implementation (1.4), there is an option to decide if reads will still be allowed on that cluster or not.

@fevers
fevers commented Nov 4, 2014

@kimchy Where can we find this option? Should it already be present in the 1.4 branch?
We came across the split-brain issue and we want to know whether this is fixed in 1.4.

@aphyr
aphyr commented Apr 4, 2015

this issue (partial network splits causing split brain) is fixed now, yes.

I'm not sure why this issue was closed--people keep citing it and saying the problem is solved, but the Jepsen test from earlier in this thread still fails. Partial network partitions (and, for that matter, clean network partitions, and single-node partitions, and single-node pauses) continue to result in split-brain and lost data, for both compare-and-set and document-creation tests. I don't think the changes from #7493 were sufficient to solve the problem, though they may have improved the odds of successfully retaining data.

For instance, here's a test in which we induce randomized 120-second long intersecting partitions, for 600 seconds, with 10 seconds of complete connectivity in between each failure. This pattern resulted in 22/897 acknowledged documents being lost due to concurrent, conflicting primary nodes. You can reproduce this in Jepsen 7d0a718 by going to the elasticsearch directory and running lein test :only elasticsearch.core-test/create-bridge--may take a couple runs to actually trigger the race though.

@bleskes
Member
bleskes commented Apr 4, 2015

I'm not sure why this issue was closed

This issue, as it is stated, relates to have two master nodes elected during partial network split, despite of min_master_nodes. This issue should be solved now. The thinking is that we will open issues for different scenarios as they are discovered. An example is #7572 as well as your recent tickets (#10407 & #10426). Once we figure out the root cause of those failure (and the one mentioned in your previous comment) and if it turns out to be similar to this issue, it will of course be re-opened.

@speedplane
Contributor

Not directly on topic to this issue, but why is it so difficult to avoid/prevent this split brain issue? If there are two master nodes on a network (ie, a split brain configuration), why can't there be some protocol for the two masters to figure out which one should become a slave?

I imagine some mechanism would need to detect that the system is in a split-brain state, and then a heuristic would be applied to choose the real master (e.g., oldest running server, most number of docs, random choice, etc.). This probably takes work to do, but it does not seem too difficult.

@hamiltop

Michael: Split brain occurs precisely because the two masters can't
communicate. If they could they would resolve it.

On Thu, Feb 25, 2016 at 6:54 PM Michael Sander notifications@github.com
wrote:

Not directly on topic to this issue, but why is it so difficult to
avoid/prevent this split brain issue? If there are two master nodes on a
network (ie, a split brain configuration), why can't there be some protocol
for the two masters to figure out which one should become a slave?

I imagine some mechanism would need to detect that the system is in a
split-brain state, and then a heuristic would be applied to choose the real
master (e.g., oldest running server, most number of docs, random choice,
etc.). This probably takes work to do, but it does not seem too difficult.


Reply to this email directly or view it on GitHub
#2488 (comment)
.

@speedplane
Contributor

Got it. Earlier this week two nodes in my cluster appeared to be fighting for who was the master of the cluster. They were both on the same network and I believe were in communication with each other, but they went back and forth over which was the master. I shut down one of the nodes, gave it five minutes, restarted that node, and everything was fine. I thought that this was a split brain issue, but I guess it may be something else.

@jasontedor
Contributor

Earlier this week two nodes in my cluster appeared to be fighting for who was the master of the cluster.

@speedplane Do you have exactly two master-eligible nodes? Do you have minimum master nodes set to two (if you're going to run with exactly two master-eligible nodes you should, although this means that your cluster becomes semi-unavailable if one of the masters faults; ideally if you have multiple master-eligible nodes you'll have at least three and have minimum master nodes set to a quorum of them)?

I thought that this was a split brain issue, but I guess it may be something else.

Split brain is when two nodes in a cluster are simultaneously acting as masters for that cluster.

@speedplane
Contributor

@jasontedor Yes, I had exactly two nodes, and minimum master nodes was set to one. I did this intentionally for the exact reason you described. It appeared that the two nodes were simultaneously acting as a master, but they were both in communication with each other, so shouldn't they be able to resolve it, as @hamiltop suggests?

@jasontedor
Contributor

Yes, I had exactly two nodes, and minimum master nodes was set to one.

@speedplane This is bad because it does subject you to split brain.

I did this intentionally for the exact reason you described.

That's not what I recommend. Either drop to one (and lose high-availability), or increase to three (and set minimum master nodes to two).

It appeared that the two nodes were simultaneously acting as a master, but they were both in communication with each other, so shouldn't they be able to resolve it, as @hamiltop suggests?

What evidence do you have that they were simultaneously acting as master? How do you know that they were in communication with each other? What version of Elasticsearch?

@speedplane
Contributor

What evidence do you have that they were simultaneously acting as master?

In the Big Desk plugin, the little star next to node name kept on bouncing back and forth between my two nodes (see screenshot).

bigdesk plugin

How do you know that they were in communication with each other?

I don't think I explicitly tested whether one could contact the other, but I was able to ssh into both, they were on the same network, and there did not appear to be any network issues.

What version of Elasticsearch?

1.7.3

@jasontedor
Contributor

In the Big Desk plugin, the little star next to node name kept on bouncing back and forth between my two nodes (see screenshot).

@speedplane I'm not familiar with the Big Desk plugin, sorry. Let's just assume that it's correct and as you say. Have you checked the logs or any other monitoring for repeated long-running garbage collections pauses on both of these nodes?

I don't think I explicitly tested whether one could contact the other, but I was able to ssh into both, they were on the same network, and there did not appear to be any network issues.

Networks are fickle things but I do suspect something else here.

1.7.3

Thanks.

@XANi
XANi commented Feb 26, 2016

@speedplane "2 node situation" is inherently hard to deal with because there is no one metric iy could be decided which one should be shot down.

"Most written to" or "last written to" doesnt really mean much and in most cases alerting that something is wrong is preferable to "just throw away whatever other node had".

That is why a lot of distributed software recommends at least 3 nodes, because with 3 there is always majority, so you can set it up to only allow requests if at least n/2+1 nodes are up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment