Mvsckey Not | Found Exclusive Link
Technical Report: "mvsckey not found exclusive" Error Analysis
Date: October 26, 2023
Subject: Analysis of Runtime Error: mvsckey not found exclusive
The Fix
- Modified the delete transaction to commit immediately via
EXEC CICS SYNCPOINT. - Changed batch job to use
SHAREOPTIONS(3,3)and added a 3-second retry loop on NOTFND. - Added console logging to identify which transaction held the lock.
Result: Error eliminated for 18 months running.
1. GRS Contention on a “Fake” Key Resource
Some subsystems use a dummy resource named after a storage key (e.g., MVSKEY.1) to serialize access to programs running in that key. If a job holds an exclusive ENQ (e.g., SYSZDD R MVSKEY.1 EXCL), any subsequent request for exclusive control of the same resource will fail with “NOT FOUND EXCLUSIVE.” mvsckey not found exclusive
How to Diagnose
When you see this error (typically in SYSLOG, job output, or an SVC dump):
- Check the full message ID. Look for a preceding component ID such as
IGW,DFS, orGRS. For example:IGW400E MVSKEY NOT FOUND EXCLUSIVE FOR KEY=5 - Identify the failing module. Use
SLIPtraps orSYSUDUMPto locate the instruction address. - Examine GRS status. Issue the operator command:
Replace/D GRS,RES=(MVSKEY.5)5with the actual key number. This shows current holders and waiters. - Review lock duration. If a batch job holds the lock abnormally long, consider canceling it after consulting with application owners.
6. Prevention & Best Practices
- Always check file status after every VSAM operation.
- COBOL:
IF FILE-STATUS = '23'(record not found) - Do not assume record exists before exclusive read.
- COBOL:
- Use standard file status codes instead of custom messages.
- In CICS:
- Use
RESPandRESP2to differentiate betweenNOTFNDand exclusive-control errors.
- Use
- Avoid exclusive read unless necessary — use shared read then promote to exclusive with
REWRITE/DELETE. - Implement retry logic for transient concurrency conflicts.
Step 5: Check for CICS ENQ Contention
In CICS, use CEMT I TASK to see if another transaction holds an exclusive ENQ on the same record or file. The error may be a side effect of a timeout: the key was missing or the exclusive enqueue timed out, returning the same message. Modified the delete transaction to commit immediately via
2. Error Deconstruction
To understand the root cause, the error message can be parsed into three distinct components:
mvsckey: This is the target identifier (Key). It likely refers to a "Multi-Variable Session Key," "Master Validation Security Key," or a similar application-specific token. The system is attempting to find this key in a database, cache, or configuration file.not found: The lookup operation returned a null or empty result. The key does not exist in the expected location, has expired, or was never created.exclusive: This is the modifier causing the critical failure. It implies the operation requires an Exclusive Lock (write mode) or guarantees that no other process can access the resource simultaneously. Because the operation required high-level permissions (exclusive access) to ensure data integrity, the inability to find the key triggered a hard stop rather than a retry or fallback.
5. Resolution Approaches
| Cause | Solution |
|-------|----------|
| Wrong key value | Correct program logic. Validate key from input or computation. |
| Record deleted | Add existence check before exclusive lock, or handle NOT FOUND gracefully. |
| Intent logic error | Change design: first issue a READ without exclusive lock to verify record exists, then if needed, re-read with exclusive lock (but beware of race conditions). |
| Concurrency | Use CICS ENQ, VSAM RECOVERY, or transaction serialization. |
| Buggy custom macro | Debug or replace with standard VSAM access methods (COBOL READ... WITH LOCK). | Result: Error eliminated for 18 months running
Part 4: Step-by-Step Diagnosis
You’re on call. A batch job abends with B37-04 or a CICS transaction dumps with an ASRA abend containing "MVSCKEY NOT FOUND EXCLUSIVE." What now?