diff options
author | Alfranio Correia <alfranio.correia@sun.com> | 2009-06-18 14:52:46 +0100 |
---|---|---|
committer | Alfranio Correia <alfranio.correia@sun.com> | 2009-06-18 14:52:46 +0100 |
commit | 3cf052b76cb62a3efbb29d4086a893f7f0d37d94 (patch) | |
tree | 49a520e10f3b7ebb207ed083d24093a52a9d4dc6 /mysql-test/include/commit.inc | |
parent | 48d911e70834af190a0650e77584f644525af538 (diff) | |
download | mariadb-git-3cf052b76cb62a3efbb29d4086a893f7f0d37d94.tar.gz |
BUG#43929 binlog corruption when max_binlog_cache_size is exceeded
Large transactions and statements may corrupt the binary log if the size of the
cache, which is set by the max_binlog_cache_size, is not enough to store the
the changes.
In a nutshell, to fix the bug, we save the position of the next character in the
cache before starting processing a statement. If there is a problem, we simply
restore the position thus removing any effect of the statement from the cache.
Unfortunately, to avoid corrupting the binary log, we may end up loosing changes
on non-transactional tables if they do not fit in the cache. In such cases, we
store an Incident_log_event in order to stop the slave and alert users that some
changes were not logged.
Precisely, for every non-transactional changes that do not fit into the cache,
we do the following:
a) the statement is *not* logged
b) an incident event is logged after committing/rolling back the transaction,
if any. Note that if a failure happens before writing the incident event to
the binary log, the slave will not stop and the master will not have reported
any error.
c) its respective statement gives an error
For transactional changes that do not fit into the cache, we do the following:
a) the statement is *not* logged
b) its respective statement gives an error
To work properly, this patch requires two additional things. Firstly, callers to
MYSQL_BIN_LOG::write and THD::binlog_query must handle any error returned and
take the appropriate actions such as undoing the effects of a statement. We
already changed some calls in the sql_insert.cc, sql_update.cc and sql_insert.cc
modules but the remaining calls spread all over the code should be handled in
BUG#37148. Secondly, statements must be either classified as DDL or DML because
DDLs that do not get into the cache must generate an incident event since they
cannot be rolled back.
Diffstat (limited to 'mysql-test/include/commit.inc')
-rw-r--r-- | mysql-test/include/commit.inc | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/mysql-test/include/commit.inc b/mysql-test/include/commit.inc index a4e7d9ae601..5ff9d409e27 100644 --- a/mysql-test/include/commit.inc +++ b/mysql-test/include/commit.inc @@ -669,13 +669,9 @@ call p_verify_status_increment(1, 0, 1, 0); insert t1 set a=3; call p_verify_status_increment(2, 2, 2, 2); savepoint a; -call p_verify_status_increment(0, 0, 0, 0); +call p_verify_status_increment(1, 0, 0, 0); insert t1 set a=4; ---echo # Binlog does not register itself this time for other than the 1st ---echo # statement of the transaction with MIXED/STATEMENT binlog_format. ---echo # It needs registering with the ROW format. Therefore 1,0,2,2 are ---echo # the correct arguments to this test after bug#40221 fixed. -call p_verify_status_increment(1, 0, 2, 2); +call p_verify_status_increment(2, 2, 2, 2); release savepoint a; rollback; call p_verify_status_increment(0, 0, 0, 0); |