tingodb icon indicating copy to clipboard operation
tingodb copied to clipboard

files renamed f<ilename>.compact

Open alienatorZ opened this issue 9 years ago • 10 comments

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!

alienatorZ avatar Oct 18 '15 21:10 alienatorZ

I suppose you are using it on Windows?

sergeyksv avatar Oct 19 '15 14:10 sergeyksv

Yes. Windows 8 and Windows 7.

alienatorZ avatar Oct 19 '15 14:10 alienatorZ

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.

sergeyksv avatar Oct 19 '15 14:10 sergeyksv

Is there a way to disable auto compactization?

alienatorZ avatar Oct 19 '15 14:10 alienatorZ

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.

sergeyksv avatar Oct 19 '15 15:10 sergeyksv

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,

moroccan-dude avatar Dec 14 '15 22:12 moroccan-dude

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.

sergeyksv avatar Dec 15 '15 09:12 sergeyksv

@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.

jhaydt avatar Feb 16 '16 19:02 jhaydt

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();

azhrkhan avatar Jan 02 '18 18:01 azhrkhan

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 :)

xeroxstar avatar Jan 05 '20 07:01 xeroxstar