Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL Unity TLS error #816

Closed
TheMrKan opened this issue Apr 23, 2024 · 6 comments · Fixed by #818
Closed

MySQL Unity TLS error #816

TheMrKan opened this issue Apr 23, 2024 · 6 comments · Fixed by #818

Comments

@TheMrKan
Copy link
Contributor

At one point all DB operations start falling with the following exception:

System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseMySql' call. ---> MySql.Data.MySqlClient.MySqlException: SSL Authentication Error ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> Mono.Security.Interface.TlsException: Handshake failed - error code: UNITYTLS_INTERNAL_ERROR, verify result: UNITYTLS_X509VERIFY_NOT_DONE

Only server restart brings the DB back to life

@TheMrKan
Copy link
Contributor Author

Full error log

[2024-03-31 21:03:41 ERR][OpenMod.Core.Eventing.EventBus] Exception occured during event PreparingPlayerStats
System.AggregateException: One or more errors occurred. (An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseMySql' call.) ---> System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseMySql' call. ---> MySql.Data.MySqlClient.MySqlException: SSL Authentication Error ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> Mono.Security.Interface.TlsException: Handshake failed - error code: UNITYTLS_INTERNAL_ERROR, verify result: UNITYTLS_X509VERIFY_NOT_DONE
  at Mono.Unity.Debug.CheckAndThrow (Mono.Unity.UnityTls+unitytls_errorstate errorState, Mono.Unity.UnityTls+unitytls_x509verify_result verifyResult, System.String context, Mono.Security.Interface.AlertDescription defaultAlert) [0x00036] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
  at Mono.Unity.UnityTlsContext.ProcessHandshake () [0x00082] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
  at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status, System.Boolean renegotiate) [0x000da] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
  at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus,bool)
  at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00006] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
  at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancellationToken) [0x000fc] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
   --- End of inner exception stack trace ---
  at Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication (System.Boolean runSynchronously, Mono.Net.Security.MonoSslAuthenticationOptions options, System.Threading.CancellationToken cancellationToken) [0x00262] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
  at MySqlConnector.Core.ServerSession.InitSslAsync (MySqlConnector.Protocol.ProtocolCapabilities serverCapabilities, MySqlConnector.Core.ConnectionSettings cs, System.Security.Authentication.SslProtocols sslProtocols, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x0086a] in /_/src/MySqlConnector/Core/ServerSession.cs:1316 
   --- End of inner exception stack trace ---
  at MySqlConnector.Core.ServerSession.InitSslAsync (MySqlConnector.Protocol.ProtocolCapabilities serverCapabilities, MySqlConnector.Core.ConnectionSettings cs, System.Security.Authentication.SslProtocols sslProtocols, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x009aa] in /_/src/MySqlConnector/Core/ServerSession.cs:1342 
  at MySqlConnector.Core.ServerSession.ConnectAsync (MySqlConnector.Core.ConnectionSettings cs, System.Int32 startTickCount, MySqlConnector.Core.ILoadBalancer loadBalancer, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x006eb] in /_/src/MySqlConnector/Core/ServerSession.cs:430 
  at MySqlConnector.Core.ConnectionPool.GetSessionAsync (MySql.Data.MySqlClient.MySqlConnection connection, System.Int32 startTickCount, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x005a3] in /_/src/MySqlConnector/Core/ConnectionPool.cs:111 
  at MySqlConnector.Core.ConnectionPool.GetSessionAsync (MySql.Data.MySqlClient.MySqlConnection connection, System.Int32 startTickCount, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x007e5] in /_/src/MySqlConnector/Core/ConnectionPool.cs:141 
  at MySql.Data.MySqlClient.MySqlConnection.CreateSessionAsync (MySqlConnector.Core.ConnectionPool pool, System.Int32 startTickCount, System.Nullable`1[T] ioBehavior, System.Threading.CancellationToken cancellationToken) [0x00120] in /_/src/MySqlConnector/MySql.Data.MySqlClient/MySqlConnection.cs:729 
  at MySql.Data.MySqlClient.MySqlConnection.OpenAsync (System.Nullable`1[T] ioBehavior, System.Threading.CancellationToken cancellationToken) [0x0016d] in /_/src/MySqlConnector/MySql.Data.MySqlClient/MySqlConnection.cs:404 
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync (System.Boolean errorsExpected, System.Threading.CancellationToken cancellationToken) [0x0012b] in <04749dad1c80429287c0de883da70092>:0 
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync (System.Boolean errorsExpected, System.Threading.CancellationToken cancellationToken) [0x00286] in <04749dad1c80429287c0de883da70092>:0 
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync (System.Threading.CancellationToken cancellationToken, System.Boolean errorsExpected) [0x0017b] in <04749dad1c80429287c0de883da70092>:0 
  at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlRelationalConnection.OpenAsync (System.Threading.CancellationToken cancellationToken, System.Boolean errorsExpected) [0x0007b] in <971e410b2fc64eaba9c11dae2dfe083d>:0 
  at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync (Microsoft.EntityFrameworkCore.Storage.RelationalCommandParameterObject parameterObject, System.Threading.CancellationToken cancellationToken) [0x000f8] in <04749dad1c80429287c0de883da70092>:0 
  at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1+AsyncEnumerator[T].InitializeReaderAsync (Microsoft.EntityFrameworkCore.DbContext _, System.Boolean result, System.Threading.CancellationToken cancellationToken) [0x000bd] in <04749dad1c80429287c0de883da70092>:0 
  at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlExecutionStrategy.ExecuteAsync[TState,TResult] (TState state, System.Func`4[T1,T2,T3,TResult] operation, System.Func`4[T1,T2,T3,TResult] verifySucceeded, System.Threading.CancellationToken cancellationToken) [0x00089] in <971e410b2fc64eaba9c11dae2dfe083d>:0 
   --- End of inner exception stack trace ---
  at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlExecutionStrategy.ExecuteAsync[TState,TResult] (TState state, System.Func`4[T1,T2,T3,TResult] operation, System.Func`4[T1,T2,T3,TResult] verifySucceeded, System.Threading.CancellationToken cancellationToken) [0x000c6] in <971e410b2fc64eaba9c11dae2dfe083d>:0 
  at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1+AsyncEnumerator[T].MoveNextAsync () [0x002fe] in <04749dad1c80429287c0de883da70092>:0 
  at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource] (System.Collections.Generic.IAsyncEnumerable`1[T] asyncEnumerable, System.Threading.CancellationToken cancellationToken) [0x0009e] in <25b3d70e4fdd45f7a2d848578491534a>:0 
  at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource] (System.Collections.Generic.IAsyncEnumerable`1[T] asyncEnumerable, System.Threading.CancellationToken cancellationToken) [0x001e7] in <25b3d70e4fdd45f7a2d848578491534a>:0 
  at UserDataStore.MySql.MySqlUserDataStore+<>c__DisplayClass9_0.<GetUserDataAsync>b__0 () [0x00219] in <e32d6f440e964af4ba89e67dac411743>:0 
  at UserDataStore.MySql.MySqlUserDataStore+<>c__DisplayClass9_0.<GetUserDataAsync>b__0 () [0x00305] in <e32d6f440e964af4ba89e67dac411743>:0 
   --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <47fc8c70fa834cbf8141d7c1a7589125>:0 
  at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <47fc8c70fa834cbf8141d7c1a7589125>:0 
  at System.Threading.Tasks.Task.Wait () [0x00000] in <47fc8c70fa834cbf8141d7c1a7589125>:0 
  at UserDataStore.MySql.MySqlUserDataStore.GetUserDataAsync (System.String userId, System.String userType) [0x000af] in <e32d6f440e964af4ba89e67dac411743>:0 
  at OpenMod.Core.Users.OfflineUserProvider.FindUserAsync (System.String userType, System.String searchString, OpenMod.API.Users.UserSearchMode searchMode) [0x00029] in /_/framework/OpenMod.Core/Users/OfflineUserProvider.cs:36 
  at OpenMod.Core.Users.UserManager.FindUserAsync (System.String userType, System.String searchString, OpenMod.API.Users.UserSearchMode searchMode) [0x000e0] in /_/framework/OpenMod.Core/Users/UserManager.cs:72 
  at BloodBoots.ReputationRanks.RanksManager.OnPreparingStats (System.IServiceProvider provider, System.Object sender, BloodBoots.PlayerDataStore.DataPreparation.Events.PreparingPlayerStatsEvent event) [0x00104] in <3eade5f5f7fd41e4b7b0e7fb2537c21c>:0 
  at OpenMod.Core.Eventing.EventBus.EmitAsync (OpenMod.API.IOpenModComponent component, System.Object sender, OpenMod.API.Eventing.IEvent event, OpenMod.API.Eventing.EventExecutedCallback callback) [0x0035a] in /_/framework/OpenMod.Core/Eventing/EventBus.cs:377 
---> (Inner Exception #0) System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseMySql' call. ---> MySql.Data.MySqlClient.MySqlException: SSL Authentication Error ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> Mono.Security.Interface.TlsException: Handshake failed - error code: UNITYTLS_INTERNAL_ERROR, verify result: UNITYTLS_X509VERIFY_NOT_DONE
  at Mono.Unity.Debug.CheckAndThrow (Mono.Unity.UnityTls+unitytls_errorstate errorState, Mono.Unity.UnityTls+unitytls_x509verify_result verifyResult, System.String context, Mono.Security.Interface.AlertDescription defaultAlert) [0x00036] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
  at Mono.Unity.UnityTlsContext.ProcessHandshake () [0x00082] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
  at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status, System.Boolean renegotiate) [0x000da] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
  at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus,bool)
  at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00006] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
  at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancellationToken) [0x000fc] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
   --- End of inner exception stack trace ---
  at Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication (System.Boolean runSynchronously, Mono.Net.Security.MonoSslAuthenticationOptions options, System.Threading.CancellationToken cancellationToken) [0x00262] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
  at MySqlConnector.Core.ServerSession.InitSslAsync (MySqlConnector.Protocol.ProtocolCapabilities serverCapabilities, MySqlConnector.Core.ConnectionSettings cs, System.Security.Authentication.SslProtocols sslProtocols, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x0086a] in /_/src/MySqlConnector/Core/ServerSession.cs:1316 
   --- End of inner exception stack trace ---
  at MySqlConnector.Core.ServerSession.InitSslAsync (MySqlConnector.Protocol.ProtocolCapabilities serverCapabilities, MySqlConnector.Core.ConnectionSettings cs, System.Security.Authentication.SslProtocols sslProtocols, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x009aa] in /_/src/MySqlConnector/Core/ServerSession.cs:1342 
  at MySqlConnector.Core.ServerSession.ConnectAsync (MySqlConnector.Core.ConnectionSettings cs, System.Int32 startTickCount, MySqlConnector.Core.ILoadBalancer loadBalancer, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x006eb] in /_/src/MySqlConnector/Core/ServerSession.cs:430 
  at MySqlConnector.Core.ConnectionPool.GetSessionAsync (MySql.Data.MySqlClient.MySqlConnection connection, System.Int32 startTickCount, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x005a3] in /_/src/MySqlConnector/Core/ConnectionPool.cs:111 
  at MySqlConnector.Core.ConnectionPool.GetSessionAsync (MySql.Data.MySqlClient.MySqlConnection connection, System.Int32 startTickCount, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x007e5] in /_/src/MySqlConnector/Core/ConnectionPool.cs:141 
  at MySql.Data.MySqlClient.MySqlConnection.CreateSessionAsync (MySqlConnector.Core.ConnectionPool pool, System.Int32 startTickCount, System.Nullable`1[T] ioBehavior, System.Threading.CancellationToken cancellationToken) [0x00120] in /_/src/MySqlConnector/MySql.Data.MySqlClient/MySqlConnection.cs:729 
  at MySql.Data.MySqlClient.MySqlConnection.OpenAsync (System.Nullable`1[T] ioBehavior, System.Threading.CancellationToken cancellationToken) [0x0016d] in /_/src/MySqlConnector/MySql.Data.MySqlClient/MySqlConnection.cs:404 
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync (System.Boolean errorsExpected, System.Threading.CancellationToken cancellationToken) [0x0012b] in <04749dad1c80429287c0de883da70092>:0 
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync (System.Boolean errorsExpected, System.Threading.CancellationToken cancellationToken) [0x00286] in <04749dad1c80429287c0de883da70092>:0 
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync (System.Threading.CancellationToken cancellationToken, System.Boolean errorsExpected) [0x0017b] in <04749dad1c80429287c0de883da70092>:0 
  at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlRelationalConnection.OpenAsync (System.Threading.CancellationToken cancellationToken, System.Boolean errorsExpected) [0x0007b] in <971e410b2fc64eaba9c11dae2dfe083d>:0 
  at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync (Microsoft.EntityFrameworkCore.Storage.RelationalCommandParameterObject parameterObject, System.Threading.CancellationToken cancellationToken) [0x000f8] in <04749dad1c80429287c0de883da70092>:0 
  at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1+AsyncEnumerator[T].InitializeReaderAsync (Microsoft.EntityFrameworkCore.DbContext _, System.Boolean result, System.Threading.CancellationToken cancellationToken) [0x000bd] in <04749dad1c80429287c0de883da70092>:0 
  at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlExecutionStrategy.ExecuteAsync[TState,TResult] (TState state, System.Func`4[T1,T2,T3,TResult] operation, System.Func`4[T1,T2,T3,TResult] verifySucceeded, System.Threading.CancellationToken cancellationToken) [0x00089] in <971e410b2fc64eaba9c11dae2dfe083d>:0 
   --- End of inner exception stack trace ---
  at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlExecutionStrategy.ExecuteAsync[TState,TResult] (TState state, System.Func`4[T1,T2,T3,TResult] operation, System.Func`4[T1,T2,T3,TResult] verifySucceeded, System.Threading.CancellationToken cancellationToken) [0x000c6] in <971e410b2fc64eaba9c11dae2dfe083d>:0 
  at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1+AsyncEnumerator[T].MoveNextAsync () [0x002fe] in <04749dad1c80429287c0de883da70092>:0 
  at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource] (System.Collections.Generic.IAsyncEnumerable`1[T] asyncEnumerable, System.Threading.CancellationToken cancellationToken) [0x0009e] in <25b3d70e4fdd45f7a2d848578491534a>:0 
  at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource] (System.Collections.Generic.IAsyncEnumerable`1[T] asyncEnumerable, System.Threading.CancellationToken cancellationToken) [0x001e7] in <25b3d70e4fdd45f7a2d848578491534a>:0 
  at UserDataStore.MySql.MySqlUserDataStore+<>c__DisplayClass9_0.<GetUserDataAsync>b__0 () [0x00219] in <e32d6f440e964af4ba89e67dac411743>:0 
  at UserDataStore.MySql.MySqlUserDataStore+<>c__DisplayClass9_0.<GetUserDataAsync>b__0 () [0x00305] in <e32d6f440e964af4ba89e67dac411743>:0 <---

@TheMrKan
Copy link
Contributor Author

Another one

[2024-04-18 00:07:26 ERR][OpenMod.Core.Plugins.PluginActivator] Failed to load plugin: BloodBoots.PlayerDataStore v0.1.0
MySql.Data.MySqlClient.MySqlException (0x80004005): SSL Authentication Error ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> Mono.Security.Interface.TlsException: Handshake failed - error code: UNITYTLS_INTERNAL_ERROR, verify result: UNITYTLS_X509VERIFY_NOT_DONE
  at Mono.Unity.Debug.CheckAndThrow (Mono.Unity.UnityTls+unitytls_errorstate errorState, Mono.Unity.UnityTls+unitytls_x509verify_result verifyResult, System.String context, Mono.Security.Interface.AlertDescription defaultAlert) [0x00036] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
  at Mono.Unity.UnityTlsContext.ProcessHandshake () [0x00082] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
  at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status, System.Boolean renegotiate) [0x000da] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
  at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus,bool)
  at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00006] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
  at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancellationToken) [0x000fc] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
   --- End of inner exception stack trace ---
  at Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication (System.Boolean runSynchronously, Mono.Net.Security.MonoSslAuthenticationOptions options, System.Threading.CancellationToken cancellationToken) [0x00262] in <647615f3c1e6423a897a1a8f71c1fd3c>:0 
  at MySqlConnector.Core.ServerSession.InitSslAsync (MySqlConnector.Protocol.ProtocolCapabilities serverCapabilities, MySqlConnector.Core.ConnectionSettings cs, System.Security.Authentication.SslProtocols sslProtocols, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x0086a] in /_/src/MySqlConnector/Core/ServerSession.cs:1316 
  at MySqlConnector.Core.ServerSession.InitSslAsync (MySqlConnector.Protocol.ProtocolCapabilities serverCapabilities, MySqlConnector.Core.ConnectionSettings cs, System.Security.Authentication.SslProtocols sslProtocols, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x009aa] in /_/src/MySqlConnector/Core/ServerSession.cs:1342 
  at MySqlConnector.Core.ServerSession.ConnectAsync (MySqlConnector.Core.ConnectionSettings cs, System.Int32 startTickCount, MySqlConnector.Core.ILoadBalancer loadBalancer, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x006eb] in /_/src/MySqlConnector/Core/ServerSession.cs:430 
  at MySqlConnector.Core.ConnectionPool.GetSessionAsync (MySql.Data.MySqlClient.MySqlConnection connection, System.Int32 startTickCount, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x005a3] in /_/src/MySqlConnector/Core/ConnectionPool.cs:111 
  at MySqlConnector.Core.ConnectionPool.GetSessionAsync (MySql.Data.MySqlClient.MySqlConnection connection, System.Int32 startTickCount, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x007e5] in /_/src/MySqlConnector/Core/ConnectionPool.cs:141 
  at MySql.Data.MySqlClient.MySqlConnection.CreateSessionAsync (MySqlConnector.Core.ConnectionPool pool, System.Int32 startTickCount, System.Nullable`1[T] ioBehavior, System.Threading.CancellationToken cancellationToken) [0x00120] in /_/src/MySqlConnector/MySql.Data.MySqlClient/MySqlConnection.cs:729 
  at MySql.Data.MySqlClient.MySqlConnection.OpenAsync (System.Nullable`1[T] ioBehavior, System.Threading.CancellationToken cancellationToken) [0x0016d] in /_/src/MySqlConnector/MySql.Data.MySqlClient/MySqlConnection.cs:404 
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync (System.Boolean errorsExpected, System.Threading.CancellationToken cancellationToken) [0x0012b] in <04749dad1c80429287c0de883da70092>:0 
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync (System.Boolean errorsExpected, System.Threading.CancellationToken cancellationToken) [0x00286] in <04749dad1c80429287c0de883da70092>:0 
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync (System.Threading.CancellationToken cancellationToken, System.Boolean errorsExpected) [0x0017b] in <04749dad1c80429287c0de883da70092>:0 
  at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlRelationalConnection.OpenAsync (System.Threading.CancellationToken cancellationToken, System.Boolean errorsExpected) [0x0007b] in <971e410b2fc64eaba9c11dae2dfe083d>:0 
  at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteScalarAsync (Microsoft.EntityFrameworkCore.Storage.RelationalCommandParameterObject parameterObject, System.Threading.CancellationToken cancellationToken) [0x000f0] in <04749dad1c80429287c0de883da70092>:0 
  at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.ExistsAsync (System.Threading.CancellationToken cancellationToken) [0x00129] in <04749dad1c80429287c0de883da70092>:0 
  at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.MigrateAsync (System.String targetMigration, System.Threading.CancellationToken cancellationToken) [0x0009d] in <04749dad1c80429287c0de883da70092>:0 
  at BloodBoots.PlayerDataStore.PlayerDataStorePlugin.OnLoadAsync () [0x0007a] in <4cc9ca7bb090444d901946a387d6b27a>:0 
  at Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`1[TStateMachine].GetResult (System.Int16 token) [0x00000] in <b570aeb885074593be3f1a2137ad3fbd>:0 
  at OpenMod.UnityEngine.Plugins.OpenModUnityEnginePlugin.LoadAsync () [0x00116] in /_/unityengine/OpenMod.UnityEngine/Plugins/OpenModUnityEnginePlugin.cs:32 
  at OpenMod.Core.Plugins.PluginActivator.TryActivatePluginAsync (System.Reflection.Assembly assembly) [0x0051c] in /_/framework/OpenMod.Core/Plugins/PluginActivator.cs:262 

@rube200
Copy link
Contributor

rube200 commented Apr 23, 2024

@sunnamed434
Copy link
Contributor

sunnamed434 commented Apr 24, 2024

I experience a similar issue, however, I register EF Core db without openmod API, but doing same thing.

Server shutdown shouldn't cause this since I pass cancellation tokens everywhere where possible is.

EDIT: This exception appears randomly at some point, not at the start or smth.

Logs:

Exception message: An error occured in "PendingEntitiesWorker" 
System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseMySql' call. ---> MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts.
  at MySqlConnector.Core.ServerSession.ConnectAsync (MySqlConnector.Core.ConnectionSettings cs, System.Int32 startTickCount, MySqlConnector.Core.ILoadBalancer loadBalancer, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x002d4] in /_/src/MySqlConnector/Core/ServerSession.cs:378 
  at MySqlConnector.Core.ConnectionPool.GetSessionAsync (MySql.Data.MySqlClient.MySqlConnection connection, System.Int32 startTickCount, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x005a3] in /_/src/MySqlConnector/Core/ConnectionPool.cs:111 
  at MySqlConnector.Core.ConnectionPool.GetSessionAsync (MySql.Data.MySqlClient.MySqlConnection connection, System.Int32 startTickCount, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x007e5] in /_/src/MySqlConnector/Core/ConnectionPool.cs:141 
  at MySql.Data.MySqlClient.MySqlConnection.CreateSessionAsync (MySqlConnector.Core.ConnectionPool pool, System.Int32 startTickCount, System.Nullable`1[T] ioBehavior, System.Threading.CancellationToken cancellationToken) [0x00120] in /_/src/MySqlConnector/MySql.Data.MySqlClient/MySqlConnection.cs:729 
  at MySql.Data.MySqlClient.MySqlConnection.OpenAsync (System.Nullable`1[T] ioBehavior, System.Threading.CancellationToken cancellationToken) [0x0016d] in /_/src/MySqlConnector/MySql.Data.MySqlClient/MySqlConnection.cs:404 
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync (System.Boolean errorsExpected, System.Threading.CancellationToken cancellationToken) [0x0012b] in <04749dad1c80429287c0de883da70092>:0 
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync (System.Boolean errorsExpected, System.Threading.CancellationToken cancellationToken) [0x00286] in <04749dad1c80429287c0de883da70092>:0 
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync (System.Threading.CancellationToken cancellationToken, System.Boolean errorsExpected) [0x0017b] in <04749dad1c80429287c0de883da70092>:0 
  at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlRelationalConnection.OpenAsync (System.Threading.CancellationToken cancellationToken, System.Boolean errorsExpected) [0x0007b] in <971e410b2fc64eaba9c11dae2dfe083d>:0 
  at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync (Microsoft.EntityFrameworkCore.Storage.RelationalCommandParameterObject parameterObject, System.Threading.CancellationToken cancellationToken) [0x000f8] in <04749dad1c80429287c0de883da70092>:0 
  at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1+AsyncEnumerator[T].InitializeReaderAsync (Microsoft.EntityFrameworkCore.DbContext _, System.Boolean result, System.Threading.CancellationToken cancellationToken) [0x000bd] in <04749dad1c80429287c0de883da70092>:0 
  at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlExecutionStrategy.ExecuteAsync[TState,TResult] (TState state, System.Func`4[T1,T2,T3,TResult] operation, System.Func`4[T1,T2,T3,TResult] verifySucceeded, System.Threading.CancellationToken cancellationToken) [0x00089] in <971e410b2fc64eaba9c11dae2dfe083d>:0 
   --- End of inner exception stack trace ---
  at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlExecutionStrategy.ExecuteAsync[TState,TResult] (TState state, System.Func`4[T1,T2,T3,TResult] operation, System.Func`4[T1,T2,T3,TResult] verifySucceeded, System.Threading.CancellationToken cancellationToken) [0x000c6] in <971e410b2fc64eaba9c11dae2dfe083d>:0 
  at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1+AsyncEnumerator[T].MoveNextAsync () [0x002fe] in <04749dad1c80429287c0de883da70092>:0 
  at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource] (System.Linq.IQueryable`1[T] source, System.Threading.CancellationToken cancellationToken) [0x000cc] in <25b3d70e4fdd45f7a2d848578491534a>:0 
  at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource] (System.Linq.IQueryable`1[T] source, System.Threading.CancellationToken cancellationToken) [0x0016b] in <25b3d70e4fdd45f7a2d848578491534a>:0 
  at UnturnedGuard.Database.Entities.MySql.MySqlEntitiesRepository+<>c__DisplayClass9_0.<GetByLogLevelAsync>b__0 () [0x002f9] in <5430c01670224847be6fae7b81697ef2>:0 
  at UnturnedGuard.Shared.Threading.Dispatchers.ThreadPoolDispatcher+<>c__DisplayClass9_0`1[T].<Enqueue>b__0 () [0x00102] in <4effa5d7de8044c5b501bec44e26c8a9>:0 
  at UnturnedGuard.Shared.Threading.Dispatchers.ThreadPoolDispatcher.<ProcessQueue>b__11_0 () [0x000bd] in <4effa5d7de8044c5b501bec44e26c8a9>:0 

@CyberAndrii
Copy link
Member

Someone might have forgotten to put ! before IsServer https://github.com/Unity-Technologies/mono/blob/2021.3.29f1/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs#L339

@sunnamed434
Copy link
Contributor

Currently use the fix made by CyberAndrii in one of the my plugins, and it seems like annoying exception is gone now !

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

Successfully merging a pull request may close this issue.

4 participants