From 8ee4f95a23357435dcc976188d951bcf28459b05 Mon Sep 17 00:00:00 2001 From: Federico Nusymowicz Date: Wed, 11 Feb 2015 15:20:31 -0800 Subject: [PATCH 1/3] Fix #345 --- lib/moped/node.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/moped/node.rb b/lib/moped/node.rb index 8847fd8..0cafd4e 100644 --- a/lib/moped/node.rb +++ b/lib/moped/node.rb @@ -150,10 +150,10 @@ def disconnect # # @since 2.0.0 def down! - @pool = Connection::Manager.shutdown(self) @down_at = Time.new + @pool = nil @latency = nil - true + Connection::Manager.shutdown(self) end # Yields the block if a connection can be established, retrying when a From 4ebfbba3009c0cadb91efbd7fd1d9e6197ea6f3b Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 12 Feb 2015 11:35:13 -0500 Subject: [PATCH 2/3] Spec for #345. --- spec/moped/node_spec.rb | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/spec/moped/node_spec.rb b/spec/moped/node_spec.rb index 2113ab2..aa88688 100644 --- a/spec/moped/node_spec.rb +++ b/spec/moped/node_spec.rb @@ -63,15 +63,33 @@ end end - pending '#down!' do + describe '#down!' do + describe 'when connected' do + before do + node.connected? + end - before do - node.connected? - node.down! - end + describe 'shutdown' do + before do + node.down! + end - it 'clears out the connection pool' do - expect(node.instance_variable_get(:@pool)).to be_nil + it 'clears out the connection pool' do + expect(node.instance_variable_get(:@pool)).to be_nil + end + end + + describe 'shutdown from multiple threads' do + before do + # fake the behavior of @pool that holds its value until shutdown returns + allow(Moped::Connection::Manager).to receive(:shutdown).and_return(node.instance_variable_get(:@pool)).once + node.down! + end + + it 'clears out the connection pool before returning' do + expect(node.instance_variable_get(:@pool)).to be_nil + end + end end end From f9905ffa15a8bdcc482ae844b27865567d1b6311 Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 12 Feb 2015 11:37:23 -0500 Subject: [PATCH 3/3] Added CHANGELOG. --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index caf3848..745b17f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Overview +## Next + +### Resolved Issues + +* \#345 + Writes fail with ConnectionPool::PoolShuttingDownError. (fedenusy, dblock) + ## 2.0.3 ### Resolved Issues