Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

How can I check if I have a lock without locking or unlocking

edited March 10 in OpenInsight

Do you know if it's possible to check in code if I have the lock on a particular record without actually locking or unlocking said record?

I know that I could check this by running the lock or unlock statement, but i'd rather not, as I want to only check. Running either of the above statements will have the side effect that I lock and unlock the record.

To give you some background:

as you know, the internal tool that Revelation provides to check locks doesn't work (It causes our entire system to crash. We had a person from Revelation come to our office to fix it, but he couldn't fix it...)

So the idea is to have each workstation (inside of the TIMER EVENT) check if it has the lock.

Also, RTI_Lock_Owner doesn't work. We have tested it, and it just doesn't work.


  • This question was asked recently on the Revelation forum by our friend M@. He didn't get a response from Revelation but our other friend Barry Stevens suggestion RTI_Lock_Owner. I'm not sure if this gave M@ what he needed.

    We are aware that RTI_Lock_Owner is unreliable, especially with older versions of the UD (v4 and earlier). There is a lower level routine called RTI_LH_INFO that is supposed to be more reliable, but we have still found some issues with it.
  • ok thanks. We will just use the unlock statement. It's not ideal, but it will do.

  • What I did was first check if there is an active connection to the Linear Hash service (v4.7.2). If so then I'll use RTI_Lock_Owner() to determine the lock status; otherwise I'll test the lock manually.
    isLocked = false$ lockStatus = '' If SRP_Array( 'Join', NTSserial()< 2>, 'N/A', 'NOT', @vm) != '' then // Get lock info directly from the active LH service lockOwner = RTI_Lock_Owner( dataFile, dataId) If lockOwner != '' then isLocked = true$ lockStation = field( lockOwner, '*', 3) ;// assuming LH v4.7.2 lockStatus = (lockStation == @station) End end else // Test the lock manually Open dataFile to lockFv then Lock lockFv, dataId then lockStatus = status() Unlock lockFv, dataId else null isLocked = true$ End End End
    The NTSserial() function will return the server names and LH service serial number for the attached files. I found that calling RTI_Lock_Owner (or List_User_Locks)) can add any servers it finds to this list, even for files not attached! That's why in the code above, RTI_Lock_Owner() is only used if there are no instances of a server without a service.

    Also, while RTI_Lock_Owner() can tell you the lock status without producing a temporary physical lock, it is veeery sloow compared to just a Lock statement (probably because of the network interrogation it does). Its use seems to degrade performance of the LH service, affecting all sessions (at least for locking).

    HTH, M@
Sign In or Register to comment.