Skip to content
Snippets Groups Projects
Verified Commit e8ca6a70 authored by Vladimír Čunát's avatar Vladimír Čunát Committed by Petr Špaček
Browse files

lib/cache: tweaks round transactions

- The switched order is documented not to make difference,
  but it seems much clearer this way.
- MDB_TXN_FULL wasn't handled correctly (a reversed condition)
  and current LMDB code indicates that such transaction is
  not recoverable anyway... so we give up on trying.
parent b1b57540
Branches
Tags
1 merge request!1042cache-forking fixes
......@@ -245,14 +245,14 @@ static int txn_curs_get(struct lmdb_env *env, MDB_cursor **curs, struct kr_cdb_s
static void txn_free_ro(struct lmdb_env *env)
{
if (env->txn.ro) {
mdb_txn_abort(env->txn.ro);
env->txn.ro = NULL;
}
if (env->txn.ro_curs) {
mdb_cursor_close(env->txn.ro_curs);
env->txn.ro_curs = NULL;
}
if (env->txn.ro) {
mdb_txn_abort(env->txn.ro);
env->txn.ro = NULL;
}
}
/** Abort all transactions.
......@@ -606,17 +606,7 @@ static int cdb_write(struct lmdb_env *env, MDB_txn **txn, const knot_db_val_t *k
stats->write++;
int ret = mdb_put(*txn, env->dbi, &_key, &_val, flags);
/* Try to recover from doing too much writing in a single transaction. */
if (ret == MDB_TXN_FULL) {
ret = cdb_commit(env, stats);
if (ret) {
ret = txn_get(env, txn, false);
}
if (ret) {
stats->write++;
ret = mdb_put(*txn, env->dbi, &_key, &_val, flags);
}
}
/* We don't try to recover from MDB_TXN_FULL. */
if (ret != MDB_SUCCESS) {
txn_abort(env);
return lmdb_error(ret);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment