Commit graph

202447 commits

Author SHA1 Message Date
Aleksey Midenkov
b8ad202da1 MDEV-34770 UBSAN: runtime error: load of address 0x... with
insufficient space for an object of type 'uchar' in sys_vars.inl

Disable UBSAN for global_var_ptr()/session_var_ptr() (none of
"undefined" suboptions for gcc-13 worked).
2024-12-03 13:49:43 +03:00
Aleksey Midenkov
13f93da1f6 MDEV-33783 CREATE SERVER segfaults on wrong mysql.servers
Do basic checking of mysql.servers compatibility.
2024-12-03 13:49:43 +03:00
Aleksey Midenkov
27c25ceedb MDEV-31030 Assertion `!error' failed in ha_partition::update_row on UPDATE
Removing wrong assertion as division by zero was caused by valid
input.
2024-12-03 13:49:42 +03:00
Aleksey Midenkov
55b5993205 Cleanup: make_keypart_map inline
for easier debugging.
2024-12-03 13:49:42 +03:00
Aleksey Midenkov
3835437eb8 MDEV-15330 Cleanup: load_data.test removed 2024-12-03 13:49:42 +03:00
Aleksey Midenkov
c20f09ddcf Dtrace cmake fix for clang
When there are GCC-incompatible compiler flags dtrace fails like this:

gcc: error: unrecognized command-line option ‘-fno-limit-debug-info’
gcc: error: unrecognized command-line option ‘-mbranches-within-32B-boundaries’
"gcc .dtrace-temp.3fd6bacf.c" failed
Usage /usr/bin/dtrace [--help] [-h | -G] [-C [-I<Path>]] -s File.d [-o <File>]
2024-12-03 13:49:42 +03:00
Jan Lindström
8a32ae5d6d MDEV-32779 : galera_concurrent_ctas: assertion in the galera::ReplicatorSMM::finish_cert()
I could not reproduce reported assertion. However, I could
reporoduce test failure because missing wait_condition
and error in test case. Added missing wait_condition and
fixed error in test case to make test stable.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-12-03 03:19:35 +01:00
Jan Lindström
f219fb8489 MDEV-35355 : Galera test failure on galera_sr.mysql-wsrep-features#165
Problem was that in DeadlockChecker::trx_rollback() we hold lock_sys
before we call wsrep_handle_SR_rollback() where THD::LOCK_thd_data
(and some cases THD::LOCK_thd_kill) are acquired. This is against
current mutex ordering rules.

However, acquiring THD::LOCK_thd_data is not necessary because we
always are in victim_thd context, either client session is rolling
back or rollbacker thread should be in control. Therefore, we should
always use wsrep_thd_self_abort() and then no additional mutexes are
required.

Fixed by removing locking of THD::LOCK_thd_data and using only
wsrep_thd_self_abort(). In debug builds added assertions to
verify that we are always in victim_thd context.

This fix is for MariaDB 10.5 and we already have a test case
that sporadically fail in Jenkins before this fix.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-12-03 03:19:35 +01:00
Jan Lindström
af50783fcd MDEV-35471 : Sporadic failures in the galera_pc_recovery mtr test
For some reason InnoDB was disabled at --wsrep-recover call.
Added --loose-innodb to command like to make sure InnoDB is
enabled.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-12-03 03:19:35 +01:00
Jan Lindström
bf3e16eb81 MDEV-35467 : WSREP: read_completion_condition(): shutdown while in init ()
Ignore expected warning from Galera library when connections
are shutdown.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-12-03 03:19:35 +01:00
Yuchen Pei
d0fcac4450
MDEV-35422 Fix spider group by handler trying to use fake group by fields
This is a fixup of MDEV-26345 commit
77ed235d50.

In MDEV-26345 the spider group by handler was updated so that it uses
the item_ptr fields of Query::group_by and Query::order_by, instead of
item. This was and is because the call to
join->set_items_ref_array(join->items1) during the execution stage,
just before the execution replaces the order-by / group-by item arrays
with Item_temptable_field.

Spider traverses the item tree during the group by handler (gbh)
creation at the end of the optimization stage, and decides a gbh could
handle the execution of the query. Basically spider gbh can handle the
execution if it can construct a well-formed query, executes on the
data node, and store the results in the correct places. If so, it will
create one, otherwise it will return NULL and the execution will use
the usual handler (ha_spider instead of spider_group_by_handler). To
that end, the general principle is the items checked for creation
should be the same items later used for query construciton. Since in
MDEV-26345 we changed to use the item_ptr field instead of item field
of order-by and group-by in query construction, in this patch we do
the same for the gbh creation.

The item_ptr field could be the uninitialised NULL value during the
gbh creation. This is because the optimizer may replace a DISTINCT
with a GROUP BY, which only happens if the original GROUP BY is empty.
It creates the artificial GROUP BY by calling create_distinct_group(),
which creates the corresponding ORDER object with item field aligning
with somewhere in ref_pointer_array, but leaving item_ptr to be NULL.
When spider finds out that item_ptr is NULL, it knows there's some
optimizer skullduggery and it is passed a query different from the
original. Without a clear contract between the server layer and the
gbh, it is better to be safe than sorry and not create the gbh in this
case.

Also add a check and error reporting for the unlikely case of item_ptr
changing from non-NULL at gbh construction to NULL at execution to
prevent server crash.

Also, we remove a check added in MDEV-29480 of order by items being
aggregate functions. That check was added with the premise that spider
was including auxiliary SELECT items which is referenced by ORDER BY
items. This premise was no longer true since MDEV-26345, and caused
problems such as MDEV-29546, which was fixed by MDEV-26345.
2024-12-03 10:32:42 +11:00
Marko Mäkelä
f0961301c8 Merge 11.7 into main 2024-12-02 17:55:44 +02:00
Marko Mäkelä
33907f9ec6 Merge 11.4 into 11.7 2024-12-02 17:51:17 +02:00
Oleksandr Byelkin
5c86f3df33 MDEV-35522: MariaDB Audit does not detect all DCLs forms when masking password
1. skip OR REPLACE
 (to make it filter_query_type made recursive)

2. skip SET STATEMENT ... FOR before checking
statements with passwords
2024-12-02 15:44:12 +01:00
Alexander Barkov
3de412fbe8 MDEV-25593 Assertion `0' failed in Type_handler_temporal_result::Item_get_date on double EXECUTE
When binding to NULL, DEFAULT or IGNORE from an Item value, Item_param did not
change m_type_handler, so its value remained from the previous bind.
Thid led to DBUG_ASSERTs in Item_param::get_date() and
Timestamp_or_zero_datetime_native_null.

Fix:

Set Item_param::m_type_handler to &type_handler_null when
binding from an Item returning NULL.

This patch also fixes MDEV-35427.
2024-12-02 11:19:12 +01:00
Marko Mäkelä
2719cc4925 Merge 10.11 into 11.4 2024-12-02 11:35:34 +02:00
Marko Mäkelä
ecf2e131bd MDEV-31174 fixup: clang++-20 -Wnontrivial-memcall 2024-12-02 11:04:38 +02:00
Marko Mäkelä
4d9548876e MDEV-31340 fixup: clang++-20 -Wdeprecated-literal-operator 2024-12-02 10:44:06 +02:00
Alexander Barkov
01cc92e098 MDEV-34700 Connect SQLite3 MTR test fails due to various charset/collation related output changes
Re-recorded test results with the COLLATE clause, according to MDEV-29446.
2024-12-01 13:52:41 +04:00
Marko Mäkelä
1a9011d273 MDEV-35525: Index corruption in reverse scans
btr_cur_t::search_leaf(): In the BTR_SEARCH_PREV and BTR_MODIFY_PREV
modes, reset the previous search status before invoking
page_cur_search_with_match(). Otherwise, we the search could invoke
in a totally wrong subtree.

This fixes a regression that was introduced in
commit de4030e4d4 (MDEV-30400).
2024-11-29 15:12:20 +02:00
Marko Mäkelä
507323abe6 Cleanup: Remove duplicated code
buf_block_alloc(): Define as an alias in buf0lru.h, which defines
the underlying buf_LRU_get_free_block().

buf_block_free(): Define as an alias of the non-inline function
buf_pool.free_block(block).

Reviewed by: Vladislav Lesin
2024-11-29 14:16:34 +02:00
Marko Mäkelä
998a625d00 Clean up recv_sys.pages bookkeeping
Instead of repurposing buf_page_t::access_time for state()==MEMORY
blocks that are part of recv_sys.pages, let us define an anonymous
union around buf_page_t::hash.  In this way, we will be able to
declare access_time private.

Reviewed by: Vladislav Lesin
2024-11-29 14:16:11 +02:00
Marko Mäkelä
3d23adb766 Merge 10.6 into 10.11 2024-11-29 13:43:17 +02:00
Marko Mäkelä
7d4077cc11 Merge 10.5 into 10.6 2024-11-29 12:37:46 +02:00
Marko Mäkelä
19acb0257e MDEV-35508 Race condition between purge and secondary index INSERT or UPDATE
row_purge_remove_sec_if_poss_leaf(): If there is an active transaction
that is not newer than PAGE_MAX_TRX_ID, return the bogus value 1
so that row_purge_remove_sec_if_poss_tree() is guaranteed to recheck if
the record needs to be purged. It could be the case that an active
transaction would insert this record between the time this check
completed and row_purge_remove_sec_if_poss_tree() acquired a latch
on the secondary index leaf page again.

row_purge_del_mark_error(), row_purge_check(): Some unlikely code
refactored into separate non-inline functions.

trx_sys_t::find_same_or_older_low(): Move the unlikely and bulky
part of trx_sys_t::find_same_or_older() to a non-inline function.

trx_sys_t::find_same_or_older_in_purge(): A variant of
trx_sys_t::find_same_or_older() for use in the purge subsystem,
with potential concurrent access of the same trx_t object from
multiple threads.

trx_t::max_inactive_id_atomic: An Atomic_relaxed alias of the
regular data field trx_t::max_inactive_id, which we
use on systems that have native 64-bit loads or stores.
On any 64-bit system that seems to be supported by GCC, Clang or MSVC,
relaxed atomic loads and stores use the regular load and store
instructions. On -march=i686 the 64-bit atomic loads and stores
would use an XMM register.

This fixes a regression that had been introduced in
commit b7b9f3ce82 (MDEV-34515).
There would be messages
[ERROR] InnoDB: tried to purge non-delete-marked record in index
in the server error log, and an assertion ut_ad(0) would cause a
crash of debug instrumented builds. This could also cause incorrect
results for MVCC reads and corrupted secondary indexes.

The debug instrumented test case was written by Debarun Banerjee.

Reviewed by: Debarun Banerjee
2024-11-29 10:44:38 +02:00
Daniele Sciascia
1d76fdfcb9 Adapt galera_sr.GCF-572 to make it work with innodb-snapshot-isolation
Make galera_sr.GCF-572 behave the same with and without option
innodb-snapshot-isolation. It is sufficient to remove a SELECT
statement from a transaction to delay the creation of the read
view in innodb. Avoiding the detection of a write-write conflict
under innodb-snapshot-isolation.
2024-11-29 08:06:32 +01:00
Daniele Sciascia
e821c9fa7c MDEV-35281 SR transaction crashes with innodb_snapshot_isolation
Ignore snapshot isolation conflict during fragment removal, before
streaming transaction commits. This happens when a streaming
transaction creates a read view that precedes the INSERTion of
fragments into the streaming_log table. Fragments are INSERTed
using a different transaction. These fragment are then removed
as part of COMMIT of the streaming transaction. This fragment
removal operation could fail when the fragments were not part
the transaction's read view, thus violating snapshot isolation.
2024-11-29 08:06:32 +01:00
Alexander Barkov
fdb6db6b47 MDEV-29462 ASAN: heap-use-after-free in Binary_string::copy on DO CONVERT
Item_char_typecast::val_str_generic() uses Item::str_value as a buffer.
Item::val_str_ascii() also used Item::str_value as a buffer.
As a result, str_value tried to copy to itself.

Fixing val_str_ascii() to use a local buffer instead of str_value.
2024-11-28 16:34:32 +04:00
Daniel Black
27c7e73f9a MDEV-35513 fails to compile on riscv32
Misplaced brace in my_rdtsc.h results in RV32 failing to compile.

ref: https://github.com/MariaDB/server/pull/1981/files#r1859762957

Thanks Jessica Clarke for the note.
2024-11-28 03:13:15 +02:00
Jan Lindström
f39217da0c MDEV-35473 : Sporadic failures in the galera_3nodes.galera_evs_suspect_timeout mtr test
Remove unnecessary sleep and replace it with proper wait_conditions.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-11-28 01:02:35 +01:00
Jan Lindström
e7e06b3cb7 MDEV-35481 : ER_LOCK_DEADLOCK instead of ER_NO_SUCH_TABLE in galera_var_ignore_apply_errors
Add wait_condition before select and set wsrep_sync_wait=0 to avoid
possible deadlock.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-11-28 01:02:35 +01:00
Jan Lindström
ff45fdac29 MDEV-35440 : Protocol error warning in the galera_wsrep_schema_detached test
Make sure that node_1 remains in primary view by increasing it's
weight. Add suppression on expected warnings because we kill
node_2.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-11-28 01:02:35 +01:00
Julius Goryavsky
8bc254dd62 MDEV-26516: WSREP: Record locking is disabled in this thread, but the table being modified
We periodically observe assertion failures in the mtr tests,
specifically in the /storage/innobase/row/row0ins.cc file,
following a WSREP error. The error message is: 'WSREP: record
locking is disabled in this thread, but the table being modified
is not mysql/wsrep_streaming_log: mysql/innodb_table_stats.'"
This issue seems to occur because, upon opening the table,
innodb_stats_auto_recalc may trigger, which Galera does not
anticipate. This commit should fix this bug.
2024-11-28 01:02:35 +01:00
Oleksandr Byelkin
0ea19c12fd MDEV-35507 ed25519 authentication plugin create user statement trigger plain text password in audit log
Mask also all cases of "password(PWD" in CREATE/ALTER USER and GRANT.
(minimal fix)
2024-11-27 19:45:33 +01:00
Ivan Prisyazhnyy
f39a61505f MDEV-33075 [backport/2f5174e556] use more robust self-pipe to wake up poll() in break_connect_loop()
Backport of 2f5174e556:
MDEV-33075 Resolve server shutdown issues on macOS, Solaris, and FreeBSD.

This commit addresses multiple server shutdown problems observed on macOS,
Solaris, and FreeBSD:

1. Corrected a non-portable assumption where socket shutdown was expected
to wake up poll() with listening sockets in the main thread.

Use more robust self-pipe to wake up poll() by writing to the pipe's write
end.

Signed-off-by: Ivan Prisyazhnyy <john.koepi@gmail.com>
2024-11-27 14:59:50 +02:00
Ivan Prisyazhnyy
c4cadb768f MDEV-33075 [backport/2f5174e556] fix rnd crash on macOS from pthread_kill(signal_handler)
Backport of 2f5174e556:
MDEV-33075 Resolve server shutdown issues on macOS, Solaris, and FreeBSD.

This commit addresses multiple server shutdown problems observed on macOS,
Solaris, and FreeBSD:

2. Fixed a random crash on macOS from pthread_kill(signal_handler)
when the signal_handler was detached and the thread had already exited.

Use more robust `kill(getpid(), SIGTERM)` to wake up the signal handler
thread.

Additionally, the shutdown code underwent light refactoring
for better readability and maintainability:

- Modified `break_connect_loop()` to no longer wait for the main thread,
  aligning behavior with Windows (since 10.4).
2024-11-27 14:59:50 +02:00
Ivan Prisyazhnyy
8214707699 MDEV-33075 [backport/2f5174e556] fix signal handler thread exit on abort
Backport of 2f5174e556:
MDEV-33075 Resolve server shutdown issues on macOS, Solaris, and FreeBSD.

This commit addresses multiple server shutdown problems observed on macOS,
Solaris, and FreeBSD:

3. Made sure, that signal handler thread always exits once `abort_loop` is
set, and also calls `my_thread_end()` and clears `signal_thread_in_use`
when exiting.

This fixes warning "1 thread did not exit"  by `my_global_thread_end()`
seen on FreeBSD/macOS when the process is terminated via signal.

Additionally, the shutdown code underwent light refactoring
for better readability and maintainability:

- Removed dead code related to the unused `USE_ONE_SIGNAL_HAND`
  preprocessor constant.

Signed-off-by: Ivan Prisyazhnyy <john.koepi@gmail.com>
2024-11-27 14:59:50 +02:00
Ivan Prisyazhnyy
490274e850 MDEV-33075 [backport/2f5174e556] eliminated support for #ifndef HAVE_POLL
Backport of 2f5174e556:
MDEV-33075 Resolve server shutdown issues on macOS, Solaris, and FreeBSD.

Eliminated support for `#ifndef HAVE_POLL` in `handle_connection_sockets`
This code is also dead, since 10.4

Signed-off-by: Ivan Prisyazhnyy <john.koepi@gmail.com>
2024-11-27 14:59:50 +02:00
Jan Lindström
f5aed74573 MDEV-35486 : MDEV-33997 test failed
Problem was that at wsrep_to_isolation_end saved_lock_wait_timeout
variable was set to thd->variables.lock_wait_timeout when RSU
is used and variable value was 0 leading sporadic lock wait timeout
errors. Fixed by removing incorrect variable set.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-11-27 13:00:08 +01:00
Alexander Barkov
8b057889d7 MDEV-34981 Functions missing from INFORMATION_SCHEMA.SQL_FUNCTIONS
Plugin functions are now displayed in I_S.SQL_FUNCTIONS
2024-11-27 14:24:52 +04:00
Thirunarayanan Balathandayuthapani
9ba18d1aa0 MDEV-35394 Innochecksum misinterprets freed pages
- Innochecksum misinterprets the freed pages as active one.
This leads the user to think there are too many valid
pages exist.

- To avoid this confusion, innochecksum introduced one
more option --skip-freed-pages and -r to avoid the freed
pages while dumping or printing the summary of the tablespace.

- Innochecksum can safely assume the page is freed if
the respective extent doesn't belong to a segment and marked as
freed in XDES_BITMAP in extent descriptor page.

- Innochecksum shouldn't assume that zero-filled page as extent
descriptor page.

Reviewed-by: Marko Mäkelä
2024-11-27 13:00:51 +05:30
Yuchen Pei
5be859d52c
MDEV-30649 Adding a spider testcase showing copying from a remote to a local table
Also deleted some trailing whitespace in mdev_30191.test.
2024-11-27 10:25:14 +11:00
Yuchen Pei
a8cc40d9a4
MDEV-35064 Reduce the default spider connect retry counts to 2
The existing default value 1000 is too big and could result in
"hanging" when failing to connect a remote server. Three tries in
total is a more sensible default.
2024-11-27 10:25:14 +11:00
Monty
c34a2feceb MDEV-35509 mariabackup.alter_copy_race crashes with abort in backup_file_op_fail
The bug was that backup_file_op_fail() was using a static variable
initialized by arguments. This does not work as static variables
will only be initialized on the first call and not change for future
calls, even when the arguments changes.

Fixed by removing 'static'.
2024-11-26 22:30:52 +02:00
Nikita Malyavin
e64857c25b Provide a safe range for RocksDB errors
Last time, commit b9f579317 (MDEV-9101) has updated HA_ERR_LAST, breaking the
rocksdb error codes. According to the commit history, this happens each time a
new HA error is added.

This patch fixes the range to start from '500', hopefully resolving the problem
for the close future.

In addition, fix incorrect error codes enumeration.
2024-11-26 19:21:12 +01:00
ParadoxV5
0fabe1dc18 Create FUNDING.yml
Configure a Sponsor button to surface a link to mariadb.org/donate
2024-11-26 17:39:37 +02:00
Monty
142851f120 Update my_print_defaults to accept --mariadbd as an option
--mariadbd and --mysqld are now synonymes for my_print_defaults

Other things
- Removed safemalloc warnings when using an unknown argument to
  my_print_defaults
2024-11-26 14:23:31 +02:00
Monty
f09020b3bb Fixed bug in subselect3.inc (not notable) 2024-11-26 14:23:31 +02:00
Alexander Barkov
225c17d35c MDEV-34090 Client allows to set character set to utf32 and crashes on the next command
Disallowing character sets with mbminlen>1 in the client.
2024-11-26 13:57:55 +04:00
Ahmed Ibrahim
a35f744d78 MDEV-31736: format_bytes implementation 2024-11-26 13:10:01 +04:00