-
Notifications
You must be signed in to change notification settings - Fork 350
Description
When a session is returned to the pool, it is rejected as invalid if its database has changed:
MySqlConnector/src/MySqlConnector/Core/ConnectionPool.cs
Lines 151 to 152 in 2b29279
| if (session.DatabaseOverride != null) | |
| return false; |
This test is unnecessarily strict. It reduces performance to close the socket and open a new one; it would be better to reuse the open connection. To accomplish this, the session could be flagged as "requires a database change".
If this flag is set, then when resetting the connection, use a COM_CHANGE_USER packet to specify the same DB as in the original connection string. Or, if The database should be set back to the one in the connection string, even if ConnectionReset=false, do nothing and leave the state of the connection as-is (considering the selected DB to be part of the session state).ConnectionReset=false; this is the expected outcome from opening a connection and is the behaviour of Connector/NET.