aboutsummaryrefslogtreecommitdiff
path: root/content/posts/2020-03-29-the-strange-case-of-elasticsearch-allocation-failure.md
diff options
context:
space:
mode:
Diffstat (limited to 'content/posts/2020-03-29-the-strange-case-of-elasticsearch-allocation-failure.md')
-rw-r--r--content/posts/2020-03-29-the-strange-case-of-elasticsearch-allocation-failure.md61
1 files changed, 46 insertions, 15 deletions
diff --git a/content/posts/2020-03-29-the-strange-case-of-elasticsearch-allocation-failure.md b/content/posts/2020-03-29-the-strange-case-of-elasticsearch-allocation-failure.md
index a976a7e..d0f4bac 100644
--- a/content/posts/2020-03-29-the-strange-case-of-elasticsearch-allocation-failure.md
+++ b/content/posts/2020-03-29-the-strange-case-of-elasticsearch-allocation-failure.md
@@ -1,19 +1,37 @@
1--- 1---
2title: The strange case of Elasticsearch allocation failure 2title: The strange case of Elasticsearch allocation failure
3url: the-strange-case-of-elasticsearch-allocation-failure.html 3url: the-strange-case-of-elasticsearch-allocation-failure.html
4date: 2020-03-29 4date: 2020-03-29T12:00:00+02:00
5draft: false 5draft: false
6--- 6---
7 7
8I've been using Elasticsearch in production for 5 years now and never had a single problem with it. Hell, never even known there could be a problem. Just worked. All this time. The first node that I deployed is still being used in production, never updated, upgraded, touched in anyway. 8I've been using Elasticsearch in production for 5 years now and never had a
9 9single problem with it. Hell, never even known there could be a problem. Just
10All this bliss came to an abrupt end this Friday when I got notification that Elasticsearch cluster went warm. Well, warm is not that bad right? Wrong! Quickly after that I got another email which sent chills down my spine. Cluster is now red. RED! Now, shit really hit the fan! 10worked. All this time. The first node that I deployed is still being used in
11 11production, never updated, upgraded, touched in anyway.
12I tried googling what could be the problem and after executing allocation function noticed that some shards were unassigned and 5 attempts were already made (which is BTW to my luck the maximum) and that meant I am basically fucked. They also applied that one should wait for cluster to re-balance itself. So, I waited. One hour, two hours, several hours. Nothing, still RED. 12
13 13All this bliss came to an abrupt end this Friday when I got notification that
14The strangest thing about it all was, that queries were still being fulfilled. Data was coming out. On the outside it looked like nothing was wrong but everybody that would look at the cluster would know immediately that something was very very wrong and we were living on borrowed time here. 14Elasticsearch cluster went warm. Well, warm is not that bad right? Wrong!
15 15Quickly after that I got another email which sent chills down my spine.
16> **Please, DO NOT do what I did.** Seriously! Please ask someone on official forums or if you know an expert please consult him. There could be million of reasons and these solution fit my problem. Maybe in your case it would disastrous. I had all the data backed up and even if I would fail spectacularly I would be able to restore the data. It would be a huge pain and I would loose couple of days but I had a plan B. 16Cluster is now red. RED! Now, shit really hit the fan!
17
18I tried googling what could be the problem and after executing allocation
19function noticed that some shards were unassigned and 5 attempts were already
20made (which is BTW to my luck the maximum) and that meant I am basically fucked.
21They also applied that one should wait for cluster to re-balance itself. So,
22I waited. One hour, two hours, several hours. Nothing, still RED.
23
24The strangest thing about it all was, that queries were still being fulfilled.
25Data was coming out. On the outside it looked like nothing was wrong but
26everybody that would look at the cluster would know immediately that something
27was very very wrong and we were living on borrowed time here.
28
29> **Please, DO NOT do what I did.** Seriously! Please ask someone on official
30forums or if you know an expert please consult him. There could be million of
31reasons and these solution fit my problem. Maybe in your case it would
32disastrous. I had all the data backed up and even if I would fail spectacularly
33I would be able to restore the data. It would be a huge pain and I would
34loose couple of days but I had a plan B.
17 35
18Executing allocation and told me what the problem was but no clear solution yet. 36Executing allocation and told me what the problem was but no clear solution yet.
19 37
@@ -21,9 +39,14 @@ Executing allocation and told me what the problem was but no clear solution yet.
21GET /_cat/allocation?format=json 39GET /_cat/allocation?format=json
22``` 40```
23 41
24I got a message that `ALLOCATION_FAILED` with additional info `failed to create shard, failure ioexception[failed to obtain in-memory shard lock]`. Well splendid! I must also say that our cluster is capable more than enough to handle the traffic. Also JVM memory pressure never was an issue. So what happened really then? 42I got a message that `ALLOCATION_FAILED` with additional info
43`failed to create shard, failure ioexception[failed to obtain in-memory shard lock]`.
44Well splendid! I must also say that our cluster is capable more than enough
45to handle the traffic. Also JVM memory pressure never was an issue. So what
46happened really then?
25 47
26I tried also re-routing failed ones with no success due to AWS restrictions on having managed Elasticsearch cluster (they lock some of the functions). 48I tried also re-routing failed ones with no success due to AWS restrictions
49on having managed Elasticsearch cluster (they lock some of the functions).
27 50
28```yaml 51```yaml
29POST /_cluster/reroute?retry_failed=true 52POST /_cluster/reroute?retry_failed=true
@@ -37,7 +60,10 @@ I got a message that significantly reduced my options.
37} 60}
38``` 61```
39 62
40After that I went on a hunt again. I won't bother you with all the details because hours/days went by until I was finally able to re-index the problematic index and hoped for the best. Until that moment even re-indexing was giving me errors. 63After that I went on a hunt again. I won't bother you with all the details
64because hours/days went by until I was finally able to re-index the problematic
65index and hoped for the best. Until that moment even re-indexing was giving
66me errors.
41 67
42```yaml 68```yaml
43POST _reindex 69POST _reindex
@@ -51,7 +77,8 @@ POST _reindex
51} 77}
52``` 78```
53 79
54I needed to do this multiple times to get all the documents re-indexed. Then I dropped the original one with the following command. 80I needed to do this multiple times to get all the documents re-indexed. Then
81I dropped the original one with the following command.
55 82
56```yaml 83```yaml
57DELETE /myindex 84DELETE /myindex
@@ -71,6 +98,10 @@ POST _reindex
71} 98}
72``` 99```
73 100
74On the surface it looks like all is working but I have a long road in front of me to get all the things working again. Cluster now shows that it is in Green mode but I am also getting a notification that the cluster has processing status which could mean million of things. 101On the surface it looks like all is working but I have a long road in front
102of me to get all the things working again. Cluster now shows that it is in
103Green mode but I am also getting a notification that the cluster has
104processing status which could mean million of things.
75 105
76Godspeed! 106Godspeed!
107