Skip to content
This repository was archived by the owner on Nov 16, 2021. It is now read-only.

Differentiate retries for NOT_OPEN and TIMED_OUT transport exceptions #56

@ryangreenberg

Description

@ryangreenberg

The underlying thrift Ruby library raises TransportException under a variety of circumstances:

From thrift's socket.rb:

raise TransportException.new(TransportException::NOT_OPEN, "Connection timeout to #{@desc}")
raise TransportException.new(TransportException::NOT_OPEN, "Could not connect to #{@desc}: #{e}")
raise TransportException.new(TransportException::TIMED_OUT, "Socket: Timed out writing #{str.length} bytes to #{@desc}")
raise TransportException.new(TransportException::NOT_OPEN, e.message)
raise TransportException.new(TransportException::TIMED_OUT, "Socket: Timed out reading #{sz} bytes from #{@desc}")
raise TransportException.new(TransportException::NOT_OPEN, e.message)
raise TransportException.new(TransportException::UNKNOWN, "Socket: Could not read #{sz} bytes from #{@desc}")

The type of transport exception is a property of the exception instance (NOT_OPEN, TIMED_OUT, or UNKNOWN). Currently thrift_client provides the ability to retry only at the level of an exception class (e.g. TransportException). For non-idempotent requests, TIMED_OUT and UNKNOWN are not safe to retry, but NOT_OPEN should be safe. An ideal solution would be to have the Ruby thrift library itself raise subclasses of TransportException. In the interim, does this seem like a reasonable retry strategy to add to thrift_client? If so, I'm happy to do the implementation but would like some input on a good interface for configuring ThriftClient.

Some ideas I had:

  • Add a new top-level option that lets users give a block to determine whether the exception should be retried
  • Don't add any new options, but have thrift_client instead convert Thrift::TransportException to ThriftClient::TransportException::NotOpen, ThriftClient::TransportException::TimedOut, and ThriftClient::TransportException::Unknown all of which subclass Thrift::TransportException, preserving existing behavior.

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