maria:bb-10.2-MDEV-28530

Last commit made on 2022-05-10
Get this branch:
git clone -b bb-10.2-MDEV-28530 https://git.launchpad.net/maria

Branch merges

Branch information

Name:
bb-10.2-MDEV-28530
Repository:
lp:maria

Recent commits

949ff70... by Brandon Nesterenko

MDEV-28530: Revoking privileges from a non-existing user on a master breaks replication on the slave in the presence of replication filters

Problem:
========
Replication can break while applying a query log event if its
respective command errors on the primary, but is ignored by the
replication filter within Grant_tables on the replica. The bug
reported by MDEV-28530 shows this with REVOKE ALL PRIVILEGES using a
non-existent user. The primary will binlog the REVOKE command with
an error code, and the replica will think the command executed with
success because the replication filter will ignore the command while
accessing the Grant_tables classes. When the replica performs an
error check, it sees the difference between the error codes, and
replication breaks.

Solution:
========
If the replication filter check done by Grant_tables logic ignores
the tables, reset thd->slave_expected_error to 0 so that
Query_log_event::do_apply_event() can be made aware that the
underlying query was ignored when it compares errors.

Note that this bug also effects DROP USER if not all users exist
in the provided list, and the patch fixes and tests this case.

Reviewed By:
============
<TODO>

a5dc12e... by Andrei <email address hidden>

MDEV-28310 Missing binlog data for INSERT .. ON DUPLICATE KEY UPDATE
MDEV-21810 MBR: Unexpected "Unsafe statement" warning for unsafe IODKU

MDEV-17614 fixes to replication unsafety for INSERT ON DUP KEY UPDATE
on two or more unique key table left a flaw. The fixes checked the
safety condition per each inserted record with the idea to catch a user-created
value to an autoincrement column and when that succeeds the autoincrement column
would become the source of unsafety too.
It was not expected that after a duplicate error the next record's
write_set may become different and the unsafe decision for that
specific record will be computed to screw the Query's binlogging
state and when @@binlog_format is MIXED nothing gets bin-logged.

This case has been already fixed in 10.5.2 by 91ab42a823 that
relocated/optimized THD::decide_logging_format_low() out of the record insert
loop. The safety decision is computed once and at the right time.
Pertinent parts of the commit are cherry-picked.

Also a spurious warning about unsafety is removed when MIXED
@@binlog_format; original MDEV-17614 test result corrected.
The original test of MDEV-17614 is extended and made more readable.

141ab97... by Oleksandr "Sanja" Byelkin

MDEV-28402 ASAN heap-use-after-free in create_tmp_table, Assertion `l_offset >= 0 && table->s->rec_buff_length - l_offset > 0'

Make default() function follow Item_field and use get_tmp_table_item() for
change_to_use_tmp_fields().

624cb97... by Sergey Petrunia

Update test results after fix for MDEV-19398

20ae481... by Marko Mäkelä

MDEV-28478: INSERT into SPATIAL INDEX in TEMPORARY table writes log

row_ins_sec_index_entry_low(): If a separate mini-transaction is
needed to adjust the minimum bounding rectangle (MBR) in the parent
page, we must disable redo logging if the table is a temporary table.
For temporary tables, no log is supposed to be written, because
the temporary tablespace will be reinitialized on server restart.

rtr_update_mbr_field(): Plug a memory leak.

84e32ef... by Sergey Petrunia

MDEV-28437: Assertion `!eliminated' failed: Part #2

In SELECT_LEX::update_used_tables(),
do not run the loop setting tl->table->maybe_null
when tl is an eliminated table

(Rationale: First, with current table elimination, tl already
 has maybe_null=1. Second, one should not care what flags
 eliminated tables had)

8dbfaa2... by Sergey Petrunia

MDEV-28437: Assertion `!eliminated' failed in Item_subselect::exec

(This is the assert that was added in fix for MDEV-26047)

Table elimination may remove an ON expression from an outer join.
However SELECT_LEX::update_used_tables() will still call

  item->walk(&Item::eval_not_null_tables)

for eliminated expressions. If the subquery is constant and cheap
Item_cond_and will attempt to evaluate it, which will trigger an
assert.
The fix is not to call update_used_tables() or eval_not_null_tables()
for ON expressions that were eliminated.

ba4927e... by Sergey Petrunia

MDEV-19398: Assertion `item1->type() == Item::FIELD_ITEM ...

Window Functions code tries to minimize the number of times it
needs to sort the select's resultset by finding "compatible"
OVER (PARTITION BY ... ORDER BY ...) clauses.

This employs compare_order_elements(). That function assumed that
the order expressions are Item_field-derived objects (that refer
to a temp.table). But this is not always the case: one can
construct queries order expressions are arbitrary item expressions.

Add handling for such expressions: sort them according to the window
specification they appeared in.
This means we cannot detect that two compatible PARTITION BY clauses
that use expressions can share the sorting step.
But at least we won't crash.

794bebf... by anel <email address hidden>

Use proper pid namespace

    Problem:
    ==============
    By testing `pgrep` with `--ns` option,
    introduced with MDEV-21331, commit fb7c1b9415c9a8b0dc2e86ae44f0e7a2634e5d7e,
    I noted that:
    a) `--ns` cannot use more than single PID.
    b) `--ns` is returning the processes of the namespace to which supplied PID belongs to.
    So by that sense command `pgrep -x --ns $$ mysqld` will always return an error and skip
    checking of the existing PID of the server.

    Solution:
    ==============
    Suggested solution is to add `--nslist pid`, since `--ns` needs to know in which namespace type it should look for.
    See `pgrep --help` for different namespace types.
    Note also that this works *only* if script is run as a `root` (we have that case here).

    Current PR is a part of:
    1. MDEV-21331: sync preinst and postrm script
    2. MDEV-15718: check for exact mysqld process

    This commit:
    a) fixes fb7c1b9415c9a8b0dc2e86ae44f0e7a2634e5d7e
    b) Closes PR #2068 (obsolete)
    c) Closes PR #2069 (obsolete)

    Thanks Faustin Lammler <email address hidden> for testing and verifying
    Reviewed by <>

7055545... by Oleksandr "Sanja" Byelkin

New CC 3.1