A database transaction is a unit of recovery that represents work done by one or more database sessions. All access to CA IDMS data from within a run unit is done under the control of a database transaction.
Journaling Changes
Every time your program modifies the database, a before and after image of the affected record occurrence is written to the journal file. These images are used in the event of program or system failure to recover (roll back) all changes made to the database. During a rollback, updates are reversed to the last checkpoint written to the journal file.
Checkpoints
Checkpoints are written at the following times:
A database transaction encompasses the work done between two checkpoints. A database transaction is also a recovery unit since all changes made by a transaction are committed or recovered as a single unit.
Note: If a database transaction is shared by more than one session, itimpacts when checkpoint records are written.
For more information, see Sharing Transactions Among Sessions.
Automatic Recovery Under Central Version
Recovery takes place automatically for programs running under the central version. In order to recover under local mode, you must manually recover the database by using CA IDMS recovery utilities or by restoring the database files from a backup copy.
For more information on recovering the database under local mode, see the CA IDMS Database Administration Guide.
Rolling Back the Database
The figure below shows journaling, checkpoints, and rollback. The BIND RUN-UNIT statement writes the initial checkpoint to the journal file. Before and after images are maintained for every modified record occurrence. In the event of an abend, the central version uses the before images to restore the database back to the last checkpoint. In this figure, there is a one-to-one association between the run unit and its database transaction.
Establishing Checkpoints
The figure below shows the use of the COMMIT statement to establish checkpoints. In the event of an abend, the central version restores the database as far back as the last COMMIT checkpoint.
Committing Changes
If your application performs database updates, you should commit those updates at regular intervals to:
Frequency of COMMIT Statements
Since modified records are implicitly and exclusively locked, timely use of the COMMIT statement is an important programming consideration.
The frequency of issuing COMMITs is a site- and application-specific decision. Some questions to ask when determining the frequency of COMMITs are:
For detailed information on the implicit exclusive record locks maintained for each modified record, see Implicit Record Locks.
Note: You can use the IDMS statistics block (explained in Collecting Database Statistics) to obtain lock-related information at run time.
Copyright © 2013 CA.
All rights reserved.
|
|