1. 21 Apr, 2021 2 commits
  2. 20 Apr, 2021 4 commits
    • Marko Mäkelä's avatar
      922e676b
    • Aditya A's avatar
      Bug #32032897 DEADLOCKING WAIT GRAPH ON BUSY SERVER · 72432ec7
      Aditya A authored
      PROBLEM
      -------
      
      1. The customer had presented a stack which had many threads waiting on
         multiple mutexes like LOCK_Status, srv_innodb_monitor_mutex,  ibuf_mutex etc.
      2. The root cause was that the AHI latch was held in S (shared) mode by the a thread which was
         doing a truncate of a large table .
      3. There was another thread which was trying to acquire the AHI latch in X (exclusive) mode
      4. With our lock implementation any thread requesting a X lock ,blocks rest of the threads
         requesting S(shared) locks,this caused many threads to wait for this shared lock.
      5. The main reason why we hold the latches in truncate is to avoid disabling of AHI
         during truncate
      
      FIX
      72432ec7
    • Monty's avatar
      Fix all warnings given by UBSAN · 031f1171
      Monty authored
      The easiest way to compile and test the server with UBSAN is to run:
      ./BUILD/compile-pentium64-ubsan
      and then run mysql-test-run.
      After this commit, one should be able to run this without any UBSAN
      warnings. There is still a few compiler warnings that should be fixed
      at some point, but these do not expose any real bugs.
      
      The 'special' cases where we disable, suppress or circumvent UBSAN are:
      - ref10 source (as here we intentionally do some shifts that UBSAN
        complains about.
      - x86 version of optimized int#korr() methods. UBSAN do not like unaligned
        memory access of integers.  Fixed by using byte_order_generic.h when
        compiling with UBSAN
      - We use smaller thread stack with ASAN and UBSAN, which forced me to
        disable a few tests that prints the thread stack size.
      - Verifying class types does not work for shared libraries. I added
        suppression in mysql-test-run.pl for this case.
      - Added '#ifdef WITH_UBSAN' when using integer arithmetic where it is
        safe to have overflows (two cases, in item_func.cc).
      
      Things fixed:
      - Don't left shift signed values
        (byte_order_generic.h, mysqltest.c, item_sum.cc and many more)
      - Don't assign not non existing values to enum variables.
      - Ensure that bool and enum values are properly initialized in
        constructors.  This was needed as UBSAN checks that these types has
        correct values when one copies an object.
        (gcalc_tools.h, ha_partition.cc, item_sum.cc, partition_element.h ...)
      - Ensure we do not called handler functions on unallocated objects or
        deleted objects.
        (events.cc, sql_acl.cc).
      - Fixed bugs in Item_sp::Item_sp() where we did not call constructor
        on Query_arena object.
      - Fixed several cast of objects to an incompatible class!
        (Item.cc, Item_buff.cc, item_timefunc.cc, opt_subselect.cc, sql_acl.cc,
         sql_select.cc ...)
      - Ensure we do not do integer arithmetic that causes over or underflows.
        This includes also ++ and -- of integers.
        (Item_func.cc, Item_strfunc.cc, item_timefunc.cc, sql_base.cc ...)
      - Added JSON_VALUE_UNITIALIZED to json_value_types and ensure that
        value_type is initialized to this instead of to -1, which is not a valid
        enum value for json_value_types.
      - Ensure we do not call memcpy() when second argument could be null.
      - Fixed that Item_func_str::make_empty_result() creates an empty string
        instead of a null string (safer as it ensures we do not do arithmetic
        on null strings).
      
      Other things:
      
      - Changed struct st_position to an OBJECT and added an initialization
        function to it to ensure that we do not copy or use uninitialized
        members. The change to a class was also motived that we used "struct
        st_position" and POSITION randomly trough the code which was
        confusing.
      - Notably big rewrite in sql_acl.cc to avoid using deleted objects.
      - Changed in sql_partition to use '^' instead of '-'. This is safe as
        the operator is either 0 or 0x8000000000000000ULL.
      - Added check for select_nr < INT_MAX in JOIN::build_explain() to
        avoid bug when get_select() could return NULL.
      - Reordered elements in POSITION for better alignment.
      - Changed sql_test.cc::print_plan() to use pointers instead of objects.
      - Fixed bug in find_set() where could could execute '1 << -1'.
      - Added variable have_sanitizer, used by mtr.  (This variable was before
        only in 10.5 and up).  It can now have one of two values:
        ASAN or UBSAN.
      - Moved ~Archive_share() from ha_archive.cc to ha_archive.h and marked
        it virtual. This was an effort to get UBSAN to work with loaded storage
        engines. I kept the change as the new place is better.
      - Added in CONNECT engine COLBLK::SetName(), to get around a wrong cast
        in tabutil.cpp.
      - Added HAVE_REPLICATION around usage of rgi_slave, to get embedded
        server to compile with UBSAN. (Patch from Marko).
      - Added #ifdef for powerpc64 to avoid a bug in old gcc versions related
        to integer arithmetic.
      
      Changes that should not be needed but had to be done to suppress warnings
      from UBSAN:
      
      - Added static_cast<<uint16_t>> around shift to get rid of a LOT of
        compiler warnings when using UBSAN.
      - Had to change some '/' of 2 base integers to shift to get rid of
        some compile time warnings.
      
      Reviewed by:
      - Json changes: Alexey Botchkov
      - Charset changes in ctype-uca.c: Alexander Barkov
      - InnoDB changes & Embedded server: Marko Mäkelä
      - sql_acl.cc changes: Vicențiu Ciorbaru
      - build_explain() changes: Sergey Petrunia
      031f1171
    • Daniele Sciascia's avatar
      More fixes to variable wsrep_on · eb4123ee
      Daniele Sciascia authored
      * Disallow setting wsrep_on = 1 if wsrep_provider is unset. Also, move
        wsrep_on_basic from sys_vars to wsrep suite: this test now requires
        to run with wsrep_provider set
      * Disallow setting @@session.wsrep_on = 1 when @@global.wsrep_on = 0
      * Handle the case where a new connection turns @@global.wsrep_on from
        off to on. In this case we would miss a call to wsrep_open, causing
        unexpected states in wsrep::client_state (causing assertions).
      * Disable wsrep.MDEV-22443 because it is no longer possible to enable
        wsrep_on, if server is started with wsrep_provider='none'
      Reviewed-by: default avatarJan Lindström <jan.lindstrom@mariadb.com>
      eb4123ee
  3. 19 Apr, 2021 2 commits
  4. 17 Apr, 2021 2 commits
    • Igor Babaev's avatar
      MDEV-25362 Incorrect name resolution for subqueries in ON expressions · 635b5ce3
      Igor Babaev authored
      This patch sets the proper name resolution context for outer references
      used in a subquery from an ON clause. Usually this context is more narrow
      than the name resolution context of the parent select that were used before
      this fix.
      This fix revealed another problem that concerned ON expressions used in
      from clauses of specifications of derived tables / views / CTEs. The name
      resolution outer context for such ON expression must be set to NULL to
      prevent name resolution beyond the derived table where it is used.
      The solution to resolve this problem applied in sql_derived.cc was provided
      by Sergei Petrunia <sergey@mariadb.com>.
      
      The change in sql_parse.cc is not good for 10.4+. A corresponding diff for
      10.4+ will be provided in JIRA entry for this bug.
      
      Approved by Oleksandr Byelkin <sanja@mariadb.com>
      635b5ce3
    • Rainer Orth's avatar
      MDEV-15064: IO_CACHE mysys read_pos, not libmaria rc_pos · 73bf6246
      Rainer Orth authored
      It seems some overly tolerant compilers (gcc) allow the structure
      of IO_CACHE that is defined differently in libmaria to have
      members equalivance to the iocache in mysys.
      
      More strict Solaris compilers recognise that rc_pos really
      isn't a structure member and won't compile.
      73bf6246
  5. 16 Apr, 2021 1 commit
  6. 15 Apr, 2021 6 commits
  7. 14 Apr, 2021 8 commits
  8. 13 Apr, 2021 5 commits
    • Sergei Golubchik's avatar
      -DMYSQL_MAINTAINER_MODE=NO · 55a7682a
      Sergei Golubchik authored
      also add =WARN as an alias for =OFF
      and clarify the help text
      55a7682a
    • Marko Mäkelä's avatar
      MDEV-24620 ASAN heap-buffer-overflow in btr_pcur_restore_position() · b8c8692f
      Marko Mäkelä authored
      Between btr_pcur_store_position() and btr_pcur_restore_position()
      it is possible that purge empties a table and enlarges
      index->n_core_fields and index->n_core_null_bytes.
      Therefore, we must cache index->n_core_fields in
      btr_pcur_t::old_n_core_fields so that btr_pcur_t::old_rec can be
      parsed correctly.
      
      Unfortunately, this is a huge change, because we will replace
      "bool leaf" parameters with "ulint n_core"
      (passing index->n_core_fields, or 0 for non-leaf pages).
      For special cases where we know that index->is_instant() cannot hold,
      we may also pass index->n_fields.
      b8c8692f
    • Marko Mäkelä's avatar
      Merge 10.2 into 10.3 · 6e6318b2
      Marko Mäkelä authored
      6e6318b2
    • Thirunarayanan Balathandayuthapani's avatar
      MDEV-24971 InnoDB access freed virtual column after rollback of secondary index · e262eb16
      Thirunarayanan Balathandayuthapani authored
      - Fixing post-fix failure. In clean_new_vcol_index(), InnoDB has the wrong
      offset to store the virtual column
      e262eb16
    • Dmitry Shulga's avatar
      MDEV-25197: The statement set password=password('') executed in PS mode fails... · 61f84bba
      Dmitry Shulga authored
      MDEV-25197: The statement set password=password('') executed in PS mode fails in case it is run by a user with expired password
      
      A user connected to a server with an expired password
      can't change password with the statement "SET password=..."
      if this statement is run in PS mode. In mentioned use case a user
      gets the error ER_MUST_CHANGE_PASSWORD on attempt to run
      the statement  PREPARE stmt FOR "SET password=...";
      
      The reason of failure to reset password by a locked user using the
      statement PREPARE stmt FOR "SET password=..." is that PS-related
      statements are not listed among the commands allowed for execution
      by a user with expired password. However, simple adding of PS-related
      statements (PREPARE FOR/EXECUTE/DEALLOCATE PREPARE ) to the list of
      statements allowed for execution by a locked user is not enough
      to solve problems, since it opens the opportunity for a locked user
      to execute any statement in the PS mode.
      
      To exclude this opportunity, additional checking that the statement
      being prepared for execution in PS-mode is the SET statement has to be added.
      This extra checking has been added by this patch into the method
      Prepared_statement::prepared() that executed on preparing any statement
      for execution in PS-mode.
      61f84bba
  9. 12 Apr, 2021 9 commits
    • Dmitriy Karpovskiy's avatar
      MDEV-24135: Print warnings in XML, save test retries in XML, save the... · f776fa96
      Dmitriy Karpovskiy authored
      MDEV-24135: Print warnings in XML, save test retries in XML, save the combinations in XML, replace the special symbols in the XML comment
      f776fa96
    • Monty's avatar
      Fixed assert in WSREP if one started with --wsrep_provider=.. --wsrep_on=OFF · e14b6826
      Monty authored
      Assert was:
      mariadbd: /my/maria-10.6/wsrep-lib/src/client_state.cpp:256:
      int wsrep::client_state::after_statement(): Assertion `state() == s_exec'
      
      The reason was because of two faults:
      - A missing test for WSREP(thd) when checking wsrep_after_statement(()
      - THD->wsrep_cs().state was set to s_idle instead of s_none
      e14b6826
    • Oleksandr Byelkin's avatar
      MDEV-25182 Complex query in Store procedure corrupts results · 68e0defc
      Oleksandr Byelkin authored
      At the second execution of the PS
      1. mark_as_dependent() is called with the same parameters as at the first
         execution (select#4 and select#3)
      2. as outer_select (select#3) has been already merged at the first
         execution of PS it cannot be reached using the outer_select() function
         anymore (and so can not stop iteration).
      3. as a result all selects towards the top level select including the
         select for 'ca' are marked as uncacheable.
      4. Marked uncacheable it executed incorrectly triggering filling its
         temporary table several times and using freed memory at the end.
      
      To avoid the problem we use name resolution context to go "up".
      
      NOTE: problem also exists in 10.2 but has no visible effect on execution.
      That is why the problem is fixed in 10.2.
      
      The patch also add debug logging of important procedures and
      better specify parameters types of st_select_lex::mark_as_dependent.
      68e0defc
    • Dmitry Shulga's avatar
      MDEV-25108: Running of the EXPLAIN EXTENDED statement produces extra warning... · f8bf2a01
      Dmitry Shulga authored
      MDEV-25108: Running of the EXPLAIN EXTENDED statement produces extra warning in case it is executed in PS (prepared statement) mode
      
      The EXPLAIN EXTENDED statement run as a prepared statement can produce extra
      warning comparing with a case when EXPLAIN EXTENDED statement is run as
      a regular statement. For example, the following test case
        CREATE TABLE t1 (c int);
        CREATE TABLE t2 (d int);
        EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) FROM t1;
      
      produces the extra warning
        "Field or reference 'c' of SELECT #2 was resolved in SELECT #1"
      in case the above mentioned "EXPLAIN EXTENDED" statement is executed
      in PS mode, that is by submitting the following statements:
         PREPARE stmt FROM "EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) FROM t1";
         EXECUTE stmt;
      
      The reason of the extra warning emittion is in a way items
      are handled (being fixed) during execution of the JOIN::prepare() method.
      The method Item_field::fix_fields() calls the find_field_in_tables()
      function in case a field hasn't been associated yet with the item.
      Implementation of the find_field_in_tables() function first checks whether
      a table containing the required field was already opened and cached.
      It is done by checking the data member item->cached_table. This data member
      is set on handling the PRERARE FROM statement and checked on executing
      the EXECUTE statement. If the data member item->cached_table is set
      the find_field_in_tables() function invoked and the
      mark_select_range_as_dependent() function called if the field
      is an outer referencee. The mark_select_range_as_dependent() function
      calls the mark_as_dependent() function that finally invokes
      the push_warning_printf() function that produces extra warning.
      
      To fix the issue, calling of push_warning_printf() is elimited in case
      it was run indirectly in result of hanlding already opened table from
      the Item_field::fix_fields() method.
      f8bf2a01
    • Julius Goryavsky's avatar
      MDEV-21484: galera_sst_mariabackup_encrypt_with_key test failed · e95cdc45
      Julius Goryavsky authored
      This commit removes the mtr test galera_sst_mariabackup_encrypt_with_key
      from the list of disabled tests because the problem with it has already
      been fixed.
      e95cdc45
    • Thirunarayanan Balathandayuthapani's avatar
      MDEV-24971 InnoDB access freed virtual column after rollback of secondary index · cf2c6b7f
      Thirunarayanan Balathandayuthapani authored
      Problem:
      ========
       InnoDB fails to clean the index stub if it fails to add the
      virtual index which contains new virtual column. But it clears
      the newly virtual column from index in clear_added_indexes()
      during inplace_alter_table. On commit, InnoDB evicts and
      reload the table. In case of rollback, it doesn't happen.
      InnoDB clears the ABORTED index while opening the table
      or doing the DDL. In the mean time, InnoDB can access
      the dropped virtual index columns while creating prebuilt
      or rollback of concurrent DML.
      
      Solution:
      ==========
      (1) InnoDB should maintain newly added virtual column while
      rollbacking the newly added virtual index.
      (2) InnoDB must not defer the index removal
      if the alter table is executed with LOCK=EXCLUSIVE.
      (3) For LOCK=SHARED, InnoDB should check whether the table
      has any other transaction lock other than alter transaction
      before deferring the index stub.
      
      Replaced has_new_v_col with dict_add_vcol_info in dict_index_t to
      indicate whether the index has any new virtual column.
      
      dict_index_t::has_new_v_col(): Returns whether the index has
      newly added virtual column, it doesn't say which columns are
      newly added virtual column
      
      ha_innobase_inplace_ctx::is_new_vcol(): Return whether the
      given column is added as a part of the current alter.
      
      ha_innobase_inplace_ctx::clean_new_vcol_index(): Copy the newly
      added virtual column to new_vcol_info in dict_index_t. Replace
      the column in the index fields with virtual column stored
      in new_vcol_info.
      
      dict_index_t::assign_new_v_col(): Store the number of virtual
      column added in index as a part of alter table.
      
      dict_index_t::get_n_new_vcol(): Get the number of newly added
      virtual column
      
      dict_index_t::assign_drop_v_col(): Allocate the memory for
      adding new virtual column in new_vcol_info.
      
      dict_index_t::add_drop_v_col(): Add the newly added virtual
      column in new_vcol_info.
      
      dict_table_t::has_lock_for_other_trx(): Whether the table has
      any other transaction lock than given transaction.
      
      row_merge_drop_indexes(): Add parameter alter_trx and check
      whether the table has any other lock than alter transaction.
      cf2c6b7f
    • Marko Mäkelä's avatar
      MDEV-18802 Assertion table->stat_initialized failed in dict_stats_update_if_needed() · ea2d44d0
      Marko Mäkelä authored
      When a table has been evicted from dict_sys and reloaded internally by
      InnoDB for FOREIGN KEY processing, statistics may not be initialized,
      but nevertheless row_update_cascade_for_mysql() could invoke
      dict_stats_update_if_needed(). In that case, we cannot really update
      the statistics. For tables that have STATS_PERSISTENT=1 and
      STATS_AUTO_RECALC=1, ANALYZE TABLE might have to be executed later.
      
      dict_stats_update_if_needed(): Replace the assertion with
      a conditional early return.
      ea2d44d0
    • Marko Mäkelä's avatar
      MDEV-24434 Assertion trx->in_rw_trx_list... in trx_sys_any_active_transactions() · 75dd7a04
      Marko Mäkelä authored
      trx_sys_any_active_transactions(): Remove a bogus debug assertion.
      In trx_commit_in_memory() and trx_erase_lists(), we will remove
      the transaction from trx_sys->rw_trx_list and set the state to
      TRX_STATE_COMMITTED_IN_MEMORY.
      75dd7a04
    • Otto Kekäläinen's avatar
      Deb: Stop depending on empty transitional package dh-systemd · 058d93d4
      Otto Kekäläinen authored
      MariaDB Server still supports Ubuntu 16.04 "Xenial" until it goes EOL
      in April 30, 2021. Thus we need to include a customization for backwards
      compatibility.
      
      This change is intended to be applied for all MariaDB versions still
      supported, i.e. 10.2 to 10.6.
      058d93d4
  10. 11 Apr, 2021 1 commit
    • Julius Goryavsky's avatar
      MDEV-25307: The value of the auto-increment variables changes during the test · 966c5a35
      Julius Goryavsky authored
      The auto-increment variables may change intermittently during
      the execution of some tests from the Galera mtr suite, causing
      these tests to fail. This patch creates conditions in which
      unpredictable changes to these variables are not possible
      during the execution of those tests in which this problem
      is noticed or their values are restored before the end of
      testing.
      966c5a35