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] System.IndexOutOfRangeException in GetCollectionIndexesSlots() #1701

Closed
mikhail-khalizev opened this issue May 30, 2020 · 1 comment
Closed
Labels

Comments

@mikhail-khalizev
Copy link

Version
5.0.8

Describe the bug
I started getting the IndexOutOfRangeException exception when updating a document in the database.

Code to Reproduce

[Fact]
public void MyTest()
{
    var cs = new ConnectionString();
    cs.Connection = ConnectionType.Direct;
    cs.Upgrade = true;
    cs.Filename = Directory.GetCurrentDirectory() + "\\..\\..\\..\\app.db";
    var App = new LiteDatabase(cs);
    App.Timeout = TimeSpan.FromSeconds(10);
    App.UtcDate = true;

    var Devices = App.GetCollection("devices");
    // Devices.EnsureIndex("device_chip_id", x => x.SystemInfo["cpu"]["id"], true);
    // Devices.EnsureIndex(x => x.Thumbprint, true);
    // Devices.EnsureIndex(x => x.Order);

    var doc = (BsonDocument)JsonSerializer.Deserialize("{\"_id\":144479156,\"Order\":0,\"SystemInfo\":{\"time\":{\"$date\":\"2020-05-30T16:39:51.7730000Z\"},\"lastTimeUpdate\":{\"$date\":\"2020-05-30T15:47:39.0850000Z\"},\"timezone\":180,\"name\":\"awatem-autowatering-0-proto\",\"version\":\"v11-26-g8fa387b-dirty\",\"cpu\":{\"package\":\"ESP32-D0WDQ5\",\"revision\":1,\"cores\":2,\"freq\":240000000,\"id\":\"84-0d-8e-ec-f8-a4\",\"timeSinceBoot\":{\"$date\":\"1970-01-01T00:03:51.8440000Z\"},\"resetReason\":\"RstWdt\",\"ram\":{\"dram\":{\"total\":278100,\"allocated\":160788,\"free\":117312,\"freeMinimum\":109028,\"largestFreeBlock\":113792,\"reserved\":{\"data\":16076,\"bss\":32144}},\"iram\":{\"total\":48740,\"allocated\":28924,\"free\":19816,\"reserved\":114855},\"external\":{\"total\":4175620,\"allocated\":111968,\"free\":4063652,\"freeMinimum\":3879356,\"largestFreeBlock\":4055952}},\"flash\":{\"id\":13123608,\"size\":16777216,\"sectorSize\":4096,\"speed\":80000000,\"mode\":\"qio\"}},\"partitions\":[{\"label\":\"factory\",\"type\":\"App\",\"subtype\":\"Factory\",\"boot\":true,\"running\":true,\"size\":4194304,\"app\":{\"name\":\"awatem-autowatering-0-proto\",\"version\":\"v11-26-g8fa387b-dirty\",\"buildTime\":\"2020-05-29T23:13:29Z\",\"idfVersion\":\"v4.0.1-dirty\",\"size\":3204720}},{\"label\":\"ota_0\",\"type\":\"App\",\"subtype\":\"Ota0\",\"forNextUpdate\":true,\"size\":4194304},{\"label\":\"ota_1\",\"type\":\"App\",\"subtype\":\"Ota1\",\"size\":4194304},{\"label\":\"fs\",\"type\":\"Data\",\"subtype\":\"Any\",\"size\":4063232,\"filesystem\":{\"size\":4063232,\"free\":3637248}}],\"wifi\":{\"sta\":{\"ssid\":\"Micky53-v2\",\"bssid\":\"28-c6-8e-3c-b0-10\",\"channel\":11,\"bandwidth\":\"HT40\",\"rssi\":-56,\"auth\":\"Wpa2Psk\",\"phy\":\"b/g/n\",\"ip\":\"192.168.1.7\",\"netmask\":\"255.255.255.0\",\"gateway\":\"192.168.1.1\",\"mac\":\"84-0d-8e-ec-f8-a4\"}}},\"Configuration\":{\"version\":24,\"script\":{\"file\":\"script/main.js\"},\"wifi\":{\"networks\":[{\"ssid\":\"Micky53-v2\",\"password\":\"*************\"}]},\"device\":{\"soil\":{\"1\":{\"moisture\":{\"type\":\"auto\",\"percent0\":1416,\"percent100\":1428}},\"2\":{\"moisture\":{\"type\":\"auto\",\"percent0\":1370,\"percent100\":1502}}}},\"timezone\":180,\"lastTimeUpdate\":\"2020-05-30T15:47:39.085986Z\"},\"Thumbprint\":\"1F6D2AA1F5898D8978BC8F7A3AAAE19A9E9DEB94\"}}");
    
    Devices.Update(doc); // Throw IndexOutOfRangeException.
}

app.db.zip

Expected behavior
No exception throw.

@lbnascimento
Copy link
Collaborator

@mikhail-khalizev This issue has been fixed in master and its fix will be present in the next incremental release.

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

2 participants