tingodb
tingodb copied to clipboard
files renamed f<ilename>.compact
As my software gets used TingoDB will randomly rename my collections files to a .compact file causing the data to not be found.
Is there a workaround?
Thanks!
I suppose you are using it on Windows?
Yes. Windows 8 and Windows 7.
file with .compact extension are create for purpose of compactization or garbage collection. This procedure is triggered automatically or upon request (collection.compact or db.compact functions). The goal is to substitute files (old and compacted) in most safe manner. Unfortunately on windows this is tricky. See the code here: https://github.com/sergeyksv/tingodb/blob/master/lib/tcoll.js#L216 Unfortunately I have no windows OS to try to fix this. Probably you can check what goes wrong and why replacing of .compact to normal file doesn't happening.
Is there a way to disable auto compactization?
There is no option that control this, but this is here decision is made: https://github.com/sergeyksv/tingodb/blob/master/lib/tcoll.js#L135 You can comment out this code or ad false into condition.
Hi,
We are in the process of choosing a lightweight Js db to run on a nodejs server deployed on Windows server 2012. We would like to use Tingodb but we will most likely be faced with the same problem. Any updates on this? What is the easiest way to disable this 'compact' feature ?
Thank you,
This is windows only issue. Unfortunately I didn't use windows and especially for NodeJS development. So for me it is problematic to reproduce and therefore fix this issue. Code is open, fix should be trivial for anybody who use windows.
@alienatorZ or @sergeyksv, please change title to indicate windows only? many thanks. We are considering as well for windows and will fix if we use tingodb.
For windows (Tested) in node_modules\tingodb\lib\tcoll.js on line 135
Change
if (deleted > size || err) { self._compact(function (errCompact) { if (errCompact && err) cb(errCompact); else { if (errCompact) console.log(err); cb(); } }); } else cb();
To:
if (deleted > size || err) { cb(); } else cb();
For windows (Tested) in node_modules\tingodb\lib\tcoll.js on line 135 Change
if (deleted > size || err) { self._compact(function (errCompact) { if (errCompact && err) cb(errCompact); else { if (errCompact) console.log(err); cb(); } }); } else cb();
To:
if (deleted > size || err) { cb(); } else cb();
thanks, worked :)