Right if you are executing remote() and later the query will
go to the cluster with interserver secret, then you should have the same
user on the nodes from that cluster, otherwise the query will fail with:
DB::NetException: Connection reset by peer
And on the remote node:
<Debug> TCPHandler: User (initial, interserver mode): new_user (client: 172.16.1.5:40536)
<Debug> TCP_INTERSERVER-Session: d29ecf7d-2c1c-44d2-8cc9-4ab08175bf05 Authentication failed with error: new_user: Authentication failed: password is incorrect, or there is no user with such name.
<Error> ServerErrorHandler: Code: 516. DB::Exception: new_user: Authentication failed: password is incorrect, or there is no user with such name. (AUTHENTICATION_FAILED), Stack trace (when copying this message, always include the lines below):
The problem is that remote() will not use passed to it user in
any form, and instead, the initial user will be used, i.e. "cli_user"
not "query_user":
chc --user cli_user -q "select * from remote(node, default, some_dist_table, 'query_user')"
Fix this by using the user from query for the remote().
Note, that the Distributed over Distributed in case of tables still wont
work, for this you have to have the same users on all nodes in all
clusters that are involved in case of interserver secret is enabled (see
also test).
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
v2: move client initial_user adjustment into ClusterProxy/executeQuery.cpp
v3: we cannot check for interserver_mode in
updateSettingsAndClientInfoForCluster() since it is not yet
interserver in remote() context