FairCom DB is a file-based database technology. All data and indexes reside in independent files on the filesystem. These can be quite numerous in many applications, and span multiple filesystem folders. Applications can easily delete files on-the-fly and in some applications this is under end user control. And mistakes happen! In nearly all filesystems, recovering a deleted file is extremely difficult if not impossible. A backup might not be up to date enough. What has been requested is a temporary holding of deleted files such as a "rubbish bin" that can later be emptied.
Beginning with FairCom DB V13, deleted files can optionally be moved to a recycle bin instead of immediately permanently removing files from storage. A configurable background task then runs periodically emptying, that is, permanently deleting, previously deleted files.
Recycle bin support
The recycle bin feature is supported at FairCom DB ISAM and low-level API layers. Extended ISAM and low-level file delete function versions are introduced allowing this new support.
SERVER CONFIGURATION OPTIONS
The recycle bin is configured with SUBSYSTEM CTFILE RECYCLE_BIN . This subsystem configuration option supports the following options:
Example
subsystem ctfile recycle_bin {
recycle_folder_name deleted_files
purge_frequency_minutes 60
max_file_age_days 30
max_folder_storage_size 1 gb
}
MONITORING
The statistic utility, ctstat supports a deleted_files option listing the total size and detail list of files currently in the recycle bin.
Example
ctstat -deleted_files -u ADMIN -p ADMIN -s FAIRCOMS -i 1 -h 1 -t
Thu Dec 9 15:01:48 2021
Total file size: 917500 for 4 file(s)
Deleted file of size 131071 deleted\1639081086.20211209\qatranrepl097.sup.992
Deleted file of size 131071 deleted\1639081086.20211209\qatranrepl097.sup.998
Deleted file of size 327679 deleted\1639081086.20211209\qatranrepl097.sup.1017
Deleted file of size 327679 deleted\1639081086.20211209\qatranrepl097.sup.1026
NEW SERVER FILES
Two new files are required for tracking inactive files in the recycle bin. RECBINDT.FCS and RECBINIX.FCS are transaction-controlled data and index files retaining data about the current recycle bin state. The data file contains a state record for each deleted file, and a state record that holds the total space in use by deleted files. The index enables the background thread to find files that were deleted from the oldest to newest timestamp.
REPLICATION AGENT CHANGES
The replication agent supports a configuration option to enable whether the agent uses the recycle bin any time it deletes a file on the target server. The ctreplagent.cfg option is delete_to_recycle_bin yes | no and is on by default.
NEW FUNCTION PROTOTYPES:
CTERR DELRFILX(FILNO datno, pctDELETE_FILE_XTD_OPTIONS pDeleteFileOptions);
CTERR DELFILX(FILNO filno, pctDELETE_FILE_XTD_OPTIONS pDeleteFileOptions);
CTERR DELIFILX(pctDELETE_IFIL_XTD_OPTIONS pDeleteIFILXtdOptions);
NEW DATA TYPE DEFINITIONS:
Parameters for DELFILX() and DELRFILX() function calls as defined in ctopt2.h.
optionBits bit field values
typedef enum ctDeleteFileOptionsBits_t {
ctDELETE_TO_RECYCLE_BIN = 0x00000001 /* move files to recycle bin instead of deleting */
} ctDELETE_FILE_OPTIONS_BITS;
typedef struct ctDeleteFileOptions_t {
UCOUNT structVersion; /* [IN] version of this structure */
UCOUNT pad; /* unused padding */
ULONG optionBits; /* [IN] option bits */
} ctDELETE_FILE_XTD_OPTIONS, *pctDELETE_FILE_XTD_OPTIONS;
Parameters for DELIFILX() function call
typedef struct ctDeleteIFILXtdOptions_t {
UCOUNT structVersion; /* [IN] version of this structure */
UCOUNT pad; /* unused padding */
ULONG optionBits; /* [IN] option bits */
pIFIL pifil; /* [IN] IFIL pointer */
} ctDELETE_IFIL_XTD_OPTIONS, *pctDELETE_IFIL_XTD_OPTIONS;
COMPATIBILITY NOTES
The new extended delete functions require both a new client library and a new server. Calling a new function on an old server will fail with error SFUN_ERR (170) "bad function number".
Likewise, if a new replication agent is using the delete_to_recycle_bin yes option in ctreplagent.cfg with an old server, its replicated file delete operations will fail with error 170.
AFFECTED COMPONENTS: server, client library, replication agent.