summaryrefslogtreecommitdiff
path: root/sql/wsrep_mysqld.h
diff options
context:
space:
mode:
authorsjaakola <seppo.jaakola@iki.fi>2020-10-27 12:45:42 +0200
committerJan Lindström <jan.lindstrom@mariadb.com>2020-11-03 19:40:06 +0200
commit4d6c6611443f1e0e1cdab34ac6e320031e7f980b (patch)
tree668ad8155d96f1cd151f729fac2fd2503083e4e3 /sql/wsrep_mysqld.h
parent5739c7702d83e83ecff5cdd84e0fab899101f9f5 (diff)
downloadmariadb-git-4d6c6611443f1e0e1cdab34ac6e320031e7f980b.tar.gz
MDEV-21577 MDL BF-BF conflict
Some DDL statements appear to acquire MDL locks for a table referenced by foreign key constraint from the actual affected table of the DDL statement. OPTIMIZE, REPAIR and ALTER TABLE belong to this class of DDL statements. Earlier MariaDB version did not take this in consideration, and appended only affected table in the certification key list in write set. Because of missing certification information, it could happen that e.g. OPTIMIZE table for FK child table could be allowed to apply in parallel with DML operating on the foreign key parent table, and this could lead to unhandled MDL lock conflicts between two high priority appliers (BF). The fix in this patch, changes the TOI replication for OPTIMIZE, REPAIR and ALTER TABLE statements so that before the execution of respective DDL statement, there is foreign key parent search round. This FK parent search contains following steps: * open and lock the affected table (with permissive shared locks) * iterate over foreign key contstraints and collect and array of Fk parent table names * close all tables open for the THD and release MDL locks * do the actual TOI replication with the affected table and FK parent table names as key values The patch contains also new mtr test for verifying that the above mentioned DDL statements replicate without problems when operating on FK child table. The mtr test scenario #1, which can be used to check if some other DDL (on top of OPTIMIZE, REPAIR and ALTER) could cause similar excessive FK parent table locking. Reviewed-by: Aleksey Midenkov <aleksey.midenkov@mariadb.com> Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
Diffstat (limited to 'sql/wsrep_mysqld.h')
-rw-r--r--sql/wsrep_mysqld.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index a717caa836e..b0050a2ebae 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -212,6 +212,7 @@ wsrep_sync_wait_upto (THD* thd, wsrep_gtid_t* upto, int timeout);
extern void wsrep_last_committed_id (wsrep_gtid_t* gtid);
extern int wsrep_check_opts();
extern void wsrep_prepend_PATH (const char* path);
+void wsrep_append_fk_parent_table(THD* thd, TABLE_LIST* table, wsrep::key_array* keys);
/* Other global variables */
extern wsrep_seqno_t wsrep_locked_seqno;
@@ -357,7 +358,7 @@ struct TABLE_LIST;
class Alter_info;
int wsrep_to_isolation_begin(THD *thd, const char *db_, const char *table_,
const TABLE_LIST* table_list,
- Alter_info* alter_info= NULL);
+ Alter_info* alter_info= NULL, wsrep::key_array *fk_tables=NULL);
void wsrep_to_isolation_end(THD *thd);
@@ -476,6 +477,9 @@ void wsrep_deinit_server();
*/
enum wsrep::streaming_context::fragment_unit wsrep_fragment_unit(ulong unit);
+wsrep::key wsrep_prepare_key_for_toi(const char* db, const char* table,
+ enum wsrep::key::type type);
+
#else /* !WITH_WSREP */
/* These macros are needed to compile MariaDB without WSREP support