Commit Graph

199479 Commits

Author SHA1 Message Date
5dbfb52d04 MDEV-36894 JSNX::SetArrayOptions and BJNX::SetArrayOptions unused nm arg
Calling SetArrayOptions with Nodes[i - 1].Key as its nm argument
exposed a MemorySanitizer error when i=0 for the tests:
* connect.bson_udf
* connect.json_udf
* connect.json_udf_bin

Its assumed that a basic optimization would have eliminated
these invalid expressions.

As the nm argument was unused, it has been removed.
2025-05-28 16:33:09 +10:00
495153feac MDEV-36893 THD::reset_sub_statement_state swaps with uninitialized structure
THD::reset_sub_statement_state and THD::restore_sub_staement_state
swap auto_inc_intervals_forced(Discrete_intervals_list) of a THD class
with a local variable temporary to execute other things before restoring
at the end of Table_triggers_list::process_triggers under a
rpl_master_erroneous_autoinc(true) condition as exposed by the
rpl.rpl_trigger test.

The uninitialized data isn't used and the only required action is to
copy the data in one direction. As the intent is for the auto_inc_intervals_forced
value to be overwritten or unused, MEM_UNDEFINED is used on it to
ensure the previous state is considered invalid.

The other uses of reset_sub_statement_state in Item_sp::execute_impl
also follow the same pattern of taking a copy to restore within the
same function.
2025-05-28 16:33:09 +10:00
8d2665e56b MDEV-34388 default stack size under MSAN needs increasing
Without this increase the mtr test case pre/post conditions will
fail as the stack usage has increased under MSAN with clang-20.1.

ASAN takes a 11M stack, however there was no obvious gain in MSAN
test success after 2M.

The resulting behaviour observed on smaller stack size was a
SEGV normally.

Hide the default stack size from the sysvar tests that expose
thread-stack as a variable with its default value.
2025-05-28 16:30:56 +10:00
2811559337 version string - memory sanitizer isn't the same as valgrind
Despite being included in the HAVE_valgrind define.

As such it's best differenciated from valgrind in the
server identifier as they have for the purposes a distinct
and different set of behaviours.

MSAN has its own set of test inclusions that that are different
from valgrind and such including "valgrind" in a server string that
gets tested for valgrind will incorrectly exclude some tests
that are suitable for MSAN but not valgrind.

There's a have_sanitizer system variable for exposing
the sanitizer being used so there's no need for
version verboseness.

Correct have_sanitizer system variable description to
include MSAN has been possible for a while.
2025-05-28 16:29:55 +10:00
8490901307 MDEV-34388: Stack overflow on Alpine Linux (postfix - ASAN/MSAN+Debug)
In original fix, commit 82d7419e06,
a 16k stack frame limit was imposed. Under the stack usage is doubled due
to MSAN. Debug builds without optimization can use more as well.

ASAN Debug builds also exceeded the 16k stack frame limit.

To keep some safety limit, a 64k limit is imposed to the compiler
under MSAN or ASAN with CMAKE_BUILD_TYPE=Debug.
2025-05-28 16:29:03 +10:00
5012402330 MDEV-34388 Alpine Stack Overflow - reduce Grant_tables::open_and_lock
The stacksize was still too large. Back port from the 10.11 merge
commit 1c7209e828
2025-05-28 16:29:03 +10:00
df414933f1 MDEV-36316/MDEV-36327/MDEV-36328 Debug msan
Clang ~16+ on MSAN became quite strict with uninitalized
data being passed and returned from functions. Non-debug builds
have a basic optimization that hides these from those builds

Two innodb cases violate the assumptions, however once inlined
with a basic optimization those that existed for uninitialized
values are removed.

(MDEV-36316) rec_set_bit_field_2 calling mach_read_from_2 hits a read of
bits it wasn't actually changing.

(MDEV-36327) The function dict_process_sys_columns_rec left
nth_v_col uninitialized unless it was a virtual column. This was
ok as the function i_s_sys_columns_fill_table also didn't read
this value unless it was a virtual column.
2025-05-28 16:28:34 +10:00
507cbde68f MDEV-36882: Inconsistent DBUG_ASSERT trips GCC -Og
my_time_fraction_remainder(): Remove a DBUG_ASSERT, because there is
none in sec_part_shift() or sec_part_unshift() either.  A buffer
overflow should be caught by cmake -DWITH_ASAN=ON in all three.
This fixes a build with GCC 14.2 and
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS=-Og.

Reviewed by: Daniel Black
2025-05-27 08:05:19 +03:00
aba04c562b Compiling - fix warnings with MSVC 17.14
New warnings come from 3 places

1. Warning C5287: Warning comes from json_lib.c from code like
  compile_time_assert((int) JSON_VALUE_NULL == (int) JSV_NULL);
2. Warning C5287: Similar warning come from wc_static_assert() from code
  in wolfSSL's header file
3. Warning C5286 in WolfSSL code, -enum_value

   (i.e multiplying enum with -1)is used

To fix:
- Disable warnings in WolfSSL code, using /wd<num> flag.
- workaround warning for users of WolfSSL, disable
  wc_static_assert() with -DWC_NO_STATIC_ASSERT compile flag
- Rewrite some compile_time_assert in json_lib.c to avoid warning.
- add target_link_libraries(vio ${SSL_LIBRARIES}) so that
  vio picks up -DWC_NO_STATIC_ASSERT
2025-05-26 16:58:21 +02:00
8a4d3a044f MDEV-36017 Alter table aborts when temporary directory is full
Problem:
=======
- During inplace algorithm, concurrent DML fails to write
the log operation into the temporary file. InnoDB fail to
mark the error for the online log.

- ddl_log_write() releases the global ddl lock prematurely before
release the log memory entry

Fix:
===
row_log_online_op(): Mark the error in online log when
InnoDB ran out of temporary space

fil_space_extend_must_retry(): Mark the os_has_said_disk_full
as true if os_file_set_size() fails

btr_cur_pessimistic_update(): Return error code when
btr_cur_pessimistic_insert() fails

ddl_log_write(): Release the global ddl lock after releasing the
log memory entry when error was encountered

btr_cur_optimistic_update(): Relax the assertion that
blob pointer can be null during rollback because InnoDB can
ran out of space while allocating the external page

row_undo_mod_upd_exist_sec(): Remove the assertion which says
that InnoDB should fail to build index entry when rollbacking
an incomplete transaction after crash recovery. This scenario
can happen when InnoDB ran out of space.

row_upd_changes_ord_field_binary_func(): Relax the assertion to
make that externally stored field can be null when InnoDB ran out
of space.
2025-05-25 09:11:41 +05:30
4c8143b451 Make it compiling with last gcc 2025-05-23 14:18:07 +02:00
1037f95941 MDEV-33675 Assertion(reclength < vreclength) in setup_vcols_for_repair()
When table2myisam() prepares recinfo structures BIT field was skipped
because pack_length_in_rec() returns 0. Instead of BIT field
DB_ROW_HASH_1 field was taken into recinfo structure and its length
was added to reclength. This is wrong because not stored fields must
not be prepared as record columns (MI_COLUMNDEF) in storage
layer. 0-length fields are prepared in "reserve space for null bits"
branch.

The problem only occurs with tables where there is no data for the
main record outside of the null bits.

The fix updates minpos condition so we avoid fields after
stored_rec_length and these are not stored by
definition. share->reclength already includes not stored lengths from
CREATE TABLE so we cannot use it as minpos starting point.

In Aria there is no "reserve space for null bits" and it does not
create column definition for BIT. Also there is no
setup_vcols_for_repair() to reproduce the issue. But nonetheless it
creates column definition for not stored fields redundantly, so we
patch table2maria() as well. The test case for Aria tries to
demonstrate BIT field works, it does not reproduce any issues (as
redundant column definition for not stored field seem to not cause any
problems).
2025-05-23 14:46:35 +03:00
1a95c2a4b2 MDEV-36817 Server crashes in do_mark_index_columns instead of
ER_DUP_ENTRY on partitioned table

Now as c1492f3d07 (MDEV-36115) restores m_last_part table->file
points to partition p0 while the error happens in p1, so error index
does not match ib_table in innobase_get_mysql_key_number_for_index().

This case is handled by separate code block in
innobase_get_mysql_key_number_for_index() which was wrong on using
secondary index for dict_index_is_auto_gen_clust() and it was not
covered by the tests.
2025-05-23 14:46:34 +03:00
fbd736c872 mysqltest: result_format fix
--result_format 2 command fails with assertion:

DbugExit (why=0x7fffffff49e0 "missing DBUG_RETURN or DBUG_VOID_RETURN
macro in function \"do_result_format_version\"\n") at
../src/dbug/dbug.c:2045
2025-05-21 11:10:09 +03:00
d5247592c5 Test sysvars_server failure fix 2025-05-21 11:10:09 +03:00
2c4fe3557a MDEV-36337: mroonga_* udf correct ptr types for is_null/error
Shows up in mroonga UDF tests under clang with UBSAN:

UndefinedBehaviorSanitizer: function-type-mismatch

Accepted upstream: https://github.com/mroonga/mroonga/pull/902
2025-05-21 09:47:55 +02:00
b9a20752a9 MDEV-36337 auth_ed25519 correct UDF pointers for is_null/error
Shows up on test plugins.auth_ed25519.

There isn't the import to define uchar so left as unsigned char.
2025-05-21 09:47:55 +02:00
0b5a084e27 MDEV-36337: connect UDF pointers need unsigned char* for is_null/error
This is required to match the sql/sql_udf.h
2025-05-21 09:47:55 +02:00
c91c2e74ff MDEV-36337: udf_example UDF pointers need unsigned is_null/error
This is required to match the sql/sql_udf.h
2025-05-21 09:47:55 +02:00
497d6324bc MDEV-36627 : galera.MDEV-29142: certification position less than last commited
After the membership change on a newly synced node, then this is just a
warning and safe to suppress.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-05-20 20:59:10 +02:00
7aed06887b MDEV-36512 : galera_3nodes.GCF-354: certification position less than last committed
Test changes only. Both warnings are expected and
should be suppressed because we intentionally inject
different inconsistencies on two nodes and then join
them back with membership change.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-05-20 20:59:10 +02:00
7fd5957d55 MDEV-36622 : Hang during galera_evs_suspect_timeout test
Test changes only. Add wait_condition so that all nodes
are in the expected state and add debug output if issue
does reproduce.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-05-20 20:59:10 +02:00
d38558f99b MDEV-36117: MDL BF-BF conflict on ALTER and UPDATE with multi-level foreign key parents
Issue:
Mariadb acquires additional MDL locks on UPDATE/INSERT/DELETE statements
on table with foreign keys. For example, table t1 references t2, an
UPDATE to t1 will MDL lock t2 in addition to t1.
A replica may deliver an ALTER t1 and UPDATE t2 concurrently for
applying. Then the UPDATE may acquire MDL lock for t1, followed by a
conflict when the ALTER attempts to MDL lock on t1. Causing a BF-BF
conflict.

Solution:
Additional keys for the referenced/foreign table needs to be added
to avoid potential MDL conflicts with concurrent update and DDLs.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-05-20 20:59:10 +02:00
a96367bc67 MDEV-36620 post-fix: galera_toi_ddl_nonconflicting test failure
Add wait_condition to wait until all inserted rows are replicated
so that show create table is deterministic.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-05-20 20:59:10 +02:00
82d7419e06 MDEV-34388: Stack overflow on Alpine Linux
page_is_corrupted(): Do not allocate the buffers from stack,
but from the heap, in xb_fil_cur_open().

row_quiesce_write_cfg(): Issue one type of message when we
fail to create the .cfg file.

update_statistics_for_table(), read_statistics_for_table(),
delete_statistics_for_table(), rename_table_in_stat_tables():
Use a common stack buffer for Index_stat, Column_stat, Table_stat.

ha_connect::FileExists(): Invoke push_warning_printf() so that
we can avoid allocating a buffer for snprintf().

translog_init_with_table(): Do not duplicate TRANSLOG_PAGE_SIZE_BUFF.

Let us also globally enable the GCC 4.4 and clang 3.0 option
-Wframe-larger-than=16384 to reduce the possibility of introducing
such stack overflow in the future.  For RocksDB and Mroonga we relax
these limits.

Reviewed by: Vladislav Lesin
2025-05-20 17:27:05 +03:00
2350295643 MDEV-36740: galera.galera_ssl_upgrade fails due to expired certificate
The certificate used in tests has been renewed.
2025-05-20 12:33:36 +02:00
d7457b4076 MDEV-36628 : galera_vote_during_ist test failed
Test changes only. Added wait_conditions to wait for expected
database state.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-05-20 12:30:40 +02:00
60f046d7e6 MDEV-35009: Initialize affected_rows in SQL service
The SQL service leaves the affected rows uninitialized.

The initialization of the spider plugin that uses
this service will fail under MSAN because there isn't
an initialized value to return at the end of the query.
2025-05-08 17:54:20 +10:00
c626715439 MDEV-35452 [fixup] fix spider/bugfix.perfschema view protocol
mtr with --view-protocol creates new threads
2025-04-30 10:38:44 +10:00
76e8e24b0b Merge branch '10.5' into 10.6 2025-04-30 10:35:11 +10:00
55ddfe1c95 MDEV-36684 - main.mdl_sync fails under valgrind (test for Bug#42643)
Valgrind is single threaded and only changes threads as part of
system calls or waits.

Some busy loops were identified and fixed where the server assumes
that some other thread will change the state, which will not happen
with valgrind.

Based on patch by Monty. Original patch introduced VALGRIND_YIELD,
which emits pthread_yield() only in valgrind builds. However it was
agreed that it is a good idea to emit yield() unconditionally, such
that other affected schedulers (like SCHED_FIFO) benefit from this
change. Also avoid pthread_yield() in favour of standard
std::this_thread::yield().
2025-04-29 15:05:20 +04:00
83e0438f62 MDEV-36536 post-review changes
that were apparently partially lost in a rebase
2025-04-29 11:34:35 +02:00
739578915f Make the test more stable. 2025-04-28 17:47:45 +02:00
d9cd4e1f75 MDEV-22250 InnoDB: Failing assertion: opt_no_lock during mariabackup --backup
Ensure that backup_reset_alter_copy_lock() is called in case of rollback
or error in mysql_inplace_alter_table() or copy_data_between_tables().

Other things:
- Improved error from mariabackup when unexpected DDL operation is
  encountered.
- Added assert if backup_ddl_log() is called in the wrong context.
2025-04-28 12:38:01 +03:00
1b934a387c MDEV-36536 Add option to not collect statistics for long char/varchars
This is needed to make it easy for users to automatically ignore long
char and varchars when using  ANALYZE TABLE PERSISTENT.
These fields can cause problems as they will consume
'CHARACTERS * MAX_CHARACTER_LENGTH * 2 * number_of_rows' space on disk
during analyze, which can easily be much bigger than the analyzed table.

This commit adds a new user variable, analyze_max_length, default value 4G.
Any field that is bigger than this in bytes, will be ignored by
ANALYZE TABLE PERSISTENT unless it is specified in FOR COLUMNS().

While doing this patch, I noticed that we do not skip GEOMETRY columns from
ANALYZE TABLE, like we do with BLOB. This should be fixed when merging
to the 'main' branch. At the same time we should add a resonable default
value for analyze_max_length, probably 1024, like we have for
max_sort_length.
2025-04-28 12:38:01 +03:00
5c92b27d54 MDEV-36633 MDEV-35452 spider/bugfix.mdev_33434 reports wrong error in view protocol
With view protocol collation_connection is reset in mysql_make_view in
the "SELECT * FROM mysqltest_tmp_v" query. In the case of
spider/bugfix.mdev_33434, it is reset to latin1_swedish_ci, with the
latin1 charset.

This results in no conversion needed since it is the same as
character_set_client and the corresponding argument in the udf remains
unchanged, with "dummy" srv value. Thus the reported error is

1477: 'The foreign server name you are trying to reference does not exist. Data source error:  dummy'

Without view protocol, the character_set_connection ucs2 setting in
the test survives, and the conversion results in empty connection
parameters, and the reported error is 1429
ER_CONNECT_TO_FOREIGN_DATA_SOURCE

This failure is irrelevant to the test, or to spider at all. Therefore
we disable view protocol for the statement.
2025-04-28 14:40:16 +10:00
b1446080d1 MDEV-36476 MDEV-35452 Disable view protocol for spider tests where thread metadata could prevent lock wait timeout
In spider/bugfix.mdev_29352, with flush tables with read lock,
statements blocked in THD::has_read_only_protection() by checking
THD::global_read_lock could result in view protocol to "hang" waiting
for acquiring mdl in another THD.

In spider/bugfix.mdev_34555, within an XA transaction, statements
blocked by trans_check() by checking thd->transaction->xid_state could
result in view protocol to "hang" for the same reason.

Therefore we disable view protocol for relevant statements in these
tests.
2025-04-28 14:40:16 +10:00
08793310fb MDEV-36478 MDEV-35452 Remove blocks testing SELECT SQL_CALC_FOUND_ROWS from spider tests
Spider tables do not support SELECT SQL_CALC_FOUND_ROWS and the
correct test output is a coincidence. Debugging shows that the
limit_found_rows field was last updated in an unrelated statement:

SELECT STRAIGHT_JOIN a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s')\nFROM ta_l a, tb_l b WHERE a.a = b.a ORDER BY a.a

As a byproduct, this fixes the "wrong found_rows() results" when
running these tests with view protocol.
2025-04-28 14:40:16 +10:00
9089a75b7f MDEV-36477 MDEV-35452 Fix Spider tests with view protocol fail with "Failed to drop view: 0: "
The failure is caused by exec $stmt where $stmt has two queries.
mtr with view protocol transforms the first query into a view, leaving
the second query executed in the usual way. mtr being oblivious about
the second query then does not handle its results, resulting in
CR_COMMANDS_OUT_OF_SYNC. We disable view protocol for such edge cases.
After fixing these "Failed to drop view: 0: " further failures emerge
from two of the tests, which are the same problem as MDEV-36454, so we
fix them to by disabling view protocol for the relevant SELECTs.
2025-04-28 14:40:16 +10:00
d3c5c47e0e MDEV-36324 MDEV-35452 Missing appending FROM ... in spider_mbase_handler::append_key_select
The missing append_from causes ill-formed query construction.

This fixes spider/bugfix.mdev_35874 with --view-protocol.
2025-04-28 14:40:15 +10:00
2b448e7337 print_ddl_recovery_log.pl ; Print content of the ddl_recovery.log 2025-04-27 15:12:21 +03:00
19644f6821 Merge branch '10.5' into 10.6 mariadb-10.6.22 2025-04-26 10:41:52 +02:00
c461188ca6 MDEV-36681 Remove systemd CapabilityBoundingSet as unnecessary
Hopefully, this ends the long story of CapabilityBoundingSet
in mariadb.service.

Started from MDEV-9095 (27e6fd9a59) which was supposed
to let --memlock work without root, but instead of
adding the necessary capability (CAP_IPC_LOCK) by putting it into
AmbientCapabilities it removed all other capabilities,
by putting CAP_IPC_LOCK into CapabilityBoundingSet
(which is the mask of allowed capabilities).

This broke pam plugin, which needed CAP_DAC_OVERRIDE,
it was fixed in MDEV-19878 (dd93028dae) by appending
CAP_DAC_OVERRIDE to CapabilityBoundingSet.

Obviously, memlock still didn't work, this was fixed
in MDEV-33301 (76a27155b4) by moving CAP_IPC_LOCK
to AmbientCapabilities.

Unfortunately, it moved too much (everything), so
MDEV-36229 (85ecb80fa3) fixed it moving CAP_DAC_OVERRIDE
back to CapabilityBoundingSet.

This caused MDEV-36591 (8925877dc8) triggering a bug in old
systemd versions. And it broke pam plugin on CentOS Stream 10,
where CAP_DAC_OVERRIDE alone was apparently not enough.

Let's finally fix this by removing CapabilityBoundingSet
completely and keeping CAP_IPC_LOCK in AmbientCapabilities,
which should've been the correct fix for MDEV-9095 from the start.
mariadb-10.5.29
2025-04-25 17:48:13 +02:00
9579ee4fa2 Revert "MDEV-36591: RHEL8(+compat)/Ubuntu 20.04 cannot start systemd servce (EXIT_CAPABILTIES/218)"
This reverts commit 8925877dc8.
2025-04-25 17:48:13 +02:00
4fc9dc84b0 MDEV-32086 (part 2) Server crash when inserting from derived table containing insert target table
Get rid of need of matherialization for usual INSERT (cache results in
Item_cache* if needed)

- subqueries in VALUE do not see new records in the table we are
  inserting to
- subqueries in RETIRNING prohibited to use the table we are inserting to
2025-04-25 15:10:36 +02:00
9b313d2de1 MDEV-32086 Server crash when inserting from derived table containing insert target table
Use original solution for INSERT ... SELECT - select result buferisation.

Also fix MDEV-36447 and MDEV-33139
2025-04-25 12:58:24 +02:00
9b0294cd12 MDEV-36666 - atomic.alter_table still times out often
According to buildbot cross-reference atomic.alter_table is failing ~10
times a day due to 900 seconds test case timeout. Split it into two
tests: atomic.alter_table_myisam and atomic.alter_table_innodb.
It should reduce failure frequency down to once a day or so, similarly
to atomic.alter_table_aria test.

Diabling InnoDB for MyISAM/Aria/RocksDB tests makes them 20-35% faster.
2025-04-25 10:40:47 +04:00
2f5c260f55 MDEV-36514 : galera_var_ignore_apply_errors test failure: table doesn't exist
Test changes only. Added proper wait_conditions to wait for expected
replication state.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-04-23 18:45:57 +02:00
76938eda9d MDEV-36625 : galera.galera_var_replicate_myisam_on test failure
Test case changes only. Add proper wait_conditions to wait expected
database state.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-04-23 18:45:11 +02:00
2fa50befbd rpm: restore MariaDB-test dependency on MariaDB-common
after 41b036bff0
2025-04-23 12:57:14 +02:00