Replies: 2 comments 1 reply
-
Hey! you can implement the I would consider using a reentrant mutex (just google it, there are multiple Go packages, and they are all based on Go runtime internals to get goroutine ID) or I would extend your current API in the way when the user can disable lock using optional argument. Something like:
https://go.dev/play/p/MXA-d_lvt1h You also can create a lock-free API and/or only lock-free methods. (ie: Peek method above) Another option would be to completely redesign your API to use an event driver pattern and have only one place where you can control everything but I think it is out of your scope. :) Let me know what you think. |
Beta Was this translation helpful? Give feedback.
-
Problems can happen when you search and insert into the tree in parallel.
For example, when the search goes through one node, and at the same moment,
the same node is modified.
`ErrConcurrentModification` has been implemented to avoid tree modification
while using the iterator. This is a tribute to the Java iterator. :)
Pavel
…On Thu, Aug 4, 2022 at 4:09 PM James Mills ***@***.***> wrote:
@plar <https://github.com/plar> One thing I've noticed in your
implementation of ART is that you already use some kind of lock-free
patterns in many of the tree traversal methods by copying the root node or
the current node to a local variable. If I'm reading the code right?
So I'm wondering whether I need to lock a hold at all whilst searching the
tree at all? 🤔 experimenting with this idea
<https://git.mills.io/prologic/bitcask/issues/238#issuecomment-12324>
seems to suggest I don't -- but I'd hardly call that patch very
"scientific" 😅
—
Reply to this email directly, view it on GitHub
<#25 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAARYI7R76KBX3PA3MHGBYLVXREQ7ANCNFSM55RI5OXQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Hey @plar 👋
I know I asked this question in #9 once before and I answered it myself.
Been trying to solve a design issue with Bitcask and Deadlocks for a while now and looking for some help/guidance here.
Basic problem can be summarized as:
.Fold()
call we hold a Read lock on the tree.Get()
this tries to also acquire a Read lock on the treeExample:
This repro can be found in the deadlock_repro branch and is as simple as:
One way to solve this I think is to copy the tree. You don't currently expose an interface for though though so that's been quite hard to do. Would you consider this?
The downside of copying the tree is of course increased memory (2x) usage whilst performing search/scan operations on the database. But given we deadlock, maybe that's a good trade-off?
Keen to hear your thoughts, and I appreciate your time if you have any spare to offer up any helpful advice 🙏
Beta Was this translation helpful? Give feedback.
All reactions