This topic provides general guidelines for maintaining
locked records in ClearQuest.
Scanning to find locked records
It is good
practice to scan the database for locked records on a regular basis.
To find locked records, create and run a query that identifies the
records and the users that hold each lock. When you find the locked
records, take the appropriate action to remove the locks, if needed.
Unlocking records with a timeout feature
You
can create a script that allows you to identify locked records and
unlock them automatically. A timeout script should perform these tasks:
- Collect the set of record types defined by the schema.
- Build a data structure that identifies all the locked records
for each record type. The structure should include information such
as the user that holds the lock, the version that is locked, and the
time that the lock was observed. This structure is initially empty.
- Build a query to find records that are currently locked, selecting
the record ID, locked_by and lock_version columns.
- Compare the current set of locked records with those already known
and recorded in the data structure. This check must include a match
on both the locking user and the version of the record that was locked,
in order to distinguish locks by the same user but on a new version
of the record or by a different user.
- Remove locks that have been held longer than a chosen interval,
by loading the entity and calling the Unlock API method.
- Update the data structure to add references to records that are
found to be newly locked and remove references to records that are
no longer locked.
The script should also log its activity or notify users
when it removes a lock they were holding.
The script should
be set to run at regular intervals. The chosen timeout interval and
the frequency that the script performs a scan will determine the minimum
and maximum expected time for a lock to timeout. These values should
be made known to users, since they affect:
- how long a user can work on editing a record before losing their
lock.
- how long a user must wait for an abandoned lock to be released
automatically.
Using findrecordlocks_pl for lock maintenance
Rational
ClearQuest includes a findrecordlocks_pl script that you can use to
find record locks and set timeout locks. For more information and
instructions to use the script, see the reference page for findrecordlocks.pl.