Skip to content

Error Handling Around Missing Socket #656

@sallustfire

Description

@sallustfire

We have a number of hosts deployed with local redis instances that are accessed over a unix socket. The documentation is straightforward and this all works great. However, occasionally when hosts are brought down the socket may be removed, which breaks redis communication. This is also not a problem, but our error handling logic only gracefully resolves all redis related errors that stem from Redis::BaseError.

The connection error for a socket that does not exist is not wrapped with Redis::CannotConnectError. However, all sorts of other connection errors (e.g. unreachable hosts, timeouts, etc.) are. For example,

redis = Redis.new(:path => "/tmp/redis.sock")
redis.set("mykey", "hello world")

raises Errno::ENOENT: No such file or directory - connect(2) for /tmp/redis.sock. However,

redis = Redis.new(:url => "redis://missing.host")
redis.set("mykey", "hello world")

raises Redis::CannotConnectError: Error connecting to Redis on missing.host:6379 (Errno::ECONNREFUSED) essentially wrapping the underlying error.

Is this intentional or can I submit pull request that handles Errno::ENOENT alongside the other connection errors? Thanks.

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