Skip to content

How is keepalive supposed to work? #118

Closed
@snaury

Description

@snaury

I'm wondering how keepalive is supposed to work, because it seems it doesn't:

  • MySQL server stops reading commands after COM_BINLOG_DUMP/_GTID packet, until mysql_binlog_send returns
  • Sending data on a socket is a very bad way to test whether connection is alive, e.g. having data in the send buffer actually disables TCP keepalive until send buffer is drained, i.e. it actually makes it impossible to know when the connection has failed in case there is system-wide TCP keepalive configuration
  • It would be very unusual to have a send side fail without a corresponding receive side failure as well, thus network problems would likely be manifested on the channel receive (in , not on a channel send
  • Having a keepalive thread spawning other random threads makes it very hard to track what's going on in the background, e.g. what is the status of the current reconnection attempt

Would it be possible to change the API to a more user-friendly workflow? Something like this:

  • Method connect would connect, authenticate and start binlog dumping, but return immediately otherwise
  • Method readEvent would (synchronously) read the next event, instead of a separate thread making callbacks, this way it would be easily to control and exceptions would naturally bubble-up to the application loop (this would also make it similar to BinaryLogFileReader)
  • In case of disconnect the keepalive setting would do a reconnect, in the same thread that called readEvent, again making it easier for exceptions to bubble-up

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions