MySQLRouter - Too many open files

Hi,

I’m testing with MySqlRouter and I’m getting the error:

I am testing with 1000 threads.

The error does not occur when I perform the test directly on the Primary or Secondary nodes.

2024-09-01 16:04:02 metadata_cache INFO [7fa31c2756c0] Using unreachable_quorum_allowed_traffic=‘none’
2024-09-01 16:04:02 metadata_cache INFO [7fa31c2756c0] Using read_only_targets=‘secondaries’
2024-09-01 16:04:02 metadata_cache INFO [7fa31c2756c0] Potential changes detected in cluster after metadata refresh (view_id=0)
2024-09-01 16:04:02 metadata_cache INFO [7fa31c2756c0] Metadata for cluster ‘myCluster’ has 3 member(s), single-primary:
2024-09-01 16:04:02 metadata_cache INFO [7fa31c2756c0] cluster01:24801 / 33060 - mode=RW
2024-09-01 16:04:02 metadata_cache INFO [7fa31c2756c0] cluster02:24802 / 33060 - mode=RO
2024-09-01 16:04:02 metadata_cache INFO [7fa31c2756c0] cluster03:24803 / 33060 - mode=RO

2024-09-01 16:04:14 routing INFO [7fa3152006c0] Stop accepting connections for routing routing:bootstrap_rw listening on 0.0.0.0:6446
2024-09-01 16:04:14 routing ERROR [7fa3152006c0] [routing:bootstrap_rw_split] connecting to backend(s) for client from 10.10.10.20:37810 failed: connect(/* cluster02 /): ignored, connect(/ cluster03 /): ignored, resolve(cluster01) failed after 0ms: Too many open files, end of destinations: no more destinations
2024-09-01 16:04:14 routing INFO [7fa3152006c0] Stop accepting connections for routing routing:bootstrap_rw_split listening on 0.0.0.0:6450
2024-09-01 16:04:14 routing ERROR [7fa313e006c0] [routing:bootstrap_rw_split] connecting to backend(s) for client from 10.10.10.20:37828 failed: connect(/
cluster02 /): ignored, connect(/ cluster03 /): ignored, connect(/ cluster01:24801 /): is quarantined, end of destinations: no more destinations
2024-09-01 16:04:14 routing ERROR [7fa3134006c0] [routing:bootstrap_rw_split] connecting to backend(s) for client from 10.10.10.20:37842 failed: connect(/
cluster03 /): ignored, connect(/ cluster02 /): ignored, connect(/ cluster01:24801 */): is quarantined, end of destinations: no more destinations
2024-09-01 16:04:14 routing INFO [7fa309e006c0] Start accepting connections for routing routing:bootstrap_rw_split listening on ‘0.0.0.0:6450’
2024-09-01 16:04:14 routing INFO [7fa309e006c0] Start accepting connections for routing routing:bootstrap_rw listening on ‘0.0.0.0:6446’
2024-09-01 16:04:14 routing WARNING [7fa309e006c0] accepting new connection failed at accept(): generic:24, Too many open files

2024-09-01 16:04:14 routing WARNING [7fa309e006c0] accepting new connection failed at accept(): generic:24, Too many open files

System data:

MySQL 8.4.2
Ubuntu: 24.04 LTS
MySQL Router Ver 8.4.2

/etc/security/limits.conf

  • soft nproc 831072
  • hard nproc 831072
  • soft nofile 831072
  • hard nofile 831072

fs.file-max = 9223372036854775807

Have you searched https://bugs.mysql.com/ for anything similar? I would make the nofile unlimited for the user account that mysqlrouter is running under.

Then, I would look at ProxySQL, as it is more performant, and offers far, far more features than MySQL Router.

Hi matthewb,

Yes I tested ProxySQL, but I found mysqlrouter to be better.

I set the mysqlrouter user to unlimited and the error still persists.
The tests I’m doing don’t make me feel very confident about using INNODB CLUSTER.

Hi,

I’m testing proxySQL with sysbench and it’s not distributing SELECTS between nodes.

defines all the MySQL servers

mysql_servers =
(
{ address=“cluster01” , port=24801 , hostgroup=0, max_connections=3000 },
{ address=“cluster02” , port=24802 , hostgroup=1, max_connections=3000 },
{ address=“cluster03” , port=24803 , hostgroup=1, max_connections=3000 },
)

#defines MySQL Query Rules
mysql_query_rules:
(
{
rule_id=1
active=1
match_pattern=“^SELECT .* FOR UPDATE$”
destination_hostgroup=0
apply=1
},
{
rule_id=2
active=1
match_pattern=“^SELECT”
destination_hostgroup=1
apply=1
}
)

sysbench /usr/share/sysbench/tpcc.lua --threads=512 --tables=10 --scale=100 --time=300 --db-driver=mysql --mysql-host=cluster01 --mysql-db=sbtest --mysql-user=cluster --mysql-password=<> --mysql-port=6033 run

ProxySQL Admin>SELECT * FROM stats.stats_mysql_connection_pool\G;
*************************** 1. row ***************************
hostgroup: 0
srv_host: cluster01
srv_port: 24801
status: ONLINE
ConnUsed: 0
ConnFree: 300
ConnOK: 512
ConnERR: 0
MaxConnUsed: 512
Queries: 754731
Queries_GTID_sync: 0
Bytes_data_sent: 127178273
Bytes_data_recv: 22342461
Latency_us: 170
*************************** 2. row ***************************
hostgroup: 1
srv_host: cluster02
srv_port: 24802
status: ONLINE
ConnUsed: 0
ConnFree: 0
ConnOK: 0
ConnERR: 0
MaxConnUsed: 0
Queries: 0
Queries_GTID_sync: 0
Bytes_data_sent: 0
Bytes_data_recv: 0
Latency_us: 426
*************************** 3. row ***************************
hostgroup: 1
srv_host: cluster03
srv_port: 24803
status: ONLINE
ConnUsed: 0
ConnFree: 0
ConnOK: 0
ConnERR: 0
MaxConnUsed: 0
Queries: 0
Queries_GTID_sync: 0
Bytes_data_sent: 0
Bytes_data_recv: 0
Latency_us: 382
3 rows in set (0.01 sec)

“InnoDB Cluster” is just Oracle’s marketing term for “Group Replication + Router”. You can use Group Replication without router.

For our reasoning on ProxySQL over mysqlrouter:

Personally, the #1 issue I have with router is that you must rewrite your application to do R/W splitting. Whereas using ProxySQL does not require any modifications to application code.

Have you checked the runtime_mysql_query_rules table to ensure the rules have been loaded?

Additionally, ProxySQL will not split/multiplex connections within the same transaction. SELECT queries cannot be sent to different hosts while inside the same transaction with UPDATE/DELETE. You need to disable transactions on sysbench in order to see the splitting.

SELECT queries inside a trx would be considered “critical reads” and need to see the most up to date data, which would be the data potentially changed within the trx. To split non-critical reads, they need to be outside of the transaction.

Hi @matthewb

Thank you very much for the clarifications.

Hi @matthewb ,

Even with proxySQL distributing the reading, the cluster had no advantage in directly accessing the main server without going through the proxy.

I used the ProxySQL cache but it didn’t improve the result

I used the percona tpcc.lua test with 1k threads.

Result ProxySQL:

SQL statistics:
queries performed:
read: 4424153
write: 4591649
other: 342508
total: 9358310
transactions: 340972 (1133.29 per sec.)
queries: 9358310 (31104.18 per sec.)
ignored errors: 1537 (5.11 per sec.)
reconnects: 0 (0.00 per sec.)

General statistics:
total time: 300.8683s
total number of events: 340972

Latency (ms):
min: 2.33
avg: 451.16
max: 6799.78
95th percentile: 1069.86
sum: 153832604.70

Threads fairness:
events (avg/stddev): 665.9609/75.72
execution time (avg/stddev): 300.4543/0.28

Directly in MySQL using 1 node:

SQL statistics:
queries performed:
read: 4551487
write: 4726423
other: 351818
total: 9629728
transactions: 350282 (1165.01 per sec.)
queries: 9629728 (32027.71 per sec.)
ignored errors: 1503 (5.00 per sec.)
reconnects: 0 (0.00 per sec.)

General statistics:
total time: 300.6671s
total number of events: 350282

Latency (ms):
min: 2.24
avg: 438.55
max: 5477.95
95th percentile: 995.51
sum: 153617884.71

Threads fairness:
events (avg/stddev): 684.1445/21.99
execution time (avg/stddev): 300.0349/0.34