From 1ac5147fc175907f0c657ce8416c70242eb91fd5 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sun, 6 Jul 2014 17:47:25 -0700 Subject: [PATCH] Compacting copy doesn't need to snapshot metas --- libraries/liblmdb/mdb.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index bdc11b5..e0465d4 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -8338,29 +8338,12 @@ mdb_env_copyfd1(MDB_env *env, HANDLE fd) my.mc_toggle = 0; my.mc_env = env; my.mc_fd = fd; + THREAD_CREATE(thr, mdb_env_copythr, &my); - /* Do the lock/unlock of the reader mutex before starting the - * write txn. Otherwise other read txns could block writers. - */ rc = mdb_txn_begin(env, NULL, MDB_RDONLY, &txn); if (rc) return rc; - if (env->me_txns) { - /* We must start the actual read txn after blocking writers */ - mdb_txn_reset0(txn, "reset-stage1"); - - /* Temporarily block writers until we snapshot the meta pages */ - LOCK_MUTEX_W(env); - - rc = mdb_txn_renew0(txn); - if (rc) { - UNLOCK_MUTEX_W(env); - goto leave; - } - } - - THREAD_CREATE(thr, mdb_env_copythr, &my); mp = (MDB_page *)my.mc_wbuf[0]; memset(mp, 0, 2*env->me_psize); mp->mp_pgno = 0; @@ -8410,7 +8393,7 @@ mdb_env_copyfd1(MDB_env *env, HANDLE fd) pthread_cond_wait(&my.mc_cond, &my.mc_mutex); pthread_mutex_unlock(&my.mc_mutex); THREAD_FINISH(thr); -leave: + mdb_txn_abort(txn); #ifdef _WIN32 CloseHandle(my.mc_cond);