Code Monkey home page Code Monkey logo

Comments (2)

bytesnake avatar bytesnake commented on August 11, 2024 1

the default setting won't allow multiple txn_reader at the same time. A note in mdb_txn_begin (http://www.lmdb.tech/doc/group__mdb.html#gad7ea55da06b77513609efebd44b26920) clarifies this:

A transaction and its cursors must only be used by a single thread, and a thread may only have a single transaction at a time. If MDB_NOTLS is in use, this does not apply to read-only transactions. 

I totally missed this, with CHECK(rc = mdb_env_open(env, "./testing", MDB_NOTLS, 0664)); everything works fine :)

from rust-kv.

zshipko avatar zshipko commented on August 11, 2024

Thanks for reporting this!

I assumed this would work too, but after looking into this it seems to be a bit more complicated than I thought.

Even this minimal C reproduction exhibits the same behavior as your example:

#include <lmdb.h>
#include <stdio.h>
#include <stdlib.h>

#define CHECK(x)                                                  \
  {                                                                             \
    int y = x;                                                               \
    if (y != 0) {                                                            \
      printf("FAIL: %d: %d\n", __LINE__, y);              \
      abort();                                                               \
    };                                                                           \
  }

int main(void) {
  int rc;
  MDB_env *env;
  MDB_txn *txn, *txn2;

  CHECK(rc = mdb_env_create(&env));

  mdb_env_set_maxreaders(env, 1024);
  CHECK(rc = mdb_env_open(env, "./testing", 0, 0664));
  CHECK(rc = mdb_txn_begin(env, NULL, MDB_RDONLY, &txn));
  CHECK(rc = mdb_txn_begin(env, NULL, MDB_RDONLY, &txn2));

  mdb_txn_abort(txn);
  mdb_txn_abort(txn2);
  mdb_env_close(env);
  return 0;
}

I'm not really sure if there's anything I can do in rust-kv to make this work, but I will try to put a little more thought into this.

from rust-kv.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.