Commit graph

192885 commits

Author SHA1 Message Date
Oleksandr Byelkin
50998a6c6f MDEV-33861 main.query_cache fails with embedded after enabling WITH_PROTECT_STATEMENT_MEMROOT
Synopsis: If SELECT returned answer from Query Cache it is not really executed.

The reason for firing of assertion
  DBUG_ASSERT((mem_root->flags & ROOT_FLAG_READ_ONLY) == 0);
is that in case the query_cache is on and the same query run by different
stored routines the following use case can take place:
First, lets say that bodies of routines used by the test case are the same
and contains the only query 'SELECT * FROM t1';
  call p1() -- a result set is stored in query cache for further use.
  call p2() -- the same query is run against the table t1, that result in
               not running the actual query but using its cached result.
               On finishing execution of this routine, its memory root is
               marked for read only since every SP instruction that this
               routine contains has been executed.
  INSERT INT t1 VALUE (1); -- force following invalidation of query cache
  call p2() -- query the table t1 will result in assertion failure since its
               execution would require allocation on the memory root that
               has been already marked as read only memory root

The root cause of firing the assertion is that memory root of the stored
routine 'p2' was marked as read only although actual execution of the query
contained inside hadn't been performed.

To fix the issue, mark a SP instruction as not yet run in case its execution
doesn't result in real query processing and a result set got from query cache
instead.

Note that, this issue relates server built in debug mode AND with the protect
statement memory root feature turned on. It doesn't affect server built
in release mode.
2024-04-16 08:52:51 +02:00
Yuchen Pei
051a1fa0e9
MDEV-33777 Spider: Correct checks for show index column numbers
It was updated for 10.6+ in MDEV-7317. Because a lower version spider
node may connect to a higher version data node, we need to change this
for 10.4 and 10.5 as well.
2024-04-15 09:59:24 +10:00
Yuchen Pei
18b93d6eb0
MDEV-28993 Spider: Push down CASE statement 2024-04-15 09:56:24 +10:00
Yuchen Pei
99dc0f030f
MDEV-28993 spider: revert removal of ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC
It was done in MDEV-29447.
2024-04-15 09:56:23 +10:00
Vlad Lesin
d7fc975cfe MDEV-33802 Weird read view after ROLLBACK of other transactions.
In the case if some unique key fields are nullable, there can be
several records with the same key fields in unique index with at least
one key field equal to NULL, as NULL != NULL.

When transaction is resumed after waiting on the record with at least one
key field equal to NULL, and stored in persistent cursor record is
deleted, persistent cursor can be restored to the record with all key
fields equal to the stored ones, but with at least one field equal to
NULL. And such record is wrongly treated as a record with the same unique
key as stored in persistent cursor record one, what is wrong as
NULL != NULL.

The fix is to check if at least one unique field is NULL in restored
persistent cursor position, and, if so, then don't treat the record as
one with the same unique key as in the stored record key.

dict_index_t::nulls_equal was removed, as it was initially developed for
never existed in MariaDB "intrinsic tables", and there is no code, which
would set it to "true".

Reviewed by Marko Mäkelä.
2024-04-12 18:13:51 +03:00
Marko Mäkelä
d824977598 MDEV-33512 Corrupted table after IMPORT TABLESPACE and restart
In commit d74d95961a (MDEV-18543)
there was an error that would cause the hidden metadata record
to be deleted, and therefore cause the table to appear corrupted
when it is reloaded into the data dictionary cache.

PageConverter::update_records(): Do not delete the metadata record,
but do validate it.

RecIterator::open(): Make the API more similar to 10.6, to simplify
merges.
2024-04-10 09:47:44 +03:00
Yuchen Pei
662bb176b4
MDEV-33661 MENT-1591 Keep spider in memory until exit in ASAN builds
Same as MDEV-29579. For some reason, libodbc does not clean up
properly if unloaded too early with the dlclose() of spider. So we add
UNIQUE symbols to spider so the spider does not reload in dlclose().

This change, however, uncovers some hidden problems in the spider
codebase, for which we move the initialisation of some spider global
variables into the initialisation of spider itself.

Spider has some global variables. Their initialisation should be done
in the initialisation of spider itself, otherwise, if spider were
re-initialised without these symbol being unloaded, the values could
be inconsistent and causing issues.

One such issue is caused by the variables
spider_mon_table_cache_version and spider_mon_table_cache_version_req.
They are used for resetting the spider monitoring table cache and have
initial values of 0 and 1 respectively. We have that always
spider_mon_table_cache_version_req >= spider_mon_table_cache_version,
and when the relation is strict, the cache is reset,
spider_mon_table_cache_version is brought to be equal to
spider_mon_table_cache_version_req, and the cache is searched for
matching table_name, db_name and link_idx. If the relation is equal,
no reset would happen and the cache would be searched directly.

When spider is re-inited without resetting the values of
spider_mon_table_cache_version and spider_mon_table_cache_version_req
that were set to be equal in the previous cache reset action, the
cache was emptied in the previous spider deinit, which would result in
HA_ERR_KEY_NOT_FOUND unexpectedly.

An alternative way to fix this issue would be to call the spider udf
spider_flush_mon_cache_table(), which increments
spider_mon_table_cache_version_req thus making sure the inequality is
strict. However, there's no reason for spider to initialise these
global variables on dlopen(), rather than on spider init, which is
cleaner and "purer".

To reproduce this issue, simply revert the changes involving the two
variables and then run:

mtr --no-reorder spider.ha{,_part}
2024-04-10 10:10:30 +10:00
Yuchen Pei
a73c3f1077
MDEV-21007 Do not assert auto_increment_value unless all parts open
Commit 6dce6aeceb breaks out of a loop
in ha_partition::info when some partitions aren't opened, in which
case auto_increment_value assertion will fail. This commit patches
that hole.
2024-04-08 16:35:21 +10:00
Yuchen Pei
f9e0ebeca4
MDEV-33742 Do not create group by handler when all tables are constant 2024-04-08 14:35:36 +10:00
Yuchen Pei
e865ef6a04
MDEV-33742 Remove macro PARTITION_HAS_GET_CHILD_HANDLERS
Similar to MDEV-27658.

Also fixing the positioning of #ifdef WITH_PARTITION_STORAGE_ENGINE
blocks and add missing ones.
2024-04-08 14:35:36 +10:00
Yuchen Pei
860c1ca9ad
MDEV-33679 Spider group by handler: skip on multiple equalities
The spider group by handler is created in
JOIN::make_aggr_tables_info(), by which time calls to
substitute_for_best_equal_field() should have already removed all the
multiple equalities (i.e. Item_equal, with MULT_EQUAL_FUNC func_type).
Therefore, if there is still such items, it is deemed as an optimizer
bug and should be skipped.
2024-04-08 14:35:35 +10:00
Yuchen Pei
9c93d41ad7
MDEV-33728 spider: remove use of MYSQL_VERSION_ID and MARIADB_BASE_VERSION
change created by:

unifdef -DMYSQL_VERSION_ID=100400 -DMARIADB_BASE_VERSION -m storage/spider/spd_* storage/spider/ha_spider.* storage/spider/hs_client/*

basically MDEV-27637, MDEV-27641, MDEV-27655
2024-04-08 14:35:35 +10:00
Yuchen Pei
44c88faeca
MDEV-28992 Spider group by handler: Push down TIMESTAMPDIFF function
Also removed ITEM_FUNC_TIMESTAMPDIFF_ARE_PUBLIC.

Similar to pr#2225, with the testcase adapted from that patch:

--8<---------------cut here---------------start------------->8---
From 884f7c6df1 Mon Sep 17 00:00:00 2001
From: "Norio Akagi (norakagi)" <norakagi@amazon.com>
Date: Wed, 3 Aug 2022 23:30:34 -0700
Subject: [PATCH] [MDEV-28992] Push down TIMESTAMP_DIFF in spider

This changes so that TIMESTAMP_DIFF function in a query is pushed down and works natively in Spider.
Instead of directly accessing item's member, now we can rely on a public accessor method to make it work.
Unit tests are added under spider.pushdown_timestamp_diff.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer
Amazon Web Services, Inc.
--8<---------------cut here---------------end--------------->8---
2024-04-08 14:35:35 +10:00
Yuchen Pei
11fe2ee0af
MDEV-33493 Spider: Make a symlink result file a normal file 2024-04-08 14:35:35 +10:00
Yuchen Pei
504925c416
MDEV-33434 spider direct sql: Check length before memcpy
similar to MDEV-30981
2024-04-08 14:35:34 +10:00
Thirunarayanan Balathandayuthapani
9b5d711ac3 MDEV-20094 InnoDB blob allocation allocates extra extents
- InnoDB reserves the free extents unnecessarily during blob
page allocation even though btr_page_alloc() can handle
reserving the extent when the existing ran out of pages to be used.
2024-04-05 19:55:57 +05:30
Sergei Petrunia
8cc36fb743 MDEV-21102: Server crashes in JOIN_CACHE::write_record_data upon EXPLAIN with subqueries
JOIN_CACHE has a light-weight initialization mode that's targeted at
EXPLAINs. In that mode, JOIN_CACHE objects are not able to execute.

Light-weight mode was used whenever the statement was an EXPLAIN. However
the EXPLAIN can execute subqueries, provided they enumerate less than
@@expensive_subquery_limit rows.

Make sure we use light-weight initialization mode only when the select is
more expensive @@expensive_subquery_limit.

Also add an assert into JOIN_CACHE::put_record() which prevents its use
if it was initialized for EXPLAIN only.
2024-04-04 10:30:09 +03:00
Daniele Sciascia
a618ff2b1c MDEV-33216 stack-use-after-return in Wsrep_schema_impl::open_table()
Fix a case of stack-use-after-return reported by ASAN in
Wsrep_schema_impl::open_table(). This function has a stack allocated
TABLE_LIST object and return TABLE_LIST::table to the caller.
Changed the function to take a TABLE_LIST pointer as argument.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-03-28 10:55:37 +01:00
Dmitry Shulga
c81139357a MDEV-14959: the follow-up patch to turn on the option -DWITH_PROTECT_STATEMENT_MEMROOT by default 2024-03-28 11:48:32 +07:00
Yuchen Pei
e6d12bb459
MDEV-33661 MENT-1591 Fix spider/bugfix.mdev_28856 because of MDEV-29718.
The failure should be table not found, rather than no spider same
server link
2024-03-28 09:32:59 +11:00
Yuchen Pei
0b627377a9
MDEV-33661 MENT-1591 Documenting spider_mon_table_cache and friends.
Partial documentation due to time constraints. Will improve over time.

Also removed a redundant parameter link_idx from
spider_get_sys_tables_connect_info().

And deleted some commented out code.
2024-03-28 09:32:53 +11:00
Julius Goryavsky
fa1ae367f1 galera: wsrep-lib submodule update 2024-03-27 04:31:45 +01:00
Daniele Sciascia
c71dc39529 MDEV-26499 Fix error "mysql_shutdown failed" during MTR tests
- Fix to avoid mysqltest client getting killed abruptly during
  mysql_shutdown(). When Galera replication is shutdown, wait for
  THDs with `thd->stmt_da()->is_eof()` to disconnect (these are about
  to disconnect anyway).
- Extract duplicate code from `wsrep_stop_replication()` and
  `wsrep_shutdown_replication()` in a new function.
- No need to use a custom `shutdown_mysqld.inc` in galera
  suite. Delete it, so that the one in `mysql-test/include/` is used.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-03-27 04:31:45 +01:00
Yuchen Pei
db0b9ec37b
MDEV-33584 Use the default SQL_MODE for spider init queries
This should fix all future problems caused by a non-default global
sql_mode from the server where spider is to be installed.
2024-03-27 11:40:41 +11:00
Yuchen Pei
9d34939c6e
MDEV-33494 fix spider init with no_zero_date global sql mode
Like the fix for MDEV-32753 and MDEV-33242, spider init queries
creates new connections that use the global sql_mode of the existing
connection.
2024-03-27 11:35:23 +11:00
Thirunarayanan Balathandayuthapani
bf49e7cfc7 MDEV-33770 Alter operation hangs when encryption thread works on the same tablespace
- Background encryption threads wait for stop flag
to exit early from the tablespace. Alter operation
fails to set the stop flag before waiting for the
encryption thread to stop using the tablespace.
2024-03-26 19:19:53 +05:30
Vladislav Vaintroub
d695e2de54 MDEV-33506 Show original IP in the "aborted" message.
Add "real ip:<ip_or_localhost>" part to the aborted message
Only for proxy-protocoled connection, so it does not  not to cause
confusion to normal users.
2024-03-26 13:10:36 +01:00
Sergei Petrunia
ed027d65f1 MDEV-33747: Optimization of (SELECT) IN (SELECT ...) executes subquery at prepare stage
Make IN->EXISTS rewrite not to compute constant left expression if it
has a subquery in it.
2024-03-26 12:45:36 +03:00
Marko Mäkelä
17573166c4 MDEV-22742 fixup: Remove a suppression 2024-03-26 10:47:50 +02:00
Marko Mäkelä
9b7c2c6b00 MDEV-33220 fixup: Remove some initialization 2024-03-26 10:47:43 +02:00
Daniele Sciascia
e0c8165487 MDEV-33509 Failed to apply write set with flags=(rollback|pa_unsafe)
Fix function `remove_fragment()` in wsrep_schema so that no error is
raised if the fragment to be removed is not found in the
wsrep_streaming_log table. This is necessary to handle the case where
streaming transaction in idle state is BF aborted. This may result in
the case where the rollbacker thread successfully removes the
transaction's fragments, followed by the applier's attempt to remove
the same fragments. Causing the node to leave the cluster after
reporting a "Failed to apply write set" error.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-03-26 05:56:37 +01:00
Yuchen Pei
ef9cdacf51
MDEV-33220 Fix -wmaybe-uninitialized warnings for g++-13 2024-03-25 12:56:00 +11:00
Marko Mäkelä
2250b42f52 Fix heap-use-after-free in fts_free()
This fixes up 83a87da430
2024-03-21 16:01:29 +02:00
Marko Mäkelä
5d85749953 Cleanup: Remove unused DYN_BLOCK_FULL_FLAG
This had become unused in commit 2e814d4702
or mysql/mysql-server@eca5b0fc17.
This cleanup affects mtr_buf_t::used().
2024-03-21 14:20:33 +02:00
Marko Mäkelä
59e7289b6c Fix g++-14 -Wmaybe-uninitialized 2024-03-19 08:10:42 +02:00
Marko Mäkelä
2a8c4ccf2e Fix g++-14 -Wtemplate-id-cdtor 2024-03-19 08:09:31 +02:00
Marko Mäkelä
83a87da430 Fix g++-14 -Wmaybe-uninitialized 2024-03-19 08:08:18 +02:00
Marko Mäkelä
2ba4248334 Fix g++-14 -Wcalloc-transposed-args 2024-03-19 08:07:41 +02:00
Vladislav Vaintroub
af85e2ba19 MTR, Windows - remove --verbose-restart output on buildbot run
MTR buildbot output suggest that buildbot can lose some stdout information
by overwriting it with stderr, which is captured separately

This is bad, since stdout contains information about failing test.
So, this is an attempt to minimize the damage by excluding most frequent
stderr messages - those about restart.
2024-03-18 22:28:16 +01:00
Vladislav Vaintroub
5abf0fea51 mtr - synchronize output between different threads on Windows.
An attempt to fix lost output sometimes seen on buildbot.
2024-03-18 22:03:21 +01:00
mariadb-DebarunBanerjee
d912a6369c MDEV-31154 Fatal InnoDB error or assertion `!is_v' failure upon multi-update with indexed virtual column
MDEV-33558 Fatal error InnoDB: Clustered record field for column x not found

This is issue is about row ID filtering used with index on virtual
column(s). We hit debug assert and crash while building the record
template in Innodb. The primary reason is that we try to force the code
path to use the ICP path. With ICP, we don't support index with virtual
column and we validate it while index condition is pushed.

Simplify the code for building template to handle both ICP and Row ID
filtering by skipping virtual columns.
2024-03-15 19:29:46 +05:30
Thirunarayanan Balathandayuthapani
f5df4482e0 MDEV-33214 Table is getting rebuild with ALTER TABLE ADD COLUMN
Problem:
======
- InnoDB fail to do instant operation while adding the variable
length column. Problem is that InnoDB wrongly assumes that
variable character length can never part of externally stored
page.

Solution:
========
instant_alter_column_possible(): Variable length
character field can be stored as externally stored page.
2024-03-15 14:04:59 +05:30
Kristian Nielsen
ef7abc881c MDEV-10793: MDEV-33292: main.kill_processlist-6619 fails sporadically in buildbot
There were several races in the main.kill_processlist-6619 testcase:

 - Lingering connections from a previous test case could be visible in SHOW
   PROCESSLIST and cause .result diff.
 - A sync point "dispatch_command_end" was ineffective, as it was consumed at
   the end of the SET DEBUG command itself.
 - The signal from sync point "before_execute_sql_command" could override an
   earlier signal, causing DEBUG_SYNC timeout and test failure.
 - The final SHOW PROCESSLIST could occasionally see a connection in state
   "Busy" instead of the expected "Sleep".

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2024-03-14 22:48:12 +01:00
Monty
ae063e4ff5 Fixed random failure in main.kill_processlist-6619
The problem was that SHOW PROCESSLIST was done before the command of
the default connection was cleared.

Reviewer: Sergei Golubchik <serg@mariadb.org>
2024-03-14 21:02:29 +01:00
Dmitry Shulga
d7758debae MDEV-33218: Assertion `active_arena->is_stmt_prepare_or_first_stmt_execute() || active_arena->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed in st_select_lex::fix_prepare_information
In case there is a view that queried from a stored routine or
a prepared statement and this temporary table is dropped between
executions of SP/PS, then it leads to hitting an assertion
at the SELECT_LEX::fix_prepare_information. The fired assertion
 was added by the commit 85f2e4f8e8
(MDEV-32466: Potential memory leak on executing of create view statement).
Firing of this assertion means memory leaking on execution of SP/PS.
Moreover, if the added assert be commented out, different result sets
can be produced by the statement SELECT * FROM the hidden table.

Both hitting the assertion and different result sets have the same root
cause. This cause is usage of temporary table's metadata after the table
itself has been dropped. To fix the issue, reload the cache of stored
routines. To do it  cache of stored routines is reset at the end of
execution of the function dispatch_command(). Next time any stored routine
be called it will be loaded from the table mysql.proc. This happens inside
the method Sp_handler::sp_cache_routine where loading of a stored routine
is performed in case it missed in cache. Loading is performed unconditionally
while previously it was controlled by the parameter lookup_only. By that
reason the signature of the method Sroutine_hash_entry::sp_cache_routine
was changed by removing unused parameter lookup_only.

Clearing of sp caches affects the test main.lock_sync since it forces
opening and locking the table mysql.proc but the test assumes that each
statement locks its tables once during its execution. To keep this invariant
the debug sync points with names "before_lock_tables_takes_lock" and
"after_lock_tables_takes_lock" are not activated on handling the table
mysql.proc
2024-03-14 15:43:03 +07:00
Kristian Nielsen
0a6f46965a MDEV-33475: --gtid-ignore-duplicate can double-apply event in case of parallel replication retry
When rolling back and retrying a transaction in parallel replication, don't
release the domain ownership (for --gtid-ignore-duplicates) as part of the
rollback. Otherwise another master connection could grab the ownership and
double-apply the transaction in parallel with the retry.

Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2024-03-13 16:59:10 +01:00
Oleksandr Byelkin
7bcacd767a MDEV-21864 Commands start-all-slaves and stop-all-slaves are not listed in mysqladmin help
Added commands to the help
2024-03-13 14:01:07 +01:00
Dmitry Shulga
ac20edd737 MDEV-33549: Incorrect handling of UPDATE in PS mode in case a table's colum declared as NOT NULL
Follow-up to fix comiler warings caused by present of
the clause override in declaration of the method Item_param::cleanup
2024-03-13 17:46:05 +07:00
Dmitry Shulga
428a673152 MDEV-33549: Incorrect handling of UPDATE in PS mode in case a table's colum declared as NOT NULL
UPDATE statement that is run in PS mode and uses positional parameter
handles columns declared with the clause DEFAULT NULL incorrectly in
case the clause DEFAULT is passed as actual value for the positional
parameter of the prepared statement. Similar issue happens in case
an expression specified in the DEFAULT clause of table's column definition.

The reason for incorrect processing of columns declared as DEFAULT NULL
is that setting of null flag for a field being updated was missed
in implementation of the method Item_param::assign_default().
The reason for incorrect handling of an expression in DEFAULT clause is
also missed saving of a field inside implementation of the method
Item_param::assign_default().
2024-03-12 16:13:49 +07:00
Marko Mäkelä
0a9cec229a MDEV-33642: MemorySanitizer: SEGV on unknown address on shutdown
signal_hand(): Remove the cmake -DWITH_DBUG_TRACE=ON instrumentation.
It can cause a crash on shutdown when the only other thread is
waiting in wait_for_signal_thread_to_end().
2024-03-11 16:14:54 +02:00