Skip to content
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

Can't write to db correctly #8

Open
zhaoyi0113 opened this issue Dec 15, 2017 · 6 comments
Open

Can't write to db correctly #8

zhaoyi0113 opened this issue Dec 15, 2017 · 6 comments

Comments

@zhaoyi0113
Copy link
Contributor

I am running rocksdb-node 1.7.2 with rocks 5.8 on MacOs. Below is my code:

db = rocksdb.open(
    {create_if_missing: true},
    path.join(dbPath, `users-${nodeEnv}.rocksdb`)
  );
  db.put('node', 'rocks');

after running above code and I use admin console to inspect the rocks file as below:

$ rocksdb_ldb --db=users-test.rocksdb/ scan
rock : rocks

I wonder why the key is not what I put which isnode.

@dberesford
Copy link
Owner

That's very strange, works fine for me with 1.7.2, rocksdb 5.8.8 on MacOs:

$ cat ./simple.js
const rocksdb = require('./build/Release/rocksdb.node')

db = rocksdb.open(
  {create_if_missing: true},
  '/tmp/users-test.rocksdb');
db.put('node', 'rocks');

12:42 $ node ./simple.js
12:42 $ rocksdb_ldb --db=/tmp/users-test.rocksdb scan
node : rocks

If you do a db.get('node') after the put what does it return?

@zhaoyi0113
Copy link
Contributor Author

I get null output, below is my full code. I also tried to upgrade rocksdb to 5.8.8 and rebuild the project still get the same error.

$ cat lib/demo.js
const rocksdb = require('rocksdb-node');
db = rocksdb.open(
  {create_if_missing: true},
  '/tmp/users-test.rocksdb');
db.put('node', 'rocks');
console.log(db.get('node'));

$ node lib/demo.js
null

My env:

$ node --version
v7.9.0
$ npm --version
5.5.1
$ uname -a
Darwin 192-168-1-4.tpgi.com.au 17.2.0 Darwin Kernel Version 17.2.0: Fri Sep 29 18:27:05 PDT 2017; root:xnu-4570.20.62~3/RELEASE_X86_64 x86_64

Below is the dependency in package.json:

"rocksdb-node": "^1.7.2"

@zhaoyi0113
Copy link
Contributor Author

I make a reproducible demo: https://github.com/zhaoyi0113/rocksdb-demo.git

Could you try to build this repo and run node demo.js?

@dberesford
Copy link
Owner

Demo works for me locally with both node 6 & node 8.

$ node demo.js
rocks
08:38 $ rocksdb_ldb --db=users-test.rocksdb scan
node : rocks

Not sure how to debug this further. Over the upcoming holidays I'll see if I can try a few other os'es, and I've also been meaning to add Travis CI for some time now, maybe that will show something up.

@zhaoyi0113
Copy link
Contributor Author

Thanks for checking it. Some of my co-workers checked these issue and we found this may relate to Mac OS version. It works fine on Mac OS 10.9.5 but doesn't work on 10.13.1. What is your mac version?

@azraellamber
Copy link

I Checked the demo on CentOS 7.2.1511, node v8.11.4, RocksDB v5.17.2, it does't work. I get null value without any error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants