Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Re-connect to server-proxy if remote connection is closed. #14

Description

@fatih

We should handle the edge cases for remote connections being closed. The client (sql-client-proxy) might lose the connection to sql-server-proxy due to the connection being closed via the database. If that happens, the client might assume that the TCP connection is still in-tact, but any writes on the TCP connection will fail.

If sql-server-proxy loses the connection to the database, it'll print this error:

2021/01/19 14:56:04 instance remote conn closed connection

If sql-client-proxy loses the connection to the sql-server-proxy, it'll print this error:

2021/01/19 14:56:04 instance remote connection closed connection

Finally, the MySQL client, in our example the mysql CLI will print this error when we try to send any commands (a.k.a write to the TCP connection):

mysql> \s
ERROR 2013 (HY000): Lost connection to MySQL server during query

However, the MySQL client is smart enough to retry and make a new connection:

mysql> \s
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    119159
Current database: *** NONE ***

--------------
mysql  Ver 14.14 Distrib 5.7.32, for osx10.16 (x86_64) using  EditLine wrapper

Connection id:          119159
Current database:
Current user:           vt_app@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.7.9-Vitess MySQL Community Server - GPL
Protocol version:       10
Connection:             127.0.0.1 via TCP/IP
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
TCP port:               3307
--------------

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