Hi list ,

I am working on intergrating LMDB with ceph, I met follow error "Invalid 
argument" when I commit transaction to LMDB,  details are descripted as 
following.

Two threads operate on LMDB, each thread  is responsible for create write 
transaction and read transaction , the write transaction will update LMDB, and 
read transaction is for iterator that read values from LMDB, the two threads 
share same MDB_env.  I check mdb_txn_commit source code , there are two places 
to return "EINVAL",

1. if (txn == NULL || txn->mt_env == NULL)
                return EINVAL;
 2. if (txn != env->me_txn) {
                DPUTS("attempt to commit unknown transaction");
                rc = EINVAL;
                goto fail;
        }

I check txn and txn->mt_env  and  rule out the first case , so only the second 
case cause "EINVAL",  and variable env->me_txn is only initialized when you 
start a write transaction with mdb_txn_open, and there is a lock to prevent 
several writer from operating on LMDB.  Btw , I tried to add lock to 
synchronize the two threads , everything seems ok.

My question is in what situation  can cause "txn != env-> me_txn",.

I'm very new to LMDB, if there is anything wrong, please correct me.

Cheers,
xinxin


Reply via email to