[MDEV-16909] RBR aborts with ER_NO_SUCH_TABLE upon RENAME on temporary table Created: 2018-08-07  Updated: 2024-02-04

Status: Stalled
Project: MariaDB Server
Component/s: Data Definition - Temporary, Replication
Affects Version/s: 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Andrei Elkin
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MDEV-16728 RENAME temporary table may not find t... Open
Relates
relates to MDEV-25587 RENAME on namesake of temporary table... Open
relates to MDEV-33376 RBR aborts with ER_NO_SUCH_TABLE, Int... Open

 Description   

--source include/have_binlog_format_row.inc
--source include/master-slave.inc
 
CREATE TEMPORARY TABLE t1 (a INT);
--error 0,1146
RENAME TABLE t1 TO tmp;
 
--sync_slave_with_master
--connection master
--source include/rpl_end.inc

10.0 9dfef6e29b9

180807  3:38:56 [ERROR] Slave SQL: Error 'Table 'test.t1' doesn't exist' on query. Default database: 'test'. Query: 'RENAME TABLE t1 TO tmp', Gtid 0-1-1, Internal MariaDB error code: 1146
180807  3:38:56 [Warning] Slave: Table 'test.t1' doesn't exist Error_code: 1146
180807  3:38:56 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'master-bin.000001' position 313
180807  3:38:56 [Note] Slave SQL thread exiting, replication stopped in log 'master-bin.000001' at position 313

The replication problem appeared in 10.0.27 release after the commit below made RENAME on temporary table possible.

commit bf2e31500c9a0a7fcdccfb724e9447347a3ab684
Author: Alexey Botchkov <holyfoot@askmonty.org>
Date:   Mon Jul 18 11:50:08 2016 +0400
 
    MDEV-8569 build_table_filename() doesn't support temporary tables.
    
            Temporary tables support added for RENAME and ALTER TABLE.



 Comments   
Comment by Elena Stepanova [ 2019-05-31 ]

Apparently the same root cause, somewhat different effect:

--source include/have_binlog_format_row.inc
--source include/master-slave.inc
 
CREATE TABLE t1 (a INT);
CREATE TEMPORARY TABLE t2 (b INT);
RENAME TABLE t2 TO t1;
--sync_slave_with_master
 
# Cleanup
--connection master
DROP TEMPORARY TABLE t1;
DROP TABLE t1;
--source include/rpl_end.inc

10.1 a47464d1

2019-05-31 15:14:47 139627934533376 [ERROR] Slave SQL: Error 'Table 't1' already exists' on query. Default database: 'test'. Query: 'RENAME TABLE t2 TO t1', Gtid 0-1-2, Internal MariaDB error code: 1050
2019-05-31 15:14:47 139627934533376 [Warning] Slave: Table 't1' already exists Error_code: 1050

Comment by Sujatha Sivakumar (Inactive) [ 2021-09-07 ]

Hello elenst,

I verified the test cases on latest 10.2 code base.

On Master:

Server version: 10.2.41-MariaDB-debug-log Source distribution
 
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]> use test;
Database changed
MariaDB [test]> CREATE TEMPORARY TABLE t1 (a INT);
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [test]> RENAME TABLE t1 TO tmp;
Query OK, 0 rows affected (0.00 sec)

On slave:

Last_SQL_Errno: 1146
Last_SQL_Error: Error 'Table 'test.t1' doesn't exist' on query. Default database: 'test'. Query: 'RENAME TABLE t1 TO tmp'

Since temporary tables are not replicated in row based replication the above error
is expected.

Test case2 from JIRA page:

On master:
==========

MariaDB Version 10.2.41-MariaDB-debug
 
MariaDB [test]> CREATE TABLE t1 (a INT);
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [test]> 
MariaDB [test]> CREATE TEMPORARY TABLE t2 (b INT);
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [test]> 
MariaDB [test]> RENAME TABLE t2 TO t1;
Query OK, 0 rows affected (0.00 sec)

On slave:
=========

Last_SQL_Errno: 1050
Last_SQL_Error: Error 'Table 't1' already exists' on query. Default database: 'test'. Query: 'RENAME TABLE t2 TO t1'

I verified the same test case on latest 10.5. It reports following error.
10.5 error looks more appropriate. I feel this needs to be fixed.

Server version: 10.5.13-MariaDB-debug-log Source distribution
Last_SQL_Errno: 1146
Last_SQL_Error: Error 'Table 'test.t2' doesn't exist' on query. Default database: 'test'. Query: 'RENAME TABLE t2 TO t1'

Can you please confirm.

Thank you.

Comment by Elena Stepanova [ 2021-09-07 ]

sujatha.sivakumar,

I can't confirm that either of these is appropriate or expected. A simple operation like RENAME, which isn't a corner case in any way and doesn't require any superuser permissions, cannot be allowed to break replication like this.

It is understandable why it is happening, as we know how RBR operates in regard to temporary tables, and how broken temporary tables are in general in regard to binlog/replication; but it still can't be declared an expected outcome. I also don't think it makes any sense to waste an effort on swapping ER_TABLE_EXISTS_ERROR with ER_NO_SUCH_TABLE, it really makes no practical difference from the end user perspective.

I however agree that the failure is a small part of a big problem, for which we have plenty other reports; so, if you want to defer solving it to some major refactoring in replication of temporary tables, I think it is okay.

Generated at Thu Feb 08 08:32:27 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.