[MDEV-15450] Add Host Name Field to MariaDB Client Handshake Protocol Created: 2018-03-02  Updated: 2018-05-22  Resolved: 2018-05-22

Status: Closed
Project: MariaDB Server
Component/s: Server
Fix Version/s: 10.3.7

Type: Task Priority: Blocker
Reporter: Alex Lee Assignee: Vladislav Vaintroub
Resolution: Fixed Votes: 0
Labels: client, contribution, foundation, protocol

Attachments: PNG File hostname.png    
Issue Links:
Relates
relates to CONJ-602 Add server hostname to connection pac... Closed
relates to ODBC-144 Add connection string option for serv... Closed
relates to CONJS-31 Add server hostname to connection pac... Closed

 Description   

Why

In original, one MariaDB server instance is identified by one address (IP + port). That is not enough for a shared proxy for multi servers. Like HTTP HOST header, which enables virtual host in a web server machine [1]. The similar approach is used in Oracle net listener by adding INSTANCE_NAME [2]. Adding the host name field helps the proxy layer to find the backend server, monitor full throughput easily, and can do the specific logic on different host. For cloud service, let server instance can be identified by <server name, address (IP + port)> will help to simplified workflow for the frontend proxy.

What to do

Since 10.0.5. MariaDB started supporting applications to pass key/value connection attributes when connecting [3].
Adding host name field in connection attributes is a good idea. The connection attributes are passed from client to server in the first communication package. The attributes is optional so that it keeps back compatibility.

MariaDB reserves the attribute names that begin with an underscore (_) for internal use which should not be created by application programs [4]. The proposal is using the same approach to reserve one more name. The attribute is named ‘_host_name’ to record the host name used in the connection string (the connection parameters). This field is used by the server or proxy to figure out which server the client is trying to connect to. The client drivers that support this protocol sends the attribute in the handshake response packet.

The code change involves:
1. Add ‘_host_name’ attributes in MariaDB owned client driver.
2. Add a new document to encourage other community client driver to including this attribute.
3. Support this protocol in MaxScale proxy.

[1]. https://stackoverflow.com/questions/43156023/what-is-http-host-header
[2]. https://docs.oracle.com/cd/E11882_01/network.112/e41945/listenercfg.htm#NETAG299
[3]. https://mariadb.com/kb/en/library/performance-schema-session_account_connect_attrs-table/
[4.] https://dev.mysql.com/doc/refman/5.7/en/performance-schema-connection-attribute-tables.html



 Comments   
Comment by Otto Kekäläinen [ 2018-04-26 ]

Thanks for the detailed feature specification. Do you have any patches / prototype code or something related to this?

Comment by xiangyhu [ 2018-05-09 ]

Hi otto, thanks for you comment, I have attached the screenshot which includes the _host_name attribute proposed, please check out.

Thanks,
xiangyhu

Comment by Otto Kekäläinen [ 2018-05-09 ]

Nice. So you already have a patch against MySQL 5.7? Can you rebase it on MariaDB 10.3/10.4 and share?

Comment by xiangyhu [ 2018-05-10 ]

otto Yeah sure, I have created pull request at https://github.com/MariaDB/server/pull/751, please help to review!

Thanks,
xiangyhu

Comment by Vladislav Vaintroub [ 2018-05-10 ]

actually our server supports proxy protocol, and MaxScale uses it too. Would not this do the same thing that proxy protocol does?
https://mariadb.com/kb/en/library/proxy-protocol-support/

Comment by Sergei Golubchik [ 2018-05-11 ]

No, that's different, as far as I understand. In the proxy protocol you specify what host you connect from, but here you specify what host you connect to.

Comment by Vladislav Vaintroub [ 2018-05-11 ]

right,I figured this too, from looking at the patch. The "host_name" was a little confusing, but now it changed to _server_host , and this is more clear.

Comment by Sergei Golubchik [ 2018-05-11 ]

Reopening until C/C is fixed too

Generated at Thu Feb 08 08:21:24 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.