Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6544565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:28:51+00:00 2026-05-25T11:28:51+00:00

I have a WCF service that occasionally causes a database deadlock. My service allows

  • 0

I have a WCF service that occasionally causes a database deadlock. My service allows you to submit applications to the council, also it allows you to load them again because the council can updated them. Each of the applications has a number of documents associated with it.

So if a set of events like this occur on my service

1) Application #1 is submitted
2) A document is uploaded for application #1
3) Application #1 is loaded
4) Part 2 above finishes

Deadlock at part 3. I believe the reason is that the document in part 2 takes a while to submit to the SQL server from the WCF service, and during this time it locks the table.

So if we load from the database application #1, and the associated documents we get in trouble.

I am using the entity framework. How can I solve this? All I really want to do is load the documents in this circumstance that are completely submitted and not run into the table being locked or anything.

By the way this is the specific error I am getting,

Message: Transaction (Process ID 93) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

UPDATE: I have had a couple of comments that I could change the order of operations. I cannot actually do that because part 2 and part 3 are from different calls to the WCF service. So it is up to the user of the service to order the operations. ‘Ask them to change it’ you say, but it is not that simple either. The order of the operations actually depends on the end user just happening to ‘refresh’ their browser at the right moment.

Update #2: I need some advice on how to replicate this issue. I have written a test application and part 2 above does block the operation in part 3, but the consequences for me is that operation 3 just blocks until operation 2 is finished, and then operation 3 finishes.

So that means part 3 takes 1 minute 50 seconds instead of 3 which it normally would. Any ideas why it would be blocking for me, and not creating a deadlock? Could it relate to the amount of database traffic overall on that server seeing as I am using a test server, or could some database settings be affecting it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:28:52+00:00Added an answer on May 25, 2026 at 11:28 am

    There are several ways to avoid dead-locks in general (SQL Server and other database):

    1) Call saveChanges() only at the end of the transaction, to execute all queries together.

    2) Change the order to perform the database update, first perform all reading (SELECT) and last perform all updates.

    3) Perform the readings out of the transaction of the data that would be not modified in the transaction.

    4) Change the isolation level of the transaction to SERIALIZABLE (poor performance) or SNAPSHOT or other intermediate with no locking like READ UNCOMMITTED if application logic allows.

    5) Create synchronized code blocks by using lock(lock_object) to avoid two threads performing same transaction in parallel or performing two different transaction that lock themselves.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF Data Service that exposes an Entity Framework database context and
I have a WCF service that accesses the database and adds data to it.
I have a WCF service that stores and processes images. Consuming applications can download
I have a WCF service that I use in one of my applications. Everything
I have a WCF service that I have to reference from a .net 2.0
I have a WCF Service that should not enter the faulted state. If there's
I have a WCF service that is hosted in a windows application. The service
I have a WCF Service that exposes a method GetCustomers(). The internals of the
I have a WCF service that I call from a windows service. The WCF
I have a WCF service that uses basicHttpbinding in development. Now in product we

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.