-
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
Errors when using DbDataAdapter.Fill with parameterized and prepared command #1483
Comments
I don't understand how this exception and message can be thrown from the specified line of code:
Additionally, the unbalanced single quote and missing closing parenthesis is very strange. Is this the exact exception message and call stack from the error? |
Sorry, my mistake. I stupidly copied the following error message from calling method in my program code. I will now test IgnorePrepare = true in the connection properties to rule out that the problem has something to do with the Prepare on the server. |
@bgrainger |
Are you able to construct a consistent repro for this, or is it still kind of "random" when it happens? (But known to never happen if |
No, it's still random. It can happen after half an hour or after several hours. |
I ran a stress-test of 70 concurrent threads each creating 10,000 DataTables using your code above: using var connection = await dataSource.OpenConnectionAsync();
using var command = connection.CreateCommand();
command.CommandText = "select rowid, byte, int16, int32, int64 from datatypes_integers where rowid < @rowid and int32 < @int32";
command.Parameters.AddWithValue("@rowid", 10);
command.Parameters.AddWithValue("@int32", 1000000);
command.Prepare();
var dataAdapter = new MySqlDataAdapter(); No exceptions were thrown when running against MariaDB 10.11. Can you provide a more realistic example (e.g., with table schema, some mock data, etc.) for me to test? |
@bgrainger
The problem has nothing to do with the server load. It feels like it is some problem on the DB server side, where the prepared statement on the server side breaks due to a “hiccup”. Normally this happens after several hours, the queries are called every 10 seconds. |
Thanks for the details.
Not from MySqlConnector. You would need to run Wireshark (or similar) to capture the network packets. (Note that if you're using SSL, the packets will be encrypted and thus not usable.) |
I agree. It would be nice for MySqlConnector to detect this and emit a more appropriate exception (if that can be done without adding too much overhead for the expected and normal code path). |
Software versions
MySqlConnector version: 2.3.7
Server type (MySQL, MariaDB, Aurora, etc.) and version: MariaDb 10.6 and 10.11
.NET version: 8
(Optional) ORM NuGet packages and versions: no ORM
Describe the bug
I run the select queries with the parameterized and prepared commands. It runs several times without problem until at some point (it can happen after several minutes or hours) the error "Value cannot be null. (Parameter 'Data table may not be null.)".
If this is the case, the command can no longer be executed and returns the above error message.
The command somehow seems to be permanently "broken"
Other queries with non-parametrized commands can still be executed.
The only thing that helps at this point is reconnect.
The problem seems to be related to the switch to MySqlConnector 2.3.x and .NET 8.
Previously it worked stable with MySqlConnector 2.2.x and .NET 6 or even earlier with MySqlConnector 1.3.x and .NET Framework 4.7.2
Exception
Code sample
Expected behavior
A stable version as in previous versions or at least a correct error message.
The text was updated successfully, but these errors were encountered: