Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Version 13.2.0 connection use issue - System.InvalidOperationException: This MySqlConnection is already in use #12024


User avatar
0
slamj1 created

Angular + ASP.NET Core version 8.0 ANZ version 13.2.0

Greetings;

We have upgraded to version 13.2.0 from 13.1.1 and are now encountering backend connection errors immediately on startup:

ERROR 2024-05-24 22:33:40,227 [14 ] oft.EntityFrameworkCore.Database.Command - Failed executing DbCommand (2ms) [Parameters=[@__Now_0='?' (DbType = DateTime), @__p_1='?' (DbType = Int32)], CommandType='Text', CommandTimeout='300'] SELECT a.Id, a.CreationTime, a.CreatorUserId, a.IsAbandoned, a.JobArgs, a.JobType, a.LastTryTime, a.NextTryTime, a.Priority, a.TryCount FROM AbpBackgroundJobs AS a WHERE NOT (a.IsAbandoned) AND (a.NextTryTime <= @__Now_0) ORDER BY a.Priority DESC, a.TryCount, a.NextTryTime LIMIT @__p_1 ERROR 2024-05-24 22:33:40,263 [14 ] Microsoft.EntityFrameworkCore.Query - An exception occurred while iterating over the results of a query for context type 'LSSPortal.EntityFrameworkCore.LSSPortalDbContext'. System.InvalidOperationException: This MySqlConnection is already in use. See https://fl.vu/mysql-conn-reuse at MySqlConnector.Core.ServerSession.StartQuerying(ICancellableCommand command) in //src/MySqlConnector/Core/ServerSession.cs:line 288 at MySqlConnector.Core.CommandExecutor.ExecuteReaderAsync(CommandListPosition commandListPosition, ICommandPayloadCreator payloadCreator, CommandBehavior behavior, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) at MySqlConnector.MySqlCommand.ExecuteReaderAsync(CommandBehavior behavior, IOBehavior ioBehavior, CancellationToken cancellationToken) in //src/MySqlConnector/MySqlCommand.cs:line 357 at MySqlConnector.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior) in /_/src/MySqlConnector/MySqlCommand.cs:line 290 at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.Enumerator.InitializeReader(Enumerator enumerator) at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.Enumerator.MoveNext()

Note, these repeat over a few minutes and then exhaust the connection pool, rendering the backend non-functional. This appears to start with the Background job system.

We have not upgraded any MySql components and this is NOT an issue on version 13.1.1. This upgrade from 13.1.1 to 13.2.0 was quite easy relative to past upgrades and we've done many. Although we are using MySql (have been for years), this would likely happen with the SQL provider as well, although I have not tested that.

I'll continue to look in to this as time permits, but I thought it should be reported as this release is quite new.

Sam.


3 Answer(s)
  • User Avatar
    0
    slamj1 created

    Additional information from my testing:

    Disabling the Backgound job system entirely using IsJobExecutionEnabled=false, stops the issue described above, so it's very likely something was introduced since 13.1.1 that affects the Background job processing / database connection use.

    Thanks, Sam.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Please follow https://github.com/aspnetboilerplate/aspnetboilerplate/issues/6950, we will fix this issue and release a new version as soon as possible.

  • User Avatar
    0
    slamj1 created

    Thanks @ismcagdas