-
Notifications
You must be signed in to change notification settings - Fork 299
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
Major data corruption issue with PR #956 and connection pooling #1344
Comments
@agclark27 thanks for bringing this up. We will look into it shortly. CC: @Wraith2 |
I think this is going to be a case where you'll only see it in the traces. It's really hard to debug this when it's running at high speed. It's probably worth reverting that specific PR and looking to see if this repro still works. |
Edit: It's not consistently reproducible, so might be just that.. Trying to create a consistent repro. |
also with previous versions I tested with preview1 and 3.0.1 and it worked fine. |
Sure. And I agree that it's likely to be #956 but we should really bisect by just removing that one PR and retesting so make sure of that because there are other changes between 3 and 4. |
I haven't been able to reproduce it when #956 is reverted. |
Then it looks like the safest route is to revert that PR and see if a new version can be worked out before 4.0.0. Reverting to the previous bad but known behaviour seems safer than having the possibility of data return on the wrong connection. |
@Wraith2 something to consider is the code is trying to get the value when connection is closed. It might be related to this as well. |
The repro doesn't look like it's doing anything illegal. It's likely to be an issue similar to the ones we've seen in the past where a connection is returned to to pool without being completely closed. Whatever the cause I think reverting that one PR is probably the best place to start. |
We have identified a major bug that appears to have been introduced in PR #956. When using connection pooling under high concurrency, cancelled SqlCommand objects may return the connection to the pool with data still in flight. In the reproduction example below, which occurs in 4.0.0-preview2 but is not reproducible prior to the PR in 4.0.0-preview1, we spawn 100 threads that are opening connections, executing a simple SQL statement that passes in a parameter set to a unique GUID and gets it echoed back through a second parameter, and closes the connection, with a low cancellation timeout so that some will fail and some will succeed. We are finding that the parameter values from a previous connection are being returned in a new, unrelated command object. This suggests that the changes made in PR #956 are no longer fully resetting the connection and in-flight data may come into a new command using a connection retrieved from the pool. This could have significant data corruption implications where output parameters from an unrelated command are returned.
Reproduction Code:
Just a few seconds into execution, you'll see it throw the InvalidOperationException with something like:
System.InvalidOperationException: 'OH NO: Expected f90b93e5-e651-4543-a663-562998fca20d, Got 50f1c311-9e34-4573-9637-e3e3f0a4737b'
The output parameter is clearing being populated with data from another past iteration of the connection.
The text was updated successfully, but these errors were encountered: