Skip to content

Handling edge cases on connSet(Read/Write)Handler #528

@madolson

Description

@madolson

There are quite a few places where we call connSetReadHandler and connSetWriteHandler and don't check the return code.

From an API perspective, we only need to check the return code when we're setting the value to a non-null value, which is the only place with known failure modes. The only known failure mode I'm aware of is when you try to set a connection handler to a connection whose fd is greater than the maxclients, which is possible if the ulimit for fds is set greater than the maxclients.

When we fail to check the return code, we might end up in a situation where a connection is not registered and becomes unreachable outside of an operation like client kill. I've seen this at AWS with the primary/replica link, which can lead to a broken link.

I think we have two options:

  1. Make sure we are better handling these failure modes, as in we always handle the error code when setting the read or write handler.
  2. Make sure there are no failure modes on the connSetHandler path, by making sure it's a valid connection during connAccept or connConnect. connSetReadHandler and connSetWriteHandler should be changed to a void return type, and panic when they fail. (My preference)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions