maria:bb-10.5-mdev-31269

Last commit made on 2023-05-24
Get this branch:
git clone -b bb-10.5-mdev-31269 https://git.launchpad.net/maria

Branch merges

Branch information

Name:
bb-10.5-mdev-31269
Repository:
lp:maria

Recent commits

b8bae4c... by Yuchen Pei

MDEV-31269 Fixing exists2in 2nd ps execution segfault

In the exists2in transformation, if 1) we are in a ps/sp execution and
2) the equalities picked out for the transformation intersect with the
temporary query arena free list, skip the transformation.

Further analysis:

Consider the following example:

--8<---------------cut here---------------start------------->8---
set optimizer_switch=default;
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (b INT);
PREPARE st FROM "
SELECT * FROM t2
HAVING 0 IN (
  SELECT a FROM t1
  WHERE EXISTS (
    SELECT a FROM t1
    WHERE b = a
  )
)
";
EXECUTE st;
EXECUTE st;
drop table t1, t2;
--8<---------------cut here---------------end--------------->8---

1. During the JOIN::prepare() of the first execution, the Item_field referring to t2.b is replaced by an Item_ref
2. The item_ref is moved around in the exists2in transformation and subsequent optimizations
3. At the end of the 1st ps execution, the Item_ref is freed due to its creation in the ps execution as part of the cleanup
4. During the JOIN::prepare() of the second execution, it tries to restore the optimized version of the statement, in doing so it does a sanity check and causes a sigsegv when trying to access the freed Item_ref.

Why the problem does not occur with the transformation disabled:

- during step 1 above, the replacement also adds an item to the change_list
- during step 2 above, the optimizations cause the equality {{b = a}} to be moved around as a whole, thereby moving its {{args}} which is an {{Item **}} instead of the {{item *}}'s as a whole
- during step 3 above, the change is rolled back, so the {{Item **}} that is the args of the {{Item_func_eq}} goes from {{b (Item_ref) = a}} becomes {{b (Item_field) = a}}
- during step 4 above, there's no use-after-free in the restored optimized statment because it automatically contains the {{b (Item_field) = a}}.

Why we can't do the same with the transformation enabled:

- during step 2, we break the {{b = a}} into the outer_expr (b) and local_field (a), add the outer_expr to left_expr and local_field to the inner select item list. we cannot move the equality as a whole during this transformation.

c0adb05... by Daniel Black

MDEV-31268: Fedora mariadb-connector-c-config conflicts with MariaDB's MariaDB-common

The previous fix in MDEV-24629 had a version end of life date.

Thanks @pgnd on Zulip for noticing.

3f59bbe... by Teemu Ollakka <email address hidden>

MDEV-29293 MariaDB stuck on starting commit state

The problem seems to be a deadlock between KILL command execution
and BF abort issued by an applier, where:
* KILL has locked victim's LOCK_thd_kill and LOCK_thd_data.
* Applier has innodb side global lock mutex and victim trx mutex.
* KILL is calling innobase_kill_query, and is blocked by innodb
  global lock mutex.
* Applier is in wsrep_innobase_kill_one_trx and is blocked by
  victim's LOCK_thd_kill.

The fix in this commit removes the TOI replication of KILL command
and makes KILL execution less intrusive operation. Aborting the
victim happens now by using awake_no_mutex() and ha_abort_transaction().
If the KILL happens when the transaction is committing, the
KILL operation is postponed to happen after the statement
has completed in order to avoid KILL to interrupt commit
processing.

Notable changes in this commit:
* wsrep client connections's error state may remain sticky after
  client connection is closed. This error message will then pop
  up for the next client session issuing first SQL statement.
  This problem raised with test galera.galera_bf_kill.
  The fix is to reset wsrep client error state, before a THD is
  reused for next connetion.
* Release THD locks in wsrep_abort_transaction when locking
  innodb mutexes. This guarantees same locking order as with applier
  BF aborting.
* BF abort from MDL was changed to do BF abort on server/wsrep-lib
  side first, and only then do the BF abort on InnoDB side. This
  removes the need to call back from InnoDB for BF aborts which originate
  from MDL and simplifies the locking.
* Removed wsrep_thd_set_wsrep_aborter() from service_wsrep.h.
  The manipulation of the wsrep_aborter can be done solely on
  server side. Moreover, it is now debug only variable and
  could be excluded from optimized builds.
* Remove LOCK_thd_kill from wsrep_thd_LOCK/UNLOCK to allow more
  fine grained locking for SR BF abort which may require locking
  of victim LOCK_thd_kill. Added explicit call for
  wsrep_thd_kill_LOCK/UNLOCK where appropriate.
* Wsrep-lib was updated to version which allows external
  locking for BF abort calls.

Changes to MTR tests:
* Disable galera_bf_abort_group_commit. This test is going to
  be removed (MDEV-30855).
* Record galera_gcache_recover_manytrx as result file was incomplete.
  Trivial change.
* Make galera_create_table_as_select more deterministic:
  Wait until CTAS execution has reached MDL wait for multi-master
  conflict case. Expected error from multi-master conflict is
  ER_QUERY_INTERRUPTED. This is because CTAS does not yet have open
  wsrep transaction when it is waiting for MDL, query gets interrupted
  instead of BF aborted. This should be addressed in separate task.
* A new test galera_kill_group_commit to verify correct behavior
  when KILL is executed while the transaction is committing.

Co-authored-by: Seppo Jaakola <email address hidden>
Co-authored-by: Jan Lindström <email address hidden>
Signed-off-by: Julius Goryavsky <email address hidden>

03d4fd3... by Robin Newhouse <email address hidden>

Backport GitLab CI to 10.5

Add .gitlab-ci.yml file to earliest supported branch to enable
automated building and testing for all MariaDB major branches.

Note to mergers:
GitLab CI is available for branches >= 10.6. This commit includes a
GitLab CI file identical to that in branches >= 10.6, except for the
MARIADB_MAJOR_VERSION variable which should reflect the branch version.
A modified CI will be included in branches 10.4 with PR !2418.
Also changed is the `allow_failure: true` for the MSAN build,
which should be merged up to later branches.

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.

5422784... by Vlad Lesin

MDEV-31256 fil_node_open_file() releases fil_system.mutex allowing other thread to open its file node

There is room between mutex_exit(&fil_system.mutex) and
mutex_enter(&fil_system.mutex) calls in fil_node_open_file(). During this
room another thread can open the node, and ut_ad(!node->is_open())
assertion in fil_node_open_file_low() can fail.

The fix is not to open node if it was already opened by another thread.

06d555a... by Marko Mäkelä

Merge bb-10.5-release into 10.5

e0084b9... by Marko Mäkelä

MDEV-31234 InnoDB does not free UNDO after the fix of MDEV-30671

trx_purge_truncate_history(): Only call trx_purge_truncate_rseg_history()
if the rollback segment is safe to process. This will avoid leaking undo
log pages that are not yet ready to be processed. This fixes a regression
that was introduced in
commit 0de3be8cfdfc26f5c236eaefe12d03c7b4af22c8 (MDEV-30671).

trx_sys_t::any_active_transactions(): Separately count XA PREPARE
transactions.

srv_purge_should_exit(): Terminate slow shutdown if the history size
does not change and XA PREPARE transactions exist in the system.
This will avoid a hang of the test innodb.recovery_shutdown.

Tested by: Matthias Leich

caeff13... by Otto Kekäläinen

Remove CODEOWNERS as obsolete

The CODEOWNERS was added almost 3 years ago but never saw any adoption.
Only one person used it (me) to mark what files I maintain and for which
I wish to review commits. No other maintainers or code paths were added,
so clean it away for clarity.

c9eff1a... by Marko Mäkelä

MDEV-31254 InnoDB: Trying to read doublewrite buffer page

buf_read_page_low(): Remove an error message and a debug assertion
that can be triggered when using innodb_page_size=4k and
innodb_file_per_table=0. In that case, buf_read_ahead_linear()
may be invoked on page 255, which is one less than the first
page of the doublewrite buffer (256).

477285c... by Marko Mäkelä

MDEV-31253 Freed data pages are not always being scrubbed

fil_space_t::flush_freed(): Renamed from buf_flush_freed_pages();
this is a backport of aa45850687409ba857eb3a0eb19e7ccc28dc02f7 from 10.6.
Invoke log_write_up_to() on last_freed_lsn, instead of avoiding
the operation when the log has not yet been written.
A more costly alternative would be that log_checkpoint() would invoke
this function on every affected tablespace.