Question
· Feb 14, 2019

Accessing the lock table and another process's variables, potentially on a different server

Hi Community,

I have a need to access the Lock Table to find the Process ID of the process that has a particular global node Locked. The process holding the lock could be on any one of four application servers.

Having identified the Process ID, I then need to interrogate the local variables for that process, to find an application User ID.

I can then inform the current user which of their colleagues has a particular record locked, preventing them from continuing with their work...

Are these things I can do under Caché? If so, how would I do so?

In any answers, please bear in mind that I am mostly just a fusty old MUMPS programmer, from what increasingly seems like the dark ages, who did most of his coding in DSM for Open VMS!

Thanks,

Adrian

Discussion (6)0
Log in or sign up to continue

Thanks for the pointers, and I have located those in the documentation.

However, if I follow that, I get:

HCSLIVE>S Rset=##class(%ResultSet).%New("%SYS.LockQuery:List")

IHCSLIVE>zw

Rset=<OBJECT REFERENCE>[1@%Library.ResultSet]

IHCSLIVE>zw Rset

Rset=<OBJECT REFERENCE>[1@%Library.ResultSet]

IHCSLIVE>D Rset.Execute("")

IHCSLIVE>zw

Rset=<OBJECT REFERENCE>[1@%Library.ResultSet]

IHCSLIVE>zw Rset

Rset=<OBJECT REFERENCE>[1@%Library.ResultSet]

IHCSLIVE>W $O(Rset(""))

IHCSLIVE>

i.e. there doesn't seem to be anything there I can work with.

I suspect that I lack some basic understanding of working with classes...

Thanks,

Adrian

Hi Vitaliy,

Thanks again for your ongoing help with this.

I have now accessed the Lock Table (on the current node, anyway), and identified the PID of the process that has the Lock that I am interested in.

I can see from the help how to use %SYS.ProcessQuery:VariableByPid

However, if I try -

S Vars=##class(%ResultSet).%New("%SYS.ProcessQuery:VariableByPid(6460,zPRS)")

which I know from the System Management Portal exists for that PID, and therefore would have expected to return the value of zPRS from PID 6460, I don't get what the help seems to indicate -

IHCSLIVE>W Vars.zPRS
^
<INVALID OREF>

I guess I'm still missing something fundamental?

Thanks,
Adrian
(btw, this is my first-ever foray into Caché's world of classes and objects - essentially, I am "just" an old MUMPSter)

Hi Adrian.

Made a small example:

#dim rs As %ResultSet
   
pid=4652
   
rs=##class(%ResultSet).%New("%SYS.ProcessQuery:VariableByPid")
   
filter="","a*" {
 !,"Filter = ",$$$quote(filter),!
 rs.Execute(pid,,,,filter)
 while rs.Next() {
   "Name = ",rs.Get("Name"),", Value = ",rs.Get("Value"),!
 }
}

Result:

USER:4652>a="11",b="22",a1="33" w $job
4652

USER:1392>w $job,! ^dc
1392
 
Filter = ""
Name = a, Value = 11
Name = a1, Value = 33
Name = b, Value = 22
 
Filter = "a*"
Name = a, Value = 11
Name = a1, Value = 33