maria:MDEV-29770/rm_table_variation

Last commit made on 2022-10-17
Get this branch:
git clone -b MDEV-29770/rm_table_variation https://git.launchpad.net/maria

Branch merges

Branch information

Name:
MDEV-29770/rm_table_variation
Repository:
lp:maria

Recent commits

1c6ed3e... by midenok

Fix

93acf5a... by midenok

Variation without log_drop

22701cd... by midenok

Progress

a25c1b7... by midenok

Atomic block

933764d... by midenok

MDEV-29770 Broken table cannot be CREATE OR REPLACE -ed anymore

6df00b8... by midenok

MDEV-29783 ER_NO_SUCH_TABLE_IN_ENGINE after failed CREATE OR REPLACE with FK violation

If atomic C-O-R fails it reverts back to original table. When doing so
InnoDB code checked old table for foreign key consistency and
failed. The patch disables foreign key check when reverting to
original table: they was created in previous statement and current
statement has nothing to do with that.

InnoDB part just disables any warnings in that case. The warnings was
done when the foreign keys was created.

aabf073... by midenok

MDEV-29793 Assertion failure in translog_write_record upon CREATE OR REPLACE

Aria cannot start bulk insert with transactional logging of temporary
table (fails on assertion). But complex join does external_lock()
which disables logging again but sees log_incomplete and does
translog_write_record() which expects logging on.

Probably some logic of Aria is wrong. Atomic C-O-R does
mysql_trans_prepare_alter_copy_data() hack to overcome the prohibition
of transactional logging in temporary table for bulk insert. There is
no objective reason for that prohibition for atomic C-O-R temporary
table as the same works with non-temporary table. And now we enable
transaction back after ha_start_bulk_insert() so complex join will be
happy with external_lock().

396253a... by midenok

MDEV-29791 ER_NO_SUCH_TABLE_IN_ENGINE or "File not found"
    upon concurrent DDL with CREATE OR REPLACE

Race condition happens when atomic C-O-R drops backup table by
replaying ddl_log_state_rm in finalize_ddl(). When it already dropped
table (DDL_DROP_PHASE_TABLE) and before DDL_DROP_PHASE_TRIGGER
triggers still exist. At that point another thread tries to drop the
trigger and finds no such table.

The fix protects triggers with MDL lock when renaming original table
to backup. Thus we can drop triggers in another thread either before
that and rename to backup will be already without triggers or after
the C-O-R is finished and at that point there will be no table nor
triggers.

c64fbbf... by midenok

MDEV-29787 CREATE OR REPLACE does not work with custom DATA/INDEX DIRECTORY

When data_file_name and/or index_file_name setting is defined we must
update it for atomic C-O-R. The first update for any CREATE TABLE is in
Sql_cmd_create_table_like::execute(THD *thd):

  /* Fix names if symlinked or relocated tables */
  if (append_file_to_dir(thd, &create_info.data_file_name,
                         &create_table->table_name) ||
      append_file_to_dir(thd, &create_info.index_file_name,
                         &create_table->table_name))
    goto end_with_restore_list;

At the beginning of "if" data_file_name/index_file_name contain
directory path (or NULL). Then we add table_name to it.

In the second update in make_tmp_table_list() (which is done for
atomic C-O-R only) we return data_file_name/index_file_name back to
directory state and then append temporary table name.

4511e7e... by midenok

MDEV-29779 Unexpected ER_ERROR_ON_RENAME upon CREATE OR REPLACE

When table was renamed to backup its foreign keys was loaded into
cache and checked for validity. We must not load foreign keys in that
case: there is nothing to check as these foreign keys was already
there and we don't need them in cache for temporary table.