mongo 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,11 @@
1
1
  # MongoDB Ruby Driver History
2
2
 
3
+ ### 1.2.2
4
+ 2011-2-15
5
+
6
+ * Improved replica set failover for edge case.
7
+ * Fix for REE on OSX (Hongli Lai)
8
+
3
9
  ### 1.2.1
4
10
  2011-1-18
5
11
 
@@ -63,7 +63,7 @@ The Ruby driver (>= 1.1.5) includes unit tests for verifying replica set behavio
63
63
  rake test:rs
64
64
 
65
65
  The suite will set up a five-node replica set by itself and ensure that driver behaves correctly even in the face
66
- of individual node failures. Node that the `mongod` executable must be in the search path for this to work.
66
+ of individual node failures. Note that the `mongod` executable must be in the search path for this to work.
67
67
 
68
68
  ### Further Reading
69
69
 
@@ -19,7 +19,7 @@
19
19
  $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
20
20
 
21
21
  module Mongo
22
- VERSION = "1.2.1"
22
+ VERSION = "1.2.2"
23
23
  end
24
24
 
25
25
  module Mongo
@@ -795,7 +795,7 @@ module Mongo
795
795
  begin
796
796
  message = new_binary_string
797
797
  socket.read(length, message)
798
- raise ConnectionFailure, "connection closed" unless message.length > 0
798
+ raise ConnectionFailure, "connection closed" unless message && message.length > 0
799
799
  if message.length < length
800
800
  chunk = new_binary_string
801
801
  while message.length < length
@@ -119,8 +119,10 @@ module Mongo
119
119
  BSON::BSON_CODER.update_max_bson_size(self)
120
120
  else
121
121
  if @secondary_pools.empty?
122
+ close # close any existing pools and sockets
122
123
  raise ConnectionFailure, "Failed to connect any given host:port"
123
124
  else
125
+ close # close any existing pools and sockets
124
126
  raise ConnectionFailure, "Failed to connect to primary node."
125
127
  end
126
128
  end
@@ -136,7 +138,7 @@ module Mongo
136
138
  #
137
139
  # @return [Boolean]
138
140
  def read_primary?
139
- !@read_pool || @read_pool.length.zero?
141
+ !@read_pool
140
142
  end
141
143
  alias :primary? :read_primary?
142
144
 
@@ -194,9 +196,13 @@ module Mongo
194
196
 
195
197
  check_set_name(config, socket)
196
198
  rescue OperationFailure, SocketError, SystemCallError, IOError => ex
197
- close unless connected?
199
+ # It's necessary to rescue here. The #connect method will keep trying
200
+ # until it has no more nodes to try and raise a ConnectionFailure if
201
+ # it can't connect to a primary.
198
202
  ensure
203
+ socket.close if socket
199
204
  @nodes_tried << node
205
+
200
206
  if config
201
207
  nodes = []
202
208
  nodes += config['hosts'] if config['hosts']
@@ -208,8 +214,6 @@ module Mongo
208
214
  @logger.warn("MONGODB #{config['msg']}")
209
215
  end
210
216
  end
211
-
212
- socket.close if socket
213
217
  end
214
218
 
215
219
  config
@@ -76,7 +76,7 @@ module Mongo
76
76
  socket = TCPSocket.new(@host, @port)
77
77
  socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
78
78
  rescue => ex
79
- raise ConnectionFailure, "Failed to connect socket: #{ex}"
79
+ raise ConnectionFailure, "Failed to connect to host #{@host} and port #{@port}: #{ex}"
80
80
  end
81
81
 
82
82
  # If any saved authentications exist, we want to apply those
@@ -146,7 +146,7 @@ module Mongo
146
146
 
147
147
  if socket
148
148
 
149
- # This call all procs, in order, scoped to existing sockets.
149
+ # This calls all procs, in order, scoped to existing sockets.
150
150
  # At the moment, we use this to lazily authenticate and
151
151
  # logout existing socket connections.
152
152
  @socket_ops[socket].reject! do |op|
@@ -17,8 +17,10 @@ class ReplicaSetQuerySecondariesTest < Test::Unit::TestCase
17
17
  end
18
18
 
19
19
  def test_read_primary
20
- assert !@conn.read_primary?
21
- assert !@conn.primary?
20
+ rescue_connection_failure do
21
+ assert !@conn.read_primary?
22
+ assert !@conn.primary?
23
+ end
22
24
  end
23
25
 
24
26
  def test_con
@@ -59,6 +61,12 @@ class ReplicaSetQuerySecondariesTest < Test::Unit::TestCase
59
61
  # Should still be able to read immediately after killing master node
60
62
  RS.kill_primary
61
63
  assert_equal 2, @coll.find.to_a.length
64
+ rescue_connection_failure do
65
+ @coll.save({:a => 50}, :safe => {:w => 2, :wtimeout => 10000})
66
+ end
67
+ RS.restart_killed_nodes
68
+ @coll.save({:a => 50}, :safe => {:w => 2, :wtimeout => 10000})
69
+ assert_equal 4, @coll.find.to_a.length
62
70
  end
63
71
 
64
72
  def test_kill_secondary
@@ -71,6 +79,7 @@ class ReplicaSetQuerySecondariesTest < Test::Unit::TestCase
71
79
  RS.kill(read_node)
72
80
 
73
81
  # Should fail immediately on next read
82
+ old_read_pool_port = @conn.read_pool.port
74
83
  assert_raise ConnectionFailure do
75
84
  @coll.find.to_a.length
76
85
  end
@@ -80,6 +89,8 @@ class ReplicaSetQuerySecondariesTest < Test::Unit::TestCase
80
89
  length = @coll.find.to_a.length
81
90
  assert_equal 2, length
82
91
  end
92
+ new_read_pool_port = @conn.read_pool.port
93
+ assert old_read_pool != new_read_pool
83
94
  end
84
95
 
85
96
  end
@@ -16,7 +16,7 @@ class Test::Unit::TestCase
16
16
  begin
17
17
  yield
18
18
  rescue Mongo::ConnectionFailure => ex
19
- puts "Rescue attempt #{retries}"
19
+ puts "Rescue attempt #{retries}: from #{ex}"
20
20
  retries += 1
21
21
  raise ex if retries > max_retries
22
22
  sleep(1)
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 27
5
+ prerelease:
5
6
  segments:
6
7
  - 1
7
8
  - 2
8
- - 1
9
- version: 1.2.1
9
+ - 2
10
+ version: 1.2.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Jim Menard
@@ -16,7 +17,7 @@ autorequire:
16
17
  bindir: bin
17
18
  cert_chain: []
18
19
 
19
- date: 2011-02-10 00:00:00 -05:00
20
+ date: 2011-02-15 00:00:00 -05:00
20
21
  default_executable:
21
22
  dependencies:
22
23
  - !ruby/object:Gem::Dependency
@@ -27,11 +28,12 @@ dependencies:
27
28
  requirements:
28
29
  - - ">="
29
30
  - !ruby/object:Gem::Version
31
+ hash: 27
30
32
  segments:
31
33
  - 1
32
34
  - 2
33
- - 1
34
- version: 1.2.1
35
+ - 2
36
+ version: 1.2.2
35
37
  type: :runtime
36
38
  version_requirements: *id001
37
39
  description: A Ruby driver for MongoDB. For more information about Mongo, see http://www.mongodb.org.
@@ -153,6 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
153
155
  requirements:
154
156
  - - ">="
155
157
  - !ruby/object:Gem::Version
158
+ hash: 3
156
159
  segments:
157
160
  - 0
158
161
  version: "0"
@@ -161,13 +164,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
164
  requirements:
162
165
  - - ">="
163
166
  - !ruby/object:Gem::Version
167
+ hash: 3
164
168
  segments:
165
169
  - 0
166
170
  version: "0"
167
171
  requirements: []
168
172
 
169
173
  rubyforge_project:
170
- rubygems_version: 1.3.7
174
+ rubygems_version: 1.4.1
171
175
  signing_key:
172
176
  specification_version: 3
173
177
  summary: Ruby driver for the MongoDB