diff options
Diffstat (limited to 'sql/log.cc')
-rw-r--r-- | sql/log.cc | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/sql/log.cc b/sql/log.cc index fe782c5d621..9080dcd7fa2 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -3372,12 +3372,6 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd) DBUG_ENTER("reset_logs"); ha_reset_logs(thd); - /* - We need to get both locks to be sure that no one is trying to - write to the index log file. - */ - mysql_mutex_lock(&LOCK_log); - mysql_mutex_lock(&LOCK_index); /* The following mutex is needed to ensure that no threads call @@ -3387,6 +3381,13 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd) */ mysql_mutex_lock(&LOCK_thread_count); + /* + We need to get both locks to be sure that no one is trying to + write to the index log file. + */ + mysql_mutex_lock(&LOCK_log); + mysql_mutex_lock(&LOCK_index); + /* Save variables so that we can reopen the log */ save_name=name; name=0; // Protect against free @@ -5993,7 +5994,7 @@ int TC_LOG_MMAP::open(const char *opt_name) { pg->next=pg+1; pg->waiters=0; - pg->state=POOL; + pg->state=PS_POOL; mysql_mutex_init(key_PAGE_lock, &pg->lock, MY_MUTEX_INIT_FAST); mysql_cond_init(key_PAGE_cond, &pg->cond, 0); pg->start=(my_xid *)(data + i*tc_log_page_size); @@ -6167,7 +6168,7 @@ int TC_LOG_MMAP::log_xid(THD *thd, my_xid xid) cookie= (ulong)((uchar *)p->ptr - data); // can never be zero *p->ptr++= xid; p->free--; - p->state= DIRTY; + p->state= PS_DIRTY; /* to sync or not to sync - this is the question */ mysql_mutex_unlock(&LOCK_active); @@ -6179,13 +6180,13 @@ int TC_LOG_MMAP::log_xid(THD *thd, my_xid xid) p->waiters++; /* note - it must be while (), not do ... while () here - as p->state may be not DIRTY when we come here + as p->state may be not PS_DIRTY when we come here */ - while (p->state == DIRTY && syncing) + while (p->state == PS_DIRTY && syncing) mysql_cond_wait(&p->cond, &LOCK_sync); p->waiters--; - err= p->state == ERROR; - if (p->state != DIRTY) // page was synced + err= p->state == PS_ERROR; + if (p->state != PS_DIRTY) // page was synced { if (p->waiters == 0) mysql_cond_signal(&COND_pool); // in case somebody's waiting @@ -6223,7 +6224,7 @@ int TC_LOG_MMAP::sync() pool_last->next=syncing; pool_last=syncing; syncing->next=0; - syncing->state= err ? ERROR : POOL; + syncing->state= err ? PS_ERROR : PS_POOL; mysql_cond_broadcast(&syncing->cond); // signal "sync done" mysql_cond_signal(&COND_pool); // in case somebody's waiting mysql_mutex_unlock(&LOCK_pool); @@ -6506,8 +6507,11 @@ int TC_LOG_BINLOG::unlog(ulong cookie, my_xid xid) { DBUG_ENTER("TC_LOG_BINLOG::unlog"); mysql_mutex_lock(&LOCK_prep_xids); - DBUG_ASSERT(prepared_xids > 0); - if (--prepared_xids == 0) { + // prepared_xids can be 0 if the transaction had ignorable errors. + DBUG_ASSERT(prepared_xids >= 0); + if (prepared_xids > 0) + prepared_xids--; + if (prepared_xids == 0) { DBUG_PRINT("info", ("prepared_xids=%lu", prepared_xids)); mysql_cond_signal(&COND_prep_xids); } |