Fix Elasticsearch connection cleanup in Sidekiq middleware (#39359)

This commit is contained in:
Claire 2026-06-10 17:12:25 +02:00 committed by GitHub
parent 2994e8543d
commit 22a5e1b0b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -34,7 +34,7 @@ class Mastodon::SidekiqMiddleware
# and each such client manages its long-lasting connection to
# Elasticsearch.
#
# As far as I know, neither `chewy`, `elasticsearch-transport` or even
# As far as I know, neither `chewy`, `elastic-transport` or even
# `faraday` provide a reliable way to immediately close a connection, and
# rely on the underlying object to be garbage-collected instead.
#
@ -44,7 +44,7 @@ class Mastodon::SidekiqMiddleware
def clean_up_elasticsearch_connections!
return unless Chewy.enabled? && Chewy.current[:chewy_client].present?
Chewy.client.transport.transport.connections.each do |connection|
Chewy.client.transport.connections.each do |connection|
# NOTE: This bit of code is tailored for the HTTPClient Faraday adapter
connection.connection.app.instance_variable_get(:@client)&.reset_all
end