1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-25607: Auto-generated DELETE from HEAP table can break replication

The special logic used by the memory storage engine
to keep slaves in sync with the master on a restart can
break replication. In particular, after a restart, the
master writes DELETE statements in the binlog for
each MEMORY-based table so the slave can empty its
data. If the DELETE is not executable, e.g. due to
invalid triggers, the slave will error and fail, whereas
the master will never see the problem.

Instead of DELETE statements, use TRUNCATE to
keep slaves in-sync with the master, thereby bypassing
triggers.

Reviewed By:
===========
Kristian Nielsen <knielsen@knielsen-hq.org>
Andrei Elkin <andrei.elkin@mariadb.com>
This commit is contained in:
Brandon Nesterenko
2021-06-09 11:03:03 -06:00
parent 834c013b64
commit cbc1898e82
4 changed files with 123 additions and 2 deletions

View File

@ -2993,7 +2993,7 @@ static bool open_table_entry_fini(THD *thd, TABLE_SHARE *share, TABLE *entry)
String query(query_buf, sizeof(query_buf), system_charset_info);
query.length(0);
query.append("DELETE FROM ");
query.append("TRUNCATE TABLE ");
append_identifier(thd, &query, &share->db);
query.append(".");
append_identifier(thd, &query, &share->table_name);