![]() |
![]() |
|
|
![]() |
![]() |
KSAM/3000 Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 2 USING KSAM UTILITIES![]() KEYINFO |
|
Displays information about the key file, and attempts recovery of a KSAM file in case of system failure when the file is open.
KEYINFO performs two operations: it collects and displays information about the key file, and it takes steps to recover the KSAM file in case a system crash occurred when the file was open. The second operation is performed only after a system crash or if the RECOVER parameter is specified. The key information displayed by KEYINFO consists of:
The crash recovery performed by KEYINFO depends on the type of damage to the file.
Information is displayed by KEYINFO for each key in the key file, in key order starting with the primary key. For example, request KEYINFO for the file DATAFIL which has three keys:
# OF LEVELS OF B-TREE - Key files are organized in a structure known as a "B-Tree". This structure may have one or more levels (for details refer to appendix B). The file DATAFIL has only one level. # OF KEY BLOCKS - Key values are stored in blocks; this entry gives the total number of key blocks in the file. DATAFIL has only one key block. # OF SECTORS PER KEY BLOCK - A key block may require one or more 128-word sectors. DATAFIL uses eight sectors for its key block (the default value). # OF KEYS IN ROOT BLOCK - This specifies the number of key values stored in the root block (in this case the only block). If this number is equal to the key blocking factor (see KEY BF header in VERIFY output), then the next key block split will increase the number of levels in the B-Tree by one. DATAFIL has 20 key values in its root block, and the blocking factor allows 52, 202, or 144 (see VERIFY printout below).
# OF KEYS IN B-TREE - This is the total number of key values in the key file for each key. This number should be the same for each key and should also be the same as the number of active records in the data file (to determine this, use the FCOPY command >FROM=DATAFIL;TO=$NULL ;KEY=O. FCOPY is described later in this section). DATAFIL has 20 key values in each B-Tree, and this is the same number as the number of active data records (see FCOPY output below).
% OF KEY BLOCK UTILIZATION - Average percent of use of all key blocks (percent of use means how much of the block contains key values). Note that the root block of a multi-level tree is omitted from this average. For multi-level trees the percent is between 50% and 100%, for single-level trees between 0% and 100%. The higher the percentage, the faster the retrieval of data. But, also the higher the percentage, the greater the chance of block splits when records are added. DATAFIL uses 38.4% for its primary hey, 9.9% and 13.8% each for its two alternate keys. THE LARGEST KEY BLOCK ADDRESS - This is the largest key block address found for each key. The key file end-of-file should never be less than the largest block address for the file plus the number of sectors per key block. The largest block address for DATAFIL is 18 (the largest block address for DATAFIL is 18 (the largest block address of key 3). Since the number of sectors per block is 8, the key file end-of-file should be at least 26 (see VERIFY output below).
KEYINFO only performs the recovery operations if there has been a system failure or if you specify the RECOVER parameter. If there has been a system failure while the KSAM file is open for non-read access, a flag is set that prevents the file from being opened. Whenever this occurs, KEYINFO must be used in order to reset this flag so that the file can be opened. KEYINFO also recovers from any damage done to the file as a result of the system failure. It resets end-of-file markers for both the data and key files, and deletes any key values that point to records beyond the data file end-of-file. It also stores in the key file the user, group, account, and home group of the user who runs KEYINFO to recover the file. (When there has been a system failure or when KEYINFO is run with the RECOVER option, the KSAM file is opened for exclusive access; otherwise it is opened for shared access.) When KEYINFO is run after a system failure, the SYSTEM FAILURE count displayed by option 3 of VERIFY is incremented by 1. If there was no system failure but KEYINFO was run with the RECOVER option, this count is not incremented. When KEYINFO resets the "crash" flag, the date of this reset is saved and can be recovered through the VERIFY command, option 3 under the heading RESET DATE. Note that the NOCHECK option of VERIFY allows that command to open a KSAM file for read-only access even if a system failure prevents the file from being opened for all other access. For example, assume a file TEST that was open when a system failure occurred. In this case, KEYINFO must be run. Also, assume the following:
Running KEYINFO will correct the end-of-file markers and, if any keys point to data records beyond the data file end-of-file, it will delete these key values. KEYINFO cannot, however, restore missing key values. To do this, you must reload the file with FCOPY. To illustrate, KEYINFO operates as shown below:
In this case, the file must be reloaded in order to add the missing key values to the key file. For a full discussion of recovery procedures in case of system failure, including how to reload your file, refer to appendix E. USING RECOVER OPTION Even if a system failure does not occur, you can run KEYINFO with the RECOVER option in order to check the file structure. The RECOVER option forces KEYINFO to correct any end-of-file inconsistency, including the key file end-of-file, and to delete any invalid key values. This option sets the RESET DATE field of the VERIFY output to the current date, and saves your user name, account, group, and home group, but does not increment the SYSTEM FAILURE count displayed by VERIFY. Note that checking each record and key in a file with a lot of data is very time consuming. Therefore, you should not use RECOVER unless it is necessary to reconstitute your file. For example, use KEYINFO with RECOVER to validate file TEST:
If you now run VERIFY, using option 3, you will see that the date of recovery is displayed following the heading RESET DATE.
|
![]() |
||
![]() |
![]() |
![]() |
|||||||||
|