Commit graph

24837 commits

Author SHA1 Message Date
Marko Mäkelä
b3e8788009 MDEV-25967: Correctly extend deferred-recovery files
recv_sys_t::recover_deferred(): Set the file size to match the number
of pages. Mariabackup might copy the file while it was being extended.
2021-06-23 13:37:11 +03:00
Marko Mäkelä
592a925c0c MDEV-25996 sux_lock::s_lock(): Assertion !have_s() failed on startup
dict_check_sys_tables(): Correctly advance the cursor position.
This fixes a regression that was caused by
commit 49e2c8f0a6 (MDEV-25743).
2021-06-23 13:36:04 +03:00
Marko Mäkelä
3a566de22d Merge 10.5 into 10.6 2021-06-23 09:24:32 +03:00
Marko Mäkelä
344e59904d Merge 10.4 into 10.5 2021-06-23 08:17:49 +03:00
Marko Mäkelä
09b03ff31b Merge 10.3 into 10.4 2021-06-23 08:05:27 +03:00
Marko Mäkelä
9fc67c6bf3 MDEV-25950 Ignoring strange row from mysql.innodb_index_stats after DDL
commit_try_rebuild(): Invoke trx_t::drop_table_statistics()
with the correct (original) name of the table.
This fixes a regression that was introduced in
commit 1bd681c8b3 (MDEV-25506 part 3).
2021-06-22 17:52:54 +03:00
Marko Mäkelä
e1c953ef23 MDEV-25989 Crash (or hang) on startup after restoring backup
If an ALTER TABLE that affected a table with FULLTEXT INDEX was
in progress while a backup was made, InnoDB would crash or hang
during the first startup after restoring the backup,
while trying to drop the #sql-alter- table for the DDL operation.

drop_garbage_tables_after_restore(): Invoke dict_sys.unlock()
before invoking the FTS functions. Also, invoke purge_sys.stop_FTS()
in debug builds to silence debug assertions. (Purge is not yet
running at this point.)
2021-06-22 15:25:58 +03:00
Marko Mäkelä
35a9aaebe2 MDEV-25981 InnoDB upgrade fails
trx_undo_mem_create_at_db_start(): Relax too strict upgrade checks
that were introduced in
commit e46f76c974 (MDEV-15912).
On commit, pages will typically be set to TRX_UNDO_CACHED state.
Having the type TRX_UNDO_INSERT in such pages is common and
unproblematic; the type would be reset in trx_undo_reuse_cached().

trx_rseg_array_init(): On failure, clean up the rollback segments
that were initialized so far, to avoid an assertion failure later
during shutdown.
2021-06-22 09:30:25 +03:00
Marko Mäkelä
e07f0a2d80 Merge 10.2 into 10.3 2021-06-22 09:15:38 +03:00
Marko Mäkelä
19716ad5a8 MDEV-25982 Upgrade of MariaDB 10.1 log crashes due to missing encryption key
init_crypt_key(): On failure, set info->key_version to
ENCRYPTION_KEY_VERSION_INVALID.

log_crypt_101_read_block(): Refuse to attempt decryption if
info->key_version is ENCRYPTION_KEY_VERSION_INVALID.
2021-06-22 09:11:41 +03:00
Marko Mäkelä
367c75c099 Merge 10.5 into 10.6 2021-06-21 19:56:14 +03:00
Marko Mäkelä
a1907fed60 Merge 10.4 into 10.5 2021-06-21 18:49:36 +03:00
Marko Mäkelä
ce868cd89e Merge 10.3 into 10.4 2021-06-21 18:44:14 +03:00
Marko Mäkelä
9dc50ea229 MDEV-25979 Invalid page number written to DB_ROLL_PTR
trx_undo_report_row_operation(): Fix a race condition that was introduced
in commit f74023b955 (MDEV-15090).
We must not access undo_block after the page latch has been released
in mtr_t::commit(), because the block could be evicted or replaced.
2021-06-21 18:13:28 +03:00
Marko Mäkelä
09249eb9bd MDEV-14180 fixup: Avoid unnecessary dirtying of pages
fil_crypt_rotate_page(): If a page is already marked as dirty,
do not move it in buf_pool.flush_list. Actual re-encryption
will happen in buf_flush_page(), and moving the page in
buf_pool.flush_list may only postpone the operation.
2021-06-21 17:51:03 +03:00
Marko Mäkelä
4dfec8b230 Merge 10.5 into 10.6 2021-06-21 17:49:33 +03:00
Marko Mäkelä
a42c80bd48 Merge 10.4 into 10.5 2021-06-21 14:22:22 +03:00
Marko Mäkelä
baf0ef9a18 After-merge fix: Remove duplicated code
In the merge commit d3e4fae797
a message about innodb_force_recovery was accidentally duplicated.
2021-06-21 14:05:43 +03:00
Marko Mäkelä
d3e4fae797 Merge 10.3 into 10.4 2021-06-21 12:38:25 +03:00
Marko Mäkelä
e46f76c974 MDEV-15912: Remove traces of insert_undo
Let us simply refuse an upgrade from earlier versions if the
upgrade procedure was not followed. This simplifies the purge,
commit, and rollback of transactions.

Before upgrading to MariaDB 10.3 or later, a clean shutdown
of the server (with innodb_fast_shutdown=1 or 0) is necessary,
to ensure that any incomplete transactions are rolled back.
The undo log format was changed in MDEV-12288. There is only
one persistent undo log for each transaction.
2021-06-21 12:34:07 +03:00
Marko Mäkelä
241d30d3fa After-merge fixes for MDEV-14180 2021-06-21 12:09:00 +03:00
Marko Mäkelä
c9a85fb1b1 Merge 10.2 into 10.3 2021-06-21 09:07:40 +03:00
Sergei Golubchik
c3a1ba0fd9 fix spider tests for --ps in 10.5
see also 068246c006 and 690ae1de45
2021-06-19 14:06:11 +02:00
Sergei Golubchik
690ae1de45 fix spider tests for --ps in 10.4
see also 068246c006
2021-06-19 13:46:11 +02:00
Sergei Golubchik
a4f485917e spider tests aren't big in 10.4
see also a5f6eca50d
2021-06-19 13:46:11 +02:00
Monty
15e1fbc37d Fixed flush table issue in MyISAM with CREATE ... SELECT
When doing CREATE TABLE ... ENGINE=MyISAM SELECT ...
the MyISAM table was not completely flushed at commit
which gave some warnings about table not closed in the
atomic test suite.

Fixed by flushing the table in select_insert::prepare_eof().
2021-06-19 03:46:00 +03:00
Sergei Golubchik
068246c006 fix spider tests for --ps
spider tests use

--let $var= many;sql;statements
--eval $var

and this doesn't work in ps
2021-06-19 00:45:49 +02:00
Sergei Golubchik
a5f6eca50d spider tests aren't big
and *never* disable tests in suite.pm based on $::opt_big_test,
this will make the test skipped both as too big (for ./mtr)
and as too small (for ./mtr --big --big).
2021-06-19 00:22:15 +02:00
Sergei Golubchik
12bcbfc978 MDEV-16708: extract nonembedded part of the test into a separate file 2021-06-17 19:30:24 +02:00
Marko Mäkelä
f778a5d5e2 MDEV-25854: Remove garbage tables after restoring a backup
In commit 1c5ae99194 (MDEV-25666)
we had changed Mariabackup so that it would no longer skip files
whose names start with #sql. This turned out to be wrong.
Because operations on such named files are not protected by any
locks in the server, it is not safe to copy them.

Not copying the files may make the InnoDB data dictionary
inconsistent with the file system. So, we must do something
in InnoDB to adjust for that.

If InnoDB is being started up without the redo log (ib_logfile0)
or with a zero-length log file, we will assume that the server
was restored from a backup, and adjust things as follows:

dict_check_sys_tables(), fil_ibd_open(): Do not complain about
missing #sql files if they would be dropped a little later.

dict_stats_update_if_needed(): Never add #sql tables to
the recomputing queue. This avoids a potential race condition when
dropping the garbage tables.

drop_garbage_tables_after_restore(): Try to drop any garbage tables.

innodb_ddl_recovery_done(): Invoke drop_garbage_tables_after_restore()
if srv_start_after_restore (a new flag) was set and we are not in
read-only mode (innodb_read_only=ON or innodb_force_recovery>3).

The tests and dbug_mariabackup_event() instrumentation
were developed by Vladislav Vaintroub, who also reviewed this.
2021-06-17 13:46:16 +03:00
Marko Mäkelä
da65cb4d97 MDEV-25936 Crash during DDL that involves FULLTEXT INDEX
In commit 1bd681c8b3 we introduced
a work-around for the missing MDL protection when the internal
tables of FULLTEXT INDEX are dropped during DDL operations.
That work-around suffered from a race condition. A purge thread
could have narrowly passed purge_sys.check_stop_FTS() and then
(while holding dict_sys.mutex) acquire a table reference right
after fts_lock_table() determined that no references were being
held.

fts_lock_table(): Protect the reference check with dict_sys.mutex.

Thanks to Thirunarayanan Balathandayuthapani for repeating the
failure and testing the fix.
2021-06-16 12:23:41 +03:00
Marko Mäkelä
71964c76fe MDEV-25910: Aim to make all InnoDB DDL durable
Before any committed DDL operation returns control to the caller,
we must ensure that it will have been durably committed before the
ddl_log state may be changed, no matter if
innodb_flush_log_at_trx_commit=0 is being used.

Operations that would involve deleting files were already safe,
because the durable write of the FILE_DELETE record that would precede
the file deletion would also have made the commit durable.

Furthermore, when we clean up ADD INDEX stubs that were left behind
by a previous ha_innobase::commit_inplace_alter_table(commit=false)
when MDL could not be acquired, we will use the same interface as
for dropping indexes. This safety measure should be dead code,
because ADD FULLTEXT INDEX is not supported online, and dropping indexes
only involves file deletion for FULLTEXT INDEX.
2021-06-16 09:03:02 +03:00
Marko Mäkelä
c307dc6efd Remove a unused variable
In commit 1c35a3f6fd a useless
computation that used the variable was removed.
2021-06-16 07:50:04 +03:00
Marko Mäkelä
e5b9dc1536 MDEV-25910: Make ALTER TABLE...ALGORITHM=COPY durable again
ha_innobase::extra(HA_EXTRA_END_ALTER_COPY): Flush the redo log
because the main transaction will not have written any log and
thus will not initiate any log write either. But the DDL recovery
layer expects that the operation will have been committed.
2021-06-15 22:14:51 +03:00
Eugene Kosov
1c35a3f6fd fix clang build
a new warning -Wunused-but-set-variable was introduced recently to clang
2021-06-15 13:10:16 +03:00
Thirunarayanan Balathandayuthapani
7d591cf850 MDEV-24713 Assertion `dict_table_is_comp(index->table)' failed in row_merge_buf_add()
- During online alter conversion from compact to redundant,
virtual column field length already set during
innobase_get_computed_value(). Skip the char(n) check for
virtual column in row_merge_buf_add()
2021-06-15 13:15:32 +05:30
Thirunarayanan Balathandayuthapani
7229107e3e MDEV-25872 InnoDB: Assertion failure in row_merge_read_clustered_index upon ALTER on table with indexed virtual columns
- InnoDB fails to check DB_COMPUTE_VALUE_FAILED error in
row_merge_read_clustered_index() and wrongly asserts that
the buffer shouldn't be ran out of memory. Alter table
should give warning when the column value is being
truncated.
2021-06-15 13:15:32 +05:30
Thirunarayanan Balathandayuthapani
8c7d8b716c MDEV-14180 Automatically disable key rotation checks for file_key_managment plugin
Problem:
=======
- InnoDB iterates the fil_system space list to encrypt the
tablespace in case of key rotation. But it is not
necessary for any encryption plugin which doesn't do
key version rotation.

Solution:
=========
- Introduce a new variable called srv_encrypt_rotate to
indicate whether encryption plugin does key rotation

fil_space_crypt_t::key_get_latest_version(): Enable the
srv_encrypt_rotate only once if current key version is
higher than innodb_encyrption_rotate_key_age

fil_crypt_must_default_encrypt(): Default encryption tables
should be added to default_encryp_tables list if
innodb_encyrption_rotate_key_age is zero and encryption
plugin doesn't do key version rotation

fil_space_create(): Add the newly created space to
default_encrypt_tables list if
fil_crypt_must_default_encrypt() returns true

Removed the nondeterministic select from
innodb-key-rotation-disable test. By default,
InnoDB adds the tablespace to the rotation list and
background crypt thread does encryption of tablespace.
So these select doesn't give reliable results.
2021-06-15 13:15:32 +05:30
Thirunarayanan Balathandayuthapani
7d2c338c48 MDEV-14180 preparation: Rename key_rotation_list
- Rename the rotation list to default_encrypt_tables in
fil_system_t. Because rotation list naming could be
misleading when it comes to key version rotation

- Rename is_in_rotation_list to is_in_default_encrypt
in fil_space_t

- Rename keyrotate_next function to default_encrypt_next

fil_system_t::default_encrypt_next(): Find the next
suitable default encrypt table if beginning of
default_encrypt_tables list has been scheduled
to be deleted
2021-06-15 13:15:32 +05:30
Monty
e41522d6bf Updated libmarias3 2021-06-15 01:34:14 +03:00
Monty
278ab53849 Updated libmarias3 to latest version 2021-06-14 21:33:42 +03:00
Monty
6653206467 Fixed compiler warnings
- Replace strncpy() with strmake() to ensure things are \0 terminated
- Initialized some variables that caused compiler warnings
- Increased buffer that caused warnings from strncpy

One warning from InnoDB, others from Connect.
2021-06-14 20:37:34 +03:00
Monty
af33202af7 Added DDL_options_st *thd_ddl_options(const MYSQL_THD thd)
This is used by InnoDB to detect if CREATE...SELECT is used

Other things:
- Changed InnoDB to use thd_ddl_options()
- Removed lock checking code for create...select (Approved by Marko)
2021-06-14 17:03:19 +03:00
Monty
8d37ef2999 Aria now marks not used varchar space with MEM_UNDEFINED on read. 2021-06-14 17:03:19 +03:00
Marko Mäkelä
cb0cad8156 MDEV-25907: Assertion failed in dict_table_schema_check()
dict_table_schema_check(): Simply remove the debug assertion.
We will still return a failure.
2021-06-14 12:38:56 +03:00
Marko Mäkelä
6ba938af62 MDEV-25905: Assertion table2==NULL in dict_sys_t::add()
In commit 49e2c8f0a6 (MDEV-25743)
we made dict_sys_t::find() incompatible with the rest of the
table name hash table operations in case the table name contains
non-ASCII octets (using a compatibility mode that facilitates the
upgrade into the MySQL 5.0 filename-safe encoding) and the target
platform implements signed char.

ut_fold_string(): Remove; replace with my_crc32c(). This also makes
table name hash value calculations independent on whether char
is unsigned or signed.
2021-06-14 12:38:56 +03:00
Marko Mäkelä
74a0a9877b MDEV-24731 fixup: Another bogus assertion
In commit de407e7cb4 a debug assertion
was added that would not always hold: We could have TRX_STATE_PREPARED
here. But, in that case, the transaction should not have been chosen
as a deadlock victim.
2021-06-14 12:38:56 +03:00
Sujatha
6c39eaeb12 MDEV-21117: refine the server binlog-based recovery for semisync
Problem:
=======
When the semisync master is crashed and restarted as slave it could
recover transactions that former slaves may never have seen.
A known method existed to clear out all prepared transactions
with --tc-heuristic-recover=rollback does not care to adjust
binlog accordingly.

Fix:
===
The binlog-based recovery is made to concern of the slave semisync role of
post-crash restarted server.
No changes in behavior is done to the "normal" binloggging server
and the semisync master.

When the restarted server is configured with
  --rpl-semi-sync-slave-enabled=1
the refined recovery attempts to roll back prepared transactions
and truncate binlog accordingly.
In case of a partially committed (that is committed at least
in one of the engine participants) such transaction gets committed.
It's guaranteed no (partially as well) committed transactions
exist beyond the truncate position.
In case there exists a non-transactional replication event
(being in a way a committed transaction) past the
computed truncate position the recovery ends with an error.

As after master crash and failover to slave, the demoted-to-slave
ex-master must be ready to face and accept its own (generated by)
events, without generally necessary --replicate-same-server-id.
So the acceptance conditions are relaxed for the semisync slave
to accept own events without that option.
While gtid_strict_mode ON ensures no duplicate transaction can be
(re-)executed the master_use_gtid=none slave has to be
configured with --replicate-same-server-id.

*NOTE* for reviewers.

This patch does not handle the user XA which is done
in next git commit.
2021-06-11 19:49:39 +03:00
Sergei Golubchik
773ee80fab federatedx: ha_federatedx::get_txn -> static 2021-06-11 13:02:55 +02:00
Sergei Golubchik
3648b333c7 cleanup: formatting
also avoid an oxymoron of using `MYSQL_PLUGIN_IMPORT` under
`#ifdef MYSQL_SERVER`, and empty_clex_str is so trivial that a plugin
can define it if needed.
2021-06-11 13:02:55 +02:00