-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Over 256Mb datafile throw err upon opening #389
Comments
See #363. NeDB is not meant to be used with that large databases. You should probably use MongoDB. |
Thanks, @lukasbestle, I searched with wrong words. The DB is not that large (3 Mb of actual data), but I messed up auto compactification and got stuck with huge file I had to edit in UltraEdit32 to restore NEDB ability to work. :) Now that I know, I will add some more checks for size. But mention something about 256Mb limit of DB filesize in https://github.com/louischatriot/nedb#persistence may be useful for future dummies like me. |
Ah, alright. If auto-compaction works for you now, that should be solved. The note in the README is a good idea however. @louischatriot? |
Hmm adding a check on file size could be an idea but there are a lot of questions here. I'm pretty sure that there is no 256 MB limite on nedb datafiles though, that must be something to do with your system. |
As I can see (but I am pretty much newbie in Node) there is a problem in Buffer.js during DB loading and trying to convert all file from Buffer to String in one go. Since one String can't be longer than kMaxLength in V8. Checking in node.exe (5.7.0) var len = 268435441;
var blob = new Buffer(len).toString('utf8'); result is (also tried
Just for fun tried
As I understood from googling, there is no way to open over256Mb JSON file in node in one go: only streaming by line and parsing into JSON. |
Final comment on this: if this is indeed an issue that's reproducible, please create a test case according to the bug reporting guidelines, which I will then review! |
Sorry, I am new to these guidlines, and if I'm wrong please point me to the proper doc. I tested in Express v3.4.4, Node 5.7.0. Folder for DB file is app.js var express = require('express');
var http = require('http');
var app = express();
app.set('port', process.env.PORT || 3000);
app.set('views', './views');
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(express.static('./public'));
var stats = require('./routes/index.js');
app.get('/testDB', stats.testDB);
http.createServer(app).listen(app.get('port'), function () {
// console.dir(process.versions);
console.log('Express server in mode ' + app.get('env') + ' listening on port ' + app.get('port'));
}); index.js. function checkDBsize() {
var fs = require('fs');
fstat = fs.statSync('./DB/DBtest.nedb');
var filesize = fstat["size"];
console.log("DB size is", filesize, "bytes");
return filesize;
}
function increaseDBsize(db, limit, res) {
var data = [];
for (var i = 0; i < 15; i++)
data.push({index: i, dataSegment: JSON.stringify(data)});
db.insert({ test: true, dataChunk: data }, function (err, newDoc) {
if (newDoc) {
db.remove({ test: true }, { multi: true }, function (err, recNum) {
if (err) {
console.log("error deleting", JSON.stringify(err));
} else {
filesize = checkDBsize();
if (filesize >= limit)
res.send(filesize + " bytes");
else
return increaseDBsize(db, limit, res);
}
});
} else {
console.log("error adding", JSON.stringify(err));
}
});
}
exports.testDB = function (req, res) {
var text2send = "";
var filesize = 0;
var DatastoreTest = require('nedb'),
db = new DatastoreTest({ filename: './DB/DBtest.nedb', timestampData: true, autoload: true });
filesize = increaseDBsize(db, 350 * 1000000, res); // With 250 all is OK.
} First run of http://localhost:1337 (I'm using VS2015 community) produces NEDB database file ~335Mb. console output is:
Second run crashes Node.
|
Sorry but this still doesn't adhere to the bug reporting guidelines, see bottom of the readme. Specifically, please remove all unneeded dependencies such as Express to remove external factors, and you sohuld be able to make it so the crash/bad assertion occurs in only one run. |
When you try to open NeDb size of 500MB, an exception is thrown.
Probably due to the fact that the file size exceeds the maximum Buffer if you are going to deal with this bug? Thank you. |
Here is a gist of @ornic's code, simplified down. You can run it as Are there any plans to accommodate larger file sizes? Or should people be using https://github.com/Ivshti/linvodb3 or mongo instead? If not, I do agree with some of the previous posters that this should be addressed clearly near the top of the README. |
I'm also seeing this error on db size of 256MB. Looks like no work around? |
Seems that the reason is the max string size supported by Chrome, which is 512MB/2: http://stackoverflow.com/q/34957890 |
Can we remove the limit if you're using nedb from node.js on the server? There is no need for a 256MB database limit. |
This is not a limit that has been hardcoded into NeDB. It's a limitation of how many characters can be loaded into the string in Node. NeDB could load the DB by streaming from the file, but this wouldn't solve the issue that large DBs won't perform well. Consider using a "real" DB like MongoDB. |
Windows x64 Node v5.3.0 and v5.7.0 x64
Datafile contains large portions of data (about 1 Mb for each JSON) updated continuosly. Clean datafile (no deleted entries) has size about 3 Mb.
It is looks like somebody (NEDB?) try to load all file into one string and bumps into nodejs/node#3175 256Mb limit.
May be it will help to set some size limit to force compactification?
Node window (VS 2015 community)
Interactive node
The text was updated successfully, but these errors were encountered: