Skip to content

Commit 67835eb

Browse files
authored
Fix RUBY-1687 Cluster hangs waiting for first round of sdam when time is frozen (#1225)
1 parent d86970c commit 67835eb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/mongo/cluster.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def initialize(seeds, monitoring, options = Options::Redacted.new)
177177
# server selection timeout or the 3 second minimum.
178178
loop do
179179
servers = servers_list.dup
180-
if servers.all? { |server| server.description.last_update_time > start_time }
180+
if servers.all? { |server| server.description.last_update_time >= start_time }
181181
break
182182
end
183183
if (time_remaining = deadline - Time.now) <= 0

spec/integration/client_construction_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,17 @@
9191
expect(client.options[:connect]).to eq :direct
9292
end
9393
end
94+
95+
context 'when time is frozen' do
96+
let(:now) { Time.now }
97+
before do
98+
allow(Time).to receive(:now).and_return(now)
99+
end
100+
101+
it 'connects' do
102+
client = ClientRegistry.instance.new_local_client([SpecConfig.instance.addresses.first],
103+
SpecConfig.instance.test_options)
104+
expect(client.cluster.topology).not_to be_a(Mongo::Cluster::Topology::Unknown)
105+
end
106+
end
94107
end

0 commit comments

Comments
 (0)