Insert-during-iterate deadlock #73
-
In my application I sometimes generate DB entries from existing entries. The pattern is that I iterate over a range of existing keys, occasionally creating new entries (outside the iterator range) as I go. It looks like Fjall is deadlocking in this scenario after some number of insertions. I thought perhaps using the snapshot feature would help, but it makes no difference. Glancing at the code, I can see that I thought about reporting this as an issue but if this kind of usage is an explicit non-goal of Fjall I didn't want to do that. Is this supported? Supportable? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hmm yeah this is a bit of a conundrum.
Yeah, this is correct. I think using try_lock may fix this, but as a consequence memory usage may grow past its intended limits because all the write buffer checks need to be skipped. Insert ( |
Beta Was this translation helpful? Give feedback.
-
Writing to a batch should work though... (a transaction would also work) let mut batch = keyspace.batch();
let iter = db.snapshot().iter();
for kv in iter {
batch.insert(&db, k, v);
}
batch.commit()?; |
Beta Was this translation helpful? Give feedback.
-
I will track this in #74 I think there are some things that can be improved |
Beta Was this translation helpful? Give feedback.
Writing to a batch should work though... (a transaction would also work)