From 02285aca58f5629547263ba09e7dd685dcf6b4b5 Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Wed, 9 Jul 2014 20:16:33 +0200 Subject: [PATCH] ITS#7789 Fix resize vs MDB_NOMETASYNC, and a comment. --- libraries/liblmdb/lmdb.h | 2 +- libraries/liblmdb/mdb.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h index f63c6719e0..2374ef7cc7 100644 --- a/libraries/liblmdb/lmdb.h +++ b/libraries/liblmdb/lmdb.h @@ -411,7 +411,7 @@ typedef enum MDB_cursor_op { #define MDB_CURSOR_FULL (-30787) /** Page has not enough space - internal error */ #define MDB_PAGE_FULL (-30786) - /** Database contents grew beyond environment mapsize */ + /** Environment mapsize was changed by another process */ #define MDB_MAP_RESIZED (-30785) /** MDB_INCOMPATIBLE: Operation and DB incompatible, or DB flags changed */ #define MDB_INCOMPATIBLE (-30784) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index dc1bb26093..a1199eaa93 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -3323,7 +3323,6 @@ mdb_txn_commit(MDB_txn *txn) #endif if ((rc = mdb_page_flush(txn, 0)) || - (rc = mdb_env_sync(env, 0)) || (rc = mdb_env_write_meta(txn))) goto fail; @@ -3480,7 +3479,7 @@ mdb_env_init_meta(MDB_env *env, MDB_meta *meta) static int mdb_env_write_meta(MDB_txn *txn) { - MDB_env *env; + MDB_env *env = txn->mt_env; MDB_meta meta, metab, *mp; off_t off; int rc, len, toggle; @@ -3492,11 +3491,14 @@ mdb_env_write_meta(MDB_txn *txn) int r2; #endif + /* Sync data and previous metapage before writing a new metapage */ + if ((rc = mdb_env_sync(env, 0)) != MDB_SUCCESS) + return rc; + toggle = txn->mt_txnid & 1; DPRINTF(("writing meta page %d for root page %"Z"u", toggle, txn->mt_dbs[MAIN_DBI].md_root)); - env = txn->mt_env; mp = env->me_metas[toggle]; if (env->me_flags & MDB_WRITEMAP) { -- 2.39.5