1. 28 Oct, 2020 2 commits
  2. 27 Oct, 2020 1 commit
    • Dmitry Shulga's avatar
      MDEV-22805: SIGSEGV in check_fields on UPDATE · 97b10b7f
      Dmitry Shulga authored
      For debug build of MariaDB server running of the following test case
      will hit the assert `thd->lex->sql_command == SQLCOM_UPDATE' in the function
      check_fields() on attempt to execute the UPDATE statement.
      
        CREATE TABLE t1 (a INT);
        UPDATE t1 FOR PORTION OF APPTIME FROM (SELECT 1 FROM t1) TO 2 SET a = 1;
      
      Stack trace to the fired assert statement
        DBUG_ASSERT(thd->lex->sql_command == SQLCOM_UPDATE)
      listed below:
        mysql_execute_command() ->
          mysql_multi_update_prepare() -->
            Multiupdate_prelocking_strategy::handle_end() -->
              check_fiels()
      
      It's worth to note that this stack trace looks like a multi update
      statement is being executed. The fired assert is checked inside the
      function check_fields() in case table->has_period() returns the value
      true that in turns happens when temporal period specified in the UPDATE
      statement. Condition specified in the DEBUG_ASSERT statement returns
      the false value since the data member thd->lex->sql_command have the
      value SQLCOM_UPDATE_MULTI. So, the main question is why a program control
      flow go to the path prescribed for handling MULTI update statement
      despite of the fact that the ordinary UPDATE statement being executed.
      
      The answer is a way that SQL grammar rules written.
      
      When the statement
        UPDATE t1 FOR PORTION OF APPTIME FROM (SELECT 1 FROM t1) TO 2 SET a = 1;
      being parsed an action for the rule 'table_primary_ident' (part of this action
      is listed below to simplify description) is  invoked to handle the table
      name 't1' specified in the clause 'SELECT 1 FROM t1'.
      
      table_primary_ident:
        table_ident opt_use_partition opt_for_system_time_clause
        opt_table_alias_clause opt_key_definition
        {
          SELECT_LEX *sel= Select;
          sel->table_join_options= 0;
          if (!($$= Select->add_table_to_list(thd, $1, $4,
      
      This action calls the method st_select_lex::add_table_to_list()
      to add the table name 't1' to the list of tables being used by the statement.
      
      Later, an action for the following grammar rule
      update_table_list:
        table_ident opt_use_partition for_portion_of_time_clause
        opt_table_alias_clause opt_key_definition
        {
          SELECT_LEX *sel= Select;
          sel->table_join_options= 0;
          if (!($$= Select->add_table_to_list(thd, $1, $4,
      
      is invoked to handle the clause 't1 FOR PORTION OF APPTIME FROM ... TO 2'.
      This action also calls the method st_select_lex::add_table_to_list()
      to add the table name 't1' to the list of tables being used by the statement.
      
      In result the table name 't1' contained twice in this list.
      
      Presence of duplicate names for the table 't1' in a list of table used by
      a statement leads to the fact that the function unique_table() called
      from the function mysql_update() returns the value true that forces
      implementation of the function mysql_update() to return the value 2 as
      a signal to fall through the case boundary of the switch statement placed
      in the function mysql_execute_statement() and start handling of the case
      for sql_command SQLCOM_UPDATE_MULTI. The compound statement block for the
      case SQLCOM_UPDATE_MULTI invokes the function mysql_multi_update_prepare()
      that executes the statement
        set thd->lex->sql_command= SQLCOM_UPDATE_MULTI;
      and after that calls the method
        Multiupdate_prelocking_strategy::handle_end(). Finally, this method
      invokes the check_field() function and assert is fired.
      
      The above analysis shows that update for a table that simultaneously specified
      both as a destination table of UPDATE statement and as a table taking part in
      subquery is actually treated by MariaDB server as multi-update statement.
      Taking into account that multi-update statement for temporal period
      table is not supported yet by MariaDB, correct way to fix the bug is to return
      the error ER_NOT_SUPPORTED_YET for this case.
      97b10b7f
  3. 26 Oct, 2020 2 commits
    • Eugene Kosov's avatar
      MDEV-23356 InnoDB: Failing assertion: field->col->mtype == type, crash or ASAN... · 31cde275
      Eugene Kosov authored
      MDEV-23356 InnoDB: Failing assertion: field->col->mtype == type, crash or ASAN failures in row_sel_convert_mysql_key_to_innobase, InnoDB indexes are inconsistent after INDEX changes
      
      innobase_rename_indexes_cache(): fix corruption of index cache. Index ids
      help distinguish indexes when their names clash.
      
      innobase_rename_indexes_cache(): fix corruption of index statistics table.
      Use unique temporary names to avoid names clashing.
      
      Reviewed by: Marko Mäkelä
      31cde275
    • Daniel Black's avatar
      MDEV-23539: aws key plugin - fails to build · 045671d4
      Daniel Black authored
      Recent gcc/clang versions failed to compile the existing code.
      
      Updating a later upstream SDK version was simple and required
      only implementing a flush method. This was left blank as
      there was no strong requirement to keep the error log
      atomic or durable.
      
      Reviewed-by: wlad@mariadb.com
      
      The upstream SDK version added a flush method which was simple
      to complete.
      045671d4
  4. 23 Oct, 2020 1 commit
  5. 22 Oct, 2020 7 commits
    • Aleksey Midenkov's avatar
      MDEV-23672: incorrect v_indexes access fix · 54c521ca
      Aleksey Midenkov authored
      v_indexes was wrongly copied from the source table.
      54c521ca
    • Marko Mäkelä's avatar
      9868253b
    • Marko Mäkelä's avatar
      After-merge fix to wsrep.variables · 45e10d46
      Marko Mäkelä authored
      We must make the test depend on a debug version of Galera.
      45e10d46
    • Marko Mäkelä's avatar
      Merge 10.3 into 10.4 · 46957a6a
      Marko Mäkelä authored
      46957a6a
    • Marko Mäkelä's avatar
      MDEV-23672: Partly revert an incorrect fix · 1619ae89
      Marko Mäkelä authored
      In commit 7eda5561 we removed a
      valid debug assertion.
      
      AddressSanitizer would trip when writing undo log for an INSERT
      operation that follows the problematic ALTER TABLE because the
      v_indexes would refer to an index object that was freed during
      the execution of ALTER TABLE.
      
      The operation to remove NOT NULL attribute from a column should
      lead into any affected indexes to be dropped and re-created.
      But, the SQL layer set the ha_alter_info->handler_flags to
      HA_INPLACE_ADD_UNIQUE_INDEX_NO_WRITE|ALTER_COLUMN_NULLABLE
      (that is, InnoDB was asked to add an index and change the column,
      but not to drop the index that depended on the column).
      
      Let us restore the debug assertion that catches this problem
      outside AddressSanitizer, and 'defuse' the offending ALTER TABLE
      statement in the test until something has been fixed in the SQL layer.
      1619ae89
    • Marko Mäkelä's avatar
      Merge 10.2 into 10.3 · e3d692aa
      Marko Mäkelä authored
      e3d692aa
    • Dmitry Shulga's avatar
      MDEV-23935: Fix warnings generated during compilation of... · 77c00799
      Dmitry Shulga authored
      MDEV-23935: Fix warnings generated during compilation of plugin/auth_pam/testing/pam_mariadb_mtr.c on MacOS
      
      During build server 10.4 on MacOS warnings like the following one
      are generated on compiling the file plugin/auth_pam/testing/pam_mariadb_mtr.c
      
      server-10.4/plugin/auth_pam/testing/pam_mariadb_mtr.c:25:22: error:
      initializing 'char *' with an expression of type 'const char [23]'
      discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
      { PAM_TEXT_INFO, "Challenge input first." }
      
      The reason of the warnings is that the data member pam_message::msg is declared
      as 'char *' on MacOS but initializer of the data member is 'const char *'.
      
      To eliminate warnings the compiler option
        -Wno-incompatible-pointer-types-discards-qualifiers
      has been added to the compiler flags used for compiling the file
      pam_mariadb_mtr.c.
      77c00799
  6. 21 Oct, 2020 8 commits
    • Rinat Ibragimov's avatar
      MDEV-20945: BACKUP UNLOCK + FTWRL assertion failure · 709ba7dc
      Rinat Ibragimov authored
      MDEV-20945: BACKUP UNLOCK + FTWRL assertion failure | SIGSEGV in I_P_List
      from MDL_context::release_lock on INSERT w/ BACKUP LOCK (on optimized
      builds) | Assertion `ticket->m_duration == MDL_EXPLICIT' failed
      
      BACKUP LOCK behavior is modified so it won't be used wrong:
      - BACKUP LOCK should commit any active transactions.
      - BACKUP LOCK should not be allowed in stored procedures.
      - When BACKUP LOCK is active, don't allow any DDL's for that connection.
      - FTWRL is forbidden on the same connection while BACKUP LOCK is active.
      
      Reviewed-by: monty@mariadb.com
      709ba7dc
    • Kentoku SHIBA's avatar
      MDEV-20100 MariaDB 13.3.9 Crash "[ERROR] mysqld got signal 11 ;" · ac8d2057
      Kentoku SHIBA authored
      Some functions on ha_partition call functions on all partitions, but handler->reset() is only called that pruned by m_partitions_to_reset. So Spider didn't clear pointer on unpruned partitions, if the unpruned partitions are used by next query, Spider reference the pointer that is already freed.
      ac8d2057
    • Daniele Sciascia's avatar
      MDEV-23081 Stray XA transactions at startup, with wsrep_on=OFF · fdf87973
      Daniele Sciascia authored
      Change xarecover_handlerton so that transaction with WSREP prefixed
      xids are rolled back when Galera is disabled.
      Reviewd-by: default avatarJan Lindström <jan.lindstrom@mariadb.com>
      fdf87973
    • Marko Mäkelä's avatar
      Merge 10.1 into 10.2 · 620ea816
      Marko Mäkelä authored
      620ea816
    • Dmitry Shulga's avatar
      MDEV-23925: Fixed warnings generated during compilation of mysys_ssl/openssl.c on MacOS · a1b6691f
      Dmitry Shulga authored
      Compiler warnings like one listed below are generated during server build on MacOS:
      In file included from server-10.2-MDEV-23564/mysys_ssl/openssl.c:33:
      In file included from /usr/local/include/openssl/evp.h:16:
      In file included from /usr/local/include/openssl/bio.h:20:
      /usr/local/include/openssl/crypto.h:206:10: warning: 'CRYPTO_cleanup_all_ex_data' macro redefined [-Wmacro-redefined]
                 ^
        /mariadb/server-10.2-MDEV-23564/include/ssl_compat.h:46:9: note: previous definition is here
                ^
      
      In case MariaDB serer is build with -DCMAKE_BUILD_TYPE=Debug it results in
      build error.
      
      The reason of compiler warnings is that header file <ssl_compat.h>
      included before the openssl system header files. File ssl_compat.h
      contains some macros with the same names as SSL API functions declared
      in the openssl system header files. It resulted in duplicate
      symbols that produces compiler warnings.
      
      To fix the issue the header file ssl_compat.h should be included
      after a line where openssl system header is included.
      a1b6691f
    • Daniel Black's avatar
      MDEV-23887: check_linker_flags correct for old cmake compatibility · b4c225ac
      Daniel Black authored
      It was only from CMake-3.14.0 that CMAKE_REQUIRED_LINK_OPTIONS
      was used in CHECK_CXX_SOURCE_COMPILES. Without this, it could be
      the case (as was on OSX) that a flag was never checked in
      CHECK_CXX_SOURCE_COMPILES, the CHECK successfully passed, but
      failed at link time.
      
      As such we use CMAKE_REQUIRED_LIBRARIES to include the flags to check
      as its compatible enough with the cmake versions for non-Windows
      compilers/linkers.
      
      Tested on x86_64 with:
      * 3.11.4
      * 3.17.4
      
      Corrects: 7473e184
      
      In the future:
      * cmake >=3.14.0 can use CMAKE_REQUIRED_LINK_OPTIONS
      * cmake >=3.18.0 can use CHECK_LINKER_FLAG (with policy CMP0057 NEW)
      (e.g: commit c7ac2deff9a2c965887dcc67cbf2a3a7c3e0123d)
      
      CMAKE_REQUIRED_LIBRARIES suggested by serg@mariadb.com
      
      Reviewed-by: anel@mariadb.org
      b4c225ac
    • Marko Mäkelä's avatar
      InnoDB 5.6.50 · 65b7f72b
      Marko Mäkelä authored
      The only applicable InnoDB change to MariaDB that was made
      between MySQL 5.6.49 and MySQL 5.6.50 is MDEV-23999.
      65b7f72b
    • Marko Mäkelä's avatar
      MDEV-23999 Potential stack overflow in InnoDB fulltext search · c7552969
      Marko Mäkelä authored
      fts_query_t::nested_sub_exp: Keep track of nested
      fts_ast_visit_sub_exp() calls.
      
      fts_ast_visit_sub_exp(): Return DB_OUT_OF_MEMORY if the
      maximum recursion depth is exceeded.
      
      This is motivated by a change in MySQL 5.6.50:
      mysql/mysql-server@e2a46b4834a0030e5380d45789772cb6beab6e92
      Bug #29929684 USING MANY NESTED ARGUMENTS WITH BOOLEAN FTS CAN LEAD
      TO TERMINATE SERVER
      c7552969
  7. 20 Oct, 2020 15 commits
    • Marko Mäkelä's avatar
      Revert MDEV-23484 Rollback unnecessarily acquires dict_operation_lock · 0049d5b5
      Marko Mäkelä authored
      In row_undo_ins_remove_clust_rec() and similar places,
      an assertion !node->trx->dict_operation_lock_mode could fail,
      because an online ALTER is not allowed to run at the same time
      while DDL operations on the table are being rolled back.
      
      This race condition would be fixed by always acquiring an InnoDB
      table lock in ha_innobase::prepare_inplace_alter_table() or
      prepare_inplace_alter_table_dict(), or by ensuring that recovered
      transactions are protected by MDL that would block concurrent DDL
      until the rollback has been completed.
      
      This reverts commit 15093639
      and commit 22c4a751.
      0049d5b5
    • Marko Mäkelä's avatar
      MDEV-23996 Race conditions in SHOW ENGINE INNODB MUTEX · 832a6acb
      Marko Mäkelä authored
      The function innodb_show_mutex_status() is the only ultimate caller of
      LatchCounter::iterate() via MutexMonitor::iterate(). Because the call
      is not protected by LatchCounter::m_mutex, any mutex_create() or
      mutex_free() that is invoked concurrently during the execution, bad
      things such as a crash could happen.
      
      The most likely way for this to happen is buffer pool resizing,
      which could cause buf_block_t::mutex (which existed before MDEV-15053)
      to be created or freed. We could also register InnoDB mutexes in
      TrxFactory::init() if trx_pools needs to grow.
      
      The view INFORMATION_SCHEMA.INNODB_MUTEXES is not affected, because it
      only displays information about rw-locks, not mutexes.
      
      This commit intentionally touches also MutexMonitor::iterate()
      and the only code that interfaces with LatchCounter::iterate()
      to make it clearer for future readers that the scattered code
      that is obfuscated by templates belongs together.
      
      This is based on
      mysql/mysql-server@273a93396f49c7e0a8b07b260128d9a990c2b154
      832a6acb
    • Anel Husakovic's avatar
      Update mtr help · d1af93a5
      Anel Husakovic authored
      - Based on patch: d6a983351c5a454bd0cb113852f
      - Update combination example for 10.2 (commit 2a3fe45d added change
      for 10.3+)
      ```
      ==============================================================================
      
      TEST                                      RESULT   TIME (ms) or COMMENT
      --------------------------------------------------------------------------
      
      worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019
      rpl.rpl_invoked_features 'innodb,mix'    [ pass ]   1677
      rpl.rpl_invoked_features 'innodb,row'    [ pass ]   3516
      rpl.rpl_invoked_features 'innodb,stmt'   [ pass ]   1609
      --------------------------------------------------------------------------
      ```
      - `gdb` option will be added during the merge
      d1af93a5
    • Anel Husakovic's avatar
      Updated mtr help · 0627c4ae
      Anel Husakovic authored
      - Updated combination example to use `innodb_plugin`
      ```
      $ ./mysql-test/mtr rpl.rpl_invoked_features # no rpl.rpl_invoked_features,mix,xtradb_plugin
      
      worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019
      rpl.rpl_invoked_features 'innodb_plugin,mix' [ pass ]    904
      rpl.rpl_invoked_features 'mix,xtradb'    [ pass ]   1707
      rpl.rpl_invoked_features 'innodb_plugin,row' [ pass ]    927
      rpl.rpl_invoked_features 'row,xtradb'    [ pass ]    828
      rpl.rpl_invoked_features 'innodb_plugin,stmt' [ pass ]    855
      rpl.rpl_invoked_features 'stmt,xtradb'   [ pass ]    952
      --------------------------------------------------------------------------
      ```
      - `gdb` option can take optional gdb arguments (good documentation in
      KB)
      0627c4ae
    • Kentoku SHIBA's avatar
      MDEV-20100 MariaDB 13.3.9 Crash "[ERROR] mysqld got signal 11 ;" · 88d22f0e
      Kentoku SHIBA authored
      Some functions on ha_partition call functions on all partitions, but handler->reset() is only called that pruned by m_partitions_to_reset. So Spider didn't clear pointer on unpruned partitions, if the unpruned partitions are used by next query, Spider reference the pointer that is already freed.
      88d22f0e
    • Julius Goryavsky's avatar
      MDEV-21951: mariabackup SST fail if data-directory have lost+found directory · 888010d9
      Julius Goryavsky authored
      To fix this, it is necessary to add an option to exclude the
      database with the name "lost+found" from processing (the database
      name will be checked by the check_if_skip_database_by_path() or
      by the check_if_skip_database() function, and as a result
      "lost+found" will be skipped).
      
      In addition, it is necessary to slightly modify the verification
      logic in the check_if_skip_database() function.
      
      Also added a new test galera_sst_mariabackup_lost_found.test
      888010d9
    • Oleksandr Byelkin's avatar
      MDEV-23327: followup · 692a44b3
      Oleksandr Byelkin authored
      fix an error with locked taböes
      692a44b3
    • Aleksey Midenkov's avatar
      MDEV-23672 Assertion `v.v_indexes.empty()' failed in dict_table_t::instant_column · 7eda5561
      Aleksey Midenkov authored
      dict_v_idx_t node was shared between two dict_v_col_t objects because
      of wrong object copy. Replace memory plain copy with copy constructor.
      
      Tha patch also removes n_v_indexes property and improves "page full"
      judgements for trx_undo_log_v_idx().
      7eda5561
    • Aleksey Midenkov's avatar
      MDEV-23968 CREATE TEMPORARY TABLE .. LIKE (system versioned table) returns... · 9b46d8e5
      Aleksey Midenkov authored
      MDEV-23968 CREATE TEMPORARY TABLE .. LIKE (system versioned table) returns error if unique index is defined in the table
      
      - Remove row_start/row_end from keys in fix_create_like();
      
      - Disable manual adding of implicit row_start/row_end to indexes on
        CREATE TABLE. INVISIBLE_SYSTEM fields are unoperable by user;
      
      - Fix memory leak on allocation of Key_part_spec.
      9b46d8e5
    • Aleksey Midenkov's avatar
      MDEV-23779 Error upon querying the view, that selecting from versioned table with partitions · ddea8f6a
      Aleksey Midenkov authored
      PARTITION clause in SELECT means query is non-versioned (see
      WITH_PARTITION_STORAGE_ENGINE in vers_setup_conds()).
      
      vers_setup_conds() expands such query to SYSTEM_TIME_ALL which is then
      added to VIEW specification. When VIEW is queried both clauses
      PARTITION and FOR SYSTEM_TIME ALL lead to ER_VERS_QUERY_IN_PARTITION
      (same place WITH_PARTITION_STORAGE_ENGINE).
      
      Fix removes FOR SYSTEM_TIME ALL from VIEW by accessing original
      SYSTEM_TIME clause: the one specified in parser. As a side-effect
      EXPLAIN SELECT displays SYSTEM_TIME specified in SELECT which is
      user-friendly.
      ddea8f6a
    • Aleksey Midenkov's avatar
      MDEV-23799 CREATE .. SELECT wrong result on join versioned table · a3c379ea
      Aleksey Midenkov authored
      For join to work correctly versioning condition must be added to table
      on_expr. Without that JOIN_CACHE gets expression (1)
      
        trigcond(xtitle.row_end = TIMESTAMP'2038-01-19 06:14:07.999999') and
        trigcond(xtitle.elementId = x.`id` and xtitle.pkey = 'title')
      
      instead of (2)
      
        trigcond(xtitle.elementId = x.`id` and xtitle.pkey = 'title')
      
      for join_null_complements(). It is NULL-row of xtitle for
      complementing the join and the above comparisons of course FALSE, but
      trigcond (Item_func_trig_cond) makes them TRUE via its trig_var
      property which is bound to some boolean properties of JOIN_TAB.
      
      Expression (2) evaluated to TRUE because its trig_var is bound to
      first_inner_tab->not_null_compl. The expression (1) does not evaluate
      correctly because row_end comparison's trig_var is bound to
      first_inner->found earlier. As a result JOIN_CACHE::check_match()
      skipped the row for join_null_complements().
      
      When we add versioning condition to table's on_expr the optimizer in
      make_join_select() distributes conditions differently. tmp_cond
      inherits on_expr value and in Good case it is full expression
      
      xgender.elementId = x.`id` and xgender.pkey = 'gender' and
      xgender.row_end = TIMESTAMP'2038-01-19 06:14:07.999999'
      
      while in Bad case it is only
      
      xgender.elementId = x.`id` and xgender.pkey = 'gender'.
      
      Later in Good row_end condition is optimized out and we get one
      trigcond in form of (2).
      a3c379ea
    • Thirunarayanan Balathandayuthapani's avatar
      MDEV-23072 Diskspace not reused for Blob in data file · 7b7ea331
      Thirunarayanan Balathandayuthapani authored
      - This issue is caused by commit a4948daf.
      Purge doesn't free the externally stored page associated with the
      last record of the root page. In that case, purge thread does empty
      the root page and leads to more orphaned blob page in the tablespace.
      Purge thread should free the blob even for the last record of the
      root page.
      
      Reviewed-by: Marko Mäkelä
      7b7ea331
    • Rucha Deodhar's avatar
      MDEV-23445: LIMIT ROWS EXAMINED throws error in Debug build only · 00bf4882
      Rucha Deodhar authored
      Analysis: When we reach the maximum limit to examine rows killed_state is set
      as ABORT. But this isn't an actual error and we still return TRUE. This
      eventually sets error as UNKNOWN ERROR.
      Fix: Check if need to stop execution by checking the killed state. If we have
      to abort it, return false because this isn't an actual error.
      00bf4882
    • Rucha Deodhar's avatar
      MDEV-5628: Assertion `! is_set()' or `!is_set() || (m_status == DA_OK_BULK && · 9fca6645
      Rucha Deodhar authored
      is_bulk_op())' fails on UPDATE on a partitioned table with subquery
      (MySQL:71630)
      
      Analysis and fix: Error is not checked. So correct error state is not returned.
      Fix: Check for error and return the error state.
      9fca6645
    • Rucha Deodhar's avatar
      MDEV-17729: Assertion `! is_set() || m_can_overwrite_status' failed in · d36cd5f0
      Rucha Deodhar authored
      Diagnostics_area::set_error_status
      
      Analysis: When strict mode is enabled, all warnings are converted to errors
      including those which do not occur because of bad data.
      Fix: Query should not be aborted when we have warning because limit to
      examine rows was reached because it doesn't happen due to bad data.
      So thd->abort_on_warning should be false.
      d36cd5f0
  8. 19 Oct, 2020 4 commits