# Request to close index fails due to socket timeout

**URL:** https://discuss.elastic.co/t/request-to-close-index-fails-due-to-socket-timeout/294687
**Category:** Elasticsearch
**Created:** [January 18, 2022, 11:05am UTC](https://discuss.elastic.co/t/request-to-close-index-fails-due-to-socket-timeout/294687 "2022-01-18T11:05:41Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Shubham\_M](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@Shubham\_M](https://discuss.elastic.co/u/Shubham_M)
#### Post date: [January 18, 2022, 11:05am UTC](https://discuss.elastic.co/t/request-to-close-index-fails-due-to-socket-timeout/294687/1 "2022-01-18T11:05:41Z")

</div>

Scenario:  
We create new index on daily basis so as to keep the data in the index updated.After creation of new index when close request is made,it times out with Socket failure execption.

```auto
{
class: "org.quartz.simpl.SimpleThreadPool$WorkerThread"
exact: true
file: "SimpleThreadPool.java"
}]
localizedMessage: "30,000 milliseconds timeout on connection http-outgoing-26 [ACTIVE]"
message: "30,000 milliseconds timeout on connection http-outgoing-26 [ACTIVE]"
name: "java.net.SocketTimeoutException"
}

```

The client used here is Java High level client

```auto
    compile "org.elasticsearch.client:elasticsearch-rest-high-level-client: 7.9.2"

```

What could be the cause for the timeout happening and  
what approach or practice to be followed to close index effectively and avoid this timeout?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [January 18, 2022, 11:24am UTC](https://discuss.elastic.co/t/request-to-close-index-fails-due-to-socket-timeout/294687/2 "2022-01-18T11:24:24Z")

</div>

Which version of Elasticsearch are you using? What is the full output of the [cluster stats API](https://www.elastic.co/guide/en/elasticsearch/reference/7.16/cluster-stats.html)?

One reason this could happen is that you have a very large number of shards (open and closed) that results in a large cluster state that takes time to update and propagate. How well Elasticsearch handles this depend a lot on the version used though.

---

<div class="post-metadata">

### Author: ![Shubham\_M](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@Shubham\_M](https://discuss.elastic.co/u/Shubham_M)
#### Post date: [January 18, 2022, 2:07pm UTC](https://discuss.elastic.co/t/request-to-close-index-fails-due-to-socket-timeout/294687/3 "2022-01-18T14:07:56Z")

</div>

elastic version used is 7.9.2,  
Could you please specify which info from cluster stats is needed?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [January 18, 2022, 3:19pm UTC](https://discuss.elastic.co/t/request-to-close-index-fails-due-to-socket-timeout/294687/4 "2022-01-18T15:19:38Z")

</div>

It would be good to see it all as it is hard to tell which parts are most important. Initially I would be most interested in the following though:

- Number of nodes in the cluster
- System resources assigned to the nodes, e.g. RAM and heap
- Total number of indices and shards in the cluster (open and closed)
- Total data volume stored in the cluster
- Memory usage information
- List of third-party plugins installed that could have an impact on cluster state updates and distribution

It would also be good to get an understanding around what load the cluster is under and what kind of hardware and storage that supports it.

Is there anything in the logs, e.g. around long GC?

---

<div class="post-metadata">

### Author: ![Shubham\_M](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@Shubham\_M](https://discuss.elastic.co/u/Shubham_M)
#### Post date: [January 19, 2022, 6:14am UTC](https://discuss.elastic.co/t/request-to-close-index-fails-due-to-socket-timeout/294687/5 "2022-01-19T06:14:41Z")

</div>

There are 7 nodes in total  
please check the below details

```auto
mem": {
        "total_in_bytes": 375809638400,
        "free_in_bytes": 58817269760,
        "used_in_bytes": 316992368640,
        "free_percent": 16,
        "used_percent": 84
      }
    },
    "process": {
      "cpu": {
        "percent": 38
      },
      "open_file_descriptors": {
        "min": 709,
        "max": 819,
        "avg": 767
      }
    },
    "jvm": {
      "max_uptime_in_millis": 4945262384,
      "versions": [
        {
          "version": "15",
          "vm_name": "OpenJDK 64-Bit Server VM",
          "vm_version": "15+36",
          "vm_vendor": "AdoptOpenJDK",
          "bundled_jdk": true,
          "using_bundled_jdk": true,
          "count": 7
        }
      ],
      "mem": {
        "heap_used_in_bytes": 80353920208,
        "heap_max_in_bytes": 187904819200
      },
      "threads": 893
    },
    "fs": {
      "total_in_bytes": 1472131325952,
      "free_in_bytes": 1164132966400,
      "available_in_bytes": 1164015525888
    }

```

there are no logs in es server as such

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [January 19, 2022, 7:02am UTC](https://discuss.elastic.co/t/request-to-close-index-fails-due-to-socket-timeout/294687/6 "2022-01-19T07:02:23Z")

</div>

What about answers to the remaining questions? The most likely reason you are seeing this is in my experience that you have too many shards and indices (open and closed all count) in the cluster which has increased the size of the cluster state and affected how fast this updates and replicates.

---

<div class="post-metadata">

### Author: ![Shubham\_M](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@Shubham\_M](https://discuss.elastic.co/u/Shubham_M)
#### Post date: [January 19, 2022, 7:53am UTC](https://discuss.elastic.co/t/request-to-close-index-fails-due-to-socket-timeout/294687/7 "2022-01-19T07:53:04Z")

</div>

```auto
"index : {
    "count": 26,
    "shards": {
      "total": 94,
      "primaries": 26,
      "replication": 2.6153846153846154,
      "index": {
        "shards": {
          "min": 1,
          "max": 7,
          "avg": 3.6153846153846154
        },
        "primaries": {
          "min": 1,
          "max": 1,
          "avg": 1.0
        },
        "replication": {
          "min": 0.0,
          "max": 6.0,
          "avg": 2.6153846153846154
        }
      }
    },
    "docs": {
      "count": 6156944,
      "deleted": 574568
    },
    "store": {
      "size_in_bytes": 200301943826,
      "reserved_in_bytes": 0
    },
    "fielddata": {
      "memory_size_in_bytes": 23387224,
      "evictions": 0
    },
    "query_cache": {
      "memory_size_in_bytes": 922891449,
      "total_count": 25291617563,
      "hit_count": 339591942,
      "miss_count": 24952025621,
      "cache_size": 172299,
      "cache_count": 904183,
      "evictions": 731884
    },
    "completion": {
      "size_in_bytes": 15990602714
    },
    "segments": {
      "count": 1233,
      "memory_in_bytes": 16087510648,
      "terms_memory_in_bytes": 16066293914,
      "stored_fields_memory_in_bytes": 1421048,
      "term_vectors_memory_in_bytes": 0,
      "norms_memory_in_bytes": 5009536,
      "points_memory_in_bytes": 0,
      "doc_values_memory_in_bytes": 14786150,
      "index_writer_memory_in_bytes": 275889624,
      "version_map_memory_in_bytes": 345014,
      "fixed_bit_set_memory_in_bytes": 0,
      "max_unsafe_auto_id_timestamp": -1,
      "file_sizes": {
        
      }
    },

```

Please check the details above for the other questions

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [January 19, 2022, 8:06am UTC](https://discuss.elastic.co/t/request-to-close-index-fails-due-to-socket-timeout/294687/8 "2022-01-19T08:06:20Z")

</div>

Does that count include the closed indices?

---

<div class="post-metadata">

### Author: ![Shubham\_M](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@Shubham\_M](https://discuss.elastic.co/u/Shubham_M)
#### Post date: [January 19, 2022, 8:38am UTC](https://discuss.elastic.co/t/request-to-close-index-fails-due-to-socket-timeout/294687/9 "2022-01-19T08:38:01Z")

</div>

those are total number of indices (closed+open)

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [January 19, 2022, 8:47am UTC](https://discuss.elastic.co/t/request-to-close-index-fails-due-to-socket-timeout/294687/10 "2022-01-19T08:47:07Z")

</div>

That does not look excessive. What kind if storage are you using?

---

<div class="post-metadata">

### Author: ![Shubham\_M](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@Shubham\_M](https://discuss.elastic.co/u/Shubham_M)
#### Post date: [January 19, 2022, 8:54am UTC](https://discuss.elastic.co/t/request-to-close-index-fails-due-to-socket-timeout/294687/11 "2022-01-19T08:54:38Z")

</div>

storage type is ssd on gcloud

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [January 19, 2022, 8:59am UTC](https://discuss.elastic.co/t/request-to-close-index-fails-due-to-socket-timeout/294687/12 "2022-01-19T08:59:07Z")

</div>

Then I am unfortunately out of ideas.

---

<div class="post-metadata">

### Author: ![Shubham\_M](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@Shubham\_M](https://discuss.elastic.co/u/Shubham_M)
#### Post date: [January 19, 2022, 9:06am UTC](https://discuss.elastic.co/t/request-to-close-index-fails-due-to-socket-timeout/294687/13 "2022-01-19T09:06:40Z")

</div>

It would be great if you could suggest some best practice around closing index effectively

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [January 19, 2022, 9:08am UTC](https://discuss.elastic.co/t/request-to-close-index-fails-due-to-socket-timeout/294687/14 "2022-01-19T09:08:42Z")

</div>

I would recommend not closing indices as well as upgrading to a more recent version. The overhead of open indices has been reduced in recent version which reduces the benefits of closing indices.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [February 16, 2022, 9:09am UTC](https://discuss.elastic.co/t/request-to-close-index-fails-due-to-socket-timeout/294687/15 "2022-02-16T09:09:14Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
