HPlogo KSAM/3000 Reference Manual: HP 3000 MPE/iX Computer Systems > Appendix E RECOVERY FROM SYSTEM FAILURE

END-OF-FILE AND THE EXTRA DATA SEGMENT

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

As described in appendix B, each open KSAM file uses an extra data segment (XDS) to hold the control information for that particular open file. The extra data segment also contains a data block buffer into which records are read from the file and from which records are written. Finally, the extra data segment keeps key block buffers to hold key entries affected by the data records being accessed. The control block in each extra data segment also maintains the most up-to-date KSAM end-of-file markers for each open file.

Whenever a KSAM file is opened, the KSAM end-of-files for the data and key files are moved (with all other information from the key file control block) to the control block of the extra data segment for that file. When the file is closed or unlocked, the control block is written back to disc. (Refer to Figure E-1 “KSAM File and an Extra Data Segment ”for a diagram illustrating the end-of-file markers and their relation to an extra data segment.)

Figure E-1 KSAM File and an Extra Data Segment

[KSAM File and an Extra Data Segment]

NORMAL OPERATION - FILE IS CLOSED

During normal operation, if a new record is written to the file by any user, the record is written in the data block buffer of the extra data segment and the key entry for the record is inserted into the key block buffer where it belongs. (Refer to appendix B for a discussion of how new key entries are added.) The appropriate key block buffer is brought into the extra data segment automatically. Then, whenever the data block or key block buffers are full or new blocks must be read into the extra data segment, the key and data blocks are written back to disc. But the control block from the extra data segment is not written to disc until the file is closed (or is unlocked, or FCONTROL with code 2 or 6 is called).

Before considering what happens in case of a system failure, let's look at the normal steps taken when the file is closed:

  1. Key block buffers are written to the key file

  2. Data block buffer is written to the data file (and, if a new extent is allocated, the MPE end-of-file is written to the data file system label).

  3. Control block with the KSAM end-of-file marks is written to the key file.

  4. MPE end-of-file mark is written to the data file system label.

When a file is unlocked, the first three steps shown above are taken (except the MPE end of file is not written). FCONTROL with control code 6 performs all four steps, and control code 2 performs the first three steps.

SYSTEM FAILURE - FILE IS OPEN

If the system fails when a KSAM file is open, the extent of the damage to the file depends on when the failure occurred and whether the file was being modified. If all users opened the file for readonly, then the file is undamaged and can be reopened. If a user had just unlocked the file and no other user has modified it, the MPE end-of-file may need to be reset but otherwise, the file is undamaged. But if the file was being modified, then the extent of the damage depends on whether any of the steps listed above had been completed and, if so, which ones.

In the simplest case, all the steps except step 4 have been performed. This means that the KSAM end-of-file is up-to-date, but the MPE end-of-file is still at its previous position, In the most complex case, caused by records being deleted, data records remain in the data file for which there are no corresponding key entries, (error number 175).