python-rocksdb
python-rocksdb copied to clipboard
Support for transactions
It seems the bindings are missing transaction support.
Thank you for using python-rocksdb. these features are coming soon since I am re-making whole project to make it more easily to maintain.
tx!
It has been 2 years since this issue was opened. Any news on this? I was considering using rocksdb for a project written in python, but not having transactions is a showstopper!
You can use WriteBatch for that, or even a custom writebatch which stores the key data and statuses for from that.
Not really, because I need read-write conflict detection by using GetForUpdate.
Not really, because I need read-write conflict detection by using GetForUpdate.
Yeah, you can do that in python. You can use bisect
for automatic ordering when you need iter too.
Not really, because I need read-write conflict detection by using GetForUpdate.
Yeah, you can do that in python. You can use
bisect
for automatic ordering when you need iter too.
I am not sure I understand what you mean.. How does bisect help me with this?
I am not sure I understand what you mean.. How does bisect help me with this?
So simple:
class OwnWriteBatch:
def __init__(self, db):
self.db = db
self.keys = {}
def get(self, key, *args, **kwargs):
if key not in self.keys:
return self.db.get(key, *args, **kwargs)
return self.keys[key][1] if self.keys[key][0] else None
def put(self, key, value):
self.keys[key] = [True, value]
def delete(self, key):
self.keys[key] = [False, None]
def write(self):
wb = rocksdb.WriteBatch()
for k, (s, v) in self.keys.items():
if s:
wb.put(k, v)
else:
wb.delete(k)
self.db.write(wb)
Right. But this still does not provide read-write or write-write conflict detection. I do need transactions for that.
Right. But this still does not provide read-write or write-write conflict detection. I do need transactions for that.
Can you explain that a little more?
Transactions can give you guarantees that no other thread has updated an entry your transaction is modifying or depending upon. See https://github.com/facebook/rocksdb/wiki/Transactions
I'm using threading.RLock
for that. I think what you want there is a "simple" workaround for that, but the Transactions
is currently not supported.
I appreciate you trying to help, but you are not understanding the problem and I am not looking for workarounds. This bug is about the missing support for transactions as provided by rocksdb.
for what it is worth sqlite lsm extension support transactions and you build it standalone as shared lib.
HTH.
https://github.com/coleifer/python-lsm-db