question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] currupt or damaged records version 5.0.5 and newer

See original GitHub issue

Version Running on linux docker using master version up to commit below as i needed one of the othere fixes. https://github.com/mbdavid/LiteDB/commit/96e4ee71c0250e1349d13e86730e5d62319f715d

Describe the bug When the database is used i am finding that some of my records are getting damaged. It seems to relate to fields of type Dictionary<string,guid> on the class i am saving but a standard unit test can’t duplicate. Further details on the question i opened (https://github.com/mbdavid/LiteDB/issues/1600). I started debugging the read since i can’t easily duplicate the write issue in a dev environment and it looks like a records gets over ridden by another or something strange like a byte being wrong causing things to get mixed up.

Code to Reproduce Use the attached database and the code below damaged database.zip

            using (var db = new LiteDatabase(@"O:\drive issues\VirtualFileSystem_litedb_stuffed.db"))
            {
                var col = db.GetCollection<VirtualDirectory>("directories");
                var dir = col.FindById(Guid.Parse("3e70872d-30cf-47f9-b360-782b034b6b95"));
            }

        public class VirtualDirectory
        {
            public Guid Id { get; set; }
            public ulong Size { get; set; }
            public uint RefCount { get; set; }
            public ushort Permission { get; set; }
            public DateTime ATime { get; set; }
            public DateTime MTime { get; set; }
            public DateTime CTime { get; set; }

            //info about dir ref count being 2 for empty directory
            //https://unix.stackexchange.com/a/153640

            public Dictionary<string, Guid> Files { get; set; } = new Dictionary<string, Guid>();
            public Dictionary<string, Guid> Directories { get; set; } = new Dictionary<string, Guid>();

            internal VirtualDirectory()
            {
            }
        }

Expected behavior The instance of the class should be returned correctly from the database

Screenshots/Stacktrace System.NotSupportedException: BSON type not supported at LiteDB.Engine.BufferReader.ReadElement(HashSet`1 remaining, String& name)

Additional context Add any other context about the problem here.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:13

github_iconTop GitHub Comments

2reactions
seertenedoscommented, Apr 8, 2020

@lbnascimento i spoke too soon. seems i was not catching all exceptions. Sadly i think i need to look at another DB for now as i keep hitting too many bugs in LiteDb and i am spending more time trying to find them code around them than my actual application. The project is great but there real needs to be a clear difference between the stable releases and the beta ones and really get the fixes released a little faster for testing for bad releases like the latest one was.

0reactions
asmejkalcommented, Jun 20, 2020

Having the same issue since I’ve upgraded to v5. Similarly to the OP, it seems to be related to a Dictionary<string, BsonDocument> property (in C# it’s a Dictionary<ulong, class>, but the ulong seems to get serialized as a plain string). I suspect this, because it only happens to this specific collection.

Some of the documents in this collection are getting randomly corrupted, which prevents them from deserializing. This happens to a few specific documents, while all the other documents in the collection can be deserialized just fine (despite also having data in the dictionary). I can export the document to JSON, fix it manually and Upsert it back into the collection. It works fine for a few minutes, but then it gets corrupted again. Same as OP, this is a multithreaded program.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[QUESTION] Strange issue records getting damaged #1600
Basically my database is having around 90000 records over 3 ... looks like the database is getting corrupt or damaged so will open...
Read more >
Many crashes and corrupt files since 5.0.6 (character "ÿ" in files)
I have many problems since 5.0.6 up to newest beta 5.0.7 (717). ... or when doing Search and Replace in files, often files...
Read more >
Corrupted record - how it happened and how to recover it?
So I tried a recovery first which in the new versions rewrites all indexes. The recovery reported 'no problems found'. In the recoverd...
Read more >
The kubeconfig file being updated by oc command
Hi, all, could you please tell me your steps to make the file corrupt with old oc version? Thanks! To verify the bug,...
Read more >
CR2 files from CANON will corrupted when preview b...
Problem is once a file is corrupted I can't recover or undo what Adobe Bridge or ACR dose to it I lose the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found