Bug #47175 | failing INSERT, transaction, replication out of sync | ||
---|---|---|---|
Submitted: | 7 Sep 2009 13:25 | Modified: | 7 Mar 2010 1:53 |
Reporter: | Matthias Leich | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Row Based Replication ( RBR ) | Severity: | S3 (Non-critical) |
Version: | 5.1,5.4 | OS: | Any |
Assigned to: | Alfranio Tavares Correia Junior | CPU Architecture: | Any |
[7 Sep 2009 13:25]
Matthias Leich
[23 Sep 2009 2:47]
Alfranio Tavares Correia Junior
See also BUG#47287.
[23 Sep 2009 3:47]
Alfranio Tavares Correia Junior
The problem in this bug stems from the fact that the failing statement, which has changed a non-transactional table, does not get through the binary log even after calling ROLLBACK to finish the transaction. This problem will be partially fixed in BUG#47287 as an early statement that fails and has changed non-transactional tables will be automatically written to the binary log as follows: COMMANDS: CREATE TABLE `tt_1_innodb` ( f1 INTEGER, f2 INT, PRIMARY KEY (f1)) ENGINE = Innodb; CREATE TABLE `nt_1_myisam` ( f1 INTEGER, f2 INT, PRIMARY KEY (f1)) ENGINE = MyISAM; INSERT INTO nt_1_myisam VALUES (1, NULL) , (2, 1); SET AUTOCOMMIT = 0; CREATE TABLE nt_2_myisam ( f2 INT, f1 INTEGER , PRIMARY KEY (f1)) ENGINE = MyISAM; INSERT INTO nt_2_myisam VALUES (NULL, 1); COMMIT; --error ER_DUP_ENTRY INSERT INTO nt_2_myisam SELECT * FROM nt_1_myisam; ROLLBACK; BINLOG: Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 4 Format_desc 1 106 Server ver: 5.1.39-debug-log, Binlog ver: 4 master-bin.000001 106 Query 1 251 use `test`; CREATE TABLE `tt_1_innodb` ( f1 INTEGER, f2 INT, PRIMARY KEY (f1)) ENGINE = Innodb master-bin.000001 251 Query 1 396 use `test`; CREATE TABLE `nt_1_myisam` ( f1 INTEGER, f2 INT, PRIMARY KEY (f1)) ENGINE = MyISAM master-bin.000001 396 Query 1 464 BEGIN master-bin.000001 464 Table_map 1 515 table_id: 23 (test.nt_1_myisam) master-bin.000001 515 Write_rows 1 558 table_id: 23 flags: STMT_END_F master-bin.000001 558 Query 1 627 COMMIT master-bin.000001 627 Query 1 771 use `test`; CREATE TABLE nt_2_myisam ( f2 INT, f1 INTEGER , PRIMARY KEY (f1)) ENGINE = MyISAM master-bin.000001 771 Query 1 839 BEGIN master-bin.000001 839 Table_map 1 890 table_id: 24 (test.nt_2_myisam) master-bin.000001 890 Write_rows 1 924 table_id: 24 flags: STMT_END_F master-bin.000001 924 Query 1 993 COMMIT master-bin.000001 993 Query 1 1061 BEGIN master-bin.000001 1061 Table_map 1 1112 table_id: 24 (test.nt_2_myisam) master-bin.000001 1112 Write_rows 1 1150 table_id: 24 flags: STMT_END_F master-bin.000001 1150 Query 1 1221 ROLLBACK However, there is another problem not fixed by BUG#47287 and that would pop up if we slightly change the statements: INSERT INTO tt_1_innodb SELECT * FROM nt_1_myisam; --error ER_DUP_ENTRY INSERT INTO nt_2_myisam SELECT * FROM nt_1_myisam; ROLLBACK; In this case, nothing is written to the binary log although a non-transactional table was updated. This happen because in row mode: thd->transaction.all.modified_non_trans_table is not set to true and the following code in the log.cc is not executed: if ((all && thd->transaction.all.modified_non_trans_table) || (!all && thd->transaction.stmt.modified_non_trans_table && !(thd->options & (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT))) || (!all && thd->transaction.stmt.modified_non_trans_table && !trx_data->at_least_one_stmt && thd->current_stmt_binlog_row_based) || ((thd->options & OPTION_KEEP_LOG))) { Query_log_event qev(thd, STRING_WITH_LEN("ROLLBACK"), TRUE, TRUE, 0); error= binlog_end_trans(thd, trx_data, &qev, all); }
[23 Sep 2009 5:14]
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/84236 3118 Alfranio Correia 2009-09-23 BUG#47175 failing INSERT, transaction, replication out of sync In the RBR mode, a failing INSERT...SELECT statement was not corretly setting the variable THD::transaction.all.modified_non_trans_table and as such if a rollback was requested and no other non-transactional table updated, nothing was written to the binary log. To fix the bug, we set the variable regardless the replication mode.
[29 Sep 2009 10:10]
Luis Soares
Will be fixed after WL#2687 is pushed in future release.
[4 Nov 2009 1:33]
Alfranio Tavares Correia Junior
Pushed to mysql-5.1-rep+3 revision-id: alfranio.correia@sun.com-20091103190256-637o8qxlveikrt3i
[12 Nov 2009 23:56]
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/90290 3120 Alfranio Correia 2009-11-12 Post-fix for WL#2687 WL#5072 BUG#40278 BUG#47175 Create a set of test cases to see if some DDL statements implicitly commit a transaction on the NDB and are written directly to the binary log without going through either the Statement- or Transactional-Cache.
[13 Nov 2009 0:18]
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/90291 3120 Alfranio Correia 2009-11-13 Post-fix for WL#2687 WL#5072 BUG#40278 BUG#47175 Create a set of test cases to see if some DDL statements implicitly commit a transaction on the NDB and are written directly to the binary log without going through either the Statement- or Transactional-Cache.
[18 Jan 2010 12:06]
Bugs System
Pushed into 6.0.14-alpha (revid:alik@ibmvm-20100118120357-hnzhgadkpzqfnvsc) (version source revid:alik@ibmvm-20100118115413-kd3klpine09yyktw) (merge vers: 6.0.14-alpha) (pib:16)
[18 Jan 2010 12:07]
Bugs System
Pushed into mysql-next-mr (revid:alik@ibmvm-20100118120111-73dulkgc893it4r9) (version source revid:alik@ibmvm-20100118115335-0stecyzftqm7bqx6) (pib:16)
[19 Jan 2010 8:45]
Jon Stephens
Documented bugfix in the 5.6.0 and 6.0.14 changelogs. Set NDI state, waiting for further merges.
[15 Feb 2010 10:17]
Jon Stephens
Discussed with Alfranio; no further merges expected. Closed.
[6 Mar 2010 11:06]
Bugs System
Pushed into 5.5.3-m3 (revid:alik@sun.com-20100306103849-hha31z2enhh7jwt3) (version source revid:vvaintroub@linux-rbsx-20100118220048-5vnyqi5ghsbgmdsd) (merge vers: 5.5.99-m3) (pib:16)
[7 Mar 2010 1:53]
Paul DuBois
Moved 5.6.0 changelog entry to 5.5.3.