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
This commit is contained in:
parent
67b5c9d4d1
commit
896aba9630
@ -681,7 +681,10 @@ lock_is_table_exclusive(
|
|||||||
lock_t* lock;
|
lock_t* lock;
|
||||||
ibool ok = FALSE;
|
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);
|
for (lock = UT_LIST_GET_FIRST(table->locks);
|
||||||
lock;
|
lock;
|
||||||
@ -689,7 +692,7 @@ lock_is_table_exclusive(
|
|||||||
if (lock->trx != trx) {
|
if (lock->trx != trx) {
|
||||||
/* A lock on the table is held
|
/* A lock on the table is held
|
||||||
by some other transaction. */
|
by some other transaction. */
|
||||||
return(FALSE);
|
goto not_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(lock_get_type(lock) & LOCK_TABLE)) {
|
if (!(lock_get_type(lock) & LOCK_TABLE)) {
|
||||||
@ -706,11 +709,16 @@ lock_is_table_exclusive(
|
|||||||
auto_increment lock. */
|
auto_increment lock. */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
not_ok:
|
||||||
/* Other table locks than LOCK_IX are not allowed. */
|
/* Other table locks than LOCK_IX are not allowed. */
|
||||||
return(FALSE);
|
ok = FALSE;
|
||||||
|
goto func_exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func_exit:
|
||||||
|
lock_mutex_exit_kernel();
|
||||||
|
|
||||||
return(ok);
|
return(ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3664,6 +3672,7 @@ lock_table_has_to_wait_in_queue(
|
|||||||
dict_table_t* table;
|
dict_table_t* table;
|
||||||
lock_t* lock;
|
lock_t* lock;
|
||||||
|
|
||||||
|
ut_ad(mutex_own(&kernel_mutex));
|
||||||
ut_ad(lock_get_wait(wait_lock));
|
ut_ad(lock_get_wait(wait_lock));
|
||||||
|
|
||||||
table = wait_lock->un_member.tab_lock.table;
|
table = wait_lock->un_member.tab_lock.table;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user