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

Fixed segfault on DB close #92

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions rocksdb/_rocksdb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1672,21 +1672,20 @@ cdef class DB(object):

def __dealloc__(self):
self.close()

if not self.db == NULL:
del self.db

def close(self):
cdef ColumnFamilyOptions copts
if not self.db == NULL:
# We have to make sure we delete the handles so rocksdb doesn't
# assert when we delete the db
# assert when we delete the db.
self.cf_handles.clear()
for copts in self.cf_options:
if copts:
copts.in_use = False
self.cf_options.clear()

with nogil:
del self.db

if self.opts is not None:
self.opts.in_use = False

Expand Down
9 changes: 8 additions & 1 deletion rocksdb/db.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ cdef extern from "rocksdb/db.h" namespace "rocksdb":
Range(const Slice&, const Slice&)

cdef cppclass DB:
Status Close() nogil except+

Status Put(
const options.WriteOptions&,
ColumnFamilyHandle*,
Expand Down Expand Up @@ -199,7 +201,12 @@ cdef extern from "rocksdb/db.h" namespace "rocksdb":
cdef cppclass ColumnFamilyDescriptor:
ColumnFamilyDescriptor() nogil except+
ColumnFamilyDescriptor(
const string&,
const string&,
const options.ColumnFamilyOptions&) nogil except+
string name
options.ColumnFamilyOptions options

cdef extern from "rocksdb/convenience.h" namespace "rocksdb":
void CancelAllBackgroundWork(
DB* db,
cpp_bool wait) nogil except+