diff --git a/config/initializers/macos.rb b/config/initializers/macos.rb index 860167e12cd51efb6783478d95c38d9f88f5c49b..7ec022add183a285c3944c42fdd9826d130d87cd 100644 --- a/config/initializers/macos.rb +++ b/config/initializers/macos.rb @@ -28,4 +28,12 @@ module CFTimeZone time_zone_name = CFTimeZone.CFTimeZoneGetName(default_time_zone) CFTimeZone.CFRelease(time_zone_name) CFTimeZone.CFRelease(default_time_zone) + + # With curl v8.2.0, the thread unsafe macOS API call to + # SCDynamicStoreCopyProxies has been moved to the global init function + # (https://github.com/curl/curl/issues/11252). The Elasticsearch + # gem uses Typhoeus, which uses Ethon to wrap libcurl. + # Init curl to ensure Spring works + # (https://github.com/elastic/elasticsearch-ruby/issues/2244). + Ethon::Curl.init end diff --git a/ee/lib/gitlab/elastic/client.rb b/ee/lib/gitlab/elastic/client.rb index 56b3ac5f4a519671a7f43133f30f8303e1a22d6a..d42a03ff1156755e7ac7bf8dba9b92b0c7f0f5c0 100644 --- a/ee/lib/gitlab/elastic/client.rb +++ b/ee/lib/gitlab/elastic/client.rb @@ -41,18 +41,9 @@ def self.build(config) end def self.adapter - # We can't use Typhoeus with Spring on macOS because Typhoeus uses libcurl. - # Before libcurl resolves an IP address, it calls SCDynamicStoreCopyProxies, - # which appears to crash in a forked process with threads. - return :net_http if spring_on_macos? - ::Feature.enabled?(:use_typhoeus_elasticsearch_adapter) ? :typhoeus : :net_http end - def self.spring_on_macos? - Rails.env.test? && defined?(::Spring) && RUBY_PLATFORM.include?('darwin') - end - def self.debug? Gitlab.dev_or_test_env? && Gitlab::Utils.to_boolean(ENV['ELASTIC_CLIENT_DEBUG']) end diff --git a/ee/spec/lib/gitlab/elastic/client_spec.rb b/ee/spec/lib/gitlab/elastic/client_spec.rb index 1af24047a0c1b62aa96ede1fb5d1b55ede76f391..a1701621edff9e60fb03419e6aef34799000f171 100644 --- a/ee/spec/lib/gitlab/elastic/client_spec.rb +++ b/ee/spec/lib/gitlab/elastic/client_spec.rb @@ -34,10 +34,6 @@ end context 'with typhoeus adapter for keep-alive connections' do - before do - allow(described_class).to receive(:spring_on_macos?).and_return(false) - end - it 'sets typhoeus as the adapter' do options = client.transport.options