示意代码如下:
TransactionOptions transOption = new TransactionOptions();
transOption.IsolationLevel = System.Transactions.IsolationLevel.RepeatableRead;
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew, transOption))
{
//1、增加申请
dal.Add(apply);
//2、更新订单状态
dalOrders.UpdateStatus(orderId, PaymentStatus.等待退款.GetHashCode());
//提交事务
ts.Complete();
}
现在我遇到的奇怪现象是,在数据库压力大的情况下,有万分之一概率出现:事务提交了,但第2步实际上失败了(数据没有更新)。
我的线上环境是:
Windows2008 + .net Framework3.5 + SqServer2008R2,web服务器和Db服务器是分开的。
有谁遇到过这样的情况吗:
1、这是什么原因呢?
2、除了提高事务的隔离级别,还有别的办法吗?