10000 When using Connection Pooling, it is not possible to send a Validation Query. · Issue #1474 · mysql-net/MySqlConnector · GitHub
[go: up one dir, main page]

Skip to content
When using Connection Pooling, it is not possible to send a Validation Query. #1474
Closed as not planned
@ikpil

Description

@ikpil

Software versions
MySqlConnector version: 2.3.7
Server type (MySQL, MariaDB, Aurora, etc.) and version: MySql 8.0.3
.NET version: .net 8.0
(Optional) ORM NuGet packages and versions: Dapper 2.1.44

Describe the bug
We are using the ConnectionPool feature.
We are maintaining three sessions.

However, the Validation Query(SELECT 1) should be used by all three sessions, but due to pooling, it cannot be used in the remaining two sessions.

As a result of this issue, sessions keep getting disconnected due to the wait_timeout.
How can we send the Validation Query to all sessions?

Exception
Full exception message and call stack (if applicable)

System.Net.Sockets.SocketException (10053): 현재 연결은 사용자의 호스트 시스템의 소프트웨어의 의해 중단되었습니다.
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.CreateException(SocketError error, Boolean forAsyncThrow)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.SendAsync(Socket socket, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.SendAsync(ReadOnlyMemory`1 buffer, SocketFlags socketFlags, CancellationToken cancellationToken)
   at MySqlConnector.Protocol.Serialization.SocketByteHandler.DoWriteBytesAsync(ReadOnlyMemory`1 data) in /_/src/MySqlConnector/Protocol/Serialization/SocketByteHandler.cs:line 133
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at MySqlConnector.Protocol.Serialization.SocketByteHandler.DoWriteBytesAsync(ReadOnlyMemory`1 data)
   at MySqlConnector.Protocol.Serialization.SocketByteHandler.WriteBytesAsync(ReadOnlyMemory`1 data, IOBehavior ioBehavior) in /_/src/MySqlConnector/Protocol/Serialization/SocketByteHandler.cs:line 114
   at MySqlConnector.Core.ServerSession.TryResetConnectionAsync(ConnectionSettings cs, MySqlConnection connection, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ServerSession.cs:line 629
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at MySqlConnector.Core.ServerSession.TryResetConnectionAsync(ConnectionSettings cs, MySqlConnection connection, IOBehavior ioBehavior, CancellationToken cancellationToken)
   at MySqlConnector.Core.ConnectionPool.GetSessionAsync(MySqlConnection connection, Int32 startTickCount, Int32 timeoutMilliseconds, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ConnectionPool.cs:line 71
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at MySqlConnector.Core.ConnectionPool.GetSessionAsync(MySqlConnection connection, Int32 startTickCount, Int32 timeoutMilliseconds, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken)
   at MySqlConnector.MySqlConnection.CreateSessionAsync(ConnectionPool pool, Int32 startTickCount, Activity activity, Nullable`1 ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlConnection.cs:line 929
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at MySqlConnector.MySqlConnection.CreateSessionAsync(ConnectionPool pool, Int32 startTickCount, Activity activity, Nullable`1 ioBehavior, CancellationToken cancellationToken)
   at MySqlConnector.MySqlConnection.OpenAsync(Nullable`1 ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlConnection.cs:line 423
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at MySqlConnector.MySqlConnection.OpenAsync(Nullable`1 ioBehavior, CancellationToken cancellationToken)
   at MySqlConnector.MySqlConnection.OpenAsync(CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlConnection.cs:line 384
   at Dapper.SqlMapper.TryOpenAsync(IDbConnection cnn, CancellationToken cancel) in /_/Dapper/SqlMapper.Async.cs:line 399
   at Dapper.SqlMapper.QueryRowAsync[T](IDbConnection cnn, Row row, Type effectiveType, CommandDefinition command) in /_/Dapper/SqlMapper.Async.cs:line 488
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Dapper.SqlMapper.QueryRowAsync[T](IDbConnection cnn, Row row, Type effectiveType, CommandDefinition command)
   at Dapper.SqlMapper.QueryFirstOrDefaultAsync[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Nullable`1 commandTimeout, Nullable`1 commandType) in /_/Dapper/SqlMapper.Async.cs:line 119
   at Gemini.Food.Database.DbConnection.<>c__DisplayClass12_0`1.<SelectSingleAsync>b__0(MySqlConnection conn) in D:\workspace\src\Gemini.Food.Database\DbConnection.cs:line 72
   at Gemini.Food.Database.DbConnection.<>c__DisplayClass18_0`1.<ExecuteAsync>b__0(MySqlConnection conn) in D:\workspace\src\Gemini.Food.Database\DbConnection.cs:line 164
   at Gemini.Food.Database.DbExecutor.<>c__DisplayClass13_0`1.<ExecuteAsync>b__0() in D:\workspace\src\Gemini.Food.Database\DbExecutor.cs:line 171
   at Gemini.Food.Core.Threading.SingleThreadExecutor.<>c__DisplayClass9_0`1.<ExecuteAsync>b__0() in D:\workspace\src\Gemini.Food.Core\Threading\SingleThreadExecutor.cs:line 95
   at Gemini.Food.Core.Threading.SingleThreadExecutor.PollingInternal(TickThreadContext ctx) in D:\workspace\src\Gemini.Food.Core\Threading\SingleThreadExecutor.cs:line 142
   at Gemini.Food.Core.Threading.TickThreadContext.StartInternal() in D:\workspace\src\Gemini.Food.Core\Threading\TickThreadContext.cs:line 62
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task, ConfigureAwaitOptions options)

Code sample

        builder.Server = connStr.Host;
        builder.Port = (uint)connStr.Port;
        builder.Database = connStr.DbName;
        builder.UserID = connStr.UserName;
        builder.Password = connStr.UserPasswd;
        builder.SslMode = MySqlSslMode.Disabled;
        builder.Keepalive = 60; 
        builder.CharacterSet = "utf8mb4";
        builder.ConvertZeroDateTime = true;
        builder.AllowLoadLocalInfile = true;
        builder.AllowPublicKeyRetrieval = true;
        builder.Pooling = true;
        builder.MinimumPoolSize = 3;
        builder.MaximumPoolSize = 3
        builder.DnsCheckInterval = 5; 
.......



/* A concise code sample to reproduce the bug */
			// check for a waiting session
			lock (m_sessions)
			{
				if (m_sessions.Count > 0)
				{
					session = m_sessions.First!.Value; 
					m_sessions.RemoveFirst();  <------ like stack 
				}
			}

Expected behavior
A clear and concise description of what you expected to happen.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    waiting for answerNeeds more information from the bug reporter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0