Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-30281

MTR usability improvements (config file and misc features)

    XMLWordPrintable

Details

    • Q3/2026 Server Maintenance, Q3/2026 Server Development

    Description

      A set of independent quality-of-life improvements to the MTR harness (mariadb-test-run.pl), covering four areas: reading options from a standard config file, trimming noisy failure reports, running test features, and debugger options.

      Each item is self-contained and lands as its own commit; command-line options are off by default and preserve existing behaviour unless requested.

      1. Configuration from an option file

      MTR now reads its own options from the standard MariaDB option files, from the [mtr] section. Command-line options take precedence over the file.

      • Default lookup follows Configuring MariaDB with Option Files (global, server and user configs); ~/.my.cnf is read last.
      • The default search covers the Unix locations only (no Windows directories, no my.ini); on Windows, or any non-standard setup, use an explicit MTR_CONFIG / --defaults-file, which work on every platform.
      • MTR_CONFIG env var selects a custom config location; when set, no other file is read.
      • Reuses the in-tree My::Config parser (no third-party module). A new load_defaults() in mariadb-test-run.pl merges [mtr] options into @ARGV, separated from command-line options by an ---end-of-config--- marker so error reporting can name the source.
      • My::Config extended to support !includedir, skip whitespace-only lines, and ignore unknown ! directives instead of failing.

      Standard defaults options are wired in, mirroring libmariadb's my_load_defaults():

      Option Meaning
      --no-defaults do not read any option file
      --defaults-file read [mtr] from this file only
      --defaults-extra-file read this file in addition
      --defaults-group-suffix also read [mtr<suffix>]
      --print-defaults print the [mtr] options and exit
      --mtr-config-only (alias -M) read [mtr] from --defaults-file/--defaults-extra-file only, without also using them as the server template

      --defaults-file / --defaults-extra-file keep their existing MTR meaning as the server config template too; the two consumers read different groups of the same file. Command line overrides MTR_CONFIG/MTR_CONFIG_EXTRA and the group-suffix env vars.

      --mtr-config-only (-M) opts out of that dual use: the file is then read for [mtr] only and dropped from @ARGV, so it is not also applied as the server template. It may be given on the command line, or set inside the [mtr] section itself (applied on the fly while [mtr] is read) — so a single mtr-config-only line turns any --defaults-file into an MTR-only config.

      -M is only relevant for a command-line --defaults-file / --defaults-extra-file (the dual-use options). The MTR_CONFIG / MTR_CONFIG_EXTRA env vars are read only for [mtr] and never reach the template consumer, so they are mtr-config-only already and -M is a no-op for them.

      Config error reporting

      Every wrong setting in a config file now fails with a clean file:line: reason message, without a Perl stack trace or source-code location, and it is clear whether a bad option came from the config file or the command line.

      2. Trimming noisy failure reports

      Crash reports and shutdown-warning dumps could emit the entire server error log and every suspicious line with no limit. New options bound them.

      Head/tail trimming

      Option Meaning
      --head-log=N keep first N lines of the server error log
      --tail-log=N keep last N lines; combine with --head-log to keep both ends
      --head-warnings=N keep first N suspicious shutdown-warning lines
      --tail-warnings=N keep last N; combine with --head-warnings
      --head=N shortcut: head-* = N, tail-* = 0
      --tail=N shortcut: tail-* = N, head-* = 0

      N=0 keeps nothing; a negative value keeps everything; trimmed output is marked with < snip N lines >.

      Stripping boilerplate

      Option Removes
      --strip-hints bug-reporting hint paragraphs: the server log's, My::CoreDump's "Output from gdb follows", and MTR's own end-of-run "report this error" bug-tracker block
      --strip-limits the "Resource Limits" table read from /proc/self/limits
      --strip-backtrace the server's own my_print_stacktrace backtrace (the gdb/lldb core backtrace is kept)
      --strip-log convenience alias enabling all three

      All stripping runs before head/tail trimming, so those line counts apply to the already-stripped log. --strip-backtrace treats the backtrace as a bounded block (state machine) rather than matching lines everywhere.

      3. Running test features

      • --suites=!NAME — exclude a suite. Positive names (or the default set) form the base; every !-name is removed from it. Accumulates across the config file and command line, so a command-line exclusion trims the file-configured set. Ignores the -<overlay> suffix (so !rpl removes rpl-).
      • --combination-select=N (alias -c) — run only the Nth combination of a .combinations file (1-based; negative counts from the end, -1 = last). Applied in the single point where every .combinations file is read. Ignored when --combination is given.
      • --list-combinations (alias --lc) — print a test's available combinations in the selectable test,combination form and exit. Each printed line round-trips back into mtr. Multi-dimension tests list the full product.
      • --exit-line=N (alias -l) — stop the test before the command at line N of the test file, exactly as if an --exit directive were placed there. Implemented as a mysqltest option and forwarded by mtr; gated to the top-level test file so line numbers of sourced includes never trigger it.

      4. Debugger options

      Running external tools under a debugger

      New --exec-rr / --exec-gdb options run every mysqltest --exec command under a wrapper (rr record, or gdb --args in a terminal), so external tools invoked by tests (myisampack, myisamchk, ...) can be traced or debugged without naming them.

      • My::Debugger: any debugger with an exec template auto-registers an --exec-<dbg> option; pre_setup() exports MYSQLTEST_EXEC_WRAP (plus _RR_TRACE_DIR for rr).
      • do_exec() injects the wrapper into the command line after any leading shell NAME=VALUE assignments, so the tool — not the assignment word — is wrapped. The implicit /bin/sh -c from popen() provides the shell layer.

      Configurable terminal

      The terminal emulator for interactive debuggers (--gdb, --exec-gdb, ...) was hard-coded to xterm; it is now configurable via the --terminal option or the MTR_TERM environment variable (the option takes precedence). The template expands two placeholders — {title} (window title) and {command} (the debugger invocation) — and the default xterm -title {title} -e {command} preserves the previous behaviour. For example: --terminal='gnome-terminal --title={title} -- {command}'.

      5. Faster test collection (~3x)

      Locating each test's .result/.rdiff files used a per-test glob keyed on the test name, which forced a full read of the suite's result directory on every test — and twice over, once for each extension — so collection cost grew with tests × directory size. Each result directory is now read once and its .result/.rdiff files indexed by base test name (the leading run before the first . or ,); every test then looks its files up in that cache. The glob was only a coarse prefilter — the existing regex still does the real matching — so the candidate set, and the resulting test list, is byte-for-byte identical.

      Collecting all default suites (6548 tests, warm cache): collection time 13.1s → 4.5s (~2.9×), directory-open syscalls 23026 → 5284.

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              midenok Aleksey Midenkov
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 10d Original Estimate - 10d
                  10d
                  Remaining:
                  Time Spent - 13.25d Remaining Estimate - 2d
                  2d
                  Logged:
                  Time Spent - 13.25d Remaining Estimate - 2d
                  13.25d

                  Git Integration

                    Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.