isamu / rocksdb-ruby

A simple RocksDB library for Ruby
MIT License
75 stars 24 forks source link

race condition and crash process #15

Closed JokerCatz closed 6 years ago

JokerCatz commented 6 years ago

just demo code ...

require "rocksdb"
key = "test"
value = "1"
rocksdb = RocksDB::DB.new "/tmp/file"
rocksdb2 = RocksDB::DB.new "/tmp/file"
rocksdb.put(key, value)
rocksdb2.put(key, value)
# ruby kernel exception

did here need add lock check or something like mutex to skip this condition ?

isamu commented 6 years ago

I changed that raise RocksDB::DBError when same file open twice. I alse added singleton method.

JokerCatz commented 6 years ago

RocksDB::DBError: error /tmp/file alread open

it looking good , but I'll wait version change and use it to my project , many thanx , this gem is very useful for fast local DB :)