Release a lock - Remove LOCK file on a leveldb directory

1,922 views
Skip to first unread message

Sreejith M

unread,
Oct 14, 2015, 10:12:23 AM10/14/15
to leveldb
Hi,

This is the scenario,

1. Process A creates/opens a leveldb dir "/foo" using db::Open(). This means there is a LOCK file on the dir indicating that the leveldb has been locked by the process.
2. Process A does some Get/Put operations. 
3. Process A wants to release the lock. i.e., remove the LOCK file on the leveldb directory.
4. Process B or A wants to open the same leveldb directory "/foo" but the LOCK is still present.

I was wondering if there is a way to release the lock(delete the LOCK file) so that I can use the same leveldb directory once again? I am digging into the source code but posting it here incase anyone sees it before.

Thanks!

Sreejith M

unread,
Oct 16, 2015, 11:14:29 AM10/16/15
to leveldb
I checked the source code and see that UnlockFile() does remove the LOCK file but UnlockFile() is only invoked during a destroyDB(). But I do not want to destroy the DB. Is there a workaround for this?

Robert Escriva

unread,
Oct 16, 2015, 11:17:04 AM10/16/15
to lev...@googlegroups.com
The presence/absence of the LOCK file is not what determines whether the
db is locked. It's locked using flock(2). The lock is released when
you close the database in one process. Just call "delete db" to close
it in your C++ program (or the equivalent in your language).
> --
> You received this message because you are subscribed to the Google Groups
> "leveldb" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to leveldb+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages