{"action":"opened","issue":{"url":"https://api.github.com/repos/symisc/unqlite/issues/43","repository_url":"https://api.github.com/repos/symisc/unqlite","labels_url":"https://api.github.com/repos/symisc/unqlite/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/symisc/unqlite/issues/43/comments","events_url":"https://api.github.com/repos/symisc/unqlite/issues/43/events","html_url":"https://github.com/symisc/unqlite/issues/43","id":197323991,"number":43,"title":"Unqlite lost some key-value pair after commit","user":{"login":"onto","id":768585,"avatar_url":"https://avatars.githubusercontent.com/u/768585?v=3","gravatar_id":"","url":"https://api.github.com/users/onto","html_url":"https://github.com/onto","followers_url":"https://api.github.com/users/onto/followers","following_url":"https://api.github.com/users/onto/following{/other_user}","gists_url":"https://api.github.com/users/onto/gists{/gist_id}","starred_url":"https://api.github.com/users/onto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onto/subscriptions","organizations_url":"https://api.github.com/users/onto/orgs","repos_url":"https://api.github.com/users/onto/repos","events_url":"https://api.github.com/users/onto/events{/privacy}","received_events_url":"https://api.github.com/users/onto/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-23T07:22:01Z","updated_at":"2016-12-23T07:22:01Z","closed_at":null,"body":"I found strange bug, for some keys unqlite lost some key-value pair after commit, I write code for reproduce it:\r\n```cpp\r\n#include <string>\r\n#include <ctime>\r\n#include <cstdint>\r\n\r\nextern \"C\" {\r\n#include \"../UnQLite-kv/unqlite.h\"\r\n}\r\n\r\nstruct TestStruct\r\n{\r\n    double d1;\r\n    double d2;\r\n};\r\n\r\nint main(int argc, char **argv)\r\n{\r\n    std::string filename(\"TEST.\" + std::to_string(time(nullptr)));\r\n    TestStruct test = { 1.0, 1.1 };\r\n\r\n    // Fill database \r\n    {\r\n        unqlite *db = nullptr;\r\n\r\n        int res = unqlite_open(&db, filename.c_str(), UNQLITE_OPEN_CREATE);\r\n        if (res != UNQLITE_OK)\r\n        {\r\n            return res;\r\n        }\r\n\r\n        for (int64_t i = 0; i < 165; ++i)\r\n        {\r\n            int res = unqlite_kv_store(db, &i, sizeof(int64_t), &test, sizeof(TestStruct));\r\n            if (res != UNQLITE_OK)\r\n            {\r\n                return res;\r\n            }\r\n        }\r\n\r\n        res = unqlite_close(db);\r\n        if (res != UNQLITE_OK)\r\n        {\r\n            return res;\r\n        }\r\n    }\r\n\r\n    // Reopen\r\n    {\r\n        unqlite *db = nullptr;\r\n\r\n        int res = unqlite_open(&db, filename.c_str(), UNQLITE_OPEN_CREATE);\r\n        if (res != UNQLITE_OK)\r\n        {\r\n            return res;\r\n        }\r\n\r\n        // Write pair with key 162 again\r\n        int64_t i_bug = 162;\r\n        res = unqlite_kv_store(db, &i_bug, sizeof(int64_t), &test, sizeof(TestStruct));\r\n        if (res != UNQLITE_OK)\r\n        {\r\n            return res;\r\n        }\r\n\r\n        // Force commit\r\n        res = unqlite_commit(db);\r\n        if (res != UNQLITE_OK)\r\n        {\r\n            return res;\r\n        }\r\n\r\n        // Test pair with key 164, it lost\r\n        int64_t i = 164;\r\n        TestStruct test1= {};\r\n        unqlite_int64 buf_size = sizeof(TestStruct);\r\n        res = unqlite_kv_fetch(db, &i, sizeof(int64_t), &test1, &buf_size);\r\n        if (res != UNQLITE_OK)\r\n        {\r\n            printf(\"%d\", res); //Yep, print -6 there\r\n            return res;\r\n        }\r\n\r\n        res = unqlite_close(db);\r\n        if (res != UNQLITE_OK)\r\n        {\r\n            return res;\r\n        }\r\n    }\r\n\r\n    return 0;\r\n}\r\n```\r\nFor this types of key and value, after reopen database and write pair with key 162 and force commit unqlite lost pair with key 164. \r\nI check it with last unqlite and unqlite-kv sources on msvc2013"}}
{"actor":{"display_login":"onto"}}