rocksdb-node icon indicating copy to clipboard operation
rocksdb-node copied to clipboard

Can't write to db correctly

Open zhaoyi0113 opened this issue 8 years ago • 6 comments

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.

zhaoyi0113 avatar Dec 15 '17 12:12 zhaoyi0113

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?

dberesford avatar Dec 15 '17 12:12 dberesford

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 avatar Dec 15 '17 21:12 zhaoyi0113

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

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

zhaoyi0113 avatar Dec 15 '17 21:12 zhaoyi0113

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.

dberesford avatar Dec 19 '17 13:12 dberesford

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?

zhaoyi0113 avatar Dec 19 '17 20:12 zhaoyi0113

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.

azraellamber avatar Dec 13 '18 07:12 azraellamber