Commit abd34d96 authored by Timothy Smith's avatar Timothy Smith

Applying InnoDB snapshot innodb-5.1-ss3603

Detailed description of changes:
r3601 | marko | 2008-12-22 16:05:19 +0200 (Mon, 22 Dec 2008) | 9 lines
branches/5.1: Make
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED
a true replacement of SET GLOBAL INNODB_LOCKS_UNSAFE_FOR_BINLOG=1.
This fixes an error that was introduced in r370, causing
semi-consistent read not to not unlock rows in READ UNCOMMITTED mode.
(Bug #41671, Issue #146)

rb://67 approved by Heikki Tuuri
parent ff8017e7
drop table if exists t1; drop table if exists t1;
set binlog_format=mixed; set binlog_format=mixed;
set session transaction isolation level read committed; set session transaction isolation level repeatable read;
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
insert into t1 values (1),(2),(3),(4),(5),(6),(7); insert into t1 values (1),(2),(3),(4),(5),(6),(7);
set autocommit=0; set autocommit=0;
...@@ -8,11 +8,12 @@ select * from t1 where a=3 lock in share mode; ...@@ -8,11 +8,12 @@ select * from t1 where a=3 lock in share mode;
a a
3 3
set binlog_format=mixed; set binlog_format=mixed;
set session transaction isolation level read committed; set session transaction isolation level repeatable read;
set autocommit=0; set autocommit=0;
update t1 set a=10 where a=5; update t1 set a=10 where a=5;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit; commit;
set session transaction isolation level read committed;
update t1 set a=10 where a=5; update t1 set a=10 where a=5;
select * from t1 where a=2 for update; select * from t1 where a=2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction ERROR HY000: Lock wait timeout exceeded; try restarting transaction
......
--innodb_locks_unsafe_for_binlog=true --innodb_lock_wait_timeout=2 --innodb_lock_wait_timeout=2
...@@ -11,7 +11,7 @@ connect (a,localhost,root,,); ...@@ -11,7 +11,7 @@ connect (a,localhost,root,,);
connect (b,localhost,root,,); connect (b,localhost,root,,);
connection a; connection a;
set binlog_format=mixed; set binlog_format=mixed;
set session transaction isolation level read committed; set session transaction isolation level repeatable read;
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
insert into t1 values (1),(2),(3),(4),(5),(6),(7); insert into t1 values (1),(2),(3),(4),(5),(6),(7);
set autocommit=0; set autocommit=0;
...@@ -19,13 +19,15 @@ set autocommit=0; ...@@ -19,13 +19,15 @@ set autocommit=0;
select * from t1 where a=3 lock in share mode; select * from t1 where a=3 lock in share mode;
connection b; connection b;
set binlog_format=mixed; set binlog_format=mixed;
set session transaction isolation level read committed; set session transaction isolation level repeatable read;
set autocommit=0; set autocommit=0;
-- error ER_LOCK_WAIT_TIMEOUT -- error ER_LOCK_WAIT_TIMEOUT
update t1 set a=10 where a=5; update t1 set a=10 where a=5;
connection a; connection a;
commit; commit;
connection b; connection b;
# perform a semi-consisent read (and unlock non-matching rows)
set session transaction isolation level read committed;
update t1 set a=10 where a=5; update t1 set a=10 where a=5;
connection a; connection a;
-- error ER_LOCK_WAIT_TIMEOUT -- error ER_LOCK_WAIT_TIMEOUT
...@@ -33,6 +35,7 @@ select * from t1 where a=2 for update; ...@@ -33,6 +35,7 @@ select * from t1 where a=2 for update;
# this should lock the records (1),(2) # this should lock the records (1),(2)
select * from t1 where a=2 limit 1 for update; select * from t1 where a=2 limit 1 for update;
connection b; connection b;
# semi-consistent read will skip non-matching locked rows a=1, a=2
update t1 set a=11 where a=6; update t1 set a=11 where a=6;
-- error ER_LOCK_WAIT_TIMEOUT -- error ER_LOCK_WAIT_TIMEOUT
update t1 set a=12 where a=2; update t1 set a=12 where a=2;
......
...@@ -4129,7 +4129,8 @@ ha_innobase::unlock_row(void) ...@@ -4129,7 +4129,8 @@ ha_innobase::unlock_row(void)
switch (prebuilt->row_read_type) { switch (prebuilt->row_read_type) {
case ROW_READ_WITH_LOCKS: case ROW_READ_WITH_LOCKS:
if (!srv_locks_unsafe_for_binlog if (!srv_locks_unsafe_for_binlog
|| prebuilt->trx->isolation_level == TRX_ISO_READ_COMMITTED) { && prebuilt->trx->isolation_level
!= TRX_ISO_READ_COMMITTED) {
break; break;
} }
/* fall through */ /* fall through */
......
...@@ -1486,12 +1486,13 @@ row_unlock_for_mysql( ...@@ -1486,12 +1486,13 @@ row_unlock_for_mysql(
ut_ad(prebuilt && trx); ut_ad(prebuilt && trx);
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
if (!(srv_locks_unsafe_for_binlog if (UNIV_UNLIKELY
|| trx->isolation_level == TRX_ISO_READ_COMMITTED)) { (!srv_locks_unsafe_for_binlog
&& trx->isolation_level != TRX_ISO_READ_COMMITTED)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: calling row_unlock_for_mysql though\n" "InnoDB: Error: calling row_unlock_for_mysql though\n"
"InnoDB: srv_locks_unsafe_for_binlog is FALSE and\n" "InnoDB: innodb_locks_unsafe_for_binlog is FALSE and\n"
"InnoDB: this session is not using" "InnoDB: this session is not using"
" READ COMMITTED isolation level.\n"); " READ COMMITTED isolation level.\n");
......
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