Redirection mechanism is widely used in proxy-based scenario.
Currently when multiple servers share one proxy, proxy forwards all the packets between servers and clients. Thus, the proxy adds latency, take many computing resources and impacts the overall performance. Especially for short connections scenarios like WordPress, the latency can be a critical issue.
Supporting redirection mechanism is helpful for proxy-based scenario. It is more like HTTP redirects  or Oracle redirected connections . Clients get the servers’ address from proxies and connect to servers transparently without latency and computing resource wasted.
Client/Server Protocol change needs both client and server support. The routine is
- Server sets the capability flag  in Initial Handshake Packet, indicating server supports MARIADB_SERVER_REDIRECTION.
MARIADB_SERVER_REDIRECTION 1 <<31 Server support redirection
- Client sets the capability flag  in Client Handshake Response Packet, indicating client supports MARIADB_SERVER_REDIRECTION.
- If client sets MARIADB_SERVER_REDIRECTION in Client Handshake Response Packet , server can send Redirection Information Packet other than OK_Packet / ERR_Packet / Authentication Switch Packet.
- Client receives Redirection Information Packet, close the connection, and then use its information to connect the new host.
- Client will use the redirection information to set up new connections until information expires or login parse error happens. The redirection information packet contains TTL of the information.
The Redirection Information Packet schema is
|Field Type||Field Name||Notes|
|int<1>||Packet Header||Packet header sets 0xFC to indicate it is a Redirection Information Packet.|
|int<1>||Protocol Version||Currently protocol version is 0, specifying TCP-IPv4 protocol.|
|int<2>||Protocol Property||For TCP-IPv4 protocol, it is the port number.|
|int<2>||Time to Live||TTL is the life time of the validity of this redirected information with unit ‘second’.|
|string<NUL>||Redirected Host||Redirected host is a valid IPv4 address, an A name pointing to this address, or a CNAME record.|
|string<NUL>||Redirected User||Default will be the original user in connection string, but can used for proxy user.|
For recursion of redirection, in the scenario, the recursion is not useful. Should not recommend client side implement recursion of redirection.