SELECT CUSTFILE
ASSIGN TO CUST
ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM
RECORD KEY IS PRIMARY-KEY
Before the file was opened by the COBOL program, the following lock was already held:
Type Status Elapsed Owns Waits Scope Qname Rname
SHRD OWNS 46.31031 2 SYSTEM SYSDSN USERID.CUST.KSDS
When the KSDS file was opened in INPUT mode, additional locks with Qname=SYSVSAM were dynamically acquired. These locks remained active for the duration of the file being open and were automatically released when the file was closed.
Type Status Elapsed Owns Waits Scope Qname Rname
SHRD OWNS 1.404245 2 SYSTEM SYSVSAM USERID.CUST.KSDS.INDEXICF.CATALOG.PROD4...I
SHRD OWNS 1.404669 2 SYSTEM SYSVSAM USERID.CUST.KSDS.DATAICF.CATALOG.PROD4...I
SHRD OWNS 1.409698 2 SYSTEM SYSVSAM USERID.CUST.KSDSICF.CATALOG.PROD4...N
SHRD OWNS 00:01:09 2 SYSTEM SYSDSN USERID.CUST.KSDS
Test 2 : Locking Behavior of a KSDS File Accessed Through Alternate Key-1 in INPUT mode
The COBOL program contained the following SELECT statement, which defined both the primary key and an alternate key:
SELECT CUSTFILE
ASSIGN TO CUST
ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM
RECORD KEY IS PRIMARY-KEY
ALTERNATE RECORD KEY IS ALTERNATE-KEY1
Since the program uses Alternate Key-1, both the KSDS base cluster and the corresponding PATH dataset must be provided in the JCL.
Before the file was opened by the COBOL program, the following locks were acquired:
Type Status Elapsed Owns Waits Scope Qname Rname
SHRD OWNS 38.09832 1 SYSTEM SYSDSN USERID.CUST.PATH1
SHRD OWNS 38.09832 1 SYSTEM SYSDSN USERID.CUST.KSDS
When the file was opened in INPUT mode, additional SYSVSAM locks were dynamically acquired. These locks remained active while the file was open and were released automatically when the file was closed.
Type Status Elapsed Owns Waits Scope Qname Rname
SHRD OWNS 00:02:01 1 SYSTEM SYSVSAM USERID.CUST.KSDSICF.CATALOG.PROD4...N
SHRD OWNS 00:02:01 1 SYSTEM SYSVSAM USERID.CUST.KSDS.INDEXICF.CATALOG.PROD4...I
SHRD OWNS 00:02:01 1 SYSTEM SYSVSAM USERID.CUST.KSDS.DATAICF.CATALOG.PROD4...I
SHRD OWNS 00:02:01 1 SYSTEM SYSVSAM USERID.CUST.AIX1.INDEXICF.CATALOG.PROD4...I
SHRD OWNS 00:02:01 1 SYSTEM SYSVSAM USERID.CUST.AIX1.DATAICF.CATALOG.PROD4...I
SHRD OWNS 00:02:54 1 SYSTEM SYSDSN USERID.CUST.PATH1
SHRD OWNS 00:02:54 1 SYSTEM SYSDSN USERID.CUST.KSDS
Test 3 : Locking Behavior of a KSDS File Accessed Through Alternate Key-1 in I-O mode
The COBOL program contained the following SELECT statement, which defined both the primary key and Alternate Key-1:
SELECT CUSTFILE
ASSIGN TO CUST
ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM
RECORD KEY IS PRIMARY-KEY
ALTERNATE RECORD KEY IS ALTERNATE-KEY1
Since the program accesses the file using Alternate Key-1, both the KSDS base cluster and the corresponding PATH dataset must be specified in the JCL.
Before the file was opened by the COBOL program, the following locks were acquired:
Type Status Elapsed Owns Waits Scope Qname Rname
SHRD OWNS 30.81659 1 SYSTEM SYSDSN USERID.CUST.PATH1
SHRD OWNS 30.81659 1 SYSTEM SYSDSN USERID.CUST.KSDS
When the file was opened in I-O mode, VSAM dynamically acquired the following SYSVSAM locks. These locks remained in effect until the file was closed, at which point they were automatically released.
Type Status Elapsed Owns Waits Scope Qname Rname
SHRD OWNS 1.715577 1 SYSTEM SYSVSAM USERID.CUST.KSDS.INDEXICF.CATALOG.PROD4...I
SHRD OWNS 1.715260 1 SYSTEM SYSVSAM USERID.CUST.KSDS.INDEXICF.CATALOG.PROD4...O
SHRD OWNS 1.716168 1 SYSTEM SYSVSAM USERID.CUST.KSDS.DATAICF.CATALOG.PROD4...O
SHRD OWNS 1.716495 1 SYSTEM SYSVSAM USERID.CUST.KSDS.DATAICF.CATALOG.PROD4...I
EXCL OWNS 1.693842 1 SYSTEM SYSVSAM USERID.CUST.AIX1.INDEXICF.CATALOG.PROD4...I
EXCL OWNS 1.693445 1 SYSTEM SYSVSAM USERID.CUST.AIX1.INDEXICF.CATALOG.PROD4...O
EXCL OWNS 1.694132 1 SYSTEM SYSVSAM USERID.CUST.AIX1.DATAICF.CATALOG.PROD4...O
EXCL OWNS 1.694345 1 SYSTEM SYSVSAM USERID.CUST.AIX1.DATAICF.CATALOG.PROD4...I
EXCL OWNS 1.705077 1 SYSTEM SYSVSAM USERID.CUST.AIX2.DATAICF.CATALOG.PROD4...I
EXCL OWNS 1.704877 1 SYSTEM SYSVSAM USERID.CUST.AIX2.DATAICF.CATALOG.PROD4...O
EXCL OWNS 1.704285 1 SYSTEM SYSVSAM USERID.CUST.AIX2.INDEXICF.CATALOG.PROD4...O
EXCL OWNS 1.704550 1 SYSTEM SYSVSAM USERID.CUST.AIX2.INDEXICF.CATALOG.PROD4...I
SHRD OWNS 1.722668 1 SYSTEM SYSVSAM USERID.CUST.KSDSICF.CATALOG.PROD4...N
SHRD OWNS 1.688906 1 SYSTEM SYSVSAM USERID.CUST.KSDSICF.CATALOG.PROD4...P
SHRD OWNS 38.02660 1 SYSTEM SYSDSN USERID.CUST.PATH1
SHRD OWNS 38.02660 1 SYSTEM SYSDSN USERID.CUST.KSDS
JCL specifies DISP=SHR for both the KSDS base cluster and the PATH dataset, while the COBOL program opens the file in I-O mode.
Under these conditions, when the COBOL program attempts to open the VSAM file for update (I-O mode), the OPEN operation will fail with file status 93 (resource unavailable) if another job or user already has the base cluster or any of its alternate indexes open.
To prevent this situation and ensure exclusive update access, the JCL should specify DISP=OLD for both the KSDS base cluster and the associated PATH dataset.
JCL specifies DISP=SHR for a sequential dataset, while
the COBOL program updates the file in I-O mode.
In this scenario, the initiator acquires a shared ENQ
on the dataset during job initialization. When the COBOL program subsequently
opens the file in I-O mode and proceeds to update the dataset, the
dataset continues to be protected only by the existing shared lock; no
exclusive serialization is established.
As a result, another job or user can concurrently open the
same dataset in INPUT mode while updates are being performed by the
COBOL program. This concurrent access may expose readers to in-flight changes
and can lead to data integrity or consistency issues.
To prevent such situations, datasets that are updated by a COBOL
program should be allocated with DISP=OLD in the JCL. This ensures
exclusive access to the dataset throughout the job step and prevents other jobs
or users from accessing the file while update processing is in progress.