Closed justdmitry closed 2 years ago
Tried to write to other collection in same database - same failure. Tried to create separate DB with only one collection - same failure.
I found that bug is related with index somehow.
Here is my class:
public class SwapChance
{
public ObjectId Id { get; set; }
public string Rarity { get; set; } = string.Empty;
public int Template1Id { get; set; }
public int Template2Id { get; set; }
public List<string> Accounts1to2 { get; set; } = new List<string>();
public List<string> Accounts2to1 { get; set; } = new List<string>();
}
And I create this indexes to be able to search by individual account in lists:
collection.EnsureIndex(x => x.Accounts1to2);
collection.EnsureIndex(x => x.Accounts2to1);
If I remove indexes (recreate collection without them) then everything works Ok.
Hi @justdmitry, thanks for reporting this and all your tests and context, it's important for us to understand the situation and simulate the problem. So, regarding this issue, I already find the problem, I'm currently working to find the best fix for that
Hi @justdmitry, just committed a fix for this issue in the master branch
Version LiteDB 5.0.11 in .NET 6.0.1 in Ubuntu 18.04
Describe the bug Insert (and InsertBulk) fail with "LiteDB ENSURE: slot position must be empty before use" when inserting new items into collection second time (after DeleteAll).
Code to Reproduce
Expected behavior Insert operations should succeed.
Screenshots/Stacktrace
Additional context This collection holds about 150 records. By timer (once per 15min), collection is cleared with DeleteAll and re-populated (usually with same data, changes are rare). First time (once after collection created after deletion) everything works Ok. On second round, exception is raised. Tried to replace InsertBulk with one-by-one Insert - several records (~30-40) are inserted, then exception. Tried to remove collection and rebuild database - no luck.
Sample of data being saved (via System.Text.Json):