1. 08 Apr, 2021 14 commits
    • Marko Mäkelä's avatar
      MDEV-25315 Crash in SHOW ENGINE INNODB STATUS · 1fde5812
      Marko Mäkelä authored
      In commit 8ea923f5 (MDEV-24818)
      when we optimized multi-statement INSERT into an empty table,
      we would sometimes wrongly enable bulk insert into a table that
      is actually already using row-level locking and undo logging.
      
      trx_has_lock_x(): New predicate, to check if the transaction of
      the current thread is holding an exclusive lock on a table.
      
      trx_undo_report_row_operation(): Only invoke
      trx_mod_table_time_t::start_bulk_insert() if
      trx_has_lock_x() holds.
      1fde5812
    • Sujatha's avatar
      MDEV-20220: Merge 5.7 P_S replication table 'replication_applier_status_by_worker · f9bd7f20
      Sujatha authored
      Step 3:
      ======
      
      Preserve worker pool information on either STOP SLAVE/Error.  In case STOP
      SLAVE is executed worker threads will be gone, hence worker threads will be
      unavailable. Querying the table at this stage will give empty rows. To
      address this case when worker threads are about to stop, due to an error or
      forced stop, create a backup pool and preserve the data which is relevant to
      populate performance schema table. Clear the backup pool upon slave start.
      f9bd7f20
    • Sujatha's avatar
      MDEV-20220: Merge 5.7 P_S replication table 'replication_applier_status_by_worker · 036ee612
      Sujatha authored
      Step2:
      =====
      Add two extra columns mentioned below.
      ---------------------------------------------------------------------------
      |Column Name:           |        Description:                             |
      |-------------------------------------------------------------------------|
      |                       |                                                 |
      |WORKER_IDLE_TIME       | Total idle time in seconds that the worker      |
      |                       | thread has spent waiting for work from          |
      |                       | co-ordinator thread                             |
      |                       |                                                 |
      |LAST_TRANS_RETRY_COUNT | Total number of retries attempted by last       |
      |                       | transaction                                     |
      ---------------------------------------------------------------------------
      036ee612
    • Sujatha's avatar
      MDEV-20220: Merge 5.7 P_S replication table 'replication_applier_status_by_worker · 94f1d0f8
      Sujatha authored
      Step1:
      =====
      Backport 'replication_applier_status_by_worker' from upstream.
      
      Iterate through rpl_parallel_thread_pool and display slave worker thread
      specific information as part of 'replication_applier_status_by_worker'
      table.
      
      ---------------------------------------------------------------------------
      |Column Name:           |        Description:                             |
      |-------------------------------------------------------------------------|
      |                       |                                                 |
      |CHANNEL_NAME           | Name of replication channel through which the   |
      |                       | transaction is received.                        |
      |                       |                                                 |
      |THREAD_ID              | Thread_Id as displayed in 'performance_schema.  |
      |                       | threads' table for thread with name             |
      |                       | 'thread/sql/rpl_parallel_thread'                |
      |                       |                                                 |
      |                       | THREAD_ID will be NULL when worker threads are  |
      |                       | stopped due to an error/force stop              |
      |                       |                                                 |
      |SERVICE_STATE          | Thread is running or not                        |
      |                       |                                                 |
      |LAST_SEEN_TRANSACTION  | Last GTID executed by worker                    |
      |                       |                                                 |
      |LAST_ERROR_NUMBER      | Last Error that occured on a particular worker  |
      |                       |                                                 |
      |LAST_ERROR_MESSAGE     | Last error specific message                     |
      |                       |                                                 |
      |LAST_ERROR_TIMESTAMP   | Time stamp of last error                        |
      |                       |                                                 |
      ---------------------------------------------------------------------------
      
      CHANNEL_NAME will be empty when the worker has not processed any
      transaction. Channel_name points to valid source channel_name when it is
      processing a transaction/event group.
      94f1d0f8
    • Marko Mäkelä's avatar
      MDEV-25371 Potential hang in wsrep_is_BF_lock_timeout() · 7c524d44
      Marko Mäkelä authored
      In commit e71e6133 (MDEV-24671),
      lock_sys.wait_mutex was moved above lock_sys.mutex
      (which was later replaced with lock_sys.latch) in the latching order.
      
      In commit 7cf4419f (MDEV-24789),
      a potential hang was introduced to Galera. The function lock_wait()
      would hold lock_sys.wait_mutex while invoking wsrep_is_BF_lock_timeout(),
      which in turn could acquire LockMutexGuard for some diagnostic printout.
      
      wsrep_is_BF_lock_timeout(): Do not invoke trx_print_latched() or
      LockMutexGuard.
      
      lock_sys_t::wr_lock(), lock_sys_t::rd_lock(): Assert that the current
      thread is not holding lock_sys.wait_mutex.
      Unfortunately, RW-locks are not covered by SAFE_MUTEX.
      
      Reviewed by: Jan Lindström
      7c524d44
    • Marko Mäkelä's avatar
      Merge 10.5 into 10.6 · 1900c2ed
      Marko Mäkelä authored
      1900c2ed
    • Daniel Black's avatar
      GIS skip_locked_nowait test needs fixing · 76db096a
      Daniel Black authored
      76db096a
    • Martin Hansson's avatar
      MDEV-13115: Add Oracle SKIP LOCKED tests cases · f41f7199
      Martin Hansson authored
      Imported the following tests from Oracle MySQL:
      
      * mysql-test/t/locking_clause.test
      * mysql-test/suite/innodb/t/skip_locked_nowait.test
      * mysql-test/t/locking_part.test
      
      Ported to MariaDB by Daniel Black, changes include:
      * Removed 'FOR SHARE OF /FOR UPDATE OF' tests that are part of
        MDEV-17514 (not yet implemented)
      * mysql-test/t/locking_clause.test removes broken the limit test (outstanding MDEV-25244) bug.
      * mysql-test/suite/innodb/t/skip_locked_nowait.test - removed high
        priority transactions
      * mysql-test/t/locking_part.test imported to mysql-test/suite/innodb/t/partition_locking.test
        changed ER_LOCK_NOWAIT -> ER_LOCK_WAIT_TIMEOUT consistent with already
        implemented WAIT/NOWAIT feature. Changed "FOR SHARE SKIP LOCKED" ->
        "LOCK IN SHARE MODE SKIP LOCKED".
      f41f7199
    • Daniel Black's avatar
      MDEV-13115: Implement SELECT SKIP LOCKED · 553ef1a7
      Daniel Black authored
      Adds an implementation for SELECT ... FOR UPDATE SKIP LOCKED /
      SELECT ... LOCK IN SHARED MODE SKIP LOCKED
      
      This is implemented only InnoDB at the moment, not in RockDB yet.
      
      This adds a new hander flag HA_CAN_SKIP_LOCKED than
      will be used when the storage engine advertises the flag.
      
      When a storage engine indicates this flag it will get
      TL_WRITE_SKIP_LOCKED and TL_READ_SKIP_LOCKED transaction types.
      
      The Lex structure has been updated to store both the FOR UPDATE/LOCK IN
      SHARE as well as the SKIP LOCKED so the SHOW CREATE VIEW
      implementation is simplier.
      
      "SELECT FOR UPDATE ... SKIP LOCKED" combined with CREATE TABLE AS or
      INSERT.. SELECT on the result set is not safe for STATEMENT based
      replication. MIXED replication will replicate this as row based events."
      
      Thanks to guidance from Facebook commit
      https://github.com/facebook/mysql-5.6/commit/193896c466d43fd905a62a60f1d73fd9c551a6e4
      This helped verify basic test case, and components that need implementing
      (even though every part was implemented differently).
      
      Thanks Marko for guidance on simplier InnoDB implementation.
      
      Reviewers: Marko, Monty
      553ef1a7
    • Daniel Black's avatar
      Add TL_FIRST_WRITE in SQL layer for determining R/W · 05848468
      Daniel Black authored
      Use < TL_FIRST_WRITE for determining a READ transaction.
      
      Use TL_FIRST_WRITE as the relative operator replacing TL_WRITE_ALLOW_WRITE
      as the minimium WRITE lock type.
      05848468
    • Marko Mäkelä's avatar
      0ba845a8
    • Marko Mäkelä's avatar
      Merge 10.4 into 10.5 · b4f09aa2
      Marko Mäkelä authored
      b4f09aa2
    • Marko Mäkelä's avatar
      MDEV-22775: Merge 10.4 into 10.5 · 2a781075
      Marko Mäkelä authored
      2a781075
    • Marko Mäkelä's avatar
      Merge 10.4 into 10.5 · 7b48da4d
      Marko Mäkelä authored
      7b48da4d
  2. 07 Apr, 2021 6 commits
    • Monty's avatar
      MDEV-25334 FTWRL/Backup blocks DDL on temporary tables with binlog enabled,... · 4e2ca422
      Monty authored
      MDEV-25334 FTWRL/Backup blocks DDL on temporary tables with binlog enabled, assertion fails in Diagnostics_area::set_error_status
      
      Fixed by adding a MDL_BACKUP_COMMIT lock before altering temporary tables
      whose creation was logged to binary log (in which case the ALTER TABLE
      must also be logged)
      4e2ca422
    • Marko Mäkelä's avatar
      MDEV-25312 Replace fil_space_t::name with fil_space_t::name() · cf552f58
      Marko Mäkelä authored
      A consistency check for fil_space_t::name is causing recovery failures
      in MDEV-25180 (Atomic ALTER TABLE). So, we'd better remove that field
      altogether.
      
      fil_space_t::name was more or less a copy of dict_table_t::name
      (except for some special cases), and it was not being used for
      anything useful.
      
      There used to be a name_hash, but it had been removed already in
      commit a75dbfd7 (MDEV-12266).
      
      We will also remove os_normalize_path(), OS_PATH_SEPARATOR,
      OS_PATH_SEPATOR_ALT. On Microsoft Windows, we will treat \ and /
      roughly in the same way. The intention is that for per-table
      tablespaces, the filenames will always follow the pattern
      prefix/databasename/tablename.ibd. (Any \ in the prefix must not
      be converted.)
      
      ut_basename_noext(): Remove (unused function).
      
      read_link_file(): Replaces RemoteDatafile::read_link_file().
      We will ensure that the last two path component separators are
      forward slashes (converting up to 2 trailing backslashes on
      Microsoft Windows), so that everywhere else we can
      assume that data file names end in "/databasename/tablename.ibd".
      
      Note: On Microsoft Windows, path names that start with \\?\ must
      not contain / as path component separators. Previously, such paths
      did work in the DATA DIRECTORY argument of InnoDB tables.
      
      Reviewed by: Vladislav Vaintroub
      cf552f58
    • Alexander Barkov's avatar
      MDEV-22775 [HY000][1553] Changing name of primary key column with foreign key constraint fails. · 58780b5a
      Alexander Barkov authored
      Problem:
      
      The problem happened because of a conceptual flaw in the server code:
      
      a. The table level CHARSET/COLLATE clause affected all data types,
        including numeric and temporal ones:
      
         CREATE TABLE t1 (a INT) CHARACTER SET utf8 [COLLATE utf8_general_ci];
      
        In the above example, the Column_definition_attributes
        (and then the FRM record) for the column "a" erroneously inherited
        "utf8" as its character set.
      
      b. The "ALTER TABLE t1 CONVERT TO CHARACTER SET csname" statement
         also erroneously affected Column_definition_attributes::charset
         for numeric and temporal data types and wrote "csname" as their
         character set into FRM files.
      
      So now we have arbitrary non-relevant charset ID values for numeric
      and temporal data types in all FRM files in the world :)
      
      The code in the server and the other engines did not seem to be affected
      by this flaw. Only InnoDB inplace ALTER was affected.
      
      Solution:
      
      Fixing the code in the way that only character string data types
      (CHAR,VARCHAR,TEXT,ENUM,SET):
      - inherit the table level CHARSET/COLLATE clause
      - get the charset value according to "CONVERT TO CHARACTER SET csname".
      
      Numeric and temporal data types now always get &my_charset_numeric
      in Column_definition_attributes::charset and always write its ID into FRM files:
      - no matter what the table level CHARSET/COLLATE clause is, and
      - no matter what "CONVERT TO CHARACTER SET" says.
      
      Details:
      
      1. Adding helper classes to pass small parts of HA_CREATE_INFO
         into Type_handler methods:
      
         - Column_derived_attributes - to pass table level CHARSET/COLLATE,
           so columns that do not have explicit CHARSET/COLLATE clauses
           can derive them from the table level, e.g.
      
             CREATE TABLE t1 (a VARCHAR(1), b CHAR(1)) CHARACTER SET utf8;
      
         - Column_bulk_alter_attributes - to pass bulk attribute changes
           generated by the ALTER related code. These bulk changes affect
           multiple columns at the same time:
      
             ALTER TABLE ... CONVERT TO CHARACTER SET csname;
      
         Note, passing the whole HA_CREATE_INFO directly to Type_handler
         would not be good: HA_CREATE_INFO is huge and would need not desired
         dependencies in sql_type.h and sql_type.cc. The Type_handler API should
         use smallest possible data types!
      
      2. Type_handler::Column_definition_prepare_stage1() is now responsible
         to set Column_definition::charset properly, according to the data type,
         for example:
      
         - For string data types, Column_definition_attributes::charset is set from
           the table level CHARSET/COLLATE clause (if not specified explicitly in
           the column definition).
      
         - For numeric and temporal fields, Column_definition_attributes::charset is
           set to &my_charset_numeric, no matter what the table level
           CHARSET/COLLATE says.
      
         - For GEOMETRY, Column_definition_attributes::charset is set to
           &my_charset_bin, no matter what the table level CHARSET/COLLATE says.
      
         Previously this code (setting `charset`) was outside of of
         Column_definition_prepare_stage1(), namely in
         mysql_prepare_create_table(), and was erroneously called for
         all data types.
      
      3. Adding Type_handler::Column_definition_bulk_alter(), to handle
         "ALTER TABLE .. CONVERT TO". Previously this code was inside
         get_sql_field_charset() and was erroneously called for all data types.
      
      4. Removing the Schema_specification_st parameter from
         Type_handler::Column_definition_redefine_stage1().
         Column_definition_attributes::charset is now fully properly initialized by
         Column_definition_prepare_stage1(). So we don't need access to the
         table level CHARSET/COLLATE clause in Column_definition_redefine_stage1()
         any more.
      
      5. Other changes:
         - Removing global function get_sql_field_charset()
      
         - Moving the part of the former get_sql_field_charset(), which was
           responsible to inherit the table level CHARSET/COLLATE clause to
           new methods:
            -- Column_definition_attributes::explicit_or_derived_charset() and
            -- Column_definition::prepare_charset_for_string().
           This code is only needed for string data types.
           Previously it was erroneously called for all data types.
      
         - Moving another part, which was responsible to apply the
           "CONVERT TO" clause, to
           Type_handler_general_purpose_string::Column_definition_bulk_alter().
      
         - Replacing the call for get_sql_field_charset() in sql_partition.cc
           to sql_field->explicit_or_derived_charset() - it is perfectly enough.
           The old code was redundant: get_sql_field_charset() was called from
           sql_partition.cc only when there were no a "CONVERT TO CHARACTER SET"
           clause involved, so its purpose was only to inherit the table
           level CHARSET/COLLATE clause.
      
         - Moving the code handling the BINCMP_FLAG flag from
           mysql_prepare_create_table() to
           Column_definition::prepare_charset_for_string():
           This code is responsible to resolve the BINARY comparison style
           into the corresponding _bin collation, to do the following transparent
           rewrite:
              CREATE TABLE t1 (a VARCHAR(10) BINARY) CHARSET utf8;  ->
              CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_bin);
           This code is only needed for string data types.
           Previously it was erroneously called for all data types.
      
      6. Renaming Table_scope_and_contents_source_pod_st::table_charset
         to alter_table_convert_to_charset, because the only purpose it's used for
         is handlering "ALTER .. CONVERT". The new name is much more self-descriptive.
      58780b5a
    • Daniel Black's avatar
      unittest: my_getopt-t errors on -ve ul{l,} · c2a63ac5
      Daniel Black authored
      c2a63ac5
    • Daniel Black's avatar
      46852b3b
    • Daniel Black's avatar
      MDEV-19508: SI_KERNEL is not on all implementations · f69c1c9d
      Daniel Black authored
      SI_USER is, however in FreeBSD there are a couple of non-kernel
      user signal infomations above SI_KERNEL.
      
      Put a fallback just in case there is nothing available.
      f69c1c9d
  3. 06 Apr, 2021 2 commits
    • Jan Lindström's avatar
      MDEV-21402 : sql_safe_updates breaks Galera 4 · 5b71e042
      Jan Lindström authored
      Added handling for sql_safe_updated i.e. we disable it while
      we do wsrep_schema operations.
      5b71e042
    • Monty's avatar
      MDEV-17913 Encrypted transactional Aria tables remain corrupt after crash... · 81258f14
      Monty authored
      MDEV-17913 Encrypted transactional Aria tables remain corrupt after crash recovery, automatic repairment does not work
      
      This was because of a wrong test in encryption code that wrote random
      numbers over the LSN for pages for transactional Aria tables during repair.
      The effect was that after an ALTER TABLE ENABLE KEYS of a encrypted
      recovery of the tables would not work.
      
      Fixed by changing testing of !share->now_transactional to
      !share->base.born_transactional.
      
      Other things:
      - Extended Aria check_table() to check for wrong (= too big) LSN numbers.
      - If check_table() failed just because of wrong LSN or TRN numbers,
        a following repair table will just do a zerofill which is much faster.
      - Limit number of LSN errors in one check table to MAX_LSN_ERROR (10).
      - Removed old obsolete test of 'if (error_count & 2)'. Changed error_count
        and warning_count from bits to numbers of errors/warnings as this is
        more useful.
      81258f14
  4. 05 Apr, 2021 2 commits
    • mkaruza's avatar
      MDEV-24956: ALTER TABLE not replicated with Galera in MariaDB 10.5.9 · f8488370
      mkaruza authored
      `WSREP_CLIENT` is used as condition for starting ALTER/OPTIMIZE/REPAIR TOI.
      Using this condition async replicated affected DDL's will not be replicated.
      Fixed by removing this condition.
      Reviewed-by: default avatarJan Lindström <jan.lindstrom@mariadb.com>
      f8488370
    • Daniele Sciascia's avatar
      MDEV-25226 Assertion when wsrep_on set OFF with SR transaction · 915983e1
      Daniele Sciascia authored
      This patch makes the following changes around variable wsrep_on:
      
      1) Variable wsrep_on can no longer be updated from a session that has
      an active transaction running. The original behavior allowed cases
      like this:
      
           BEGIN;
           INSERT INTO t1 VALUES (1);
           SET SESSION wsrep_on = OFF;
           INSERT INTO t1 VALUES (2);
           COMMIT;
      
      With regular transactions this would result in no replication
      events (not even value 1). With streaming replication it would be
      unnecessarily complex to achieve the same behavior. In the above
      example, it would be possible for value 1 to be already replicated if
      it happened to fill a separate fragment, while value 2 wouldn't.
      
      2) Global variable wsrep_on no longer affects current sessions, only
      subsequent ones. This is to avoid a similar case to the above, just
      using just by using global wsrep_on instead session wsrep_on:
      
            --connection conn_1
            BEGIN;
            INSERT INTO t1 VALUES(1);
      
            --connection conn_2
            SET GLOBAL wsrep_on = OFF;
      
            --connection conn_1
            INSERT INTO t1 VALUES(2);
            COMMIT;
      
      The above example results in the transaction to be replicated, as
      global wsrep_on will only affect the session wsrep_on of new
      connections.
      Reviewed-by: default avatarJan Lindström <jan.lindstrom@mariadb.com>
      915983e1
  5. 02 Apr, 2021 1 commit
    • Monty's avatar
      MDEV-17913 Encrypted transactional Aria tables remain corrupt after crash... · 880baedc
      Monty authored
      MDEV-17913 Encrypted transactional Aria tables remain corrupt after crash recovery, automatic repairment does not work
      
      This was because of a wrong test in encryption code that wrote random
      numbers over the LSN for pages for transactional Aria tables during repair.
      The effect was that after an ALTER TABLE ENABLE KEYS of a encrypted
      recovery of the tables would not work.
      
      The test cases will be pushed into 10.5 as it requires of several changes
      to check table that safer not to backport.
      880baedc
  6. 01 Apr, 2021 3 commits
  7. 31 Mar, 2021 10 commits
  8. 30 Mar, 2021 2 commits