Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Reusing connection #1554

mtrekker started this conversation in General
Mar 12, 2025 · 1 comments · 3 replies
Discussion options

  1. What is the proper code usage to benefit from connection reuse ? Perhaps creating unit test ?
  2. There seems to be an issue with charset statements because quite often 2 queries are being sent to the server:
2025年03月12日T15:35:34.088403+02:00	 1957 Connect	test@localhost on performance_mon using SSL/TLS
2025年03月12日T15:35:34.089155+02:00	 1957 Query	SET NAMES utf8mb4
2025年03月12日T15:35:34.097924+02:00	 1957 Query	SET NAMES utf8mb4

I am seeing multiple "Connect" events in the MySQL general log even if using the following config:

ConnectionLifeTime=0;Min Pool Size=0;Max Pool Size=100;Pooling=true

This approach does not create new "Connect" event:

using (MySqlConnection connection = new MySqlConnection(_connectionString)) 
{
 await connection.OpenAsync();
 // do whatever needed
}

But this approach will create "Connect" event each time:

_dataSource = new MySqlDataSourceBuilder(_connectionString).
 UseLoggerFactory(_logger)
 .Build();
using (MySqlConnection connection = await _dataSource.OpenConnectionAsync())
{
 // do whatever needed
}
2025年03月12日T15:35:38.653244+02:00	 1967 Connect	test@localhost on performance_mon using SSL/TLS
2025年03月12日T15:35:38.653715+02:00	 1967 Query	SET NAMES utf8mb4
2025年03月12日T15:35:38.658850+02:00	 1967 Query	SET NAMES utf8mb4
2025年03月12日T15:35:38.667228+02:00	 1967 Query	INSERT INTO foo SET `field` = 0
You must be logged in to vote

Replies: 1 comment 3 replies

Comment options

Any comments ? @bgrainger

You must be logged in to vote
3 replies
Comment options

I would need a self-contained repro of the problem in order to comment accurately on this issue.

Comment options

If you enable "Trace"-level logging and upload a full log file, that may provide enough information to diagnose the issue. (MySqlConnector will log all statements it sends.)

Comment options

It may take me some time to provide self-contained example. Standard examples work fine...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /