-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Description
I found that multi-threaded tokio runtime moves the task between threads, and this leads to let tx = env.write_txn() and tx.commit() to run in different threads. And the next call to env.write_txn() hangs.
let tx = env.write_txn()?; // thread A
while let Some(row) = stream.next().await {
insert_row(&mut tx, row)?;
}
tx.commit()?; // thread B
let tx = env.write_txn()?; // hangs[indexing] IndexBuilder tx is created in thread=ThreadId(9)
████████████████████████████████████████ 4317834/4317834
[indexing] IndexBuilder tx is committed in thread=ThreadId(17)
[task] lmdb - getting WriteTx in thread=ThreadId(17) # hangsSwitching to a single-threaded tokio runtime did not have a deadlock.
I found this in jnwatson/py-lmdb#89 (comment) :
A write Transaction can only be used from the thread it was created on.
Is it okay to commit a write transaction in a different thread?
If not, what is a recommended approach to interleave async workload with transactions?
Metadata
Metadata
Assignees
Labels
No labels