1
0
mirror of https://github.com/MariaDB/server.git synced 2025-09-15 05:41:27 +03:00

18982 Commits

Author SHA1 Message Date
Sergei Golubchik
e02f4d7e31 12.2 branch 2025-08-04 21:28:16 +02:00
Pekka Lampio
603afc82d2 MDEV-36554: Assertion `is_wsrep() == wsrep_on(mysql_thd)' failed in void trx_t::commit_in_memory(const mtr_t*)
This bug fix prevents debug assertion failure when Galera feature
retry applying is enabled. This patch introduces also a general
mechanism for temporarily disabling some debug assertions in InnoDB
code.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-08-04 14:58:18 +02:00
Pekka Lampio
b39ea86305 MDEV-36077: Galera feature: Retry applying writesets at slaves
A new Galera feature that allows retrying of applying of writesets at
slave nodes (codership/mysql-wsrep-bugs/#1619). Currently replication
applying stops for first non ignored failure occurring in event
applying, and node will do emergency abort (or start inconsistency
voting). Some failures, however, can be concurrency related, and
applying may succeed if the operation is tried at later time.

This feature introduces a new dynamic global option variable
"wsrep_applier_retry_count" that controls the retry-applying feature:
a zero value disables retrying and a positive value sets the maximum
number of retry attempts. The default value for this option is zero,
which means that this feature is disabled by default.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-08-04 14:58:10 +02:00
Oleksandr Byelkin
dae5a99c73 MDEV-13817 add support for oracle left join syntax - the ( + )
Parser changes made by Alexander Barkov <bar@mariadb.com>.

Part of the tests made by Iqbal Hassan <iqbal@hasprime.com>.
Initially marking with ORA_JOIN flag made also by
Iqbal Hassan <iqbal@hasprime.com>.

Main idea is that parser mark fields with (+) with a flag
(ORA_JOIN).

During Prepare the flag bring to the new created items if needed.

Later after preparing (fix_firlds()) WHERE confition the
relations betweel the tables analyzed and tables reordered
so to make JOIN/LEFT JOIN operators in chain equivalent to
the query with oracle outer join operator (+).

Then the flags of (+) removed.
2025-08-04 12:05:53 +02:00
Sergei Golubchik
6e8dbb9693 Merge branch '12.0' into 12.1
wsrep.wsrep_off: update the result file after c4cad8d50c
2025-08-03 15:01:09 +02:00
Sergei Golubchik
90f5e09956 fix tests for --view
bead24b7f3 has unintentionally enabled many tests for --view.
these tests never run with --view before and needed fixing.
2025-08-03 14:59:18 +02:00
Sergei Golubchik
1563988ae6 MDEV-37160 When >=2 clients are in use, the server_audit_file_buffer_size setting is not honored
initialize cn->sync_statement everywhere where cn->thread_id is

followup for ef3c843c17 and 7251cbca51
2025-08-02 15:24:34 +02:00
Sergei Golubchik
ef3c843c17 MDEV-34680 post-fixes
* clarify the help text for --server-audit-file-rotate-size
* initialize cn->sync_statement, otherwise new connection randomly syncs
* and DON'T SPAM syslog
2025-08-01 18:00:53 +02:00
Alexey Botchkov
7251cbca51 MDEV-34680 Asynchronous and Buffered Logging for Audit Plugin.
Buffering with the IO_CACHE added to the file logger.
2025-08-01 18:00:49 +02:00
Sergei Golubchik
26c8bc9357 mtr: make wait_for_line_count_in_file.inc leave traces in the log 2025-08-01 18:00:45 +02:00
Sergei Golubchik
aab83aecdc Merge branch '11.8' into 12.0
main/statistics_json.result is updated for f8ba5ced55 (MDEV-36099)

The test uses 'delete from t1' in many places and then populates
the table again. The natural order of rows in a MyISAM table is well
defined and the test was implicitly relying on that.

before f8ba5ced55 delete was deleting rows one by one, using
ha_myisam::delete_row() because the connection was stuck in rbr mode.
This caused rows to be shown in the reverse insertion order (because of
the delete link list).

MDEV-36099 fixes this bug and the server now correctly uses
ha_myisam::delete_all_rows(). This makes rows to be shown in the
insertion order as expected.
2025-07-31 20:55:47 +02:00
Sergei Golubchik
5008e33eac fix sporadic failures of rpl.rpl_drop_temp test
the test forces create_tmp_table_binlog_formats="statement,mixed",
so CREATE TEMPORARY TABLE is always logged, and the test should
thus always wait for it
2025-07-31 20:54:41 +02:00
Sergei Golubchik
dfe4f82ebf update engines/funcs.rpl_stm_reset_slave
in 12.0 temp table replication was changed, mixed behaves as row
in this test, not as statement
2025-07-31 20:54:37 +02:00
Sergei Golubchik
f984eecef8 bump the VERSION 2025-07-29 19:45:04 +02:00
Monty
51602dcc99 MDEV-36980 Assertion `thd->mdl_context.is_lock_owner()...fails in close_thread_table
The problem is that a few constructs are missing from atomic create table
patch that is not yet committed:

- table_creation_was_logged is now set to 1 when logging create temporary.
- Testing for BINLOG_FORMAT_STMT changed to binlog_create_tmp_table() to
  take create_tmp_table_binlog_formats value into account.
- When logging the table creation of temporary tables to the binlog, the
  source table was used instead of the newly temporary table.
2025-07-29 15:05:28 +02:00
Sergei Golubchik
b565b3e7e0 Merge branch '11.4' into 11.8 2025-07-28 21:29:29 +02:00
Sergei Golubchik
c4ed889b74 Merge branch '10.11' into 11.4 2025-07-28 19:40:10 +02:00
Sergei Golubchik
053f9bcb5b Merge branch '10.6' into 10.11 2025-07-28 18:06:31 +02:00
Sergei Golubchik
cbcb080a1f MDEV-37328 Assertion failure in make_empty_rec upon CONVERT PARTITION
ALTER TABLE ... CONVERT invokes build_frm_image() three times on
the same data structures. The latter should not increment
create_info->null_bits on every invocation.
2025-07-28 18:06:11 +02:00
Sergei Golubchik
633417308f MDEV-37312 ASAN errors or assertion failure upon attempt to UPDATE FOR PORTION violating long unique under READ COMMITTED
in case of a long unique conflict ha_write_row() used delete_row()
to remove the newly inserted row, and it used rnd_pos() to position
the cursor before deletion. This rnd_pos() was freeing and reallocating
blobs in record[0]. So when the code for FOR PORTION OF did
  store_record(record[2]);
  ha_write_row()
  restore_record(record[2]);
it ended up with blob pointers to a freed memory.

Let's use lookup_handler for deletion.
2025-07-26 10:54:28 +02:00
Sergei Golubchik
5fa5ee3edb Bug#37117875 test case 2025-07-25 16:04:10 +02:00
Sergei Golubchik
fb2f324f85 MDEV-37310 Non-debug failing assertion node->pcur->rel_pos == BTR_PCUR_ON upon violating long unique under READ-COMMITTED
let's disallow UPDATE IGNORE in READ COMMITTED with the table
has UNIQUE constraint that is USING HASH or is WITHOUT OVERLAPS

This rarely-used combination should not block a release, with be
fixed in MDEV-37233
2025-07-25 12:28:30 +02:00
Sergei Golubchik
18f85c8c68 MDEV-37302 Assertion failure in Table_triggers_list::add_tables_and_routines_for_triggers upon attempt to insert DEFAULT into non-insertable view
Only do trigger prelocking for tables that are doing to be
modified (with a write lock). A table can cause prelocking
if its DEFAULT value is used (because DEFAULT can be NEXTVAL),
even if the table itself is only used for reads. Don't process
triggers for such a table
2025-07-24 00:11:48 +02:00
Brandon Nesterenko
5f51a3a6eb MDEV-36906: RBR crashes upon DML after CONVERT PARTITION
MDEV-33658 part 1’s refactoring ecaedbe299
introduced a new function init_key_info which (in part) aims to
calculate the total key length; however, it doesn’t account for the
key already having been initialized (as happens when called via
ALTER TABLE .. CONVERT PARTITION .. TO TABLE). This leads to crashes
when this key is later iterated over, because the iterator will try
to iterate over additional key parts which don’t exist because the
length reports as longer than the actual memory owned. The crash
reported by MDEV-36906 highlights this in function key_copy.

To explain how the keys already have been initialized, init_key_info
is called multiple times. That is, init_key_info is called from
mysql_prepare_create_table, which prepares a table and its key
structures for table creation, which is in turn called by
mysql_write_frm when using flags MFRM_WRITE_SHADOW and
MFRM_WRITE_CONVERTED_TO. The
ALTER TABLE .. CONVERT PARTITION .. TO TABLE use case (see function
fast_alter_partition_table), calls mysql_write_frm multiple times with
both of these flags set (first with MFRM_WRITE_CONVERTED_TO and then
with MFRM_WRITE_SHADOW).

Raising it up a level, mysql_prepare_create_table doesn't need to be
called again after it has already been invoked when just writing frms.
Init_key_info is the only place in that function which leads to side
effects, but the rest is redundant and can be skipped on the second
call (i.e. when writing the shadow).

The patch fixes this by skipping the call to mysql_prepare_create_table
in mysql_write_frm in the MFRM_WRITE_SHADOW block when it has already
been called previously. To track whether or not it has been previously
called, we add a new flag for the mysql_write_frm function,
MFRM_ALTER_INFO_PREPARED, which is hard-coded into the function call on
the later invocation.

Test case based on work by Elena Stepanova <elenst@mariadb.com>

Reviewed By:
============
Sergei Golubchik <serg@mariadb.org>
Nikita Malyavin <nikita.malyavin@mariadb.com>
2025-07-22 11:30:39 -06:00
ParadoxV5
33e845595d MDEV-36839: Revert MDEV-7409
MDEV-6247 added PROCESSLIST states for when a Replication
SQL thread processes Row events, including a WSRep variant
that dynamically includes the Galera Sequence Number.
MDEV-7409 further expanded on it by adding the table name to the states.

However, PROCESSLIST __cannot__ support generated states.
Because it loads the state texts asynchronously,
only permanently static strings are safe.
Even thread-local memory can become invalid when the thread terminates,
which can happen in the middle of generating a PROCESSLIST.

To prioritize memory safety, this commit reverts both variants to
static strings as the non-WSRep variant was before MDEV-7409.
* __Fully__ revert MDEV-7409 (d9898c9a71)
* Remove the WSRep override from MDEV-6247
  * Remove `THD::wsrep_info` and its compiler
    flag `WSREP_PROC_INFO` as they are now unused

This commit also includes small optimizations
from MDEV-36839’s previous draft, #4133.

Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
2025-07-22 10:05:24 -06:00
Sergei Golubchik
3dc0cef218 MDEV-35184 Corruption errors upon creation or usage of Federated table with vector key
disallow vector indexes in FederatedX, both in normal create
and in assisted discovery
2025-07-21 10:24:14 +02:00
Sergei Golubchik
ad297c5181 MDEV-7761 Some MTR tests fail when run on a host named 'localhost'
skip the test in the unlikely case of hostname being "localhost"
2025-07-21 10:24:14 +02:00
Sergei Golubchik
faec725599 MDEV-37005 Unexpected ER_TABLE_EXISTS_ERROR on primary or replica upon CREATE OR REPLACE for partitioned table
cannot check thd->lex->part_info when a table is opened,
it can describe anything, not necessarily the table in question
2025-07-21 10:24:14 +02:00
Marko Mäkelä
55e0c34f4f MDEV-37263 Hang or crash when shrinking innodb_buffer_pool_size
buf_pool_t::shrink(): If we run out of pages to evict from buf_pool.LRU,
abort the operation. Also, do not leak the spare block that we may have
allocated.
2025-07-18 10:06:33 +03:00
Daniel Black
c517f0e12d fix incorrect merge 15700f54c2 (part 3) galera.mariadb_tzinfo_to_sql
In 805e7ca3ad the errors codes
for "The variable '@@alter_algorithm' is ignored" was
changed to 4201 when it should have stayed as 4200.

Correct like main.mysql_tzinfo_to_sql_symlink in
to the 4200 code like it was when they where added
in 2464ee758a.
2025-07-18 15:23:22 +10:00
Julius Goryavsky
008145b968 galera: changes for transition to galera library 26.4.23 2025-07-17 17:21:02 +02:00
Julius Goryavsky
1681b6c330 MDEV-37257: unstable tests temporarily added to 'disabled' list 2025-07-17 15:42:59 +02:00
Marko Mäkelä
cedfe8eca4 MDEV-37250 buf_pool_t::shrink() assertion failure
buf_pool_t::shrink(): When relocating a dirty page of the temporary
tablespace, reset the oldest_modification() on the discarded block,
like we do for persistent pages in buf_flush_relocate_on_flush_list().

buf_pool_t::resize(): Add debug assertions to catch this error earlier.

This bug does not seem to affect non-debug builds.

Reviewed by: Thirunarayanan Balathandayuthapani
2025-07-17 12:24:25 +03:00
Aleksey Midenkov
9a51709dba MDEV-29001 DROP DEFAULT makes SHOW CREATE non-idempotent
DROP DEFAULT adds DEFAULT NULL in case of nullable column. In case of
NOT NULL column it drops default expression if any exists.
2025-07-17 09:18:18 +02:00
Sergei Golubchik
b1daecfc45 MDEV-30190 Password check plugin prevents changing grants for CURRENT_USER
CURRENT_USER should not initialize $$->auth, just like explicitly
specified user name doesn't.
2025-07-17 09:18:18 +02:00
Sergei Golubchik
aef0468c18 cleanup: select ... into tests
* automatically disable ps2 and cursor protocol when the
  select statement returns no result set
* remove manual {disable|enable}_{ps2|cursor}_protocol from around
  `select ... into` in tests
* other misc collateral test cleanups

Cherry-pick from 11.8
2025-07-17 09:18:18 +02:00
Sergei Golubchik
dd63c6c9e3 MDEV-29186 Query cache makes virtual column function RAND() non-random 2025-07-17 09:18:18 +02:00
Sergei Golubchik
46135c625b MDEV-36979 Same alias name with different case on same table is not working in functions
table keys {db,table,alias} must be compared with table_alias_charset
2025-07-17 09:18:17 +02:00
Sergei Golubchik
cb7978a12d MDEV-36720 Possible memory leak on updating table with index without overlaps
when closing a lookup_handler, don't forget to close it in PSI too
2025-07-17 09:18:17 +02:00
Thirunarayanan Balathandayuthapani
626d5bf832 MDEV-36287 mariabackup ignores tables-file
Problem:
========
- Mariabackup ignores tables-file option because it fails to
register the new entry in database hash cells. This issue was
caused by the commit 3c312d247c (MDEV-35190).
xb_register_filter_entry() fails to stop when it encounters the
empty list.

Solution:
=========
xb_register_filter_entry(): If there is no next member to
deference then it return pointer to existing element.
2025-07-16 15:50:50 +03:00
Sergei Golubchik
9703c90712 MDEV-37199 UNIQUE KEY USING HASH accepting duplicate records
Server-level UNIQUE constraints (namely, WITHOUT OVERLAPS and USING HASH)
only worked with InnoDB in REPEATABLE READ isolation mode, when the
constraint was checked first and then the row was inserted or updated.
Gap locks prevented race conditions when a concurrent connection
could've also checked the constraint and inserted/updated a row
at the same time.

In READ COMMITTED there are no gap locks. To avoid race conditions,
we now check the constraint *after* the row operation. This is
enabled by the HA_CHECK_UNIQUE_AFTER_WRITE table flag that InnoDB
sets in the READ COMMITTED transactions.

Checking the constraint after the row operation is more complex.
First, the constraint will see the current (inserted/updated) row,
and needs to skip it. Second, IGNORE operations become tricky,
as we need to revert the insert/update and continue statement execution.

write_row() (INSERT IGNORE) is reverted with delete_row(). Conveniently
it deletes the current row, that is, the last inserted row.

update_row(a,b) (UPDATE IGNORE) is reverted with a reversed update,
update_row(b,a). Conveniently, it updates the current row too.

Except in InnoDB when the PK is updated - in this case InnoDB internally
performs delete+insert, but does not move the cursor, so the "current"
row is the deleted one and the reverse update doesn't work.
This combination now throws an "unsupported" error and will
be fixed in MDEV-37233
2025-07-16 13:02:44 +02:00
Marko Mäkelä
b7b2e009b3 MDEV-37215 SELECT FOR UPDATE crash in SERIALIZABLE
ha_innobase::store_lock(): Set also trx->will_lock when starting
a transaction at SERIALIZABLE isolation level. This fixes up
commit 7fbbbc983f (MDEV-36330).
2025-07-14 10:31:56 +03:00
Marko Mäkelä
7fbbbc983f MDEV-36330: SERIALIZABLE read inconsistency
At TRANSACTION ISOLATION LEVEL SERIALIZABLE, InnoDB would fail to flag
a write/read conflict, which would be a violation already at the more
relaxed REPEATABLE READ level when innodb_snapshot_isolation=ON.

Fix: Create a read view and start the transaction at the same time.
Thus, lock checks will be able to consult the correct read view
to flag ER_CHECKREAD if we are about to lock a record that was committed
after the start of our transaction.

innobase_start_trx_and_assign_read_view(): At any other isolation level
than READ UNCOMMITTED, do create a read view. This is needed for the
correct operation of START TRANSACTION WITH CONSISTENT SNAPSHOT.

ha_innobase::store_lock(): At SERIALIZABLE isolation level, if the
transaction was not started yet, start it and open a read view.
An alternative way to achieve this would be to make trans_begin()
treat START TRANSACTION (or BEGIN) in the same way as
START TRANSACTION WITH CONSISTENT SNAPSHOT when the isolation level
is SERIALIZABLE.

innodb_isolation_level(const THD*): A simpler version of
innobase_map_isolation_level(). Compared to earlier, we will return
READ UNCOMMITTED also if the :newraw option is set for the
InnoDB system tablespace.

Reviewed by: Vladislav Lesin
2025-07-11 16:07:08 +03:00
Marko Mäkelä
f73ffd1150 MDEV-37183 Scrubbing empty record breaks recovery
page_delete_rec_list_end(): Do not attempt to scrub the data of
an empty record.

The test case would reproduce a debug assertion failure in branches
where commit 358921ce32 (MDEV-26938)
is present. MariaDB Server 10.6 only supports ascending indexes,
and in those, the empty string would always be sorted first, never
last in a page.

Nevertheless, we fix the bug also in 10.6, in case it would be
reproducible in a slightly different scenario.

Reviewed by: Thirunarayanan Balathandayuthapani
2025-07-11 15:20:06 +03:00
Sergei Golubchik
c27d78beb5 MDEV-36870 Spurious unrelated permission error when selecting from table with default that uses nextval(sequence)
Lots of different cases, SELECT, SELECT DEFAULT(),
UPDATE t SET x=DEFAULT, prepares statements,
opening of a table for the I_S, prelocking (so TL_WRITE),
insert with subquery (so SQLCOM_SELECT), etc.

Don't check NEXTVAL privileges in fix_fields() anymore, it cannot
possibly handle all the cases correctly. Make a special method
Item_func_nextval::check_access() for that and invoke it from

* fix_fields on explicit SELECT NEXTVAL()
  (but not if NEXTVAL() is used in a DEFAULT clause)
* when DEFAULT bareword in used in, say, UPDATE t SET x=DEFAULT
  (but not if DEFAULT() itself is used in a DEFAULT clause)
* in CREATE TABLE
* in ALTER TABLE ALGORITHM=INPLACE (that doesn't go CREATE TABLE path)
* on INSERT

helpers
* Virtual_column_info::check_access() to walk the item tree and invoke
  Item::check_access()
* TABLE::check_sequence_privileges() to iterate default expressions
  and invoke Virtual_column_info::check_access()

also, single-table UPDATE in prepared statements now associates
value items with fields just as multi-update already did, fixes the
case of PREPARE s "UPDATE t SET x=?"; EXECUTE s USING DEFAULT.
2025-07-09 18:04:46 +02:00
Sergei Golubchik
1c7685f5fc bugfix: nextval() in default, and UPDATE SET x=DEFAULT
set thd->lex->default_used accordingly
2025-07-09 17:32:37 +02:00
Kristian Nielsen
4c8af2007d MDEV-36934: semi sync makes the master unresponsive when a replica is stopped
Ensure that a pending semi-sync transaction can only be signalled on its THD
while it is waiting in commit_trx(); not if the wait in commit_trx() is
skipped for some reason.

There was a bug that if no semi-sync slaves were connected and
rpl_semi_sync_master_wait_no_slave was off, the THD pointer could be left in
the list of pending transactions after THD was deleted, and an invalid
THD/condition variable could be signalled, causing hang or other corruption.

Testcase based on work by Brandon Nesterenko <brandon.nesterenko@mariadb.com>.

Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2025-07-08 16:41:12 +02:00
Vladislav Vaintroub
13e9f2d65b MDEV-37143 mariabackup fails on Windows with "SSL certificate is self-signed"
This is the same as MDEV-35368, which was  previously incompletely fixed
(on *nix-only, for unix socket connections)

This time, we fix it compatibly to Connector/C, by not verifying
server certificate for local connections, which, in addition to socket
and named pipe, are also "127.0.0.1" and "::1", and on Windows "localhost"
as well.

The corresponding code in Connector/C is was added by
1287c901dc8515823d28edcebfe4be65e6c5a6b3.

It remain a good question whether mariabackup should use SSL at all
since all it does are local connections, for "BACKUP STAGE" stuff.
2025-07-04 23:29:33 +03:00
Thirunarayanan Balathandayuthapani
0dd6566ee4 MDEV-37123 dict_table_open_on_id() fails to release dict_sys.latch
While updating the persistent defragmentation statistics
for the table, InnoDB opens the table only if it is in cache.
If dict_table_open_on_id() fails to find the table in cache
then it fails to unfreeze dict_sys.latch. This lead to crash
2025-07-02 14:25:38 +05:30
Jan Lindström
56fbc0cdd7 MDEV-36953 : mysql-wsrep#198 test hangs
Test changes only. INSERT may fail for lock wait because
in other node we have LOCK TABLE or it may succeed
if next statement i.e. UNLOCK TABLES is fast enough.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-06-30 01:08:55 +02:00