Guardian Programmer's Guide

Table Of Contents
Fault-Tolerant Programming in C
Guardian Programmer’s Guide 421922-014
27 - 23
Saving State Information for Multiple Disk Updates
/*Third update point. Include control state (cnt), data
state (buf2), and file state (account_file)*/
cnt = 3;
...Update cnt, buf2, account_file...
err = WRITEUPDATE (account_file, buf2, ...);
err = WRITE (terminal, buf1,...);
The third update point identifies the program state as “preparing to write an updated
record to disk.” The state information consists of:
The counter variable (control state)
The updated record (data state)
The disk file’s sync information (file state)
If the primary process fails between update points 1 and 2, the backup process
reissues the WRITEREAD to the terminal. If the primary process fails between update
points 2 and 3, the backup process uses the terminal input and continues processing
the transaction. If the primary process fails after update point 3, the backup process
uses the current state information to reexecute the write to disk.
Note that update point 2 could be omitted. If this were done, a failure between update
points 2 and 3 would require the operator to reenter the transaction.
Saving State Information for Multiple Disk Updates
When performing a series of updates to one or more disk files, you can save state
information for those updates at one point in the program instead of multiple points.
This results in lower system usage.
The program should be structured so that the series of writes needed to update a file
are performed in a group. For each file to be updated in this manner, you should
specify the sync-depth parameter of the FILE_OPEN_ procedure as the maximum
number of calls to the WRITE[X] procedure that are made between points at which
state information is updated. Then, just before performing sync-depth writes to the
file, update the state information, including the file’s sync block and the data buffers
about to be written to the file.
Providing Communication Between the
Primary and Backup Processes
Active backup programs require a method for communication between the primary and
backup processes and between the backup process and the operating system. HP
recommends using the Guardian interprocess communication facility for:
Sending state information from the primary process to the backup process.
Receiving state information in the backup process.