Commit graph

24971 commits

Author SHA1 Message Date
Marko Mäkelä
a9adfc0f68 MDEV-9948 Failing assertion: new_state->key_version != ENCRYPTION_KEY_VERSION_INVALID in fil0crypt.cc
The test encryption.innodb-redo-nokeys did not actually test
recovery without valid keys, because due to the setting
innodb_encrypt_tables, InnoDB refused to start up at all,
without even attempting any crash recovery.

fil_ibd_load(): If the encryption key is not available,
refuse to load the file.
2022-04-15 20:28:33 +03:00
Nayuta Yanagisawa
4abb023ba5 Spider: disable spider/bugfix.mdev_27239 2022-04-15 18:53:51 +09:00
Thirunarayanan Balathandayuthapani
f61f58e759 MDEV-26578 ERROR: AddressSanitizer: heap-use-after-free around dict_table_t::is_temporary_name
- Purge thread is trying to access the table name when other thread
does rename of the table name. It leads to heap use after free error
by purge thread. purge thread should check whether the table name
is temporary while holding dict_sys.mutex.
2022-04-11 19:59:01 +05:30
Nayuta Yanagisawa
d8463b64b3 MDEV-27239 Spider: Assertion `thd->transaction->stmt.ha_list == __null || trans == &thd->transaction->stmt' failed in ha_commit_trans on BEGIN WORK after FTWRL
The check on the SQL command type, in ha_spider::external_lock() is deleted
by e954d9de. This resulted in the wrong call of spider_internal_start_trx()
(and thus Ha_trx_info::register_ha()).

I reverted the check and refactored ha_spider::external_lock().
2022-04-08 17:59:50 +09:00
Marko Mäkelä
5d8dcfd86c MDEV-25975: Merge 10.4 into 10.5 2022-04-06 10:30:49 +03:00
Marko Mäkelä
cbdf62ae90 MDEV-25975 merge fixup 2022-04-06 10:13:21 +03:00
Marko Mäkelä
cacb61b6be Merge 10.4 into 10.5 2022-04-06 10:06:39 +03:00
Marko Mäkelä
d172df9913 MDEV-25975: Merge 10.3 into 10.4 2022-04-06 09:18:38 +03:00
Marko Mäkelä
d6d66c6e90 Merge 10.3 into 10.4 2022-04-06 08:59:09 +03:00
Marko Mäkelä
e9735a8185 MDEV-25975 innodb_disallow_writes causes shutdown to hang
We will remove the parameter innodb_disallow_writes because it is badly
designed and implemented. The parameter was never allowed at startup.
It was only internally used by Galera snapshot transfer.
If a user executed
SET GLOBAL innodb_disallow_writes=ON;
the server could hang even on subsequent read operations.

During Galera snapshot transfer, we will block writes
to implement an rsync friendly snapshot, as follows:

sst_flush_tables() will acquire a global lock by executing
FLUSH TABLES WITH READ LOCK, which will block any writes
at the high level.

sst_disable_innodb_writes(), invoked via ha_disable_internal_writes(true),
will suspend or disable InnoDB background tasks or threads that could
initiate writes. As part of this, log_make_checkpoint() will be invoked
to ensure that anything in the InnoDB buf_pool.flush_list will be written
to the data files. This has the nice side effect that the Galera joiner
will avoid crash recovery.

The changes to sql/wsrep.cc and to the tests are based on a prototype
that was developed by Jan Lindström.

Reviewed by: Jan Lindström
2022-04-06 08:06:49 +03:00
Marko Mäkelä
7c584d8270 Merge 10.2 into 10.3 2022-04-06 08:06:35 +03:00
Vlad Lesin
6a3545dd1e MDEV-26322 Last binlog file and position are "empty" in mariabackup --prepare output
The issue is caused by 59a0236da4 commit.
The initial intention of the commit was to speed up
"mariabackup --prepare".

The call stack of binlog position reading is the following:
▾ trx_rseg_mem_restore
  ▾ trx_rseg_array_init
      ▾ trx_lists_init_at_db_start
            ▸ srv_start
Both trx_lists_init_at_db_start() and trx_rseg_mem_restore() contain
special cases for srv_operation == SRV_OPERATION_RESTORE condition, and
on this condition only rseg headers are read to parse binlog position.
Performance impact is not so big.

The solution is to revert 59a0236da4.
2022-04-04 12:19:09 +03:00
Daniel Black
7f5a3cd253 MDEV-28231: innodb: format string warning on aix UINT64PFx (ib_id_t)
ib_id_t is a uint64. On AIX this isn't a long long unsigned and to
prevent the compile warnings and potential wrong type, the UINT64PFx
defination is corrected.

As INT64PF is unused (last use, xtradb in 10.2), it is removed to
remove the confusion that INT64PF and UINT64PFx would be different
types otherwise.
2022-04-04 12:06:37 +03:00
Anel Husakovic
1118b66a22 MDEV-23626: CONNECT VIR tables return inconsistent error for UPDATE
- Before the patch UPDATE error message for VIR tables was different from TRUNCATE,UPDATE,DELETE
Reviewed by: <Olivier Bertrand>, vicentiu@mariadb.org
2022-04-01 06:40:28 -07:00
Monty
69be3c13b6 Fixed unlikely assert/crash if initialization of translog failed
This was noticed as part of verifying
MDEV-28186 "crash on startup after crash while regular use"
but is probably not related to the users issue.
Still good to have it fixed
2022-03-31 15:40:17 +03:00
Vlad Lesin
c1ab0e6fc6 MDEV-27343 Useless warning "InnoDB: Allocated tablespace ID <id> for <tablename>, old maximum was 0" during backup stage
mariabackup does not load dictionary during backup, but it loads
tablespaces, that is why fil_system.max_assigned_id is not set with
dict_check_tablespaces_and_store_max_id(). There is no sense to issue the
warning during backup.
2022-03-30 19:42:35 +03:00
Marko Mäkelä
35425cfc55 Cleanup: Remove some unused functions 2022-03-30 15:57:08 +03:00
Marko Mäkelä
7d7bdd4aaa MDEV-28185 InnoDB generates redundant log checkpoints
The comparison on the checkpoint age (number of log bytes
written since the previous checkpoint) is inaccurate, because
the previous FILE_CHECKPOINT record could span two 512-byte
log blocks, which will cause the LSN to increase by the size of the
log block header and footer.

We will still generate a redudant checkpoint if the previous
checkpoint wrote some FILE_MODIFY records before the FILE_CHECKPOINT
record.
2022-03-29 19:42:10 +03:00
Marko Mäkelä
d875c50bf4 MDEV-17841 fixup: GCC -Wmaybe-uninitialized
Let us remove a redundant condition when the S3 plugin is disabled
during compilation time.
2022-03-29 19:41:38 +03:00
Marko Mäkelä
42609c240d Cleanup: Replace log_sys.n_pending_checkpoint_writes with a Boolean
Only one checkpoint may be in progress at a time.
The counter log_sys.n_pending_checkpoint_writes
was being protected by log_sys.mutex.
Let us replace it with the Boolean log_sys.checkpoint_pending.
2022-03-29 14:56:44 +03:00
Marko Mäkelä
b7016bd379 MDEV-26626 fixup: SIGFPE during startup
srv_start(): Set srv_startup_is_before_trx_rollback_phase before
starting the buf_flush_page_cleaner() thread, so that it will not
invoke log_checkpoint() before the log file has been created.

This race condition was reproduced with https://rr-project.org.
This fixes up commit 15efb7ed48
2022-03-29 14:53:51 +03:00
Marko Mäkelä
c14f60a72f Fix g++-12 -O2 -Wstringop-overflow
buf_pool_t::watch_unset(): Reorder some code so that
no warning will be emitted in CMAKE_BUILD_TYPE=RelWithDebInfo.
It is unclear why invoking watch_is_sentinel() before
buf_fix_count() would make the warning disappear.
2022-03-29 12:59:38 +03:00
Marko Mäkelä
d62b0368ca Merge 10.4 into 10.5 2022-03-29 12:59:18 +03:00
Marko Mäkelä
ae6e214fd8 Merge 10.3 into 10.4 2022-03-29 11:13:18 +03:00
Marko Mäkelä
020e7d89eb Merge 10.2 into 10.3 2022-03-29 09:53:15 +03:00
Marko Mäkelä
303448bc91 MDEV-27931: buf_page_is_corrupted() wrongly claims corruption
In commit 437da7bc54 (MDEV-19534),
the default value of the global variable srv_checksum_algorithm
in innochecksum was changed from SRV_CHECKSUM_ALGORITHM_INNODB
to implied 0 (innodb_checksum_algorithm=crc32). As a result,
the function buf_page_is_corrupted() would by default invoke
buf_calc_page_crc32() in innochecksum, and crc32_inited would hold.

This would cause "innochecksum" to fail on a particular page.

The actual problem is older, introduced in 2011 in
mysql/mysql-server@17e497bdb7
(MySQL 5.6.3). It should affect the validation of pages of old
data files that were written with innodb_checksum_algorithm=innodb.
When using innodb_checksum_algorithm=crc32 (the default setting
since MariaDB Server 10.2), some valid pages would be rejected
only because exactly one of the two checksum fields accidentally
matches the innodb_checksum_algorithm=crc32 value.

buf_page_is_corrupted(): Simplify the logic of non-strict
checksum validation, by always invoking buf_calc_page_crc32().
Remove a bogus condition that if only one of the checksum fields
contains the value returned by buf_calc_page_crc32(), the page
is corrupted.
2022-03-28 13:36:36 +03:00
Vlad Lesin
dcb2968f90 MDEV-27557 InnoDB unnecessarily commits mtr during secondary index search to preserve clustered index latching order
New function to release latches till savepoint was added in mtr_t. As
there is no longer need to limit MDEV-20605 fix usage for locking reads
only, the limitation is removed.
2022-03-25 09:22:36 +03:00
Sergei Golubchik
d2c019b200 MDEV-28107 S3 doesn't build if CURL is in non-default location 2022-03-23 17:42:15 +01:00
Sergei Golubchik
2ca3861b55 MDEV-28106 S3 tries to include thread.h while compiling on Windows
S3 engine and libmarias3 don't compile on Windows

also fixes:
MDEV-28104 Typo in storage/maria/s3_func.c: 'FN_DECVHAR
2022-03-23 17:42:15 +01:00
Monty
74e668eaeb Fixed warning for maria.maria-recovery2 about crashed table
The bug was a missing va_start in eprint() which caused a wrong table
name to be printed.
Patch backported from 10.3.
2022-03-18 13:26:50 +02:00
Marko Mäkelä
06e3bc4390 MDEV-17841 fixup: GCC -Wmaybe-uninitialized
In commit ab38b7511b
an added "goto err" would seemingly cause a read of
an uninitialized variable old_info if errpos>=5.

However, because we would have errpos=0 at that point,
there was no real error.
2022-03-17 10:33:06 +02:00
Marko Mäkelä
118826d173 Fix gcc-12 -O2 -Warray-bounds 2022-03-17 10:20:07 +02:00
Marko Mäkelä
75e39f3cba Fix gcc-12 -O2 -Wmaybe-uninitialized 2022-03-17 10:13:50 +02:00
Marko Mäkelä
0f56e21efa MDEV-28091 PERFORMANCE_SCHEMA unit tests fail due to memory misalignment
Let us make the mocked-up pfs_malloc() return aligned memory, just
like the actual implementation does.
2022-03-16 11:49:47 +02:00
Marko Mäkelä
73fee39ea6 MDEV-27985 buf_flush_freed_pages() causes InnoDB to hang
buf_flush_freed_pages(): Assert that neither buf_pool.mutex
nor buf_pool.flush_list_mutex are held. Simplify the loops.
Return the tablespace and the number of pages written or punched.

buf_flush_LRU_list_batch(), buf_do_flush_list_batch():
Release buf_pool.mutex before invoking buf_flush_space().

buf_flush_list_space(): Acquire the mutexes only after invoking
buf_flush_freed_pages().

Reviewed by: Thirunarayanan Balathandayuthapani
2022-03-15 14:44:22 +02:00
Marko Mäkelä
00896db1c5 MDEV-25214 Crash in fil_space_t::try_to_close
fil_space_t::try_to_close(): Tolerate a tablespace that has no
data files attached. The function fil_ibd_create() initially
creates and attaches a tablespace with no files, and invokes
fil_space_t::add() later.

fil_node_open_file(): After releasing and reacquiring fil_system.mutex,
check if the file was already opened by another thread. This avoids
an assertion failure !node->is_open() in fil_node_open_file_low().

These failures were reproduced with the test
innodb.table_definition_cache_debug and the fix of MDEV-27985.
2022-03-15 10:37:13 +02:00
Marko Mäkelä
e1246775a9 Merge 10.4 into 10.5 2022-03-15 08:32:28 +02:00
Thirunarayanan Balathandayuthapani
1c43660aea MDEV-28060 Online DDL fails while checking for instant alter condition
- InnoDB fails to skip newly created column while checking for
change column when table is in redundant row format. This issue
is caused the MDEV-18035 (ccb1acbd3c)
2022-03-14 22:35:11 +05:30
Marko Mäkelä
258c34f17c MDEV-28050: clang -Wtypedef-redefinition when PLUGIN_S3=NO
Let us remove the redundant typedef.
This problem was revealed by
commit 77c184df7c
2022-03-14 10:42:50 +02:00
Marko Mäkelä
c2146ce774 MDEV-24841: More workarounds
For some reason, the tests of the MemorySanitizer build on 10.5 failed
with both clang 13 and clang 14 with SIGSEGV. On 10.6 where it worked
better, some more places to work around were identified.
2022-03-14 10:37:39 +02:00
Marko Mäkelä
59359fb44a MDEV-24841 Build error with MSAN use-of-uninitialized-value in comp_err
The MemorySanitizer implementation in clang includes some built-in
instrumentation (interceptors) for GNU libc. In GNU libc 2.33, the
interface to the stat() family of functions was changed. Until the
MemorySanitizer interceptors are adjusted, any MSAN code builds
will act as if that the stat() family of functions failed to initialize
the struct stat.

A fix was applied in
https://reviews.llvm.org/rG4e1a6c07052b466a2a1cd0c3ff150e4e89a6d87a
but it fails to cover the 64-bit variants of the calls.

For now, let us work around the MemorySanitizer bug by defining
and using the macro MSAN_STAT_WORKAROUND().
2022-03-14 09:28:55 +02:00
Daniel Black
d78173828e MDEV-27900: aio handle partial reads/writes
As btrfs showed, a partial read of data in AIO /O_DIRECT circumstances can
really confuse MariaDB.

Filipe Manana (SuSE)[1] showed how database programmers can assume
O_DIRECT is all or nothing.

While a fix was done in the kernel side, we can do better in our code by
requesting that the rest of the block be read/written synchronously if
we do only get a partial read/write.

Per the APIs, a partial read/write can occur before an error, so
reattempting the request will leave the caller with a concrete error to
handle.

[1] https://lore.kernel.org/linux-btrfs/CABVffENfbsC6HjGbskRZGR2NvxbnQi17gAuW65eOM+QRzsr8Bg@mail.gmail.com/T/#mb2738e675e48e0e0778a2e8d1537dec5ec0d3d3a

Also spell synchronously correctly in other files.
2022-03-12 09:47:53 +11:00
Marko Mäkelä
97d82808b8 Fix clang -Wtypedef-redefinition
This fixes commit 77c184df7c.
2022-03-11 13:29:41 +02:00
Marko Mäkelä
9047a908fe Merge 10.4 into 10.5 2022-03-11 13:03:33 +02:00
Marko Mäkelä
fc8da65919 After-merge fix: clang -Winconsistent-missing-override
The virtual member function that was added in
commit 1766a18e06
needs to be declared "override".
2022-03-11 13:02:53 +02:00
Marko Mäkelä
5503c40460 Stabilize innodb.redo_log_during_checkpoint
Externally kill and restart the server, and remove the
unreliable crash_after_checkpoint.
2022-03-11 09:46:50 +02:00
Marko Mäkelä
81523baac6 Merge 10.4 into 10.5 2022-03-11 09:36:03 +02:00
Marko Mäkelä
22d2df8c6b Merge 10.3 into 10.4 2022-03-11 09:26:42 +02:00
Vlad Lesin
1766a18e06 MDEV-19577 Replication does not work with innodb_autoinc_lock_mode=2
The first step for deprecating innodb_autoinc_lock_mode(see MDEV-27844) is:
- to switch statement binlog format to ROW if binlog format is MIXED and
the statement changes autoincremented fields
- issue warnings if innodb_autoinc_lock_mode == 2 and binlog format is
STATEMENT
2022-03-10 15:38:43 +03:00
Vlad Lesin
0b92c7b0e0 Merge 10.4 into 10.5 2022-03-07 17:16:11 +03:00