t44k / clj-rocksdb

Eclipse Public License 1.0
16 stars 3 forks source link

Cannot "destroy-db" #2

Open cordawyn opened 4 years ago

cordawyn commented 4 years ago

Hi again!

I'm trying this simple sequence:

(def db-path (.getPath (clojure.java.io/resource "rocksdb")))
(def db
  (clj-rocksdb/create-db db-path
    {:key-encoder taoensso.nippy/freeze :key-decoder taoensso.nippy/thaw
    :val-encoder taoensso.nippy/freeze :val-decoder taoensso.nippy/thaw}))
...
(clj-rocksdb/destroy-db db-path)

but it crashes with:

org.rocksdb.RocksDBException: lock : /home/cordawyn/projects/try-rocksdb/dev-resources/rocksdb/LOCK: No locks available
 at org.rocksdb.RocksDB.destroyDB (RocksDB.java:-2)
    org.rocksdb.RocksDB.destroyDB (RocksDB.java:2189)
    clj_rocksdb$destroy_db.invokeStatic (clj_rocksdb.clj:265)
    clj_rocksdb$destroy_db.invoke (clj_rocksdb.clj:262)
    ...

The files in the DB directory all seem to be properly created and all DB-related commands work fine (except "sync", as reported previously). The LOCK file is empty.

t44k commented 4 years ago

You should close the db before destroying it:

(.close db)
(clj-rocksdb/destroy-db dp-path)

TODO: Improve documentation