-
Notifications
You must be signed in to change notification settings - Fork 14
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
Implementation question #1
Comments
After doing a bit of testing with a mild stress test, 200 sequential requets 10ms apart which take 10-500 ms to complete, I'm seeing a lot of errors. Some of these are read connections. I think you're correct that for some queries that are read the connection is, but the connection may never get closed leading to connection pool leaks. After a min or so I get these messages: "Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occured because all pooled connections were in use and max pool size was reached. Should the code not call the Dispose method for the connection in DbContext.Dispose() ? |
Created a PR w/ fix #2 Alternatively you can subclass |
@MARKUSER Can you add comments to the PR I created for or against? |
@pimbrouwers Please help me on below points.
May i know why we have to commit (dbContext.Commit();) the transaction for SQL statements which only get the information from database (Like Read operation). Can we ignore Begin Transaction for operations like Read from SQL.
I am using Dapper as middle layer. I have registered the context exactly like how you provided the instructions in startup.cs file. The problem that i am seeing here is with in same controller method call if i am making two database calls (both are read), First call is working fine but the second one is throwing below exception as i believe context was already closed due to
commit was called after completing the fist DB call. Please let me know if i am missing anything.
System.InvalidOperationException: The ConnectionString property has not been initialized.
at System.Data.SqlClient.SqlConnection.PermissionDemand()
Any async call being made with this code resulted in below exception. Please guide me how to invoke async calls.
DB call: await Connection.QueryAsync(sQuery,transaction:Transaction);
System.InvalidOperationException: Invalid operation. The connection is closed.
at System.Data.SqlClient.SqlCommand.<>c.b__122_0(Task`1 result)
services.AddTransient(options =>
{
var builder = new SqlConnectionStringBuilder(Configuration.GetConnectionString("DefaultConnectionString"));
Please help.
The text was updated successfully, but these errors were encountered: