Repository navigation
Conversation
A MySQL dictionary source created with a DDL query accepted `socket`. The connection pool reads it for the source and for every <replica> (a replica without its own inherits the source's, Pool.cpp:78-80), and the MariaDB connector uses a Unix socket whenever the host is empty or `localhost`, ignoring the port. The only destination check for such a dictionary, RemoteHostFilter::checkHostAndPort, sees `host` and `port` only, so with `localhost:3306` in remote_url_allow_hosts a user allowed to create a dictionary could make the server connect to any local socket path. Reject `socket` for DDL-created dictionaries the same way checkNoSSLPaths rejects the SSL paths, as requested in the review of ClickHouse#109736: a presence check at the source prefix next to checkNoSSLPaths, before the named-collection branch is chosen (so it also covers the value a replica inherits and a `socket` given next to `NAME`), and at each <replica> prefix. Configuration-file dictionaries keep `socket`. The replica call is placed between checkNoSSLPaths and checkNoLocalInfile so it does not touch the lines ClickHouse#109736 changes. `HOST 'localhost'` without `socket` still goes to the connector's default socket; that path is fixed by the build, not chosen by the query. The embedded documentation drops the DDL socket example and says the key is only accepted in a configuration file. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding; 2 full passes: 1 finding on the first, 0 on the second after the fix).
Severity: ❌ blocker / |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20261026-144100 |
|
cc @vdimir @evillique, could you review this and add the |
|
Workflow [PR], commit [f4bb39a] Summary: ❌
AI ReviewSummaryThis PR rejects explicit Missing context / blind spots
Final VerdictStatus: ✅ Approve. No additional code changes requested. |
CI finish ledger - 7f9fc23Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The first run of this head stopped at Session id: cron:our-pr-ci-monitor:20261027-203012 |
For `localhost` the MariaDB connector uses a Unix socket and ignores the port: its default one (`/tmp/mysql.sock`, or `MYSQL_UNIX_PORT`) when no socket is passed. So a dictionary created with a DDL query and `HOST 'localhost'` still did not go to the `host`:`port` that `remote_url_allow_hosts` checks, with or without a named collection. Add `force_tcp` to `mysqlxx::Connection::connect`, which sets `MYSQL_OPT_PROTOCOL = MYSQL_PROTOCOL_TCP`, and pass it through `Pool`, `PoolWithFailover`, `PoolFactory::get` and `createMySQLPoolWithFailover`. The MySQL dictionary source sets it for DDL-created dictionaries only; configuration-file dictionaries, the `mysql` table function and the `MySQL` engines keep their current behaviour. `force_tcp` is part of the key of a shared pool, so a DDL dictionary never shares a pool with a configuration-file dictionary that uses the default socket. Rename the test to 05229, next to 05229_mysql_dictionary_enable_local_infile, as asked in review, and make its last arm check that `HOST 'localhost'` without `socket` fails with a TCP error for `localhost`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
socket only in the configuration filesocket only in the configuration file, connect over TCP for DDL dictionaries
… for DDL dictionaries mariadb-connector-c gives two characters in `host` a meaning of its own in `mysql_real_connect` (mariadb_lib.c): - `;` or `=`: the host is parsed as a connection string, whose options are applied after the ones `mysqlxx::Connection` sets. So a DDL dictionary with `HOST 'host=localhost;protocol=2;socket=/path/x.sock'` overrode the forced TCP protocol and connected to a Unix socket of its choosing, with no `socket` key for `checkNoSocket` to reject. The same string can set `local-infile` and SSL file paths, which the other DDL guards reject as keys. - `,`: the host is a failover list of `host:port`. With a `remote_url_allow_hosts` regexp such as `.*\.allowed\.example`, `HOST '127.0.0.1:20255,x.allowed.example'` matched the regexp as one string and then connected to `127.0.0.1:20255`, which is not allowed. Reject hosts containing any of the three for DDL-created dictionaries at every place the host is checked against `remote_url_allow_hosts`: the source, each replica and the named-collection addresses. No valid host name contains them. Dictionaries defined in configuration files are unchanged. The test also gains no-socket `localhost` controls at a replica and with a named collection, which reach the default Unix socket without TCP forcing on those paths. Reported by the AI review of the PR (r4405080282) and the second-model review. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units9 translation units recompiled, 17 s compile time in total, 9 of them have a recent master baseline. |
CI finish ledger - bbfc810Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
praktika dropped 72 later jobs because of the first row, so they did not run on this head. Session id: cron:our-pr-ci-monitor:20261028-223002 |
|
@groeneai please check the ci result. |
…ct-socket Resolves the conflict with ClickHouse#129139 in the embedded MySQL dictionary source docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ClickHouse#129139 made every MySQL connection without an explicit `socket` use TCP, including `localhost`, and made every MySQL connection reject hosts that the client library reads as a connection string or a list of hosts. That covers the `force_tcp` flag and the dictionary-only host check of this PR, so both are removed and the mysqlxx and MySQLHelpers files are back to master. What remains is rejecting `socket` in a dictionary created with a DDL query, at the source and at each replica. 05229_mysql_dictionary_socket keeps the `socket` cases and one TCP control. The dictionary cases of 05493_mysql_host_connector_syntax set `SOCKET` in a DDL dictionary, so they now check port 0 without `socket`; a dictionary with `socket` and port 0 is only reachable from a server configuration file. Co-Authored-By: Claude Opus 5.5 <[email protected]>
socket only in the configuration file, connect over TCP for DDL dictionariessocket only in the configuration file
|
I checked it. On The PR also conflicted with master after #129139. That PR already makes MySQL connections without Locally |
…entries of configuration-file ones With `share_connection`, `PoolFactory::get` returns a cached pool keyed by `getPoolEntryName`, which joins the configuration fields without framing. The DDL checks (`socket`, `ssl_*` paths, `enable_local_infile`, the host filter) only see the keys of the `CREATE DICTIONARY` query, so a DDL source whose key matched a pool created from a configuration file got that pool, including its configured socket. On bbfc810 the `force_tcp` suffix kept the keys apart; it went away with ClickHouse#129139. `getPoolEntryName` now takes `created_from_ddl` and appends a marker for DDL-created sources, so their keys never equal a configuration-file key. The dictionary source passes it through `PoolFactory::get`. Covered by a new case in `gtest_pool_entry_name.cpp` (same configuration, different origin, different key). Also drop the `MySQL socket` alternative from the 05493 grep: the DDL dictionary cases there no longer set `SOCKET`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - f4bb39aEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261113-083007 |
|
Fixing PR for |
Related: #109736
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A MySQL dictionary source created with a
CREATE DICTIONARYquery can no longer setsocket, at the source or at one of itsREPLICAentries (BAD_ARGUMENTS): forlocalhostthe connection went to that Unix socket, whileremote_url_allow_hostschecks onlyhostandport. To keep using a Unix socket, define the dictionary in a server configuration file.Description
Follow-up to @ serxa's review point on #109736 (#109736 (comment)).
For
localhostthe MySQL connector uses the configured Unix socket and ignores the port: thesocketof the source or of a<replica>(a replica inherits the source's). The only destination check,RemoteHostFilter::checkHostAndPort, sees justhostandport, so withlocalhost:3306inremote_url_allow_hostsa dictionary creator could make the server connect to any local socket.Change.
checkNoSocketrejectssocketin a DDL-created dictionary at the source (also the value a replica inherits and asocketnext toNAME) and at each<replica>, likecheckNoSSLPaths. Configuration-file dictionaries are unchanged. Withshare_connection, a DDL-created source no longer reuses a cached pool created from a configuration file (the DDL checks see only the query's keys):getPoolEntryNamemarks the key of a DDL-created source. #129139 already makes a connection withoutsocketuse TCP, also forlocalhost, and rejects connection-string and host-list hosts for every MySQL connection, so this PR no longer changes those. The dictionary cases of05493_mysql_host_connector_syntaxsetSOCKETin a DDL dictionary, so they now check port 0 without it.Validation.
05229_mysql_dictionary_socketcoverssocketat the source, inherited by a replica, at a replica and next to a named collection, plusHOST 'localhost'withoutsocketfailing with a TCP error. It fails on master (the source is accepted and a connection is attempted,ALL_CONNECTION_TRIES_FAILED) and passes 50/50 with randomized settings, as does05493.gtest_pool_entry_namechecks that the same configuration gets different keys for the two origins.Workflow [PR]
Sync PR [sync-upstream/pr/127853]