我们看到 MSDTC 记录了以下间歇性警告:
调用者尝试将事务传播到远程系统,但 MSDTC 网络 DTC 访问当前在计算机“X”上被禁用。请检查 MS DTC 配置设置。
然而,MSDTC 在设计上在机器 X 上被禁用 - 它是一台客户端机器,并且没有业务参与事务!
该问题很难重现 - 通常在服务重新启动后。我们怀疑在事务上下文中发生了对客户端计算机的回调。
只是想知道是否有人见过类似的问题?
肯
c# msdtc distributed-transactions system.transactions linq-to-sql
我们正在使用NServiceBus.Host.exe主机进程运行基于 NServiceBus 的服务。
在过去的几个月中,Windows 服务两次在生产中突然停止,在应用程序事件日志中留下以下事件:
应用程序:NServiceBus.Host.exe 框架版本:v4.0.30319 描述:由于未处理的异常,进程被终止。异常信息:System.InvalidOperationException 堆栈:在 System.Transactions.TransactionState.ChangeStatePromotedPhase0(System.Transactions.InternalTransaction) 在 System.Transactions.Phase0VolatileDemultiplexer.InternalPrepare() 在 System.Transactions.VolatileDemultiplexer.PoolablePrepare(System.Object) 在 System. .Oletx.OletxVolatileEnlistment.Prepare(System.Transactions.Oletx.OletxVolatileEnlistmentContainer) 在 System.Transactions.Oletx.OletxPhase0VolatileEnlistmentContainer.Phase0Request(Boolean) 在 System.Transactions.Oletx.OletxTransactionManager.SystemObject.Callback(SystemObject.Callback) _ThreadPoolWaitOrTimerCallback。
我们在几分钟的网络不稳定期间收到此错误(例如,对数据库的大量超时,这在我们的 log4net 日志文件中可见)
关于这里失败的任何想法?
我们在 log4net 日志文件中没有看到致命错误。
版本:
考虑以下小程序,它只是创建一个TransactionScope、打印Transaction.Current、调用另一个 AppDomain 中的方法(需要一段时间执行),然后Transaction.Current在返回时打印。
using System;
using System.Linq;
using System.Runtime.Remoting.Lifetime;
using System.Threading;
using System.Transactions;
namespace TransactionScopeFlowTest
{
class Program
{
static void Main(string[] args)
{
// These times are just to generate the error faster. Normally the initial lease is 5 minutes, meaning the method call
// would have to take 5 minutes to occur, so we speed it up here for demonstration purposes.
LifetimeServices.LeaseManagerPollTime = TimeSpan.FromSeconds(1);
LifetimeServices.LeaseTime = TimeSpan.FromSeconds(1);
LifetimeServices.RenewOnCallTime = TimeSpan.FromSeconds(1);
AppDomain domain …Run Code Online (Sandbox Code Playgroud) .net remoting appdomain transactionscope system.transactions
交易范围如何运作?它是如何知道何时已经使用了另一个上下文,以及如何在我的代码中实现另一种范围.
我主要是一个vb.net开发人员,但如果你写的话,我可以阅读c#.
如果上述情况过于模糊:
我理解system.transactions的作用以及如何使用它.我想知道的是如何创建类似的东西,我自己的库,我可以包装一些代码,可以像system.transactions范围一样处理它.我打算在缓存模型中使用它,它会大大增强它.我正在寻找有关事务范围如何知道的详细信息,例如存在父范围,因此它可以附加到它等等,或者提交然后需要在更高级别或更高级别的联系中进行.
例如,如果我有以下内容
using scope1 as new system.transactions.scope
using scope2 as new system.transactions.scope
using scope3 as new system.transactions.scope
scope3.commit
end using
scope2.commit
end using
end using
Run Code Online (Sandbox Code Playgroud)
Scope1不会提交,因此scope2或scope3也不会提交,因为它们的父级都是scope1的上下文.我希望能够用我自己的库来设置它.
我正在测试看嵌套事务是如何工作的,并发现了这种令人不安和意外的行为.
using(TransactionScope otx = new TransactionScope())
using(SqlConnection conn1 = new SqlConnection("Server=S;Database=DB;Trusted_Connection=yes"))
using(SqlCommand cmd1 = conn1.CreateCommand())
{
conn1.Open();
cmd1.CommandType = CommandType.Text;
cmd1.CommandText = "INSERT INTO FP.ACLs (ChangeToken,ACL) VALUES (1,0x)";
cmd1.ExecuteNonQuery();
using(TransactionScope itx = new TransactionScope(TransactionScopeOption.RequiresNew))
using(SqlConnection conn2 = new SqlConnection("Server=S;Database=DB;Trusted_Connection=yes"))
using(SqlCommand cmd2 = conn1.CreateCommand())
{
conn2.Open();
cmd2.CommandType = CommandType.Text;
cmd2.CommandText = "INSERT INTO FP.ACLs (ChangeToken,ACL) VALUES (2,0x)";
cmd2.ExecuteNonQuery();
// we don't commit the inner transaction
}
otx.Complete(); // nonetheless, the inner transaction gets committed here and two rows appear in the …Run Code Online (Sandbox Code Playgroud) transactions transactionscope system.transactions sql-server-2008
.net ×2
c# ×2
msdtc ×2
transactions ×2
appdomain ×1
linq-to-sql ×1
nhibernate ×1
nservicebus ×1
remoting ×1