1. 16 Jun, 2024 9 commits
    • Monty's avatar
      Added 'crash_error' to Aria for recording of reason for crash) · 395613d4
      Monty authored
      This will allow us to in the future add better error messages why
      an Aria table is crashed.
      395613d4
    • Monty's avatar
      Improve error message for ER_CANT_FIND_DL_ENTRY · c0744105
      Monty authored
      Added name of the dll/udf that caused the error.
      c0744105
    • Monty's avatar
      56dcf96a
    • Monty's avatar
      MDEV-33620 Improve times and states in show processlist for replication · 8d55da9f
      Monty authored
      - Slave_IO thread time is now reset between reading events. Before
        this commit Slave_IO always showed "Waiting for master to send
        event" and the time was from SLAVE START. Now it shows time since
        reading last event.
      8d55da9f
    • Monty's avatar
      Generate a warning(note) and write to error log if master_pos_wait() fails. · 2d7a3638
      Monty authored
      This is to make it easier to understand why master_pos_wait() fails in mtr.
      2d7a3638
    • Monty's avatar
    • Monty's avatar
      This is just to get columnstore to compile · 5a97c3a4
      Monty authored
      This commit can be ignored when columnstore changes to use
      rows_stats.updated+rows_stats.rows_inserted+rows_stats.rows_deleted
      instead of 'rows_changed'
      in storage/columnstore/columnstore/dbcon/mysql/ha_mcs_impl.cpp
      5a97c3a4
    • Monty's avatar
      MDEV-33501 Extend query_response_time plugin to be compatible with Percona server · 38177df5
      Monty authored
      MDEV-34031 FLUSH QUERY_RESPONSE_TIME_WRITE also flushes READ, and vice versa
      
      This is to update the plugin to be compatible with Percona's
      query_response_time plugin, with some additions.
      Some of the tests are taken from Percona server.
      
      - Added plugins QUERY_RESPONSE_TIME_READ, QUERY_RESPONSE_TIME_WRITE and
        QUERY_RESPONSE_TIME_READ_WRITE.
      - Added option query_response_time_session_stats, with possible values
        GLOBAL, ON or OFF, to the query_response_time plugin.
      
      Notes:
      - All modules are dependent on QUERY_RESPONSE_READ_TIME. This must always
        be enabled if any of the other modules are used.
        This will be auto-enabled in the near future.
      - Accounting are done per statement. Stored functions are regarded
        as part of the original statement.
      - For stored procedures the accounting are done per statement executed
        in the stored procedure. CALL will not be accounted because of this.
      - FLUSH commands will not be accounted for. This is to ensure that
        FLUSH QUERY_RESPONSE_TIME is not part of the statistics.
        (This helps when testing with mtr and otherwise).
      - Use drop_table() instead of ha_drop_table() for internal temporary
        tables to avoid information_schema queries to be categorized as
        write queries.
      - FLUSH QUERY_RESPONSE_TIME_READ and FLUSH QUERY_RESPONSE_TIME_READ
        only resets the corresponding status.
      - FLUSH QUERY_RESPONSE_TIME and FLUSH QUERY_RESPONSE_TIME_READ_WRITE or
        changing the value of query_response_time_range_base followed by
        any FLUSH of QUERY_RESPOSNSE_TIME resets all status.
      - query_response_time_flush was removed as it is not needed.
      38177df5
    • Monty's avatar
      Optimize checking if a table is a statistics table · 1eb005b9
      Monty authored
      1eb005b9
  2. 15 Jun, 2024 5 commits
    • Monty's avatar
      MDEV-33152 Add QUERIES to INDEX_STATISTICS · 4ddb1fd7
      Monty authored
      MDEV-33901 INDEX_STATISTICS.QUERIES is incremented additionally for subqueries
      
      Other changes:
      - Do not collect index statistics for system tables like index_stats
        table_stats, performance_schema, information_schema etc as the user
        has no control of these and the generate noise in the statistics.
      4ddb1fd7
    • Monty's avatar
      MDEV-33151 Add more columns to TABLE_STATISTICS and USER STATS · be2cc611
      Monty authored
      MDEV-33881 Userstat skips system tables inconsistently
      MDEV-33913 TABLE_STATISTICS increments ROWS_CHANGED twice upon UPDATE and
                 does not count DELETE
      
      Columns added to TABLE_STATISTICS
      - ROWS_INSERTED, ROWS_DELETED, ROWS_UPDATED, KEY_READ_HITS and
        KEY_READ_MISSES.
      
      Columns added to CLIENT_STATISTICS and USER_STATISTICS:
      - KEY_READ_HITS and KEY_READ_MISSES.
      
      User visible changes (except new columns):
      - CLIENT_STATISTICS and USER_STATISTICS has columns KEY_READ_HITS and
        KEY_READ_MISSES added after column ROWS_UPDATED before SELECT_COMMANDS.
      
      Other changes:
      - Do not collect table statistics for system tables like index_stats
        table_stats, performance_schema, information_schema etc as the user
        has no control of these and the generate noice in the statistics.
      - All row variables that are part of user_stats are moved to
        'struct rows_stats' to make it easy to clear all of them at once.
      - ha_read_key_misses added to STATUS_VAR
      - Fixed that all no tables in 'mysql' schema are not included in userstat.
        A benefit of this is that the server is not reading statistics tables
        if mysql.proc or other tables in mysql is accessed.
      
      Notes:
      - userstat.result has a change of numbers of rows for handler_read_key.
        This is because use-stat-tables is now disabled for the test.
      be2cc611
    • Monty's avatar
      MDEV-33144 Implement the Percona variable slow_query_log_always_write_time · a0cc4a4c
      Monty authored
      This task is inspired by the Percona implementation of
      slow_query_log_always_write_time.
      
      This task implements the variable log_slow_always_query_time (name
      matching other MariaDB variables using the slow query log). The
      default value for the variable is 31536000, which makes MariaDB
      compatible with older installations.
      
      For queries with execution time longer than log_slow_always_query_time
      the variables log_slow_rate_limit and log_slow_min_examined_row_limit
      will be ignored and the query will be written to the slow query log
      if there is no other limitations (like log_slow_filter etc).
      
      Other things:
      - long_query_time internal variable renamed to log_slow_query_time.
      - More descriptive information for "log_slow_query_time".
      a0cc4a4c
    • Monty's avatar
      MDEV-9101 Limit size of created disk temporary files and tables · 37b09810
      Monty authored
      MDEV-33680 Server hangs or assertion fails upon SELECT with
                 limited max_tmp_space_usage
      MDEV-33751 Assertion `thd' failed in int
                 temp_file_size_cb_func(tmp_file_tracking*, int)
      MDEV-34060 Unexpected behavior upon reading I_S.ALL_PLUGINS
                 under limited tmp space.
      MDEV-34142 Server crashes in create_internal_tmp_table with low tmp space limit
      MDEV-34150 Assertion failure in Diagnostics_area::set_error_status upon binary logging hitting tmp space limit
      
      Two new variables added:
      - max_tmp_space_usage : Limits the the temporary space allowance per user
      - max_total_tmp_space_usage: Limits the temporary space allowance for
        all users.
      
      New status variables: tmp_space_used & max_tmp_space_used
      New field in information_schema.process_list: TMP_SPACE_USED
      
      The temporary space is counted for:
      - All SQL level temporary files. This includes files for filesort,
        transaction temporary space, analyze, binlog_stmt_cache etc.
        It does not include engine internal temporary files used for repair,
        alter table, index pre sorting etc.
      - All internal on disk temporary tables created as part of resolving a
        SELECT, multi-source update etc.
      
      Special cases:
      - When doing a commit, the last flush of the binlog_stmt_cache
        will not cause an error even if the temporary space limit is exceeded.
        This is to avoid giving errors on commit. This means that a user
        can temporary go over the limit with up to binlog_stmt_cache_size.
      
      Noteworthy issue:
      - One has to be careful when using small values for max_tmp_space_limit
        together with binary logging and with non transactional tables.
        If a the binary log entry for the query is bigger than
        binlog_stmt_cache_size and one hits the limit of max_tmp_space_limit
        when flushing the entry to disk, the query will abort and the
        binary log will not contain the last changes to the table.
        This will also stop the slave!
        This is also true for all Aria tables as Aria cannot do rollback
        (except in case of crashes)!
        One way to avoid it is to use @@binlog_format=statement for
        queries that updates a lot of rows.
      
      Implementation:
      - All writes to temporary files or internal temporary tables, that
        increases the file size, are routed through temp_file_size_cb_func()
        which updates and checks the temp space usage.
      - Most of the temporary file monitoring is done inside IO_CACHE.
        Temporary file monitoring is done inside the Aria engine.
      - MY_TRACK and MY_TRACK_WITH_LIMIT are new flags for ini_io_cache().
        MY_TRACK means that we track the file usage. TRACK_WITH_LIMIT means
        that we track the file usage and we give an error if the limit is
        breached. This is used to not give an error on commit when
        binlog_stmp_cache is flushed.
      - global_tmp_space_used contains the total tmp space used so far.
        This is needed quickly check against max_total_tmp_space_usage.
      - Temporary space errors are using EE_LOCAL_TMP_SPACE_FULL and
        handler errors are using HA_ERR_LOCAL_TMP_SPACE_FULL.
        This is needed until we move general errors to it's own error space
        so that they cannot conflict with system error numbers.
      - Return value of my_chsize() and mysql_file_chsize() has changed
        so that -1 is returned in the case my_chsize() could not decrease
        the file size (very unlikely and will not happen on modern systems).
        All calls to _chsize() are updated to check for > 0 as the error
        condition.
      - At the destruction of THD we check that THD::tmp_file_space == 0
      - At server end we check that global_tmp_space_used == 0
      - As a precaution against errors in the tmp_space_used code, one can set
        max_tmp_space_usage and max_total_tmp_space_usage to 0 to disable
        the tmp space quota errors.
      - truncate_io_cache() function added.
      - Aria tables using static or dynamic row length are registered in 8K
        increments to avoid some calls to update_tmp_file_size().
      - Added Max_tmp_disk_space_used to slow query log.
      - Fixed some bugs in log_slow_innodb.test
      - Fixed that Filesort_on_disk in slow query log works again
        (A commit in 10.10 caused it to be always 'No')
      - Fixed bug in subselect3.inc which caused following test to use
        heap tables with low value for max_heap_table_size
      - Fixed bug in sql_expression_cache where it did not overflow
        heap table to Aria table.
      - Fixed that MyISAM and Aria parallel repair works with tmp file limit.
        This required to add current_thd to all parallel workers and add
        protection in my_malloc_size_cb_func() and temp_file_size_cb_func() to
        be able to handle shared THD's.  I removed the old code in MyISAM to
        set current_thd() as only worked when using with virtal indexed
        columns and I wanted to keep the Aria and MyISAM code identical.
      - Change variable names in commit to
        max_tmp_session_space_usage and max_tmp_total_space_usage
      - Moved writing to binlog_cache from close_thread_tables() to
        binlog_commit().
      - In select_create() delete cached row events instead of flushing them
        to disk. This was done to avoid possible disk write error in this code.
      
      Other things:
      - Ensure that all handler errors are registered.  Before, some engine
        errors could be printed as "Unknown error".
      - Fixed bug in filesort() that causes a assert if there was an error
        when writing to the temporay file.
      - Fixed that compute_window_func() now takes into account write errors.
      - In case of parallel replication, rpl_group_info::cleanup_context()
        could call trans_rollback() with thd->error set, which would cause
        an assert. Fixed by resetting the error before calling trans_rollback().
      Other things:
      - Improved error messages from Aria parallel repair and
        create_internal_tmp_table_from_heap().
      37b09810
    • Monty's avatar
      MDEV-33145 Add FLUSH GLOBAL STATUS · 5b85e660
      Monty authored
      - FLUSH GLOBAL STATUS now resets most global_status_vars.
        At this stage, this is mainly to be used for testing.
      - FLUSH SESSION STATUS added as an alias for FLUSH STATUS.
      - FLUSH STATUS does not require any privilege (before required RELOAD).
      - FLUSH GLOBAL STATUS requires RELOAD privilege.
      - All global status reset moved to FLUSH GLOBAL STATUS.
      - Replication semisync status variables are now reset by
        FLUSH GLOBAL STATUS.
      - In test cases, the only changes are:
        - Replace FLUSH STATUS with FLUSH GLOBAL STATUS
        - Replace FLUSH STATUS with FLUSH STATUS; FLUSH GLOBAL STATUS.
          This was only done in a few tests where the test was using SHOW STATUS
          for both local and global variables.
      - Uptime_since_flush_status is now always provided, independent if
        ENABLED_PROFILING is enabled when compiling MariaDB.
      - @@global.Uptime_since_flush_status is reset on FLUSH GLOBAL STATUS
        and @@session.Uptime_since_flush_status is reset on FLUSH SESSION STATUS.
      - When connected, @@session.Uptime_since_flush_status is set to 0.
      5b85e660
  3. 13 Mar, 2024 7 commits
  4. 12 Mar, 2024 1 commit
    • Alexander Barkov's avatar
      MDEV-33621 Unify duplicate code in my_wildcmp_uca_impl() and my_wildcmp_unicode_impl() · 1e889a6e
      Alexander Barkov authored
      This is a refactoring patch, it does not change the behaviour.
      The MTR tests are being added only to cover the LIKE predicate better.
      (these tests should have been added earlier under terms of MDEV 9711).
      This patch does not need its own specific MTR tests.
      
      Moving the duplicate code into a new shared file ctype-wildcmp.inl
      and including it from multiple places, to define the following functions:
      
      - my_wildcmp_uca_impl(), in ctype-uca.c
      
        For utf8mb3, utf8mb4, ucs2, utf16, utf32, using cs->cset->mb_wc().
        For UCA based collations.
      
      - my_wildcmp_mb2_or_mb4_general_ci_impl(), in ctype-ucs2.c:
      
        For ucs2, utf16, utf32, using cs->cset->mb_wc().
        For general_ci-style collations:
            - xxx_general_ci
            - xxx_general_mysql500_ci
            - xxx_general_nopad_ci
      
      - my_wildcmp_mb2_or_mb4_bin_impl(), in ctype-ucs2.c:
      
        For ucs2, utf16, utf32, using cs->cset->mb_wc().
        For _bin collations:
            - xxx_bin
            - xxx_nopad_bin
      
      - my_wildcmp_utf8mb3_general_ci_impl(), in ctype-utf8.c
      
        Optimized for utf8mb3, using my_mb_wc_utf8mb3_quick().
      
        For general_ci-style collations:
            - utf8mb3_general_ci
            - utf8mb3_general_mysql500_ci
            - utf8mb3_general_nopad_ci
      
      - my_wildcmp_utf8mb4_general_ci_impl(), in ctype-utf8.c
      
        Optimized for utf8mb4, using my_mb_wc_utf8mb4_quick().
      
        For general_ci-style collations:
            - utf8mb4_general_ci
            - utf8mb4_general_nopad_ci
      1e889a6e
  5. 07 Mar, 2024 1 commit
    • Alexander Barkov's avatar
      Extra tests for MDEV-30716 Wrong casefolding in xxx_unicode_520_ci for U+0700..U+07FF · 9e7afa77
      Alexander Barkov authored
      New tests display additional information about characters from the BMP range:
      
      - A summary with a COUNT(*) for all distinct combinations of properties
        telling how the "=" and the "LIKE" predicates compare characters to their
        LOWER() and UPPER() variants.
      
      - A detailed list of trciky characters
        for which the "=" and the "LIKE" predicates compare
        LOWER(c)/UPPER(c) variants as not equal to just "c".
      
      Tricky characters include:
       - Turkish letters: ı - small dotless letter i
       - Croatian letters: precombined contractions for Dž, Dz, Lj, Nj
       - Units of measurement: Ω,K,Å (Ohm, Kelvin, Angstrom)
         These ones look very similar to Greek letter Omega,
         Latin letter Kra, Swedish/Finnish letter A with a ring above.
      9e7afa77
  6. 28 Feb, 2024 5 commits
    • Alexander Barkov's avatar
      MDEV-31531 Remove my_casedn_str() and my_caseup_str() · 929c2e06
      Alexander Barkov authored
      Under terms of MDEV 27490 we'll add support for non-BMP identifiers
      and upgrade casefolding information to Unicode version 14.0.0.
      In Unicode-14.0.0 conversion to lower and upper cases can increase octet length
      of the string, so conversion won't be possible in-place any more.
      
      This patch removes virtual functions performing in-place casefolding:
        - my_charset_handler_st::casedn_str()
        - my_charset_handler_st::caseup_str()
      and fixes the code to use the non-inplace functions instead:
        - my_charset_handler_st::casedn()
        - my_charset_handler_st::caseup()
      929c2e06
    • Vladislav Vaintroub's avatar
      MDEV-32841 Add tests for new counters. · de9c3572
      Vladislav Vaintroub authored
      Only add innodb_async_reads/writes_total_count here.
      For all other counters, writing reproducible tests is rather tricky.
      de9c3572
    • Vladislav Vaintroub's avatar
      MDEV-32841 - review fixes · 59df9f26
      Vladislav Vaintroub authored
      59df9f26
    • Vladislav Vaintroub's avatar
      MDEV-32841 Use chrono::duration<double> instead of chrono::duration<float> · f8bb99bf
      Vladislav Vaintroub authored
      Requested by Marko during review
      f8bb99bf
    • Vladislav Vaintroub's avatar
      MDEV-32841 Provide Innodb async IO statistics · 01466adc
      Vladislav Vaintroub authored
      Provide some statistics about asynchronous IO reads and writes:
       - number of pending operations
       - number of completion callbacks that are currently being executed
       - number of completion callbacks that are currently queued
         (due to restriction on number of IO threads)
       - total number of IOs finished
       - total time to wait for free IO slot
       - total number of completions that were queued.
      
      Also revert tpool InnoDB perfschema instrumentation (MDEV-31048)
      That instrumentation of cache mutex did not bring any revelation (
      the mutex is taken for a couple of instructions), and made it impossible
      to use tpool outside of the server (e.g in mariadbimport/dump)
      01466adc
  7. 21 Feb, 2024 1 commit
    • Yuchen Pei's avatar
      MDEV-28152 Features for sequences · 374783c3
      Yuchen Pei authored
      - Add `as <int_type>` to sequence creation options
        - int_type can be signed or unsigned integer types, including
          tinyint, smallint, mediumint, int and bigint
        - Limitation: when alter sequence as <new_int_type>, cannot have any
          other alter options in the same statement
        - Limitation: increment remains signed longlong, and the hidden
          constraint (cache_size x abs(increment) < longlong_max) stays for
          unsigned types. This means for bigint unsigned, neither
          abs(increment) nor (cache_size x abs(increment)) can be between
          longlong_max and ulonglong_max
      - Truncating maxvalue and minvalue from user input to the nearest max
        or min value of the type, plus or minus 1. When the truncation
        happens, a warning is emitted
      - Information schema table for sequences
      374783c3
  8. 17 Feb, 2024 3 commits
  9. 15 Feb, 2024 1 commit
  10. 14 Feb, 2024 7 commits
    • Sergei Golubchik's avatar
      update 32bit rdiffs · 3ae6680e
      Sergei Golubchik authored
      3ae6680e
    • Yuchen Pei's avatar
      MDEV-33441 Do not deinit plugin variables when retry requested · 068a6819
      Yuchen Pei authored
      After MDEV-31400, plugins are allowed to ask for retries when failing
      initialisation. However, such failures also cause plugin system
      variables to be deleted (plugin_variables_deinit()) before retrying
      and are not re-added during retry.
      
      We fix this by checking that if the plugin has requested a retry the
      variables are not deleted. Because plugin_deinitialize() also calls
      plugin_variables_deinit(), if the retry fails, the variables will
      still be deleted.
      
      Alternatives considered:
      
      - remove the plugin_variables_deinit() from plugin_initialize() error
      handling altogether. We decide to take a more conservative approach
      here.
      
      - re-add the system variables during retry. It is more complicated
      than simply iterating over plugin->system_vars and call
      my_hash_insert(). For example we will need to assign values to
      the test_load field and extract more code from test_plugin_options(),
      if that is possible.
      068a6819
    • Sergei Golubchik's avatar
      MDEV-31857 fix galera.MW-284 · fe07ac31
      Sergei Golubchik authored
      followup for abcd23ad
      fe07ac31
    • Sergei Golubchik's avatar
      MDEV-31857 fix galera.galera_var_notify_ssl_ipv6 · 8dee23cd
      Sergei Golubchik authored
      it was able to enable --ssl-verify-server-cert if explicily requested,
      now it can also disable it, if explicitly requested.
      8dee23cd
    • Monty's avatar
      Improve error message in mysqltest when sync_with_master fails · d6794aa4
      Monty authored
      In case of failure, the something like the following is now printed:
      
      Slave position:  file: binary.000004  position: 3647
      Master position: file: binary.000004  position: 3647
      d6794aa4
    • Monty's avatar
      MDEV-31404 Implement binlog_space_limit · 18dfcfde
      Monty authored
      binlog_space_limit is a variable in Percona server used to limit the total
      size of all binary logs.
      
      This implementation is based on code from Percona server 5.7.
      
      In MariaDB we decided to call the variable max-binlog-total-size to be
      similar to max-binlog-size. This makes it easier to find in the output
      from 'mariadbd --help --verbose'). MariaDB will also support
      binlog_space_limit for compatibility with Percona.
      
      Some internal notes to explain implementation notes:
      
      - When running MariaDB does not delete binary logs that are either
        used by slaves or have active xid that are not yet committed.
      
      Some implementation notes:
      
      - max-binlog-total-size is by default 0 (no limit).
      - max-binlog-total-size can be changed without server restart.
      - Binlog file sizes are checked on startup, or if
        max-binlog-total-size is set to a value > 0, not for every log write.
        The total size of all binary logs is cached and dynamically updated
        when updating the binary log on binary log rotation.
      - max-binlog-total-size is checked against existing log files during
        serverstart, binlog rotation, FLUSH LOGS, when writing to binary log
        or when max-binlog-total-size changes value.
      - Option --slave-connections-needed-for-purge with 1 as default added.
        This allows one to ensure that we do not delete binary logs if there
        is less than 'slave-connections-needed-for-purge' connected.
        Without this option max-binlog-total-size would potentially delete
        binlogs needed by slaves on server startup or when a slave disconnects
        as there are then no connected slaves to protect active binlogs.
      - PURGE BINARY LOGS TO ... will be executed as if
        slave-connectitons-needed-for-purge would be zero. In other words
        it will do the purge even if there is no slaves connected. If there
        are connected slaves working on the logs, these will be protected.
      - If binary log is on and max-binlog-total_size <> 0 then the status
        variable 'Binlog_disk_use' shows the current size of all old binary
        logs + the state of the current one.
      - Removed test of strcmp(log_file_name, log_info.log_file_name) in
        purge_logs_before_date() as this is tested in can_purge_logs()
      - To avoid expensive calls of log_in_use() we cache the result for the
        last log that is in use by a slave. Future calls to can_purge_logs()
        for this binary log will be quickly detected and false will be returned
        until a slave starts working on a new log.
      - Note that after a binary log rotation caused by max_binlog_size,
        the last log will not be purged directly as it is still in use
        internally. The next binary log write will purge binlogs if needed.
      
      Reviewer:Kristian Nielsen <knielsen@knielsen-hq.org>
      18dfcfde
    • Sergei Golubchik's avatar
      update C/C · 9933a8cc
      Sergei Golubchik authored
      9933a8cc