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

  • SEARCH
  • Home
  • 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 6121895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:50:09+00:00 2026-05-23T15:50:09+00:00

I have been having deadlock issues. I’ve been on working some retry approaches. My

  • 0

I have been having deadlock issues. I’ve been on working some retry approaches. My retry code is currently just a ‘for’ statement that tries 5 times. I understand i need to use the ‘Evit’ nhibernate method to clear the session. I am using a session factory and use a transaction for each request.

In the below example if i experience a deadlock on the first retry will the orderNote property remain the same on the second retry?

private ActionResult OrderDetails(int id)
{
    var order = _orderRepository.Get(id);
    order.OrderNote = "will this text remain";

    Retry.Times(5).Do(() => _orderRepository.Update(order));

    return View();
}

Edit

1) Finding it hard to trace the cause. I’m getting about 10 locks a day all over my application. Just set up a profiler. Are there any other useful methods for tracing

http://msdn.microsoft.com/en-us/library/ms190465.aspx

I think the main issue is that i’m using auto increament. I’m in the process of moving to hilo.

2) Using a different transation mode. I’m not defining any at the moment. What is recommended.

5) Long running operations. Yes i do. And i think because i’m using auto increament lazy loading is ignored. Does that sound correct?

  • 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-23T15:50:10+00:00Added an answer on May 23, 2026 at 3:50 pm

    In my opinion your code is trying to fix the symptoms instead of the cause.

    You will be better off doing some of the following things:

    1. Find out why you are getting deadlocks and fix the core issue
    2. Use a different transaction mode to read past locks
    3. Look at delegating the update into a queue structure to be background processed
    4. Understand the update execution plan and perhaps add indexing to speed up queries
    5. Do you have any “long” running operations in your Controller action which is keeping the transaction open for longer than it should be?
    6. Even if the operation did deadlock, why don’t you return an friendly error back to the calling page and let them manually retry.

    Update:

    1.) Useful methods for tracing

    I have used this method for tracing deadlocks which should give you an idea of the resources which are in contention: Tracing Deadlocks

    You can also look at the concurreny models available to you: NHibernate Concurrency

    2.) Transaction Isolation Levels

    Depending on your DB this Question has some useful information: Transaction Isolation Mode

    3.) Long Running Operations

    I have to use Identity Columns as my primary keys in NHibernate and I don’t think these are going to be source of your problem in an update scenario as the Id/PK is already set by this point. Try to minimise the long running operations which will shorten the amount of time your transaction is held open.

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

Sidebar

Related Questions

I have been having some issues with LINQ-To-SQL around memory usage. I'm using it
I have been having some issues retrieving JSON data from a WCF service application
I have been having some trouble finding a good way to output just the
I have been having intermittent issues on some servers running Archlinux / php-fpm 5.3.9
I have been having some issues with django-haystack and need some help. I run
I have been having some trouble working with inner joins I guess: select count(distinct
I have been having some problems trying to get my PHP running. When I
We have been having some debate this week at my company as to how
This is a really weird problem that I have been having. When I download
As many of you may already know I have been having issues with another

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.