Skip to content

Unexpected behavior during request timeout #357

Closed

Description

@gshively11

Hi, I'm seeing some unexpected behavior during request timeouts while using the mssql library. I've traced the code down to the tedious module. Here's my scenario:

  1. Open a connection to the database
  2. Make a request to call a stored procedure
  3. Get result, everything is good.
  4. Go blackhole the database IP, so that no outgoing connections are allowed from my box to that IP.
  5. Initiate another request.
  6. After the configured requestTimeout (3 seconds), I see the request timeout triggering, which sets a 'SentAttention' state.
  7. At this point, things just hang for a little bit, until what I assume is the socket KeepAlive notices that it can't get a response and triggers an error on the socket. At this point, the connection reports back something is wrong.

The unexpected bit is where the request timeout doesn't immediately trigger an error event on the connection and cancel the request, so that the mssql module can report back to the consumer that the request failed due to timeout. Is this behavior intentional? If so, can you explain a little bit of the rationale? Is there another way I should be setting a hard limit on request time? Thanks in advance.

Activity

  1. arthurschreiber commented on Jan 31, 2016

    @arthurschreiber
    Collaborator

    Hey @gshively11,

    We've not implemented the "Cancel Timeout" correctly in Tedious. See https://msdn.microsoft.com/en-us/library/dd341108.aspx

    This is definately something we should get fixed and support correctly.

  2. arthurschreiber commented on Jan 31, 2016

    @arthurschreiber
    Collaborator

    Here's another line from the specification (https://msdn.microsoft.com/en-us/library/dd356487.aspx):

    If a TDS client implements the Client Request Timer and the timer times out, then the TDS client MUST send an Attention message to the server and enter the "Sent Attention" state.

    So we're handling the request timeout correctly.

    But on the next line, it says:

    If a TDS client implements the Cancel Timer and the timer times out, then the TDS client MUST close the underlying connection, indicate the error to the upper layer, and enter the "Final State" state.

    I also checked the code again to be sure. Although we have a cancelTimeout option, it's not honored anywhere. Adding the timeout should not be too hard.

  3. gshively11 commented on Feb 1, 2016

    @gshively11
    Author

    @arthurschreiber Thanks for clarifying, that makes sense now. I'll take a crack at a PR if I have time, but it may not be for a little while. I'd love to see this feature if you have the bandwidth! In the mean time, we can just rely on the socket error for now.

  4. IanChokS commented on Dec 18, 2019

    @IanChokS
    Member

    Feature merged in #846

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions