From 2331ae3d3b87d4f7bb9c5502722e3c692a636258 Mon Sep 17 00:00:00 2001 From: Sebastian Zuchmanski Date: Thu, 5 Feb 2026 14:51:55 +0100 Subject: [PATCH 1/4] Set socket timeouts for node validation connections --- lib/aerospike/node.rb | 2 ++ lib/aerospike/node_validator.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/aerospike/node.rb b/lib/aerospike/node.rb index b2799e7b..86aa9950 100644 --- a/lib/aerospike/node.rb +++ b/lib/aerospike/node.rb @@ -120,6 +120,8 @@ def put_connection(conn) def tend_connection if @tend_connection.nil? || @tend_connection.closed? @tend_connection = Cluster::CreateConnection.(cluster, host) + @tend_connection.timeout = cluster.connection_timeout + @tend_connection end @tend_connection end diff --git a/lib/aerospike/node_validator.rb b/lib/aerospike/node_validator.rb index 471c8bc9..b8472b73 100644 --- a/lib/aerospike/node_validator.rb +++ b/lib/aerospike/node_validator.rb @@ -44,6 +44,7 @@ def get_hosts(address) begin conn = Cluster::CreateConnection.(@cluster, Host.new(address, host.port, host.tls_name)) + conn.timeout = @cluster.connection_timeout commands = %w[node features] commands << address_command unless is_loopback?(address) From 6e539f4432b96d09dfb47cabe00168d9909aac43 Mon Sep 17 00:00:00 2001 From: Sebastian Zuchmanski Date: Thu, 5 Feb 2026 15:10:27 +0100 Subject: [PATCH 2/4] Fix specs --- lib/aerospike/node_validator.rb | 5 +++-- spec/aerospike/node_validator_spec.rb | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/aerospike/node_validator.rb b/lib/aerospike/node_validator.rb index b8472b73..5a5fe36b 100644 --- a/lib/aerospike/node_validator.rb +++ b/lib/aerospike/node_validator.rb @@ -20,12 +20,13 @@ module Aerospike class NodeValidator # :nodoc: - attr_reader :host, :aliases, :name, :features, :cluster_name, :tls_options, :conn + attr_reader :host, :timeout, :aliases, :name, :features, :cluster_name, :tls_options, :conn def initialize(cluster, host, timeout, cluster_name, tls_options = {}) @cluster = cluster @features = Set.new @host = host + @timeout = timeout @cluster_name = cluster_name @tls_options = tls_options @@ -44,7 +45,7 @@ def get_hosts(address) begin conn = Cluster::CreateConnection.(@cluster, Host.new(address, host.port, host.tls_name)) - conn.timeout = @cluster.connection_timeout + conn.timeout = timeout commands = %w[node features] commands << address_command unless is_loopback?(address) diff --git a/spec/aerospike/node_validator_spec.rb b/spec/aerospike/node_validator_spec.rb index 80561cef..81a93205 100644 --- a/spec/aerospike/node_validator_spec.rb +++ b/spec/aerospike/node_validator_spec.rb @@ -21,6 +21,7 @@ before do allow(socket).to receive(:write).and_return(nil) allow(socket).to receive(:read).and_return(nil) + allow(socket).to receive(:timeout=).and_return(nil) expect(::Aerospike::Cluster::CreateConnection).to receive(:call).and_return(socket) end @@ -31,6 +32,7 @@ let(:hosts) { [::Aerospike::Host.new('192.168.1.1', '3000')] } before do + allow(socket).to receive(:timeout=).and_return(nil) allow(::Aerospike::Cluster::CreateConnection).to receive(:call).and_return(socket) expect(::Aerospike::Info).to receive(:request).and_return( @@ -49,6 +51,7 @@ let(:hosts) { [::Aerospike::Host.new('my.lb.com', '3000')] } before do + allow(socket).to receive(:timeout=).and_return(nil) allow(::Aerospike::Cluster::CreateConnection).to receive(:call).and_return(socket) expect(Resolv).to receive(:getaddresses).and_return(['101.1.1.1', '102.1.1.1']) @@ -79,6 +82,7 @@ let(:policy) { ::Aerospike::ClientPolicy.new(tls: { enable: true }) } before do + allow(socket).to receive(:timeout=).and_return(nil) allow(::Aerospike::Cluster::CreateConnection).to receive(:call).and_return(socket) expect(Resolv).to receive(:getaddresses).and_return(['101.1.1.1', '102.1.1.1']) From fddc159898b4a70db3345efd86dca1db6e1a8e55 Mon Sep 17 00:00:00 2001 From: Sebastian Zuchmanski Date: Thu, 5 Feb 2026 15:17:34 +0100 Subject: [PATCH 3/4] Remove timeout setting for connection in tend_connection method --- lib/aerospike/node.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/aerospike/node.rb b/lib/aerospike/node.rb index 86aa9950..b2799e7b 100644 --- a/lib/aerospike/node.rb +++ b/lib/aerospike/node.rb @@ -120,8 +120,6 @@ def put_connection(conn) def tend_connection if @tend_connection.nil? || @tend_connection.closed? @tend_connection = Cluster::CreateConnection.(cluster, host) - @tend_connection.timeout = cluster.connection_timeout - @tend_connection end @tend_connection end From 268c068a742d0dc4bae5dd7013fe76cf0fa005eb Mon Sep 17 00:00:00 2001 From: Sebastian Zuchmanski Date: Fri, 6 Feb 2026 15:00:16 +0100 Subject: [PATCH 4/4] Add connection timeout setting in tend_connection method --- lib/aerospike/node.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/aerospike/node.rb b/lib/aerospike/node.rb index b2799e7b..2c6a1b8e 100644 --- a/lib/aerospike/node.rb +++ b/lib/aerospike/node.rb @@ -120,6 +120,7 @@ def put_connection(conn) def tend_connection if @tend_connection.nil? || @tend_connection.closed? @tend_connection = Cluster::CreateConnection.(cluster, host) + @tend_connection.timeout = cluster.connection_timeout end @tend_connection end