Skip to content
  • Dirkjan Bussink's avatar
    bc403f06
    Add connection check to Trilogy · bc403f06
    Dirkjan Bussink authored
    
    
    This adds a very cheap connection check to Trilogy. This cheap check can
    be used before a connection for example is checked out from a connection
    pool.
    
    It allows for making the client more robust in the case of the server
    having disconnected (like a failover, an intermediate proxy like
    ProxySQL or VTGate restarted etc) but it can be reconnected safely.
    
    It works by doing a non-blocking `recv` to peek if there's any data. If
    there is, or if the function would otherwise block it means the
    connection is still safe.
    
    If the TCP connection has been closed, `recv` immediately returns with
    zero bytes read. This indicates the connection is no longer safe to use.
    We do this directly on the file descriptor to be consistent regardless
    of things like TLS being used.
    
    Co-authored-by: default avatarDaniel Colson <composerinteralia@github.com>
    Co-authored-by: default avatarJohn Hawthorn <john@hawthorn.email>
    bc403f06
    Add connection check to Trilogy
    Dirkjan Bussink authored
    
    
    This adds a very cheap connection check to Trilogy. This cheap check can
    be used before a connection for example is checked out from a connection
    pool.
    
    It allows for making the client more robust in the case of the server
    having disconnected (like a failover, an intermediate proxy like
    ProxySQL or VTGate restarted etc) but it can be reconnected safely.
    
    It works by doing a non-blocking `recv` to peek if there's any data. If
    there is, or if the function would otherwise block it means the
    connection is still safe.
    
    If the TCP connection has been closed, `recv` immediately returns with
    zero bytes read. This indicates the connection is no longer safe to use.
    We do this directly on the file descriptor to be consistent regardless
    of things like TLS being used.
    
    Co-authored-by: default avatarDaniel Colson <composerinteralia@github.com>
    Co-authored-by: default avatarJohn Hawthorn <john@hawthorn.email>
Loading