Allow setting socket_timeout and max_time_ms per Criteria

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Duplicate
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Mongoid allows settingĀ `socket_timeout` in mongoid.yml. This value applies universally to all queries, and you cannot later override it.

      (There is a method Criteria#no_timeout which prevents database-side timeout of cursors, i.e. GETMORE, however it does not apply to the socket_timeout setting.)

      I would propose adding Criteria#socket_timeout(<Integer|nil>) which allows to override per query.

      In my use case, I would set a low default value (e.g. 5 seconds) and then override known long running queries with a longer value (e.g. 60 seconds or nil, meaning no socket timeout)

      Since read queries should use max_time_ms instead of socket_timeout, it would make sense to adjust max_time_ms per Criteria as well.

      Note that socket_timeout (currently) affects monitoring and connections overall and changing it for one operation would require driver support. max_time_ms already is a per-operation option and changing it should only require modifications in Mongoid.

            Assignee:
            Unassigned
            Reporter:
            Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: