pmwkaa / sophia

Modern transactional key-value/row storage library.
http://sophia.systems
Other
1.85k stars 153 forks source link

assert during db fill and warmup #136

Closed pmwkaa closed 8 years ago

pmwkaa commented 8 years ago

By Pavel Nevezhin (source: https://groups.google.com/forum/#!topic/sophia-database/vtJGRtIHG60)

I started getting "Segmentation fault" and "sophia/index/si_node.h:57: si_nodelock: Assertion `! (node->flags & 1)' failed." errors on filling and warmup db. Is this known issues or i have mistakes in make configuration?

Test case:

#include <stdio.h>

#include "sophia/sophia.h"

int main(int argc, char *argv[])
{
    (void)argc;
    (void)argv;

    void *env = sp_env();
    sp_setstring(env, "sophia.path", "_test", 0);
    sp_setstring(env, "db", "test", 0);
    sp_setstring(env, "db.test.scheme", "uid", 0);
    sp_setstring(env, "db.test.scheme", "tm", 0);
    sp_setstring(env, "db.test.scheme", "value", 0);
    sp_setstring(env, "db.test.scheme.uid", "u64,key(0)", 0);
    sp_setstring(env, "db.test.scheme.tm", "u64,key(1)", 0);
    sp_setstring(env, "db.test.scheme.value", "string", 0);

    sp_setint(env, "db.test.direct_io", 1);
    sp_setint(env, "db.test.mmap", 0);

    void *db = sp_getobject(env, "db.test");
    int rc = sp_open(env);
    if (rc == -1)
        goto error;

    /* set */
    uint64_t i = 0;
    uint64_t k = 0;
    uint32_t param1 = 100000;
    uint32_t values = 1500;

    for (i = 0; i <= param1; i++) {
        void *tx = sp_begin(env);
        uint64_t uid = i;
        for (k = 0; k <= values; k++) {
            void *o = sp_document(db);
            char value[48];
            sprintf(value, "%d", (int)k);
            sp_setstring(o, "uid", &uid, sizeof(uid));
            sp_setstring(o, "tm", &k, sizeof(k));
            sp_setstring(o, "value", &value, sizeof(value));
            rc = sp_set(tx, o);
            if (rc == -1)
                goto error;
        }
        sp_commit(tx);
    }
    /* finish work */
    sp_destroy(env);
    return 0;

error:;
    int size;
    char *error = sp_getstring(env, "sophia.error", &size);
    printf("error: %s\n", error);
    free(error);
    sp_destroy(env);
    return 1;
}