Product Documentation

Knowledgebase

Previous Topic

Next Topic

WRITETHRU Files

For non-WRITETHRU files, the server stores data and index updates in its internal cache and does not write updates immediately to disk. For TRNLOG files, this is not a concern because committed updates to TRNLOG files are logged to the transaction logs. For non-TRNLOG files, however, in the event of an abnormal server termination the contents of the cache (and hence any unwritten updates to data and index files) will be lost.

In this situation, the server marks non-TRNLOG files as corrupt to indicate that the file was opened, updated, and not properly closed, so its state is unknown. Attempting to open such a file fails with error FCRP_ERR (14, file corrupt at open). Rebuilding the data file and its associated indexes resets the update flag and allows the application to open the file, but all cached updates that had not yet been written to disk are lost.

The WRITETHRU file mode can be applied to FairCom DB data and index files to cause the server to write updates through the server’s cache to the file system cache or to disk, thereby minimizing the potential for loss of cached updates in the event of an abnormal server termination. While ensuring the updates are written to the file system or to disk, WRITETHRU preserves the updates in the server’s cache so that reads can be satisfied from the server’s cache.

A data or index file can be created as a WRITETHRU file (in which case WRITETHRU is a permanent attribute of the file), or it can be opened as a WRITETHRU file (in which case the file is treated as WRITETHRU until it is closed).

In This Section

Properties of WRITETHRU Files

Backup and Restore Options for WRITETHRU Files

When to Use WRITETHRU Files

Creating WRITETHRU Files

Previous Topic

Next Topic

Properties of WRITETHRU Files

For non-transaction WRITETHRU files, all updates are written through the server’s cache to the file system cache. In addition, the server flushes file system buffers on each ISAM update operation for WRITETHRU files. (Low-level updates on WRITETHRU files are written through the server’s cache to the file system cache but are not flushed to disk.)

For PREIMG files opened or created with the WRITETHRU attribute, the server behaves as follows:

  • PREIMG indexes are placed into standard WRITETHRU mode except that changes in the number of index entries are output at transaction commit time.
  • PREIMG data files are placed into a modified mode in which file updates and header updates are only output at transaction commit time.

WRITETHRU minimizes the possibility of lost updates in the event of a catastrophic event because it writes updated cache pages to disk at the time of the update operation. However, WRITETHRU does not provide the guarantee of recoverability that TRNLOG provides. It is still possible when using WRITETHRU for some updates to be lost or for data and index file inconsistencies to exist following a catastrophic event.

Previous Topic

Next Topic

Backup and Restore Options for WRITETHRU Files

The backup and restore options for WRITETHRU files are the same as for non-WRITETHRU files. The distinction is that using WRITETHRU can help minimize data loss that could occur due to unwritten updated buffers for PREIMG and non-transaction files (although WRITETHRU does not provide an absolute guarantee of data/index consistency or recoverable updates as TRNLOG does).

Previous Topic

Next Topic

When to Use WRITETHRU Files

WRITETHRU is useful for ensuring that updates to data and index files are written to the file system cache (or to disk in the case of ISAM updates) at the time of the update (or commit in the case of PREIMG WRITETHRU files). PREIMG and non-transaction files that do not use WRITETHRU can experience significant data loss due to unwritten cached data in the event of an abnormal server termination.

Previous Topic

Next Topic

Creating WRITETHRU Files

To create a WRITETHRU data or index file, include the WRITETHRU filemode in the filemode value specified when creating the file.

  • If using an ISAM-level file creation function, include WRITETHRU in the dfilmod and ifilmod fields of the IFIL structure supplied to the function.
  • If using a low-level file creation function, include WRITETHRU in the filemode parameter supplied to the function.

A data or index file that was not created using WRITETHRU can be opened as a WRITETHRU file by specifying WRITETHRU in the filemode when opening the file.

The following server configuration settings can be used to alter the server’s WRITETHRU behavior:

  • The COMPATIBILITY FORCE_WRITETHRU configuration option causes the server to enable WRITETHRU semantics for all non-TRNLOG data and index files. This option provides a simple way to enable WRITETHRU for all files that are not under full transaction control.
  • The COMPATIBILITY WTHRU_UPDFLG configuration option causes the server to avoid setting the update flag for updated WRITETHRU files. This option provides a simple way to avoid error FCRP_ERR (14) for WRITETHRU files in the event of an abnormal server termination. Note that this option should be used with caution, as an abnormal server termination could leave a data file out of sync with its corresponding indexes (if the data flush completed but the index flush had not yet completed when the server terminated abnormally).

TOCIndex