summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Smith <timothy.smith@sun.com>2009-03-02 18:10:37 -0700
committerTimothy Smith <timothy.smith@sun.com>2009-03-02 18:10:37 -0700
commit17c0218a1810cf81c361b3cec4d26c51296b6dbf (patch)
treebce137f9e12bea4e8f72dfdb80b13303e73f5f5a
parentd2e4204a1e9cda6fa64bc4910bbdb07281d7bee3 (diff)
downloadmariadb-git-17c0218a1810cf81c361b3cec4d26c51296b6dbf.tar.gz
Applying InnoDB snashot 5.1-ss4007, part 2. Fixes
Bug #42152: Race condition in lock_is_table_exclusive() Detailed revision comments: r4005 | marko | 2009-01-20 16:22:36 +0200 (Tue, 20 Jan 2009) | 8 lines branches/5.1: lock_is_table_exclusive(): Acquire kernel_mutex before accessing table->locks and release kernel_mutex before returning from the function. This fixes a portential race condition in the "commit every 10,000 rows" in ALTER TABLE, CREATE INDEX, DROP INDEX, and OPTIMIZE TABLE. (Bug #42152) rb://80 approved by Heikki Tuuri
-rw-r--r--storage/innobase/lock/lock0lock.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c
index 173d074cb82..d9bc8ba09e4 100644
--- a/storage/innobase/lock/lock0lock.c
+++ b/storage/innobase/lock/lock0lock.c
@@ -681,7 +681,10 @@ lock_is_table_exclusive(
lock_t* lock;
ibool ok = FALSE;
- ut_ad(table && trx);
+ ut_ad(table);
+ ut_ad(trx);
+
+ lock_mutex_enter_kernel();
for (lock = UT_LIST_GET_FIRST(table->locks);
lock;
@@ -689,7 +692,7 @@ lock_is_table_exclusive(
if (lock->trx != trx) {
/* A lock on the table is held
by some other transaction. */
- return(FALSE);
+ goto not_ok;
}
if (!(lock_get_type(lock) & LOCK_TABLE)) {
@@ -706,11 +709,16 @@ lock_is_table_exclusive(
auto_increment lock. */
break;
default:
+not_ok:
/* Other table locks than LOCK_IX are not allowed. */
- return(FALSE);
+ ok = FALSE;
+ goto func_exit;
}
}
+func_exit:
+ lock_mutex_exit_kernel();
+
return(ok);
}
@@ -3664,6 +3672,7 @@ lock_table_has_to_wait_in_queue(
dict_table_t* table;
lock_t* lock;
+ ut_ad(mutex_own(&kernel_mutex));
ut_ad(lock_get_wait(wait_lock));
table = wait_lock->un_member.tab_lock.table;