Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

File Recovery

Information about each data file and index is stored in the first record of the file, called the header record. This information is modified whenever you add a record or key. In many cases, this information is not written back to the header record on disk immediately, particularly in single user situations. This improves the speed of the c‑tree system, but also makes it possible to have incorrect information in the header if the program crashes before the header is updated.

If this situation occurs, c-tree detects that the header has been compromised. An appropriate error code is returned when opening a compromised data file or index.

c-tree provides a high-level function, RebuildIFile(), which rebuilds the data file header and other information, and recreates the index. To use this function you must build an incremental ISAM structure for the file and indexes, even if you are not using ISAM functions.

c-tree also provides a standalone IFIL-based rebuild utility, ctrbldif, that can be used with ISAM parameter files. See the section titled ctrbldif - IFIL-based Rebuild Utility (ctrbldif - IFIL-based Rebuild Utility, /doc/ctreeplus/ctrbldif-util.htm) in this manual.

If your keys cannot be described properly in an incremental ISAM structure, you will have to rebuild the index yourself. A general process would be:

  • Use RebuildIFile() to rebuild the data file header
  • Erase the damaged index
  • Sequentially process the data file, adding the keys to a new index

If the data portion of the file appears to be corrupted, most likely due to a hardware problem, the c-tree compact utility may be useful. See the section titled ctcmpcif - IFIL-based Compact Utility for further details.

 
In V11 and later, an option permits an ADMIN group member to open a file with a bad resource chain using ctOPENCRPT | ctDISABLERES filemodes. A file can now be opened even if it has an invalid resource chain. However, the ctOPENCRPT file mode is not sufficient to open a file in this state. Includes both ctDISABLERES and ctOPENCRPT to enable the file open to proceed.

On a server, the user opening the file must belong to the ADMIN group as passwords cannot be checked with resources disabled. The file mode will be forced to read-only (ctREADFIL).

Note: Some resources such as encryption and compression are essential to reading a file; if their resources cannot be processed then the file open operation will continue to fail.

TOCIndex