sysown / proxysql

High-performance MySQL proxy with a GPL license.
http://www.proxysql.com
GNU General Public License v3.0
6.05k stars 983 forks source link

The established connection did not execute the avoidance policy #4639

Open zhaozhiguang opened 2 months ago

zhaozhiguang commented 2 months ago

version:2.6.3 mode:mysql group replication system:centos8

I am using Hikari connection pool and JDBC template to query data (select count (*) from table) for lag data validation. I found that lagging data can be queried, but I directly changed to using JDBC's driverManager.getConnection() retrieves new connections and executes the same query data each time

problem analysis Connection pool (such as HikariCP): A connection pool establishes and maintains a certain number of database connections in advance. These connections were already directed to specific MySQL server instances at the time of creation. If ProxySQL detects a delay in a server instance and decides not to route new queries to that instance, but established connections still point to that instance, queries executed through these connections may still return old data. Driver Manager: Every time a connection is obtained through Driver Manager, a new connection is established. If ProxySQL has updated its routing rules based on the state of MGR, new connections will follow these rules, making it more likely to connect to the server instance with the latest data.

expect The established connection should also implement the backend MySQL server replication lag avoidance strategy