-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Unstable behaviour when inserting from multiple threads #1537
Comments
@domibies I've just cloned your repo and let it run on my machine as well, and I got the NullReference as well. The main question is now, what exactly is causing it 😓 |
Ok, try this : set DeleteEveryXSeconds to 10 instead of 3, and then (on windows) you see the behaviour I was first getting. First the inserting threads block on their db operations (screenshot below), and then they throw on EnterTransaction() Tried the same on macOS, and after more than 10 minutes, it's still running... LiteDB.LiteException |
crashed 5 minutes later (null reference exception) |
@domibies Could you test with the current master? The transaction model was entirely rewritten. |
@lbnascimento With the current master it does seem to be stable running for more than 1h almost 25M inserts & deletes from 32 threads. The 'auto checkpoint' behaviour seems to be gone? If I don't call LiteDataBase.Checkpoint() explicitly the *.db stays small, and the *-log.db keeps growing. Regulary calling CheckPoint() works fine. |
Version : LiteDB v5.0.3, tested on both Windows & Macos, both show unstable behaviour, but expose different errors
When inserting (a lot) from different threads, after a while, the operations on the Db lock (timeout after 1:00), mostly on Windows, or crash (null reference exception), mostly on MacOS
(edit : now crashes also on windows, as on Mac OS, see *note below)
I have witnessed the behaviour in a more complex scenario involving receiving messages multithreaded from Azure service bus, but I could reproduce it as follows.
I have written a small program that shows this behaviour. On windows, this programs shows some stats in the console for a while (as little as 30 seconds, or sometimes several minutes), until all threads lock on any insert or delete action, for one full minut, and then the code throws an exception.
you can find the program here :
https://github.com/domibies/litedb-mt-test
On MacOS, it crashes after a while.
I would expect the process to stay stable in this scenario.
a stack trace from macOS :
Unhandled exception. Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at LiteDB.Engine.TransactionMonitor.b__15_0(UInt32 id)
at LiteDB.Engine.TransactionService.Commit()
at LiteDB.Engine.LiteEngine.AutoTransaction[T](Func
2 fn) at LiteDB.LiteCollection
1.Insert(T entity)(*note : Hmm, weird, I just cloned the above repository on a windows machine, and now I'm getting the same behaviour on Windows as on MacOS (the NullReferenceException). I'm pretty sure that exactly the same source code (but project initially created on windows) showed other behaviour on windows (hanging threads, followed by a timeout exception "Timeout.DataBase is locked for more than 00:01:00. ...."))
The text was updated successfully, but these errors were encountered: