LevelDB Storage Engine MS2 (MDEV-4201)

[MDEV-4376] LevelDB: Statements suspected to be unsafe cannot be executed when binary log is ON Created: 2013-04-07  Updated: 2013-05-27  Resolved: 2013-05-27

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Technical task Priority: Minor
Reporter: Elena Stepanova Assignee: Sergei Petrunia
Resolution: Won't Fix Votes: 0
Labels: None

Issue Links:
Relates

 Description   

It is most likely an upstream problem, but I cannot positively prove it since it requires an engine which only supports STATEMENT binlog format.

Statements like

INSERT INTO t1 SELECT * FROM t1

cannot be executed at all when binlog is enabled.
The statement is considered unsafe for statement-based replication, and normally it would be processed the following way:

  • with binlog_format=ROW it is executed all right;
  • with binlog_format=MIXED it is written in the ROW format;
  • with binlog_format=STATEMENT it is executed, and a warning is written into the error log.

However, with LevelDB (and possibly with any engine limited to STATEMENT format), it cannot be executed with ROW or MIXED format because of the limitation, and with STATEMENT format it causes an unexpected error:

mysql> select @@binlog_format;
+-----------------+
| @@binlog_format |
+-----------------+
| STATEMENT       |
+-----------------+
1 row in set (0.00 sec)
 
mysql> CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=LevelDB;
Query OK, 0 rows affected (0.13 sec)
 
mysql> INSERT INTO t1 VALUES (1),(2);
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0
 
mysql> INSERT INTO t1 SELECT NULL FROM t1;
ERROR 1663 (HY000): Cannot execute statement: impossible to write to binary log since statement is unsafe, storage engine is limited to statement-based logging, and BINLOG_FORMAT = MIXED. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.

That is, on some reason server behaves as if the format was MIXED, while it's actually STATEMENT.

Test case:

--source include/have_binlog_format_statement.inc
 
SELECT @@binlog_format;
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=LevelDB;
INSERT INTO t1 VALUES (1),(2);
INSERT INTO t1 SELECT NULL FROM t1;

revision-id: psergey@askmonty.org-20130406172740-fid7u9tkz5ahlc4c
revno: 4823
branch-nick: mysql-5.6-leveldb


Generated at Thu Feb 08 06:55:57 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.