Results 1 to 7 of 7

Thread: Locking Order between Embedded-db vs CK-drivers

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009
    Location
    Brazil
    Posts
    4,691

    Default Locking Order between Embedded-db vs CK-drivers

    I've heard several times, here in this forum, that one of DF strategies to avoid dead-locks in embedded db, is by locking the tables always in the same sequence (aka, filelist order).

    I am not finding that sentence in the docs, but I believe it's true, as I've never seen a deadlock happeing under embeeded-db scenarios except when you have bad alias configurations.

    That's effecive under native-db (dat) tables as the only lock-level possible is the entire table.

    Now, Question #1 is: Is this still true/valid behavior when using any CK-Drivers / SQL backends? I thought it was.. But it does not seems to be the case.

    I've just analyzed a deadlock situation here between 2 tables (Country / State) , between two different apps/views, but using the same filelist/db .

    App1, locked Country (Id 31) first, and was trying to lock State (Id 42) later.
    App2, did the opposite.. locked State (Id 42) first, and was trying to lock Country (id 31) later.

    A typical/simple deadlock scenario.

    I thought the same logic for locking ordering would apply here, even when using CK-drivers.. If it would that deadock could be avoided for sure..

    So, question #2: If such ordering is not enforced, what constrols that ? The DDO structure hierachy is exactly the same between both.. just different table present at the bottom, as the 2 views have different puprposes. But when reaching the top level of the DDO hierarchy, they all tends to be the same, common parents.. and Country is allways parent of State, no matter what.

    If the locks are made when rereading the rows , and if that uses the DDO hirerachy, locking Country before locking State should never happen..
    So I'm puzzled again.

    Can we have some clarification here on how this really works behind the scenes. ?

    This is totally standard view with DDO structures.. No custom code present, and neither manual locks/rereads/transactions involved .


    Regards
    Last edited by Samuel Pizarro; 13-Nov-2022 at 02:17 PM.
    Samuel Pizarro

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •