Commit graph

195796 commits

Author SHA1 Message Date
Yuchen Pei
f0af56be01
MDEV-27095 installing one spider plugin should not trigger others
There are several plugins in ha_spider: spider, spider_alloc_mem,
spider_wrapper_protocols, spider_rewrite etc.

INSTALL PLUGIN foo SONAME ha_spider causes all the other ones to be
installed by the init queries where foo is any of the plugins.

This introduces unnecessary complexiy. For example it reads
mysql.plugins to find all other plugins, causing the hack of moving
spider plugin init to a separate thread.

To install all spider related plugins, install soname ha_spider should
be used instead.

This also fixes spurious rows in mysql.plugin when installing say only
the spider plugin with `plugin-load-add=SPIDER=ha_spider.so`:

select * from mysql.plugin;
name	dl
spider_alloc_mem	ha_spider.so # should not be here
spider_wrapper_protocols	ha_spider.so # should not be here

Adapted from part of the reverted commit
c160a115b8.
2023-12-07 16:01:40 +11:00
Julius Goryavsky
66fafdb922 MDEV-32344: IST failed with ssl-mode=VERIFY_CA
This commit fixes a bug where IST could be rejected in favor of SST
when ssl-mode=VERIFY_CA and when mariabackup is used. It also contains
a test and small code simplifications that will make it easier to find
bugs in the future.
2023-12-07 04:57:21 +01:00
Yuchen Pei
13896f73df
MDEV-28683 Spider: create conn on demand when direct delete
We do this in 10.4 at the same place where in 10.5+ dml_init() is
called which does the same thing, among other things.
2023-12-07 11:02:31 +11:00
Oleg Smirnov
a8bd6a9813 MDEV-15656 Assertion `is_last_prefix <= 0' failed in QUICK_GROUP_MIN_MAX_SELECT::get_next
When QUICK_GROUP_MIN_MAX_SELECT is initialized or being reset
it stores the prefix of the last group of the index chosen for
retrieving data (last_value). Later, when looping through records
at get_next() method, the server checks whether the retrieved
group is the last, and if so, it finishes processing.

At the same time, it looks like there is no need for that additional
check since method next_prefix() returns HA_ERR_KEY_NOT_FOUND
or HA_ERR_END_OF_FILE when there are no more satisfying records.
If we do not perform the check, we do not need to retrieve and
store last_value either.

This commit removes using of last_value from QUICK_GROUP_MIN_MAX_SELECT.

Reviewer: Sergei Petrunia <sergey@mariadb.com>
2023-12-06 15:19:49 +03:00
Thirunarayanan Balathandayuthapani
d5fc34db4c MDEV-29092 FOREIGN_KEY_CHECKS does not prevent non-copy alter from creating invalid FK structure
Problem:
========
- InnoDB should have two keys on the same column for the self
referencing foreign key relation.

Solution:
=========
- Allow self referential foreign key relation to work with one
key.
2023-12-06 14:29:17 +05:30
Brandon Nesterenko
dc9ac9266c MDEV-32933: Skip statement and mix mode for binlog.flashback
The binlog.flashback test tries to run using the stmt and mix
binlog_format combinations (because it includes have_log_bin.inc),
yet are meaningless tests because the server starts with the
--flashback option, forcing binlog_format=row.

This patch optimizes test time by removing the stmt and mix format
combinations from running.

Reviewed By:
============
Andrei Elkin <andrei.elkin@mariadb.com>
2023-12-05 10:47:53 -07:00
Sergei Petrunia
bd23b3dc06 MDEV-32901: innodb.mdev-14846 fails in 11.0
InnoDB could return off-by-1 estimates for the involved tables.
This would cause off-by-many difference in join output cardinality
for the top-level SELECT, and so different query plan for the subquery.

The fix: Introduce mysql-test/include/innodb_stable_estimates.{inc,opt}
which disables InnoDB's background statistics collection, and use it.
2023-12-05 19:26:30 +03:00
Daniele Sciascia
5c4c1844bf MDEV-32781 galera_bf_lock_wait test failed
This test happens to fail if it runs after test
galera_inject_bf_long_wait.
And the reason is that galera_bf_lock_wait greps for message
"BF lock wait long" in the error log, and expects that grep matches
no lines. Whereas galera_inject_bf_long_wait intentionally causes the
message to appear in the log. The fix consists in using
assert_grep.inc with option assert_only_after, such that
galera_bf_lock_wait is limited to grep only those lines that appeared
in the log after it started to execute.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2023-12-05 12:25:32 +01:00
Denis Protivensky
6d9c9d92cc MDEV-32938: DDL must check if not aborted before entering TOI
Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2023-12-05 12:25:32 +01:00
Julius Goryavsky
dc7138cbed galera: temporarily disabling problematic tests 2023-12-05 12:25:32 +01:00
Yuchen Pei
9d15c3e35a
MDEV-29020 Reduce default spider bg sts/crd thread counts 2023-12-05 20:59:58 +11:00
Yuchen Pei
ddd5449c57
[fixup] post-merge spider fixup
MDEV-32524: a couple missed magic numbers
MDEV-26247: a couple missed goto statements that could lead to memory leak
2023-12-05 14:33:16 +11:00
Sergei Petrunia
b97f4c340e Followup for fix for MDEV-20169: enable main.partition_innodb 2023-12-04 20:34:45 +03:00
Vladislav Vaintroub
9a8b1f2ac4 MDEV-32926 mysql_install_db_win fails on buildbot
- Do not suppress mysql_install_db.exe output in case of error
- Add --verbose-bootstrap to get errors coming from mysqld --boostrap
2023-12-04 12:15:49 +01:00
Sergei Golubchik
2700d20b7c MDEV-32725 innodb.import_update_stats accesses uninitialized ib_table->stat_n_rows
disable a failing test
2023-12-04 10:30:39 +01:00
Gulshan Kumar Prasad
d8e6bb0088 MDEV-32611: Test suite is missing dump option delete-master-logs.
Extending the rpl_mysqldump_slave.test to incorporate the
delete-master-logs option, and this options is alias of
get binlogs: show master status -> flush logs -> purge binary logs to <new_binlog>
sequence and this test is derived using the same pattern.
also we measure the pre and post log state
on the master following the mysqldump process. Introducing
assertions to validate the correct state.
2023-12-02 12:52:10 +01:00
Oleksandr Byelkin
af2e91d9f2 fix for the test (real fixes will be in 10.4) 2023-12-02 01:03:55 +01:00
Sergei Golubchik
98a39b0c91 Merge branch '10.4' into 10.5 2023-12-02 01:02:50 +01:00
Rex
c6a9fd7904 MDEV-32212 DELETE with ORDER BY and semijoin optimization causing crash
Statements affected by this bug are delete statements that have all
these conditions

1) single table delete syntax
2) and in (sub-query) predicate
3) semi-join optimization enabled
4) an order by clause.

Semijoin optimization on an innocent looking query, such as

DELETE FROM t1 WHERE c1 IN (select c2 from t2) ORDER BY c1;

turns it from a single table delete to a multi-table delete.

During multi_delete::initialize_tables for the top level join object, a
table is initialized missing a keep_current_rowid flag, needed to
position a handler for removal of the correct row after the filesort
structure has been built.

Fix provided by Monty (monty@mariadb.com)
Pushed into 10.5 at Monty's request.
Applicable to 10.6, 10.11, 11.0.
OK'd by Monty in slack:#askmonty 2023-12-01
2023-12-01 09:29:36 +12:00
Sergei Golubchik
5f89045221 MDEV-22230 fix failing test
followup for 5bb31bc882
2023-11-30 13:56:26 +01:00
Marko Mäkelä
89a5a8d234 MDEV-32269 InnoDB after ALTER TABLE…IMPORT TABLESPACE may not be crash safe
mtr_t::commit(): If IMPORT TABLESPACE is first-time-dirtying blocks,
acquire both log_sys.mutex and log_sys.flush_order_mutex to assign
a valid m_commit_lsn so that the block will be inserted into the
correct position of buf_pool.flush_list.

This fixes occasional debug assertion failures when running the
regression test suite.

Reviewed by: Vladislav Lesin
2023-11-30 09:43:36 +02:00
Daniel Black
2fe3e033e6 main.subselect* often fails on CI with ER_SUBQUERY_NO_1_ROW
Using mysql.slow_log was a test table would generate more than
one row if there was more than one row in the table.

Replace this table with a empty table with PK.

Reviewer: Rex Johnston
2023-11-30 16:15:26 +11:00
Marko Mäkelä
cd79f10211 MDEV-31441 BLOB corruption on UPDATE of PRIMARY KEY with FOREIGN KEY
row_upd_clust_rec_by_insert(): If we are resuming from a lock wait,
reset the 'disowned' flag of the BLOB pointers in 'entry' that we
copied from 'rec' on which we had invoked btr_cur_disown_inherited_fields()
before the lock wait started. In this way, the inserted record with
the updated PRIMARY KEY value will have the BLOB ownership associated
with itself, like it is supposed to be.

Note: If the lock wait had been aborted, then rollback would have
invoked btr_cur_unmark_extern_fields() and no corruption would be possible.

Reviewed by: Vladislav Lesin
Tested by: Matthias Leich
2023-11-29 18:57:57 +02:00
Vlad Lesin
968061fd9c MDEV-28682 gcol.gcol_purge contaminates further execution of innodb.gap_locks
ha_innobase::extra() invokes check_trx_exists() unconditionally even for
not supported operations. check_trx_exists() creates and registers trx_t
object if THD does not contain pointer to it. If ha_innobase::extra() does
not support some operation, it just invokes check_trx_exists() and quites.
If check_trx_exists() creates and registers new trx_t object for such
operation, it will never be freed and deregistered.

For example, if ha_innobase::extra() is invoked from purge thread with
operation = HA_EXTRA_IS_ATTACHED_CHILDREN, like it goes in
gcol.gcol_purge test, trx_t object will be registered, but not
deregisreted, and this causes innodb.gap_lock failure, as "SHOW ENGINE
INNODB STATUS" shows information about unexpected transaction at the end
of trx_sys.trx_list.

The fix is not to invoke check_trx_exists() for unsupported operations
in ha_innobase::extra().

Reviewed by: Marko Mäkelä
2023-11-29 19:50:52 +03:00
Thirunarayanan Balathandayuthapani
e996f77cd8 MDEV-32897 main suite test case prints extra row for metadata_lock_info query
- Added the parameter stats_persistent=0 for InnoDB engine.
- Before printing metadata_lock_info query, make sure that
InnoDB does complete purging.

Reviewed by: Marko Mäkelä
2023-11-29 17:43:40 +05:30
Marko Mäkelä
47fc64c19f MDEV-32833 InnoDB wrong error message
trx_t::commit_in_memory(): Empty the detailed_error string, so that
FOREIGN KEY error messages from an earlier transaction will not be
wrongly reused in ha_innobase::get_error_message().

Reviewed by: Thirunarayanan Balathandayuthapani
2023-11-29 10:52:25 +02:00
Daniel Black
1fec50120f mallinfo2: include malloc header even if mallinfo undetected
It may be the case that for some reason, -Werror deprecated
for instance, that mallinfo isn't detected. In this case the
malloc.h headers won't be included which defined the mallinfo2
function and its structure.

Re-organise so that either function pulls in the header.
2023-11-29 18:51:48 +11:00
Kristian Nielsen
705f7ab620 MDEV-20169: main.partition_innodb fails in buildbot with wrong result
The problem is that background statistics can race with statistics update
during INSERT and cause slightly inaccurate `Rows` count in table statistics
(this is deliberate to avoid excessive locking overhead). This was seen as
occasional .result difference in the test.

Mask out the unstable `Rows` column from SHOW TABLE STATUS; the value is not
related to what is being tested in this part of the test case.

Run ANALYZE TABLE before SHOW EXPLAIN to get stable row count in output.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2023-11-28 19:10:42 +01:00
Kristian Nielsen
ea4bcb9d98 MDEV-32168: slave_error_param condition is never checked from the wait_for_slave_param.inc
Fix some random test failures following MDEV-32168 push.

Don't blindly set $rpl_only_running_threads in many places. Instead explicit
stop only the IO or SQL thread, as appropriate. Setting it interfered with
rpl_end.inc in some cases. Rather than clearing it afterwards, better to
not set it at all when it is not needed, removing ambiguity in the test
about the state of the replication threads.

Don't fail the test if include/stop_slave_io.inc finds an error in the IO
thread after stop. Such errors can be simply because slave stop happened in
the middle of the IO thread's initial communication with the master.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2023-11-28 19:10:42 +01:00
Monty
387b92df97 Remove deprication from mariadbd --debug
--debug is supported by allmost all our other binaries and we should keep
it also in the server to keep option names similar.
2023-11-28 16:33:22 +02:00
Monty
1ffa8c5072 Fixed build failure on aarch64-macos
debug_sync.h was wrongly combined with replication
2023-11-28 15:31:44 +02:00
Monty
acdb8b6779 Fixed crash in Delayed_insert::get_local_table()
This was a bug in my previous commit, found by buildbot
2023-11-28 15:31:44 +02:00
Thirunarayanan Balathandayuthapani
7081feeac9 MDEV-29913 Assertion `thd->stmt_arena != thd->progress.arena' failed in thd_progress_init upon bulk load
- Commit fc31e3114b2538d152194d17ff0f0439db565634(MDEV-8179) doesn't
report the progress of inplace alter completely. It just does only
in row_merge_sort(). Removing the progress report function completely
2023-11-28 13:52:22 +05:30
Thirunarayanan Balathandayuthapani
d9ae5820c5 MDEV-32890 LeakSanitizer errors in mem_heap_create_block_func upon query from I_S.INNODB_SYS_TABLES with LIMIT ROWS EXAMINED
- innodb_sys_tables query fails to free the object which contains
sys_tables information in case of error.
2023-11-28 13:42:08 +05:30
Faustin Lammler
81aba2c21f Fix typo 2023-11-28 16:30:04 +11:00
Faustin Lammler
60c01206df The MariaDB mailing list system has been moved
See: https://mariadb.org/mailing-lists/
2023-11-28 16:30:04 +11:00
Alexander Barkov
f436b4a523 MDEV-32879 Server crash in my_decimal::operator= or unexpected ER_DUP_ENTRY upon comparison with INET6 and similar types
During the 10.5->10.6 merge please use the 10.6 code on conflicts.

This is the 10.5 version of the patch (a backport of the 10.6 version).
Unlike 10.6 version, it makes changes in plugin/type_inet/sql_type_inet.*
rather than in sql/sql_type_fixedbin.h

Item_bool_rowready_func2, Item_func_between, Item_func_in
did not check if a not-NULL argument of an arbitrary data type
can produce a NULL value on conversion to INET6.

This caused a crash on DBUG_ASSERT() in conversion failures,
because the function returned SQL NULL for something that
has Item::maybe_null() equal to false.

Adding setting NULL-ability in such cases.

Details:

- Removing the code in Item_func::setup_args_and_comparator()
  performing character set aggregation with optional narrowing.
  This aggregation is done inside Arg_comparator::set_cmp_func_string().
  So this code was redundant

- Removing Item_func::setup_args_and_comparator() as it git simplified to
  just to two lines:
    convert_const_compared_to_int_field(thd);
    return cmp->set_cmp_func(thd, this, &args[0], &args[1], true);
  Using these lines directly in:
    - Item_bool_rowready_func2::fix_length_and_dec()
    - Item_func_nullif::fix_length_and_dec()

- Adding a new virtual method:
  - Type_handler::Item_bool_rowready_func2_fix_length_and_dec().

- Adding tests detecting if the data type conversion can return SQL NULL into
  the following methods of Type_handler_inet6:
  - Item_bool_rowready_func2_fix_length_and_dec
  - Item_func_between_fix_length_and_dec
  - Item_func_in_fix_comparator_compatible_types
2023-11-28 07:26:39 +04:00
Yuchen Pei
2057820532
MDEV-32849 Spider: check if any table is actually locked when unlocking
This avoids the scenario in MDEV-32849, when the unlock happens after
the connection has been freed, say in rollback. This is done in 10.5+
after the commit a26700cca5.

It may or may not prevent potential other scenarios where spider has
locked something, then for some reason the statement needs to be
rolled back and spider frees the connection, and then spider proceeds
to use the freed connection. But at least we fix the regression
introduced by MDEV-30014 to 10.4 and bring 10.4 closer in parity with
10.5+.
2023-11-28 11:04:23 +11:00
Monty
83214c3406 Improve reporting from sf_report_leaked_memory()
Other things:
- Added DBUG_EXECUTE_IF("print_allocated_thread_memory") at end of query
  to easier find not freed memory allocated by THD
- Removed free_root() from plugin_init() that did nothing.
2023-11-27 19:08:14 +02:00
Monty
06f7ed4dcd MDEV-28566 Assertion `!expr->is_fixed()' failed in bool virtual_column_info::fix_session_expr(THD*)
The problem was that table->vcol_cleanup_expr() was not called in case
of error in open_table().
2023-11-27 19:08:14 +02:00
Monty
08e6431c8c Fixed memory leak introduces by a fix for MDEV-29932
The leaks are all 40 bytes and happens in this call stack when running
mtr vcol.vcol_syntax:

alloc_root()
...
Virtual_column_info::fix_and_check_exp()
...
Delayed_insert::get_local_table()

The problem was that one copied a MEM_ROOT from THD to a TABLE without
taking into account that new blocks would be allocated through the
TABLE memroot (and would thus be leaked).
In general, one should NEVER copy MEM_ROOT from one object to another
without clearing the copied memroot!

Fixed by, at end of get_local_table(), copy all new allocated objects
to client_thd->mem_root.

Other things:
- Removed references to MEM_ROOT::total_alloc that was wrongly left
  after a previous commit
2023-11-27 19:08:14 +02:00
Monty
8e96119159 Backport my_addr_resolve from 10.6 to get latest bug fixes in.
This will enable safemalloc to resolve symbols when compiled with
__PIE__
2023-11-27 19:08:14 +02:00
Monty
dc1165419a Do not use MEM_ROOT in set_killed_no_mutex()
The reason for this change are the following:
- If we call set_killed() from one thread to kill another thread with
  a message, there may be concurrent usage of the MEM_ROOT which is
  not supported (this could cause memory corruption).
  We do not currently have code that does this, but the API allows this
  and it is better to be fix the issue before it happens.
- The per thread memory tracking does not work if one thread uses
  another threads MEM_ROOT.
- set_killed() can be called if a MEM_ROOT allocation fails.  In this case
  it is not good to try to allocate more memory from potentially the same
  MEM_ROOT.

Fix is to use my_malloc() instead of mem_root for killed messages.
2023-11-27 19:08:14 +02:00
Monty
9e424b6290 MENT-1707 Crash at reload_acl_and_cache
The stack function trace for this bug is:

libc
my_free
free_root
acl_reload

The crash happens because acl_memroot gets corrupted.

The issue was that during FLUSH PRIVILEGES we discard the old
privileges and create new ones. We have protection in place that no
one can accesses the privileges during this time.

However one short piece of code called during login of a new user, or
change password, was not properly protected, which could in some very
rare circumstances case a memory overwrite of a MEMROOT object if
at the same time another thread calls FLUSH PRIVILEGES.

This it issue is fixed by adding protection around set_user_salt().
I also added asserts to other code that is using the acl_memroot to
ensure that it is properly proteced everywhere.
2023-11-27 19:08:14 +02:00
Anel Husakovic
18acf97dfd MDEV-32168: slave_error_param condition is never checked from the wait_for_slave_param.inc
- Record unrecorded tests from `rpl` suite to `engines/funcs` suite
(done by d8e448ba1b):
  1) Record test `rpl_row_until` from commit d95fa7e332
  2) Record test `rpl_slave_status` from commit a7d186a17d

- Stop only running threads for `engines/funcs.rpl_server_id1.test` that
is not the same as `rpl.rpl_server_id1.test`

- Reviewer:  <knielsen@knielsen-hq.org>
             <andrei.elkin@mariadb.com>
2023-11-27 14:12:22 +01:00
Thirunarayanan Balathandayuthapani
5bb31bc882 MDEV-22230 : Unexpected ER_ERROR_ON_RENAME upon DROP non-existing FOREIGN KEY
mysql_prepare_alter_table(): Alter table should check whether
foreign key exists when it expected to exists and
report the error in early stage

dict_foreign_parse_drop_constraints(): Don't throw error if the
foreign key constraints doesn't exist when if exists is given
in the statement.
2023-11-26 18:46:00 +05:30
Sergei Golubchik
c432c9ef19 MDEV-32862 MYSQL struct in C/C and server differs
move MYSQL::fields down, replacing MYSQL::unused5

this way only MYSQL::fields and MYSQL::field_alloc will still have
different offset in C/C and the server, but all other MYSQL members
will get back in sync.

luckily, plugins shouldn't need MYSQL::fields or MYSQL::field_alloc

added a check to ensure both MYSQL structures are always of
the same size.
2023-11-25 10:33:32 +01:00
Sergei Golubchik
361a11decb backport MEM_ROOT::total_alloc removal from 10.5
to fix sizeof(MEM_ROOT)
2023-11-25 10:33:32 +01:00
Sergei Golubchik
69d78cd3f8 move MEM_ROOT::read_only into flags 2023-11-25 10:33:31 +01:00
Sergei Golubchik
d1ca8fbb76 Backport MEM_ROOT::flags from 10.7 2023-11-25 10:33:31 +01:00