Discussion:
[leveldb] Release a lock - Remove LOCK file on a leveldb directory
Sreejith M
2015-10-14 14:12:23 UTC
Permalink
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!
--
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sreejith M
2015-10-16 15:14:28 UTC
Permalink
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?
Post by Sreejith M
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!
--
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Robert Escriva
2015-10-16 15:17:17 UTC
Permalink
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).
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?
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!
--
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
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...