PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Recovering damaged files and KEYED LOAD  (Read 1593 times)

PxPlus

  • Administrator
  • Diamond Member
  • *****
  • Posts: 1091
    • View Profile
Recovering damaged files and KEYED LOAD
« on: May 31, 2018, 10:43:54 AM »
One of the best/fastest ways to recover a damaged file is to use the KEYED LOAD directive. See https://manual.pvxplus.com/PXPLUS/directives/keyed_load.htm

The KEYED LOAD directive removes the existing key tables for a file then reads through the file physically rebuilding the key tables based on the records it finds.

If the file is VLR the records are all kept in pages/blocks thus the system reads each block from the file, validates that it looks correct (block header intact, record offsets valid, etc..) and if a data block processes all the records found. Now if a block has been overwritten or cannot physically be read then the records that existed on that block are lost (after all they data isn't on disc anymore...) and the file should be recovered from a backup.

EFF files are similar however the system has to use the file inventory to make sure that it uses the 'Active' data pages instead of 'Old/Shadow' data pages. Other than this, the logic is much the same as VLR.

For FLR files the process is quite a bit different because the records aren't stored in pages whose integrity can be verified. In this case the file is read record by record and each record is checked to see if the record length (and any external key) make sense relative to the file description. If so the system assumes the data found is a valid record.

Because FLR does not employ a record blocking mechanism there is more potential for having garbage data (or old key blocks) misinterpreted as data records.

Now when the KEYED LOAD ends normally then the value is TCB(67) is a sanity check. Basically if not -1 then we were able to read all the data blocks from a file. In the cause of FLR files which multiple keys it does attempt to validate that the number of records found when processing each the key trees match.

If the KEYED LOAD fails with an error then file generally cannot be recovered since there are defective areas (blocks) within the file.

If TCB(67) is not -1 then the record count on each of the key trees matched thus generally the file is fine. If the value is -1 then there was a mismatch however if you had NULL key suppression the -1 is not meaninful (this will be addressed in a future version).

Regardless of the value in TCB(67) though, for VLR and EFF files, its unlikely any other process could retrieve the data due to nature of the file design. For FLR it may be possible to write a program to better examine the records and determine the record validity -- this is where *UFAR and its 'Assumptions' may be useful.   

There is also another VLR file recover program available at:

https://www.pvxplus.com/downloads/misc/fixvlr2

This program can be used to copy the data out of a corrupted data file into a new file (it also supports for multi-segmented files). It reads the file physically and copies any records it finds into the output file.

In many cases this process is faster than *UFAR and can handle data files with major problems including the loss of file header information.

The data dictionary is not preserved and should be reloaded using the Data Dictionary utility.
« Last Edit: October 18, 2021, 05:19:24 PM by Mike King »