maria:bb-10.5-nikita-MDEV-30046

Last commit made on 2024-04-25
Get this branch:
git clone -b bb-10.5-nikita-MDEV-30046 https://git.launchpad.net/maria

Branch merges

Branch information

Name:
bb-10.5-nikita-MDEV-30046
Repository:
lp:maria

Recent commits

66d74d9... by Nikita Malyavin

multi_delete: fix unlikely -> likely

2d59fa6... by Nikita Malyavin

MDEV-15990 REPLACE on a precise-versioned table returns ER_DUP_ENTRY

87cdce3... by Nikita Malyavin

ha_heap: recover the cursor after failed ha_update_row

a088955... by Nikita Malyavin

MDEV-30046 Refactor REPLACE and fix idempotent replication

Idempotent write_row works same as REPLACE: if there is a duplicating
record in the table, then it will be deleted and re-inserted, with the
same update optimization.

The code in Rows:log_event::write_row was basically copy-pasted from
write_record.

What's done:
REPLACE operation was unified across replication and sql. It is now
representred as a Write_record class, that holds the whole state, and allows
re-using some resources in between the row writes.

Replace, IODKU and single insert implementations are split across different
methods, reluting in a much cleaner code.

The entry point is preserved as a single Write_record::write_record() call.
The implementation to call is chosen on the constructor stage.

This allowed several optimizations to be done:
1. The table key list is not iterated for every row. We find last unique key in
the order of checking once and preserve it across the rows. See last_uniq_key().
2. ib_handler::referenced_by_foreign_key acquires a global lock. This call was
done per row as well. Not all the table config that allows optimized replace is
folded into a single boolean field can_optimize. All the fields to check are
even stored in a single register on a 64-bit platform.
3. DUP_REPLACE and DUP_UPDATE cases now have one less level of indirection
4. modified_non_trans_tables is checked and set only when it's really needed.
5. Obsolete bitmap manipulations are removed.

Also:
* Unify replace initialization step across implementations:
  add prepare_for_replace and finalize_replace
* alloca is removed in favor of mem_root allocation. This memory is reused
  across the rows.
* An rpl-related callback is added to the replace branch, meaning that an extra
check is made per row replace even for the common case. It can be avoided with
templates if considered a problem.

aae554b... by Nikita Malyavin

MDEV-30046 wrong row targeted with "insert ... on duplicate" and "replace"

When HA_DUPLICATE_POS is not supported, the row to replace was navigated by
ha_index_read_idx_map, which uses only hash to navigate.

Suchwise, given a hash collision it may choose an incorrect row.

handler::position would be correct and very convenient to use here.
The code is updated to set dup_ref by a handler independently of engine
capabilities, when extra lookup is made (for long unique or something else,
for example WITHOUT OVERLAPS)

REPLACE works correctly with this regard, however there are other cases yet
uncovered: LOAD DATA and replication with IDEMPOTENT mode. They will be
fixed by a follow-up, after refactoring.

b3e531a... by =?utf-8?q?Jan_Lindstr=C3=B6m?= <email address hidden>

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 <email address hidden>

10d251e... by Marko Mäkelä

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 f5fddae3cbcff2d2531f0ce61bd144212379aa42

553a4d6... by Kristian Nielsen

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 <email address hidden>

a1c1f50... by Marko Mäkelä

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@f3966eaf869b7bdd9113ab9d5b78469eb0f5f028 and
llvm/llvm-project@13ea1343231fa4ae12fe9fba4c789728465783d7 and
llvm/llvm-project@ff573a42cd1f1d05508f165dc3e645a0ec17edb5 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 455a15fd06b0f449e72e6b10b0474e4139eeeca2 fixed.

Reviewed by: Sergei Golubchik

7229384... by Marko Mäkelä

MDEV-23974 fixup: Cover all debug builds

While commit 75b7cd680b8272ac5a0848791757c1d310501574 was a significant
improvement, we occasionally got test failures of debug builds. One of
the affected tests is innodb.innodb-64k-crash.