The tokyo cabinet database used to store various local data for CFEngine in 3.5 (and earlier versions) is in some cases unreliable and this can result in corrupted data files. CFEngine 3.6 and later versions use LMDB which is much more reliable and not affected by this.
To work around this issue, we have a policy to detect and remediate corrupted database files. It will search for corrupted files, try to repair them, or remove them if it is not possible to repair. Note that these files will be recreated the next time CFEngine runs, there is no user-data lost.
To use the policy, please download the attached tcdb_fix.cf and put it in your masterfiles. Then include it into inputs and bundlesequence.
Note that the policy assumes that cf-agent is scheduled to run every 5 minutes. If this is not the case, please adjust the "splay_hourly" class accordingly to be defined at appropriate intervals when you want to run the check and repair policy.
Also note that the policy will only run on linux hosts, as this is the only place it has currently been tested. If you want to run it on other operating systems, please adjust the "hourly_class.linux::" expression accordingly (e.g. replace it with hourly_class.(linux|aix):: to run it on both linux and aix systems.
CFEngine 3.6 has a more solid data storage library (LMDB), so this issue should go away when using the new version.