mbdavid / LiteDB

LiteDB - A .NET NoSQL Document Store in a single data file
http://www.litedb.org
MIT License
8.62k stars 1.25k forks source link

Exception: Datafile is not a LiteDB database. #1329

Open MestreDosMagros opened 5 years ago

MestreDosMagros commented 5 years ago

I think i found one of the reasons for the error: LiteDB.LiteException: Datafile is not a LiteDB database.

As i saw on other issues referecing this problem, is the database file that become kinda corrupt, but only when the system tryes to read, on the studio everything goes fine.

Im implementing the LiteDB in a very small project (.net core 2.2 console app as a windows service) and im using it just to keep track of the e-mails that im sending.

I faced this exception a bunch of times, then delete the db file and start again, but i noticed now, that i only have this problem when i read the file on the LiteDB Studio.

If i create a new file, everything goes fine until i open the database on the studio(dont tried on the shell), after i open the database on the studio i get this problem. Maybe the error is caused by it.

I dont have the time yet to investigate the code by my own, but im trying to help.

Cheers

mbdavid commented 5 years ago

Hello @MestreDosMagros (kkkk, nick muito engraçado!!)

I will try to reproduce this steps to check this. v5 use lock FileOpen concepts to not allow 2 process open same database at same time (only if both are using Mode=Shared). Are you using Mode=Embeded?

MestreDosMagros commented 5 years ago

kkkk Valeu!

I'm using shared mode, but the problem exists even when i got just my console app running after i open the db file externally.

For example, my service created a database an run ok, then i make a copy of that db file, and open one copy externally on the studio, with that file i get the error running the app, when i swap the file and use the one i dont opened externally it runs fine.

dfrencham commented 5 years ago

I'm having the same issue. I am using the latest 4.x version of LiteDB in my project, and the latest LiteDB Studio exe from github.

maurocristy87 commented 5 years ago

Same here

ghost commented 5 years ago

Same here, exact same.

biapar commented 5 years ago

+1

Pokis commented 4 years ago

We get it without even using studio. In very rare cases Store seems to fail, and after few failures to insert data, it starts to receive the error.

FAAAAT commented 4 years ago

+1

bkavuncu commented 4 years ago

+1 Opening db file with LiteDB Studio, app that created data file cannot open it again even when disconnected.

praiakov commented 4 years ago

+1

FarhadMohseni commented 2 years ago

+1

bar10dr commented 1 year ago

+1

rf0ster commented 8 months ago

+1