Introduction

The M Lock Utility (LKE) is a tool for examining and changing the GT.M LOCK environment. For a description of M LOCKs, refer to the LOCKs section in the General Language Features of M chapter and the description of the LOCK command in the Commands chapter of the GT.M Programmer's Guide.

The two primary functions of the M Lock Utility (LKE) are:

  1. SHOW all or specified LOCKs currently active

  2. CLEAR all or specified LOCKs currently active

When debugging an M application, you may use LKE to identify a possible deadlock situation, that is, two or more processes have LOCKs and are waiting to add resource names LOCKed by the other(s).

Process 1   Process 2
LOCK A     
            LOCK B
            LOCK +A
LOCK +B

Process 1 has A LOCKed and attempts to LOCK B. Process 2 has B LOCKed and attempts to LOCK A. Because these processes do not release their current LOCKs before adding additional LOCKs, nor do they provide a timeout to detect the problem, they are deadlocked. Neither process can proceed normally. You can use LKE to release one of the LOCKs so both processes may execute. However, because releasing a LOCK may cause the process to violate its design assumptions, terminating one process is generally a safer way to break the deadlock.

[Note] Note

When a process leaves M, GT.M normally releases any LOCKs or ZALLOCATEs held by that process. If a GT.M process terminates abnormally, or if the system "crashes" while a GT.M process is active, GT.M cannot perform normal clean-up. However, as soon as any other process waits several seconds for a LOCK owned by a process that no longer exists, GT.M automatically clears the "orphaned" LOCK.

To Invoke and Exit LKE

GT.M installation procedure places the LKE utility package in a directory specified by the environment variable gtm_dist.

LKE requires that the environment variable gtmgbldir be defined.

Invoke LKE using the following command at the shell prompt. If this does not work, consult your system manager to investigate setup and file access issues.

$gtm_dist/lke LKE>
[Important] Important

Always run LKE on the node where the lock is held.

When LKE is ready to accept commands, it displays the LKE> prompt. To leave LKE, enter the EXIT command at the LKE> prompt.

When additional information is entered on the command line after the LKE command, LKE processes the additional information as its command.

$gtm_dist/lke show -all

This command displays all current LOCKs and then returns to the shell prompt.

If your LKE argument contains quotes, precede each quote in the argument by a back-slash (\) or enclose the entire argument in a set of quotes (matching single or double). Apply this convention only for those LKE commands that you run from the shell.

$gtm_dist/lke show -lock="^Account(\"Name\")"
$gtm_dist/lke show -lock='^Account("Name")'

Both these commands display the status of LOCK ^Account("Name") in the default region.

To establish a Global Directory

LKE uses the environment variable gtmgbldir to identify the active global directory. gtmgbldir should be defined by individual users in their login files.

$ gtmgbldir=prod.gld 
$ export gtmgbldir