Bug #33210 SBR & read-committed / read-uncommitted transaction isolations yield an error
Submitted: 13 Dec 2007 12:55 Modified: 20 Dec 2007 1:01
Reporter: Domas Mituzas Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S2 (Serious)
Version:5.1-bk OS:Any
Assigned to: Paul DuBois CPU Architecture:Any
Tags: regression

[13 Dec 2007 12:55] Domas Mituzas
Description:
InnoDB in 5.1 added an error raising for transactions, that have SBR logging and READ-COMMITTED isolation level. As this breaks backwards (5.0) compatibility for many applications, this should be considered as bug and regression - or tagged as an incompatible change. 

	/* Statement based binlogging does not work in isolation level
	READ UNCOMMITTED and READ COMMITTED since the necessary
	locks cannot be taken. In this case, we print an
	informative error message and return with an error. */
	if (lock_type == F_WRLCK)
	{
		ulong const binlog_format= thd_binlog_format(thd);
		ulong const tx_isolation = thd_tx_isolation(current_thd);
		if (tx_isolation <= ISO_READ_COMMITTED &&
		    binlog_format == BINLOG_FORMAT_STMT)
		{
			char buf[256];
			my_snprintf(buf, sizeof(buf),
				    "Transaction level '%s' in"
				    " InnoDB is not safe for binlog mode '%s'",
				    tx_isolation_names[tx_isolation],
				    binlog_format_names[binlog_format]);
			my_error(ER_BINLOG_LOGGING_IMPOSSIBLE, MYF(0), buf);
			DBUG_RETURN(HA_ERR_LOGGING_IMPOSSIBLE);
		}
	}

How to repeat:
mysql> create table test1 (a int) engine=InnoDB;
Query OK, 0 rows affected (0.01 sec)

mysql> set session binlog_format=statement;
Query OK, 0 rows affected (0.00 sec)

mysql> set session transaction isolation level read committed;
Query OK, 0 rows affected (0.00 sec)

mysql> begin;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into test1 values (1);
ERROR 1598 (HY000): Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT'

Suggested fix:
behave like 5.0 does?
[13 Dec 2007 13:21] Heikki Tuuri
Domas,

this is the correct behavior.

I think Guilhem or someone added a warning print if someone uses READ COMMITTED in 5.1 with statement-based replication.

Users should in general move to row-based replication in 5.1, because it is theoretically less buggy that statement-based.

Regards,

Heikki
[13 Dec 2007 15:26] Domas Mituzas
it has to be documented as incompatible change, if we want to tag it as 'not a bug'.
[13 Dec 2007 16:01] Heikki Tuuri
Paul,

please check that there are prominent notices in the 5.1 manual:

if you use READ COMMITTED (which is equivalent to innodb_locks_unsafe_for_binlog in 5.0), you MUST use row-based binlogging.

Regards,

Heikki
[20 Dec 2007 0:55] Paul DuBois
Changing to Server: Documentation/Verified because this is a documentation issue.
Assigning to myself.
[20 Dec 2007 1:01] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

The update will appear here:
http://dev.mysql.com/doc/refman/5.1/en/innodb-transaction-isolation.html