aergoio / litetree

SQLite with Branches
MIT License
1.62k stars 35 forks source link

branch and thread ? #19

Open patrickkh7788 opened 4 years ago

patrickkh7788 commented 4 years ago

Is the multi branch work with multi thread or process ?

I mean for example branch master work on thread A, and test for thread B at same time without lock ?

kroggen commented 4 years ago

Hi!

It supports many connections to the same database on a single thread (as you can see in the tests).

But many threads writing to the db at the same time, probably not.

With LMDB it is suggested that the writes are serialized and implemented on a single thread.

It does not mean that it is impossible to implement multi-threading support. Writes would need to be redirected to a dedicated worker thread. Or maybe using a mutex.

Many processes using the same db: not tested. Maybe it can work because LMDB uses a lock file.

patrickkh7788 commented 4 years ago

If there is one write thread, and multi read thread with diff branch. will this work ?

kroggen commented 4 years ago

Yep, it should work. Although not tested yet.

You can make a multi-threaded test based on the test04_concurrent_access function from test.py