#At file:///home/acorreia/workspace.oracle/repository.mysql/bzrwork/wl-4832/mysql-trunk/ based on revid:alfranio.correia@stripped
3083 Alfranio Correia 2011-05-17
Fixed recover routine in the context of WL#4832.
The previous routine was considering a transaction as valid after
reading the next begin event or reaching the end of the log. However,
if the next begin was invalid the previous and valid transaction was
removed from the binary log.
We fixed the code by considering a transaction as valid when its
commit is read and is valid.
modified:
sql/binlog.cc
=== modified file 'sql/binlog.cc'
--- a/sql/binlog.cc 2011-05-12 21:51:20 +0000
+++ b/sql/binlog.cc 2011-05-17 20:04:06 +0000
@@ -4615,12 +4615,11 @@ int MYSQL_BIN_LOG::recover(IO_CACHE *log
Log_event *ev;
HASH xids;
MEM_ROOT mem_root;
- my_off_t last_valid_pos= *valid_pos;
/*
The flag is used for handling the case that a transaction
is partially written to the binlog.
*/
- bool in_transaction= TRUE;
+ bool in_transaction= FALSE;
if (! fdle->is_valid() ||
my_hash_init(&xids, &my_charset_bin, TC_LOG_PAGE_SIZE/3, 0,
@@ -4638,11 +4637,7 @@ int MYSQL_BIN_LOG::recover(IO_CACHE *log
*/
if (ev->get_type_code() == QUERY_EVENT &&
!strcmp(((Query_log_event*)ev)->query, "BEGIN"))
- {
in_transaction= TRUE;
- *valid_pos= last_valid_pos;
- }
- last_valid_pos= my_b_tell(log);
if (ev->get_type_code() == QUERY_EVENT &&
!strcmp(((Query_log_event*)ev)->query, "COMMIT"))
@@ -4660,16 +4655,17 @@ int MYSQL_BIN_LOG::recover(IO_CACHE *log
if (!x || my_hash_insert(&xids, x))
goto err2;
}
+
+ /*
+ Recorded valid position for the crashed binlog file
+ which did not contain incorrect events.
+ */
+ if (!log->error && !in_transaction)
+ *valid_pos= my_b_tell(log);
+
delete ev;
}
- /*
- Recorded valid position for the crashed binlog file
- which did not contain incorrect events.
- */
- if (!log->error && !in_transaction)
- *valid_pos= last_valid_pos;
-
if (ha_recover(&xids))
goto err2;
Attachment: [text/bzr-bundle] bzr/alfranio.correia@oracle.com-20110517200406-724b77qi743u6nni.bundle
| Thread |
|---|
| • bzr commit into mysql-trunk-wl4832 branch (alfranio.correia:3083) WL#4832 | Alfranio Correia | 19 May |