1. 24 Apr, 2023 3 commits
    • Brandon Nesterenko's avatar
      MDEV-31038: Parallel Replication Breaks if XA PREPARE Fails Updating Slave GTID State · 31f09e36
      Brandon Nesterenko authored
      If a replica failed to update the GTID slave state when committing
      an XA PREPARE, the replica would retry the transaction and get an
      out-of-order GTID error. This is because the commit phase of an XA
      PREPARE is bifurcated. That is, first, the prepare is handled by the
      relevant storage engines. Then second, the GTID slave state is
      updated as a separate autocommit transaction. If the second phase
      fails, and the transaction is retried, then the same transaction is
      attempted to be committed again, resulting in a GTID out-of-order
      error.
      
      This patch fixes this error by immediately stopping the slave and
      reporting the appropriate error. That is, there was logic to bypass
      the error when updating the GTID slave state table if the underlying
      error is allowed for retry on a parallel slave. This patch adds a
      parameter to disallow the error bypass, thereby forcing the error
      state to still happen.
      
      Reviewed By
      ============
      Andrei Elkin <andrei.elkin@mariadb.com>
      31f09e36
    • Oleksandr Byelkin's avatar
      Merge branch '10.4' into 10.5 · 1d74927c
      Oleksandr Byelkin authored
      1d74927c
    • Alexander Barkov's avatar
      A cleanup for MDEV-30968 mariadb-backup does not copy Aria logs if aria_log_dir_path is used · d3e394b3
      Alexander Barkov authored
      Fixing buildbot failures on mariabackup.aria_log_dir_path_rel.
      
      The problem was that directory_exists() was called with the
      relative aria_log_dir_path value, while the current directory
      in mariadb-backup is not necessarily equal to datadir when MTR is running.
      
      Fix:
      
      - Moving building the absolute path un level upper:
        from the function copy_back_aria_logs() to the function copy_back().
      - Passing the built absolute path to both directory_exists() and
        copy_back_aria_logs() as a parameter.
      d3e394b3
  2. 22 Apr, 2023 1 commit
  3. 21 Apr, 2023 4 commits
    • Alexander Barkov's avatar
      MDEV-30968 mariadb-backup does not copy Aria logs if aria_log_dir_path is used · 9f98a2ac
      Alexander Barkov authored
      - `mariadb-backup --backup` was fixed to fetch the value of the
         @@aria_log_dir_path server variable and copy aria_log* files
         from @@aria_log_dir_path directory to the backup directory.
         Absolute and relative (to --datadir) paths are supported.
      
         Before this change aria_log* files were copied to the backup
         only if they were in the default location in @@datadir.
      
      - `mariadb-backup --copy-back` now understands a new my.cnf and command line
         parameter --aria-log-dir-path.
      
        `mariadb-backup --copy-back` in the main loop in copy_back()
         (when copying back from the backup directory to --datadir)
         was fixed to ignore all aria_log* files.
      
         A new function copy_back_aria_logs() was added.
         It consists of a separate loop copying back aria_log* files from
         the backup directory to the directory specified in --aria-log-dir-path.
         Absolute and relative (to --datadir) paths are supported.
         If --aria-log-dir-path is not specified,
         aria_log* files are copied to --datadir by default.
      
      - The function is_absolute_path() was fixed to understand MTR style
        paths on Windows with forward slashes, e.g.
         --aria-log-dir-path=D:/Buildbot/amd64-windows/build/mysql-test/var/...
      9f98a2ac
    • Daniel Black's avatar
      MDEV-30713 field length handling for CONNECT engine · da1c91fb
      Daniel Black authored
      fp->field_length was unsigned and therefore the negative
      condition around it.
      
      Backport of cc182aca fixes it, however to correct the
      consistent use of types pcf->Length needs to be unsigned
      too.
      
      At one point pcf->Precision is assigned from pcf->Length so
      that's also unsigned.
      
      GetTypeSize is assigned to length and has a length argument.
      A -1 default value seemed dangerious to case, so at least 0
      should assert if every hit.
      da1c91fb
    • Marko Mäkelä's avatar
      MDEV-30753 fixup: Unsafe buffer page restoration · c6e58a8d
      Marko Mäkelä authored
      trx_purge_free_segment(): The buffer-fix only prevents a block from
      being freed completely from the buffer pool, but it will not prevent
      the block from being evicted. Recheck the page identifier after
      acquiring an exclusive page latch. If it has changed, backtrack and
      invoke buf_page_get_gen() to look up the page normally.
      c6e58a8d
    • Oleksandr Byelkin's avatar
      Merge branch '10.3' into 10.4 · 3d27f6d7
      Oleksandr Byelkin authored
      3d27f6d7
  4. 20 Apr, 2023 1 commit
    • Mikhail Chalov's avatar
      Minimize unsafe C functions usage - replace strcat() and strcpy() · fc6e8a3d
      Mikhail Chalov authored
      Similar to 567b6812 continue to replace use of strcat() and
      strcpy() with safer options strncat() and strncpy().
      
      All new code of the whole pull request, including one or several files
      that are either new files or modified ones, are contributed under the BSD-new
      license. I am contributing on behalf of my employer Amazon Web Services
      fc6e8a3d
  5. 19 Apr, 2023 7 commits
  6. 18 Apr, 2023 3 commits
    • Daniele Sciascia's avatar
      MDEV-30955 Explicit locks released too early in rollback path · feeeacc4
      Daniele Sciascia authored
      Assertion `thd->mdl_context.is_lock_owner()` fires when a client is
      disconnected, while transaction and and a table is opened through
      `HANDLER` interface.
      Reason for the assertion is that when a connection closes, its ongoing
      transaction is eventually rolled back in
      `Wsrep_client_state::bf_rollback()`. This method also releases explicit
      which are expected to survive beyond the transaction lifetime.
      This patch also removes calls to `mysql_ull_cleanup()`. User level
      locks are not supported in combination with Galera, making these calls
      unnecessary.
      feeeacc4
    • Sergei Petrunia's avatar
      MDEV-30605: Wrong result while using index for group-by · be7ef656
      Sergei Petrunia authored
      A GROUP BY query which uses "MIN(pk)" and has "pk<>const" in the
      WHERE clause would produce wrong result when handled with "Using index
      for group-by".  Here "pk" column is the table's primary key.
      
      The problem was introduced by fix for MDEV-23634. It made the range
      optimizer to not produce ranges for conditions in form "pk != const".
      
      However, LooseScan code requires that the optimizer is able to
      convert the condition on the MIN/MAX column into an equivalent range.
      The range is used to locate the row that has the MIN/MAX value.
      
      LooseScan checks this in check_group_min_max_predicates(). This fix
      makes the code in that function to take into account that "pk != const"
      does not produce a range.
      be7ef656
    • Daniele Sciascia's avatar
      MDEV-30862 Assertion `mode_ == m_high_priority' failed · bc3bfcf9
      Daniele Sciascia authored
      CREATE TABLE AS SELECT is not supported in combination with streaming
      replication.
      bc3bfcf9
  7. 17 Apr, 2023 1 commit
    • Florian Weimer's avatar
      rocksdb: Define _GNU_SOURCE during fallocate CMake probe · f575de39
      Florian Weimer authored
      The glibc headers declare fallocate only if _GNU_SOURCE is defined.
      Without this change, the probe fails with C compilers which do not
      support implicit function declarations even if the system does in
      fact support the fallocate function.
      
      Upstream rocksdb does not need this because the probe is run with the
      C++ compiler, and current g++ versions define _GNU_SOURCE
      automatically.
      f575de39
  8. 13 Apr, 2023 3 commits
  9. 12 Apr, 2023 2 commits
    • Igor Babaev's avatar
      MDEV-20773 Error from UPDATE when estimating selectivity of a range · ef4d0994
      Igor Babaev authored
      This bug could affect multi-update statements as well as single-table
      update statements processed as multi-updates when the where condition
      contained a range condition over a non-indexed varchar column. The
      optimizer calculates selectivity of such range conditions using histograms.
      For each range the buckets containing endpoints of the the range are
      determined with a procedure that stores the values of the endpoints in the
      space of the record buffer where values of the columns are usually stored.
      For a range over a varchar column the value of a endpoint may exceed the
      size of the buffer and in such case the value is stored with truncation.
      This truncations cannot affect the result of the calculation of the range
      selectivity as the calculation employes only the beginning of the value
      string. However it can trigger generation of an unexpected error on this
      truncation if an update statement is processed.
      This patch prohibits truncation messages when selectivity of a range
      condition is calculated for a non-indexed column.
      
      Approved by Oleksandr Byelkin <sanja@mariadb.com>
      ef4d0994
    • Alexander Barkov's avatar
      MDEV-31039 mariadb-backup: remove global variables ds_data and ds_meta · 7bcfa00a
      Alexander Barkov authored
      This is a non-functional change.
      
      simplifying the code logic:
      - removing global variables ds_data and ds_meta
      - passing these variables as parameters to functions instead
      - adding helper classes: Datasink_free_list and Backup_datasinks
      - moving some function accepting a ds_ctxt parameter
        as methods to ds_ctxt.
      7bcfa00a
  10. 11 Apr, 2023 1 commit
  11. 10 Apr, 2023 1 commit
  12. 06 Apr, 2023 3 commits
  13. 05 Apr, 2023 2 commits
  14. 04 Apr, 2023 4 commits
    • Jan Lindström's avatar
      MDEV-29602 : Galera debug build crashes when the spider plugin is enabled · 06393cd8
      Jan Lindström authored
      Spider system tables should be created so that wsrep_on=OFF.
      Signed-off-by: default avatarJulius Goryavsky <julius.goryavsky@mariadb.com>
      06393cd8
    • Alexander Barkov's avatar
    • Jan Lindström's avatar
      MDEV-28641 : Query cache entries not invalidated on slave of a Galera cluster · afdf19cf
      Jan Lindström authored
      Query cache should be invalidated if we are not in applier. For some
      reason this condition was incorrect starting from 10.5 but it is
      correct in 10.4.
      Signed-off-by: default avatarJulius Goryavsky <julius.goryavsky@mariadb.com>
      afdf19cf
    • Alexander Barkov's avatar
      MDEV-30034 UNIQUE USING HASH accepts duplicate entries for tricky collations · 8020b1bd
      Alexander Barkov authored
      - Adding a new argument "flag" to MY_COLLATION_HANDLER::strnncollsp_nchars()
        and a flag MY_STRNNCOLLSP_NCHARS_EMULATE_TRIMMED_TRAILING_SPACES.
        The flag defines if strnncollsp_nchars() should emulate trailing spaces
        which were possibly trimmed earlier (e.g. in InnoDB CHAR compression).
        This is important for NOPAD collations.
      
        For example, with this input:
         - str1= 'a '    (Latin letter a followed by one space)
         - str2= 'a  '   (Latin letter a followed by two spaces)
         - nchars= 3
        if the flag is given, strnncollsp_nchars() will virtually restore
        one trailing space to str1 up to nchars (3) characters and compare two
        strings as equal:
        - str1= 'a  '  (one extra trailing space emulated)
        - str2= 'a  '  (as is)
      
        If the flag is not given, strnncollsp_nchars() does not add trailing
        virtual spaces, so in case of a NOPAD collation, str1 will be compared
        as less than str2 because it is shorter.
      
      - Field_string::cmp_prefix() now passes the new flag.
        Field_varstring::cmp_prefix() and Field_blob::cmp_prefix() do
        not pass the new flag.
      
      - The branch in cmp_whole_field() in storage/innobase/rem/rem0cmp.cc
        (which handles the CHAR data type) now also passed the new flag.
      
      - Fixing UCA collations to respect the new flag.
        Other collations are possibly also affected, however
        I had no success in making an SQL script demonstrating the problem.
        Other collations will be extended to respect this flags in a separate
        patch later.
      
      - Changing the meaning of the last parameter of Field::cmp_prefix()
        from "number of bytes" (internal length)
        to "number of characters" (user visible length).
      
        The code calling cmp_prefix() from handler.cc was wrong.
        After this change, the call in handler.cc became correct.
      
        The code calling cmp_prefix() from key_rec_cmp() in key.cc
        was adjusted according to this change.
      
      - Old strnncollsp_nchar() related tests in unittest/strings/strings-t.c
        now pass the new flag.
        A few new tests also were added, without the flag.
      8020b1bd
  15. 03 Apr, 2023 3 commits
    • Lorna Luo's avatar
      Make 'move_file' command more reliable in 3 innodb tests · 0cc1694e
      Lorna Luo authored
      The tests innodb.import_tablespace_race, innodn.restart, and innodb.innodb-wl5522 move
      the tablespace file between the data directory and the tmp directory specified by
      global environment variables. However this is risky because it's not unusual that the
      set tmp directory (often under /tmp) is mounted on another disk partition or device,
      and 'move_file' command may fail with "Errcode: 18 'Invalid cross-device link.'"
      
      For innodb.import_tablespace_race and innodb.innodb-wl5522, moving files
      across directories is not necessary. Modify the tests so they rename
      files under the same directory. For innodb.restart, instead of moving
      between datadir and MYSQL_TMPDIR, move the files under MYSQLTEST_VARDIR.
      
      All new code of the whole pull request, including one or several files that
      are either new files or modified ones, are contributed under the BSD-new license.
      I am contributing on behalf of my employer Amazon Web Services, Inc.
      0cc1694e
    • Lorna Luo's avatar
      Make 'move_file' command more reliable in mysqltest · da73db23
      Lorna Luo authored
      The tests innodb.import_tablespace_race, innodn.restart, and innodb.innodb-wl5522 move
      the tablespace file between the data directory and the tmp directory specified by
      global environment variables. However this is risky because it's not unusual that the
      set tmp directory (often under /tmp) is mounted on another disk partition or device,
      and 'move_file' command may fail with "Errcode: 18 'Invalid cross-device link.'"
      
      To stabilize mysqltest in the described scenario, and prevent such
      behavior in the future, let make_file() check both from file path and to
      file path and make sure they are either both under MYSQLTEST_VARDIR or
      MYSQL_TMP_DIR.
      
      All new code of the whole pull request, including one or several files that
      are either new files or modified ones, are contributed under the BSD-new license.
      I am contributing on behalf of my employer Amazon Web Services, Inc.
      da73db23
    • Oleksandr Byelkin's avatar
      Merge branch '10.4' into 10.5 · 3261a78e
      Oleksandr Byelkin authored
      3261a78e
  16. 01 Apr, 2023 1 commit