twmht / python-rocksdb

Python bindings for RocksDB
BSD 3-Clause "New" or "Revised" License
276 stars 88 forks source link

Allow `rocksdb.DB` instances to be manually closed (second revision PR) #40

Closed fish2000 closed 5 years ago

fish2000 commented 5 years ago

While delete rocks_ptr is a deterministic operation in C++, the Python analogue del rocks_handle is not – disposal and finalization of the Rocks database are entirely dependent on the Python garbage collector (q.v. the python-rocksdb tests themselves, which call gc.collect() after del rocks_handle to attempt to force the destructor to run):

https://github.com/twmht/python-rocksdb/blob/98910c2dce41c02aaa1745ae09e9d5fcdde34bdd/rocksdb/tests/test_db.py#L14-L21

This change exposes a method to trigger the destruction of the underlying Rocks database pointer (deterministic!) through the Python Rocks handle; existing code will not need to be changed, as the Python object destructor (non-deterministic!) will now call this method.

This is the second revision of this PR – it resolves the first revision, #39, and would close issue #10.

fish2000 commented 5 years ago

@twmht I am not sure what the deal is with those failing tests – it seems to be something gone wrong with the new ColumnFamilyOptions stuff (although I am not sure). Can you let me know if it’s something I should look at?

twmht commented 5 years ago

fixed and merged.

aviau commented 5 years ago

This is giving me segfaults and double free or corruption errors.

iFA88 commented 5 years ago

46