1. 03 Jun, 2024 2 commits
    • Denis Protivensky's avatar
      MDEV-32633: Fix Galera cluster <-> native replication interaction · 0cc9b497
      Denis Protivensky authored
      It's possible to establish Galera multi-cluster setups connected
      through the native replication when every Galera cluster is configured
      to have a separate domain ID.
      For this setup to work, we need to replace domain ID values in generated
      GTID events when they are written at transaction commit to the values
      configured by Wsrep replication.
      
      At the same time, it's possible that the GTID event already contains
      a correct domain ID if it comes through the native replication from
      another Galera cluster.
      In this case, when such an event is applied either through a native
      replication slave thread or through Wsrep applier, we write GTID event
      on transaction start and avoid writing it during transaction commit.
      
      The code contained multiple problems that were fixed:
      - applying GTID events didn't work because it's applied without a
      running server transaction and Wsrep transaction was not started
      - GTID event generation on transaction start didn't contain proper
      "standalone" and "is_transactional" flags that the original applied
      GTID event contained
      - condition determining that GTID event is written on transaction start
      to avoid writing it on commit relied on the fact that the GTID event
      is the first found in transaction/statement caches, which wasn't the
      case and resulted in duplicate GTID events written
      - instead of relying on the caches to find a GTID event, a simple check
      is introduced that follows the exact rules for checking if event is
      written at transaction start as described above
      - the test case is improved to check that exact GTID events are
      applied after two Galera clusters have synced.
      Signed-off-by: default avatarJulius Goryavsky <julius.goryavsky@mariadb.com>
      0cc9b497
    • Denis Protivensky's avatar
      MDEV-33952: Fix flaky galera_create_table_as_select test with debug sync · a6b7203d
      Denis Protivensky authored
      The test that triggers multi-master conflict between two CTAS commands
      uses LOCK/UNLOCK TABLES to block local CTAS from progress. It could
      result in a race when UNLOCK TABLES command is issued a bit earlier
      then needed, causing local CTAS to run further and change wsrep
      transaction state, so that a different code path is taken later and
      the original error gets overridden, causing the test to fail.
      The solution is to replace LOCK/UNLOCK TABLES with debug sync points.
      Signed-off-by: default avatarJulius Goryavsky <julius.goryavsky@mariadb.com>
      a6b7203d
  2. 30 May, 2024 5 commits
    • Yuchen Pei's avatar
      MDEV-29027 ASAN errors in spider_db_free_result after partition DDL · 25476ba1
      Yuchen Pei authored
      Spider calls ha_spider::close() at least twice on ALTER TABLE ... ADD
      PARTITION. The first call frees wide_handler and the second call
      accesses wide_handler->trx->thd (heap-use-after-free).
      
      In general, there seems to be no problem with using THD obtained by
      the macro current_thd() except in background threads. Thus, we simply
      replace wide_handler->trx->thd with current_thd().
      
      Original author: Nayuta Yanagasawa
      25476ba1
    • Nayuta Yanagisawa's avatar
      MDEV-28522 Delete constant SPIDER_SQL_TYPE_*_HS · 6d0c9872
      Nayuta Yanagisawa authored
      The HandlerSocket support of Spider has been deleted by MDEV-26858.
      Thus, the constants, SPIDER_SQL_TYPE_*_HS, are no longer necessary.
      6d0c9872
    • Yuchen Pei's avatar
      MDEV-26858 Spider: Remove dead code related to HandlerSocket · 6c302207
      Yuchen Pei authored
      Remove the dead-code, in Spider, which is related to the Spider's
      HandlerSocket support. The code has been disabled for a long time
      and it is unlikely that the code will be enabled.
      
      - rm all files under storage/spider/hs_client/ except hs_compat.h
      - rm storage/spider/spd_db_handlersocket.*
      - unifdef -UHS_HAS_SQLCOM -UHAVE_HANDLERSOCKET \
        -m storage/spider/spd_* storage/spider/ha_spider.* storage/spider/hs_client/*
      - remove relevant files from storage/spider/CMakeLists.txt
      6c302207
    • Marko Mäkelä's avatar
      MDEV-31340 fixup: Add end-of-test marker · 0c440abd
      Marko Mäkelä authored
      0c440abd
    • Marko Mäkelä's avatar
      Fix ./mtr --repeat=2 main.func_str · c71275b6
      Marko Mäkelä authored
      c71275b6
  3. 29 May, 2024 2 commits
  4. 28 May, 2024 1 commit
    • Souradeep Saha's avatar
      Fix Various Typos · 83a04be8
      Souradeep Saha authored
      Fix various typos, in comments and DEBUG statements, and code changes
      are non-functional.
      
      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.
      83a04be8
  5. 27 May, 2024 2 commits
    • Alexander Barkov's avatar
      MDEV-34226 On startup: UBSAN: applying zero offset to null pointer in... · 4a158ec1
      Alexander Barkov authored
      MDEV-34226 On startup: UBSAN: applying zero offset to null pointer in my_copy_fix_mb from strings/ctype-mb.c and other locations
      
      nullptr+0 is an UB (undefined behavior).
      
      - Fixing my_string_metadata_get_mb() to handle {nullptr,0} without UB.
      - Fixing THD::copy_with_error() to disallow {nullptr,0} by DBUG_ASSERT().
      - Fixing parse_client_handshake_packet() to call THD::copy_with_error()
        with an empty string {"",0} instead of NULL string {nullptr,0}.
      4a158ec1
    • Alexander Barkov's avatar
      MDEV-30931 UBSAN: negation of -X cannot be represented in type 'long long... · 79253261
      Alexander Barkov authored
      MDEV-30931 UBSAN: negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in get_interval_value on SELECT
      
      - Fixing the code in get_interval_value() to use Longlong_hybrid_null.
        This allows to handle correctly:
      
        - Signed and unsigned arguments
          (the old code assumed the argument to be signed)
        - Avoid undefined negation behavior the corner case with LONGLONG_MIN
      
        This fixes the UBSAN warning:
          negation of -9223372036854775808 cannot be represented
          in type 'long long int';
      
      - Fixing the code in get_interval_value() to avoid overflow in
        the INTERVAL_QUARTER and INTERVAL_WEEK branches.
        This fixes the UBSAN warning:
          signed integer overflow: -9223372036854775808 * 7 cannot be represented
          in type 'long long int'
      
      - Fixing the INTERVAL_WEEK branch in date_add_interval() to handle
        huge numbers correctly. Before the change, huge positive numeber
        were treated as their negative complements.
        Note, some other branches still can be affected by this problem
        and should also be fixed eventually.
      79253261
  6. 24 May, 2024 2 commits
  7. 23 May, 2024 2 commits
    • Vladislav Vaintroub's avatar
      MDEV-34205: ASAN stack buffer overflow in strxnmov() in frm_file_exists · 736449d3
      Vladislav Vaintroub authored
      Correct the second parameter for strxnmov to prevent potential buffer
      overflows. The second parameter must be one less than the size of the
      input buffer to avoid writing past the end of the buffer.
      
      While the second parameter is usually correct, there are exceptions
      that need fixing.
      
      This commit addresses the issue within frm_file_exists() and other
      affected places.
      736449d3
    • Alexander Barkov's avatar
      MDEV-28387 UBSAN: runtime error: negation of -9223372036854775808 cannot be... · 7c4c0823
      Alexander Barkov authored
      MDEV-28387 UBSAN: runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_strtoll10 on SELECT
      
      Fixing the condition to raise an overflow in the ulonglong
      representation of the number is greater or equal to 0x8000000000000000ULL.
      Before this change the condition did not catch -9223372036854775808
      (the smallest possible signed negative longlong number).
      7c4c0823
  8. 21 May, 2024 5 commits
    • Yuchen Pei's avatar
    • Marko Mäkelä's avatar
      MDEV-33817 fixup: Disable for macOS · 266495b9
      Marko Mäkelä authored
      According to https://discussions.apple.com/thread/8256853
      an attempt to use AVX512 registers on macOS will result in #UD
      (crash at runtime).
      
      Also, starting with clang-18 and GCC 14, we must add "evex512" to the
      target flags so that AVX and SSE instructions can use AVX512 specific
      encodings. This flag was introduced together with the avx10.1-512 target.
      Older compiler versions do not recognize "evex512". We do not want to
      write "avx10.1-512" because it could enable some AVX512 subfeatures
      that we do not have any CPUID check for.
      
      Reviewed by: Vladislav Vaintroub
      Tested on macOS by: Valerii Kravchuk
      266495b9
    • Alexander Barkov's avatar
      Backporting bugs fixes fixed by MDEV-31340 from 11.5 · 310fd6ff
      Alexander Barkov authored
      The patch for MDEV-31340 fixed the following bugs:
      
      MDEV-33084 LASTVAL(t1) and LASTVAL(T1) do not work well with lower-case-table-names=0
      MDEV-33085 Tables T1 and t1 do not work well with ENGINE=CSV and lower-case-table-names=0
      MDEV-33086 SHOW OPEN TABLES IN DB1 -- is case insensitive with lower-case-table-names=0
      MDEV-33088 Cannot create triggers in the database `MYSQL`
      MDEV-33103 LOCK TABLE t1 AS t2 -- alias is not case sensitive with lower-case-table-names=0
      MDEV-33108 TABLE_STATISTICS and INDEX_STATISTICS are case insensitive with lower-case-table-names=0
      MDEV-33109 DROP DATABASE MYSQL -- does not drop SP with lower-case-table-names=0
      MDEV-33110 HANDLER commands are case insensitive with lower-case-table-names=0
      MDEV-33119 User is case insensitive in INFORMATION_SCHEMA.VIEWS
      MDEV-33120 System log table names are case insensitive with lower-cast-table-names=0
      
      Backporting the fixes from 11.5 to 10.5
      310fd6ff
    • mariadb-DebarunBanerjee's avatar
      MDEV-34166 Server could hang with BP < 80M under stress · b2944adb
      mariadb-DebarunBanerjee authored
      BUF_LRU_MIN_LEN (256) is too high value for low buffer pool(BP) size.
      For example, for BP size lower than 80M and 16 K page size, the limit is
      more than 5% of total BP and for lowest BP 5M, it is 80% of the BP.
      Non-data objects like explicit locks could occupy part of the BP pool
      reducing the pages available for LRU. If LRU reaches minimum limit and
      if no free pages are available, server would hang with page cleaner not
      able to free any more pages.
      
      Fix: To avoid such hang, we adjust the LRU limit lower than the limit
      for data objects as checked in buf_LRU_check_size_of_non_data_objects()
      i.e. one page less than 5% of BP.
      b2944adb
    • Marko Mäkelä's avatar
      MDEV-34204 Assertion `!*detailed_error' failed on shutdown after XA PREPARE · 0907df3d
      Marko Mäkelä authored
      trx_free_at_shutdown(): Similar to trx_t::commit_in_memory(),
      clear the detailed_error (FOREIGN KEY constraint error) before
      invoking trx_t::free(). We only do this on debug instrumented
      builds in order to avoid a debug assertion failure on shutdown.
      0907df3d
  9. 20 May, 2024 4 commits
  10. 17 May, 2024 1 commit
    • Robin Newhouse's avatar
      Minimize unsafe C functions with safe_strcpy() · dc38d8ea
      Robin Newhouse authored
      Similar to #2480.
      567b6812 introduced safe_strcpy() to minimize the use of C with
      potentially unsafe memory overflow with strcpy() whose use is
      discouraged.
      Replace instances of strcpy() with safe_strcpy() where possible, limited
      here to files in the `sql/` directory.
      
      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.
      dc38d8ea
  11. 16 May, 2024 1 commit
  12. 15 May, 2024 1 commit
  13. 14 May, 2024 2 commits
    • Sergei Golubchik's avatar
    • Yuchen Pei's avatar
      MDEV-28105 Return error in ha_spider::write_row() if info(HA_STATUS_AUTO) fails · fd767462
      Yuchen Pei authored
      Spider calls info with HA_STATUS_AUTO to update auto increment info,
      which may attempt to connect the data node. If the connection fails,
      it may emit an error and return the same error. This error should not
      be of lower priority than any possible error from the later call to
      handler::update_auto_increment().
      
      Without this change, certain errors from update_auto_increment() such
      as HA_ERR_AUTOINC_ERANGE may get ignored, causing my_insert() to call
      my_ok(), which fails the assertion because the error was emitted in
      the info() call (Diagnostics_area::is_set() returns true).
      fd767462
  14. 12 May, 2024 3 commits
  15. 10 May, 2024 1 commit
  16. 09 May, 2024 1 commit
    • He Guohua's avatar
      MDEV-31566 Fix buffer overrun of column_json function · 86774720
      He Guohua authored
      The accounting of the limit variable that represents the
      amount of space left it the buffer was incorrect.
      
      Also there was 1 or 2 bytes left to write that occured without
      the buffer length being checked.
      
      Review: Sanja Byelkin
      86774720
  17. 08 May, 2024 5 commits