]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/cache: tweaks round transactions
authorVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 4 Sep 2020 17:31:51 +0000 (19:31 +0200)
committerPetr Špaček <petr.spacek@nic.cz>
Mon, 7 Sep 2020 15:47:47 +0000 (17:47 +0200)
- 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.

lib/cache/cdb_lmdb.c

index b56d8335e904666a3c60a4eb49a085882ed4a749..64298416d28ad8c7034680008ad277371e64a166 100644 (file)
@@ -245,14 +245,14 @@ success:
 
 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);