Progress/400
Product Guide
Record Locking
The Progress RDBMS supports three lock states at the record level: EXCLUSIVE-LOCK, SHARE-LOCK, and NO-LOCK. The Progress/400 DataServer supports either these three lock states or, if you choose, the standard DB2/400 lock states LOCK and NO-LOCK. This section describes how to implement either form of record locking at the dictionary library level.
Standard Progress Locks
To support the standard Progress locking technique, the Progress/400 DataServer accesses a Progress lock table object on the AS/400. If the lock table is not present, Progress locking behavior is not supported. The lock table locks records for the physical files that are defined as part of the Progress/400 server schema. It ensures that DB2/400 records accessed by Progress applications are locked in the same manner as records on other Progress platforms.
However, the lock table applies only for Progress 4GL applications. Non-Progress languages (for example, RPG) accessing a Progress/400 dictionary library use the IBM locks LOCK and NO-LOCK. The DataServer issues a DB2/400 lock when it issues a Progress EXCLUSIVE-LOCK. Therefore, the Progress/400 lock table does not ensure that records are locked against access by non-Progress applications.
See the "Additional Locking Considerations" section for information about factors that affect record locks in DB2/400. See the chapter on transactions in the Progress Programming Handbook for more information on Progress locks.
Creating and Maintaining the Progress/400 Lock Table
The Progress/400 lock table is an OS/400 object of the *USRSPC type with the LOCK attribute. Its name is PROLKT.
The lock table has an initial default value of 500 lock table entries. A lock table entry is required for each currently locked record and for each user (transaction) that is waiting for a locked record (both EXCLUSIVE-LOCK and SHARE-LOCK).
In a Progress database, the lock table exists only during an active Progress session; the Progress/400 lock table object exists until you explicitly delete it, whether or not there is an active Progress session. You are restricted to one lock table per Progress/400 server schema.
To create or modify a lock table, use the Progress/400 Create Lock Table (CRTPROLKT) utility. Use this OS/400 syntax to create a lock table or to change the number of lock table entries:
Table 2–6 describes the CRTPROLKT parameters.
You can also create a lock table when you run the DUPPRODB utility. Enter *YES for the Create Progress Lock Table parameter. To delete the lock table, delete the OS/400 *USRSPC object.
Standard DB2/400 Locks
Locking on the AS/400 is handled by the DB2/400 record management system. The DB2/400 record management system views a record as having a LOCK or a NO-LOCK. If you use standard DB2/400 locks with Progress applications, an EXCLUSIVE-LOCK is implemented as a DB2/400 LOCK, and SHARE-LOCK and NO-LOCK are implemented as DB2/400 NO-LOCK.
SHARE-LOCK Implications
When you implement standard DB2/400 locks instead of standard Progress locks, you might encounter problems with applications that depend on Progress SHARE-LOCKs. For example, if the program PGM-A has a record under EXCLUSIVE-LOCK, and the program PGM-B requests the same record (SHARE-LOCK), the Progress/400 DataServer allows PGM-B access to the record. You will have a problem if PGM-A updates the record and releases the lock, and PGM-B then updates the record based on the old data. To resolve this problem, explicitly specify EXCLUSIVE-LOCK when you read records for update.
Additional Locking Considerations
This section lists additional considerations about OS/400 locking:
- When you implement Progress locks in the OS/400 environment, the Progress locks apply only for other Progress applications. The DataServer implements the EXCLUSIVE-LOCK as an OS/400 LOCK. The standard OS/400 lock rules apply for non-Progress applications. This is an important factor because OS/400 locks one record per file, while the DataServer can read and lock more than one record. The following example illustrates how this can affect your applications:
OS/400 locks one record per file except when multiple records are locked in one file, commitment control is active, and a transaction is pending.
Table 2–7 shows how locks for records accessed by this procedure are implemented.
Progress/400 applications view record 1 as locked throughout the entire procedure, but OS/400 sees record 1 as locked only until record 2 is read.
- OS/400 supports five object-level lock states: EXCLUSIVE (*EXCL), EXCLUSIVE ALLOW READ (*EXCLRD), SHARED FOR READ (*SHRRD), SHARED FOR UPDATE (*SHRUPD), and SHARED NO UPDATE (*SHRNUP). Progress/400 opens the OS/400 physical files as SHARED FOR READ. Once a file is opened, it stays open until you disconnect from the DB2/400 database files. Because the files are in a SHARED FOR READ lock state, Progress/400 might generate an error when you try to run OS/400 utilities that require an incompatible object lock on an open file.
- Each physical file (data file) has a WAITRCD parameter that defines the number of seconds a program waits for a record to be updated or deleted. If the record is not available in the specified time, you get an error message. For most OS/400 files, the WAITRCD default is 60 seconds.
You can modify the WAITRCD parameter for physical files using the
CHGPF CL
command and for logical files using theCHGLF CL
command. See the AS/400 CL Reference for more information.- When you use multiple defined buffers in a Progress 4GL procedure, the Progress/400 DataServer opens only one data path to the file, allocates only one cursor, and locks only one record. The Progress 4GL allows a record to be locked for each defined buffer; however, Progress/400 allows only one record per open data path.
- If the AS/400 crashes and records are locked through the Progress lock table, you might need to delete and re-create the table.
- Another technique for avoiding SHARE-LOCK conflicts is to read all records initially with NO-LOCK, then reread them with EXCLUSIVE-LOCK just before committing changes. This technique minimizes the penalty inherent in holding an EXCLUSIVE-LOCK for a long period of time.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |