levelup: Open Error: IO error Invalid argument
Hi, this is my first time using and learning about LevelDB with Node.js, and my simple app, can’t run, this is my simple code:
var
level = require('level'),
express = require('express'),
uuid = require('node-uuid'),
db = level('./users.db', {valueEncoding: 'json'}),
app = module.exports = express();
app.use(express.logger('dev'));
app.use(app.router);
app.get('/users', function(req, res) {
db.get('users', function(err, users) {
if (err) return res.json(404, err);
return res.json(200, users);
});
});
app.post('/user', function(req, res) {
db.put('users', req.body.user, function(err) {
if (err) return res.json(404, err);
return res.json(200);
});
});
app.listen(5000, function() {
console.log('LevelDB API running on port 5000');
});
And when I run: node app It throws the error:
OpenError: IO error: ./users.db/MANIFEST-000001: Invalid argument
I am using latest stable: Node.js 0.10.23
Does anybody can help me? Thanks!
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 23 (5 by maintainers)
Great news everyone (/cc @groundwater), the latest version of docker (you can register for at https://beta.docker.com/) which does NOT require virtualbox (uses xhyve under the hood - with the native hypervisor that comes with OS X) - doesn’t suffer from this
mmap
bug. You can happily create databases on your OS X host operating system, and volume map them to the xhyve docker host and it works beautifully! Woo!You can read more about the new docker here and get the full docs here
It is a glorious day!
Hmm. Not sure what it could be. Most likely not an
mmap()
issue then which is the focus of this issue thread. I’d open up a new issue with some clear steps and code to replicate the issue.I’ve wrapped everything into a docker image so you can test. Check out the details here
OK. mmap works with nfs. So just add this to your
Vagrantfile
:I’ve tested this with the coreos image, and it works great.
+1
A workaround seems to be to simply symlink the db folder from a non-shared location. Of course this only works if you’re not interested in sharing the db between host and guest.