maria:bb-11.0-mdev-29676-on-mdev-25292

Last commit made on 2023-04-27
Get this branch:
git clone -b bb-11.0-mdev-29676-on-mdev-25292 https://git.launchpad.net/maria

Branch merges

Branch information

Name:
bb-11.0-mdev-29676-on-mdev-25292
Repository:
lp:maria

Recent commits

5a5d10c... by Yuchen Pei

MDEV-29676 Add query to set lock wait timeout when getting sts crd

Set the lock wait timeout to 1 beforehand, and reset it afterwards, to
avoid lock conflict caused by opening the same table twice in case of
self-reference.

ae4c4d2... by Yuchen Pei

MDEV-29676 Some changes in behaviour w.r.t. spider sts crd

- assign spider->share early when !new_share
- remove locking before spider_share_init_{sts,crd}

cea9211... by Yuchen Pei

MDEV-29676 refactored and documented spider_get_share() and friends

Extracted out common subroutines, gave more meaningful names etc,
added comments etc.

Also:
- Documented active servers load balancing reads, and other fields in
  SPIDER_SHARE etc.
- Removed commented out code
- Documented and refactored self-reference check
- Removed some unnecessary functions
- Renamed unhelpful roop_count
- Refactored spider_get_{sts,crd}, where we turn get_type into an enum
- Cleaned up spider_mbase_handler::show_table_status() and
  spider_mbase_handler::show_index()

a9d975f... by Yuchen Pei

MDEV-28363 remove #ifdef SPIDER_use_LEX_CSTRING_for_Field_blob_constructor

a75b609... by Yuchen Pei

MDEV-30920 Remove need_lock and table from spider_close_sys_table()

9c054e9... by midenok

MDEV-29544 SIGSEGV in HA_CREATE_INFO::finalize_locked_tables

On finalize_atomic_replace() even if we dropped the original table
because we could not rename it to backup we also may fail to rename
temporary table by the same reason.

DDL_LOG flag passed as rename param helps to force rename when the
miscellaneous operations fail (such as maintaining the statistics).

fff2e51... by midenok

MDEV-29831 Galera crashes when running CoR for a locked table after
    setting the minimum memory for a user session.

Failure happens when finalize_atomic_replace() was already finished
and we removed the table from locked tables list.
finalize_locked_tables() doesn't know about that, it doesn't add back
last deleted lock because operation_failed == true.
reopen_tables() doesn't reopen table and as a result we have NULL in
pos_in_locked_tables->table.

The fix adds the knowledge that the locked_tables_count changed since
the start of the command. And if that happened we
add_back_last_deleted_lock(). That makes MDEV-29544 fix with
locked_tables_decremented deprecated.

Alternative fix would add atomic_replace_finished to Atomic_info and
updated it on successful finalize_atomic_replace(). Then the condition
would look like this:

  if (atomic_replace_finished || !operation_failed)
  {
    /*
      Add back the deleted table and re-created table as a locked table
      This should always work as we have a meta lock on the table.
    */
    thd->locked_tables_list.add_back_last_deleted_lock(pos_in_locked_tables);
  }

2b9fb85... by midenok

MDEV-29824 Galera crashes when running CoR for a locked table

locked_tables_list.reopen_tables() does external_lock() which in
InnoDB opens new transaction. The previous commit in send_eof() sets
s_committed state in wsrep. The new transaction didn't change that
state yet and on commit s_committed state is unexpected.

The fix is similar to MDEV-22222 (2b8b7394a12): we update wsrep state
before starting new transaction. The better wsrep fix would track the
state properly when the new transaction is started.

21460b8... by midenok

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

finalize_atomic_replace():

If rename to backup fails we fall back to the mechanism of dropping
old table. For that we write into cleanup chain these events
(executed in reverse order):

  1. rename from temporary to original;
  2. drop the original table.

After binlogging is done, in finalize_ddl() we execute that cleanup
chain in case of success. In case of error finalize_ddl() closes
cleanup chain and executes rollback chain which drops backup (at that
point non-existent) and the new table under tmp name.

mysql_rename_table():

ha_rename_table() is non-atomic, it can make partial changes and
fail. In that case we revert back these partitial changes to make it
more atomic-friendly.

ddl_log API changes:

DROP sequence of actions can now be written into non-empty
chain. After the sequence is replayed in straight order the chain
continues from what was before DROP_INIT action. That is done by
remembering last entry in ddl_log_drop_init() and update next_entry to
that in each ddl_log_drop(). Of course, each next ddl_log_drop()
updates previous DROP (or DROP_INIT) to point to itself as it was
before.

ddl_log_start_atomic_block()/ddl_log_commit_atomic_block(): these
functions allow to write multiple chain entries without updating
execute entry. Required when the block of several actions must be
atomic.

bff6171... by midenok

MDEV-29802 #sql-backup tables are visible upon CREATE OR REPLACE
    and get stuck in S3 storage

Now when detecting possibility of atomic replace we check
db_type->flags of existing table. Before that we checked only db_type
of new table.