Commit 32d96444 authored by gkodinov/kgeorge@magare.gmz's avatar gkodinov/kgeorge@magare.gmz

Merge bk-internal:/home/bk/mysql-5.0-opt

into  magare.gmz:/home/kgeorge/mysql/autopush/B28992-5.0-opt
parents 0fa279e5 5ea9964b
......@@ -1454,19 +1454,22 @@ CREATE TABLE t2 (id INTEGER);
INSERT INTO t2 VALUES (1),(2);
CREATE TRIGGER t1_test AFTER INSERT ON t1 FOR EACH ROW
INSERT INTO t2 VALUES (new.id);
SELECT GET_LOCK('B26162',20);
GET_LOCK('B26162',20)
SELECT GET_LOCK('B26162',120);
GET_LOCK('B26162',120)
1
SELECT 'rl_acquirer', GET_LOCK('B26162',5), id FROM t2 WHERE id = 1;
SELECT 'rl_acquirer', GET_LOCK('B26162',120), id FROM t2 WHERE id = 1;
SET SESSION LOW_PRIORITY_UPDATES=1;
SET GLOBAL LOW_PRIORITY_UPDATES=1;
INSERT INTO t1 VALUES (5);
SELECT 'rl_contender', id FROM t2 WHERE id > 1;
SELECT RELEASE_LOCK('B26162');
RELEASE_LOCK('B26162')
0
rl_acquirer GET_LOCK('B26162',5) id
rl_acquirer 0 1
1
rl_acquirer GET_LOCK('B26162',120) id
rl_acquirer 1 1
SELECT RELEASE_LOCK('B26162');
RELEASE_LOCK('B26162')
1
rl_contender id
rl_contender 2
DROP TRIGGER t1_test;
......
......@@ -1763,6 +1763,9 @@ select * from t1;
select * from t3;
drop table t1, t2, t3;
disconnect addconroot1;
disconnect addconroot2;
disconnect addconwithoutdb;
#
# Bug #26162: Trigger DML ignores low_priority_updates setting
#
......@@ -1776,19 +1779,23 @@ INSERT INTO t2 VALUES (1),(2);
CREATE TRIGGER t1_test AFTER INSERT ON t1 FOR EACH ROW
INSERT INTO t2 VALUES (new.id);
CONNECT (rl_holder, localhost, root,,);
CONNECT (rl_acquirer, localhost, root,,);
CONNECT (wl_acquirer, localhost, root,,);
CONNECT (rl_contender, localhost, root,,);
SELECT GET_LOCK('B26162',20);
CONNECTION rl_holder;
SELECT GET_LOCK('B26162',120);
CONNECTION rl_acquirer;
--send
SELECT 'rl_acquirer', GET_LOCK('B26162',5), id FROM t2 WHERE id = 1;
SELECT 'rl_acquirer', GET_LOCK('B26162',120), id FROM t2 WHERE id = 1;
CONNECTION wl_acquirer;
SET SESSION LOW_PRIORITY_UPDATES=1;
SET GLOBAL LOW_PRIORITY_UPDATES=1;
#need to wait for rl_acquirer to lock on the B26162 lock
sleep 2;
--send
INSERT INTO t1 VALUES (5);
......@@ -1798,13 +1805,16 @@ CONNECTION rl_contender;
--send
SELECT 'rl_contender', id FROM t2 WHERE id > 1;
CONNECTION default;
CONNECTION rl_holder;
#need to wait for wl_acquirer and rl_contender to lock on t2
sleep 2;
SELECT RELEASE_LOCK('B26162');
CONNECTION wl_acquirer;
--reap
CONNECTION rl_acquirer;
--reap
SELECT RELEASE_LOCK('B26162');
CONNECTION wl_acquirer;
--reap
CONNECTION rl_contender;
--reap
......@@ -1812,6 +1822,7 @@ CONNECTION default;
DISCONNECT rl_acquirer;
DISCONNECT wl_acquirer;
DISCONNECT rl_contender;
DISCONNECT rl_holder;
DROP TRIGGER t1_test;
DROP TABLE t1,t2;
......
......@@ -3449,6 +3449,7 @@ longlong Item_func_get_lock::val_int()
THD *thd=current_thd;
User_level_lock *ull;
int error;
DBUG_ENTER("Item_func_get_lock::val_int");
/*
In slave thread no need to get locks, everything is serialized. Anyway
......@@ -3458,7 +3459,7 @@ longlong Item_func_get_lock::val_int()
it's not guaranteed to be same as on master.
*/
if (thd->slave_thread)
return 1;
DBUG_RETURN(1);
pthread_mutex_lock(&LOCK_user_locks);
......@@ -3466,8 +3467,10 @@ longlong Item_func_get_lock::val_int()
{
pthread_mutex_unlock(&LOCK_user_locks);
null_value=1;
return 0;
DBUG_RETURN(0);
}
DBUG_PRINT("info", ("lock %.*s, thd=%ld", res->length(), res->ptr(),
(long) thd->real_id));
null_value=0;
if (thd->ull)
......@@ -3486,14 +3489,17 @@ longlong Item_func_get_lock::val_int()
delete ull;
pthread_mutex_unlock(&LOCK_user_locks);
null_value=1; // Probably out of memory
return 0;
DBUG_RETURN(0);
}
ull->thread=thd->real_id;
ull->thread_id=thd->thread_id;
thd->ull=ull;
pthread_mutex_unlock(&LOCK_user_locks);
return 1; // Got new lock
DBUG_PRINT("info", ("made new lock"));
DBUG_RETURN(1); // Got new lock
}
ull->count++;
DBUG_PRINT("info", ("ull->count=%d", ull->count));
/*
Structure is now initialized. Try to get the lock.
......@@ -3507,9 +3513,13 @@ longlong Item_func_get_lock::val_int()
error= 0;
while (ull->locked && !thd->killed)
{
DBUG_PRINT("info", ("waiting on lock"));
error= pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime);
if (error == ETIMEDOUT || error == ETIME)
{
DBUG_PRINT("info", ("lock wait timeout"));
break;
}
error= 0;
}
......@@ -3533,6 +3543,7 @@ longlong Item_func_get_lock::val_int()
ull->thread_id= thd->thread_id;
thd->ull=ull;
error=0;
DBUG_PRINT("info", ("got the lock"));
}
pthread_mutex_unlock(&LOCK_user_locks);
......@@ -3542,7 +3553,7 @@ longlong Item_func_get_lock::val_int()
thd->mysys_var->current_cond= 0;
pthread_mutex_unlock(&thd->mysys_var->mutex);
return !error ? 1 : 0;
DBUG_RETURN(!error ? 1 : 0);
}
......@@ -3560,11 +3571,14 @@ longlong Item_func_release_lock::val_int()
String *res=args[0]->val_str(&value);
User_level_lock *ull;
longlong result;
THD *thd=current_thd;
DBUG_ENTER("Item_func_release_lock::val_int");
if (!res || !res->length())
{
null_value=1;
return 0;
DBUG_RETURN(0);
}
DBUG_PRINT("info", ("lock %.*s", res->length(), res->ptr()));
null_value=0;
result=0;
......@@ -3577,19 +3591,20 @@ longlong Item_func_release_lock::val_int()
}
else
{
#ifdef EMBEDDED_LIBRARY
if (ull->locked && pthread_equal(current_thd->real_id,ull->thread))
#else
if (ull->locked && pthread_equal(pthread_self(),ull->thread))
#endif
DBUG_PRINT("info", ("ull->locked=%d ull->thread=%ld thd=%ld",
(int) ull->locked,
(long)ull->thread,
(long)thd->real_id));
if (ull->locked && pthread_equal(thd->real_id,ull->thread))
{
DBUG_PRINT("info", ("release lock"));
result=1; // Release is ok
item_user_lock_release(ull);
current_thd->ull=0;
thd->ull=0;
}
}
pthread_mutex_unlock(&LOCK_user_locks);
return result;
DBUG_RETURN(result);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment