-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:Mac OS X 10.5.8, Ubuntu 10.04, Ruby driver 1.0.2, MongoDB 1.4.2
How to reproduce: Take the Gemfile and Ruby script below, and replace "Toronto.png" with the name of any other large file. (FWIW, Toronto.png is 1.4M.) Run:
bundle install
bundle exec ruby mongo_hang.rb
What happens: Normally, the process will hang somewhere the first 20 times through the loop, typically in a recv call inside grid.put. Sometimes, it will crash with a different recv error.
What should happen: The script should run endlessly.
Workaround: We think this problem is specific to httpclient, so it should be possible to use any other high-level HTTP client library instead.
---- Gemfile:
source 'http://gemcutter.org'
gem 'mongo', '1.0.2'
gem 'bson_ext', '1.0.1', :require => nil
gem 'httpclient', '2.1.5.2'
---- Ruby script:
require 'mongo'
require 'httpclient'
connection = Mongo::Connection.new.db('hang_test')
grid = Mongo::Grid.new(connection)
i = 0
loop do
i = i + 1
puts "Uploading file to grid (#
)"
id = File.open("Toronto.png", 'r') do |f|
grid.put(f)
end
grid.delete(id)
end
---- Sample failures (mostly the odd ones, not the recv hang we see most often)
Uploading file to grid (1)
Uploading file to grid (2)
Uploading file to grid (3)
Uploading file to grid (4)
Uploading file to grid (5)
/Users/emk/.bundle/ruby/1.8/gems/mongo-1.0.2/lib/../lib/mongo/connection.rb:701:in `send_message_on_socket': Operation failed with the following exception: Broken pipe - send(2) (Mongo::ConnectionFailure)
from /Users/emk/.bundle/ruby/1.8/gems/mongo-1.0.2/lib/../lib/mongo/connection.rb:402:in `receive_message'
/Users/emk/.bundle/ruby/1.8/gems/mongo-1.0.2/lib/../lib/mongo/connection.rb:701:in `send_message_on_socket': Operation failed with the following exception: Connection reset by peer - send(2) (Mongo::ConnectionFailure)
from /Users/emk/.bundle/ruby/1.8/gems/mongo-1.0.2/lib/../lib/mongo/connection.rb:342:in `send_message'
from /Users/emk/.bundle/ruby/1.8/gems/mongo-1.0.2/lib/../lib/mongo/collection.rb:677:in `insert_documents'