Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sam Gooch 24 posts 116 karma points
    Mar 31, 2021 @ 17:08
    Sam Gooch
    0

    I'm seeing a few SQL deadlocks and wanted to ask if its something which we're doing wrong?

    We're calling 2 methods one after another. Both of which create their own unit of work using the IUnitOfWorkProvider and call the Complete() method on each unit of work.

    Method1();
    Method2();
    

    The deadlock exception is thrown in Method1.

    The site receives quite high traffic and is hosted in Azure. Database is an S2 database (as per Umbraco's recommendations). Running Umbraco v8.10.1, Vendr v1.5.2.

    Any ideas what could be causing this?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Mar 31, 2021 @ 18:46
    Matt Brailsford
    0

    Hey Sam,

    It’s hard to say completely without knowing what’s happening in Method1 and Method2, but assuming they do something that touches the same DB table, it’s highly likely under load that this will result in a deadline in your current setup.

    Because each method is running in its own uow, rather than a shared one, you probably have someone with an open transaction in one method needing the resource and someone with an open transaction in the other also needing it and so you get a deadlock.

    Generally speaking, you’d usually want a single transaction or uow per request (nested uow are fine as they join the same transaction). This ensures that it can’t even attempt any single action unless it can access the resources and should prevent the deadlock.

    So yea, it’s likely miss-use of uow’s can cause a deadlock, but I can’t really say where without more info.

    Hope this helps

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft