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

[BUG] LiteDB will return null for DB entries by the very first access #2528

Open
michtoen opened this issue Aug 1, 2024 · 0 comments
Open
Labels

Comments

@michtoen
Copy link

michtoen commented Aug 1, 2024

Version
LiteDb 5.0.21 on .net 8 (linked in by standard 2.0 dll)

Describe the bug
When we start our app with liteDB 5.0.21, it will access a row of liteDBs. In 50% of the INITIAL access to that DB it will fail to initialize the return for some fields of a dictionary with the right values but set them to null. Any access after the first one will return the right values, always.

The data is simple:

class FileData
{
    public string Path { get; set; } 
    public string Key  { get; set; }
}

class _fileDataDic
{
    public string id { get; set; }
    public Dictionary<string, FileData> dic { get; set; }           
}

// The DB is created with 
Dictionary<string, FileData> entry = new() {"foo.jpg", new() {Path = 'ABC', Key = "123"}};

 var col = db.GetCollection<_fileDataDic>("Example");
 col.Insert("FOO", new _fileDataDic { id = "FOO", dic =  entry});

// We access by this:
var col = db.GetCollection<_fileDataDic>("Example");
_fileDataDic fileDataDic = col.FindById("FOO");

In 50% now the returned fileDataDic will look like this

{
  "id": "FOO",
  "dic": {
    "foo.jpg": {
      "Path": null,
      "Key": null
    }
  }
}

Path & Key are NOT null in the DB. A second request will return the right values for Path & Key

  • the effect will occur always when we start the app to around 50% off all DBs initial accesses
  • there is ATM always only one entry in the dictionary
  • it will vanish with the 2nd access
  • it never happens and works flawless in 5.0.20 and lower
  • we have build the (original 5.0.20) DB with 5.0.21 but the effect is the same - it is not the DB
  • we have not hard tested deeper but it seems to work after it

The LiteDB will be called by a Microsoft.AspNetCore.Mvc Controller.

@michtoen michtoen added the bug label Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant