-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Unable to cast object of type 'LiteDB.EmptyPage' to type 'LiteDB.HeaderPage' #641
Comments
Are you using master branch version or 3.1.1 from Nuget? |
Yes, version 3.1.0 from Nuget .. 3.1.1 was too slow so I downgraded .. it's a UWP windows 10 app |
I started getting InvalidCastException
|
this error occurs in some concurrency scenarios. I'm working on this to fix |
I have added the option FileOptions.WriteThrough when opening the data file at 2017.6.13. The version of LiteDB is 3.1.1.0 with a modify of adding the option FileOptions.WriteThrough. The first exception is System.Threading.SynchronizationLockException: The write lock is being released without being held. Then, It came after the program being restarted System.InvalidCastException: Unable to cast object of type 'LiteDB.EmptyPage' to type 'LiteDB.HeaderPage'. |
Hi @lidanger, I'm working on it in "nojournal" branch. It's not finish, but you can check. |
@mbdavid, that's good.I'll try. |
Hi, I have a similar issue, here is my stack trace: System.InvalidCastException: 'Unable to cast object of type 'LiteDB.EmptyPage' to type 'LiteDB.IndexPage'.' at LiteDB.PageService.GetPage[T](UInt32 pageID) Thanks for investigating |
Hi, I have a similar issue too , here is my stack trace: System.InvalidCastException: Unable to cast object of type 'LiteDB.EmptyPage' to type 'LiteDB.DataPage'. |
Hi @JasonGrass, I never got this error anymore (on v4.x). Can you use LiteDB.Demo project (inside LiteDB source) to make a replication of this error? |
Here is the broken db file , |
Same thing. Got this exception recently. Version is 4.1.1 (from Nuget)
And here's the code producing it: |
Hi @guys, this code/database already has broken and only with this I can replicate this broken problem. I never got this problem in v4.x. How are using LiteDB over concurrency? Are web/mobile or desktop app? How write operations are made? If possible, create a sample example using LiteDB.Demo project. I made this project just to catch this kind concurrency of problem. |
Hi @mbdavid! |
Hi @os-alan, if you could reproduce this error in v4 please send to me. After corrupt database I can test anymore. |
Hey there - My team's product has been using LiteDB for a little while without seeing this problem. It's possible the people who are seeing this had an existing .db/.journal file and it was upgraded to v4. I haven't been sure what to ask them. Would it be helpful for me to get their .db files and share them here? |
Hi @MarjieAVolk, will be very helpfull if you can send me a copy of this corruped database to check. Did you know if this datafile was updated from v3? In v3 you don't have this problem? |
Yes, in v3 I did not have the problem. But I also was not using concurrency in the same way. I will ask these people for their db files. Thanks. |
Okay, I got one of the .db files that is seeing the error: This is the exact stack trace they reported:
|
Any updates on this? Did that file have the same issue? |
Hi @MarjieAVolk, not yet, sorry. I will try check this soon. |
Here's another one:
|
I see these are different stack traces, so maybe I should file separate bugs for each one? |
Both error are caused with same problem: looking for wrong page. Thats happend when, for some reason, page are corrupted and one page are linking to a wrong page (with different type). What collection name are you inserting/finding? |
I knew I should have copied the full stack traces, haha. Okay, for the first one I sent, it will be a CraftAction. For the second one, it is a PickUpAction. |
Hi @MarjieAVolk, is this second database corrupted by an bug that was "added" in commit on 11/dec here: |
You are saying the error is fixed in 4.1.2? I haven't really been able to reproduce these errors on my own machine, I only get reports of them from our players. Do you want me to check whether the second database works when run on 4.1.2? |
If you can not reproduce the error, you can only update your source code to use 4.1.2 to check if you will get more users error report (with datafiles created in v4.1.2). In datafiles with this error in old version is not possible do anything because datafile are corrupted. If this problem occurs again (i hope no :) you can open another issue about this because this error is not same as in this issue (same error message but different reasons) |
Okay, we haven't had complaints of this for a long time, but we just got another one. We are still on 4.1.2, so it might not be relevant to the current release, but here it is just in case:
The bad .db file: |
Hi, we're using v4.1.4 and since yesterday get the same error on different tables. |
Same Issue. LiteDB Ver 4.1.4 from nuget. |
Hi. I am seeing this same exception under heavy-ish load with multiple threads. Using v4.1.4 in a .NET Core web api project running in a Linux docker container hosted in Azure. Does anyone know of any safe threshold for concurrent tasks where I may not run into this issue? |
Hi @mbdavid , My question is: Is there a way to skip the corrupted items? var col = db.GetCollection<MyDbItem>(TABELA_STATES);
var all = col.FindAll();
foreach (var i in all) //THIS LINE THROWS THE ERROR WHEN IT REACHES THE CORRUPT ITEM!
{
// Some code
} Thanks |
Hi @mbdavid, Thanks |
Hi @scr4py4rd, sorry about this problem. I try reproduce this error for a long time and get no way to reproduce... so was not possible to fix yet. I about away from LiteDB project for some time because I need focus in my full work job. I believe that I will back next month. I writing v5 and my plans is fix all this in this new version because v5 works quite different in a more robust memory/manage way... |
Having had time pass allowed for some more observation. Though still not very clear, the issue tends to surface when some other process or thread does a file-read on the database file, like perhaps a file-copy, during which time the LiteDB library is active with it. |
Hi @mbdavid, thanks for your reply. Do you have a plan, when v5 will be ready? |
This is our exception stack. We use the newest version from Nuget. It seems like a tough bug surviving several versions.
|
Tried your current v5 branch and get a similiar exception. |
I can safely reproduce this error on my HDD. In method i do:
After starting the application and seeing file size of the db growing (in explorer) i close the console process. |
@scr4py4rd : If i use only one connection without disposing it, i am not able to produce the error. Maybe you can try using it as singleton. |
@jmahlitz : I use it in an asp core application, define it as singleton in the core dependency injection IServiceCollection and use it in mode exclusive. Attached my testcode to crash the file: I create a new database without any special parameter, create 3 collections with 5000 entries and start from multiple other threads read&write access. With version 5, I get with attached code an error in 2 of 3 runs: With version 4 I can't reproduce the crash, it appears only in production system every ~4-6 days (6000 write / 12000 read operations per day) |
@mbdavid Any workarounds / suggestions for now? I'm having this issue too, after database was corrupted by sudden power-out |
+1 I have this issue too, thanks |
I get this problem as well, For me it happens when I am trying to drop the collection and the error is slightly different, "Unable to cast object of type 'LiteDB.IndexPage' to type 'LiteDB.DataPage'.". The database shouldn't be in use by anything else |
Seeing this in 4.1.4... |
This was using 4.1.4, in Unity on an Android device. |
I had the same problem yesterday. "Não é possível converter um objeto do tipo 'LiteDB.EmptyPage' no tipo 'LiteDB.DataPage'. |
Saw this error enough that I quickly went back to sqlite, no errors since the migration back |
i have the same issue in version 4.1.4.0 [InvalidCastException: Unable to cast object of type 'LiteDB.HeaderPage' to type 'LiteDB.CollectionPage'.] |
Hello, any update on this issue, is there any workaround? |
This issue should have been fixed a year ago, i will close this issue for now. Please let me know if the problem persists anyway. |
Closed the app and now it's happening.
The text was updated successfully, but these errors were encountered: