Commit graph

198427 commits

Author SHA1 Message Date
Alexander Barkov
1cdf22374b MDEV-34069 Zero datetime reinterprets as '1970-01-01 00:00:00' on field_datetime=field_timestamp
The code in Field_timestamp::save_in_field() did not catch
zero datetime and stored it to the other field like a usual value
using store_timestamp_dec(), which knows nothing about zero date and
treats {tv_sec=0, tv_usec=0} as a normal timeval value corresponding to
'1970-01-01 00:00:00 +00:00'.

Fixing the code to catch the special combination (ts==0 && sec_pat==0) and
store it using store_time_dec() with a zero datetime passed as an argument.
2024-05-04 22:39:58 +04:00
Vladislav Vaintroub
88f49da8e0 MDEV-34063 tpool - integer overflow in multiplication.
When calculating next wakeup timepoint for the timer thread, with large
thread_pool_stall_limit values, 32bit int overflow can happen.
Fixed by making one operand 8 byte large.

Also fixed the type of tick_interval to be unsigned, so it does not
go negative for very thread_pool_stall_limit.
2024-05-03 22:01:09 +02:00
Vladislav Vaintroub
b18259ecf5 Compiling - Fix MSVC compile warnings, on x86 2024-05-03 22:00:56 +02:00
Vladislav Vaintroub
029e2a5fd9 MDEV-33876 CMake, zlib - use names compatible with official FindZLIB.cmake
- ZLIB_LIBRARIES, not ZLIB_LIBRARY
- ZLIB_INCLUDE_DIRS, not ZLIB_INCLUDE_DIR

For building libmariadb, ZLIB_LIBRARY/ZLIB_INCLUDE_DIR are still defined
This workaround will be removed later.
2024-05-03 21:48:47 +02:00
Marko Mäkelä
9ec7819c58 MDEV-33817: AVX512BW and VPCLMULQDQ based CRC-32
This is based on https://github.com/intel/intel-ipsec-mb/
and has been tested both on x86 and x86-64, with code that
was generated by several versions of GCC and clang.
GCC 11 or clang 8 or later should be able to compile this,
and so should recent versions of MSVC.

Thanks to Intel Corporation for providing access to hardware,
for answering my questions regarding the code, and for
providing the coefficients for the CRC-32C computation.

crc32_avx512(): Compute a reverse polynomial CRC-32 using
precomputed tables and carry-less product, for up to 256 bytes
of unaligned input per loop iteration.

Reviewed by: Vladislav Vaintroub
2024-05-03 15:55:20 +03:00
Marko Mäkelä
611cd6b981 MDEV-33817 preparation: Restructuring and unit tests
In our unit test, let us rely on our own reference
implementation using the reflected
CRC-32 ISO 3309 and CRC-32C polynomials. Let us also
test with various lengths.

Let us refactor the CRC-32 and CRC-32C implementations
so that no special compilation flags will be needed and
that some function call indirection will be avoided.

pmull_supported: Remove. We will have pointers to two separate
functions crc32c_aarch64_pmull() and crc32c_aarch64().
2024-05-03 13:06:13 +03:00
Yuchen Pei
b84d335d9d
MDEV-33538 make auxiliary spider plugins init depend on actual spider
The two I_S plugins SPIDER_ALLOC_MEM and SPIDER_WRAPPER_PROTOCOL
only makes sense if the main SPIDER plugin is installed. Further,
SPIDER_ALLOC_MEM requires a mutex that requires SPIDER init to fill
the table.

We also update the spider init query to override
--transaction_read_only=on so that it does not affect the spider init.

Also fixed error handling in spider_db_init() so that failure in
spider table init does not result in memory leak
2024-05-03 14:47:54 +10:00
Vladislav Vaintroub
20f60fe70f postfix a09ebe5567 (PCRE-10.43)
- no need to switch off -fsanitize-address for MSVC anymore
- option /WX is MSVC only
- CMAKE_C_STANDARD C99 is already in pcre's own CMakeLists.txt
2024-05-02 22:13:48 +02:00
Kristian Nielsen
596921dab8 MDEV-34042: Deadlock kill of XA PREPARE can break replication / rpl.rpl_parallel_multi_domain_xa sporadic failure
Clear any pending deadlock kill after completing XA PREPARE, and before
updating the mysql.gtid_slave_pos table in a separate transaction.

Reviewed-by: Andrei Elkin <andrei.elkin@mariadb.com>
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2024-05-02 21:07:51 +02:00
Kristian Nielsen
e365877bae MDEV-33798: ROW base optimistic deadlock with concurrent writes on same table
One case is conflicting transactions T1 and T2 with different domain id, in
optimistic parallel replication in non-GTID mode. Then T2 will
wait_for_prior_commit on T1; and if T1 got a row lock wait on T2 it would
hang, as different domains caused the deadlock kill to be skipped in
thd_rpl_deadlock_check().

More generally, if we have transactions T1 and T2 in one domain/master
connection, and independent transactions U in another, then we can
still deadlock like this:

  T1 row low wait on U
  U row lock wait on T2
  T2 wait_for_prior_commit on T1

This commit enforces the deadlock kill in these cases. If the waited-for
transaction is speculatively applied, then it will be deadlock killed in
case of a conflict, even if the two transactions are in different domains
or master connections.

Reviewed-by: Andrei Elkin <andrei.elkin@mariadb.com>
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2024-05-02 21:07:45 +02:00
mariadb-DebarunBanerjee
90b95c6149 MDEV-33543 Server hang caused by InnoDB change buffer
Issue: When getting a page (buf_page_get_gen) with no latch option
(RW_NO_LATCH), the caller is not expected to follow the B-tree latching
order. However in buf_page_get_low we try to acquire shared page latch
unconditionally to wait for a page that is being loaded by another
thread concurrently. In general it could lead to latch order violation
and deadlock.

Currently it affects the change buffer insert path btr_latch_prev()
which tries to load the previous page out of order with RW_NO_LATCH and
two concurrent inserts into IBUF tree cause deadlock. This problem is
introduced in 10.6 by following commit.
commit 9436c778c3 (MDEV-27058)

Fix: While trying to latch a page with RW_NO_LATCH, always use the
"*lock_try" interface and retry operation on failure after unfixing the
page.
2024-05-02 17:07:01 +05:30
Thirunarayanan Balathandayuthapani
156761db3b MDEV-31161 Assertion failures upon adding a too long key to table with COMPRESSED row
Problem:
=======
During InnoDB non-rebuild online alter operation, InnoDB set the
dummy log to clustered index online log. This can be used by
concurrent DML to identify whether the table undergoes online DDL.
InnoDB fails to reset the dummy log of clustered index in case
of error happened during prepare phase.

Solution:
========
Reset the InnoDB clustered index online log in case of error during
prepare phase.
2024-04-30 20:40:29 +05:30
Daniel Black
e63ed4e004 MDEV-33631 Ubuntu/Debian MYSQL_SERVER_SUFFIX is version+suffix on MariaDB packaged versions
The debian/rules removed sufficient version information from the
downstream version, however the mariadb upstream has a +
separator from the suffix.

While we are at it, remove the Debian/Ubuntu revision -1.

Other revisions used:
* Debian unstable (inherited to both Debian and Ubuntu if package unchanged): 1:10.11.6-2
* Ubuntu stable updates example: 1:10.11.6-0ubuntu0.23.10.2
* Debian stable updates example: 1:10.11.4-1~deb12u1

The result is compulation with:
    -DMYSQL_SERVER_SUFFIX="-1:10.4.34+maria~deb10" \

Compared to Debian:
    -DMYSQL_SERVER_SUFFIX="-1~deb12u1" \

The impact comes into play with SELECT VERSION():
    10.4.34-MariaDB-1:10.4.34+maria~deb10

A more abbreviated form of the following is much more human/machine parsable:
    10.6.16-MariaDB~ubu2004

Reviewer: Otto Kekäläinen
2024-05-01 00:57:15 +10:00
Dimitri John Ledkov
bf77f9793d openssl: add a more specific DES support detection
Improve detection for DES support in OpenSSL, to allow compilation
against system OpenSSL without DES.

Note that MariaDB needs to be compiled against OpenSSL-like library
that itself has DES support which cmake detected. Positive detection
is indicated with CMake variable HAVE_des 1.

Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@surgut.co.uk>
2024-04-30 23:09:02 +10:00
Thirunarayanan Balathandayuthapani
f378e76434 MDEV-33980 mariadb-backup --backup is missing retry logic for undo tablespaces
Problem:
========
- Currently mariabackup have to reread the pages in case they are
modified by server concurrently. But while reading the undo
tablespace, mariabackup failed to do reread the page in case of
error.

Fix:
===
Mariabackup --backup functionality should have retry logic
while reading the undo tablespaces.
2024-04-30 16:15:26 +05:30
Bernard Spil
f9575495ce Fix typo
There is no component `SuportFiles` in MariaDB server, yet a `SupportFiles` component exists.
2024-04-30 20:30:43 +10:00
Monty
814dc46748 Fixed slow bootstrap introduced in 10.6
The problem was that the signal thread was not killed when using
unireg_abort().

The bug was introduced by:
MDEV-30260: Slave crashed:reload_acl_and_cache during shutdown

Other things fixed:
- Don't produce memory leaks with safemalloc if all threads was not
  ended properly (not useful)
2024-04-30 11:06:04 +03:00
Rucha Deodhar
9e6858a426 MDEV-22141: JSON_REMOVE returns NULL on valid arguments
Analysis:
When we scan json to get to a beginning according to the path, we end up
scanning json even if we have exhausted it. When eventually returns error.

Fix:
Continue scanning json only if we have not exhausted it and return result
accordingly.
2024-04-29 22:32:17 +05:30
Rucha Deodhar
5ca64e65d0 MDEV-32287: JSON_EXTRACT not returning multiple values for same path
Analysis:
When scanning json and getting the exact path at each step, if a path
is reached, we end up adding the item in the result and immediately get the
next item which results in current path changing.
Fix:
Instead of immediately returning the item, count the occurences of the path
in argument and append in the result as needed.
2024-04-29 22:32:17 +05:30
Rucha Deodhar
d7df63e1c9 MDEV-19487: JSON_TYPE doesnt detect the type of String Values
(returns NULL) and for Date/DateTime returns "INTEGER"

Analysis:
When the first character of json is scanned it is number. Based on that
integer is returned.
Fix:
Scan rest of the json before returning the final result to ensure json is
valid in the first place in order to have a valid type.
2024-04-29 22:32:17 +05:30
Thirunarayanan Balathandayuthapani
a586b6dbc8 MDEV-22855 Assertion `!field->prefix_len || field->fixed_len == field->prefix_len' failed in btr_node_ptr_max_size
Problem:
========
- InnoDB wrongly calulates the record size in
btr_node_ptr_max_size() when prefix index of
the column has to be stored externally.

Fix:
====
- InnoDB should add the maximum field size to
record size when the field is a fixed length one.
2024-04-29 16:42:26 +05:30
Alexander Barkov
c6e3fe29d4 MDEV-30646 View created via JSON_ARRAYAGG returns incorrect json object
Backporting add782a13e from 10.6, this fixes the problem.
2024-04-29 13:47:45 +04:00
Sergei Golubchik
c1f3eff53f Merge branch '10.5' into 10.6 2024-04-29 10:08:58 +02:00
Alexander Barkov
dc25d600ee MDEV-21058 CREATE TABLE with generated column and RLIKE results in sigabrt
Regexp_processor_pcre::fix_owner() called Regexp_processor_pcre::compile(),
which could fail on the regex syntax error in the pattern and put
an error into the diagnostics area. However, the callers:
  - Item_func_regex::fix_length_and_dec()
  - Item_func_regexp_instr::fix_length_and_dec()
still returned "false" in such cases, which made the code
crash later inside Diagnostics_area::set_ok_status().

Fix:

- Change the return type of fix_onwer() from "void" to "bool"
  and return "true" whenever an error is put to the DA
  (e.g. on the syntax error in the pattern).
- Fixing fix_length_and_dec() of the mentioned Item_func_xxx
  classes to return "true" if fix_onwer() returned "true".
2024-04-29 11:08:07 +04:00
Yuchen Pei
3f2a5b28c6
MDEV-34003 Add testcase spider/bugfix.mdev_34003
MDEV-34003 appears to be a duplicate of MDEV-33742, and no code change
is needed. Nevertheless we add the testcase reported in the former.
2024-04-29 16:42:46 +10:00
Yuchen Pei
267dd5a993
MDEV-30727 Check spider_hton_ptr in spider udfs
We have to #undef my_error and find it from udfs when spider is not
installed.
2024-04-29 16:17:22 +10:00
mariadb-DebarunBanerjee
52f6df99ed MDEV-33669 mariabackup --backup hangs
This is a server hang and not an issue with backup. While concurrent
DDLs in server gets in hanged state, mariabackup waits for DDLs to
finish trying to acquire MDL_BACKUP_BLOCK_DDL.

The server hang is serious in nature and caused by thread pool state
being incorrectly set to thread creation pending state while no creation
is actually pending. Once a thread pool reaches such state no new thread
gets created in the pool.

While it could possibly affect all thread pools in server, the innodb
thread pool is the victim in current bug where IO job gets blocked when
the pool is stuck with much less number of threads than intended.
Available workers are blocked in purge waiting for page lock to be
released by IO write (SX lock) causing a complete deadlock.

The issue is caused by the state variable m_thread_creation_pending
introduced by MDEV-31095: 9e62ab7aaf. We check and set the variable
early while attempting to create a new thread in pool but fail to reset
it if we exit the flow for other reasons like maximum threads reached
or get into thread creation throttling path.

Fix: The simple fix is to make sure that the state is reset back in case
we don't actually attempt to create the thread.
2024-04-29 08:25:18 +05:30
Oleksandr Byelkin
bda8d4fdf7 require boost 1.53 for columnstore 2024-04-28 18:09:13 +02:00
Oleksandr Byelkin
a09ebe5567 PCRE2-10.43
pcre2 - fix CMAKE_C_FLAGS for MSVC for external project by Vladislav Vaintroub <vvaintroub@gmail.com>
2024-04-28 18:09:13 +02:00
Alexander Barkov
3141a68b7c MDEV-33534 UBSAN: Negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_double_round from sql/item_func.cc|
The negation in this line:
  ulonglong abs_dec= dec_negative ? -dec : dec;
did not take into account that 'dec' can be the smallest possible
signed negative value -9223372036854775808. Its negation is
an operation with an undefined behavior.

Fixing the code to use Longlong_hybrid, which implements a safe
method to get an absolute value.
2024-04-27 23:16:35 +04:00
mkaruza
136358036d MDEV-18590: galera.versioning_trx_id: Test failure: mysqltest: Result content mismatch
Replicated events have time associated with them from originating
node which will be used for commit timestamp. Associated time can
be set in past before event is even applied.

For WSREP replication we don't need to use time information from
event.

Addressed review comments:
	  Jan Lindström <jan.lindstrom@galeracluster.com>

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-04-27 18:40:58 +02:00
Jan Lindström
1532f12058 MDEV-33898 : Galera test failure on galera.MW-369
Tests using MW-369.inc sometimes hanged after
signaling two debug sync points inside a Galera
library. Replaced Galera library sync point
with server code sync point when possible and
added more wait_conditions to make sure we are
in correct state.

Tests effected: MW-369, MW-402, MDEV-27276, and
mysql-wsrep#332.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-04-26 20:21:44 +02:00
Julius Goryavsky
288ea9e146 galera SST scripts: parsing CN in certificates
This commit contains a fix for the code that extracts and parses
the CN (common name, domain name) record from certificates using
the openssl utility. This code is also made common to the rsync
and mariabackup scripts. There is also some systematization of
the use of 'printf' and 'echo' builtins/utilities.
2024-04-26 20:21:44 +02:00
Oleksandr Byelkin
ee59ca7ff1 Merge branch 'merge-zlib' (1.3.1) into 10.4 2024-04-26 13:50:03 +02:00
Hugo Wen
3d41747625 MDEV-33574 Improve mysqlbinlog error message
Previously, when running mysqlbinlog without providing a binlog file, it
would print the entire help text, which was very verbose and made it
difficult to identify the actual issue.

Now change the behavior to print a more concise error message instead:

    "ERROR: Please provide the log file(s). Run with '--help' for usage instructions."

This makes the error output more user-friendly and easier to understand,
especially when running the tool in scripts or automated processes.

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.
2024-04-26 12:27:28 +01:00
Oleksandr Byelkin
5aff13b65c zlib 1.3.1 2024-04-26 13:18:51 +02:00
Oleksandr Byelkin
45846bacb3 v5.7.0-stable 2024-04-26 13:02:47 +02:00
Daniele Sciascia
ef7a2344af Fixup 0ccdf54b64
0ccdf54 removed stack allocated THD objects from functions
Wsrep_schema::replay_transaction(). However, it inadvertedly
anticipated the destruction of the THD, causing assertions and usage
of THD after it was destroyed.
The fix consists in extracting the original function into a separate
function, and leave the allocation and destruction of the THD object
in Wsrep_schema::replay_transaction(), making sure that using the heap
allocated THD has no side effects.
Same for Wsrep_schema::recover_sr_transactions().

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-04-26 11:18:36 +02:00
Jan Lindström
b3e531a3cc MDEV-33896 : Galera test failure on galera_3nodes.MDEV-29171
Based on logs we might start SST before donor has reached
Primary state. Because this test shutdowns all nodes we
need to make sure when we start nodes that previous nodes
have reached Primary state and joined the cluster.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-04-25 16:32:06 +02:00
Marko Mäkelä
10d251e05a MDEV-26450 fixup: Remove a bogus assertion
mtr_t::commit_shrink(): Do not assert that some previously clean pages
will be flagged as modified by this mini-transaction. It could be the
case that there had been no recent write-back of any of the undo
tablespace pages that we are modifying when truncating the tablespace.
It suffices to assert that some pages were modified again:
ut_ad(m_modifications).

This fixes up commit f5fddae3cb
2024-04-25 15:52:38 +03:00
Oleksandr Byelkin
62287320d4 MDEV-33790 Incorrect DEFAULT expression evaluated in UPDATE
The problem was that Item_default_value::associate_with_target_field
assigned passed as argument field as an argument which changed argument
in case of default() call with certain field (i.e. deault(field)).

There is no way to get wrong field in constructor so we will not reassign
parameter.
2024-04-25 14:11:28 +02:00
Marko Mäkelä
0936c13809 MDEV-33993 Possible server hang on DROP INDEX or RENAME INDEX
commit_try_norebuild(): Add the parameter statistics_exist,
similar to commit_try_rebuild(). If the InnoDB statistics tables
did not exist, we will not attempt to update statistics later on
during the transaction.

Thanks to Matthias Leich for originally reproducing this scenario.
2024-04-25 13:44:10 +03:00
Marko Mäkelä
77d5104fee Remove a bogus workaround for old GCC
At least starting with ca83115b3e
the source code cannot be compiled with anything older than GCC 4.8.5.

Furthermore, 64-bit atomic read-modify-write operations on IA-32
would depend on the LOCK CMPXCHG8B instruction, which was introduced
in the Intel Pentium. Our IA-32 builds ought to be -march=i686
starting with commit 9cabc9fd8a.

Approved by Sergei Golubchik
2024-04-25 12:58:32 +03:00
Kristian Nielsen
553a4d6271 MDEV-33602: Sporadic test failure in rpl.rpl_gtid_stop_start
The test could fail with a duplicate key error because switching to non-GTID
mode could start at the wrong old-style position. The position could be
wrong when the previous GTID connect was stopped before receiving the fake
GTID list event which gives the old-style position corresponding to the GTID
connected position.

Work-around by injecting an extra event and syncing the slave before
switching to non-GTID mode.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2024-04-25 11:00:45 +02:00
Marko Mäkelä
a1c1f5029e MDEV-33974 Enable GNU libstdc++ debugging
Starting with GCC 10, let us enable _GLIBCXX_DEBUG as well as
_GLIBCXX_ASSERTIONS which have an impact on the GNU libstdc++.
On GCC 8, we observed a compilation failure related to some
missing type conversion.

Even though clang on GNU/Linux would default to using libstdc++
and enabling the debugging seems to work with clang-18, we will
not enable this on clang, in case it would lead to compilation
errors.

For the clang libc++ before clang-15 there was _LIBCPP_DEBUG,
but according to
llvm/llvm-project@f3966eaf86 and
llvm/llvm-project@13ea134323 and
llvm/llvm-project@ff573a42cd it
looks like that for proper results, a specially built debug version
of libc++ would have to be used in order to enable equivalent checks.

This should help catch bugs like the one that
commit 455a15fd06 fixed.

Reviewed by: Sergei Golubchik
2024-04-25 11:05:03 +03:00
Thirunarayanan Balathandayuthapani
8c8b7da017 MDEV-33979 Disallow bulk insert operation during partition update statement
Problem:
========
- Partition update operation enables the bulk insert for the
transaction while moving the row between partitions. This leads
to debug assert failure while removing the row from one
of the partition.

Solution:
========
- Disallow the bulk insert operation for non-insert operation
of partition table.
2024-04-25 10:50:34 +05:30
Marko Mäkelä
7229384256 MDEV-23974 fixup: Cover all debug builds
While commit 75b7cd680b was a significant
improvement, we occasionally got test failures of debug builds. One of
the affected tests is innodb.innodb-64k-crash.
2024-04-25 07:48:57 +03:00
Sergei Golubchik
7d5e08de6b MDEV-20157 perfschema.stage_mdl_function failed in buildbot with wrong result
MDL wait consists of short 1 second waits (this is not configurable)
repeated until lock_wait_timeout is reached. The stage is changed
to Waiting and back every second. To have predictable result in the
test the query should filter all sequences of X, "Waiting for MDL", X,
leaving just X.
2024-04-24 18:09:58 +02:00
Sergei Golubchik
259394aed7 disable mariabackup.incremental_encrypted,64k on 32bit
it allocates 1GB of memory, it causes failures in CI
2024-04-24 18:09:20 +02:00
Sergei Golubchik
e2f95ebbcb fix galera_3nodes.galera_gtid_consistency to work with nc
like other galera tests do
2024-04-24 18:09:20 +02:00