Fix "Too many open files" errors when using ElasticSearch

This change sets the Faraday adapter used for ElasticSearch to `:net_http`.

The `elasticsearch-transport` gem tries to auto detect a suitable Faraday
adapter.  Mastodon uses the Faraday default adapter of `:net_http`, but since
`elasticsearch-transport` sees that the `httpclient` gem is available it lets
Faraday use that one.  Unfortunately `httpclient` does not properly clean up
its connections, leading to a lot of established connections to ElasticSearch
over time.

See also: e074fcff9b/lib/elastic/transport/client.rb (L291-L304)

(https://github.com/mastodon/mastodon/pull/27138)
This commit is contained in:
Georg Gadinger 2024-01-07 20:05:46 +01:00 committed by Jeremy Kescher
parent 9fd1e79e95
commit 59be64f1d6
No known key found for this signature in database
GPG key ID: 80A419A7A613DFA4

View file

@ -18,6 +18,7 @@ Chewy.settings = {
index: {
number_of_replicas: ['single_node_cluster', nil].include?(ENV['ES_PRESET'].presence) ? 0 : 1,
},
adapter: :net_http,
}
# We use our own async strategy even outside the request-response