Ruby Driver
  1. Ruby Driver
  2. RUBY-221

client driver loses synchronization with comunication stream due to exceptions at certain points

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Critical - P2 Critical - P2
    • Resolution: Works as Designed
    • Affects Version/s: 1.1.4, 1.1.5
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      mongo server 1.6.5
    • Backward Breaking:
      No
    • Operating System:
      ALL
    • # Replies:
      4
    • Last comment by Customer:
      true

      Description

      The ruby client driver loses track of its position in the stream of responses from the server if an exception occurs while Connection#send_with_safe_check or Connection#receive_message are running. This commonly occurs when the client application uses a Timeout; a Timeout::Error exception may be raised while Connection#receive is blocked. Other exceptions are possible here (due to other asynchronous signals or perhaps due to unexpected IO conditions). When an exception occurs at this point, the server will eventually send a response, but the client driver is no longer waiting for it. The response is typically consumed by the subsequent mongo operations; all following request appear to get the response from the preceding request.

      (Unless there is a sequence number in the mongo protocol that is being ignored by the client driver...) I'd advise adding an exception handler to the critical section of Connection#receive_message and Connection#send_with_safe_check that closes the socket when any exception occurs. (See attached patch)

        Issue Links

          Activity

          Hide
          Kyle Banker
          added a comment -

          Hi Joshua,

          I'm pretty sure I fixed this in 1.1.5. If the response is out of sequence, the socket is closed and an exception will be raised.

          Notice that we now store the request id for the last_error_message:
          https://github.com/mongodb/mongo-ruby-driver/blob/1.1.5/lib/mongo/connection.rb#L374-382

          And that we check for the proper response here:
          https://github.com/mongodb/mongo-ruby-driver/blob/1.1.5/lib/mongo/connection.rb#L593-602

          Does this address the problem you describe?

          Kyle

          Show
          Kyle Banker
          added a comment - Hi Joshua, I'm pretty sure I fixed this in 1.1.5. If the response is out of sequence, the socket is closed and an exception will be raised. Notice that we now store the request id for the last_error_message: https://github.com/mongodb/mongo-ruby-driver/blob/1.1.5/lib/mongo/connection.rb#L374-382 And that we check for the proper response here: https://github.com/mongodb/mongo-ruby-driver/blob/1.1.5/lib/mongo/connection.rb#L593-602 Does this address the problem you describe? Kyle
          Hide
          Joshua Napoli
          added a comment -

          Thanks; it looks like that will work. I'll test it.

          Show
          Joshua Napoli
          added a comment - Thanks; it looks like that will work. I'll test it.
          Hide
          Joshua Napoli
          added a comment -

          Thanks, Kyle. The version 1.1.5 does indeed solve the problem.

          Show
          Joshua Napoli
          added a comment - Thanks, Kyle. The version 1.1.5 does indeed solve the problem.
          Hide
          Kyle Banker
          added a comment -

          Thanks for double-checking. In that case, I'll close.

          Show
          Kyle Banker
          added a comment - Thanks for double-checking. In that case, I'll close.

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since reply:
                3 years, 15 weeks, 6 days ago
                Date of 1st Reply: