fix: disable prefer_socket in mysql_async to fix StarRocks connection after upgrade

Newer StarRocks versions reject the @@socket system variable that
mysql_async queries during connection initialization when prefer_socket
is enabled (default on non-Windows). Since we always use TCP connections,
Unix socket detection is unnecessary.
This commit is contained in:
t8y2 2026-05-25 14:12:55 +08:00
parent 4fa363b1a9
commit d973fb78c1
1 changed files with 2 additions and 1 deletions

View File

@ -188,7 +188,8 @@ fn create_pool(url: &str) -> Result<MySqlPool, String> {
let pool_opts = mysql_async::PoolOpts::new()
.with_constraints(mysql_async::PoolConstraints::new(1, 5).unwrap())
.with_inactive_connection_ttl(Duration::from_secs(300));
let builder = mysql_async::OptsBuilder::from_opts(opts).stmt_cache_size(0).pool_opts(Some(pool_opts));
let builder =
mysql_async::OptsBuilder::from_opts(opts).stmt_cache_size(0).prefer_socket(false).pool_opts(Some(pool_opts));
Ok(MySqlPool::new(builder))
}