User details.

ron

Member
Hi,

If I have a long-running DB transaction I can get details like tty and PID. How can I match this with QAD details to identify the "real" user?

The usercount.log has information - but I can't see how to connect it with details from OE.

Can anyone help me?

Ron.
 

DiegoQAPPS

New Member
Hi Ron, if you still have this issue here is the solution:

lockeos
Code:
/* findLockCulprit.p
Finds the user who is locking a record and causing others to wait. */
DEFINE TEMP-TABLE ttLocks NO-UNDO LIKE _Lock
INDEX byRecid IS PRIMARY
_Lock-RecId ASCENDING
_Lock-Table ASCENDING.
DEFINE BUFFER culprit FOR ttLocks.
/* Access to _Lock is slow, so copy _Lock to an indexed temp-table ttLocks first. */
FOR EACH _Lock WHILE _Lock._Lock-table <> ?:
CREATE ttLocks.
BUFFER-COPY _Lock TO ttLocks.
END.
FOR EACH ttLocks WHERE ttLocks._Lock-Flags MATCHES "*Q*":
/* Do the FIND's with NO-ERROR, as the lock table is just a snapshot of very volatile data... */
FIND FIRST culprit WHERE culprit._Lock-RecId = ttLocks._Lock-RecId
AND culprit._Lock-Table = ttLocks._Lock-Table
AND NOT culprit._Lock-Flags MATCHES "*Q*"
NO-ERROR.
IF AVAILABLE culprit THEN DO WITH SIDE-LABELS TITLE " Users holding other users records ":
FIND _Connect WHERE _Connect._Connect-Usr = culprit._Lock-Usr NO-ERROR.
IF AVAILABLE _Connect AND _Connect._Connect-TransId <> 0 THEN
FIND _Trans WHERE _Trans._Trans-Usr = _Connect._Connect-Usr NO-ERROR.
ELSE /* Ensure no _Trans record is available. */
RELEASE _Trans NO-ERROR.
FIND _File WHERE _File._File-num = culprit._Lock-Table NO-LOCK NO-ERROR.
DISPLAY culprit._Lock-Usr   COLON 17
culprit._Lock-Name  COLON 17
_Connect._Connect-Device WHEN AVAILABLE _Connect LABEL "On"
culprit._Lock-Table COLON 17 LABEL "Table" FORMAT "ZZ,ZZ9"
_File._File-Name WHEN AVAILABLE _File NO-LABEL
culprit._Lock-RecID COLON 17
culprit._Lock-Type  COLON 17 LABEL "Lock type"
culprit._Lock-Flags
.
IF AVAILABLE _Trans THEN
DISPLAY _Trans._Trans-State  COLON 17
_Trans._Trans-Txtime COLON 17 "Transaction start"
.
IF AVAILABLE _Connect THEN
DISPLAY _Connect._Connect-Type COLON 17 LABEL "Client type"
_Connect._Connect-Time COLON 17
.
END.
END.
 
Last edited by a moderator:

Cringer

ProgressTalk.com Moderator
Staff member
Doing anything with _lock in a real production system is a recipe for disaster.
 

ron

Member
Thank you for that! I'll have a bit of a play, later.

However - that wasn't the crux of my problem. And I did solve the problem. I discovered that field mon__qadi01 in the mon_mstr record holds the database "usr" number. That allowed me to identify the user who had set the record lock -- and that was my "missing link".
 

Rob Fitzpatrick

ProgressTalk.com Sponsor
I would suggest changing the _connect query so it is bracketed rather than a table scan. Change:
Code:
FIND _Connect WHERE _Connect._Connect-Usr = culprit._Lock-Usr NO-ERROR.
to
Code:
FIND _Connect WHERE _Connect._Connect-id = culprit._Lock-Usr + 1 NO-ERROR.
Also, if this code were to be run in a federated application (more than one database), you would want to first set the database alias as appropriate, and qualify all VST and schema table references with "dictdb.".
 

Rob Fitzpatrick

ProgressTalk.com Sponsor
Doing anything with _lock in a real production system is a recipe for disaster.
Agreed, if you are not on a late 11.x or a 12.x release.

I would also be careful if -L is large. There are systems out there with -L in the hundreds of thousands or millions. This code would result in a large temp-table.
 

Cringer

ProgressTalk.com Moderator
Staff member
Agreed, if you are not on a late 11.x or a 12.x release.
Agree with the version caveat, although with this being QAD, chances are high it's not a modern release. ;)
 

ron

Member
This problem has been solved. The detail I was after - and finally found - was that the Progress "usr" is stored in mon__qadi01 in table "mon_mstr". That allowed me to get the "real" user (known to QAD).
 
Top