Commit graph

194193 commits

Author SHA1 Message Date
Marko Mäkelä
71e10ba3bb Make innodb.innodb-table-online more stable
Occasionally, the test would fail with a result difference for
ddl_log_file_alter_table (0 instead of 1) due to some
nondeterminism in the test. Let us remove that nondeterminism.
2021-11-25 14:03:20 +02:00
Marko Mäkelä
3cfbfa58de Merge 10.5 into 10.6 2021-11-25 08:08:42 +02:00
Marko Mäkelä
ca26953924 Merge 10.4 into 10.5 2021-11-25 07:49:58 +02:00
Marko Mäkelä
de7db5517d MDEV-26674 follow-up: Bless Linux 5.15.3
In commit 1193a793c4 we
set innodb_use_native_aio=OFF when using io_uring
on a kernel where write requests could potentially be lost.

The last reproducible issue was fixed in Linux 5.16-rc1
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v5.16-rc1&id=d3e3c102d107bb84251455a298cf475f24bab995
and the fix was backported to 5.15.3.

Hence, using a 5.16 or later kernel should be fine.
The Debian kernel 5.15.0-1-amd64 (5.15.3-1) was tested.
On Debian, utsname::release or uname -r does not reflect the
exact minor version while utsname::version and uname -v does.

On Fedora however the utsname::version is rather different:

  $ uname -r
  5.14.20-200.fc34.x86_64
  $ uname -v
  #1 SMP Thu Nov 18 22:03:20 UTC 2021

As such we use the version, but fall back to the release if
there isn't the beginnings of a kernel version in the version.

Thanks to Daniel Black for reporting the Linux kernel bug and
Jens Axboe for actually fixing it.

Co-Authored-By: Daniel Black <daniel@mariadb.org>

Closes: #1953
2021-11-25 09:38:58 +11:00
Robert Bindar
fcc8f480af Fix build failure on mac due to invalid access on private member from rw_lock 2021-11-24 17:52:51 +02:00
Sergei Krivonos
cba065f4fe Json_writer_object add integers 2021-11-24 13:01:49 +02:00
Sergei Krivonos
691f7e165a MDEV-27036: allow Json_writer_[array|object] from Json_writer 2021-11-24 13:01:18 +02:00
Marko Mäkelä
b53ee760ff Cleanup: offsetof instead of my_offsetof
Sys_lc_messages, Sys_lc_time_names: Use offsetof(MY_LOCALE, ...)
because the type has standard layout.
2021-11-24 12:42:31 +02:00
Marko Mäkelä
917b421012 MDEV-26682 fixup: GCC -Wunused-variable 2021-11-24 12:05:44 +02:00
Marko Mäkelä
6b2b510839 PFS_events_statements cleanup: Use offsetof
The macro my_offsetof() performs pointer arithmetics that may be
undefined behavior. As reported in MDEV-26272, it may cause
clang -fsanitize=undefined to generate invalid memory references.

struct PFS_events_statements: Convert to std::is_standard_layout
by encapsulating the standard-layout struct PFS_events instead of
deriving from it, so that the standard macro offsetof() can be used.

PFS_events_statements::copy(): Renamed from copy_events_statements().
A cast to void* is now needed in memcpy() to avoid GCC -Wclass-memaccess
"writing to an object ... leaves 64 bytes unchanged".
2021-11-24 12:04:51 +02:00
Marko Mäkelä
7e7235faa9 Cleanup: offsetof instead of my_offsetof
mdl_hash_function(): Use plain offsetof; MDL_key has standard layout.
2021-11-24 09:55:29 +02:00
Daniel Black
8d398710b3 Debian: comment default config
There's no need for Debian to set config items to their
default. Left commented user, datadir and tmpdir as
these may want to be changed. lc-messages and skip-external-locks
are so infrequently set even listing them looks overly verbose.

socket left uncommented in [client-server] as various client
implementations may have different defaults compiled in.
2021-11-24 18:13:57 +11:00
Julius Goryavsky
1c7dd233a7 MDEV-26915 post-fix: deleted unnecessary file 2021-11-23 04:41:14 +01:00
Julius Goryavsky
1ea7d59650 MDEV-26915: SST scripts do not take log_bin_index setting into account
Currently, SST scripts assume that the filename specified in
the --log-bin-index argument either does not contain an extension
or uses the standard ".index" extension. Similar assumptions are
used for the log_bin_index parameter read from the configuration
file. This commit adds support for arbitrary extensions for the
index file paths.
2021-11-23 02:47:16 +01:00
Julius Goryavsky
f21a36d5e1 MDEV-26064: mariabackup SST fails when starting with --innodb-force-recovery
If the server is started with the --innodb-force-recovery argument
on the command line, then during SST this argument can be passed to
mariabackup only at the --prepare stage, and accordingly it must be
removed from the --mysqld-args list (and it is not should be passed
to mariabackup otherwise).

This commit fixes a flaw in the SST scripts and add a test that
checks the ability to run the joiner node in a configuration that
uses --innodb-force-recovery=1.
2021-11-23 02:35:46 +01:00
Marko Mäkelä
9436c778c3 MDEV-27058 fixup: Fix MemorySanitizer, and GCC 4.8.5 ICE on ARMv8
buf_LRU_scan_and_free_block(): It turns out that even with
-fno-expensive-optimizations, GCC 4.8.5 may fail to split an instruction.
For the non-embedded server, -O1 would fail and -Og would seem to work,
while the embedded server build seems to require -O0.

buf_block_init(): Correct the MemorySanitizer instrumentation.

buf_page_get_low(): Do not read dirty data from read-fixed blocks.
These data races were identified by MemorySanitizer. If a read-fixed
block is being accessed, we must acquire and release a page latch,
so that the read-fix (and the exclusive page latch) will be released
and it will be safe to read the page frame contents if needed,
even before acquiring the final page latch. We do that in
buf_read_ahead_linear() and for the allow_ibuf_merge check.

mtr_t::page_lock(): Assert that the block is not read-fixed.
2021-11-20 13:57:23 +02:00
Marko Mäkelä
da3475605e MDEV-27058 fixup: Avoid a hang with ROW_FORMAT=COMPRESSED
buf_page_get_low(): When we are creating an uncompressed page frame
for a ROW_FORMAT=COMPRESSED page, we must release the buf_pool.page_hash
latch and buf_pool.mutex while waiting for other threads to release their
fixes on the block.

This was caught by an occasional hang of the test innodb_zip.bug56680.
2021-11-19 18:54:23 +02:00
Marko Mäkelä
e0f7c89c18 MDEV-26747 after-merge fix for MDEV-12026, MDEV-25105 2021-11-19 09:10:40 +02:00
Sergei Krivonos
d4d71153db Json_writer_object add integers 2021-11-19 01:55:23 +02:00
Sergei Krivonos
8101af68fa MDEV-27036: allow Json_writer_[array|object] from Json_writer 2021-11-19 01:55:23 +02:00
Marko Mäkelä
aaef2e1d8c MDEV-27058: Reduce the size of buf_block_t and buf_page_t
buf_page_t::frame: Moved from buf_block_t::frame.
All 'thin' buf_page_t describing compressed-only ROW_FORMAT=COMPRESSED
pages will have frame=nullptr, while all 'fat' buf_block_t
will have a non-null frame pointing to aligned innodb_page_size bytes.
This eliminates the need for separate states for
BUF_BLOCK_FILE_PAGE and BUF_BLOCK_ZIP_PAGE.

buf_page_t:🔒 Moved from buf_block_t::lock. That is, all block
descriptors will have a page latch. The IO_PIN state that was used
for discarding or creating the uncompressed page frame of a
ROW_FORMAT=COMPRESSED block is replaced by a combination of read-fix
and page X-latch.

page_zip_des_t::fix: Replaces state_, buf_fix_count_, io_fix_, status
of buf_page_t with a single std::atomic<uint32_t>. All modifications
will use store(), fetch_add(), fetch_sub(). This space was previously
wasted to alignment on 64-bit systems. We will use the following encoding
that combines a state (partly read-fix or write-fix) and a buffer-fix
count:

buf_page_t::NOT_USED=0 (previously BUF_BLOCK_NOT_USED)
buf_page_t::MEMORY=1 (previously BUF_BLOCK_MEMORY)
buf_page_t::REMOVE_HASH=2 (previously BUF_BLOCK_REMOVE_HASH)
buf_page_t::FREED=3 + fix: pages marked as freed in the file
buf_page_t::UNFIXED=1U<<29 + fix: normal pages
buf_page_t::IBUF_EXIST=2U<<29 + fix: normal pages; may need ibuf merge
buf_page_t::REINIT=3U<<29 + fix: reinitialized pages (skip doublewrite)
buf_page_t::READ_FIX=4U<<29 + fix: read-fixed pages (also X-latched)
buf_page_t::WRITE_FIX=5U<<29 + fix: write-fixed pages (also U-latched)
buf_page_t::WRITE_FIX_IBUF=6U<<29 + fix: write-fixed; may have ibuf
buf_page_t::WRITE_FIX_REINIT=7U<<29 + fix: write-fixed (no doublewrite)

buf_page_t::write_complete(): Change WRITE_FIX or WRITE_FIX_REINIT to
UNFIXED, and WRITE_FIX_IBUF to IBUF_EXIST, before releasing the U-latch.

buf_page_t::read_complete(): Renamed from buf_page_read_complete().
Change READ_FIX to UNFIXED or IBUF_EXIST, before releasing the X-latch.

buf_page_t::can_relocate(): If the page latch is being held or waited for,
or the block is buffer-fixed or io-fixed, return false. (The condition
on the page latch is new.)

Outside buf_page_get_gen(), buf_page_get_low() and buf_page_free(), we
will acquire the page latch before fix(), and unfix() before unlocking.

buf_page_t::flush(): Replaces buf_flush_page(). Optimize the
handling of FREED pages.

buf_pool_t::release_freed_page(): Assume that buf_pool.mutex is held
by the caller.

buf_page_t::is_read_fixed(), buf_page_t::is_write_fixed(): New predicates.

buf_page_get_low(): Ignore guesses that are read-fixed because they
may not yet be registered in buf_pool.page_hash and buf_pool.LRU.

buf_page_optimistic_get(): Acquire latch before buffer-fixing.

buf_page_make_young(): Leave read-fixed blocks alone, because they
might not be registered in buf_pool.LRU yet.

recv_sys_t::recover_deferred(), recv_sys_t::recover_low():
Possibly fix MDEV-26326, by holding a page X-latch instead of
only buffer-fixing the page.
2021-11-18 17:47:19 +02:00
Marko Mäkelä
db915f7387 MDEV-27058: Move buf_page_t::slot to IORequest::slot
MDEV-23855 and MDEV-23399 already moved some transient data fields
from buffer pool page descriptors to IORequest, but the write buffer
of PAGE_COMPRESSED or ENCRYPTED tables was missed. Since is only needed
during asynchronous page write requests, it belongs to IORequest.
2021-11-18 17:44:33 +02:00
Marko Mäkelä
02e72f7b44 MDEV-26769 follow-up: Remove unnecessary page locking
btr_cur_optimistic_latch_leaves(): Use transactional_shared_lock_guard.

btr_cur_latch_leaves(): Avoid acquiring some page latches, because
the changes are already blocked by index->lock.

btr_cur_search_to_nth_level_func(): Remove a redundant variable
retrying_for_search_prev=!!prev_tree_blocks, and avoid acquiring
some page latches.
2021-11-18 17:44:33 +02:00
Marko Mäkelä
14c5178f25 MDEV-27069: heap-use-after-free in dict_stats_recalc_pool_del()
dict_stats_recalc_pool_del(): Always reposition the iterators after
releasing and reacquiring the mutex. Another thread could have modified
recalc_pool, causing reallocation of the underlying memory while
we were waiting.

This fixes a regression that was caused by
commit 45a05fda27 (MDEV-25919).
2021-11-18 17:39:39 +02:00
Marko Mäkelä
862eccd524 MDEV-26769 fixup: Fix the SUX_LOCK_GENERIC build 2021-11-18 17:34:19 +02:00
Marko Mäkelä
0a168398a0 Merge 10.5 into 10.6 2021-11-17 15:03:47 +02:00
Marko Mäkelä
5489ce0ae1 Merge 10.4 into 10.5 2021-11-17 14:49:12 +02:00
Marko Mäkelä
70e788b1e5 Merge 10.3 into 10.4 2021-11-17 13:59:42 +02:00
Marko Mäkelä
9962cda527 Merge 10.2 into 10.3 2021-11-17 13:55:54 +02:00
Marko Mäkelä
878f7e38c7 MDEV-23805 fixup: Adjsut the MDEV-16131 and MDEV-24730 tests
MDEV-23805 simplified the treatment of empty tables during ALTER TABLE,
which could prevent the scenarios that were previously reported and
fixed as MDEV-16131 and MDEV-24730.

With the MDEV-23805 fix, the statement
SET DEBUG_SYNC = 'now WAIT_FOR copied';
could occasionally time out, depending on timing.
Apparently, there was a race condition where purge could resume
(and empty the table) before ALTER TABLE got the chance to execute.
We must prevent the purge of history from running before
ALTER TABLE has started executing.
2021-11-17 13:40:21 +02:00
Eugene Kosov
ed0a224b3d MDEV-26747 improve corruption check for encrypted tables on ALTER IMPORT
fil_space_decrypt(): change signature to return status via dberr_t only.
Also replace impossible condition with an assertion and prove it via
test cases.
2021-11-17 15:49:22 +06:00
Igor Babaev
8f24f5fee2 MDEV-26825 Bogus error for query with two usage of CTE referring another CTE
This bug affected queries with two or more references to a CTE referring
another CTE if the definition of the latter contained an invocation of
a stored function that used a base table. The bug could lead to a bogus
error message or to an assertion failure.
  For any non-first reference to CTE cte1 With_element::clone_parsed_spec()
is called that parses the specification of cte1 to construct the unit
structure for this usage of cte1. If cte1 refers to another CTE cte2
outside of the specification of cte1 then With_element::clone_parsed_spec()
has to be called for cte2 as well. This call is made by the function
LEX::resolve_references_to_cte() within the invocation of the function
With_element::clone_parsed_spec() for cte1.
  When the specification of a CTE is parsed all table references encountered
in it must be added to the global list of table references for the query.
As the specification for the non-first usage of a CTE is parsed at a
recursive call of the parser the function With_element::clone_parsed_spec()
invoked at this recursive call should takes care of appending the list of
table references encountered in the specification of this CTE cte1 to the
list of table references created for the query. And it should do it after
the call of LEX::resolve_references_to_cte() that resolves references to
CTEs defined outside of the specification of cte1 because this call may
invoke the parser again for specifications of other CTEs and  the table
references from their specifications must ultimately appear in the global
list of table references of the query.
  The code of With_element::clone_parsed_spec() misplaced the call of
LEX::resolve_references_to_cte(). As a result LEX::query_tables_last used
for the query that was supposed to point to the field 'next_global' of the
last element in the global list of table references actually pointed to
'next_global' of the previous element.
  The above inconsistency certainly caused serious problems when table
references used in the stored functions invoked in cloned specifications
of CTEs were added to the global list of table references.
2021-11-16 18:56:43 -08:00
Marko Mäkelä
6841d1afdd Merge 10.5 into 10.6 2021-11-16 17:15:13 +02:00
Marko Mäkelä
ebb15f986f MDEV-27059 page_zip_dir_insert() may corrupt ROW_FORMAT=COMPRESSED tables
In commit 7ae21b18a6 (MDEV-12353)
the recovery of ROW_FORMAT=COMPRESSED tables was changed.
Changes would be logged in a physical format for the compressed
page image, so that the page need not be decompressed or compressed
during recovery.

page_zip_write_rec(): Log any update of the delete-mark flag in the
ROW_FORMAT=COMPRESSED page.

page_zip_dir_insert(): Copy the delete-mark flag. A delete-marked
record may be inserted by btr_cur_pessimistic_update() via
btr_cur_insert_if_possible(), page_cur_tuple_insert(),
page_cur_insert_rec_zip(). In the observed scenario, it was
an ROLLBACK. Presumably, the test case involved repeated DELETE
and INSERT of the same key, or updating a key back and forth.
This change alone might make the adjustment in page_zip_write_rec()
redundant, but we play it safe because we failed to create a
minimal test case for this scenario.
2021-11-16 17:13:15 +02:00
Marko Mäkelä
89ab2538c5 MDEV-27028 [ERROR] [FATAL] InnoDB: SYS_VIRTUAL.TABLE_ID mismatch
If the server is killed during any DDL operation that is about to
delete an .ibd file, recovery could crash when attempting to load
the table definition of the being-dropped table. By design of
commit 1bd681c8b3 (MDEV-25506 part 3),
a table whose name starts with #sql-ib in the data dictionary may
belong to an uncommitted transaction. So, we must ignore any missing
SYS_COLUMNS, SYS_FIELDS, and SYS_VIRTUAL records for such tables.

The "ID mismatch" error messages were misleading; they really mean
"record not found".
2021-11-16 16:31:45 +02:00
Marko Mäkelä
dc8def73f7 Merge 10.5 into 10.6 2021-11-16 16:30:45 +02:00
Marko Mäkelä
09205a1c9a Merge 10.4 into 10.5 2021-11-16 14:26:13 +02:00
Marko Mäkelä
0269d491ea MDEV-27047: Replication fails to remove affected queries from query cache
Rows_log_event::do_apply_event(): Correct the mistake that was made in
the merge 5f8561a6bc.

In Galera, the query cache will be invalidated near the end
of the function.
2021-11-16 13:58:22 +02:00
Marko Mäkelä
079516f00e MDEV-27016: Assertion 'id.page_no() < space.size' failed
buf_flush_check_neighbors(): Relax a debug assertion that
could fail for the very last page(s) of a ROW_FORMAT=COMPRESSED tables          using a 1024-byte or 2048-byte page size.

This assertion started to fail after
commit d09426f9e6 (MDEV-26537)
modified the .ibd file extension to occur in steps of 4096 bytes.
2021-11-16 12:49:51 +02:00
Vladislav Vaintroub
c5e09bf81a MDEV-27056 Windows upgrade_wizard - CloseHandle() on invalid (already closed) pipe handle 2021-11-16 01:51:35 +01:00
Vladislav Vaintroub
9e9e91b3c2 Windows build - fix signtool search path to take modern SDKs into account 2021-11-16 01:51:22 +01:00
Vladislav Vaintroub
72afeaf8a5 MDEV-18439 Windows builds should have core_file=1 by default
reapply patch 96b472c0ae
It was not merged correctly into 10.5+
2021-11-13 10:31:46 +01:00
Thirunarayanan Balathandayuthapani
d270525dfd MDEV-23805 Make Online DDL to Instant DDL when table is empty
- In ha_innobase::prepare_inplace_alter_table(), InnoDB should
check whether the table is empty. If the table is empty then
server should avoid downgrading the MDL after prepare phase.
It is more like instant alter, does change only in dicationary
and metadata.

- Changed few debug test case to make non-empty DDL table
2021-11-12 17:46:35 +05:30
Vladislav Vaintroub
e58a312e42 Merge branch '10.5' into 10.6 2021-11-12 00:33:48 +01:00
Vladislav Vaintroub
5b21a8fafc MDEV-27030 vcol.vcol_keys_myisam fails on Windows x64, with Visual Studio 2022
Upon investigation, decided this to be a compiler bug
(happens with new compiler, on code that did not change for the last 15 years)

Fixed by de-optimizing single function remove_key(), using MSVC pragma
2021-11-12 00:32:39 +01:00
Vladislav Vaintroub
c5380c30b5 Merge branch '10.3' into 10.4 2021-11-12 00:16:37 +01:00
Vladislav Vaintroub
7ea12742d3 Merge branch '10.2' into 10.3 2021-11-12 00:08:53 +01:00
Vladislav Vaintroub
628c281db6 MDEV-27030 vcol.vcol_keys_myisam fails on Windows x64, with Visual Studio 2022
Upon investigation, decided this to be a compiler bug
(happens with new compiler, on code that did not change for the last 15 years)

Fixed by de-optimizing single function remove_key(), using MSVC pragma
2021-11-11 22:12:12 +01:00
Brandon Nesterenko
3163d9e60c MDEV-26991: CURRENT_TEST: main.mysql_binary_zero_insert 'grep' is not recognized as an internal or external command, operable program or batch file.
Removed grep from mysqldump command stream and instead,
extend the search_file pattern to search for rows containing
binary zeros instead of any occurance of '00' in the input
2021-11-11 06:19:19 -07:00
Sergei Krivonos
94ef277b5b MDEV-23766: fix by assert (Windows) 2021-11-10 20:53:24 +02:00