locked
Distributed Transaction with WCF Services RRS feed

  • Question

  • All,

    We are having .NET web services using WCF and exposing wsHttpBinding with transaction flow enabled. We consume the service using .NET client. Both client and services are on in one web server and database (SQL Server 2005) is on another server.

    We have MSDTC configured (not WS-AT)  on both DB and Web servers. Everything works fine most of the time but approx. 1% of the time we end up with the following error message which we have no clue about.

    The flowed transaction could not be unmarshaled. The following exception occurred: The transaction has already been implicitly or explicitly committed or aborted

    We have everything .NET and everything is internal (no internet communications). We already checked firewall settings (no firewall blocking MSDTC), GUID of the servers (they are different), MSDTC (network access -in/out/remote client enabled) - all seems to be okay.

    Does any one know why this would happen?

    Appreciate your help.

    Thursday, March 4, 2010 7:28 PM

Answers

All replies

  • Your configuration sounds correct, so this error message indicates one of two things:

    1) Transaction timeout.
    2) The application is calling "Commit" starting 2PC processing before all the participants have had a chance to enlist in the transaction.

    Do you see any indication of transaction timeout? The default is 1 minute.

    If you can rule out Transaction timeout, then I need to know a little bit more about the topology of the system:

    You have a .NET Client App a .NET WCF Service on one machine and and a SQL 2k5 DB on another. The transaction starts in the App, flows to the WCF service, and then the service is doing DB operations inside the WCF service method, correct? Is there any other details I should know?

    Thanks,
    -Clark

    Tuesday, March 9, 2010 6:38 PM
    Moderator
  • Thanks Clark.

    We are finding that this error doesn't happen if the recycle settings on the IIS application pool for the web services is turned off. The application pool has the setting to recycle the service when the memory usage exceeds 192 MB or the virtual memory usage exceeds 500MB. Looks like the service is easily exceeding this memory and hence triggering a recycle. Even though the recycling should be transparent to the MSDTC transaction, we see that it is not the case.

    Now I have these questions:

    1. If people deployed WCF services to IIS web server and configure it to use a different application pool (other than default application pool) what should be the ideal recycle settings?

    2. .NET Garbage Collector seems to do a nice job with some services but for some services, it is moving data from Gen0 to Gen1 and the memory seems to be growing over time, thus triggering a recycle. Have anyone seen this behaviour with an WCF service using PerCall instancing mode. If I explictly call GC.Collect() within the service implementation, all memory is de-allocated and the service behaves well. But, this doesn't seem to be a best practice. I am wondering why the GC is not freeing up the heap memory after servicing the web service request. Unfortunately, I am not seeing any configuration to configure GC to do the cleanup whenever memory usage of the service exceeds certain amount, say 150 MB. Any ideas?

    3. Is there any bug in MSDTC and/or IIS 6.0 which is preventing the transaction to run transparently when the recycling happens?

    Appreciate your help.
    Tuesday, March 9, 2010 9:58 PM
  • There is no known issue with MSDTC and IIS recycle settings. You can probably trace the transaction to understand, why you get this exception The transaction has already been implicitly or explicitly committed or aborted. Depending on how you modeled your application, it is possible that the transaction is aborted when this happens. Can you post the full exception including the stack trace.

    Here are some pointers to enalbe transaction tracing to understand, why/if this transaction is aborted. 

    http://support.microsoft.com/kb/926099/en-us

    http://msdn.microsoft.com/en-us/library/aa561924(BTS.20).aspx

    Regarding your other question about the ideal recycle settings., I think you might want to post here for better support.

    http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=118&SiteID=1

    Thanks,

    Srini

    Friday, March 26, 2010 12:02 AM
    Moderator
  • lvelayutham,

    I am going to mark this question as answered due to lack of activity.  If you are still struggling with this issue, please reactivate it and include the tracing logs.  Thank you.

    JVE

    Friday, April 2, 2010 2:48 PM
    Moderator
  • Hi everyone,

    I'm also experiencing a growing memory usage in a transacted WCF service/client, and we do go through the internet. In short our wcf service collect data using EF 3.5 SP1, compress the data and send it as a string base 64. The compression/decompression method and also the context and queries are all released safely. The thing is that when the service obtains data, obviously the memory grows. The transaction flow gets back to the client and after inserting the data into another DB it just calls close and the transaction gets commited on the server side too. But even after committing, the memory usage of the WCF windows service process doesn't go down to the previous level.

    has any one gone through something like this.?

    thanks!

    Juan


    Systems Analist
    Wednesday, May 19, 2010 9:41 PM