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

del db does actually not release the LOCK #3

Closed
oleiade opened this issue Nov 17, 2012 · 13 comments
Closed

del db does actually not release the LOCK #3

oleiade opened this issue Nov 17, 2012 · 13 comments

Comments

@oleiade
Copy link

oleiade commented Nov 17, 2012

While trying to port plyvel into Elevator, I noticed that DB.del method does not actually release the LOCK.

>>> db = plyvel.DB('default')
>>> del db
>>> new_db = plyvel.DB('default')
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-10-7174fcd34511> in <module>()
----> 1 new_db = plyvel.DB('default')

/Users/oleiade/.python-eggs/plyvel-0.1dev-py2.7-macosx-10.8-intel.egg-tmp/plyvel/_plyvel.so in plyvel._plyvel.DB.__init__ (plyvel/_plyvel.cpp:2264)()

/Users/oleiade/.python-eggs/plyvel-0.1dev-py2.7-macosx-10.8-intel.egg-tmp/plyvel/_plyvel.so in plyvel._plyvel.raise_for_status (plyvel/_plyvel.cpp:1061)()

IOError: IO error: lock default/LOCK: already held by process
@oleiade
Copy link
Author

oleiade commented Nov 17, 2012

My bad, bug seems to be inherent to my macbook dev environment rather than plyvel.

@oleiade oleiade closed this as completed Nov 17, 2012
@wbolster
Copy link
Owner

I'm seeing similar issues, actually. Any clue on what might be causing this?

@wbolster
Copy link
Owner

Is the example you gave above a complete example? Did you execute any operations in between that may have resulted in references to iterators or write batches still lying around (note that write batches in a "with" block will not be deallocated automatically)?

@wbolster wbolster reopened this Nov 18, 2012
@oleiade
Copy link
Author

oleiade commented Nov 18, 2012

Hey, it kind of reassure me at least that you get the same problem too, 'cause I started seing it on another computer running freebsd today.

Yes this is a complete sample.

I've noticed that through unit tests, and went down to the minimal operation of creating a db connector -> releasing it -> creating a new connector to that db; which raises the problem.

@oleiade
Copy link
Author

oleiade commented Nov 20, 2012

Tested on Linux mint, this passes:

>>> import plyvel
>>> db = plyvel.DB('default')
>>> new_db = plyvel.DB('default')
>>> db.put('1', 'a')
>>> new_db.get('1')

So I guess that in some way, python/cython, makes it possible for two DB objects working on the same db, in the same process to share the DB* pointer. (Don't ask me how, this is just an hypothesis).

On what os, python version etc did you experienced that bug?

@wbolster
Copy link
Owner

The double open support is a LevelDB bug I think. I guess it can lead to corruption even.

@wbolster
Copy link
Owner

I'm working on DB.close() btw, but it's a bit tricky due to the way things like iterator destructors work. And it requires a check in each public API method. :-(

@wbolster
Copy link
Owner

Btw, the double open issue does not reuse the pointer I think.

@wbolster
Copy link
Owner

It took some effort, but here we are: plyvel.DB has a .close () method since commit 755e000. Please review and test, since the code is a bit tricky. (Don't forget to check the API docs.)

@wbolster
Copy link
Owner

Did you have any chance to test whether the .close() API solves the problems reported earlier?

@wbolster
Copy link
Owner

Btw, the double open issue has been fixed a while back in LevelDB itself: http://code.google.com/p/leveldb/issues/detail?id=120

@oleiade
Copy link
Author

oleiade commented Nov 27, 2012

Problem seems to be solved now.
With plyvel head at fccb583 and leveldb 1.7.1

@wbolster
Copy link
Owner

Ok, same here. Thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants