ClickHouse/base/mysqlxx
Azat Khuzhin ed70ed6f71 Introduce connection_no_wait setting for MySQL engine.
This will allow to avoid superfluous sleep during query execution, since
this not only not desired behavoiur, but also may hang the server, since
if you will execute enough queries that will use MySQL database but will
not allow enough connections (or your MySQL server is too slow) then you
may run out of threads in the global thread pool.

Also note that right now it is possible to get deadlock when the mysql
pool is full, consider the following scenario:

- you have m1 and m2 mysql tables
- you have q1 and q2 queries, bot queries join m1 and m2
- q1 allocated connection for m1 but cannot allocate connection for m2
- q2 allocated connection for m2 but cannot allocate connection for m1
- but to resolve the lock one should give up on the locking while it is not possible right now...

And then you got no free threads and this:

    # grep -h ^202 /proc/$(pgrep clickhouse-serv)/task/*/syscall  | cut -d' ' -f2 | sort | uniq -c | sort -nr | head
       1554 0x7ffb60b92fe8 # mutex in mysqlxx::PoolWithFailover::get
       1375 0x7ffb9f1c4748 # mutex in ::PoolEntryHelper::~PoolEntryHelper from DB::MultiplexedConnections::invalidateReplica
       1160 0x7ffb612918b8 # mutex in mysqlxx::PoolWithFailover::get
         42 0x7ffb9f057984 # mutex in ThreadPoolImpl<std::__1::thread>::worker

    *NOTE: 202 is a `futex` with WAIT*

(Went with `syscall` because debugging 10k+ threads is not easy, and
eventually it may TRAP)
2021-09-02 22:23:37 +03:00
..
tests Build fixes 2021-03-16 14:07:53 +03:00
CMakeLists.txt Maybe better support for paths with whitespaces 2021-04-24 22:47:52 +03:00
Connection.cpp Added "opt_reconnect" parameter to config for controlling MYSQL_OPT_RECONNECT option (#19998) 2021-02-26 09:49:49 +03:00
Connection.h Added "opt_reconnect" parameter to config for controlling MYSQL_OPT_RECONNECT option (#19998) 2021-02-26 09:49:49 +03:00
Exception.cpp Enable extra warnings for base, utils, programs 2020-05-10 01:59:34 +03:00
Exception.h MySQL dictionary source: A mechanism for retrying unexpected connection loss during communication with mysql server (#21237) 2021-02-27 11:18:28 +03:00
mysqlxx.h Fix typos, the last 1% 2020-08-08 04:21:04 +03:00
Null.h Enable extra warnings for base, utils, programs 2020-05-10 01:59:34 +03:00
Pool.cpp Introduce connection_no_wait setting for MySQL engine. 2021-09-02 22:23:37 +03:00
Pool.h Introduce connection_no_wait setting for MySQL engine. 2021-09-02 22:23:37 +03:00
PoolFactory.cpp Clang Tidy, part 7 (#9799) 2020-03-23 05:12:31 +03:00
PoolFactory.h Clang Tidy, part 7 (#9799) 2020-03-23 05:12:31 +03:00
PoolWithFailover.cpp Introduce connection_no_wait setting for MySQL engine. 2021-09-02 22:23:37 +03:00
PoolWithFailover.h Introduce connection_no_wait setting for MySQL engine. 2021-09-02 22:23:37 +03:00
Query.cpp METR-41529 2021-06-21 22:31:42 +03:00
Query.h Fix some of the issues found by Coverity 2021-02-02 22:07:23 +03:00
ResultBase.cpp ISSUES-16835 try fix review comment 2020-12-09 16:19:09 +08:00
ResultBase.h Fix some of the issues found by Coverity 2021-02-02 22:07:23 +03:00
Row.cpp ISSUES-16835 try fix review comment 2020-12-09 16:19:09 +08:00
Row.h Fix some of the issues found by Coverity 2021-02-02 22:07:23 +03:00
Transaction.h Move FastMemcpy to contribs (#9219) 2020-03-13 01:26:16 +03:00
Types.h Move FastMemcpy to contribs (#9219) 2020-03-13 01:26:16 +03:00
UseQueryResult.cpp Move FastMemcpy to contribs (#9219) 2020-03-13 01:26:16 +03:00
UseQueryResult.h Fix some of the issues found by Coverity 2021-02-02 22:07:23 +03:00
Value.cpp Clang Tidy, part 7 (#9799) 2020-03-23 05:12:31 +03:00
Value.h Fix some of the issues found by Coverity 2021-02-02 22:07:23 +03:00
ya.make METR-41529 2021-06-21 22:31:42 +03:00
ya.make.in METR-41529 2021-06-21 22:31:42 +03:00