Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Function for Debugging Dead Locks

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2008
    Location
    Round Rock, TX
    Posts
    8,842

    Cool Function for Debugging Dead Locks

    Deadlocks (an application hanging when a lock is issued) happens from time to time. This is almost always caused by incorrect alias table settings, but this is difficult to track down. I threw together the attached global function you can add to an application with this issue to track it down. Documentation is included in the package. It's intentionally minimalistic. DebugLock.pkg
    Last edited by Dennis Piccioni; 2-Nov-2015 at 02:40 PM.

  2. #2
    Join Date
    Feb 2009
    Location
    Round Lake, IL
    Posts
    1,882

    Default Re: Function for Debugging Dead Locks

    vBulletin Message

    Invalid Attachment specified. If you followed a valid link, please notify the administrator
    Link did not work.
    Todd Forsberg
    Idealease, Inc.
    Senior Programmer

    Web and Mobile Development: Think Outside the <DIV>

  3. #3
    Join Date
    Feb 2009
    Location
    Round Lake, IL
    Posts
    1,882

    Default Re: Function for Debugging Dead Locks

    I just tried again. Now it downloaded fine. Did you just fix the link a few minutes ago?
    Todd Forsberg
    Idealease, Inc.
    Senior Programmer

    Web and Mobile Development: Think Outside the <DIV>

  4. #4
    Join Date
    Nov 2008
    Location
    Round Rock, TX
    Posts
    8,842

    Default Re: Function for Debugging Dead Locks

    Yep. I actually replaced the original with an updated version.

  5. #5
    Join Date
    Feb 2009
    Location
    Round Lake, IL
    Posts
    1,882

    Default Re: Function for Debugging Dead Locks

    Thanks!
    Todd Forsberg
    Idealease, Inc.
    Senior Programmer

    Web and Mobile Development: Think Outside the <DIV>

  6. #6
    Join Date
    Feb 2009
    Location
    Somewhere in Vermont, USA - unless I'm not
    Posts
    11,076

    Default Re: Function for Debugging Dead Locks

    Thanks for this Dennis!

    A small tweak to work with non-embedded. Add your driver prefix as needed:

    Code:
    Procedure CheckLocks Global Boolean bAliasTablesOnly
        Handle  hTable
        String  sTableName sRootName
        Integer iFileMode
        Boolean bIsAlias
        
        Move 0 to hTable
    
        Repeat
            Get_Attribute DF_FILE_NEXT_OPENED of hTable to hTable
            If (hTable > 0) Begin
                Get_Attribute DF_FILE_LOGICAL_NAME of hTable to sTableName
                Get_Attribute DF_FILE_ROOT_NAME    of hTable to sRootName
                Move (Trim(Uppercase(sTableName))) to sTableName
                Move (Trim(Uppercase(sRootName)))  to sRootName
                If (sRootName contains "SQL_DRV:")  Move (Replace("SQL_DRV:",sRootName,""))  to sRootName
                If (sRootName contains "MSSQLDRV:") Move (Replace("MSSQLDRV:",sRootName,"")) to sRootName
    
                Get_Attribute DF_FILE_MODE of hTable to iFileMode
                
                If (sRootName <> sTableName) Begin
                    Move True to bIsAlias
                End
                Else Begin
                    Move False to bIsAlias
                End
                
                If (bIsAlias or not(bAliasTablesOnly)) Begin
                    Show (String(hTable) + " ")
                    Show ((If(bIsAlias, "(Alias) ","")) + sTableName + ": ")
                    If (iFileMode = DF_FILEMODE_ORIGINAL)         Showln "Original"
                    Else If (iFileMode = DF_FILEMODE_DEFAULT)     Showln "Default"
                    Else If (iFileMode = DF_FILEMODE_NO_REREAD)   Showln "No Reread"
                    Else If (iFileMode = DF_FILEMODE_NO_LOCKS)    Showln "No Locks"
                    Else If (iFileMode = DF_FILEMODE_NO_EDITS)    Showln "No Edits"
                    Else If (iFileMode = DF_FILEMODE_NO_DELETES)  Showln "No Deletes"
                    Else If (iFileMode = DF_FILEMODE_NO_FINDS)    Showln "No Finds"
                    Else If (iFileMode = DF_FILEMODE_NO_CREATES)  Showln "No Creates"
                    Else If (iFileMode = DF_FILEMODE_READONLY)    Showln "Read Only"
                    Else If (iFileMode = DF_FILEMODE_SINGLE_USER) Showln "Single User"
                End
            End
        Until (hTable = 0)
    End_Procedure
    Garret

    Time for an oldie but goodie:

    "If it ain't broke, you're not trying." - Red Green

  7. #7
    Join Date
    Nov 2008
    Location
    Round Rock, TX
    Posts
    8,842

    Default Re: Function for Debugging Dead Locks

    Thanks Garret, good stuff! I'll update it when I get a chance.

  8. #8
    Join Date
    Feb 2009
    Posts
    1,085

    Default Re: Function for Debugging Dead Locks

    What exactly would this produce if an error was indicated?

  9. #9
    Join Date
    Nov 2008
    Location
    Round Rock, TX
    Posts
    8,842

    Default Re: Function for Debugging Dead Locks

    This produces a list of tables that MAY have the wrong lock type. It's up to the developer to look at the information this method provides and determine what is wrong, but it gives you a chance to quickly track down the tables with problems.

    For example, if it shows something like:

    43 Customer: Default
    44 (Alias) Cust2: Default

    and you know that Cust2 is, in fact, an alias table, then the lock type for Cust2 should be "No Locks", not "Default".

    Now you can go and apply the correct alias settings, in this case:

    Set_Attribute DF_FILE_ALIAS of Cust2.File_Number to DF_FILE_IS_ALIAS

    and that should solve (this) locking issue.

  10. #10
    Join Date
    Feb 2009
    Posts
    1,085

    Default Re: Function for Debugging Dead Locks

    ok, I was just confirming, all of my Alias files show No Locks. There is STILL an error as it locks up. I'll continue to look

    John

Page 1 of 2 12 LastLast

Posting Permissions

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