Description:
Exception thrown on dispose of TransactionScope.
- There is already a bug (https://bugs.mysql.com/bug.php?id=59346) created and closed for this issue but the problem is appearing again.
How to repeat:
1) Before running, lock tables t2 read
2)
private void btnTestTransactionScope_Click(object sender, EventArgs e)
{
using (TransactionScope scope = new TransactionScope())
{
DoInsertTablet1();
DoInsertTablet2(); //X
scope.Complete();
}
}
//DoInsertTable2 is similar except for the table name
private static void DoInsertTable1()
{
try
{
using (MySqlConnection conn = new MySqlConnection(GetTestDBConn()))
using (MySqlCommand cmd = conn.CreateCommand())
{
conn.Open();
cmd.CommandText = @"insert into t2 (Val) values (?value)";
cmd.CommandTimeout = 5;
cmd.Parameters.AddWithValue("?value", new Random().Next());
cmd.ExecuteNonQuery();
}
}
catch (Exception)
{
//throw (my custom exception that will be processed in BL layer)
}
}