| Bug #47327 | ROLLBACK TO SAVEPOINT binlogged if trx contains non-trx updates before savepoint | ||
|---|---|---|---|
| Submitted: | 15 Sep 15:21 | Modified: | 23 Nov 4:48 |
| Reporter: | Sven Sandberg | ||
| Status: | In progress | ||
| Category: | Server: Replication | Severity: | S3 (Non-critical) |
| Version: | 5.1, 6.0 | OS: | Any |
| Assigned to: | Alfranio Correia | Target Version: | |
| Tags: | non-transactional table, binlog, rollback to savepoint | ||
| Triage: | Triaged: D5 (Feature request) | ||
[4 Oct 13:28]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/85676 3519 Alfranio Correia 2009-10-04 BUG#47327 ROLLBACK TO SAVEPOINT binlogged if trx contains non-trx updates before savepoint Draft of a patch based on the WL#2687.
[3 Nov 20:20]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/89214 3117 Alfranio Correia 2009-11-03 BUG#47327 ROLLBACK TO SAVEPOINT binlogged if trx contains non-trx updates before savepoint When a ROLLBACK is issued, and there is no updates to non-transactional tables, then the transaction cache is cleared and not written to the binlog. However, if the transaction contains updates to non-transactional tables, then the transaction cache is written to the binlog, followed by a ROLLBACK. However, this happens even when the non-transactional changes were written to the binlog through the non-transaction cache and as such the transaction cache does not contain non-transactional. When a ROLLBACK TO SAVEPOINT is issued, and the transaction cache does not contain updates to non-transactional tables, then the transaction cache is cleared from the savepoint to the end. However, if the transaction cache contains updates to non-transactional tables, then the transaction cache is not cleared, even if the non-transactional updates are outside the scope of the savepoint. To fix the problem, we keep the track of the content of the transaction cache, in order to truncate it and avoid writing unnecessary data to the binary log when it does not have updates to non-transactional.

Description: When a ROLLBACK is issued, and the transaction cache does not contain any updates to non-transactional tables, then the transaction cache is cleared and not written to the binlog. If the transaction contains updates to non-transactional tables, then the transaction cache is written to the binlog, followed by a ROLLBACK. This is all good. When a ROLLBACK TO SAVEPOINT is issued, and the transaction cache does not contain updates to non-transactional tables, then the transaction cache is cleared from the savepoint to the end. However, if the transaction cache contains updates to non-transactional tables, then the transaction cache is not cleared, even if the non-transactional updates are outside the scope of the savepoint. It would be better if the transaction cache was only cleared when there is a non-transactional update in the transaction cache *after* the last savepoint. How to repeat: --source include/have_binlog_format_statement.inc --source include/have_innodb.inc create table t0 (a int) engine=myisam; create table t2 (a int) engine=innodb; show create table t0; show create table t2; begin; insert into t2 values (1); insert into t0 values (1); savepoint s1; insert into t2 values (1); rollback to s1; commit; # then run mysqlbinlog on master-bin.000001 Suggested fix: This should be simple to fix after BUG#47326 is fixed.