Fix robust mutexes - repair mti_txnid.

Broken by e3b6c359a9, if
commit() crashes in write_meta before setting mti_txnid.
vl32b
Hallvard Furuseth 10 years ago
parent 42110d83a9
commit 443a7e40c4
  1. 7
      libraries/liblmdb/mdb.c

@ -9492,7 +9492,7 @@ static int mdb_reader_check0(MDB_env *env, int rlocked, int *dead)
*/ */
static int mdb_mutex_failed(MDB_env *env, mdb_mutex_t *mutex, int rc) static int mdb_mutex_failed(MDB_env *env, mdb_mutex_t *mutex, int rc)
{ {
int rlocked, rc2; int toggle, rlocked, rc2;
#ifndef _WIN32 #ifndef _WIN32
enum { WAIT_ABANDONED = EOWNERDEAD }; enum { WAIT_ABANDONED = EOWNERDEAD };
#endif #endif
@ -9502,6 +9502,11 @@ static int mdb_mutex_failed(MDB_env *env, mdb_mutex_t *mutex, int rc)
rc = MDB_SUCCESS; rc = MDB_SUCCESS;
rlocked = (mutex == MDB_MUTEX(env, r)); rlocked = (mutex == MDB_MUTEX(env, r));
if (!rlocked) { if (!rlocked) {
/* Keep mti_txnid updated, otherwise next writer can
* overwrite data which latest meta page refers to.
*/
toggle = mdb_env_pick_meta(env);
env->me_txns->mti_txnid = env->me_metas[toggle]->mm_txnid;
/* env is hosed if the dead thread was ours */ /* env is hosed if the dead thread was ours */
if (env->me_txn) { if (env->me_txn) {
env->me_flags |= MDB_FATAL_ERROR; env->me_flags |= MDB_FATAL_ERROR;

Loading…
Cancel
Save