TransactionAbortedException and sql server connection does not restore
- Dominant language
- C#
- Stars
- 10.9k
- Forks
- 2.1k
- Avg merge
- 14h 42m
- Merged PRs (30d)
- 354
Description
Hello, I got TransactionAbortedException after restarting sql server. SqlServer connection does not restore.
```Bash
Orleans.Transactions.OrleansTransactionAbortedException: Transaction 4357009a-e08b-4866-bce4-11f8a95ed22c Aborted because of an unhandled exception in a grain method call. See InnerException for details.
---> Orleans.Runtime.OrleansException: Error from storage provider AdoNetGrainStorage.TestGrains.TaskGrain,TestGrains-TaskGrain during ReadState for grain Type=TestGrains.TaskGrain,TestGrains-TaskGrain Pk=*grn/TestGrains.TaskGrain/0+key-0xA0398413 Id=GrainReference:*grn/TestGrains.TaskGrain/0+key Error=
Exc level 0: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
```
**Reproduce:**
[github_repo](https://github.com/luyangdev/orleans-sql-server-connection-does-not-restore-sample/blob/master/TestClient/Program.cs)
In the Step 3 below, I expect sql server connection to be restored and no exception to be thrown, however, the above exception still happened.
```CSharp
using var client = BuildClientSqlServer();
await client.Connect();
Console.WriteLine("\n== Step 1. Should OK ==");
Console.WriteLine("Make sure sql server is running now, and press any key to continue");
Console.ReadKey();
var result = await client.GetGrain("key").Execute();
Console.WriteLine(result.Count);
Console.WriteLine("\n== Step 2. Should Exception ==");
Console.WriteLine("Stop sql server now, and press any key to continue");
Console.ReadKey();
try
{
result = await client.GetGrain("key").Execute();
Console.WriteLine(result.Count);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Console.WriteLine("\n== Step 3. Should OK, try several times ==");
Console.WriteLine("Restart sql server now, and press any key to continue");
Console.ReadKey();
for (var i = 0; i < 5; i++)
{
Console.WriteLine($"-- Step 3 >> Attempt {i}");
try
{
result = await client.GetGrain("key").Execute();
Console.WriteLine(result.Count);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
await Task.Delay(TimeSpan.FromSeconds(5));
}
```
Could you please help on this?
Thank you so much.
Contributor guide
Assessment
This issue has not been assessed yet.