Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-2939

UPDATE operations + socket_timeout setting

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      I have a socket_timeout set in my Mongoid.yml (set to 30 sec)

      If I run an UPDATE operation, such as: 

      SomeLargeCollection.all.set(some_field: :some_value)

      The socket will timeout after the configured 30s, however, the database will run the UPDATE query to completion (regardless of the socket timeout.)

      This is the timeout error I receive is Errno::ETIMEDOUT from the driver:

      /opt/app/vendor/bundle/ruby/3.0.0/gems/mongo-2.17.0/lib/mongo/socket.rb:447:in `rescue in map_exceptions': Errno::ETIMEDOUT: Connection timed out - Took more than 30 seconds to receive data (select call timed out) (for 192.168.253.130:27017 (xxx.mongodb.net:27017, TLS)) (on xxx.mongodb.net:27017, connection 1:47, retries disabled) (Mongo::Error::SocketTimeoutError)/opt/app/vendor/bundle/ruby/3.0.0/gems/mongo-2.17.0/lib/mongo/socket.rb:356:in `rescue in read_from_socket': Connection timed out - Took more than 30 seconds to receive data (select call timed out) (Errno::ETIMEDOUT)/usr/local/lib/ruby/3.0.0/openssl/buffering.rb:205:in `sysread_nonblock': read would block (OpenSSL::SSL::SSLErrorWaitReadable)

      I propose that UPDATE operations should ignore the socket timeout entirely, since the socket timeout is meaningless from DB perspective (query still runs fully).

      There are a number of other operations that always complete, even if socket times out, for example, creating DB indexes. I propose that ANY query which runs to completion in the DB should ignore the socket timeout setting.

      (It would be OK to add a global config "socket_timeout_on_long_running_operations" but it should be FALSE by default)

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            shields@tablecheck.com Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: