Closed einarmo closed 5 days ago
Oh i see it now. Thats pretty bad, i am sorry for that. Would you mind pr'ing a fix?
I made a PR with a simple fix, though I'm not sure it is the best solution, since it will come with a performance cost that I think the original author of this code wanted to avoid.
Performance < Stability
Hey @einarmo can you have a look at my pr and if it solves your issue? My solution doesnt require locking all the time and should still be safe from race conditions
Version LiteDB 5.0.21 .NET 8.0.401 Linux (Fedora 38)
Describe the bug Specifically, what I see is an occasional stacktrace:
when running an expression like
Code to Reproduce I cannot reproduce this consistently, it only happens once in a while, likely while I am running multiple concurrent transactions not against the same collection, but using the same types.
I believe this is a race condition caused by #2493, here's the possible race I see that this PR introduced:
GetEntityMapper
here, and does not find the mapper.BuildAddEntityMapper
, and goes past this line, adding an entity mapper to the _entities dictionary.GetEntityMapper
.This code has existed for a long time, and this issue only started after updating to the latest version, which contains this fix. There may be a different cause, though my trace above seems plausible.