-
Notifications
You must be signed in to change notification settings - Fork 337
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
Unable to connect error with multithread #1141
Comments
ServerSession.cs, line 514 should be logging an error Is that in your logs?
Are these logs from MySqlConnector 2.1.6 with |
No, we don't see that in logs
This log is with SSL Mode = Preferred. Do you think is a TLS problem? We could generate the log with SSL Mode = None |
The line number implies it's a TLS problem, although the missing logs are an anomaly. Yes, please post logs from |
Hello, We have done the test with SSL Mode = None and the results are similar. First, indicate that the test had been done in another different service of the original log (because the original service is very critical), but the behavior is the same. 1º In the attached file "DebugTLS.log" you can see the result of SSLMode = "Preffered". You can see "connecting failed" errors. A very curious behavior is: We hope these files help you to understand the error better. On the other hand, another problem with the connector is the following: |
There are a very high number of distinct Pool numbers present in the DebugSSLModeNone log: Having hundreds of concurrently-active connection pools is not the typical use case of MySqlConnector, and would likely defeat the benefits of connection pooling. It could also lead to thousands (or tens of thousands) of client TCP sockets being opened, which might be causing your problems (if the underlying issue is socket exhaustion). There are also very frequent instances of Can you adjust your client code so that it only creates one pool (i.e., one unique connection string) and stops clearing the pool frequently? |
Hello, Sorry for the delay. We are making progress on this topic. On the one hand, we are changing the methodology and not cleaning the connection pool in each request. The fear we have in applying this solution is that the number of active connections to the DB will now increase (and may even reach the limit established by the DB itself). What do you think about this? On the other hand, we have doubts about applying this solution in other application. It is a website where each client has its own database schema within the same DB server. Let's imagine a server with 100 schemas and a maximum allowed number of connections per DB server of 600. In this scenario, the maximum size of the connection pool that I can have for each schema is 6. Therefore, if I have 7 users performing a simultaneous query would give me an error for exceeding the size of the pool. This makes sense? Best regards, |
You haven't explained why you think the number of active connections to the DB will increase. An active connection is only created when your code calls Assuming that you
If you are anticipating that all 100 schemas will be in use concurrently, then yes the maximum number of connections you could have per schema (on average) would be 6.
No, I'm not following that. Does each user open 100 connections to each of the 100 schemas? If so, that seems incredibly inefficient (when you could instead join across schemas if they're hosted on the same DB server).
Finally, if you're really worried about pooling, you could add |
Thank you for the quick response,
I was referring to "idle connections", that is, connections that, even if they are in "sleep" state, will add to the total number of simultaneous connections allowed by the DB server.
I was referring to 7 users making simultaneous queries on the same schema, that is, if I have 600 maximum connections to the server and 100 schemas, each schema could be queried simultaneously by a maximum of 6 users, but the 7th user would already receive an error. Is it so? Anyway, now I have a lot more clarity about the behavior and the way of working, thank you very much! However, tonight we have had an anomalous behavior: We have a service (with the logic of cleaning the pool for each connection) with the following behavior:
The connection to DB "A" always works correctly. However, tonight, the connection to DB "B" gave a TLS1.2 connection error and started trying to connect (non-stop) over TLS1.1 (and our DB is not TLS1.1 enabled) , so it has not stopped failing until we have restarted the service. I attach the log in case you need to see more information. |
If you set |
Are you running MySqlConnector 2.1.6 or later? #1132 fixes a bug that allowed TLS downgrade. If not, please update to at least that version. If you know your server doesn't support TLS 1.1 (and that you never want to use that TLS version), you can set |
The previous TLS1_2,log file has been obtained with version 2.1.6 of the connector. Seeing #1132 the error occurs in different places. In that bug, the error appears in However, in our case, the error appears at: "MySqlConnector.Core.ServerSession.ConnectAsync" Do you think it is the same error in both cases? |
Software versions
MySqlConnector version: 2.1.6 (tested with multiple versions 1.3.13 - 2.1.2 - 2.1.6)
Server type (MySQL, MariaDB, Aurora, etc.) and version: MySQL 5.7.36
.NET version: Net Framework 4.7.2 / Net Core 3.1
ORM NuGet packages and versions: NHibernate 5.2.5
Describe the bug
Our approach involves a work context with several thousand of requests. Our solution design is open/close a connection for each request. When the number of request increases we receive faults according to the following Exception annex. To be more accurate we estimate the number of faults is around the 10% percent of request, A very bad figure. As addition information, we are using TLS 1.2 without setting any value referred to TLS connection mode. After seeing TLS errors we have allowed non TLS connection in data base server, addiontally we have updated the SSL paramenter from default to "NONE", but the result is the same one.
Exception
2022-02-18 08:43:26,793 [TRACE] MySqlConnector.ConnectionPool - Pool19 waiting for an available session
2022-02-18 08:43:26,793 [TRACE] MySqlConnector.ServerSession - Session19.198 created new session
2022-02-18 08:43:26,793 [DEBUG] MySqlConnector.ConnectionPool - Pool19 no pooled session available; created new Session19.198
2022-02-18 08:43:26,794 [TRACE] MySqlConnector.ServerSession - Session19.198 connecting to IpAddress XXXX for HostName 'XXXX'
2022-02-18 08:43:26,819 [TRACE] MySqlConnector.ConnectionPool - Pool1 waiting for an available session
2022-02-18 08:43:26,819 [TRACE] MySqlConnector.ServerSession - Session1.1670 created new session
2022-02-18 08:43:26,819 [DEBUG] MySqlConnector.ConnectionPool - Pool1 no pooled session available; created new Session1.1670
2022-02-18 08:43:26,820 [TRACE] MySqlConnector.ServerSession - Session1.1670 connecting to IpAddress XXXX for HostName 'XXXX'
2022-02-18 08:43:26,835 [TRACE] MySqlConnector.ServerSession - Session1.1670 connected to IpAddress XXXX for HostName 'XXXX' with local Port 57654
2022-02-18 08:43:26,836 [TRACE] MySqlConnector.ServerSession - Session1.1670 server sent AuthPluginName=mysql_native_password
2022-02-18 08:43:26,836 [DEBUG] MySqlConnector.ServerSession - Session1.1670 made connection; ServerVersion=5.7.36; ConnectionId=8743309; Compression=False; Attributes=True; DeprecateEof=True; Ssl=True; SessionTrack=True; Pipelining=True; QueryAttributes=False
2022-02-18 08:43:26,836 [TRACE] MySqlConnector.ServerSession - Session1.1670 initializing TLS connection
2022-02-18 08:43:26,840 [DEBUG] MySqlConnector.ServerSession - Session1.1670 connected TLS with SslProtocol=Tls12, CipherAlgorithm=Aes256, HashAlgorithm=Sha384, KeyExchangeAlgorithm=44550, KeyExchangeStrength=255
2022-02-18 08:43:26,841 [TRACE] MySqlConnector.ConnectionPool - Pool1 returning new Session1.1670 to caller; LeasedSessionsCount=1
2022-02-18 08:43:26,841 [TRACE] MySqlConnector.CommandExecutor - Session1.1670 ExecuteReader Synchronous CommandCount: 1
2022-02-18 08:43:26,841 [TRACE] MySqlConnector.SingleCommandPayloadCreator - Session1.1670 Preparing command payload; CommandText: SELECT XXXX
2022-02-18 08:43:26,842 [TRACE] MySqlConnector.ServerSession - Session1.1670 entering FinishQuerying; SessionState=Querying
2022-02-18 08:43:26,843 [TRACE] MySqlConnector.ConnectionPool - Pool9 waiting for an available session
2022-02-18 08:43:26,843 [TRACE] MySqlConnector.ServerSession - Session9.66 created new session
2022-02-18 08:43:26,843 [DEBUG] MySqlConnector.ConnectionPool - Pool9 no pooled session available; created new Session9.66
2022-02-18 08:43:26,843 [TRACE] MySqlConnector.ServerSession - Session9.66 connecting to IpAddress XXXX for HostName 'XXXX'
2022-02-18 08:43:26,852 [TRACE] MySqlConnector.ServerSession - Session9.66 connected to IpAddress XXXX for HostName 'XXXX' with local Port 57660
2022-02-18 08:43:26,853 [TRACE] MySqlConnector.ServerSession - Session9.66 server sent AuthPluginName=mysql_native_password
2022-02-18 08:43:26,853 [DEBUG] MySqlConnector.ServerSession - Session9.66 made connection; ServerVersion=5.7.36; ConnectionId=162415; Compression=False; Attributes=True; DeprecateEof=True; Ssl=True; SessionTrack=True; Pipelining=True; QueryAttributes=False
2022-02-18 08:43:26,853 [TRACE] MySqlConnector.ServerSession - Session9.66 initializing TLS connection
2022-02-18 08:43:26,855 [DEBUG] MySqlConnector.ServerSession - Session9.66 connected TLS with SslProtocol=Tls12, CipherAlgorithm=Aes256, HashAlgorithm=Sha384, KeyExchangeAlgorithm=44550, KeyExchangeStrength=255
2022-02-18 08:43:26,856 [ERROR] MySqlConnector.ServerSession - Session19.198 connecting failed
2022-02-18 08:43:26,856 [ERROR] WsGestionFlotasJaltest.WsJaltestFleet - MySQLException en el método InsertarInformacion -->
MySqlConnector.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
en MySqlConnector.Core.ServerSession.d__83.MoveNext() en //src/MySqlConnector/Core/ServerSession.cs:línea 514
--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---
en System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
en MySqlConnector.Core.ConnectionPool.d__21.MoveNext() en //src/MySqlConnector/Core/ConnectionPool.cs:línea 363
--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---
en System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
en MySqlConnector.Core.ConnectionPool.d__10.MoveNext() en //src/MySqlConnector/Core/ConnectionPool.cs:línea 94
--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---
en System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
en MySqlConnector.Core.ConnectionPool.d__10.MoveNext() en //src/MySqlConnector/Core/ConnectionPool.cs:línea 19
--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---
en System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
en MySqlConnector.MySqlConnection.d__124.MoveNext() en //src/MySqlConnector/MySqlConnection.cs:línea 919
--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---
en System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
en MySqlConnector.MySqlConnection.d__26.MoveNext() en //src/MySqlConnector/MySqlConnection.cs:línea 425
--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---
en System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
en MySqlConnector.MySqlConnection.Open() en /_/src/MySqlConnector/MySqlConnection.cs:línea 373
...
2022-02-18 08:43:26,960 [TRACE] MySqlConnector.ConnectionPool - Pool9 returning new Session9.66 to caller; LeasedSessionsCount=1
2022-02-18 08:43:26,960 [TRACE] MySqlConnector.ConnectionPool - Pool1 waiting for an available session
2022-02-18 08:43:26,960 [TRACE] MySqlConnector.ServerSession - Session1.1671 created new session
2022-02-18 08:43:26,960 [DEBUG] MySqlConnector.ConnectionPool - Pool1 no pooled session available; created new Session1.1671
2022-02-18 08:43:26,963 [TRACE] MySqlConnector.CommandExecutor - Session9.66 ExecuteReader Synchronous CommandCount: 1
2022-02-18 08:43:26,963 [TRACE] MySqlConnector.SingleCommandPayloadCreator - Session9.66 Preparing command payload; CommandText: INSERT INTO ...
2022-02-18 08:43:26,965 [TRACE] MySqlConnector.ServerSession - Session9.66 entering FinishQuerying; SessionState=Querying
2022-02-18 08:43:26,965 [TRACE] MySqlConnector.CommandExecutor - Session1.1670 ExecuteReader Synchronous CommandCount: 1
2022-02-18 08:43:26,965 [TRACE] MySqlConnector.SingleCommandPayloadCreator - Session1.1670 Preparing command payload; CommandText: set session transaction isolation level repeatable read;
2022-02-18 08:43:26,966 [TRACE] MySqlConnector.ServerSession - Session1.1670 entering FinishQuerying; SessionState=Querying
2022-02-18 08:43:26,966 [TRACE] MySqlConnector.CommandExecutor - Session1.1670 ExecuteReader Synchronous CommandCount: 1
2022-02-18 08:43:26,966 [TRACE] MySqlConnector.SingleCommandPayloadCreator - Session1.1670 Preparing command payload; CommandText: start transaction;
2022-02-18 08:43:26,966 [TRACE] MySqlConnector.ServerSession - Session1.1671 connecting to IpAddress XXXX for HostName 'XXXX'
2022-02-18 08:43:26,967 [TRACE] MySqlConnector.ServerSession - Session1.1670 entering FinishQuerying; SessionState=Querying
2022-02-18 08:43:26,967 [TRACE] MySqlConnector.ServerSession - Session1.1671 connected to IpAddress XXXX for HostName 'XXXX' with local Port 58387
The text was updated successfully, but these errors were encountered: