1
0
mirror of https://github.com/MariaDB/server.git synced 2025-04-18 21:44:20 +03:00

202987 Commits

Author SHA1 Message Date
Vladislav Vaintroub
fc60b89d0c MDEV-36283 "OpenEvent() failed" fatal error in mariadb-upgrade-service
The issue occurs when mariadb-upgrade-service shuts down the server it
started. There is a race condition where the server is online and
responsive to pings but has not yet created the named Windows shutdown
event.

This fix refactors the startup/shutdown logic to ensure startup waits for
the shutdown event. Additionally, mariadb-admin is unnecessary, as
waiting for the named pipe is already sufficient.
2025-03-31 18:37:06 +02:00
Sergei Golubchik
730dcf7e6d Merge branch '10.6' into 10.11 2025-03-31 17:57:43 +02:00
Sergei Golubchik
6e339baad5 MDEV-28908 Confusing documentation and help output for --ssl-verify-server-cert
use the same generic help text as in 11.4+
2025-03-31 17:57:40 +02:00
Sergei Golubchik
7d17ee97c2 MDEV-36437 mariabackup - confusing error message when running out of file handles with partitioned MyISAM 2025-03-31 17:57:35 +02:00
mariadb-DebarunBanerjee
77bebe9eb0 MDEV-36226 Stall and crash when page cleaner fails to generate free pages during Async flush
During regular iteration the page cleaner does flush from flush list
with some flush target and then goes for generating free pages from LRU
tail. When asynchronous flush is triggered i.e. when 7/8 th of the LSN
margin is filled in the redo log, the flush target for flush list is
set to innodb_io_capacity_max. If it could flush all, the flush
bandwidth for LRU flush is currently set to zero. If the LRU tail has
dirty pages, page cleaner ends up freeing no pages in one iteration.
The scenario could repeat across multiple iterations till async flush
target is reached. During this time the DB system is starved of free
pages resulting in apparent stall and in some cases dict_sys latch
fatal error.

Fix: In page cleaner iteration, before LRU flush, ensure we provide
enough flush limit so that freeing pages is no blocked by dirty pages
in LRU tail. Log IO and flush state if double write flush wait is long.

Reviewed by: Marko Mäkelä
2025-03-31 19:09:23 +05:30
Vladislav Vaintroub
8363d05f4d Fix Windows build to use dynamic DLL runtime (MD) by default
This change partially reverts commit b60aee58c7fda4c062f

Previously, we compiled with the flags:
/MT /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib,
which resulted in a non-standard setup where the Universal C Runtime
(UCRT) was dynamically linked, but the compiler runtime was statically
linked. Goal was to reduce runtime dependency, while still using dynamic
CRT

However, now now causes subtle static initialization issues
(and also some problems with MSVC ASAN)

To fix, we now use standard /MD, so both C runtime and compiler runtime
dynamically linked. MSVC redistributable DLL (vcruntime140.dll) is
required on the system, similar to version 10.4.

Our packaging, both zip and MSI, is already prepared for it.
2025-03-31 15:37:10 +02:00
Sergei Golubchik
8896de2baa MDEV-35746 support fmtlib-11.1.0
in 11.1.0 fmtlib removed support for FMT_STATIC_THOUSANDS_SEPARATOR
https://github.com/fmtlib/fmt/commit/b3ccc2d210

to keep :L format working we need to use a proper std::locate now.

use a custom our own locale which is the same as the default "C" one
but uses comma as a thousand separator. Because any named locale,
like "en_US.UTF-8" is not guaranteed to exist on the target system.

Let's create a locale statically, this means there's no overhead
for SFORMAT calls unless {:L} is used. For {:L} there's ~20% slowdown.
2025-03-31 15:37:10 +02:00
Sergei Golubchik
56b19ac030 MDEV-35953 mysql_stmt_errno() returns 0 after an error in mysql_stmt_execute()
The goal of the fix for MDEV-34718 was to avoid
Diagnostics_area::reset_diagnostics_area() changing
DA_OK_BULK to DA_EMPTY for bulk operations.

But it was too indiscriminative and also didn't reset DA_ERROR
if the bulk operation was in progress. This was leaving Diagnostics_area
in the inconsistent state: the status was DA_ERROR, but sql_errno was 0.

Fix it to reset the DA_ERROR status as reset_diagnostics_area()
is supposed to do.
2025-03-31 15:37:10 +02:00
Sergei Golubchik
0b37c2e7a8 MDEV-36084 mariadb-hotcopy requires '--port' set for operation since 10.11 2025-03-31 15:37:10 +02:00
Sergei Golubchik
51cc77f212 Merge branch '10.5' into 10.6 2025-03-31 12:12:50 +02:00
Sergei Golubchik
da9d575516 MDEV-35653 Assertion `commit_trx' failed in int innobase_commit(handlerton*, THD*, bool)
cherry-pick adc1beb8680f from 11.7
2025-03-31 11:38:28 +02:00
Sergei Golubchik
402595f138 fix main.timezone test for DST 2025-03-31 11:10:12 +02:00
Marko Mäkelä
30140c066d MDEV-32148 fixup: replace timestamp on Windows 2025-03-29 12:17:47 +02:00
Marko Mäkelä
f56099a95d Fix some tests mainly on Valgrind 2025-03-29 10:14:56 +02:00
Kristian Nielsen
8010a4128d MDEV-36424: binlog_encryption.encrypted_master_switch_to_unencrypted_gtid Fails in BB 11.4+
The test case was missing a wait for the SQL thread to complete its work before checking the value of @@GLOBAL.gtid_slave_pos.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2025-03-28 19:20:16 +01:00
Marko Mäkelä
f5bd250f5b Merge 10.11 into 11.4 2025-03-28 13:55:21 +02:00
Marko Mäkelä
7335e9b8ef Merge 10.6 into 10.11 2025-03-28 10:55:40 +02:00
Marko Mäkelä
31c06951c6 MDEV-36420 Assertion failure in SET GLOBAL innodb_ft_aux_table
innodb_ft_aux_table_validate(): If the table is found in InnoDB
but not valid for the parameter, only invoke dict_sys.unlock() once.

This fixes a regression due to MDEV-36122.
2025-03-28 09:05:20 +02:00
Marko Mäkelä
1b9d5cdb83 MDEV-35813: Valgrind test fixup
log_checkpoint(): In cmake -DWITH_VALGRIND=ON builds, let us
wait for all outstanding writes to complete, in order to
avoid an unexpectedly large number of innodb_log_writes
in the test innodb.page_cleaner.
2025-03-28 08:38:04 +02:00
Julius Goryavsky
c61345169a galera tests: synchronization after merge 2025-03-28 02:53:59 +01:00
Vladislav Vaintroub
da20e4d8a5 Fix PCRE2 10.45 build on Windows as an external project
PCRE2 10.45 sets cmake_minimum_required to version 3.15.
With that, on MSVC, compile flags for choosing C runtime (/MT, /MD, etc.)
are ignored. Instead, CMAKE_MSVC_RUNTIME_LIBRARY must be passed when
building an external project for consistent linkage, if it creates a
static library.
2025-03-27 21:25:05 +01:00
Sergei Golubchik
bc13c8e4ae MDEV-36078 PCRE2 10.45 breaks main.func_regexp_pcre due to change in PCRE
10.45 is correct, update test results to match.

allow builds with <10.45 too (for old distros) but remove the buggy test
2025-03-27 21:25:05 +01:00
Sergei Golubchik
04771ff6b1 MDEV-28209 New mysql_upgrade message on minor-only upgrades is confusing 2025-03-27 21:25:05 +01:00
Sergei Golubchik
bca07a6f88 cleanup: mysql_upgrade.test
make it strict, don't just ignore all the pesky numbers it shows,
replace the current mariadb version with X.Y.Z,
replace first two components of the current version with X.Y
replace the first component (or first-1, if the second is 0) with X

fix perl to write mysql_upgrade_info files in binary mode,
otherwise mariadb-upgrade reads them incorrectly on Windows.
2025-03-27 21:25:05 +01:00
Sergei Golubchik
1cc138958e MDEV-35727 main.mysql-interactive fails in buildbot on debian
fix failing main.mysql-interactive

* increase socat EOF timeout from 0.5s to 10s
* add an explicit exit to not wait 10s (or even 0.5s - the test now
  finishes in 0.15s)
* enable it for libedit
2025-03-27 21:25:05 +01:00
Sergei Golubchik
6aa860be27 MDEV-36268 mariadb-dump used wrong quoting character
use ' not " and use quote_for_equal()
2025-03-27 21:25:05 +01:00
Sergei Golubchik
992d85025c cmake CMP0177 policy, no dot in the install destination path 2025-03-27 21:25:05 +01:00
Marko Mäkelä
027d815546 MDEV-29445 fixup: Make Valgrind fair again
recv_sys_t::wait_for_pool(): Also wait for pending writes, so that
previously written blocks can be evicted and reused.

buf_flush_sync_for_checkpoint(): Wait for pending writes, in order
to guarantee progress even if the scheduler is unfair.
2025-03-27 14:52:07 +02:00
Dmitry Shulga
6e4fa7e5a1 MDEV-36390: Minor refactoring of the method get_expr_query at the classes sp_instr_cpush/sp_instr_cursor_copy_struct
Duplicated code from methods
  sp_instr_cpush::get_expr_query
  sp_instr_cursor_copy_struct::get_expr_query
were extracted to the standalone function get_cursor_query

Additionally, added correct parsing of a cursor definition with
a new line or TAB instead of the space immediately after FOR/IS.
2025-03-27 18:02:37 +07:00
Marko Mäkelä
9a6540cb84 MDEV-29445 fixup: galera_sst_mariabackup_use_memory
The mariadb-backup --use-memory parameter will be trimmed to a multiple
of 8 MiB, or 2 MiB on 32-bit systems.

Also, let us remove a bogus message in mariadb-backup:
Warning: option 'use-memory': signed value -1 adjusted to 8388608
2025-03-27 08:54:00 +02:00
Marko Mäkelä
d68f5ea9f0 MDEV-35000 fixup: galera.MDEV-33136
TRUNCATE TABLE will no longer cause a reload of InnoDB statistics.
RENAME TABLE will.
2025-03-27 08:19:40 +02:00
Marko Mäkelä
ab0f2a00b6 Merge 10.6 into 10.11 2025-03-27 08:01:47 +02:00
Marko Mäkelä
191209d8ab Merge 10.5 into 10.6 2025-03-26 17:09:57 +02:00
Marko Mäkelä
ba81009f63 MDEV-34863 RAM Usage Changed Significantly Between 10.11 Releases
innodb_buffer_pool_size_auto_min: A minimum innodb_buffer_pool_size that
a Linux memory pressure event can lead to shrinking the buffer pool to.
On a memory pressure event, we will attempt to shrink
innodb_buffer_pool_size halfway between its current value and
innodb_buffer_pool_size_auto_min. If innodb_buffer_pool_size_auto_min is
specified as 0 or not specified on startup, its default value will be
adjusted to innodb_buffer_pool_size_max, that is, memory pressure events
will be disregarded by default.

buf_pool_t::garbage_collect(): For up to 15 seconds, attempt to shrink
the buffer pool in response to a memory pressure event.

Reviewed by: Debarun Banerjee
2025-03-26 17:05:48 +02:00
Marko Mäkelä
b6923420f3 MDEV-29445: Reimplement SET GLOBAL innodb_buffer_pool_size
We deprecate and ignore the parameter innodb_buffer_pool_chunk_size
and let the buffer pool size to be changed in arbitrary 1-megabyte
increments.

innodb_buffer_pool_size_max: A new read-only startup parameter
that specifies the maximum innodb_buffer_pool_size.  If 0 or
unspecified, it will default to the specified innodb_buffer_pool_size
rounded up to the allocation unit (2 MiB or 8 MiB).  The maximum value
is 4GiB-2MiB on 32-bit systems and 16EiB-8MiB on 64-bit systems.
This maximum is very likely to be limited further by the operating system.

The status variable Innodb_buffer_pool_resize_status will reflect
the status of shrinking the buffer pool. When no shrinking is in
progress, the string will be empty.

Unlike before, the execution of SET GLOBAL innodb_buffer_pool_size
will block until the requested buffer pool size change has been
implemented, or the execution is interrupted by a KILL statement
a client disconnect, or server shutdown.  If the
buf_flush_page_cleaner() thread notices that we are running out of
memory, the operation may fail with ER_WRONG_USAGE.

SET GLOBAL innodb_buffer_pool_size will be refused
if the server was started with --large-pages (even if
no HugeTLB pages were successfully allocated). This functionality
is somewhat exercised by the test main.large_pages, which now runs
also on Microsoft Windows.  On Linux, explicit HugeTLB mappings are
apparently excluded from the reported Redident Set Size (RSS), and
apparently unshrinkable between mmap(2) and munmap(2).

The buffer pool will be mapped to a contiguous virtual memory area
that will be aligned and partitioned into extents of 8 MiB on
64-bit systems and 2 MiB on 32-bit systems.

Within an extent, the first few innodb_page_size blocks contain
buf_block_t objects that will cover the page frames in the rest
of the extent.  The number of such frames is precomputed in the
array first_page_in_extent[] for each innodb_page_size.
In this way, there is a trivial mapping between
page frames and block descriptors and we do not need any
lookup tables like buf_pool.zip_hash or buf_pool_t::chunk_t::map.

We will always allocate the same number of block descriptors for
an extent, even if we do not need all the buf_block_t in the last
extent in case the innodb_buffer_pool_size is not an integer multiple
of the of extents size.

The minimum innodb_buffer_pool_size is 256*5/4 pages.  At the default
innodb_page_size=16k this corresponds to 5 MiB.  However, now that the
innodb_buffer_pool_size includes the memory allocated for the block
descriptors, the minimum would be innodb_buffer_pool_size=6m.

my_large_virtual_alloc(): A new function, similar to my_large_malloc().

my_virtual_mem_reserve(), my_virtual_mem_commit(),
my_virtual_mem_decommit(), my_virtual_mem_release():
New interface mostly by Vladislav Vaintroub, to separately
reserve and release virtual address space, as well as to
commit and decommit memory within it.

After my_virtual_mem_decommit(), the virtual memory range will be
read-only or unaccessible, depending on whether the build option
cmake -DHAVE_UNACCESSIBLE_AFTER_MEM_DECOMMIT=1
has been specified.  This option is hard-coded on Microsoft Windows,
where VirtualMemory(MEM_DECOMMIT) will make the memory unaccessible.
On IBM AIX, Linux, Illumos and possibly Apple macOS, the virtual memory
will be zeroed out immediately.  On other POSIX-like systems,
madvise(MADV_FREE) will be used if available, to give the operating
system kernel a permission to zero out the virtual memory range.
We prefer immediate freeing so that the reported
resident set size (RSS) of the process will reflect the current
innodb_buffer_pool_size.  Shrinking the buffer pool is a rarely
executed resource intensive operation, and the immediate configuration
of the MMU mappings should not incur significant additional penalty.

opt_super_large_pages: Declare only on Solaris. Actually, this is
specific to the SPARC implementation of Solaris, but because we
lack access to a Solaris development environment, we will not revise
this for other MMU and ISA.

buf_pool_t::chunk_t::create(): Remove.

buf_pool_t::create(): Initialize all n_blocks of the buf_pool.free list.

buf_pool_t::allocate(): Renamed from buf_LRU_get_free_only().

buf_pool_t::LRU_warned: Changed to Atomic_relaxed<bool>,
only to be modified by the buf_flush_page_cleaner() thread.

buf_pool_t::shrink(): Attempt to shrink the buffer pool.
There are 3 possible outcomes: SHRINK_DONE (success),
SHRINK_IN_PROGRESS (the caller may keep trying),
and SHRINK_ABORT (we seem to be running out of buffer pool).
While traversing buf_pool.LRU, release the contended
buf_pool.mutex once in every 32 iterations in order to
reduce starvation. Use lru_scan_itr for efficient traversal,
similar to buf_LRU_free_from_common_LRU_list().

buf_pool_t::shrunk(): Update the reduced size of the buffer pool
in a way that is compatible with buf_pool_t::page_guess(),
and invoke my_virtual_mem_decommit().

buf_pool_t::resize(): Before invoking shrink(), run one batch of
buf_flush_page_cleaner() in order to prevent LRU_warn().
Abort if shrink() recommends it, or no blocks were withdrawn in
the past 15 seconds, or the execution of the statement
SET GLOBAL innodb_buffer_pool_size was interrupted.

buf_pool_t::first_to_withdraw: The first block descriptor that is
out of the bounds of the shrunk buffer pool.

buf_pool_t::withdrawn: The list of withdrawn blocks.
If buf_pool_t::resize() is aborted before shrink() completes,
we must be able to resurrect the withdrawn blocks in the free list.

buf_pool_t::contains_zip(): Added a parameter for the
number of least significant pointer bits to disregard,
so that we can find any pointers to within a block
that is supposed to be free.

buf_pool_t::is_shrinking(): Return the total number or blocks that
were withdrawn or are to be withdrawn.

buf_pool_t::to_withdraw(): Return the number of blocks that will need to
be withdrawn.

buf_pool_t::usable_size(): Number of usable pages, considering possible
in-progress attempt at shrinking the buffer pool.

buf_pool_t::page_guess(): Try to buffer-fix a guessed block pointer.
If HAVE_UNACCESSIBLE_AFTER_MEM_DECOMMIT is set, the pointer will
be validated before being dereferenced.

buf_pool_t::get_info(): Replaces buf_stats_get_pool_info().

innodb_init_param(): Refactored. We must first compute
srv_page_size_shift and then determine the valid bounds of
innodb_buffer_pool_size.

buf_buddy_shrink(): Replaces buf_buddy_realloc().
Part of the work is deferred to buf_buddy_condense_free(),
which is being executed when we are not holding any
buf_pool.page_hash latch.

buf_buddy_condense_free(): Do not relocate blocks.

buf_buddy_free_low(): Do not care about buffer pool shrinking.
This will be handled by buf_buddy_shrink() and
buf_buddy_condense_free().

buf_buddy_alloc_zip(): Assert !buf_pool.contains_zip()
when we are allocating from the binary buddy system.
Previously we were asserting this on multiple recursion levels.

buf_buddy_block_free(), buf_buddy_free_low():
Assert !buf_pool.contains_zip().

buf_buddy_alloc_from(): Remove the redundant parameter j.

buf_flush_LRU_list_batch(): Add the parameter to_withdraw
to keep track of buf_pool.n_blocks_to_withdraw.

buf_do_LRU_batch(): Skip buf_free_from_unzip_LRU_list_batch()
if we are shrinking the buffer pool. In that case, we want
to minimize the page relocations and just finish as quickly
as possible.

trx_purge_attach_undo_recs(): Limit purge_sys.n_pages_handled()
in every iteration, in case the buffer pool is being shrunk
in the middle of a purge batch.

Reviewed by: Debarun Banerjee
2025-03-26 17:05:44 +02:00
Sergei Petrunia
3b4de4c281 MDEV-32084: Assertion in best_extension_by_limited_search() ...
When subquery with LEFT JOIN is converted into semi-join, it is possible
to construct cases where the LEFT JOIN's ON expression refers to a table
in the current select but not in the current join nest. For example:

  t1 SEMI JOIN (
    t2
    LEFT JOIN (t3 LEFT JOIN t4 ON t4.col=t1.col) ON expr
  )

here, ON t4.col=t1.col" has this property. Let's denote it as
ON-EXPR-HAS-REF-OUTSIDE-NEST.

The optimizer handles LEFT JOINs like so:
- Outer join runtime requires that "inner tables follow outer" in
  any join order.
- Join optimizer enforces this by constructing join orders that follow
  table dependencies as they are specified in TABLE_LIST::dep_tables.
- The dep_tables are set in simplify_joins() according to the contents
  of ON expressions and LEFT JOIN structure.

However, the logic in simplify_joins() failed to account for possible
ON-EXPR-HAS-REF-OUTSIDE-NEST. It assumed that references outside of the
current join nest could only be OUTER_REF_TABLE_BIT or RAND_TABLE_BIT.

The fix was to add the missing logic.
2025-03-26 15:52:54 +02:00
Vasilii Lakhin
22efc2c784 Fix typos in C comments inside storage/ 2025-03-26 16:56:50 +04:00
Marko Mäkelä
d1a6792324 MDEV-36122: Protect table references with a lock
dict_table_open_on_id(): Simplify the logic.

dict_stats: A helper for acquiring MDL and opening the tables
mysql.innodb_table_stats and mysql.innodb_index_stats.

innodb_ft_aux_table_validate(): Contiguously hold dict_sys.latch
while accessing the table that we open with dict_table_open_on_name().

lock_table_children(): Do not hold a table reference while invoking
dict_acquire_mdl_shared<false>(), which may temporarily release and
reacquire the shared dict_sys.latch that we are holding.

prepare_inplace_alter_table_dict(): If an unexpected reference to the
table exists, wait for the purge subsystem to release its table handle,
similar to how we would do in case FULLTEXT INDEX existed. This function
is supposed to be protected by MDL_EXCLUSIVE on the table name.
If purge is going to access the table again later during is ALTER TABLE
operation, it will have access to an MDL compatible name for it and
therefore should conflict with any MDL_EXCLUSIVE that would cover
ha_innobase::commit_inplace_alter_table(commit=true).

ha_innobase::rename_table(): Before locking the data dictionary,
ensure that the purge subsystem is not holding a reference to the
table due to the lack of metadata locking, related to FULLTEXT INDEX
or the row-level undo logging of ALTER IGNORE TABLE.

ha_innobase::truncate(): Before locking the data dictionary,
ensure that the purge subsystem is not holding a reference to the
table due to insufficient metadata locking related to an earlier
ALTER IGNORE TABLE operation.

trx_purge_attach_undo_recs(), purge_sys_t::batch_cleanup():
Clear purge_sys.m_active only after all table handles have been released.

With these changes, no caller of dict_acquire_mdl_shared<false>
should be holding a table reference.

All remaining calls to dict_table_open_on_name(dict_locked=false)
except the one in fts_lock_table() and possibly in the DDL recovery
predicate innodb_check_version() should be protected by MDL, but there
currently is no assertion that would enforce this.

Reviewed by: Debarun Banerjee
2025-03-26 14:31:44 +02:00
Marko Mäkelä
4a21cba7fc MDEV-36122 Assertion ctx0->old_table->get_ref_count() == 1
trx_purge_close_tables(): Before releasing any metadata locks (MDL),
release all table references, in case an ALTER TABLE…ALGORITHM=COPY
operation has confused our logic.

trx_purge_table_acquire(), trx_purge_table_open(): Do not acquire any
table reference before successfully acquiring a necessary metadata lock.
In this way, if purge is waiting for MDL, a concurrent
ha_innobase::commit_inplace_alter_table(commit=true) that is holding
a conflicting MDL_EXCLUSIVE will only observe its own reference on
the table that it may need to replace.

dict_acquire_mdl_shared<false>(): Unless we hold an MDL or one is
not needed, do not hold a table reference when releasing dict_sys.latch.
After loading a table into the dictionary cache, we will look up the
table again, because the table could be evicted or dropped while we
were not holding any dict_sys.latch.

Reviewed by: Debarun Banerjee
2025-03-26 14:30:46 +02:00
Marko Mäkelä
6066e5d13c MDEV-36122: Work around missing MDL in purge
prepare_inplace_alter_table_dict(): If an unexpected reference to the
table exists, wait for the purge subsystem to release its table handle,
similar to how we would do in case FULLTEXT INDEX existed. This function
is supposed to be protected by MDL_EXCLUSIVE on the table name.
If purge is going to access the table again later during is ALTER TABLE
operation, it will have access to an MDL compatible name for it and
therefore should conflict with any MDL_EXCLUSIVE that would cover
ha_innobase::commit_inplace_alter_table(commit=true).

This change should prevent race conditions where purge had initially
looked up a table for which row-level undo log records had been
written by ALTER IGNORE TABLE, and purge did not finish before a
subsequent ALTER TABLE is trying to rebuild the table.

trx_purge_attach_undo_recs(), purge_sys_t::batch_cleanup():
Clear purge_sys.m_active only after all table handles have been released.

ha_innobase::truncate(): Before locking the data dictionary,
ensure that the purge subsystem is not holding a reference to the
table due to insufficient metadata locking related to an earlier
ALTER IGNORE TABLE operation.

Reviewed by: Debarun Banerjee
2025-03-26 14:23:45 +02:00
Marko Mäkelä
67caeca284 MDEV-36122: Protect table references with a lock
dict_table_open_on_id(): Simplify the logic.

dict_stats: A helper for acquiring MDL and opening the tables
mysql.innodb_table_stats and mysql.innodb_index_stats.

innodb_ft_aux_table_validate(): Contiguously hold dict_sys.latch
while accessing the table that we open with dict_table_open_on_name().

lock_table_children(): Do not hold a table reference while invoking
dict_acquire_mdl_shared<false>(), which may temporarily release and
reacquire the shared dict_sys.latch that we are holding.

With these changes, no caller of dict_acquire_mdl_shared<false>
should be holding a table reference.

All remaining calls to dict_table_open_on_name(dict_locked=false)
except the one in fts_lock_table() and possibly in the DDL recovery
predicate innodb_check_version() should be protected by MDL, but there
currently is no assertion that would enforce this.

Reviewed by: Debarun Banerjee
2025-03-26 14:22:58 +02:00
Marko Mäkelä
337bf8ac4b MDEV-36122 Assertion ctx0->old_table->get_ref_count() == 1
trx_purge_close_tables(): Before releasing any metadata locks (MDL),
release all table references, in case an ALTER TABLE…ALGORITHM=COPY
operation has confused our logic.

trx_purge_table_acquire(), trx_purge_table_open(): Do not acquire any
table reference before successfully acquiring a necessary metadata lock.
In this way, if purge is waiting for MDL, a concurrent
ha_innobase::commit_inplace_alter_table(commit=true) that is holding
a conflicting MDL_EXCLUSIVE will only observe its own reference on
the table that it may need to replace.

dict_acquire_mdl_shared<false>(): Unless we hold an MDL or one is
not needed, do not hold a table reference when releasing dict_sys.latch.
After loading a table into the dictionary cache, we will look up the
table again, because the table could be evicted or dropped while we
were not holding any dict_sys.latch.

Reviewed by: Debarun Banerjee
2025-03-26 14:22:40 +02:00
Thirunarayanan Balathandayuthapani
1f4a901576 MDEV-36281 DML aborts during online virtual index
Reason:
=======
- InnoDB DML commit aborts the server when InnoDB does online
virtual index. During online DDL, concurrent DML commit
operation does read the undo log record and their related
current version of the clustered index record. Based on the
operation, InnoDB do build the old tuple and new tuple for
the table. If the concurrent online index can be affected
by the operation, InnoDB does build the entry
for the index and log the operation.

Problematic case is update operation, InnoDB does build the
update vector. But while building the old row, InnoDB fails
to fill the non-affected virtual column. This lead to
server abort while build the entry for index.

Fix:
===
- First, fill the virtual column entries for the new row.
Duplicate the old row based on new row and change only the
affected fields in old row based on the update vector.
2025-03-26 12:48:39 +01:00
Thirunarayanan Balathandayuthapani
a390aaaf23 MDEV-36180 Doublewrite recovery of innodb_checksum_algorithm=full_crc32 page_compressed pages does not work
- InnoDB fails to recover the full crc32 page_compressed page
from doublewrite buffer. The reason is that buf_dblwr_t::recover()
fails to identify the space id from the page because the page
has compressed from FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION bytes.

Fix:
===
recv_dblwr_t::find_deferred_page(): Find the page which
has the same page number and try to decompress/decrypt the page
based on the tablespace metadata. After the decompression/decryption,
compare the space id and write the recovered page back to the file.

buf_page_t::read_complete(): Page read from disk is corrupted then
try to read the page from deferred pages in doublewrite buffer.
2025-03-26 12:03:44 +01:00
Marko Mäkelä
19c4e1abe4 MDEV-24035 fixup: GCC 4.8.5 CMAKE_BUILD_TYPE=Debug 2025-03-26 10:40:31 +01:00
Daniel Black
85ecb80fa3 MDEV-36229: Remove CAP_DAC_OVERRIDE CAP_AUDIT_WRITE from AmbientCapabilities
In resolving MDEV-33301 (76a27155b4cd8174e900577dd01df2db1327b120) we
moved all the capabilities from CapabilityBoundingSet to AmbientCapabilities
where only add/moving CAP_IPC_LOCK was intended.

The effect of this is the defaulting running MariaDB HAS the capabiltiy
CAP_DAC_OVERRIDE CAP_AUDIT_WRITE allowing it to access any file,
even while running as a non-root user.

Resolve this by making CAP_IPC_LOCK apply to AmbientCapabilities and
leave the remaining CAP_DAC_OVERRIDE CAP_AUDIT_WRITE to CapabilityBoundingSet
for the use by auth_pam_tool.
2025-03-26 10:50:31 +02:00
Kristian Nielsen
3b3c512feb MDEV-36265: Unique error for changing Domain ID with open temporary tables
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2025-03-26 08:52:23 +01:00
Sergei Petrunia
47d11328c9 MDEV-36381: Comment "Procedure of keys generation ..." is in the wrong place
Move it from the middle of table.cc to sql_select.cc:generate_derived_keys()
2025-03-25 19:05:32 +02:00
Thirunarayanan Balathandayuthapani
2469963f05 MDEV-36270 mariabackup.incremental_compressed fails in 10.11+
- During prepare of incremental backup, mariabackup does create
new file in target directory with default file size of
4 * innodb_page_size. While applying .delta file to corresponding
data file, it encounters the FSP_SIZE modification on page0 and
tries to extend the file to the size which is 4 in our case.
Since the table is in compressed row format, page_size for the
table is 8k. This lead to shrinking of tablespace file from 65536
to 32768. This issue happens only in windows because
os_file_set_size() doesn't check for the current size
and shrinks the file.

Solution:
========
xtrabackup_apply_delta(): Check for the current size before
doing setting size for the file.
2025-03-25 11:56:35 +01:00
Marko Mäkelä
d84ceb586a MDEV-36378 Recognize innodb_purge_rseg_truncate_frequency
In commit bda40ccb854cc1531ec7bd1ab779504c7e00bd87 (MDEV-34803)
there was a spelling mistake that somehow causes the deprecated
parameter innodb_purge_rseg_truncate_frequency to be rejected
at server startup.
2025-03-25 11:48:12 +01:00