Commit graph

195914 commits

Author SHA1 Message Date
Marko Mäkelä
54ac356dea Merge 10.7 into 10.8 2022-06-21 18:19:24 +03:00
Marko Mäkelä
6680fd8d4b Merge 10.6 into 10.7 2022-06-21 18:02:41 +03:00
Marko Mäkelä
3794673111 MDEV-28836: Memory alignment cleanup
Table_cache_instance: Define the structure aligned at
the CPU cache line, and remove a pad[] data member.
Krunal Bauskar reported this to improve performance on ARMv8.

aligned_malloc(): Wrapper for the Microsoft _aligned_malloc()
and the ISO/IEC 9899:2011 <stdlib.h> aligned_alloc().
Note: The parameters are in the Microsoft order (size, alignment),
opposite of aligned_alloc(alignment, size).
Note: The standard defines that size must be an integer multiple
of alignment. It is enforced by AddressSanitizer but not by GNU libc
on Linux.

aligned_free(): Wrapper for the Microsoft _aligned_free() and
the standard free().

HAVE_ALIGNED_ALLOC: A new test. Unfortunately, support for
aligned_alloc() may still be missing on some platforms.
We will fall back to posix_memalign() for those cases.

HAVE_MEMALIGN: Remove, along with any use of the nonstandard memalign().

PFS_ALIGNEMENT (sic): Removed; we will use CPU_LEVEL1_DCACHE_LINESIZE.

PFS_ALIGNED: Defined using the C++11 keyword alignas.

buf_pool_t::page_hash_table::create(),
lock_sys_t::hash_table::create():
lock_sys_t::hash_table::resize(): Pad the allocation size to an
integer multiple of the alignment.

Reviewed by: Vladislav Vaintroub
2022-06-21 16:59:49 +03:00
Marko Mäkelä
2e43af69e3 MDEV-28870 InnoDB: Missing FILE_CREATE, FILE_DELETE or FILE_MODIFY before FILE_CHECKPOINT
There was a race condition between log_checkpoint_low() and
deleting or renaming data files. The scenario is as follows:

1. The buffer pool does not contain dirty pages.
2. A FILE_DELETE or FILE_RENAME record is written.
3. The checkpoint LSN will be moved ahead of the write of the record.
4. The server is killed before the file is actually renamed or deleted.

We will prevent this race condition by ensuring that a log checkpoint
cannot occur between the durable write and the file system operation:

1. Durably write the FILE_DELETE or FILE_RENAME record.
2. Perform the file system operation.
3. Allow any log checkpoint to proceed.

mtr_t::commit_file(): Implement the DELETE or RENAME logic.

fil_delete_tablespace(): Delegate some of the logic to
mtr_t::commit_file().

fil_space_t::rename(): Delegate some logic to mtr_t::commit_file().
Remove the debug injection point fil_rename_tablespace_failure_2
because we do test RENAME failures without any debug injection.

fil_name_write_rename_low(), fil_name_write_rename(): Remove.

Tested by Matthias Leich
2022-06-21 16:59:21 +03:00
Marko Mäkelä
55f02c24a6 MDEV-28845 fixup: Prevent an infinite loop
buf_page_create_low(): Before retrying, release the exclusive page latch
in order to prevent an infinite loop in buf_pool_t::corrupted_evict().
2022-06-21 14:40:40 +03:00
Marko Mäkelä
3b662c6ebd MDEV-28782 fixup: ./mtr --embedded 2022-06-21 14:40:31 +03:00
Marko Mäkelä
325e6aa7af MDEV-28879 Assertion `l->lsn <= log_sys.get_lsn()' failed around recv_recover_page
recv_recover_page(): Correct a debug assertion to refer to recv_sys.lsn,
which may be ahead of log_sys.lsn during non-final recovery batches.
In commit 685d958e38 (MDEV-14425)
when some redundant LSN fields were removed,
log_sys.log.scanned_lsn had been replaced with a reference to
log_sys.lsn instead of the more appropriate recv_sys.lsn.

recv_scan_log(): Remove a redundant call to log_sys.set_recovered_lsn().
It suffices to adjust the log_sys.lsn after parsing (and before starting
to apply) records for the last batch.

Note: Normally, log_sys.lsn must be the latest log sequence number.
Before the final recovery batch, this may be safely violated, because
log_write_up_to() will be a no-op. That function will be invoked by the
buf_flush_page_cleaner thread to initiate writes of recovered pages.
2022-06-20 10:07:33 +03:00
Daniel Black
0e4cf497ca MDEV-28782 mariadb-tzinfo-to-sql to work in bootstrap mode
Work around MDEV-28718 for now, but also optimize the interation
of information_schema.SYSTEM_VARIABLES.

Add test case to show that tzinfo data into bootstrap is
desired functionality.

Bug report thanks to Dan Lenski of AWS.
2022-06-18 01:16:49 +03:00
Sergei Golubchik
2643aa43ae fix spider.variable_deprecation test 2022-06-16 22:39:35 +02:00
Sergei Golubchik
5ad9a41301 re-enable innodb.innodb_page_compressed tests 2022-06-16 21:56:34 +02:00
Marko Mäkelä
cb19e211ec Merge 10.7 into 10.8 2022-06-16 11:15:21 +03:00
Marko Mäkelä
a8c22dae8b Merge 10.6 into 10.7 2022-06-16 10:50:58 +03:00
Marko Mäkelä
5bb90cb2ac Merge 10.5 into 10.6 2022-06-16 10:01:29 +03:00
Marko Mäkelä
e99ba4ac8d MDEV-28864 Assertion `trx_id <= create_id' failed in innodb_check_version()
ha_innobase::prepare_inplace_alter_table(): If the ALTER TABLE
operation is no-op for InnoDB, do reset m_prebuilt->trx_id
so that ha_innobase::table_version() will always report either 0
or the identifier of the transaction that would commit changes
to the InnoDB data dictionary.

The failure scenario involved a completed DROP INDEX followed by
a no-op ALTER TABLE during which the server was killed.
An effort to create a reproducible test failed.
2022-06-16 09:53:46 +03:00
Marko Mäkelä
253806dffc MDEV-28845 InnoDB: Failing assertion: bpage->can_relocate() in buf0lru.cc
Since commit 0b47c126e3 (MDEV-13542)
we treat all-zero pages as corrupted ones.

During a stress test, a read-ahead of an all-zero page was triggered
and the page read was completed concurrently with buf_page_create_low().
This caused the assertion to fail, because buf_page_create_low() was
waiting for the page latch.

buf_page_get_low(): Only invoke buf_pool_t::corrupted_evict()
if the block was not already marked as corrupted.

buf_page_create_low(): On page identifier mismatch, retry the
buf_pool.page_hash lookup.

buf_pool_t::corrupted_evict(): Set the state of the block to FREED
so that a concurrent buf_page_get_low() will refuse to load the page.
Wait for the page latch to be vacant before proceeding to remove
the block from buf_pool.page_hash and buf_pool.LRU.

page_id_t::set_corrupted(), page_id_t::is_corrupted(): Accessors
for indicating a corrupted page identifier.

Tested by Matthias Leich
2022-06-15 17:00:05 +03:00
Marko Mäkelä
0850267d00 MDEV-13542 fixup: Relax an assertion 2022-06-15 13:30:44 +03:00
Vlad Lesin
27309fc6b0 MDEV-28832 infinite loop in mariabackup if log LOG_HEADER_FORMAT field is 0
Avoid the loop with getting rid of back and forth jumping.
2022-06-15 13:30:42 +03:00
Marko Mäkelä
4c0cd953ab MDEV-28766: SET GLOBAL innodb_log_file_buffering
In commit c4c8830709 (MDEV-28111) we disabled
the file system cache on the InnoDB write-ahead log file (ib_logfile0)
by default on Linux.

It turns out that especially with innodb_flush_trx_log_at_commit=2,
writing to the log via the file system cache typically improves throughput,
especially on slow storage or at a small number of concurrent transactions.
For other values of innodb_flush_log_at_trx_commit, direct writes were
observed to be mostly but not always faster. Whether it pays off to
disable the file system cache on the log may depend on the type of storage,
the workload, and the operating system kernel version.

On Linux and Microsoft Windows, we will introduce the settable Boolean
global variable innodb_log_file_buffering that indicates whether the
file system cache on the redo log file is enabled. The default value is
innodb_log_file_buffering=OFF. If the server is started up with
innodb_flush_log_at_trx_commit=2, the value will be changed to
innodb_log_file_buffering=ON.

When a persistent memory interface is being used for the log,
the value cannot be changed from innodb_log_file_buffering=OFF.
On Linux, when the physical block size cannot be determined
to be a power of 2 between 64 and 4096 bytes, the file system cache
cannot be disabled, and innodb_log_file_buffering=ON cannot be changed.

Server log messages will indicate whether the file system cache is
enabled for the redo log:

[Note] InnoDB: Buffered log writes (block size=512 bytes)
[Note] InnoDB: File system buffers for log disabled (block size=512 bytes)

After this change, the startup parameter innodb_flush_method will no
longer control whether O_DIRECT will be set on the redo log on Linux.

On other operating systems that support O_DIRECT, no interface has been
implemented for controlling the file system cache for the redo log.
The innodb_flush_method values O_DIRECT, O_DIRECT_NO_FSYNC, O_DSYNC
will enable O_DIRECT for data files, not the log.

Tested by: Matthias Leich, Axel Schwenke
2022-06-14 17:46:47 +03:00
Marko Mäkelä
813986a647 Merge 10.7 into 10.8 2022-06-14 16:19:29 +03:00
Marko Mäkelä
42d3a7b63d Merge 10.6 into 10.7 2022-06-14 15:35:49 +03:00
Marko Mäkelä
6c82ab4f72 MDEV-28840 innodb_undo_log_truncate is not crash-safe
trx_purge_free_segment(): Do mark that the block will be modified.

It seems possible that this regression was introduced by the
changes to the page-freeing logic
in commit 4179f93d28 (MDEV-18976).

Tested by: Matthias Leich
2022-06-14 15:33:11 +03:00
Thirunarayanan Balathandayuthapani
6c669b9586 MDEV-25581 Allow user thread to do InnoDB fts cache sync
- innodb_fts.sync_block doesn't make sense after MDEV-25581's patch
because fts cache syncing is done as a part of insert operation
and it leads to completion of select over insert sometimes.
This test case is not relevant any more
2022-06-14 16:53:23 +05:30
Marko Mäkelä
ddf511c44d Merge 10.6 into 10.7 2022-06-14 10:17:36 +03:00
Marko Mäkelä
1f1fa7e09c Merge 10.5 into 10.6 2022-06-14 09:49:47 +03:00
Marko Mäkelä
4849d94fe6 MDEV-28828 SIGSEGV in buf_flush_LRU_list_batch
In commit 73fee39ea6 (MDEV-27985)
a regression was introduced that would cause bpage=nullptr to
be referenced.

buf_flush_LRU_list_batch(): Always terminate the loop upon
encountering a null pointer.
2022-06-14 09:14:24 +03:00
Nayuta Yanagisawa
06e9ce798c MDEV-26127 Assertion `err != DB_DUPLICATE_KEY' failed or InnoDB: Failing assertion: id != 0 on ALTER ... REBUILD PARTITION
During rebuild of partition, the partitioning engine calls
alter_close_table(), which does not unlock and close some table
instances of the target table.
Then, the engine fails to rename partitions because there are table
instances that are still locked.

Closing all the table instance of the target table fixes the bug.
2022-06-13 23:44:59 +09:00
Marko Mäkelä
1f3f457193 MDEV-28802 DROP DATABASE in InnoDB still is case-insensitive
innodb_drop_database(): Use explicit TO_BINARY casts on
SYS_TABLES.NAME, which for historical reasons uses the wrong collation
latin1_swedish_ci instead of BINARY.
2022-06-13 17:05:31 +03:00
Monty
65dd31088a Update magic file with Aria table files and ddl log 2022-06-13 16:26:22 +03:00
Monty
1bcd87cdcc Fixed maria.maria-recover and maria.encrypt-no-key test files
These had been damaged during some merge which caused --embedded
test to fail
2022-06-13 16:10:41 +03:00
Tuukka Pasanen
d4760d8c01 MDEV-28642: Suspend obvious false-positive Lintian warnings
MariaDB codebase is huge and Lintian has lots of test than
can fire false-positive warnings which leads to situation
where real problems can't be spotted.

Suspend obvious false-positive Lintian warnings and
let Lintian problems that needs some love shine
out.

Suspends in package mariadb-test-data

Supporting BSD family needs to use '/usr/bin/env perl' and not '/usr/bin/perl'
Perl script are for testing and not for production in mariadb-test-data
package:
 * incorrect-path-for-interpreter

There is several files with national-encoding which are test file so they
can't be in unicode charset
 * national-encoding

Serveral test paths are intentionally repeated:
 * repeated-path-segment

Suspends in package mariadb-test

Supporting BSD family needs to use '/usr/bin/env perl' and not '/usr/bin/perl'
Perl script are for testing and not for production in mariadb-test-data
package:
 * incorrect-path-for-interpreter

Suspends in package source package

Remade some 'version-substvar-for-external-package' to use
regex.

MGroonga is missing source file 'jquery-ui-1.8.18.custom.js' correct
lintian suspend with regex:
 * source-is-missing

There is several files with very long line lenghts. Add suspends
for those that can't be corrected in several places. Most
of them are test result files, SQL test files or intentional
long lines that can't be splitted.
  * very-long-line-length-in-source-file

There is several autogenerated C++ files which probably should not
be there but they should not do any harm:
 * source-contains-autogenerated-visual-c++-file
2022-06-13 17:14:50 +10:00
Thirunarayanan Balathandayuthapani
1fd7d3a9ad MDEV-25581 Allow user thread to do InnoDB fts cache sync
Problem:
========
  InnoDB FTS requesting the fts sync of the table once the fts
cache size reaches 1/10 of innodb_ft_cache_size. But fts_sync()
releases cache lock when writing the word. By doing this, InnoDB
insert thread increases the innodb fts cache memory and
SYNC operation will take more time to complete.

Solution:
=========
  Remove the fts sync operation(FTS_MSG_SYNC_TABLE) from
the fts optimize background thread. Instead of that,
allow user thread to sync the InnoDB fts cache when
the cache size exceeds 512 kb. User thread holds
cache lock while doing cache syncing, it make sure that
other threads doesn't add the docs into the cache.

Removed FTS_MSG_SYNC_TABLE and its related function
because we do remove the FTS_MSG_SYNC_TABLE message
itself.

Removed fts_sync_index_check() and all related
function because other threads doesn't add while
cache operation going on.
2022-06-10 13:39:07 +05:30
Marko Mäkelä
51ca5d517e Fix ./mtr --embedded
This fixes up commit 3d241eb948
2022-06-10 08:59:23 +03:00
Marko Mäkelä
62419b1733 MDEV-26713 fixup: Correct the main.winservice_i18n result 2022-06-09 14:52:28 +03:00
Marko Mäkelä
0af9346079 Merge 10.7 into 10.8 2022-06-09 14:37:53 +03:00
Marko Mäkelä
d61839c71e MDEV-28708 Increased congestion on buf_pool.flush_list_mutex
In commit f80deb9590 (MDEV-27868)
a fix for a correctness regression caused a performance regression
by increasing the amount of work that is executed while holding
buf_pool.flush_list_mutex.

buf_page_t::set_temp_modified(): Relax an assertion, to allow an
already dirty block to be marked as dirty.

buf_page_t::flush_list_requests: Note that the variable is not
always protected by buf_pool.flush_list_mutex. Already dirty blocks
that are being written to will increment the counter without
holding buf_pool.flush_list_mutex.

mtr_t::process_freed_pages(): Handle pages that were freed during
the execution of the mini-transaction.

ReleaseUnlogged, mtr_t::release_unlogged(): Release modified pages when
no log was written. This is for pages of the temporary tablespace, or for
IMPORT TABLESPACE.

ReleaseModified: Renamed from ReleaseBlocks.
Assume that buf_pool.flush_list_mutex was acquired by the caller.

ReleaseSimple: A combination of ReleaseLatches and ReleaseModified,
for the case that for any modified pages, some earlier modifications
are already waiting to be written.

mtr_t::commit(): Invoke one of release_unlogged(), ReleaseModified,
ReleaseSimple, ReleaseAll. Acquire and release buf_pool.flush_list_mutex
at most once.

memo_slot_release(): Simplify the code.

mtr_t::sx_latch_at_savepoint(), mtr_t::x_latch_at_savepoint():
Reduce the size of the critical section.

fil_space_t::update_last_freed_lsn(), fil_space_t::clear_freed_ranges(),
fil_space_t::add_free_range(): Assume that freed_range_mutex is held
by the caller.

buf_pool_t::prepare_insert_into_flush_list(): Determine the insert
position for buf_pool_t::insert_into_flush_list(). Remove any clean
blocks from buf_pool.flush_list that were encountered while searching.

buf_pool_t::insert_into_flush_list(): Insert the block at the
predetermined position.
2022-06-09 14:12:49 +03:00
Marko Mäkelä
fe75e5e5b1 Merge 10.6 into 10.7 2022-06-09 14:11:43 +03:00
Marko Mäkelä
e11b82f8f5 Merge 10.5 into 10.6 2022-06-09 13:34:52 +03:00
Marko Mäkelä
a9d0bb12e6 Merge 10.4 into 10.5 2022-06-09 12:22:55 +03:00
Marko Mäkelä
c89e3b70a7 Merge 10.3 into 10.4 2022-06-09 11:53:46 +03:00
Marko Mäkelä
98293130c3 MDEV-28779: ALTER TABLE IMPORT TABLESPACE corrupts an encrypted table
PageConverter::update_header(): Remove an unnecessary write.
The field that was originally called FIL_PAGE_FILE_FLUSH_LSN only
made sense for the first page of the system tablespace
(initially, for the first page of each file of the system tablespace).
It never had any meaning for .ibd files, and it lost its original
meaning in MariaDB Server 10.8.1 when
commit b07920b634 (MDEV-27199)
removed the ability to start without ib_logfile0.

If the most significant 32 bits of the LSN are nonzero, this
unnecessary write would write the wrong encryption key identifier
to the page. The first page of any file is never encrypted,
so normally those bytes should be 0 for any .ibd file.
2022-06-09 10:57:28 +03:00
Daniel Lewart
2cd1edfc21 MDEV-25577 mariadb-tzinfo-to-sql generates superfluous warnings
The zoneinfo directory is littered with non-timezone information files.

These frequently contain extensions, not present in real timezone files.

Alo leapseconds is frequently there and is not a timezone file.
2022-06-09 13:20:37 +10:00
GuiXiaoDi
9c207c88c1 mysql.server.sh fix for non-Red Hat platforms
The else condition is meant to be here to define the functions
if the Red Hat include file isn't there.

Fixes: commit 467011bcac / MDEV-26614

RedHat -> Red Hat by Daniel Black
2022-06-09 13:09:44 +10:00
Tingyao Nian
4145618103 MDEV-22023 Update man page NAME section to say MariaDB instead of MySQL
Continue the effort of a previous commit (PR#2114) which changed the man
pages titles from MariaDB to MySQL, to further update the man pages.

Update the man page NAME sections to use mariadb-* instead of mysql* for
MariaDB binaries that are drop-in replacements for MySQL equivalents,
indicating that the commands are actually of the MariaDB version.

Before:
    NAME
        mysql_upgrade - check tables for MariaDB upgrade
    ...

After:
    NAME
        mariadb-upgrade - check tables for MariaDB upgrade (mysql_upgrade
        is now a symlink to mariadb-upgrade)
    ...

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.
2022-06-09 09:08:03 +10:00
Oleg Smirnov
5efadf8d8c MDEV-28747 Index condition pushdown may be configured incorrectly
ha_innobase::build_template may initialize m_prebuilt->idx_cond
even if there is no valid pushed_idx_cond_keyno.
This potentially problematic piece of code was found while
working on MDEV-27366
2022-06-08 16:23:20 +04:00
Marko Mäkelä
77b3959b5c MDEV-28457 Crash in page_dir_find_owner_slot()
A prominent remaining source of crashes on corrupted index pages
is page directory corruption.

A frequent caller of page_dir_find_owner_slot() is page_rec_get_prev().
Some of those calls can be replaced with simpler logic that is less
prone to fail.

page_dir_find_owner_slot(),
page_rec_get_prev(), page_rec_get_prev_const(),
btr_pcur_move_to_prev(), btr_pcur_move_to_prev_on_page(),
btr_cur_upd_rec_sys(),
page_delete_rec_list_end(),
rtr_page_copy_rec_list_end_no_locks(),
rtr_page_copy_rec_list_start_no_locks(): Return an error code on failure.

fil_space_t::io(), buf_page_get_low(): Use DB_CORRUPTION for
out-of-bounds page reads.

PageBulk::getSplitRec(), PageBulk::copyOut(): Simplify the code.

btr_validate_level(): Prevent some more CHECK TABLE crashes on
corrupted pages.

btr_block_get(), btr_pcur_move_to_next_page(): Implement some checks that
were previously only part of IndexPurge::next().

IndexPurge::next(): Use btr_pcur_move_to_next_page().
2022-06-08 14:53:24 +03:00
Marko Mäkelä
44ab6cba76 Cleanup: Remove unused error code DB_FORCED_ABORT
MariaDB never supported this form of preemption via high-priority
transactions. This error code shold not have been added in the
first place, in commit 2e814d4702.
2022-06-08 14:23:21 +03:00
Daniel Black
e8b0894dc8 MDEV-28243: AIX missing my_gethwaddr implementation
and failing spider partition test.

With some small datatype changes to the Linux/Solaris my_gethwaddr implementation
the hardware address of AIX can be returned. This is an important aspect
in Spider (and UUID).

Spider test change reviewed by Nayuta Yanagisawa.

my_gethwaddr review by Monty in #2081
2022-06-08 17:13:51 +10:00
Marko Mäkelä
892c426371 MDEV-13542: Do not crash on decryption failure
fil_page_type_validate(): Remove. This debug check was mostly redundant
and added little value to the code paths that deal with page_compressed
or encrypted pages.

fil_get_page_type_name(): Remove; unused function.

fil_space_decrypt(): Return an error if the page is not
supposed to be encrypted. It is possible that an unencrypted page
contains a nonzero key_version field even though it is not supposed
to be encrypted. Previously we would crash in such a situation.

buf_page_decrypt_after_read(): Simplify the code. Remove some
unnecessary error message about temporary tablespace corruption.
This is where we would usually invoke fil_space_decrypt().
2022-06-08 09:48:12 +03:00
Marko Mäkelä
c9498f33de MDEV-18519: Assertion failure in btr_page_reorganize_low()
Even after commit 0b47c126e3
there are a few ib::fatal() calls in non-debug code
that can be replaced easily.

btr_page_reorganize_low(): On size invariant violation, return
an error code instead of crashing.

btr_check_blob_fil_page_type(): On an invalid page type, report
an error but do not crash.

btr_copy_blob_prefix(): Truncate the output if a page type is invalid.

dict_load_foreign_cols(): On an error, return DB_CORRUPTION instead
of crashing.

fil_space_decrypt_full_crc32(), fil_space_decrypt_for_non_full_checksum():
On error, return DB_DECRYPTION_FAILED instead of crashing.

fil_set_max_space_id_if_bigger(): Replace ib::fatal() with an
equivalent ut_a() assertion.
2022-06-08 09:20:48 +03:00
chansuke
960f0344a2 MDEV-25273: fix typo (s/strucures/structures/) 2022-06-08 13:37:35 +10:00