我正在浏览一段代码并遇到以下内容:
using(var transactionScope = new TransactionScope(TransactionScopeOption.Required, new TransactionScopeOptions { IsolationLevel = IsolationLevel.Snapshot })
{
List<Task> tasks = new List<Task>();
try
{
// Perform some database operation to read data (These operations are happening with a transaction scope having scopeoption as "Required" and isolationlevel as "ReadCommitted")
// Filter the data
// At this point the code already has a reference to a WCF duplex callback
// Create a List<Task> and a
foreach(var data in List<SomeData>)
{
var task = Task.Factory.StartNew(() => {
**(WCF Duplex Callback Instance).Process(data);**
});
tasks.Add(task);
}
}
catch(Exception ex)
{
// Log exception details
}
transactionScope.Complete();
}
try
{
Task.WaitAll(tasks);
}
catch(AggregateException ae)
{
ae.Handle( ex => {
// log exception details
return true;
});
}
问题:
父事务隔离级别为“快照”,而内部数据库读取使用“ReadCommitted”。实际的事务隔离级别是什么?
假设有两个任务。任务 1 处理得很好,并在回调通道上发送到 WCF 客户端。但任务 2 引发了异常。我猜此时在父事务范围内执行的所有活动都应该回滚。但我不确定回滚一组已经通过 WCF 回调通道发送到客户端的数据意味着什么。