[MDEV-685] LP:662714 - PBXT replication failure with simple transactions Created: 2010-10-18  Updated: 2013-05-07  Resolved: 2013-05-07

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 5.5.28, 5.3.9, 5.1.62
Fix Version/s: 5.5.31, 5.2.15, 5.3.13

Type: Bug Priority: Minor
Reporter: Philip Stoev (Inactive) Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: Launchpad, pbxt

Attachments: XML File LPexportBug662714.xml    

 Description   

The following test causes PBXT replication to fail:

--source include/have_pbxt.inc
--source include/master-slave.inc
--source include/have_binlog_format_row.inc
--disable_abort_on_error
CREATE TABLE `table10_pbxt_int_autoinc` ( `col_int_key` int, pk integer auto_increment, `col_int` int, key (`col_int_key` ), primary key (pk)) ENGINE=pbxt;
INSERT /*! IGNORE */ INTO table10_pbxt_int_autoinc VALUES (100, NULL, 100) , (100, NULL, 100) , (100, NULL, 100) , (100, NULL, 100) , (100, NULL, 100) , (100, NULL, 100) , (100, NULL, 100) , (100, NULL, 100) , (100, NULL, 100) , (100, NULL, 100);
SET AUTOCOMMIT=OFF;
DELETE FROM `table10_pbxt_int_autoinc` WHERE 1 = 1 LIMIT 6;
UPDATE `table10_pbxt_int_autoinc` SET `pk` = 2 WHERE `col_int_key` > 3 LIMIT 6;
UPDATE `table10_pbxt_int_autoinc` SET `col_int_key` = 2 WHERE `pk` > 0 LIMIT 2;
set autocommit=1;
--sync_slave_with_master

The error is

Last_SQL_Error Could not execute Update_rows event on table test.table10_pbxt_int_autoinc; Can't find record in 'table10_pbxt_int_autoinc', Error_code: 1032; handler error HA_ERR_END_OF_FILE; the event's master log master-bin.000001, end_log_pos 1083



 Comments   
Comment by Philip Stoev (Inactive) [ 2010-10-18 ]

Re: PBXT replication failure with autocommit=ON/OFF
Bug is also reproducible without LIMIT in the queries and with COMMIT instead of autocommit=1 . The table has a primary key.

Comment by Kristian Nielsen [ 2010-10-18 ]

Re: PBXT replication failure with simple transactions
The problem can be repeated with a simpler test case that does not involve replication:

--source include/have_pbxt.inc
CREATE TABLE t1 (a INT, b INTEGER AUTO_INCREMENT PRIMARY KEY, c INT) ENGINE=pbxt;
INSERT INTO t1 VALUES (100, NULL, 100), (100, NULL, 100);
BEGIN;
--error 1062
UPDATE t1 SET b = 20 WHERE a > 3 LIMIT 6;
SELECT * FROM t1 ORDER BY b;
COMMIT;
SELECT * FROM t1 ORDER BY b;
DROP TABLE t1;
DROP DATABASE pbxt;

The failing update is not rolled back as it should be; it leaves the primary key of the first row changed from 2 to 20.

Comment by Kristian Nielsen [ 2010-10-18 ]

Re: PBXT replication failure with simple transactions
This may be a limitation of PBXT with transactions where some statements fail.

From the PBXT documentation, http://www.primebase.org/documentation/#diffs :

8.2 No Statement Level Sub-transactions

PBXT does not support statement level sub-transactions. This means that if an error occurs, PBXT will rollback the entire transaction, not just the current statement.

The only exception to this is the duplicate key error. PBXT undoes the INSERT or UPDATE statement when an duplicate key error occurs. The user is then free to decide whether to continue, or rollback the transaction.

Note that this can cause problems for replication, and means that INSERT with multiple rows should not be used when replicating PBXT tables. For example:

use test;
drop table if exists t;
create table t ( i int not null, unique index i ) engine = PBXT;
set autocommit = 0;
insert into t values (1),(2),(2);

  1. error 1062 (duplicate key) occurs
    commit;

select * from t;
i
1
2

In the above example, the INSERT statement is not completely rolled back. MySQL replication, however, will not replicate any part of the statement because it assumes that a transactional storage engine supports statement level sub-transactions.

In the original test case, the first UPDATE statement fails, and is therefore not replicated, however it is not completely rolled back despite what the pbxt documentation says.

Comment by Philip Stoev (Inactive) [ 2010-10-18 ]

Re: [Bug 662714] Re: PBXT replication failure with simple transactions
Thanks for the pointer, will try to construct a test case that is error-free
and does not use multi-row insert.

Philip Stoev

Comment by Kristian Nielsen [ 2010-10-18 ]

Re: PBXT replication failure with simple transactions
Actually, thinking more, I do believe that this is a bug in PBXT.

I don't know if PBXT should be able to roll back only the statement that fails with duplicate key error, as the documentation states. But if not, it should do like NDB, which also is not able to roll back single statements that fail. In this case, the transaction should be marked as failed, and any further operations in the transaction should cause an error (including commit, but excluding rollback of course).

This will force the transaction to roll back in its entirety, and replication will not fail.

Philip, a possible work-around might be if you can in your tests detect failing statements, and in such cases roll back the entire transactions. This might be useful for any engine that lacks the ability to roll back single statements.

Comment by Rasmus Johansson (Inactive) [ 2010-10-19 ]

Launchpad bug id: 662714

Comment by Paul McCullagh (Inactive) [ 2010-10-19 ]

Re: PBXT replication failure with simple transactions
Kristian, your insights into the problem are spot on.

The documentation is incorrect. The "statement undo", is only done correctly in the special case that the statement only affects one row. At least, this is all that is done in the current implementation.

As you say, PBXT should return an error in all other cases, and then continue to return an error until the end of the transaction.

Comment by Elena Stepanova [ 2012-11-02 ]

Setting to minor because it's PBXT

Comment by Sergei Petrunia [ 2013-05-07 ]

PBXT is no longer developed.

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