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
Comments
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:
<FONT COLOR="#0000ff">#dim </FONT><FONT COLOR="#800000">rs </FONT><FONT COLOR="#0000ff">As </FONT><FONT COLOR="#008080">%ResultSet
</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">pid</FONT><FONT COLOR="#000000">=4652
</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">rs</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%ResultSet</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"%SYS.ProcessQuery:VariableByPid"</FONT><FONT COLOR="#000000">)
</FONT><FONT COLOR="#0000ff">f </FONT><FONT COLOR="#800000">filter</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">""</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"a*" </FONT><FONT COLOR="#800080">{
</FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#000000">!,</FONT><FONT COLOR="#008000">"Filter = "</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#0000ff">$$$quote</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">filter</FONT><FONT COLOR="#000000">),!
</FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#800000">rs</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Execute</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">pid</FONT><FONT COLOR="#000000">,,,,</FONT><FONT COLOR="#800000">filter</FONT><FONT COLOR="#000000">)
</FONT><FONT COLOR="#0000ff">while </FONT><FONT COLOR="#800000">rs</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Next</FONT><FONT COLOR="#000000">() </FONT><FONT COLOR="#800080">{
</FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"Name = "</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">rs</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Get</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"Name"</FONT><FONT COLOR="#000000">),</FONT><FONT COLOR="#008000">", Value = "</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">rs</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Get</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"Value"</FONT><FONT COLOR="#000000">),!
</FONT><FONT COLOR="#800080">}
}</FONT>Result:USER:4652><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">a</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"11"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">b</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"22"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">a1</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"33" </FONT><FONT COLOR="#0000ff">w $job</FONT> 4652USER:1392><FONT COLOR="#0000ff">w $job</FONT><FONT COLOR="#000000">,! </FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">^dc</FONT> 1392
Filter = "" Name = a, Value = 11 Name = a1, Value = 33 Name = b, Value = 22
Filter = "a*" Name = a, Value = 11 Name = a1, Value = 33
Would process user not cut it?
You can later convert it into app user if you have 1:1 matching.
It would work faster than getting local variables.