Amit K.
Amit K.

Reputation: 3754

Not able to write document in Elastic search

I am using Elastic search services from AWS. I am facing a strange issue. It seems like elastic search node has become read only. I went through logs but there is not a single error in code. I am getting success. I an using elastic client for nodejs.

var elasticClient = new elasticsearch.Client(this.options); 
elasticClient.bulk(data);

and data looks like :

[
  {
    "update": {
      "_index": "elastic_index",
      "_type": "user",
      "_id": 22224689
    }
  },
  {
    "doc": {
      "id": 22224689,
      "first_name" : "John",
      "last_name" : "Deo",
      "email" : "[email protected]",
      "dob" : "1985-12-20",
      "company_name" : "MPLLC",
      "city" : "NY",
      "state" : "Cal",
      "country" : "USA",
      "events" : [
        {
          "event_name" : "E1",
          "date" : "2018-08-15",
          "venue" : "Some custom venue"
        }  

      ]
    },
    "doc_as_upsert": true
  }
]

From last 2 year it was working fine. Suddenly stopped recording users in index.

Here is exception i am getting while writing in ES :

{"error":{"root_cause":[{"type":"cluster_block_exception","reason":"blocked by: [FORBIDDEN/8/index write (api)];"}],"type":"cluster_block_exception","reason":"blocked by: [FORBIDDEN/8/index write (api)]

Any idea what's the issue.

Upvotes: 0

Views: 2727

Answers (1)

Daniel Pages Chacon
Daniel Pages Chacon

Reputation: 81

I had exactly the same issue. In my case, the problem was that the Index Lifecycle Policies. I had a policy that changed the index mode to "warm" after a certain amount of hours. For some reason, the messages started to get piled in my queues and reached the Elasticsearch cluster after that time. That causes the rejection because the index mode "warm" is a read-only status. It needs to be in a "hot" to allows writing.

The solution was to extend the time to pass to the "warm" mode.

Another possible cause is if the cluster nodes start to get run out of memory or space.

Upvotes: 0

Related Questions