1. 24 Apr, 2023 5 commits
    • Brandon Nesterenko's avatar
      MDEV-30430: Enabling system versioning on tables without primary key breaks replication · 29fb0410
      Brandon Nesterenko authored
      When replicating MDL events for a table that uses system versioning
      without primary keys, ensure that for data sets with duplicate
      records, the updates to these records with duplicates are enacted on
      the correct row. That is, there was a bug (reported in MDEV-30430)
      such that the function to find the row to update would stop after
      finding the first matching record. However, in the absence of
      primary keys, the version of the record is needed to compare the row
      to ensure we are updating the correct one.
      
      The fix, therefore, updates the record comparison functionality to
      use system version columns when there are no primary keys on the
      table.
      
      Reviewed By:
      ============
      Andrei Elkin <andrei.elkin@mariadb.com>
      29fb0410
    • Brandon Nesterenko's avatar
      MDEV-28798: Cosmetic Changes Only · 4ec3dca3
      Brandon Nesterenko authored
      Removed trailing whitespaces
      4ec3dca3
    • Brandon Nesterenko's avatar
      MDEV-28798: Previously Binlog Encrypted Master Segfaults on Binlog Dump with Using_Gtid=Slave_Pos · d3e7dba3
      Brandon Nesterenko authored
      Problem:
      ========
      A master can segfault if it can't set up decryption for its binary
      log during a binlog dump with Using_Gtid=Slave_Pos. If slave
      connects using GTID mode, the master will call into
      log.cc::get_gtid_list_event(), which iterate through binlog events
      looking for a Gtid_list_log_event. On an encrypted binlog that the
      master cannot decrypt, the first event will be a
      START_ENCRYPTION_EVENT which will call into the following decryption branch
      
      if (fdle->start_decryption((Start_encryption_log_event*) ev))
        errormsg= ‘Could not set up decryption for binlog.’;
      
      The event iteration however, does not stop in spite of this error.
      The master will try to read the next event, but segfault while
      trying to decrypt it because decryption failed to initialize.
      
      Solution:
      ========
      Break the event iteration if decryption cannot be set up.
      
      Reviewed By:
      ============
      Andrei Elkin <andrei.elkin@mariadb.com>
      d3e7dba3
    • Igor Babaev's avatar
      MDEV-31102 Crash when pushing condition into view defined as union · 5dc9a6b4
      Igor Babaev authored
      This bug could manifest itself at the first execution of prepared statement
      created for queries using a materialized view defined as union. A crash
      could happen for sure if the query contained a condition pushable into
      the view and this condition was over the column defined via a complex string
      expression requiring implicit conversion from one charset to another for
      some of its sub-expressions. The bug could cause crashes when executing
      PS for some other queries whose optimization needed building clones for
      such expressions.
      
      This bug was introduced in the patch for MDEV-29988 where the class
      Item_direct_ref_to_item was added. The implementations of the virtual
      methods get_copy() and build_clone() were invalid for the class and this
      could cause crashes after the method build_clone() was called for
      expressions containing objects of the Item_direct_ref_to_item type.
      
      Approved by Sergei Golubchik <serg@mariadb.com>
      5dc9a6b4
    • 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 3 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
    • 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 5 commits
  6. 18 Apr, 2023 2 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
    • 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 2 commits
    • Daniel Black's avatar
      alloca() fix · 2e1c532b
      Daniel Black authored
      Corrections from 1e58b8af.
      * Re-add #pragma alloca for AIX - now in my_alloca.h
      2e1c532b
    • Julius Goryavsky's avatar
      MDEV-30402: Encrypted mariabackup SST breaks on distributions with newer socat · d1a4315f
      Julius Goryavsky authored
      This commit adds a new 'no-sni' option to socat which is required to
      properly authenticate with newer socat versions (after version 1.7.4+).
      This option is needed to disable the automatic use of the SNI feature
      (Server Name Indication) since the SST script directly specifies the
      commonname if necessary and automatic activation of the SNI feature
      is unnecessary in such scenarios.
      d1a4315f
  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 2 commits
  13. 05 Apr, 2023 1 commit
    • Sergei Golubchik's avatar
      MDEV-25887 "Got notification message from PID xxxx, but reception only... · 79e27a6b
      Sergei Golubchik authored
      MDEV-25887 "Got notification message from PID xxxx, but reception only permitted for main PID yyyy" in systemd during SST
      
      server has systemd support and calls sd_notify() to communicate
      the status to systemd.
      
      mariabackup links the whole server in, but it should not notify
      systemd, because it's not started or managed by systemd.
      79e27a6b
  14. 04 Apr, 2023 3 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
    • 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 2 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
  16. 01 Apr, 2023 4 commits
    • Sergei Golubchik's avatar
      ensure that STRING_WITH_LEN is only used with string literals · 0a634390
      Sergei Golubchik authored
      This is allowed:
      
        STRING_WITH_LEN("string literal")
      
      This is not:
      
        char *str = "pointer to string";
        ... STRING_WITH_LEN(str) ..
      
      In C++ this is also allowed:
      
        const char str[] = "string literal";
        ... STRING_WITH_LEN(str) ...
      0a634390
    • Sergei Golubchik's avatar
      MDEV-13255 main.status failed in buildbot · 6a10468e
      Sergei Golubchik authored
      Test fails sporadically and very rarely on this:
      ```
      let $org_queries= `SHOW STATUS LIKE 'Queries'`;
      SELECT f1();
      CALL p1();
      let $new_queries= `SHOW STATUS LIKE 'Queries'`;
      let $diff= `SELECT SUBSTRING('$new_queries',9)-SUBSTRING('$org_queries',9)`;
      ```
      if COM_QUIT from one of the earlier (in the test) disconnect's
      happens between the two SHOW STATUS commands.
      Because COM_QUIT increments "Queries".
      
      The directly previous test uses wait_condition to wait for
      its disconnects to complete. But there are more disconnects earlier
      in the test file and nothing waits for them.
      
      Let's change wait_condition to wait for *all* disconnect to complete.
      6a10468e
    • Oleksandr Byelkin's avatar
    • Hugo Wen's avatar
      Handle meaningless addr2line results and increase timeout · 3b642440
      Hugo Wen authored
      MariaDB server prints the stack information if a crash happens.
      
      It traverses the stack frames in function `print_with_addr_resolve`.
      For *EACH* frame, it tries to parse the file name and line number of the
      frame using `addr2line`, or prints `backtrace_symbols_fd` if `addr2line`
      fails.
      
      1. Logic in `addr_resolve` function uses addr2line to get the file name
         and line numbers. It has a timeout of 500ms to wait for the response
         from addr2line. However, that's not enough on small instances
         especially if the debug information is in a separate file or
         compressed.
      
         Increase the timeout to 5 seconds to support some edge cases, as
         experiments showed addr2line may take 2-3 seconds on some frames.
      
      2. While parsing a frame inside of a shared library using `addr2line`,
         the file name and line numbers could be `??`, empty or `0` if the
         debug info is not loaded.
         It's easy to reproduce when glibc-debuginfo is not installed.
      
         Instead of printing a meaningless frame like:
      
             :0(__GI___poll)[0x1505e9197639]
             ...
             ??:0(__libc_start_main)[0x7ffff6c8913a]
      
         We want to print the frame information using `backtrace_symbols_fd`,
         with the shared library name and a hexadecimal offset.
         Stacktrace example on a real instance with this commit:
      
             /lib64/libc.so.6(__poll+0x49)[0x145cbf71a639]
             ...
             /lib64/libc.so.6(__libc_start_main+0xea)[0x7f4d0034d13a]
      
         `addr_resolve` has considered the case of meaningless combination of
         file name and line number returned by `addr2line`. e.g. `??:?`
         However, conditions like `:0` and `??:0` are not handled. So now the
         function will rollback to `backtrace_symbols_fd` in above cases.
      
      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.
      3b642440
  17. 31 Mar, 2023 3 commits
  18. 29 Mar, 2023 1 commit
    • Marko Mäkelä's avatar
      MDEV-30453 Setting innodb_buffer_pool_filename to an empty string attempts to... · a6780df4
      Marko Mäkelä authored
      MDEV-30453 Setting innodb_buffer_pool_filename to an empty string attempts to delete the data directory on shutdown
      
      Let us make innodb_buffer_pool_filename a read-only variable
      so that a malicious user cannot cause an important file to be
      deleted on InnoDB shutdown. An attempt to delete a directory
      will fail because it is not a regular file, but what if the
      variable pointed to (say) ibdata1, ib_logfile0 or some *.ibd file?
      
      It does not seem to make much sense for this parameter to be
      configurable in the first place, but we will not change that in order
      to avoid breaking compatibility.
      a6780df4