maria:bb-10.6-MDEV-31983-v2

Last commit made on 2023-10-24
Get this branch:
git clone -b bb-10.6-MDEV-31983-v2 https://git.launchpad.net/maria

Branch merges

Branch information

Name:
bb-10.6-MDEV-31983-v2
Repository:
lp:maria

Recent commits

39638a7... by Rex Johnston

MDEV-31983 jointable materialization subquery optimization ignoring

...errors, then failing ASSERT.

In optimizing a subselect, transforming it to a join, then attempting to
materialize that join, errors in evaluation of join conditions, flagged in
the thread are ignored for suffiently long to cause problems.

When executing an update SQL command, thd->abort_on_warning can cause
thd->error() to be set during evaluation in get_mm_tree() of attached
conditions. This need to be caught ASAP in test_quick_select(), the
caller of get_mm_tree() and returned as an error condition.

We change the return type of SQL_SELECT::test_quick_select() to allow
unambiguous detection of an error by the caller.

Sergei Petrunia adds:
Add error handling:
- JOIN::make_range_rowid_filters() should return error immediately if
  it fails to build a filter.
- test_if_skip_sort_order() now will return an error if it gets an error
  from test_quick_select() call.
   = All callers check for this condition, too.

Also, added error handling logic: now, a fatal error in
any SQL_SELECT::test_quick_select() call will be caught
by any caller which will abort the query execution.
- "Range checked for each record" code now checks for test_quick_select
  errors, too.

b21f52e... by Marko Mäkelä

Merge 10.5 into 10.6

b5e43a1... by Marko Mäkelä

MDEV-32552 Write-ahead logging is broken for freed pages

buf_page_free(): Flag the freed page as modified if it is found in
the buffer pool.

buf_flush_page(): If the page has been freed, ensure that the log
for it has been durably written, before removing the page
from buf_pool.flush_list.

FindBlockX: Find also MTR_MEMO_PAGE_X_MODIFY in order to avoid an
occasional failure of innodb.innodb_defrag_concurrent, which involves
freeing and reallocating pages in the same mini-transaction.

This fixes a regression that was introduced in
commit a35b4ae89871d8184f04abb112c385481d557dbb (MDEV-15528).

This logic was tested by commenting out the $shutdown_timeout line
from a test and running the following:

./mtr --rr innodb.scrub
rr replay var/log/mysqld.1.rr/mariadbd-0

A breakpoint in the modified buf_flush_page() was hit, and the
FIL_PAGE_LSN of that page had been last modified during the
mtr_t::commit() of a mini-transaction where buf_page_free()
had been executed on that page.

0a4103e... by Oleksandr "Sanja" Byelkin

new CC v3.3

4941ac9... by Sergey Petrunia

MDEV-32113: utf8mb3_key_col=utf8mb4_value cannot be used for ref

(Variant#3: Allow cross-charset comparisons, use a special
CHARSET_INFO to create lookup keys. Review input addressed.)

Equalities that compare utf8mb{3,4}_general_ci strings, like:

  WHERE ... utf8mb3_key_col=utf8mb4_value (MB3-4-CMP)

can now be used to construct ref[const] access and also participate
in multiple-equalities.
This means that utf8mb3_key_col can be used for key-lookups when
compared with an utf8mb4 constant, field or expression using '=' or
'<=>' comparison operators.

This is controlled by optimizer_switch='cset_narrowing=on', which is
OFF by default.

IMPLEMENTATION
Item value comparison in (MB3-4-CMP) is done using utf8mb4_general_ci.
This is valid as any utf8mb3 value is also an utf8mb4 value.

When making index lookup value for utf8mb3_key_col, we do "Charset
Narrowing": characters that are in the Basic Multilingual Plane (=BMP) are
copied as-is, as they can be represented in utf8mb3. Characters that are
outside the BMP cannot be represented in utf8mb3 and are replaced
with U+FFFD, the "Replacement Character".

In utf8mb4_general_ci, the Replacement Character compares as equal to any
character that's not in BMP. Because of this, the constructed lookup value
will find all index records that would be considered equal by the original
condition (MB3-4-CMP).

Approved-by: Monty <email address hidden>

6a674c3... by Monty <email address hidden>

MDEV-32476 LeakSanitizer errors in get_quick_select or Assertion ...

Problem was that JOIN_TAB::cleanup() was not run because
JOIN::top_join_tab_count was not set in case of early errors.

Fixed by setting JOIN::tab_join_tab_count when JOIN_TAB's are allocated.

Something that should eventually be fixed:
- Cleaning up JOIN_TAB's is now done in 3 different loops.
  JOIN_TAB::cleanup() is only doing a partial cleanup. Other cleanups
  are done outside of JOIN_TAB::cleanup().

The above should be fixed so that JOIN_TAB::cleanup() is freeing
everything related to it's own memory, including all its sub JOIN_ TAB's.
JOIN::cleanup() should only loop over all it's top JOIN_TAB's and call
JOIN_TAB::cleanup() on these.
This will greatly simplify and speedup the current code (as we now do some
cleanup's twice).

a1b6bef... by Monty <email address hidden>

Fixed crash in is_stat_table() when using hash joins.

Other usage if persistent statistics is checking 'stats_is_read' in
caller, which is why this was not noticed earlier.

Other things:
- Simplified no_stat_values_provided

6991b1c... by Marko Mäkelä

Merge 10.5 into 10.6

85751ed... by THIRUNARAYANAN BALATHANDAYUTHAPANI

MDEV-31851 After crash recovery, undo tablespace fails to open

srv_all_undo_tablespaces_open(): While opening the extra unused
undo tablespaces, InnoDB should use ULINT_UNDEFINED instead of
SRV_SPACE_ID_UPPER_BOUND.

dbba1bb... by THIRUNARAYANAN BALATHANDAYUTHAPANI

MDEV-31851 After crash recovery, undo tablespace fails to open

recv_recovery_from_checkpoint_start(): InnoDB should add the
redo log block header + trailer size while checking the log
sequence number in log file with log sequence number in the
system tablespace first page.