1
0
mirror of https://github.com/MariaDB/server.git synced 2026-10-23 18:49:29 +03:00
Commit Graph

10862 Commits

Author SHA1 Message Date
Jan Lindström
df2582990d MDEV-33763 : Buffered error logging for Server error log
New read-only system variables (set at startup, need --log-error):
* log_error_file_buffer_size: error log buffer size, default 0 (off)
* log_error_file_rotate_size: rotate the error log above this size,
  default 1073741824
* log_error_file_rotations: number of rotated files kept, default 0

Changes:
* Write the error log through the logger service, which batches writes
  in an in-memory buffer, when log_error_file_buffer_size is set.
* print_buffer_to_file() uses one static buffer, allocated on first use
  (MAX_LOG_BUFFER_SIZE+1), grown as needed and freed at shutdown.
* vprint_msg_to_log() writes lines longer than 1024 bytes in full, up
  to 1 MB.
* Galera messages use the same error log path. Debug messages are
  written only if wsrep_debug is set.
* Add mtr tests for the three variables, buffered logging, rotation and
  long lines.

Assisted-by: https://mariadb.org/governance/governance-ai-policy/
2026-10-20 09:04:41 +03:00
Dearsh Oberoi
1980747f96 MDEV-35254 Add get_current_thd() service function 2026-07-06 13:44:56 +02:00
Dearsh Oberoi
22228cc1e0 MDEV-35254 refactor: Make my_bit.h an independent header
Removed type aliases and macros defined in my_global.h from my_bit.h,
making it possible to include it in plugins or external code without
pulling in my_global.h
2026-07-06 13:44:56 +02:00
Marko Mäkelä
d6342cca4d Merge 12.3 into 13.0 2026-06-29 07:41:06 +03:00
Marko Mäkelä
3adf432a9f Merge 11.8 into 12.3 2026-06-29 07:40:04 +03:00
Marko Mäkelä
761c2333ca Merge 11.4 into 11.8 2026-06-26 13:46:45 +03:00
Marko Mäkelä
3ce999df6b Merge 10.11 into 11.4 2026-06-26 13:45:38 +03:00
Daniel Black
f249b0196d Merge 10.6 into 10.11 2026-06-26 17:56:20 +10:00
Daniel Black
24ee5fd6bf MDEV-28404 JSON functions don't respect KILL QUERY
Or max_statement_time limit or MAX_DEPTH.

Correct interuptability and depth checking of:
* JSON_CONTAINS
* JSON_CONTAINS_PATH
* JSON_EXISTS
* JSON_EXTRACT
* JSON_KEYS
* ST_GeomFromGeoJSON

Populate in the json library the killed as a specific
error message. As the json library has a killed_ptr
is approprate it handles it.

As json_report_error now processes the killed there's
no need of thd->check_killed().

Verified that the path after every json_scan_next, the
location of checking the killed_ptr, reports errors
correctly.
2026-06-26 07:32:21 +03:00
Daniel Black
0ff2fda7b3 MDEV-30518: JSON functions cannot be killed on big-endian (backport)
Backport to 10.6 without JSON_OVERLAPS

The json_engine killed_ptr was of type uchar however the enum
in the server is dependant on the architecture. On big-endian
architectures like IBM Z, retreiving a uchar* retreived the
unmodifed part of the THD->kill enum location and was always 0.

As C++11 allows enums to inherit a type, used uint32_t as the base
class of killed_state type in the server and used uint32_t in the
json library.

reload_acl_and_cache required an expression change to avoid
the compile error:
sql/sql_reload.cc:472:24: error: enumerated and non-enumerated
type in conditional expression [-Werror=enum-conversion]
  472 |  return result || (thd ? thd->killed : 0);

Added the kill_ptr assignment the following functions can be
killed:
* Item_func_json_depth::val_int
* Item_func_json_type::val_str
* Item_func_json_length::val_int

Item_func_json_array_append::val_str, check_killed() only applied
to json_error: label and not return_null.

Item_func_json_format::val_str(), corresponding to the SQL,
json_compact, json_detailed, json_loose - add debug instrumentation
for the func_json_notembedded test.

MDEV-26726 (fcd345de48) added a json_pause_execution sync point
however the test case used debug_max_statement_time, which doesn't
exist. Fix the sync point name in the test.
2026-06-26 07:32:21 +03:00
Daniel Black
2f46361ed6 MDEV-37615: Clang based static analysis false postive reports on UNINIT_VAR
Clang upstream bug https://github.com/llvm/llvm-project/issues/173210
shows that a "int x=x" construct will in the intermediate representation
have code to read from x. With this generated sanitizer=undefined and
static analyzers will all see the uninitialized read and write.

Because clang has a stronger implementation of following paths to
uninitialized variables, "#define UNINIT_VAR(x) x" is the which
is what our release binaries use is the ideal path for this compiler.

Clang based compilers with error during compilation if any
uninitialized behaviour is detected at compile time because of
0c80ddb519.

Corrects MDEV-36542 - 6fd57f478f.
2026-06-26 07:32:21 +03:00
Kristian Nielsen
37964c65fa Merge 12.3 to 13.0
This patch to mysqldump is only merged partially:

  commit 666ff1db36
  Author: Monty <monty@mariadb.org>
  Date:   Fri May 15 16:39:35 2026 +0300

      MDEV-39519 Change mariadb-dump to use SHOW REPLICA STATUS instead of SHOW SLAVE STATUS

The functionality for --dump-slave cannot be merged as the underlying
functionality was removed in this commit:

  commit 21c940d599
  Author: ParadoxV5 <paradox.ver5@gmail.com>
  Date:   Thu Dec 4 21:22:20 2025 -0700

      MDEV-37146 mariadb-dump: Replace SHOW SLAVE STATUS usage with information_schema.SLAVE_STATUS

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2026-06-16 12:24:32 +02:00
Kristian Nielsen
fcc5fc8916 Merge 11.8 to 12.3
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2026-06-15 16:53:03 +02:00
Kristian Nielsen
420e28ce28 Merge 11.4 to 11.8
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2026-06-15 15:15:10 +02:00
Kristian Nielsen
85ec122c15 Merge 10.11 to 11.4
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2026-06-15 12:50:45 +02:00
Alessandro Vetere
fa4f6a6194 MDEV-39600 Reduce contention in buf_flush_ahead()
When calling buf_flush_ahead() with furious=false, the function
updates the async target buf_flush_async_lsn and, if necessary notifies
the page cleaner thread to start flushing more eagerly, to avoid
a long stall later when checkpoint will be required.

When many threads call buf_flush_ahead() with furious=false, if
the update of buf_flush_async_lsn is gated inside
buf_pool.flush_list_mutex, this can cause significant contention,
just to deliver the new buf_flush_async_lsn value and a potential
notification to the page cleaner thread.

This commit enables, for the non furious case, lock-free update
of buf_flush_async_lsn and lock-free check of the page cleaner idle
flag, to avoid the contention on buf_pool.flush_list_mutex.
The lock is acquired by the CAS-loop winner thread and only
after the page cleaner is observed idle.
The cleaner clears buf_flush_async_lsn via CAS, so a concurrent
lock-free bump is preserved across the clear.
Since the reads are not protected by the mutex, there is a chance that
the decision to not signal the page cleaner thread is wrong.
In the worst case though, under sustained redo-log pressure,
eventually a wakeup signal will be delivered to the page cleaner thread
anyway, so the risk of a long stall is limited.

Similar reasoning applies to the possibly wrong decision taken by the
page cleaner thread to go to idle: eventually it will be woken up.
2026-05-28 11:22:47 +02:00
Oleksandr Byelkin
9f98f82b14 Merge branch '11.8' into 12.3 2026-05-26 21:15:58 +02:00
Oleksandr Byelkin
f572addcc1 Merge branch '12.3' into 13.0 2026-05-22 09:52:05 +02:00
Oleksandr Byelkin
3f388a1cce Merge branch '11.8' into 12.3 2026-05-22 09:27:18 +02:00
Marko Mäkelä
b89cb5d5c7 Merge mariadb-10.11.17 into 10.11 2026-05-19 08:12:14 +03:00
Daniel Black
8923afa5c2 MDEV-39584: update help sql tables and replace KB links
scripts/fill_help_tables.sql from
https://github.com/mariadb-corporation/mariadb-docs/ as of
3fb208fcdfed06beb52ef9e305017de2387ff012

Other URL changes are taken from the HTTP redirection URL
from the old KB.

Some test cases where impacted:
* ps_missed_cmds{,_bin_prot} - used a topic_id of 0 that is
 now used, used MAX_INT instead.

* range_notembedded used the help data as a test case. As its not
  a stable table data, replaces with static data. Test case valid
  by ensuring the ANALYZE EXPLAIN and optimizer trace had the same
  structure. Also valided the MDEV-24739/MDEV-25069 bug fixes from
  where the test case originaled, when reverted, exhibited the
  previous behavour before the bug fixes.
2026-05-15 13:30:21 +10:00
Daniel Black
509e40e706 MDEV-30518: JSON functions cannot be killed on big-endian
The json_engine killed_ptr was of type uchar however the enum
in the server is dependant on the architecture. On big-endian
architectures like IBM Z, retreiving a uchar* retreived the
unmodifed part of the THD->kill enum location and was always 0.

As C++11 allows enums to inherit a type, used uint32_t as the base
class of killed_state type in the server and used uint32_t in the
json library.

reload_acl_and_cache required an expression change to avoid
the compile error:
sql/sql_reload.cc:472:24: error: enumerated and non-enumerated
type in conditional expression [-Werror=enum-conversion]
  472 |  return result || (thd ? thd->killed : 0);

Added the kill_ptr assignment the following functions can be
killed:
* Item_func_json_depth::val_int
* Item_func_json_type::val_str
* Item_func_json_length::val_int

Item_func_json_array_append::val_str, check_killed() only applied
to json_error: label and not return_null.

Item_func_json_overlaps::val_bool ensure check_killed() is called.

Item_func_json_format::val_str(), corresponding to the SQL,
json_compact, json_detailed, json_loose - add debug instrumentation
for the func_json_notembedded test.

MDEV-26726 (fcd345de48) added a json_pause_execution sync point
however the test case used debug_max_statement_time, which doesn't
exist. Fix the sync point name in the test.
2026-05-14 08:44:01 +10:00
Oleksandr Byelkin
9cb70f0220 Merge branch '11.4' into 11.8 2026-05-08 08:11:03 +02:00
Oleksandr Byelkin
7598e4e95d Merge branch '10.11' into 11.4 2026-05-08 08:00:01 +02:00
Oleksandr Byelkin
6828ff7390 Merge branch '10.6' into 10.11 2026-05-08 07:38:22 +02:00
Daniel Black
e4bdee5a0d MDEV-36453 UBSAN: main.mysqltest - runtime error: null pointer
..passed as argument 2, which is declared to never be null
(dynstr_append_mem).

dynstr_append_mem, uses memcpy to append to the string which in the glibc
library is declared to not take null string as the src. Defensively we
declare dynstr_append_mem to not take a null argument too.

mariadb-test, to prevent it calling dynstr_append_mem with a null
mtr variable value, one that hasn't been initialized, we return an
error if the value is null. The result of this is the $6 in the test
case is never assigned a value and would error.

With this resolved, strchr, if the string isn't found, a null pointer is
returned. UBSAN will complain both about incrementing a pointer beyond
the boundary, and also incrementing if it is null.
2026-05-04 17:30:39 +10:00
Michael Widenius
7828fb475b MDEV-32745 Add a simple MySQL to MariaDB upgrade helper
The tool is named mariadb-migrate-config-file.
The main purpose of the tool is to change MySQL option
files to work both for MySQL and MariaDB.
There are options to do the changes in the options file inline,
or at-end-of-file. One can also remove or comment unknown options.

The list of supported options is generated compile time from
mariadbd --help. All server options, including compiled plugins, are
supported.

The bulk of the code comes from Väinö.
Monty has updated it with a lot of extra options.
Wlad helped with cmake integration

Other things:
- Fixed a memory leak in sql_plugin.cc
- plugin-load will now in case of errors try to load all given plugins
  before aborted
- If silent-startup is used, plugin-load will not give errors for
  plugins it cannot load or warnings about plugin marturity level.
- my_rm_tree() will now delete symlinks, not the actual file, if
  MY_NOSYMLINK flag is used.
- my_stat() will now give data for symlink if MY_NOSYMLINKS is used.
- Added 'number of lines' option to mysqltest --cat_file

@Authors: Väinö Mäkelä <vaino.makela@iki.fi>,monty@mariadb.com
2026-05-01 15:14:06 +03:00
Monty
16633ac421 Have mariadbd server read [mariadb-X] and [mariadb-X] sections
X is major version, like mariadb-11 and mariadbd-11

This simplifies my.cnf files supporting many MariaDB versions
2026-05-01 12:29:12 +03:00
Sergei Golubchik
89c933d61c cleanup: remove explicit rounding before decimal2longlong
embed rounding into decimal2longlong instead.
this avoid carry propagation loop on rounding.
and allows decimal2longlong detect truncation correctly
2026-04-30 21:55:42 +02:00
Alexey Botchkov
2ed8c4c812 MDEV-39124 XMLTYPE: allow only well-formed XML.
Necessary checks added to the XMLTYPE.
2026-04-29 14:38:18 +04:00
Alexey Botchkov
855ee88362 MDEV-39210 ExtractValue/UpdateXML crash.
test and a comment fixed.
2026-04-22 21:05:46 +04:00
Marko Mäkelä
58f507206f Merge 10.6 into 10.11 2026-04-20 11:07:30 +03:00
Yuchen Pei
da66549039 MDEV-38179 sysvars tracker: lock only when needed
Lock LOCK_plugin only when the variable is a plugin variable.
Lock LOCK_global_system_variables only when the variable is a
global-only variable or a plugin variable.

Also fix lockless session value for Sys_var_multi_source_ulonglong.

This saves 54 calls to pthread_mutex_lock when constructing the
initial OK packet.

The added testcases do not show the lock savings. They are there to
improve coverage for the MDEV-31609 feature, in light of bugs like
MDEV-39207 and MDEV-39217.
2026-04-20 13:22:56 +10:00
Yuchen Pei
3a7f7ce521 Merge branch '11.4' into 11.8 2026-04-20 13:16:55 +10:00
Alexey Botchkov
8d0feb2072 MDEV-39210 ExtractValue/UpdateXML crash.
XML parser fixed to handle <! and <? correctly.
2026-04-19 00:45:57 +04:00
Mikhail Pochatkin
cbcff6324a MDEV-39173 Replace sprintf with snprintf, remove deprecated pragma
Remove the unscoped #pragma GCC diagnostic ignored
"-Wdeprecated-declarations" from include/violite.h and replace all
sprintf/vsprintf calls with snprintf/vsnprintf across the codebase.

Where possible, pass actual buffer sizes as function parameters
instead of using hardcoded constants or recomputing strlen().
Notable API changes:
- get_date(): added to_len parameter for buffer size
- nice_time(), end_timer() in client/mysql.cc: added buff_size
- generate_new_name(): added name_size parameter
- calc_md5(): added buffer_size parameter (fixes off-by-one)
- MD5_HASH_TO_STRING macro: added _size parameter
- Added MYSQL_UDF_MAX_RESULT_LENGTH constant in mysql_com.h

Also fixed a pre-existing bug in sql/rpl_mi.cc where the ellipsis
"..." was written to the wrong buffer (dbuff instead of buff).

Vendored code is excluded: extra/readline, extra/wolfssl,
wsrep-lib, libmariadb, storage/mroonga/vendor, zlib.
2026-04-16 19:00:12 +10:00
Oleksandr Byelkin
11f408bd3b MDEV-39287 (11.4 part) Fix compilation problems with glibc 2.43/gcc 16/fedora 44
Trick compiler with ==.
2026-04-14 12:19:38 +02:00
Abhishek Bansal
57e5d789b1 MDEV-18386: Add server_audit_timestamp_format to customize audit log timestamps 2026-04-13 21:25:08 +02:00
Bill Jin
9fc925d771 MDEV-35461 Remove redundant checks for standard library functions
Remove function checks that are guaranteed by C89/C99 standards to
reduce the excessive time spent during CMake configuration step. Also,
clean up related compatibility code.

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.
2026-04-02 10:36:09 +11:00
Sergei Golubchik
6660d0bdd7 Merge branch '12.3' into 13.0
changed deprecation version for wsrep_slave_FK_checks,
because it was just deprecated this month
2026-03-27 14:15:54 +01:00
Marko Mäkelä
02aedc1065 Merge 11.8 into 12.3 2026-03-24 09:49:17 +02:00
Marko Mäkelä
e6b8cacfb9 Merge 11.4 into 11.8 2026-03-23 11:57:44 +02:00
Marko Mäkelä
3fe04b1e18 Merge 10.11 into 11.4 2026-03-17 11:30:41 +02:00
Marko Mäkelä
1e639cb76d Merge 10.6 into 10.11 2026-03-17 11:05:34 +02:00
Vladislav Vaintroub
8ac04937fb MDEV-37788 fix uintNkorr/intNstore macros to avoid unaligned access
Replaced macros with optimized inline functions, that use memcpy
instead of unaligned access (translates to single instruction
on architectures we support). Used compiler byteswap intrinsics
where appropriate.

Removed byte_order_generic.h as well as Intel specific headers
byte_order_generic_{x86|x86_64}.h

Added some casts to places where intNstore writes into "const char*".
2026-03-13 08:27:46 +01:00
Marko Mäkelä
a6c9013965 Merge 10.11 into 11.4 2026-03-11 14:18:49 +02:00
Marko Mäkelä
072c7dc774 MDEV-38671: Default to large innodb_buffer_pool_size_max (except on AIX)
my_large_virtual_alloc(): If large page allocation fails, clear
my_use_large_pages. Outside large page allocation (and IBM AIX),
invoke mmap(2) with PROT_NONE so that no page table entries will
have to be allocated. Also, fix the error reporting.

my_virtual_mem_commit(): Do not set the Linux specific flag MAP_POPULATE
because it would introduce a performance regression on startup.
There is a better, system-wide way to disable the overcommit:

	sudo sysctl vm.overcommit_memory=2

HAVE_UNACCESSIBLE_AFTER_MEM_DECOMMIT: Remove. We will always make
the virtual memory unaccessible, so that the operating system
can deallocate the page table entries.

buf_pool_t::create(): Skip the my_virtual_mem_commit() on AIX only.

buf_pool_t::page_guess(): Unconditionally check if the pointer is
within the currently allocated buffer pool.

innodb_buffer_pool_size_max: On 64-bit systems other than IBM AIX,
we will default to 8 TiB.

On 32-bit systems, we retain the default innodb_buffer_pool_size_max=0,
that is, by default, SET GLOBAL innodb_buffer_pool_size=... will be
unable to increase from the initial value.

There is no functional change to the startup logic that adjusts
innodb_buffer_pool_size_max to be at least innodb_buffer_pool_size
rounded up to the extent size (2 MiB on 32-bit, 8 MiB on 64-bit).
2026-03-02 11:30:56 +02:00
Thirunarayanan Balathandayuthapani
e5fed9eaf4 MDEV-36436 Assertion "unexpected references" == 0 after ALTER IGNORE TABLE
Problem:
=========
An assertion failure occurs in InnoDB during consecutive
ALTER TABLE operations using the COPY algorithm. The crash
happens during the table rename phase because the
source table (dict_table_t::n_ref_count) is non-zero, despite
the thread holding an exclusive Metadata Lock (MDL).

Reason:
========
When ALTER IGNORE TABLE is executed via the COPY algorithm,
it generates undo logs for every row inserted into the
intermediate table (e.g., #sql-alter-...). The background Purge
Thread, responsible for cleaning up these undo logs, attempts
to take an MDL on the table to prevent the table from
being dropped while in use.

Race condition:
==================
First ALTER: Creates #sql-alter-, copies data, and renames it to t1.

Purge Activation: The Purge thread picks up the undo logs from step 1.
It takes an MDL on the temporary name (#sql-alter-) and increments
the table's n_ref_count.

Identity Shift: InnoDB renames the physical table object to t1, but
the Purge thread still holds a reference to this object.

Second ALTER: Starts a new copy process. When it attempts to rename
the "new" t1 to a backup name, it checks if n_ref_count == 0.
Because the Purge thread is still "pinning" the object to
clean up logs from the first ALTER, the count is > 0,
triggering the assertion failure.

Solution:
========
ALTER IGNORE TABLE needs row-level undo logging to easily
roll back the last inserted row in case of duplicate key errors.
By discarding the last undo log record after inserting each row,
purge will not process any log records generated by
ALTER IGNORE TABLE, preventing unexpected access from the purge
subsystem during subsequent DDL operations.

Make skip_alter_undo (1-bit) to (2-bit enum)
to support different ALTER operation modes:

- NO_UNDO (0): Normal mode with standard undo logging
- SKIP_UNDO (1): ALTER mode that skips undo logging
- IGNORE_UNDO (2): ALTER IGNORE mode that rewrites undo blocks

trx_undo_report_row_operation(): Add ALTER IGNORE undo
rewriting logic. Store old undo record info before writing
new records for IGNORE_UNDO mode. Reset undo top_offset
to maintain only latest insert undo

row_ins_clust_index_entry_low(): Prevent ALTER IGNORE from
using bulk insert optimization. since it requires to write
undo log for each row operation that's incompatible with
existing bulk operation.
2026-02-26 13:18:23 +05:30
Marko Mäkelä
e23282a068 MDEV-19929 Add a startup message about PAUSE instruction timing
On IA-32 and AMD64 (x86-64) CPU implementations, the latency of the
PAUSE instruction (REPZ NOP that was repurposed from a no-operation
on the Intel Pentium 4) can vary a lot, and we may adjust the
my_cpu_relax_multiplier accordingly. Let us display the value of
that variable on startup if --log-warnings=3 or larger was specified.

Microsoft Windows is available for multiple instruction set architectures.
Therefore, we had better not assume that defined(_WIN32) implies the
availability of a PAUSE instruction.

Reviewed by: Sergey Vojtovich
2026-02-20 08:33:35 +02:00
Mohammad El-Shennawy
637f8c4db7 MDEV-21543: Speed up VARCHAR pad space handling
- Scoped partial optimization for MDEV-21543 improving
PAD SPACE collations for multibyte character sets in
HA_KEYTYPE_VARTEXT1.
- This keeps the old behavior for other cases until
MDEV-38712 is resolved.
- Benchmark: see zulip topic in the PR description
- Results:
- ~3.1% lower wall-clock time
- ~2.1% fewer CPU cycles
- ~0.5% fewer retired instructions
- ~0.7% fewer branch mispredictions
2026-02-19 17:21:43 +02:00