[BUG] The process cannot access the file even on "shared" connection
See original GitHub issueVersion .NET 5, LiteDB 5.0.11
Describe the bug
The process cannot access the file 'xxx' because it is being used by another process.
during Upserts and Deletes in a very heavily used web app.
Too bad, I though LiteDB is thread safe.
Should I maybe create one static instance of db
and keep using it throughout the app? Will it be thread-safe then?
Full exception
System.IO.IOException: The process cannot access the file 'xxxx' because it is being used by another process.
at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at LiteDB.Engine.FileStreamFactory.GetStream(Boolean canWrite, Boolean sequencial)
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at LiteDB.Engine.DiskService..ctor(EngineSettings settings, Int32[] memorySegmentSizes)
at LiteDB.Engine.LiteEngine..ctor(EngineSettings settings)
at LiteDB.SharedEngine.OpenDatabase()
at LiteDB.SharedEngine.Delete(String collection, IEnumerable`1 ids)
at LiteDB.LiteCollection`1.Delete(BsonValue id)
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
Build error: "The process cannot access the file because it ...
I have found a simple solution which works for me. It goes like this: When the problem occurs, just change the building configuration...
Read more >FIX The Process Cannot Access the File Because It ... - YouTube
FIX The Process Cannot Access the File Because It Is Being Used by Another Process Commands Shown: net stop http net start http...
Read more >Process can't access the file because it is being used by ...
To resolve it, first make sure that no users have the file open anywhere, then reboot the machine to make sure it is...
Read more >The process cannot access the file because it is being ...
The process cannot access the file because it is being used by another process. Microsoft Technologies based on the . NET software framework....
Read more >[BUG] Cannot access the file... it is being used by another ...
Hello. By default, context is creating with the Direct connection mode which means that the database file cannot be opened by another process....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi Team,
LiteDb: 5.0.11 .NET Framework 4.8
I am also facing the same issue, and I can able to fix this issue, by applying the code changes given in https://github.com/mbdavid/LiteDB/issues/1893
When we can expect the next release or patch update for this fix.
Still getting this with 5.0.15. Hits certain customers only. Can’t see that they’re on a network share. We store data under %ProgramData% though there’s potential that is on a network share, but our diagnostic logs aren’t showing network drives.
Restarting the services fixes it for a while then happens again and locked out until restarted.