Skip to content
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

Changes to properly support Mutexes on NET6.0 #2206

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

conradmicallef
Copy link

Global Mutexes were being created without insufficient rights for a 2nd process running on same machine to use them

This fix addresses that by using same methodology applied to NETFRAMEWORK but to NET6.0

Global Mutexes were being created without insufficient rights for a 2nd process running on same machine to use them
@inbarbarkai
Copy link

Is there any plan on merging this PR?

@tjmoore
Copy link

tjmoore commented Oct 20, 2023

Any update? What's the symptom without this fix, is there a particular error raised?

Looking for solutions to access denied errors on shared mode access, but I'm not seeing it on the mutex but on the journal file (and only one process is writing, the other opens database in read mode).

@JKamsker
Copy link
Collaborator

JKamsker commented Jun 4, 2024

I would also like to see some repro code before merging this.

@inbarbarkai
Copy link

@JKamsker I can't provide a repro, but I can provide the scenario.

Environment: Windows 10/11
Version: 5.0.12

2 writer processes from different users.
1 of the writers is also a reader.

This happened sometimes during our tests, but our customers encountered it all the time, forcing us to release a patch disabling some functionalities.
We replaced it with SQLite to restore those functionalities.

@JKamsker
Copy link
Collaborator

JKamsker commented Jun 5, 2024

@inbarbarkai Oh i remember now, i had a similar problem with named pipes and different users.

Ok thank you for the clarification! I will try to get to it asap :)

@JKamsker JKamsker self-assigned this Jun 5, 2024
@tjmoore
Copy link

tjmoore commented Jun 5, 2024

Similar to above, have not reproduced the issues we see, but have had them from customers, particularly this kind of error.

System.IO.IOException: The process cannot access the file 'C:\\XXX\\somedatabase.db' because it is being used by another process.

This occurs either on .db or the log, and the processes all open the database in shared mode. Have tried long and short lived instances of LiteDatabase also (I believe in shared mode it is internally opening and closing connections on each operation so likely makes little difference, unlike direct mode).

Could this occur if the mutexes aren't being acquired right? Though would you see a mutex error instead? Or is there a potential race condition somewhere?

We've done extensive diagnostics and cannot see what the other process is. Some customers show signs of things like Microsoft Defender for Endpoints (the corporate version of Defender) access files but looks more like it detecting file access not actually opening and locking files. Other customers don't have anything like this though.

Any solution needs to be proven fix to roll out to customers though as already got frustrated customers, hence repo is very desirable.

Only alternative have thought about is to move to a single process for database operations and some communication between them. Getting into building a database server territory though and already considering supporting MongoDB as an alternative to LiteDB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants