Skip to content

Conversation

@cheald
Copy link
Contributor

@cheald cheald commented Nov 18, 2014

Previously, unhandled exceptions could cause the driver to leave a pool
entry checked out indefinitely and would stall any other attempts from
the same thread to check out the item, as the orphaned socket was the
thread-affiliated socket.

@cheald
Copy link
Contributor Author

cheald commented Nov 18, 2014

Here's a standalone test case to illustrate the issue:

$: << File.expand_path("../lib", __FILE__)
require_relative './lib/bson'
require_relative './lib/mongo'

$do_raise = false

module Mongo
  class MongoClient
  private
    alias :send_message_on_socket_without_exception :send_message_on_socket
    def send_message_on_socket(packed_message, socket)
      raise "Manually invoked exception" if $do_raise
      send_message_on_socket_without_exception(packed_message, socket)
    end
  end
end

client = Mongo::MongoClient.new pool_size: 5
100.times { client["test"]["pool_test"].insert foo: "bar" }

cursor = client["test"]["pool_test"].find
p cursor
p client.primary_pool

while cursor.has_next?
  doc = cursor.next
  begin
    $do_raise = true
    client["test"]["pool_test"].remove(_id: doc["_id"])
  rescue RuntimeError => e
  end
  print "."
  $do_raise = false
end

Non-handled exceptions can currently be thrown by things like timeout.rb, signals sent to the app, or in the case of JRuby, Java exceptions. These can all leave a given thread permanently unable to check out a socket from the pool.

@durran durran self-assigned this Nov 18, 2014
@durran
Copy link
Member

durran commented Nov 20, 2014

Can you update the specs to use 1.8.x hash syntax? We're still supporting 1.8.7 on the 1.x-stable branch. Thanks!

@estolfo
Copy link
Contributor

estolfo commented Nov 26, 2014

@cheald Would you mind rebasing this and updating it to support 1.8.7? Thanks!

@cheald
Copy link
Contributor Author

cheald commented Nov 27, 2014

Yup, will do. Sorry, been a busy week! :)

On Wed, Nov 26, 2014 at 3:08 AM, Emily notifications@github.com wrote:

@cheald https://github.com/cheald Would you mind rebasing this and
updating it to support 1.8.7? Thanks!


Reply to this email directly or view it on GitHub
#537 (comment)
.

Previously, unhandled exceptions could cause the driver to leave a pool
entry checked out indefinitely and would stall any other attempts from
the same thread to check out the item, as the orphaned socket was the
thread-affiliated socket.

Fix syntax to be 1.8-compatible
@cheald
Copy link
Contributor Author

cheald commented Nov 27, 2014

There you go, rebased onto 1.x-stable and fixed for 1.8!

@estolfo
Copy link
Contributor

estolfo commented Nov 27, 2014

cool, thanks @cheald

estolfo added a commit that referenced this pull request Nov 27, 2014
Ensure that the socket is always checked in after send_message_with_gle
@estolfo estolfo merged commit 159adf9 into mongodb:1.x-stable Nov 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants