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

Add ResetConnectionAsync #831

Closed
bgrainger opened this issue Jun 9, 2020 · 4 comments
Closed

Add ResetConnectionAsync #831

bgrainger opened this issue Jun 9, 2020 · 4 comments
Assignees
Milestone

Comments

@bgrainger
Copy link
Member

From #178 (comment)

For advanced scenarios, it could be useful to support the following API:

class MySqlConnection
{
    public ValueTask ResetConnectionAsync(CancellationToken token = default);
}

This would send a COM_RESET_CONNECTION packet to reset the open connection. By allowing the user to manually reset the connection only when needed (e.g., a temporary table has been created or user variables were set), it would be practical to add ConnectionReset=false to the connection string and avoid its overhead when retrieving a pooled connection (see #178).

Since this is an advanced API, is a synchronous version of this method needed? (Probably not.)

@bgrainger bgrainger changed the title Add ResetConnection{Async} Add ResetConnectionAsync Jun 9, 2020
@bgrainger bgrainger added this to the 1.0 milestone Jun 14, 2020
@bgrainger bgrainger self-assigned this Jun 14, 2020
@athoscouto
Copy link

Thanks for doing this @bgrainger!
Will this feature be available on 0.x or only on 1.x?

@bgrainger
Copy link
Member Author

This is only in the 1.0.0 release.

While it's current tagged as -beta in NuGet, this is mostly due to the (breaking) namespace change, rather than any prerelease code quality issues.

@athoscouto
Copy link

Just tested it and couldn't make it work.

Migrated to 1.0.0-beta.4 and added ConnectionReset=False to the connection string.
Before calling MySqlConnection.DisposeAsync() I awaited MySqlConnection.ResetConnectionAsync().

I've got an "Unknown command" exception. This was at the top of the stack trace:

   at MySqlConnector.Core.ServerSession.ReceiveReplyAsyncAwaited(ValueTask`1 task) in /_/src/MySqlConnector/Core/ServerSession.cs:line 806
   at MySqlConnector.MySqlConnection.ResetConnectionAsync(CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlConnection.cs:line 436

@bgrainger
Copy link
Member Author

What server and version are you using? For MySQL Server, you have to be running 5.7.3 or later. For MariaDB, it needs to be 10.2.4 or later. Other MySQL-compatible backends may not support it at all.

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

No branches or pull requests

2 participants