The Transaction Logging Process

Transaction logging provides the programmer with a COBOL verb that can roll back or undo file operations performed during a transaction. A rollback is typically invoked when the program detects a file error or other error condition.

Outside of the application, transaction log files can be used for another purpose: to recover files after a program failure or system crash. The recovery process is performed by an ACUCOBOL-GT library routine that accesses the latest backup and the log files. It is the site's responsibility to clear the log files when a backup is made, so that the logs always contain precisely those transactions that have occurred since the last backup. The logs and the backup can then be used to reconstruct files into a consistent state after a crash.

To make rollback and recovery operations possible, the runtime records information about how to redo and undo each file update that occurs within a transaction. After the transaction starts, each Vision or relative file update operation is recorded until the transaction is committed or rolled back. At that point:

All programs that operate on the same set of data files must also use the same set of transaction log files.

In transaction management, the log files must be synchronized to the backup procedure for the files being managed. When the files are backed up, the log files must be cleared (or deleted). The next time a transaction occurs, the runtime creates new log files (or begins writing to the cleared files). Thus, the logs contain precisely those transactions that have occurred since the last backup.

If the log files and backups are synchronized, when a program dies in mid-transaction, you can reconstruct the files into a consistent state. To do this, you restore the backup, then run a program that calls the C$RECOVER utility routine. This routine reads a log file and performs each update operation that was part of a completed transaction. Operations that were not part of a completed transaction are not performed.

By using transaction logging, you ensure logically consistent files. In addition, you never need to do a rebuild operation on a broken data file, because you can always recover files by restoring the backup and running a program that calls C$RECOVER.

You can use the utility program logutil to examine and edit an ACUCOBOL-GT transaction log file. The logutil utility supports large (>2GB) transaction log files. The host operating system must allow such large files. See logutil for more information.

Though a transaction logging system provides a high degree of file security, it does impose extra overhead. Backups are essential, and there is increased disk I/O, more memory use, and more record locks.

Going to your backups and using the recovery procedure usually takes more time than just checking the data files and restarting the program. On the other hand, if the system dies, you do not need to worry about examining the files for problems.