diff options
author | Kristian Nielsen <knielsen@knielsen-hq.org> | 2017-03-24 12:07:07 +0100 |
---|---|---|
committer | Kristian Nielsen <knielsen@knielsen-hq.org> | 2017-04-21 10:30:16 +0200 |
commit | fdf2d407707faf05b8b7d67662a70cc5537d15aa (patch) | |
tree | 63fa7fb276ffe1d247054bc1712a9b745f1b129d /sql/rpl_gtid.cc | |
parent | 3cc89b3e85605ecb09b4b2222c8b0b8222a29fde (diff) | |
download | mariadb-git-fdf2d407707faf05b8b7d67662a70cc5537d15aa.tar.gz |
MDEV-12179: Per-engine mysql.gtid_slave_pos table
Intermediate commit.
Implement auto-creation of mysql.gtid_slave_pos* tables with needed engines,
if listed in --gtid-pos-auto-engines.
Uses an asynchronous approach to minimise locking overhead.
The list of available tables is extended with a flag. Extra entries are
added for --gtid-pos-auto-engines tables that do not exist yet, marked as
not existing but ready for auto-creation.
If record_gtid() needs a table marked for auto-creation, it sends a request
to the slave background thread to create the table, and continues to use an
existing table for the current and immediately coming transactions.
As soon as the slave background thread has made the new table available, it
will be used for all subsequent relevant transactions in record_gtid().
This asynchronous approach also avoids a lot of complex issues around trying
to do DDL in the middle of an on-going transaction.
Diffstat (limited to 'sql/rpl_gtid.cc')
-rw-r--r-- | sql/rpl_gtid.cc | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc index ac3c621a5c1..af70f281d8c 100644 --- a/sql/rpl_gtid.cc +++ b/sql/rpl_gtid.cc @@ -26,6 +26,7 @@ #include "key.h" #include "rpl_gtid.h" #include "rpl_rli.h" +#include "slave.h" const LEX_STRING rpl_gtid_slave_state_table_name= @@ -494,8 +495,20 @@ rpl_slave_state::select_gtid_pos_table(THD *thd, LEX_STRING *out_tablename) { if (table_entry->table_hton == trx_hton) { - *out_tablename= table_entry->table_name; - return; + if (likely(table_entry->state == GTID_POS_AVAILABLE)) + { + *out_tablename= table_entry->table_name; + return; + } + /* + This engine is marked to automatically create the table. + We cannot easily do this here (possibly in the middle of a + transaction). But we can request the slave background thread + to create it, and in a short while it should become available + for following transactions. + */ + slave_background_gtid_pos_create_request(table_entry); + break; } table_entry= table_entry->next; } @@ -1240,7 +1253,8 @@ rpl_slave_state::add_gtid_pos_table(rpl_slave_state::gtid_pos_table *entry) struct rpl_slave_state::gtid_pos_table * -rpl_slave_state::alloc_gtid_pos_table(LEX_STRING *table_name, void *hton) +rpl_slave_state::alloc_gtid_pos_table(LEX_STRING *table_name, void *hton, + rpl_slave_state::gtid_pos_table_state state) { struct gtid_pos_table *p; char *allocated_str; @@ -1258,6 +1272,7 @@ rpl_slave_state::alloc_gtid_pos_table(LEX_STRING *table_name, void *hton) p->table_hton= hton; p->table_name.str= allocated_str; p->table_name.length= table_name->length; + p->state= state; return p; } |