1 Attachment(s)
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. [ATTACH]9395[/ATTACH]
Re: Function for Debugging Dead Locks
[QUOTE][B]vBulletin Message[/B]
[COLOR=#000000]Invalid Attachment specified. If you followed a valid link, please notify the [/COLOR][URL="http://support.dataaccess.com/Forums/sendmessage.php"]administrator[/URL][/QUOTE]
Link did not work.
Re: Function for Debugging Dead Locks
I just tried again. Now it downloaded fine. Did you just fix the link a few minutes ago?
Re: Function for Debugging Dead Locks
Yep. I actually replaced the original with an updated version.
Re: Function for Debugging Dead Locks
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
[/code]
Re: Function for Debugging Dead Locks
Thanks Garret, good stuff! I'll update it when I get a chance.
Re: Function for Debugging Dead Locks
What exactly would this produce if an error was indicated?
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.
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