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).
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:
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.
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).
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.
To create a WRITETHRU data or index file, include the WRITETHRU filemode in the filemode value specified when creating the file.
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: