Troubleshooting of transaction processing exceptions in a Distributed Transaction Manager (MSDTC)

Source: Internet
Author: User
Tags stack trace

In the past two days, the system of an MS sql2005 server has some problems. After the server is restarted, it cannot log on to the system normally. Therefore, the last correct configuration of the server is restored. It is always runningProgramWhen a new record is added, a transaction error occurs. The operations are normal during editing and deletion.

My network environment is a web server, a data server, the same data center, the same network segment, and different IP addresses.

The transaction Exception error prompt is as follows:

System. Transactions. transactionmanagercommunicationexception: network access to the Distributed Transaction Manager (MSDTC) is disabled. Use the component service management tool to enable DTC for network access in MSDTC security configuration. ---> System. runtime. interopservices. comexception (0x8004d024): the Transaction Manager has disabled its support for remote/network transactions. (Exception from hresult: 0x8004d024)
In system. Transactions. oletx. Transport. deleetransaction (uint32 propgationtokensize, byte [] propgationtoken, intptr managedidentifier, guid & transactionidentifier, interval & isolationlevel, interval & transactionshim)
In system. Transactions. transactioninterop. getoletxtransactionfromtransmitterpropigationtoken (byte [] propagationtoken)
--- End of the internal exception stack trace ---
In system. Transactions. oletx. oletxtransactionmanager. proxyexception (comexception)
In system. Transactions. transactioninterop. getoletxtransactionfromtransmitterpropigationtoken (byte [] propagationtoken)
In system. Transactions. transactionstatepspeoperation. pspepromote (internaltransaction Tx)
In system. Transactions. transactionstatedelegatedbase. enterstate (internaltransaction Tx)
In system. Transactions. enlistablestates. Promote (internaltransaction Tx)
In system. Transactions. transaction. Promote ()
In system. Transactions. transactioninterop. converttooletxtransaction (transaction)
In system. Transactions. transactioninterop. getexportcookie (transaction, byte [] whereabouts)
In system. Data. sqlclient. sqlinternalconnection. gettransactioncookie (transaction, byte [] whereabouts)
In system. Data. sqlclient. sqlinternalconnection. enlistnonnull (transaction Tx)
In system. Data. sqlclient. sqlinternalconnection. Enlist (transaction Tx)
In system. Data. sqlclient. sqlinternalconnectiontds. Activate (transaction)
In system. Data. providerbase. dbconnectioninternal. activateconnection (transaction)
In system. Data. providerbase. dbconnectionpool. getconnection (dbconnection owningobject)
In system. Data. providerbase. dbconnectionfactory. getconnection (dbconnection owningconnection)
In system. Data. providerbase. dbconnectionclosed. openconnection (dbconnection outerconnection, dbconnectionfactory connectionfactory)
In system. Data. sqlclient. sqlconnection. open ()
In system. Data. LINQ. sqlclient. sqlconnectionmanager. useconnection (iconnectionuser user)
In system. Data. LINQ. sqlclient. sqlprovider. get_issqlce ()
In system. Data. LINQ. sqlclient. sqlprovider. initializeprovidermode ()
In system. Data. LINQ. sqlclient. sqlprovider. system. Data. LINQ. provider. iprovider. Execute (expression query)
In system. Data. LINQ. Table '1. system. LINQ. iqueryprovider. Execute [tresult] (expression)
In system. LINQ. queryable. firstordefault [tsource] (iqueryable '1 source, expression' 1 predicate)
In gcevideomonitor. BLL. siteinfo. getdevicetypekey (int32 devicetypeid, int32 rttype)
In gcevideomonitor. Manage. Monitor. monitorchannelmanage. addsubmit (Object sender, eventargs E)

 

At first, I thought it was a MSDTC problem, but my MSDTC was enabled. According to the error message, "network access to the Distributed Transaction Manager (MSDTC) has been disabled. Please use the component service management tool to enable DTC for network access in MSDTC security configuration. "search online, the configuration is consistent with what is said on the Internet, and all methods have been tried. The exception persists. The following exceptions have also occurred:

System. Transactions. transactionmanagercommunicationexception: communication with the basic transaction manager fails. ---> System. runtime. interopservices. comexception (0x80004005): An error hresult e_fail is returned for calling COM components.
In system. Transactions. oletx. Transport. deleetransaction (uint32 propgationtokensize, byte [] propgationtoken, intptr managedidentifier, guid & transactionidentifier, interval & isolationlevel, interval & transactionshim)
In system. Transactions. transactioninterop. getoletxtransactionfromtransmitterpropigationtoken (byte [] propagationtoken)
--- End of the internal exception stack trace ---
In system. Transactions. transactioninterop. getoletxtransactionfromtransmitterpropigationtoken (byte [] propagationtoken)
In system. Transactions. transactionstatepspeoperation. pspepromote (internaltransaction Tx)
In system. Transactions. transactionstatedelegatedbase. enterstate (internaltransaction Tx)
In system. Transactions. enlistablestates. Promote (internaltransaction Tx)
In system. Transactions. transaction. Promote ()
In system. Transactions. transactioninterop. converttooletxtransaction (transaction)
In system. Transactions. transactioninterop. getexportcookie (transaction, byte [] whereabouts)
In system. Data. sqlclient. sqlinternalconnection. gettransactioncookie (transaction, byte [] whereabouts)
In system. Data. sqlclient. sqlinternalconnection. enlistnonnull (transaction Tx)
In system. Data. sqlclient. sqlinternalconnection. Enlist (transaction Tx)
In system. Data. sqlclient. sqlinternalconnectiontds. Activate (transaction)
In system. Data. providerbase. dbconnectioninternal. activateconnection (transaction)
In system. Data. providerbase. dbconnectionpool. getconnection (dbconnection owningobject)
In system. Data. providerbase. dbconnectionfactory. getconnection (dbconnection owningconnection)
In system. Data. providerbase. dbconnectionclosed. openconnection (dbconnection outerconnection, dbconnectionfactory connectionfactory)
In system. Data. sqlclient. sqlconnection. open ()
In system. Data. LINQ. sqlclient. sqlconnectionmanager. useconnection (iconnectionuser user)
In system. Data. LINQ. sqlclient. sqlprovider. get_issqlce ()
In system. Data. LINQ. sqlclient. sqlprovider. initializeprovidermode ()
In system. Data. LINQ. sqlclient. sqlprovider. system. Data. LINQ. provider. iprovider. Execute (expression query)
In system. Data. LINQ. Table '1. system. LINQ. iqueryprovider. Execute [tresult] (expression)
In system. LINQ. queryable. firstordefault [tsource] (iqueryable '1 source, expression' 1 predicate)
In gcevideomonitor. BLL. siteinfo. getdevicetypekey (int32 devicetypeid, int32 rttype)
In gcevideomonitor. Manage. Monitor. monitorchannelmanage. addsubmit (Object sender, eventargs E)

Carefully analyze and enableCodeAfter debugging, we found that "gcevideomonitor. bll. siteinfo. getdevicetypekey (int32 devicetypeid, int32 rttype) "This location causes an exception. The code of this method is directly used in the transaction process. If this method is not called, exceptions in this location are not generated.

When a new record with a transaction is added and tested, the following exception occurs:

System. Transactions. transactionexception: This operation is invalid for the transaction status. ---> System. timeoutexception: Transaction timeout
--- End of the internal exception stack trace ---
In system. Transactions. transactionstate. enlistpromotablesinglephase (internaltransaction Tx, ipromotablesinglephasenotification promotablesinglephasenotification, transaction atomictransaction)
In system. Transactions. transaction. enlistpromotablesinglephase (ipromotablesinglephasenotification promotablesinglephasenotification)
In system. Data. sqlclient. sqlinternalconnection. enlistnonnull (transaction Tx)
In system. Data. sqlclient. sqlinternalconnection. Enlist (transaction Tx)
In system. Data. sqlclient. sqlinternalconnectiontds. Activate (transaction)
In system. Data. providerbase. dbconnectioninternal. activateconnection (transaction)
In system. Data. providerbase. dbconnectionpool. getconnection (dbconnection owningobject)
In system. Data. providerbase. dbconnectionfactory. getconnection (dbconnection owningconnection)
In system. Data. providerbase. dbconnectionclosed. openconnection (dbconnection outerconnection, dbconnectionfactory connectionfactory)
In system. Data. sqlclient. sqlconnection. open ()
In system. Data. LINQ. sqlclient. sqlconnectionmanager. useconnection (iconnectionuser user)
In system. Data. LINQ. sqlclient. sqlprovider. Execute (expression query, queryinfo, iobjectreaderfactory, object [] parentargs, object [] userargs, icompiledsubquery [] subqueries, object lastresult)
In system. Data. LINQ. sqlclient. sqlprovider. executeall (expression query, queryinfo [] queryinfos, iobjectreaderfactory, object [] userarguments, icompiledsubquery [] subqueries)
In system. Data. LINQ. sqlclient. sqlprovider. system. Data. LINQ. provider. iprovider. Execute (expression query)
In system. Data. LINQ. changedirector. standardchangedirector. dynamicinsert (trackedobject item)
In system. Data. LINQ. changedirector. standardchangedirector. insert (trackedobject item)
In system. Data. LINQ. changeprocessor. submitchanges (conflictmode failuremode)
In system. Data. LINQ. datacontext. submitchanges (conflictmode failuremode)
In gcevideomonitor. dal. gcevideomonitor3datacontext. submitchanges (conflictmode failuremode) Location E: \ official project VM2 \ gce3.0 \ gceteam \ gce3.0 \ gcevideomonitor. dal \ entities \ gcevideomonitor3datacontext. manager. CS: Row 56
In system. Data. LINQ. datacontext. submitchanges ()
At location E: \ official project VM2 \ gce3.0 \ gceteam \ gce3.0 \ gcevideomonitor. Dal \ entities \ users. generated. CS: Row 999
In gcevideomonitor. manage. monitor. monitorchannelmanage. addsubmit (Object sender, eventargs e) Location E: \ official project VM2 \ gce3.0 \ gceteam \ gce3.0 \ gcevideomonitor. manage \ monitor \ monitorchannelmanage. aspx. CS: Row 161

This exception is resolved on the Internet:

There are two main methods for improper use:
1. The transaction is called first, and then the database connection is opened.
2. Another transaction is nested in one transaction.

Therefore, modify the Code as follows:

Using (VAR Ts = new system. Transactions. transactionscope ())
{

Using (VAR Dc = BLL. siteinfo. createdbdatacontext ())
{

....

}

}

Changed:

Using (VAR Dc = BLL. siteinfo. createdbdatacontext ())
{

Using (VAR Ts = new system. Transactions. transactionscope ())
{

....

}

}

Records are successfully added and all exceptions are resolved.

In addition, I found that my computer cannot add records, but on a colleague's computer, he can add records without exceptions, which is very strange.

No language, just for later.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.