Skip to main content

272 posts tagged with "Issues"

Common Issues and Troubleshooting

View All Tags

Fixed: "The connection is already in a transaction and cannot participate in another transaction" in EF Core

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Calling one helper method from inside a transaction failed with The connection is already in a transaction and cannot participate in another transaction. The helper had its own BeginTransactionAsync, which made sense when it was written, and it stopped making sense once something else called it inside a transaction.

Fixed: Two Requests Buy the Last Item in EF Core (Overselling)

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

One unit left, five simultaneous orders, and all five answered 201 Created. The order code was in a transaction, and it checked the stock first. It looked correct, and the first time I ran it, it even behaved. The check and the write were two separate steps, and every order did the check before any of them had written.

Fixed: EF Core Retry Places the Same Order Twice After a Lost COMMIT

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

One request answered 201, and the database had two orders, with the stock taken twice. MySQL had committed the first attempt, the connection dropped before the reply arrived, and EF Core's retry, knowing only that the commit had failed, did it all again. Retrying is only safe when each attempt can tell that an earlier one already worked.

Fixed: "Too many connections" from "Authentication to host failed" with MySql.Data

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Authentication to host '127.0.0.1' for user 'inventory_app' using method 'caching_sha2_password' failed with message: Too many connections looks like a login problem, and I went to check the password first. The password was fine. The second half of the message is the real error: MySQL had no connections left to give.

Fixed: "Fatal error encountered during command execution" and "Reading from the stream has failed" with MySql.Data

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Fatal error encountered during command execution sounds like something is badly wrong with the statement. Read the inner exceptions, and it ends with Attempted to read past the end of the stream: the connection went away while the driver was waiting for an answer. The statement isn't the problem, and it's usually worth trying again.

Fixed: "NullReferenceException" at MySqlCommand.ExecuteNonQueryInternalAsync After KILL QUERY

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

A statement was stuck behind a row lock, so I stopped it with KILL QUERY. The mysql client reports that as ERROR 1317: Query execution was interrupted. My API got System.NullReferenceException from inside MySql.Data. It's a misleading message, and once you know that, it tells you exactly what happened.