maria:bb-10.5.19-undo_truncate

Last commit made on 2023-05-25
Get this branch:
git clone -b bb-10.5.19-undo_truncate https://git.launchpad.net/maria

Branch merges

Branch information

Name:
bb-10.5.19-undo_truncate
Repository:
lp:maria

Recent commits

6225a3d... by Marko Mäkelä

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

trx_purge_truncate_rseg_history(): Add a parameter to specify if
the entire rollback segment is safe to be freed. If not, we may
still be able to invoke trx_undo_truncate_start() and free some pages,
but we will avoid leaking undo log pages that are not yet ready
to be processed. This fixes a regression that was introduced in
MDEV-30671.

trx_purge_free_segment(), trx_purge_truncate_rseg_history():
Replace some unreachable code with debug assertions.
A buffer-fix does prevent pages from being evicted
from the buffer pool; see buf_page_t::can_relocate().

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.

bc63505... by Marko Mäkelä

MDEV-30753 fixup: Unsafe buffer page restoration

trx_purge_free_segment(): The buffer-fix only prevents a block from
being freed completely from the buffer pool, but it will not prevent
the block from being evicted. Recheck the page identifier after
acquiring an exclusive page latch. If it has changed, backtrack and
invoke buf_page_get_gen() to look up the page normally.

84bb01b... by Sergei Golubchik

don't abort if invalid SSL setup

THIS INTRODUCES A SECURITY ISSUE - THE SERVER AUTOMATICALLY DISABLES
SSL WHEN IT'S REQUIRED, SO A USER WILL THINK THE CONNECTION IS
SECURE WHILE IN FACT IT SILENTLY WON'T BE.

MUST NOT BE PUSHED INTO A MAIN BRANCH

1d0d7c4... by Sergei Golubchik

MDEV-30818 invalid ssl prevents bootstrap

in bootstrap the server reads stdin and does not listen to network.
it won't use ssl anyway

01402e3... by Sergei Golubchik

CONC-637 Build fails when specifying -DPLUGIN_AUTH_GSSAPI_CLIENT=OFF

5d09e04... by Marko Mäkelä

MDEV-30753 Possible corruption due to trx_purge_free_segment()

Starting with commit 0de3be8cfdfc26f5c236eaefe12d03c7b4af22c8 (MDEV-30671),
the field TRX_UNDO_NEEDS_PURGE lost its previous meaning.
The following scenario is possible:

(1) InnoDB is killed at a point of time corresponding to the durable
execution of some fseg_free_step_not_header() but not
trx_purge_remove_log_hdr().
(2) After restart, the affected pages are allocated for something else.
(3) Purge will attempt to access the newly reallocated pages when looking
for some old undo log records.

trx_purge_free_segment(): Invoke trx_purge_remove_log_hdr() as the first
thing, to be safe. If the server is killed, some pages will never be
freed. That is the lesser evil. Also, before each mtr.start(), invoke
log_free_check() to prevent ib_logfile0 overrun.

3e7763a... by Marko Mäkelä

MDEV-30671 InnoDB undo log truncation fails to wait for purge of history

It is not safe to invoke trx_purge_free_segment() or execute
innodb_undo_log_truncate=ON before all undo log records in
the rollback segment has been processed.

A prominent failure that would occur due to premature freeing of
undo log pages is that trx_undo_get_undo_rec() would crash when
trying to copy an undo log record to fetch the previous version
of a record.

If trx_undo_get_undo_rec() was not invoked in the unlucky time frame,
then the symptom would be that some committed transaction history is
never removed. This would be detected by CHECK TABLE...EXTENDED that
was impleented in commit ab0190101b0587e0e03b2d75a967050b9a85fd1b.
Such a garbage collection leak should be possible even when using
innodb_undo_log_truncate=OFF, just involving trx_purge_free_segment().

trx_rseg_t::needs_purge: Change the type from Boolean to a transaction
identifier, noting the most recent non-purged transaction, or 0 if
everything has been purged. On transaction start, we initialize this
to 1 more than the transaction start ID. On recovery, the field may be
adjusted to the transaction end ID (TRX_UNDO_TRX_NO) if it is larger.

The field TRX_UNDO_NEEDS_PURGE becomes write-only; only some debug
assertions that would validate the value. The field reflects the old
inaccurate Boolean field trx_rseg_t::needs_purge.

trx_undo_mem_create_at_db_start(), trx_undo_lists_init(),
trx_rseg_mem_restore(): Remove the parameter max_trx_id.
Instead, store the maximum in trx_rseg_t::needs_purge,
where trx_rseg_array_init() will find it.

trx_purge_free_segment(): Contiguously hold a lock on
trx_rseg_t to prevent any concurrent allocation of undo log.

trx_purge_truncate_rseg_history(): Only invoke trx_purge_free_segment()
if the rollback segment is empty and there are no pending transactions
associated with it.

trx_purge_truncate_history(): Only proceed with innodb_undo_log_truncate=ON
if trx_rseg_t::needs_purge indicates that all history has been purged.

Tested by: Matthias Leich

a61d762... by Marko Mäkelä

MDEV-30479 OPT_PAGE_CHECKSUM mismatch after innodb_undo_log_truncate=ON

page_recv_t::trim(): Do remove log records for mini-transactions
that end right at the threshold LSN. This will avoid an inconsistency
where a dirty page had been evicted from the buffer pool during
undo tablespace truncation, and recovery would attempt to apply
log records for which the last available copy in the data file is
too new. These changes would be discarded anyway.

f8a85af... by Andrei <email address hidden>

MDEV-30940: Revert "binlog.innodb_rc_insert_before_delete is disabled with MDEV-30490"

This reverts commit b2ea57e899b50cb428b6b58a21de5cfe1b191576,
as well as edits binlog.innodb_rc_insert_before_delete.test
to be safely runnable with any preceding test.

Note: manual 10.5 -> 10.6 merge is required to the test.

b2ea57e... by Andrei <email address hidden>

binlog.innodb_rc_insert_before_delete is disabled with MDEV-30490