Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
2b41b8fa
Commit
2b41b8fa
authored
Feb 17, 2005
by
serg@serg.mylan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
post-review fixes. Now ROLLBACK is done in Format_description_log_event
parent
e4116bc2
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
176 additions
and
184 deletions
+176
-184
client/mysqlbinlog.cc
client/mysqlbinlog.cc
+2
-3
mysql-test/r/ctype_ucs.result
mysql-test/r/ctype_ucs.result
+1
-1
mysql-test/r/mysqlbinlog.result
mysql-test/r/mysqlbinlog.result
+5
-2
mysql-test/r/mysqlbinlog2.result
mysql-test/r/mysqlbinlog2.result
+21
-4
mysql-test/r/rpl_charset.result
mysql-test/r/rpl_charset.result
+1
-1
mysql-test/r/user_var.result
mysql-test/r/user_var.result
+1
-1
mysql-test/t/ctype_ucs.test
mysql-test/t/ctype_ucs.test
+0
-1
mysql-test/t/mix_innodb_myisam_binlog.test
mysql-test/t/mix_innodb_myisam_binlog.test
+9
-0
mysql-test/t/user_var.test
mysql-test/t/user_var.test
+0
-1
sql/log_event.cc
sql/log_event.cc
+63
-62
sql/log_event.h
sql/log_event.h
+10
-20
sql/mysql_priv.h
sql/mysql_priv.h
+8
-0
sql/slave.cc
sql/slave.cc
+43
-57
sql/sql_parse.cc
sql/sql_parse.cc
+8
-23
sql/sql_repl.cc
sql/sql_repl.cc
+4
-8
No files found.
client/mysqlbinlog.cc
View file @
2b41b8fa
...
...
@@ -1171,11 +1171,10 @@ static int dump_local_log_entries(const char* logname)
{
/*
if binlog wasn't closed properly ("in use" flag is set) don't complain
about a corruption, but issue a "ROLLBACK" to annihilate half-logged
transaction. Otherwise, treat it as EOF and move to the next binlog.
about a corruption, but treat it as EOF and move to the next binlog.
*/
if
(
description_event
->
flags
&
LOG_EVENT_BINLOG_IN_USE_F
)
f
printf
(
result_file
,
"ROLLBACK;
\n
"
)
;
f
ile
->
error
=
0
;
else
if
(
file
->
error
)
{
fprintf
(
stderr
,
...
...
mysql-test/r/ctype_ucs.result
View file @
2b41b8fa
...
...
@@ -527,8 +527,8 @@ show binlog events from 96;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 96 User var 1 136 @`v`=_ucs2 0x006100620063 COLLATE ucs2_general_ci
master-bin.000001 136 Query 1 226 use `test`; insert into t2 values (@v)
flush logs;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`;
use test;
SET TIMESTAMP=10000;
...
...
mysql-test/r/mysqlbinlog.result
View file @
2b41b8fa
...
...
@@ -15,6 +15,7 @@ flush logs;
--- Local --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=1000000000;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...
...
@@ -47,6 +48,7 @@ insert into t1 values ("Alas");
--- --database --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=1;
--- --position --
...
...
@@ -60,6 +62,7 @@ insert into t1 values ("Alas");
--- Remote --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=1000000000;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...
...
@@ -92,6 +95,7 @@ insert into t1 values ("Alas");
--- --database --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=1;
--- --position --
...
...
@@ -105,13 +109,12 @@ insert into t1 values ("Alas");
--- reading stdin --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=1065204671;
BEGIN;
ROLLBACK;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
use test;
SET TIMESTAMP=1065204671;
BEGIN;
ROLLBACK;
drop table t1, t2;
mysql-test/r/mysqlbinlog2.result
View file @
2b41b8fa
...
...
@@ -16,6 +16,7 @@ insert into t1 values(null, "f");
--- Local --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...
...
@@ -40,6 +41,7 @@ insert into t1 values(null, "e");
--- offset --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=1;
use test;
SET TIMESTAMP=1579609942;
...
...
@@ -75,6 +77,7 @@ insert into t1 values(null, "e");
--- stop-position --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...
...
@@ -93,6 +96,7 @@ insert into t1 values(null, "c");
--- start-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=3;
use test;
SET TIMESTAMP=1579609944;
...
...
@@ -109,6 +113,7 @@ insert into t1 values(null, "e");
--- stop-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...
...
@@ -124,6 +129,7 @@ insert into t1 values(null, "b");
--- Local with 2 binlogs on command line --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...
...
@@ -152,10 +158,10 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq
SET @@session.sql_mode=0;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
insert into t1 values(null, "f");
ROLLBACK;
--- offset --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=1;
use test;
SET TIMESTAMP=1579609942;
...
...
@@ -182,7 +188,6 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq
SET @@session.sql_mode=0;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
insert into t1 values(null, "f");
ROLLBACK;
--- start-position --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
...
...
@@ -203,10 +208,10 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq
SET @@session.sql_mode=0;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
insert into t1 values(null, "f");
ROLLBACK;
--- stop-position --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...
...
@@ -232,6 +237,7 @@ SET INSERT_ID=6;
--- start-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=3;
use test;
SET TIMESTAMP=1579609944;
...
...
@@ -252,10 +258,10 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq
SET @@session.sql_mode=0;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
insert into t1 values(null, "f");
ROLLBACK;
--- stop-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...
...
@@ -271,6 +277,7 @@ insert into t1 values(null, "b");
--- Remote --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...
...
@@ -295,6 +302,7 @@ insert into t1 values(null, "e");
--- offset --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=1;
use test;
SET TIMESTAMP=1579609942;
...
...
@@ -330,6 +338,7 @@ insert into t1 values(null, "e");
--- stop-position --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...
...
@@ -348,6 +357,7 @@ insert into t1 values(null, "c");
--- start-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=3;
use test;
SET TIMESTAMP=1579609944;
...
...
@@ -364,6 +374,7 @@ insert into t1 values(null, "e");
--- stop-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...
...
@@ -379,6 +390,7 @@ insert into t1 values(null, "b");
--- Remote with 2 binlogs on command line --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...
...
@@ -410,6 +422,7 @@ insert into t1 values(null, "f");
--- offset --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=1;
use test;
SET TIMESTAMP=1579609942;
...
...
@@ -459,6 +472,7 @@ insert into t1 values(null, "f");
--- stop-position --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...
...
@@ -484,6 +498,7 @@ SET INSERT_ID=6;
--- start-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=3;
use test;
SET TIMESTAMP=1579609944;
...
...
@@ -507,6 +522,7 @@ insert into t1 values(null, "f");
--- stop-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...
...
@@ -522,6 +538,7 @@ insert into t1 values(null, "b");
--- to-last-log --
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...
...
mysql-test/r/rpl_charset.result
View file @
2b41b8fa
...
...
@@ -175,6 +175,7 @@ select hex(c1), hex(c2) from t1;
hex(c1) hex(c2)
CDF32C20E7E020F0FBE1E0EBEAF3 CDF32C20E7E020F0FBE1E0EBEAF3
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET TIMESTAMP=1000000000;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
SET @@session.sql_mode=0;
...
...
@@ -244,5 +245,4 @@ CREATE TABLE t1 (c1 VARBINARY(255), c2 VARBINARY(255));
SET TIMESTAMP=1000000000;
SET @@session.character_set_client=7,@@session.collation_connection=51,@@session.collation_server=30;
INSERT INTO t1 (c1, c2) VALUES (', ',', ');
ROLLBACK;
drop table t1;
mysql-test/r/user_var.result
View file @
2b41b8fa
...
...
@@ -181,8 +181,8 @@ master-bin.000001 137 Query 1 230 use `test`; INSERT INTO t1 VALUES(@`a b`)
master-bin.000001 230 User var 1 272 @`var1`=_latin1 0x273B616161 COLLATE latin1_swedish_ci
master-bin.000001 272 User var 1 310 @`var2`=_latin1 0x61 COLLATE latin1_swedish_ci
master-bin.000001 310 Query 1 411 use `test`; insert into t1 values (@var1),(@var2)
flush logs;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`;
use test;
SET TIMESTAMP=10000;
...
...
mysql-test/t/ctype_ucs.test
View file @
2b41b8fa
...
...
@@ -339,7 +339,6 @@ set @v=convert('abc' using ucs2);
reset
master
;
insert
into
t2
values
(
@
v
);
show
binlog
events
from
96
;
flush
logs
;
# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we
# absolutely need variables names to be quoted and strings to be
# escaped).
...
...
mysql-test/t/mix_innodb_myisam_binlog.test
View file @
2b41b8fa
...
...
@@ -26,6 +26,7 @@ insert into t2 select * from t1;
commit
;
--
replace_column
5
#
--
replace_result
"xid=12"
"xid=7"
show
binlog
events
from
96
;
delete
from
t1
;
...
...
@@ -54,6 +55,7 @@ rollback to savepoint my_savepoint;
commit
;
--
replace_column
5
#
--
replace_result
"xid=45"
"xid=24"
show
binlog
events
from
96
;
delete
from
t1
;
...
...
@@ -71,6 +73,7 @@ commit;
select
a
from
t1
order
by
a
;
# check that savepoints work :)
--
replace_column
5
#
--
replace_result
"xid=67"
"xid=36"
show
binlog
events
from
96
;
# and when ROLLBACK is not explicit?
...
...
@@ -103,6 +106,7 @@ insert into t1 values(9);
insert
into
t2
select
*
from
t1
;
--
replace_column
5
#
--
replace_result
"xid=116"
"xid=59"
show
binlog
events
from
96
;
# Check that when the query updat1ng the MyISAM table is the first in the
...
...
@@ -115,11 +119,13 @@ insert into t1 values(10); # first make t1 non-empty
begin
;
insert
into
t2
select
*
from
t1
;
--
replace_column
5
#
--
replace_result
"xid=130"
"xid=65"
show
binlog
events
from
96
;
insert
into
t1
values
(
11
);
commit
;
--
replace_column
5
#
--
replace_result
"xid=130"
"xid=65"
"xid=133"
"xid=67"
show
binlog
events
from
96
;
...
...
@@ -138,6 +144,7 @@ insert into t2 select * from t1;
commit
;
--
replace_column
5
#
--
replace_result
"xid=152"
"xid=77"
show
binlog
events
from
96
;
delete
from
t1
;
...
...
@@ -165,6 +172,7 @@ rollback to savepoint my_savepoint;
commit
;
--
replace_column
5
#
--
replace_result
"xid=184"
"xid=93"
show
binlog
events
from
96
;
delete
from
t1
;
...
...
@@ -182,6 +190,7 @@ commit;
select
a
from
t1
order
by
a
;
# check that savepoints work :)
--
replace_column
5
#
--
replace_result
"xid=205"
"xid=104"
show
binlog
events
from
96
;
# Test for BUG#5714, where a MyISAM update in the transaction used to
...
...
mysql-test/t/user_var.test
View file @
2b41b8fa
...
...
@@ -111,7 +111,6 @@ set @var1= "';aaa";
SET
@
var2
=
char
(
ascii
(
'a'
));
insert
into
t1
values
(
@
var1
),(
@
var2
);
show
binlog
events
from
96
;
flush
logs
;
# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we
# absolutely need variables names to be quoted and strings to be
# escaped).
...
...
sql/log_event.cc
View file @
2b41b8fa
...
...
@@ -1682,14 +1682,20 @@ void Start_log_event_v3::print(FILE* file, bool short_form, LAST_EVENT_INFO* las
fprintf
(
file
,
" at startup"
);
fputc
(
'\n'
,
file
);
}
if
(
!
artificial_event
&&
created
)
{
#ifdef WHEN_WE_HAVE_THE_RESET_CONNECTION_SQL_COMMAND
/*
This is for mysqlbinlog: like in replication, we want to delete the stale
tmp files left by an unclean shutdown of mysqld (temporary tables). Probably
this can be done with RESET CONNECTION (syntax to be defined).
tmp files left by an unclean shutdown of mysqld (temporary tables)
and rollback unfinished transaction.
Probably this can be done with RESET CONNECTION (syntax to be defined).
*/
fprintf
(
file
,
"RESET CONNECTION;
\n
"
);
#else
fprintf
(
file
,
"ROLLBACK;
\n
"
);
#endif
}
fflush
(
file
);
}
#endif
/* MYSQL_CLIENT */
...
...
@@ -1765,30 +1771,6 @@ int Start_log_event_v3::exec_event(struct st_relay_log_info* rli)
close_temporary_tables
(
thd
);
cleanup_load_tmpdir
();
}
/*
As a transaction NEVER spans on 2 or more binlogs:
if we have an active transaction at this point, the master died
while writing the transaction to the binary log, i.e. while
flushing the binlog cache to the binlog. As the write was started,
the transaction had been committed on the master, so we lack of
information to replay this transaction on the slave; all we can do
is stop with error.
Note: this event could be sent by the master to inform us of the
format of its binlog; in other words maybe it is not at its
original place when it comes to us; we'll know this by checking
log_pos ("artificial" events have log_pos == 0).
TODO test whether it's really necessary, as slave.cc does ROLLBACK
itself
*/
if
(
!
artificial_event
&&
(
thd
->
options
&
OPTION_BEGIN
))
{
slave_print_error
(
rli
,
0
,
"\
Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. \
A probable cause is that the master died while writing the transaction to its \
binary log."
);
return
(
1
);
}
break
;
/*
...
...
@@ -2004,6 +1986,27 @@ int Format_description_log_event::exec_event(struct st_relay_log_info* rli)
delete
rli
->
relay_log
.
description_event_for_exec
;
rli
->
relay_log
.
description_event_for_exec
=
this
;
/*
As a transaction NEVER spans on 2 or more binlogs:
if we have an active transaction at this point, the master died
while writing the transaction to the binary log, i.e. while
flushing the binlog cache to the binlog. As the write was started,
the transaction had been committed on the master, so we lack of
information to replay this transaction on the slave; all we can do
is stop with error.
Note: this event could be sent by the master to inform us of the
format of its binlog; in other words maybe it is not at its
original place when it comes to us; we'll know this by checking
log_pos ("artificial" events have log_pos == 0).
*/
if
(
!
artificial_event
&&
created
&&
thd
->
transaction
.
all
.
nht
)
{
slave_print_error
(
rli
,
0
,
"Rolling back unfinished transaction (no "
"COMMIT or ROLLBACK) from relay log. A probable cause "
"is that the master died while writing the transaction "
"to its binary log."
);
end_trans
(
thd
,
ROLLBACK
);
}
/*
If this event comes from ourselves, there is no cleaning task to perform,
we don't call Start_log_event_v3::exec_event() (this was just to update the
...
...
@@ -2032,9 +2035,9 @@ int Format_description_log_event::exec_event(struct st_relay_log_info* rli)
If the event was not requested by the slave i.e. the master sent it while
the slave asked for a position >4, the event will make
rli->group_master_log_pos advance. Say that the slave asked for position
1000, and the Format_desc event's end is 9
5
. Then in the beginning of
replication rli->group_master_log_pos will be 0, then 9
5, then jump to first
really asked event (which is >95
). So this is ok.
1000, and the Format_desc event's end is 9
6
. Then in the beginning of
replication rli->group_master_log_pos will be 0, then 9
6, then jump to
first really asked event (which is >96
). So this is ok.
*/
DBUG_RETURN
(
Start_log_event_v3
::
exec_event
(
rli
));
}
...
...
@@ -3134,9 +3137,7 @@ int Xid_log_event::exec_event(struct st_relay_log_info* rli)
{
rli
->
inc_event_relay_log_pos
();
/* For a slave Xid_log_event is COMMIT */
thd
->
options
&=
~
(
ulong
)
(
OPTION_BEGIN
|
OPTION_STATUS_NO_TRANS_UPDATE
);
thd
->
server_status
&=
~
SERVER_STATUS_IN_TRANS
;
return
ha_commit
(
thd
);
return
end_trans
(
thd
,
COMMIT
);
}
#endif
/* !MYSQL_CLIENT */
...
...
sql/log_event.h
View file @
2b41b8fa
...
...
@@ -312,14 +312,14 @@ struct sql_ex_info
small chance that mysqld crashes in the middle of insert and end of
the binlog would look like a Stop_log_event).
This flag is used to detect a restart after a crash,
and to provide "unbreakable" binlog. The problem is that on a crash
storage engines rollback automatically, while binlog does not.
To solve this we use this flag and automatically append ROLLBACK
to every non-closed binlog (append virtually, on reading, file itself
is not changed). If this flag is found, mysqlbinlog simply prints "ROLLBACK"
Replication master does not abort on binlog corruption, but takes it as EOF,
and replication slave forces a rollback in this case (see below)
.
This flag is used to detect a restart after a crash,
and to provide
"unbreakable" binlog. The problem is that on a crash storage engines
rollback automatically, while binlog does not. To solve this we use this
flag and automatically append ROLLBACK to every non-closed binlog (append
virtually, on reading, file itself is not changed). If this flag is found,
mysqlbinlog simply prints "ROLLBACK" Replication master does not abort on
binlog corruption, but takes it as EOF, and replication slave forces a
rollback in this case
.
Note, that old binlogs does not have this flag set, so we get a
a backward-compatible behaviour.
...
...
@@ -327,16 +327,6 @@ struct sql_ex_info
#define LOG_EVENT_BINLOG_IN_USE_F 0x1
/*
This flag is only used for fake Rotate_log_event. When a master, doing
binlog dump, reaches the end of the binlog and fakes a rotate to make
the slave to go to a new file, this flag is used if there was no
"natural" Rotate_log_event.
If this flag is set, slave will execute ROLLBACK before going further
*/
#define LOG_EVENT_FORCE_ROLLBACK_F 0x1
/*
If the query depends on the thread (for example: TEMPORARY TABLE).
Currently this is used by mysqlbinlog to know it must print
...
...
@@ -903,8 +893,8 @@ public:
binary log) was created. In the other case (i.e. this event is at
the start of a binary log created by FLUSH LOGS or automatic
rotation), 'created' should be 0. This "trick" is used by MySQL
>=4.0.14 slaves to know
if they must drop the
stale temporary
tables
or not
.
>=4.0.14 slaves to know
whether they must drop
stale temporary
tables
and whether they should abort unfinished transaction
.
Note that when 'created'!=0, it is always equal to the event's
timestamp; indeed Start_log_event is written only in log.cc where
...
...
sql/mysql_priv.h
View file @
2b41b8fa
...
...
@@ -456,6 +456,14 @@ bool delete_precheck(THD *thd, TABLE_LIST *tables);
bool
insert_precheck
(
THD
*
thd
,
TABLE_LIST
*
tables
);
bool
create_table_precheck
(
THD
*
thd
,
TABLE_LIST
*
tables
,
TABLE_LIST
*
create_table
);
enum
enum_mysql_completiontype
{
ROLLBACK_RELEASE
=-
2
,
ROLLBACK
=
1
,
ROLLBACK_AND_CHAIN
=
7
,
COMMIT_RELEASE
=-
1
,
COMMIT
=
0
,
COMMIT_AND_CHAIN
=
6
};
int
end_trans
(
THD
*
thd
,
enum
enum_mysql_completiontype
completion
);
Item
*
negate_expression
(
THD
*
thd
,
Item
*
expr
);
#include "sql_class.h"
#include "sql_acl.h"
...
...
sql/slave.cc
View file @
2b41b8fa
...
...
@@ -1722,7 +1722,7 @@ static int init_relay_log_info(RELAY_LOG_INFO* rli,
if
(
rli
->
relay_log
.
open_index_file
(
opt_relaylog_index_name
,
ln
)
||
rli
->
relay_log
.
open
(
ln
,
LOG_BIN
,
0
,
SEQ_READ_APPEND
,
0
,
(
max_relay_log_size
?
max_relay_log_size
:
max_binlog_size
),
0
))
max_binlog_size
),
1
))
{
pthread_mutex_unlock
(
&
rli
->
data_lock
);
sql_print_error
(
"Failed in open_log() called from init_relay_log_info()"
);
...
...
@@ -3214,21 +3214,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
thd
->
set_time
();
// time the query
thd
->
lex
->
current_select
=
0
;
if
(
!
ev
->
when
)
{
ev
->
when
=
time
(
NULL
);
/*
fake Rotate: it means that normal execution flow of statements is
interrupted. Let's fake ROLLBACK to undo any half-executed transaction
*/
if
(
ev
->
get_type_code
()
==
ROTATE_EVENT
&&
ev
->
flags
&
LOG_EVENT_FORCE_ROLLBACK_F
)
{
ha_rollback_stmt
(
thd
);
ha_rollback
(
thd
);
thd
->
options
&=
~
(
ulong
)
(
OPTION_BEGIN
|
OPTION_STATUS_NO_TRANS_UPDATE
);
thd
->
server_status
&=
~
SERVER_STATUS_IN_TRANS
;
}
}
ev
->
thd
=
thd
;
exec_res
=
ev
->
exec_event
(
rli
);
DBUG_ASSERT
(
rli
->
sql_thd
==
thd
);
...
...
sql/sql_parse.cc
View file @
2b41b8fa
...
...
@@ -1286,33 +1286,22 @@ err:
/*
Ends the current transaction and (maybe) begin the next
First uint4 in packet is completion type
SYNOPSIS
end_trans
_and_send_ok
()
end_trans()
thd Current thread
completion Completion type
release (OUT) indicator for release operation
RETURN
0 - OK
*/
enum
enum_mysql_completiontype
{
ROLLBACK_RELEASE
=-
2
,
COMMIT_RELEASE
=-
1
,
COMMIT
=
0
,
ROLLBACK
=
1
,
COMMIT_AND_CHAIN
=
6
,
ROLLBACK_AND_CHAIN
=
7
};
int
end_trans_and_send_ok
(
THD
*
thd
,
enum
enum_mysql_completiontype
completion
)
int
end_trans
(
THD
*
thd
,
enum
enum_mysql_completiontype
completion
)
{
bool
do_release
=
0
;
int
res
=
0
;
LEX
*
lex
=
thd
->
lex
;
DBUG_ENTER
(
"end_trans
_and_send_ok
"
);
DBUG_ENTER
(
"end_trans"
);
switch
(
completion
)
{
case
COMMIT
:
...
...
@@ -1323,8 +1312,7 @@ int end_trans_and_send_ok(THD *thd, enum enum_mysql_completiontype completion)
*/
thd
->
options
&=
~
(
ulong
)
(
OPTION_BEGIN
|
OPTION_STATUS_NO_TRANS_UPDATE
);
thd
->
server_status
&=
~
SERVER_STATUS_IN_TRANS
;
if
(
!
(
res
=
ha_commit
(
thd
)))
send_ok
(
thd
);
res
=
ha_commit
(
thd
);
break
;
case
COMMIT_RELEASE
:
do_release
=
1
;
/* fall through */
...
...
@@ -1332,8 +1320,6 @@ int end_trans_and_send_ok(THD *thd, enum enum_mysql_completiontype completion)
res
=
end_active_trans
(
thd
);
if
(
!
res
&&
completion
==
COMMIT_AND_CHAIN
)
res
=
begin_trans
(
thd
);
if
(
!
res
)
send_ok
(
thd
);
break
;
case
ROLLBACK_RELEASE
:
do_release
=
1
;
/* fall through */
...
...
@@ -1346,9 +1332,6 @@ int end_trans_and_send_ok(THD *thd, enum enum_mysql_completiontype completion)
thd
->
options
&=
~
(
ulong
)
(
OPTION_BEGIN
|
OPTION_STATUS_NO_TRANS_UPDATE
);
if
(
!
res
&&
(
completion
==
ROLLBACK_AND_CHAIN
))
res
=
begin_trans
(
thd
);
if
(
!
res
)
send_ok
(
thd
);
break
;
}
default:
...
...
@@ -3853,14 +3836,16 @@ unsent_create_error:
send_ok
(
thd
);
break
;
case
SQLCOM_COMMIT
:
if
(
end_trans
_and_send_ok
(
thd
,
lex
->
tx_release
?
COMMIT_RELEASE
:
if
(
end_trans
(
thd
,
lex
->
tx_release
?
COMMIT_RELEASE
:
lex
->
tx_chain
?
COMMIT_AND_CHAIN
:
COMMIT
))
goto
error
;
send_ok
(
thd
);
break
;
case
SQLCOM_ROLLBACK
:
if
(
end_trans
_and_send_ok
(
thd
,
lex
->
tx_release
?
ROLLBACK_RELEASE
:
if
(
end_trans
(
thd
,
lex
->
tx_release
?
ROLLBACK_RELEASE
:
lex
->
tx_chain
?
ROLLBACK_AND_CHAIN
:
ROLLBACK
))
goto
error
;
send_ok
(
thd
);
break
;
case
SQLCOM_RELEASE_SAVEPOINT
:
{
...
...
sql/sql_repl.cc
View file @
2b41b8fa
...
...
@@ -44,7 +44,7 @@ static int binlog_dump_count = 0;
*/
static
int
fake_rotate_event
(
NET
*
net
,
String
*
packet
,
char
*
log_file_name
,
ulonglong
position
,
int
flags
,
const
char
**
errmsg
)
ulonglong
position
,
const
char
**
errmsg
)
{
DBUG_ENTER
(
"fake_rotate_event"
);
char
header
[
LOG_EVENT_HEADER_LEN
],
buf
[
ROTATE_HEADER_LEN
+
100
];
...
...
@@ -60,7 +60,7 @@ static int fake_rotate_event(NET* net, String* packet, char* log_file_name,
ulong
event_len
=
ident_len
+
LOG_EVENT_HEADER_LEN
+
ROTATE_HEADER_LEN
;
int4store
(
header
+
SERVER_ID_OFFSET
,
server_id
);
int4store
(
header
+
EVENT_LEN_OFFSET
,
event_len
);
int2store
(
header
+
FLAGS_OFFSET
,
flags
);
int2store
(
header
+
FLAGS_OFFSET
,
0
);
// TODO: check what problems this may cause and fix them
int4store
(
header
+
LOG_POS_OFFSET
,
0
);
...
...
@@ -325,7 +325,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
const
char
*
errmsg
=
"Unknown error"
;
NET
*
net
=
&
thd
->
net
;
pthread_mutex_t
*
log_lock
;
bool
binlog_can_be_corrupted
=
FALSE
,
rotate_was_found
=
FALSE
;
bool
binlog_can_be_corrupted
=
FALSE
;
#ifndef DBUG_OFF
int
left_events
=
max_binlog_dump_events
;
#endif
...
...
@@ -419,7 +419,7 @@ impossible position";
given that we want minimum modification of 4.0, we send the normal
and fake Rotates.
*/
if
(
fake_rotate_event
(
net
,
packet
,
log_file_name
,
pos
,
0
,
&
errmsg
))
if
(
fake_rotate_event
(
net
,
packet
,
log_file_name
,
pos
,
&
errmsg
))
{
/*
This error code is not perfect, as fake_rotate_event() does not
...
...
@@ -509,8 +509,6 @@ impossible position";
binlog_can_be_corrupted
=
(
*
packet
)[
FLAGS_OFFSET
+
1
]
&
LOG_EVENT_BINLOG_IN_USE_F
;
else
if
((
*
packet
)[
EVENT_TYPE_OFFSET
+
1
]
==
STOP_EVENT
)
binlog_can_be_corrupted
=
FALSE
;
else
if
((
*
packet
)[
EVENT_TYPE_OFFSET
+
1
]
==
ROTATE_EVENT
)
rotate_was_found
=
TRUE
;
if
(
my_net_write
(
net
,
(
char
*
)
packet
->
ptr
(),
packet
->
length
()))
{
...
...
@@ -690,13 +688,11 @@ impossible position";
*/
if
((
file
=
open_binlog
(
&
log
,
log_file_name
,
&
errmsg
))
<
0
||
fake_rotate_event
(
net
,
packet
,
log_file_name
,
BIN_LOG_HEADER_SIZE
,
rotate_was_found
?
0
:
LOG_EVENT_FORCE_ROLLBACK_F
,
&
errmsg
))
{
my_errno
=
ER_MASTER_FATAL_ERROR_READING_BINLOG
;
goto
err
;
}
rotate_was_found
=
FALSE
;
packet
->
length
(
0
);
packet
->
append
(
'\0'
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment