Home - Waterfall Grid T-Grid Console Builders Recent Builds Buildslaves Changesources - JSON API - About

Console View


Categories: connectors experimental galera main
Legend:   Passed Failed Warnings Failed Again Running Exception Offline No data

connectors experimental galera main
Sergei Golubchik
bugfix: correct plugin version comparison

(also fix it in C/C to use the same pattern)

The pattern is always the same now everywhere:

  if plugin_version < min_supported_api_version or
    plugin_version > current_api_version
  then it's an error.

in almost all cases min_supported_api_version is
`~0xFF & current_api_version`, meaning, major api
version must be the same.

Authentication API supports plugins of lower major version,
this support was specially implemented though.
Sergei Golubchik
race in ssl_crl.test

connection with a revoked certitifate is correctly rejected in all cases.
but a server sends the error message and RST when a client sends new auth
data.

if RST arrives first, the client fails to send into the closed socket.
If the client sends first, it reads the reply and gets the "revoked"
error message.
Sergei Golubchik
cleanup: remove libfmt-7.1.3 compatibility code
Rex Johnston
MDEV-39492 PQ: the workers' temporary space counts against the session's limit as one

temp_file_size_cb_func() charges temporary space to current_thd and
checks max_tmp_session_space_usage against that THD's own usage. A
worker's THD copies the session's variables in
pwt_thread::init_worker_thd(), so each worker was checked against the
whole session limit on its own, and a parallel query could write
parallel_worker_threads times what the session is allowed before any
one worker hit it.

Dividing the limit evenly between the workers would bound the total, but
a worker that got most of the rows would hit its share while the others
left theirs unused. Instead every worker charges the session itself.
THD gains tmp_space_owner, set on a worker's THD to the manager's, and
temp_file_size_cb_func() charges and checks the owner in its place, so
the session's tmp_space_used, Max_tmp_space_used and limit cover the
workers and the manager together, however the rows are divided.
tmp_space_shared, set on the manager's THD from before the first worker
starts until every worker has been joined (quiesce_workers(), or the
abort path of init_parallel_workers()), makes the callback update its
counters under LOCK_thd_data, as it already did for shared_thd. A new
flag rather than shared_thd, because shared_thd also changes how the
THD's memory is accounted (my_malloc_size_cb_func()), which the
manager's ~THD has to reconcile. The lock is now taken before the
assertion that reads tmp_space_used, which other threads may be
updating.

Charges and credits both land on the manager, whichever thread grows a
container or frees it, so a worker's own tmp_space_used stays 0 and
thread_func_end() no longer hands it over with the other counters.
max_tmp_total_space_usage needed nothing: it is checked against one
server-wide counter that every thread adds to.

parallel_query_tmp_space gains a 2M session limit for a query whose four
workers write about 4.3M between them and at most about 1.5M each. With
each worker checked against the whole limit the query succeeded; it now
fails.

This commit was prepared with Claude Code (Opus 5.5), which first
divided the limit evenly between the workers and then, at the user's
request, replaced that with the shared counter. It measured the query's
thresholds under both (about 4.3M shared, about 4.5M split, about 1.5M
with neither), confirmed the 2M case fails with the change reverted on
its own, found that InnoDB's dynamic chunking spreads even a 500-row
table evenly over four workers so that no test without a debug hook can
skew the rows, and ran the parallel_query tests and main.tmp_space_usage
in normal and --ps-protocol modes, the maria suite and the main suite.
Rex Johnston
MDEV-39492 PQ: the workers share one temporary table's worth of memory

Every worker's result container is a temporary table that starts in HEAP
and converts to Aria on disk when it fills. Each one was sized from the
session's min(tmp_memory_table_size, max_heap_table_size), so a team of
N workers could hold N times the memory a single temporary table of the
session is allowed.

init_parallel_workers() now gives each worker a share of that limit,
divided by parallel_worker_threads, kept in
pwt_row_layout::worker_heap_bytes. The share is left alone when
tmp_memory_table_size is at its maximum (no limit) or the limit is 0
(temporary tables forced to disk), and is never rounded down to 0, which
would also force them to disk. make_container() and
make_container_from() take a for_worker flag; for a worker's container
the pwt_worker_heap_size guard lowers the manager THD's
tmp_memory_table_size to the share while the container is built, and
puts it back after. The guard has to cover both create_tmp_table(),
which sets share->max_rows from it, and instantiate_tmp_table(), where
ha_heap::create() sets max_table_size from it again. Every container is
built on the manager's thread, so the manager's THD is the one both read.
The worker containers so sized are the plain-row, scan-only and
pre-aggregation ones; the manager's own receive and sort containers keep
the session's full size.

parallel_ship_cost() charged the disk tier for rows past
parallel_divisor full containers; it now counts parallel_divisor
shares, so the optimizer does not undercount what spills.

mtr's default max_heap_table_size is 1M, which now leaves 256K to each
of 4 workers. That spilled the 50 VARCHAR(4000) groups that
parallel_query_aggregate expects to stay in heap, and the added spill
charge made the serial plan cheaper for the queries
parallel_query_worker_side and parallel_query_why expect to run in the
workers. These tests set max_heap_table_size to 4M, the 1M per worker
they had before, so they go on checking what they were written for.

This commit was prepared with Claude Code (Opus 5.5), which traced where
the worker containers are sized (create_tmp_table() and ha_heap::create()),
wrote the change, ran the parallel_query tests in normal and
--ps-protocol modes, confirmed the three failures were the split and not
a fault by rerunning them with max_heap_table_size=4M, and made the test
changes.
Sergei Golubchik
fix server parsec plugin to follow OpenSSL documentation

man EVP_DigestVerify:

  EVP_DigestVerifyInit() and EVP_DigestVerifyUpdate() return
  1 for success and 0 for failure.
  EVP_DigestVerifyFinal() and EVP_DigestVerify() return
  1 for success; any other value indicates failure.
Jan Lindström
MDEV-42497 Galera test failure on galera_sr_nonPK_and_PA

The test galera_sr.galera_sr_nonPK_and_PA passes, but the MTR check of
the test case fails on node 2 with ER_LOCK_WAIT_TIMEOUT. The check
query waits for node 2 to apply all write sets, and an applier on node
2 is stuck on a Galera debug sync point.

The test sets two sync points on node 2, commit_monitor_slave_enter_sync
and then apply_monitor_slave_enter_sync. "dbug=" pops one level of the
Galera debug stack, it does not clear all sync points. The test signals
commit_monitor_slave_enter_sync, pops one level, signals
apply_monitor_slave_enter_sync, and pops the last level. After the
first pop commit_monitor_slave_enter_sync is active again. When the
released SR fragment reaches the commit monitor before the last pop,
it waits there and no signal comes.

Pop both sync points before the signals. Wait on node 2 until the SR
transaction is applied, and show the rows of t1 and t2 on both nodes,
so that a stuck applier fails the test itself.

Assisted-by: Claude:claude-4.6-sonnet
Sergei Golubchik
MDEV-34846 PARSEC authentication improvement

parsec protocol allows to skip salt request - the client
can send the signed responce without asking for salt

now parsec + ssl takes only 2 roundtrips. Same as mysql_native_password
with no ssl.
Yuchen Pei
MDEV-25848 Make older servers refuse a table with an ARRAY index

An ARRAY index is stored in the frm as a regular key with algorithm
HA_KEY_ALG_ARRAY (8), and nothing else marks the table. An older server
opens such a table, counts the ARRAY key as a regular index on the JSON
column and:
- prints it as KEY (j) in SHOW CREATE TABLE, which can't be reloaded;
- fails indexed lookups, as the engine has no such index;
- crashes in SHOW INDEX / INFORMATION_SCHEMA.STATISTICS
- writes rows without updating the side table, so the index drifts;
- leaves the side table behind on DROP TABLE.

Write a new extra2 section, EXTRA2_NEWEST_KEY_ALGORITHM=132, with one
byte holding the newest key algorithm used in the table, if a key uses
an algorithm newer than HA_KEY_ALG_VECTOR. As 132 >=
EXTRA2_ENGINE_IMPORTANT, older servers refuse to open the table. This
server checks that the section matches the highest key algorithm.

This closes finding #12.

Tested with actual servers:

First on new server (at this patch):

MariaDB [test]> CREATE TABLE t (a int primary key, j JSON, INDEX i1 (CAST(j AS UNSIGNED ARRAY))) engine=innodb;
Query OK, 0 rows affected (0.007 sec)

MariaDB [test]> INSERT INTO t VALUES (1, '[5, 6]'), (2, '[5]'), (3, '[7]');
Query OK, 3 rows affected (0.002 sec)
Records: 3  Duplicates: 0  Warnings: 0

Then on old server (820699c7e88c8858dbcab16caf9af587333559e9):

MariaDB [test]> show create table t;
ERROR 1033 (HY000): Incorrect information in file: './test/t.frm'
MariaDB [test]> SELECT * FROM t;
ERROR 1033 (HY000): Incorrect information in file: './test/t.frm'
MariaDB [test]> SHOW INDEX FROM t;
ERROR 1033 (HY000): Incorrect information in file: './test/t.frm'
MariaDB [test]> SELECT * FROM information_schema.STATISTICS;
// [... 81 lines elided]
77 rows in set, 1 warning (0.022 sec)

MariaDB [test]> show warnings;
+---------+------+-----------------------------------------------+
| Level  | Code | Message                                      |
+---------+------+-----------------------------------------------+
| Warning | 1033 | Incorrect information in file: './test/t.frm' |
+---------+------+-----------------------------------------------+
1 row in set (0.000 sec)

MariaDB [test]> INSERT INTO t VALUES (5, '[7]');
ERROR 1033 (HY000): Incorrect information in file: './test/t.frm'
MariaDB [test]> CHECK TABLE t;
+--------+-------+----------+-----------------------------------------------+
| Table  | Op    | Msg_type | Msg_text                                      |
+--------+-------+----------+-----------------------------------------------+
| test.t | check | Error    | Incorrect information in file: './test/t.frm' |
| test.t | check | error    | Corrupt                                      |
+--------+-------+----------+-----------------------------------------------+
2 rows in set (0.000 sec)

MariaDB [test]> drop table t;
Query OK, 0 rows affected (0.001 sec)

Note: A separate bug, to be fixed separately:

Finally on new server again:

MariaDB [test]> show create table t;
ERROR 1146 (42S02): Table 'test.t' doesn't exist
MariaDB [test]> CREATE TABLE t (a int primary key, j JSON, INDEX i1 (CAST(j AS UNSIGNED ARRAY))) engine=innodb;
ERROR 1050 (42S01): Table '`test`.`t#i#01`' already exists
Sergei Golubchik
CONC-833 cache plugin data in the session cache

this extends auth plugin API, the version is incremented

username and password are now part of the client connection cache key,
so connections with different passwords do not use eash other's
session tickets, this increased the number of roundtrips in the test.
Sergei Golubchik
add change_user test to plugins.parsec
Sergei Golubchik
MDEV-12320 change initial authentication plugin in the server

instead of unconditionally starting the authentication from the
mysql_native_password, start it from the plugin that will most likely
avoid "change plugin" packet (and thus a round-trip). Maintain counters
of what plugins were used to authenticate users so far, pick the plugin
with the largest count for new connections. But don't count plugins,
such as unix_socket, that need no client counterpart, they can never
cause a round-trip. And don't count pam that sends the password in
plain-text, we don't want to ask that of every new connection.

Uses separately allocated hash and memory, not acl_memroot, not
plugin->locks_count. This allows not to take extra acl_cache->lock
in acl_authenticate(), reset stats on FLUSH PRIVILEGES, and adapt to
the changed load with exponentially decreasing weights.

New status variable Connection_init_auth to show what plugin
is sent in the handshake packet.

Total number of MariaDB authentication plugins in the world is likely
below 15, including purely test plugins. So the hash is expected to
have hardly more than 3-5 entries.
Sergei Golubchik
test that counts number of roundtrips in various situations

wolfssl needs curve25519 support, otherwise openssl client offers it,
server disagrees and they agree on something else after an extra roundtrip
Sergei Golubchik
cleanup: remove historical my_plugin_lock aliases
Marko Mäkelä
Merge 13.2 into main
Jan Lindström
MDEV-42497 Galera test failure on galera_sr_nonPK_and_PA

The test galera_sr.galera_sr_nonPK_and_PA passes, but the MTR check of
the test case fails on node 2 with ER_LOCK_WAIT_TIMEOUT. The check
query waits for node 2 to apply all write sets, and an applier on node
2 is stuck on a Galera debug sync point.

The test sets two sync points on node 2, commit_monitor_slave_enter_sync
and then apply_monitor_slave_enter_sync. "dbug=" pops one level of the
Galera debug stack, it does not clear all sync points. The test signals
commit_monitor_slave_enter_sync, pops one level, signals
apply_monitor_slave_enter_sync, and pops the last level. After the
first pop commit_monitor_slave_enter_sync is active again. When the
released SR fragment reaches the commit monitor before the last pop,
it waits there and no signal comes.

Pop both sync points before the signals. Wait on node 2 until the SR
transaction is applied, and show the rows of t1 and t2 on both nodes,
so that a stuck applier fails the test itself.

Assisted-by: Claude:claude-4.6-sonnet
Sergei Golubchik
MDEV-40445 TLS 1.3 early data (wolfssl)
Sergei Golubchik
cleanup: reduce usage of (type*)thd->alloc((sizeof type)*n)

replace with shorter and safer thd->alloc<type>(n)
Rex Johnston
MDEV-39492 PQ: a worker container rebuilt on disk counts against the temporary space limits

When a worker's HEAP container fills, it is rebuilt as an Aria table on
the worker's thread. The container is opened cross_thread, which uses
HA_OPEN_GLOBAL_TMP_TABLE instead of HA_OPEN_INTERNAL_TABLE so that Aria
does not allocate its structures thread-specific, and it keeps
HA_OPEN_SIZE_TRACKING, so the share is tracked but not internal.

Aria assumed a tracked table is always internal ("Tracked table (always
internal)", maria_def.h). _ma_set_share_data_file_length(), which is how
a block-record table reports its data file growing, reported the growth
to temp_file_size_cb_func() only in the branch taken for an internal
table; for any other share it took intern_lock, updated the length,
unlocked, and reported nothing. Index file growth (ma_page.c) is
reported for any tracked share, so a worker's keyed pre-aggregation
container was partly counted, but the data file of every worker
container was never counted at all: Max_tmp_space_used stayed 0, and
neither max_tmp_session_space_usage nor max_tmp_total_space_usage could
stop a parallel query however much it wrote to disk.

The growth is now reported for every tracked share, after intern_lock is
released for a non-internal one.

parallel_query_tmp_space spills every worker's container to disk and
checks that the space is counted, and that a session limit and a server
limit far below what one worker writes each fail the query. Before this
change the query succeeded under both, with Max_tmp_space_used 0.

This commit was prepared with Claude Code (Opus 5.5), which found that
the limits never fired for a parallel query while setting up the
per-worker split of max_tmp_session_space_usage, traced it with a DBUG
trace (temp_file_size_cb_func() was called only on the manager's thread,
never on the workers') to the internal-table branch in
_ma_set_share_data_file_length(), made the change, wrote the test, and
ran the parallel_query tests and main.tmp_space_usage in normal and
--ps-protocol modes and the maria suite.
Rex Johnston
MDEV-40012 PQ: a driving table may have BLOB, TEXT, JSON and GEOMETRY columns

table_can_be_parallel_scanned() refused any table with a blob-backed
column, on the grounds that a blob's data lives outside the record and a
by-value row transport would carry only the pointer, into the worker's own
buffer. No record image is shipped any more. A worker writes its rows into
its container with ha_write_tmp_row(), which stores the data the pointer
names, and the manager reads them back with ha_rnd_next(), whose pointer
names the container's own copy. Since MDEV-38975 a HEAP container holds
blobs in continuation records; one that fills is rebuilt in Aria by
create_internal_tmp_table_from_heap(), which copies the data too. Neither
keeps the buffer it reads a blob into per thread, so reading a container
on the manager after a worker wrote it is no different for a blob than for
any other column. The restriction is removed.

That exposed a leak. A container's TMP_TABLE_PARAM is allocated on a
mem_root, so its destructor never runs, and free_container() did not call
TMP_TABLE_PARAM::cleanup() either. The Copy_field pairs create_tmp_table()
made for it were therefore never destroyed, and a pair that copies a blob
for GROUP BY keeps the value in a String of its own (do_save_blob()), on
the heap. A grouped query aggregating a blob left one such buffer per
worker, reported at shutdown as lost memory and as an internal memory
accounting error. free_container() now cleans the param up.

The optimizer trace's refusal for a table that cannot be scanned in
parallel no longer lists a blob-backed column, and parallel_query_why uses
a temporary table as its example of one.

parallel_query_blob runs plain, filtered, sorted, aggregated, grouped and
joined queries over BLOB, TEXT, LONGBLOB, JSON and GEOMETRY columns, with
the containers in memory and rebuilt on disk. The new include
parallel_query_same.inc runs each query serially and in the workers and
compares an order-independent checksum of the complete rows, blob data
included, failing the test on a difference, and checks that the second
run was in the workers.

This commit was prepared with Claude Code (Opus 5.5), which checked how
rows move from a worker to the manager and how HEAP and Aria allocate
their blob buffers, removed the restriction, compared serial and parallel
results for twenty query shapes against a running server, traced the
shutdown leak to the uncleaned TMP_TABLE_PARAM and fixed it, wrote the
test and include (verifying that the include fails on a mismatch, and
that the test fails with the restriction restored alone), and ran the
parallel_query*, opt_trace* and tmp_space_usage tests in normal,
--ps-protocol and --view-protocol modes.
Sergei Golubchik
MDEV-40445 TLS 1.3 early data (0-RTT)

Read client reply packet that was sent as TLS 1.3 early data
Send next server packet (e.g. OK or "change plugin" packet)
as early data to the client. This allows to establish a TLS
connection with no additional roundtrips.

Assisted-By: Claude:claude-5-opus
Sergei Golubchik
MDEV-40444 configurable default authentication plugin

New session sysvar and a command line option: default_authentication
(named similarly to default_storage_engine). Tells what authentication
plugin to use for CREATE|ALTER USER ... IDENTIFIED BY - the syntax
that specifies a password, but not a plugin.

SET PASSWORD not affected

empty password still means native (for tests and because it doesn't matter)
Mohammad Tafzeel Shams
MDEV-37685 : BtrBulk compression level changes during bulk load cause index inconsistency

BtrBulk::finish() copies the records of the single top-level page into
the root page of the index and compresses the root page again.
PageBulk::compress() read the global innodb_compression_level on every
call. If SET GLOBAL innodb_compression_level lowered the level between
the compression of the top-level page and that of the root page, the
root page could fail to compress although the identical top-level page
had been compressed successfully. BtrBulk::pageSplit() would then split
the root page, giving it a right sibling and a parent page that is not
reachable from the data dictionary.

Fix:
BtrBulk::m_compression_level: innodb_compression_level at the start
of the bulk load, used for compressing every page.

PageBulk::compress(): Take the compression level as a parameter.

BtrBulk::finish(): Add the DEBUG_SYNC point btr_bulk_finish_before_root
for the test.
Sergei Golubchik
MDEV-40445 TLS session resumption

in fact it was already on in the server, so this only
enables statistics to see it in SHOW STATUS, adds tests,
and updates C/C to match.

Assisted-By: Claude:claude-5-opus
Rex Johnston
MDEV-40012  Documentation

Updates, more documentation in Docs/sql_parallel_query
bsrikanth-mariadb
MDEV-38303: Support MIN/MAX in the HAVING early-stop shortcut

Extend the shortcut to MIN and MAX. MAX never decreases as rows are
added, so once MAX(..) < c or MAX(..) <= c is false it stays false.
MIN never increases, so the same holds for MIN(..) > c and
MIN(..) >= c.

Add Item_sum_min_max::is_having_shortcut_cmp(), which accepts these
operators for MAX_FUNC and MIN_FUNC only. ANY_VALUE shares the class
but is not handled, so it is read in full as before.

Only numeric arguments are used. For a string argument, MIN/MAX
compares values as strings ('10' < '9'), but the HAVING condition
compares the result with a numeric constant as numbers (10 > 9).
The two orders differ, so the result is not monotonic and the scan
must not stop early.

Until a non-NULL value is seen, MIN/MAX returns NULL, so the HAVING
condition is NULL, not FALSE, and the scan does not stop. This covers:
- leading NULL values, e.g. MAX(v) < 150 where the first rows have
  v IS NULL. The scan stops once a non-NULL value makes the condition
  FALSE.
- a column that is all NULL, or a WHERE that leaves no rows or only
  NULL values. The result stays NULL, the condition is never FALSE,
  and the whole table is read.
- a NULL constant, e.g. MAX(v) < NULL. It is not used for the
  shortcut at all.
A NULL conjunct does not hide a FALSE one: with
MAX(n) < 5 AND MIN(v) > 200, the scan stops when the second part
becomes FALSE, even though the first is NULL.

Add is_numeric_cmp_type() and use it in the three places that check
for an INT, REAL or DECIMAL comparison type.

Tests cover both directions, swapped operands, NULL values and NULL
results, string, temporal, DOUBLE and unsigned arguments, DISTINCT,
GROUP BY, joins, subqueries, prepared statements and ANY_VALUE.
Rex Johnston
MDEV-40012 PQ: a finished worker removes its performance schema thread

mysql_thread_create() gives each parallel worker pthread a performance
schema thread of its own (pfs_spawn_thread()), and nothing removes it when
the thread function returns: a thread is expected to do that itself, which
my_thread_end() does for one that called my_thread_init(). A worker never
does. It runs on the mysys_var create_background_thd() made for its THD,
and destroy_background_thd() ends that one with the PSI thread switched out
of the way, so the pthread's own PFS thread outlives it.

Two things follow. Every worker stays in performance_schema.threads after
it has gone -- three queries with four workers leave twelve
'thread/sql/Parallel Worker' rows. And the pins of its lock-free hashes
are never returned. A filename-hash node the worker deleted, such as one
for the files of a container it rebuilt on disk in Aria, waits in the pins'
purgatory to be freed, and since lf_pinbox_put_pins() never runs it never
is: shutdown reports the nodes as lost by safemalloc and as an "Internal
memory accounting error" in global_memory_used.

The worker now calls PSI_CALL_delete_current_thread() at the end of
init_and_run_thread_func(), before the THD is destroyed and while its
mysys_var is still attached -- the pins hold a pointer to that mysys_var's
stack bound, and destroy_background_thd() frees it. This is the order
threadpool_remove_connection() uses.

parallel_query_pfs_threads runs three parallel queries whose containers
are rebuilt on disk and checks that no worker thread is left in
performance_schema.threads.

This commit was prepared with Claude Code (Opus 5.5), which traced the
leaked blocks in the shutdown report to the performance schema's
filename hash, found that worker PFS threads were never deleted, confirmed
it through performance_schema.threads, wrote the fix and the test,
checked that the test fails with the fix reverted alone, and ran the
parallel_query*, opt_trace* and tmp_space_usage tests in normal and
--ps-protocol modes and the perfschema suite.
Sergei Golubchik
MDEV-40445 TLS session resumption (wolfssl)

* enable HAVE_SESSION_TICKET to allow resumption
* enable OPENSSL_ALL+KEEP_PEER_CERT to keep peer cert in the ticket,
  otherwise REQUIRE SUBJECT doesn't work after resumption
* disable OPENSSL_EXTRA which was enabled as a replacement
  when OPENSSL_ALL was disabled in 136e8661197
* disable NO_WOLFSSL_STUB to get SSL_CTX_sess_hits/etc stubs
* but they're stubs, always return 0, so add a wolfssl combination to
  the test that checks for these values
Marko Mäkelä
MDEV-42741 innodb_log_archive=ON debug assertion failure

commit 518761d1d72154d2ca686f2314ad640763f67ced (MDEV-42350)
introduced a bogus debug assertion that would fail when the
checkpoint mini-transaction at the end of a log file comprises
some FILE_MODIFY records.

recv_sys_t::find_checkpoint(): Correct the debug assertion by
referring to the actual end of the FILE_CHECKPOINT mini-transaction.

recv_sys_t::find_checkpoint_archived(): Remember the end of the latest
FILE_CHECKPOINT mini-transaction in the debug-only variable
found_checkpoint_end.

Co-developed by: Thirunarayanan Balathandayuthapani
Assisted-by: Claude:claude-opus-5-5
Sergei Golubchik
MDEV-41649 better default for mhnsw_max_cache_size

16M->1G

one doesn't need a vector index if the dataset fits into 16M
Sergei Golubchik
cleanup: wolfSSL Ed25519 EVP wrappers in include/wolfssl_ed25519.h

add DigestVerify wrappers, use the header in server_parsec.cc
instead of HAVE_WOLFSSL-specific code

Assisted-by: Claude:claude-opus-5-5
Oleg Smirnov
Remove an unused addition to InnoDB
Sergei Golubchik
MDEV-42746 Switch default authentication plugin to PARSEC

* make parsec MANDATORY
* compile parsec statically into C/C and server
* change parsec_iterations to 262144 by default as per OWASP recommendations
* update tests
Sergei Golubchik
beautify parsec handling of empty passwords

parsec hashes empty passwords too: random salt, pbkdf2, everything.
this made them visually indistinguishable from non-empty passwords
in the global_priv, SHOW CREATE, and on the wire.

It is an improvement, empty passwords are hardly less secure than
a password of one space, no need to single them out. Still it might
be quite an unexpected change for users who like to search for
"accounts with empty passwords".

Let's store and show accounts with empty passwords specially, as
mysql_native_password does. But still treat them on the wire as
normal passwords, no change in the parsec protocol to add
a special exception, and no visible leak of whether an account
has an empty password.

mark with "Used password: YES"

return CR_AUTH_USER_CREDENTIALS for wrong password
Mohammad Tafzeel Shams
MDEV-37685 : BtrBulk compression level changes during bulk load cause index inconsistency

BtrBulk::finish() copies the records of the single top-level page into
the root page of the index and compresses the root page again.
PageBulk::compress() read the global innodb_compression_level on every
call. If SET GLOBAL innodb_compression_level lowered the level between
the compression of the top-level page and that of the root page, the
root page could fail to compress although the identical top-level page
had been compressed successfully. BtrBulk::pageSplit() would then split
the root page, giving it a right sibling and a parent page that is not
reachable from the data dictionary.

Fix:
BtrBulk::m_compression_level: innodb_compression_level at the start
of the bulk load, used for compressing every page.

PageBulk::compress(): Take the compression level as a parameter.

BtrBulk::finish(): Add the DEBUG_SYNC point btr_bulk_finish_before_root
for the test.
Sergei Golubchik
MDEV-38524 Extend CREATE USER statement to allow HEX strings
Rex Johnston
MDEV-39492 PQ: parallel query tests under --view-protocol

The view protocol runs each SELECT as CREATE VIEW mysqltest_tmp_v AS
<query> on mysqltest's utility connection, then SELECT * FROM
mysqltest_tmp_v. Four tests broke on that, none of them because of
parallel query:

- parallel_query_why, parallel_query_firstmatch, parallel_query_join read
  the optimizer trace. Through the view, list_has_optimizer_trace_table()
  sees only the view and not information_schema.optimizer_trace behind
  it, so a read of the trace is itself traced and replaces the trace a
  second read sees. A query with aggregates or LIMIT becomes a
  materialized derived table whose outer SELECT adds refusals of its own
  to $**.parallel_scan_declined_because, and shifts the subquery
  numbering. A merged view drops STRAIGHT_JOIN, so the join order, and
  with it the costing, changes. View protocol is disabled for the whole
  of parallel_query_why, every case of which reads the trace, and around
  the trace sections of the other two.

- parallel_query_session hung. FLUSH STATUS commits implicitly, so after
  SET AUTOCOMMIT=0; START TRANSACTION; FLUSH STATUS mysqltest sees no
  open transaction and wraps the next SELECT in a view; with autocommit
  off that SELECT opens a transaction holding the view's metadata lock,
  and mysqltest's DROP VIEW waits on it. FLUSH STATUS now comes before
  the transaction is started, which also makes the SELECT run inside the
  transaction the test opened, as it intended.

parallel_query_join also checked that a CREATE ... SELECT was chosen for
the workers by reading the trace after it. CREATE TABLE is not a command
the optimizer trace records (sql_command_can_be_traced()), so the check
read the trace of the SELECT before it and proved nothing. It is now an
INSERT ... SELECT, which is traced: chosen by the optimizer, then run
serially because InnoDB declines the locking read
(Parallel_queries_executed 0), with every row inserted.

This commit was prepared with Claude Code (Opus 5.5), which ran the tests
under --view-protocol, traced each difference to its cause with scratch
tests (which statement's trace a read sees, EXPLAIN of a STRAIGHT_JOIN
view, the general log of the hung run), made the test changes, and ran
the parallel_query tests in normal, --ps-protocol and --view-protocol
modes.
Rex Johnston
MDEV-40012 PQ: split the planner and the trace out of sql_parallel_execution.cc

sql_parallel_execution.cc held both halves of parallel query: the
optimize-time gate that decides whether the workers can run a query, and
the code that runs it. It is now three files.

sql_parallel_planner.cc takes the decision: the shape gate the join order
search asks (pwt_query_shape_allows_workers), the full gate asked of the
finished plan (can_run_query_in_workers), the driving table's access-path
checks (jointab_can_be_parallel_scanned, can_parallel_scan_jointab_access),
the worker-safety tests on expressions, the pre-aggregation shape, the
manager's sort order, pwt_plan_group_key and parallel_join_check().

sql_parallel_trace.cc takes what writes to the optimizer trace and little
else: pwt_decline(), pwt_decline_tab(), and two new functions,
pwt_trace_chosen() and pwt_trace_declined(), which are the two trace blocks
parallel_join_check() used to write inline.

sql_parallel_execution.cc keeps the execution: opening the workers' tables,
cloning their join tabs and expressions, the worker-side join, the drain,
the manager's sort stage and do_select_parallel().

pwt_table_cond() and pwt_cache_scan_cond() are asked by both the gate and
the worker setup, so they are no longer static and are declared in
sql_parallel_workers.h, along with pwt_decline_tab() and the two trace
functions. A stale remark that pwt_plan_group_key() had to live beside the
static end_update() is removed; end_update() is declared in sql_select.h.

No behaviour changes; the function bodies are moved unchanged apart from
the trace extraction.

This commit was prepared with Claude Code (Opus 5.5), which cut the file
along line ranges with a script, extracted the trace helpers, updated the
header and both CMake source lists, checked that the old file and the
three new ones differ only by the intended edits, and ran the
parallel_query* and opt_trace* tests in normal and --ps-protocol modes.
Sergei Golubchik
cleanup: remove pre-locking of old_password_plugin

nobody should be using it, so this "optimization" actually isn't.
Mohammad Tafzeel Shams
MDEV-37467: InnoDB Instant ALTER TABLE is not crash safe

The hidden metadata record of instant ALTER TABLE was not written
crash-safely, and recovery could fail to roll it back. These are
independent problems.

First, the metadata record may include externally stored BLOB
metadata. The existing BLOB storage path in
btr_store_big_rec_extern_fields() writes the clustered index record
first, with zero BLOB pointers, and only fills in the BLOB pointers
afterwards. If the server is killed after the mini-transaction that
wrote the (incomplete) metadata record was durably committed, but
before the BLOB pointers were written, the table could become
inaccessible on recovery.

Make metadata BLOB storage crash-safe by writing the BLOB pages and
computing their pointers before the metadata record itself is
inserted or updated, so that the record is always written with
complete BLOB pointers. If the server is killed before the metadata
record is written, the already-written BLOB pages are merely
orphaned, which is safe.

Second, trx_undo_report_row_operation() writes the undo log record in
a mini-transaction of its own, which is committed before the
mini-transaction that writes the metadata record. Because
innobase_instant_try() had already updated SYS_COLUMNS and SYS_TABLES
in earlier mini-transactions, a kill in between left a durable undo
log record for the table while the metadata record was unchanged. On
recovery, trx_resurrect_table_locks() would then load the table
definition before the incomplete transaction was rolled back. The
data dictionary described the table as it would be after the
operation, while the metadata record still described it as it was
before, and btr_cur_instant_init() failed on that disagreement.

Write the undo log record of the metadata record in the same
mini-transaction that inserts or updates the record, so that the two
cannot be separated by a crash: until that mini-transaction is
committed, neither of them is durable.

An undo log record is never split between pages. If the DEFAULT
values of the columns being added are large enough that the undo log
record for updating the metadata record would not fit on one page,
innobase_instant_try() would fail. Determine this before the operation
starts, so that it can be performed by another algorithm instead.

Third, the table definition that recovery loads need not correspond to
the metadata record. dict_load_table_one() reads the committed version
of the SYS_TABLES record, and escalates to READ UNCOMMITTED only when
it finds a SYS_COLUMNS record that was written by a transaction that is
still active. The number of SYS_COLUMNS records that dict_load_columns()
reads is derived from SYS_TABLES.N_COLS, which was read from the
committed version. The record of a column that the operation appended is
located after that many records, so it is never read and the operation
goes unnoticed. Only an instant ALTER TABLE that merely appends columns
can escape this way: ADD COLUMN ... FIRST, DROP COLUMN and column
reordering rewrite the SYS_COLUMNS records of already existing columns.

Load the committed table definition first, and the uncommitted one only
if btr_cur_instant_init() reports that the committed definition does not
describe the metadata record. Reading the uncommitted definition
unconditionally would be wrong in the opposite case: if the operation
had not updated the metadata record yet, the definition would describe
columns that the record does not comprise, and btr_cur_instant_init()
would request the default value of a column that does not have one.

Fourth, the rollback writes a metadata record that comprises fewer
fields than the table definition describes, because
btr_cur_trim_alter_metadata() shortens it to the number of fields that
it comprised before the operation. That number determines the size of
the null flag bitmap, and hence the position of the array of field
lengths. rec_init_offsets_comp_ordinary() derives it from the record,
while the two functions that write the record derived it from the table
definition and asserted that the two agree.

- btr_store_big_rec_metadata():
  New function to store the off-page columns of a metadata record
  ahead of time. Each BLOB page is allocated and linked in its own
  mini-transaction, and the resulting BLOB pointers are written
  directly into the (heap-resident) index entry. On failure, it frees
  any pages it already allocated and resets the pointers to zero.

- btr_free_big_rec_metadata():
  New helper to free the BLOB pages written by
  btr_store_big_rec_metadata() and reset the entry's BLOB pointers
  to zero, used both on failure inside that function and by its
  callers when the metadata record ends up not being written.
  All BLOB page chains are validated before any page is freed, and
  all pages are freed in the mini-transaction of the caller.

- row_ins_clust_index_entry_low():
  For a metadata entry that needs external storage, convert it to a
  big record and call btr_store_big_rec_metadata() (with
  log_free_check() allowed, since no latches are held yet) before
  inserting the record. On failure, free the metadata BLOBs and
  convert the entry back.

- btr_cur_pessimistic_update():
  When updating a metadata record that requires external storage,
  call btr_store_big_rec_metadata() (without log_free_check(),
  since index and page latches are held) before modifying the record,
  and free the temporary big_rec vector via btr_free_big_rec_metadata()
  or dtuple_big_rec_free() on the various failure/success paths.

- btr_cur_optimistic_insert():
  Remove the special-cased jump to convert_big_rec for metadata
  entries, since their BLOBs are now always stored ahead of time by
  the caller; assert that a metadata entry never needs external
  storage at this point.

- innobase_instant_try():
  Since btr_cur_pessimistic_update() now stores metadata BLOBs
  before updating the record, big_rec is always NULL here; assert
  this instead of calling btr_store_big_rec_extern_fields().

- trx_undo_report_row_operation():
  Instead of starting and committing a mini-transaction of its own,
  use the one that the caller started and will commit, which is passed
  in the new parameter mtr. The new parameter own_mtr tells whether mtr
  may be committed and restarted here before an undo log page is added
  or freed, as was done before. For a metadata record, own_mtr is false
  and mtr is the mini-transaction that is going to insert or modify the
  record. It is never committed or restarted here, and an undo log page
  is added within it if the record does not fit on the current one. A
  temporary table is never passed own_mtr=false, because that would
  require changing the logging mode of the caller's mini-transaction.
  Encapsulate the parameters that describe the row change
  (clust_entry, update, cmpl_info, rec, offsets) in the new type
  trx_undo_row_op. Which of the fields are set depends on the
  operation, which the type documents.

- btr_cur_undo_report():
  New function to avoid duplicating the undo logging code of
  btr_cur_ins_lock_and_undo(), btr_cur_upd_lock_and_undo() and
  btr_cur_del_mark_set_clust_rec(). Start and commit the
  mini-transaction for trx_undo_report_row_operation(), and pass
  own_mtr=true. For an instant ALTER TABLE metadata record, pass the
  mini-transaction that is going to insert or modify the record, and
  own_mtr=false. The function is not inlined, so that the
  mini-transaction occupies stack only while the undo log record is
  being written. row_ins_clust_index_entry_low() starts and commits
  its own mini-transaction for the TRX_UNDO_EMPTY record.

- trx_undo_max_rec_size():
  New function to determine the maximum size of an undo log record,
  that is, the space available on an empty undo log page.

- ha_innobase::check_if_supported_inplace_alter():
  Refuse ALGORITHM=INSTANT if the metadata record already exists and
  the undo log record for updating it would exceed
  trx_undo_max_rec_size(). trx_undo_page_report_modify() stores the
  DEFAULT value of each column that is being added in that record in
  full, inline. No such limit applies when the metadata record is
  being inserted, because trx_undo_page_report_insert() writes
  TRX_UNDO_INSERT_METADATA and no field data.

- dict_load_table_one():
  Load the committed table definition first, and the uncommitted one
  only if btr_cur_instant_init() reports that the committed definition
  does not describe the clustered index metadata record.
  dict_load_columns() cannot detect this, because the number of
  SYS_COLUMNS records that it reads is derived from SYS_TABLES.N_COLS,
  and a column that the operation appended is located after that many
  records. A table that an uncommitted transaction is rebuilding is
  excluded, because the committed definition is the one that
  corresponds to its clustered index.

- btr_cur_instant_init(), btr_cur_instant_init_low():
  Determine the number of fields of the metadata record in the same way
  as rec_init_offsets_comp_ordinary() does, and refuse the table if it
  disagrees with the table definition. rec_get_offsets() would otherwise
  request the default value of a column that does not have one. New
  parameter quiet for a caller that is going to try another table
  definition, so that an attempt which is not the final one is not
  reported. Mark the table as unreadable on these failures, like the
  other ones in that function do, because dict_load_table_one() asserts
  that a readable table is not corrupted.

- dict_sys_tables_rec_read():
  Store the fields that are read in the new type dict_sys_tables_rec,
  instead of in separate output parameters. A caller that does not want
  a delete-marked record to be reported as not found used to indicate
  that by specifying trx_id as nullptr; that is now the parameter
  skip_deleted.

- trx_undo_add_page():
  Correct the documented restriction on the mini-transaction of the
  caller.

- rec_get_converted_size_comp_prefix_low(),
  rec_convert_dtuple_to_rec_comp():
  For a record that includes a metadata BLOB, determine the number of
  nullable fields from the tuple, by way of
  dict_index_t::get_n_nullable(), and not from
  dict_index_t::n_nullable. This is what
  rec_init_offsets_comp_ordinary() does, and it is equivalent for a
  tuple that comprises all fields of the index. Relax the assertions
  that required the tuple to comprise all of them.

- Added test in innodb.instant_alter and innodb.instant_alter_crash
  to test normal working of INSTANT ALTER, crash safety and full table.