Commit graph

11494 commits

Author SHA1 Message Date
Marko Mäkelä
6319c0b541 MDEV-13564: Replace innodb_unsafe_truncate with innodb_safe_truncate
Rename the 10.2-specific configuration option innodb_unsafe_truncate
to innodb_safe_truncate, and invert its value.

The default (for now) is innodb_safe_truncate=OFF, to avoid
disrupting users with an undo and redo log format change within
a Generally Available (GA) release series.
2018-10-11 15:10:13 +03:00
Marko Mäkelä
3448ceb02a MDEV-13564: Implement innodb_unsafe_truncate=ON for compatibility
While MariaDB Server 10.2 is not really guaranteed to be compatible
with Percona XtraBackup 2.4 (for example, the MySQL 5.7 undo log format
change that could be present in XtraBackup, but was reverted from
MariaDB in MDEV-12289), we do not want to disrupt users who have
deployed xtrabackup and MariaDB Server 10.2 in their environments.

With this change, MariaDB 10.2 will continue to use the backup-unsafe
TRUNCATE TABLE code, so that neither the undo log nor the redo log
formats will change in an incompatible way.

Undo tablespace truncation will keep using the redo log only. Recovery
or backup with old code will fail to shrink the undo tablespace files,
but the contents will be recovered just fine.

In the MariaDB Server 10.2 series only, we introduce the configuration
parameter innodb_unsafe_truncate and make it ON by default. To allow
MariaDB Backup (mariabackup) to work properly with TRUNCATE TABLE
operations, use loose_innodb_unsafe_truncate=OFF.

MariaDB Server 10.3.10 and later releases will always use the
backup-safe TRUNCATE TABLE, and this parameter will not be
added there.

recv_recovery_rollback_active(): Skip row_mysql_drop_garbage_tables()
unless innodb_unsafe_truncate=OFF. It is too unsafe to drop orphan
tables if RENAME operations are not transactional within InnoDB.

LOG_HEADER_FORMAT_10_3: Replaces LOG_HEADER_FORMAT_CURRENT.

log_init(), log_group_file_header_flush(),
srv_prepare_to_delete_redo_log_files(),
innobase_start_or_create_for_mysql(): Choose the redo log format
and subformat based on the value of innodb_unsafe_truncate.
2018-10-11 08:17:04 +03:00
Marko Mäkelä
07815d9555 Merge 10.1 into 10.2 2018-10-11 08:16:08 +03:00
Jan Lindström
8b92c64298 Fix tests affected by new configuration variable on Galera. 2018-10-10 18:30:42 +03:00
Julius Goryavsky
1eb364f8b3 MDEV-17421: mtr does not restart the server whose parameters were changed
If a mtr test runs multiple servers and only some of them get
restarted on whatever reason with new command-line parameters,
then subsequent mtr test may fail, because no cleanup is performed.
Replication and Galera test suites are affected.

In the mtr script, there is a server_need_restart function
that decides whether we need to start a new mysqld process before
the new (next) test. If the mysqld parameters were changed in the
previous test - not necessarily the parameters of the primary mysqld
server, maybe even the secondary server parameters - this function
decides to start a new mysqld process. But since it does not remove
the old (changed) parameters, the new process starts with the
parameters changed by the *previous* test.

To correct this error, we must delete the modified process
parameters after checking that they have been changed during
the previous test.

This patch also simplifies and makes more stable the
galera_drop_database test, during debugging of which this
problem was detected.

https://jira.mariadb.org/browse/MDEV-17421
2018-10-10 17:16:34 +02:00
Jan Lindström
3c3c4ae225 MDEV-17403: Test failure on galera.galera_enum
Add wait on second node.
2018-10-10 09:17:10 +03:00
Marko Mäkelä
00b6c7d8fc MDEV-16946 innodb.alter_kill failed in buildbot with wrong result
Ensure that no redo log checkpoint occurs in a critical section
of a recovery test.
2018-10-10 06:31:43 +03:00
Thirunarayanan Balathandayuthapani
e9d9ca8c44 MDEV-16980 Wrongly set tablename len while opening the
table for purge thread

Problem:
=======
	Purge tries to fetch mdl lock for the whole table even though it tries
to open one of the partition. But table name length was wrongly set to indicate
the partition name too.

Solution:
========
- Table name length should identify the table name only not the partition name.
2018-10-08 21:40:18 +05:30
Kristian Nielsen
2f4a0c5be2 Fix accumulation of old rows in mysql.gtid_slave_pos
This would happen especially in optimistic parallel replication, where there
is a good chance that a transaction will be rolled back (due to conflicts)
after it has executed record_gtid(). If the transaction did any deletions of
old rows as part of record_gtid(), those deletions will be undone as well.
And the code did not properly ensure that the deletions would be re-tried.

This patch makes record_gtid() remember the list of deletions done as part
of a transaction. Then in rpl_slave_state::update() when the changes have
been committed, we discard the list. However, in case of error and rollback,
in cleanup_context() we will instead put the list back into
rpl_global_gtid_slave_state so that the deletions will be re-tried later.

Probably fixes part of the cause of MDEV-12147 as well.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2018-10-07 18:59:52 +02:00
Marko Mäkelä
1ff22b2062 MDEV-17289: Skip the test for non-debug server 2018-10-06 13:43:13 +03:00
Thirunarayanan Balathandayuthapani
33fadbfefc MDEV-17289: Add a test case 2018-10-05 17:36:31 +03:00
Marko Mäkelä
29703e4f87 Fix a Galera result 2018-10-05 16:45:58 +05:30
Thirunarayanan Balathandayuthapani
6f2389b22d - Added flush table at the beginning of crash_recovery test case. 2018-10-05 16:45:27 +05:30
Jan Lindström
e855912733 Test by reverting MDEV-16656: DROP DATABASE crashes the Galera Cluster 2018-10-04 13:29:29 +03:00
Jan Lindström
6c29544c20 Enable for staging tree. 2018-10-04 08:05:50 +03:00
Jan Lindström
391b7f5bd1 Fix typo. 2018-10-04 08:04:55 +03:00
Jan Lindström
e2a1c58582 Fix test failure on wsrep.variables
SLES11 can't build currently latest Galera library version.
2018-10-04 07:13:30 +03:00
Jan Lindström
84a24d36d8 MDEV-17357: Test failure on galera.galera_pc_ignore_sb
Add wait until cluster has correct number of nodes.
2018-10-04 07:13:07 +03:00
Jan Lindström
649451ae0d
Merge pull request #875 from tempesta-tech/sysprg/MDEV-16656
MDEV-16656: DROP DATABASE crashes the Galera Cluster
2018-10-01 12:47:35 +03:00
Sachin
865237e5af Fix rpl_parallel_optimistic_nobinlog failure on binlog 2018-10-01 15:15:34 +05:30
Julius Goryavsky
c62e49d0cf MDEV-16656: DROP DATABASE crashes the Galera Cluster
When converting table identifiers to a new format,
some tables can be renamed twice, which subsequently
leads to the appearance of "false" auxiliary tables
belonging to another main (parent) table (which does
not actually have auxiliary tables).

This is because the table number is repeatedly added
to the aux_tables_to_rename vector inside the function
fts_check_and_drop_orphaned_tables.

To correct this error, we must add a check for the
occurrence of the table number in the aux_tables_to_rename
vector before adding a new element.

https://jira.mariadb.org/browse/MDEV-16656
2018-10-01 09:53:37 +02:00
Marko Mäkelä
304857764b MDEV-13564 Mariabackup does not work with TRUNCATE
Implement undo tablespace truncation via normal redo logging.

Implement TRUNCATE TABLE as a combination of RENAME to #sql-ib name,
CREATE, and DROP.
2018-09-25 17:29:43 +03:00
Sergei Golubchik
5ae8fce50b Merge branch '10.1' into 10.2 2018-09-24 11:46:08 +02:00
Sergei Golubchik
1fc5a6f30c Merge branch '10.0' into 10.1 2018-09-23 12:58:11 +02:00
Jan Lindström
87dc4e98dd MDEV-17276: Adjust Galera tests after Galera library 25.3.24 2018-09-23 13:53:57 +03:00
Jan Lindström
eefaf4fdc9 Adjust disabled Galera tests. 2018-09-23 13:26:25 +03:00
Jan Lindström
428669fa83 MDEV-15805: Test failure on galera.query_cache
Reset query cache after every test case and add wait after
load infile.
2018-09-23 13:26:10 +03:00
Sergei Golubchik
a265f0ff24 MDEV-9137 MariaDB Crash on Query Using Aria Engine
more tests
2018-09-22 00:22:09 +02:00
Sergei Golubchik
fb324e3f8f MDEV-9137 MariaDB Crash on Query Using Aria Engine
fix for 2-level ft indexes and boolean search in Aria
2018-09-22 00:22:09 +02:00
Sergei Golubchik
7438667fa9 MDEV-9137 MariaDB Crash on Query Using Aria Engine
update the code to match semantics of `key` -
it's not a (char*) pointer to the buffer as in MyISAM.
2018-09-22 00:22:09 +02:00
Sergei Golubchik
3d65d0db16 MDEV-9137 MariaDB Crash on Query Using Aria Engine
Two bugs in Aria, related to 2-level fulltext indexes:

* REPAIR calculated the key number incorrectly

* CHECK copied the key into last_key too early and
  checking the second-level btree was overwriting it
2018-09-22 00:22:09 +02:00
Sergei Golubchik
e7d152293d MDEV-13089 identifier quoting in partitioning
cover ALTER TABLE
2018-09-21 20:22:14 +02:00
Sergei Golubchik
e4b466aa3d MDEV-16792 Assertion `m_status == DA_ERROR' failed in Diagnostics_area::sql_errno or wrong result upon SHOW TABLE STATUS after adding partition under ANSI_QUOTES
if opening a table fails with a syntax error, the error shouldn't
be suppressed completely as if it didn't happen at all.
2018-09-21 19:56:55 +02:00
Alexander Barkov
80bcb05b24 Merge remote-tracking branch 'origin/5.5' into 10.0 2018-09-21 08:37:42 +04:00
Vladislav Vaintroub
0fa35ddf1f Amend fix for MDEV-17236
Simplify, and make it work with system tablespace outside of
innodb data home.

Also, do not reread TRX_SYS page  in endless loop,
if it appears to be corrupted.

Use finite number of attempts.
2018-09-20 14:08:57 +01:00
Thirunarayanan Balathandayuthapani
7e4bbd3aa6 MDEV-17236 mariabackup incorrectly tries to open ibdata1
if custom undo tablespace is defined

- In case of multiple undo tablespace, mariabackup have to open system
tablespace to find the list of undo tablespace present in TRX_SYS page.
For opening system tablespace, mariabackup should fetch the file name
from already initialized system tablespace object.
2018-09-20 17:13:12 +05:30
Jan Lindström
3177d26627 MDEV-13873: galera.galera_suspend_slave failed in buildbot with wrong error code
Add wsrep_sync_wait as we want INSERT to fail.
2018-09-19 13:10:54 +03:00
Jan Lindström
45712a9a1f MDEV-13871: galera.galera_unicode_identifiers failed in buildbot with 'Unknown database'
Wait in second node until tables with databases are created.
2018-09-19 12:19:30 +03:00
Jan Lindström
82524239c4 MDEV-17208: Test failure on galera.MW-286
Test changes only.
2018-09-19 11:42:43 +03:00
Jan Lindström
654b587999 MDEV-17208: Test failure on galera.MW-286
Test changes only.
2018-09-19 11:33:22 +03:00
Jan Lindström
cc616bea53 Test galera.query_cache is still failing on bb. 2018-09-17 18:18:19 +03:00
Jan Lindström
145c947b88 MDEV-17206: Test failure on galera.galera_ist_* in debug builds
Failure is due missing .rdiff files for debug build as tests have
@have_debug combination.
2018-09-17 12:03:41 +03:00
Jan Lindström
dbf4e68704 MDEV-13879: galera.galera_wan fails in buildbot with Stray state UUID msg or with "Transport endpoint is not connected" or with a failure to start a node
Add correct suppressions and wait conditions for expected database
contents.
2018-09-17 09:05:52 +03:00
Jan Lindström
6a31e86bbd Adjust Galera disabled tests based on test results. 2018-09-17 08:11:38 +03:00
Jan Lindström
d3a8b5aa9c MDEV-14143: galera.galera_kill_smallchanges, galera.galera_kill_ddl fail in buildbot with "Last Applied Action message in non-primary configuration from member 0"
Add supression.
2018-09-14 13:10:48 +03:00
Vladislav Vaintroub
6b2da93359 MDEV-17192 Backup with -no-lock should fail, if DDL is detected at the end of backup 2018-09-14 09:36:02 +01:00
Jan Lindström
c886368a3a Test galera_sst_rsync_data_dir has different result on release
and debug builds. Modified version for 10.1 from following commit:

commit 8e68876477
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date:   Thu Sep 13 15:06:44 2018 +0200

    Fix of the test which has debug version
2018-09-14 11:16:54 +03:00
Jan Lindström
ed7a0e5efc MDEV-13876: galera.MW-328A failed in buildbot with wrong result or timeout
Move MW-328[A,B,C] to big tests as there seem to be big variation
on their execution times and sometimes that could lead timeout.
2018-09-14 10:40:39 +03:00
Oleksandr Byelkin
28f08d3753 Merge branch '10.1' into 10.2 2018-09-14 08:47:22 +02:00
Oleksandr Byelkin
8e68876477 Fix of the test which has debug version 2018-09-13 15:06:44 +02:00
Oleksandr Byelkin
c9d6728c36 try to fix version detection 2018-09-13 12:46:51 +03:00
Jan Lindström
6c7910ee22 Fix test galera#505 galera library version check.
Test requires galera library version 25.3.24.
2018-09-12 19:54:40 +03:00
Jan Lindström
038804d594 Update disabled Galera tests. 2018-09-12 14:56:48 +03:00
Jan Lindström
794e89ed3f MDEV-17108: Test failure on galera.galera_kill_ddl
Add suppression.
2018-09-12 14:54:59 +03:00
Jan Lindström
c76ee73dc7 MDEV-13743: galera_toi_truncate may fail with: query 'reap' succeeded - should have failed with errno 1213
Replace sleep with debug sync point before insert commit to
make sure insert is not executed before truncate has started.
2018-09-12 13:32:14 +03:00
mkaruza
4d9ec7cb6c MDEV-16052 galera mtr galera_certification_double_failure fails with deadlock
There was change in error reporting from my_error to my_message so new recording is required.
2018-09-11 13:55:40 +03:00
Jan Lindström
21829bd743 MDEV-17106: Test failure on galera.galera_binlog_stmt_autoinc
Add missing test case with proper wait conditions for expected
node contents.
2018-09-11 08:19:16 +03:00
Eugene Kosov
e43bc02e7b MDEV-16741 Assertion `m_extra_cache' failed in ha_partition::late_extra_cache
multi_delete sets TABLE::no_cache=1 and should set it to 0 when DELETE is done.
2018-09-10 19:30:06 +02:00
Marko Mäkelä
75f8e86f57 MDEV-17158 TRUNCATE is not atomic after MDEV-13564
It turned out that ha_innobase::truncate() would prematurely
commit the transaction already before the completion of the
ha_innobase::create(). All of this must be atomic.

innodb.truncate_crash: Use the correct DEBUG_SYNC point, and
tolerate non-truncation of the table, because the redo log
for the TRUNCATE transaction commit might be flushed due to
some InnoDB background activity.

dict_build_tablespace_for_table(): Merge to the function
dict_build_table_def_step().

dict_build_table_def_step(): If a table is being created during
an already started data dictionary transaction (such as TRUNCATE),
persistently write the table_id to the undo log header before
creating any file. In this way, the recovery of TRUNCATE will be
able to delete the new file before rolling back the rename of
the original table.

dict_table_rename_in_cache(): Add the parameter replace_new_file,
used as part of rolling back a TRUNCATE operation.

fil_rename_tablespace_check(): Add the parameter replace_new.
If the parameter is set and a file identified by new_path exists,
remove a possible tablespace and also the file.

create_table_info_t::create_table_def(): Remove some debug assertions
that no longer hold. During TRUNCATE, the transaction will already
have been started (and performed a rename operation) before the
table is created. Also, remove a call to dict_build_tablespace_for_table().

create_table_info_t::create_table(): Add the parameter create_fk=true.
During TRUNCATE TABLE, do not add FOREIGN KEY constraints to the
InnoDB data dictionary, because they will also not be removed.

row_table_add_foreign_constraints(): If trx=NULL, do not modify
the InnoDB data dictionary, but only load the FOREIGN KEY constraints
from the data dictionary.

ha_innobase::create(): Lock the InnoDB data dictionary cache only
if no transaction was passed by the caller. Unlock it in any case.

innobase_rename_table(): Add the parameter commit = true.
If !commit, do not lock or unlock the data dictionary cache.

ha_innobase::truncate(): Lock the data dictionary before invoking
rename or create, and let ha_innobase::create() unlock it and
also commit or roll back the transaction.

trx_undo_mark_as_dict(): Renamed from trx_undo_mark_as_dict_operation()
and declared global instead of static.

row_undo_ins_parse_undo_rec(): If table_id is set, this must
be rolling back the rename operation in TRUNCATE TABLE, and
therefore replace_new_file=true.
2018-09-10 14:59:58 +03:00
Jan Lindström
bdaace9b30 MDEV-17151: Galera test failure on galera.galera_var_node_address
Add wait_conditions to wait expected node contents.
2018-09-10 13:43:37 +03:00
Jan Lindström
c1f308054d MDEV-17143: Galera test failure on galera.MW-44
Start general log OFF and then truncate mysql.general_log and
use proper wait timeouts to make sure it is really empty.
2018-09-09 10:23:54 +03:00
Jan Lindström
f01c4a10d7 Add one more wait for truncate in MW-44. 2018-09-08 08:12:55 +03:00
Marko Mäkelä
73ed19e44f MDEV-14585 Automatically remove #sql- tables in InnoDB dictionary during recovery
This is a backport of the following commits:
commit b4165985c9
commit 69e88de0fe
commit 40f4525f43
commit 656f66def2

Now that MDEV-14717 made RENAME TABLE crash-safe within InnoDB,
it should be safe to drop the #sql- tables within InnoDB during
crash recovery. These tables can be one of two things:

(1) #sql-ib related to deferred DROP TABLE (follow-up to MDEV-13407)
or to table-rebuilding ALTER TABLE...ALGORITHM=INPLACE
(since MDEV-14378, only related to the intermediate copy of a table),

(2) #sql- related to the intermediate copy of a table during
ALTER TABLE...ALGORITHM=COPY

We will not drop tables whose name starts with #sql2, because
the server can be killed during an ALGORITHM=COPY operation at
a point where the original table was renamed to #sql2 but the
finished intermediate copy was not yet renamed from #sql-
to the original table name.

If an old version of MariaDB Server before 10.2.13 (MDEV-11415)
was killed while ALTER TABLE...ALGORITHM=COPY was in progress,
after recovery there could be undo log records for some records that were
inserted into an intermediate copy of the table. Due to these undo log
records, InnoDB would resurrect locks at recovery, and the intermediate
table would be locked while we are trying to drop it. This would cause
a call to row_rename_table_for_mysql(), either from
row_mysql_drop_garbage_tables() or from the rollback of a RENAME
operation that was part of the ALTER TABLE.

row_rename_table_for_mysql(): Do not attempt to parse FOREIGN KEY
constraints when renaming from #sql-something to #sql-something-else,
because it does not make any sense.

row_drop_table_for_mysql(): When deferring DROP TABLE due to locks,
do not rename the table if its name already starts with the #sql-
prefix, which is what row_mysql_drop_garbage_tables() uses.
Previously, the too strict prefix #sql-ib was used, and some
tables were renamed unnecessarily.
2018-09-07 22:10:03 +03:00
Marko Mäkelä
8dcacd3b01 Follow-up to MDEV-13407 innodb.drop_table_background failed in buildbot with "Tablespace for table exists"
This is a backport of commit 88aff5f471.

The InnoDB background DROP TABLE queue is something that we should
really remove, but are unable to until we remove dict_operation_lock
so that DDL and DML operations can be combined in a single transaction.

Because the queue is not persistent, it is not crash-safe. We should
in some way ensure that the deferred-dropped tables will be dropped
after server restart.

The existence of two separate transactions complicates the error handling
of CREATE TABLE...SELECT. We should really not break locks in DROP TABLE.

Our solution to these problems is to rename the table to a temporary
name, and to drop such-named tables on InnoDB startup. Also, the
queue will use table IDs instead of names from now on.

check-testcase.test: Ignore #sql-ib*.ibd files, because tables may enter
the background DROP TABLE queue shortly before the test finishes.

innodb.drop_table_background: Test CREATE...SELECT and the creation of
tables whose file name starts with #sql-ib.

innodb.alter_crash: Adjust the recovery, now that the #sql-ib tables
will be dropped on InnoDB startup.

row_mysql_drop_garbage_tables(): New function, to drop all #sql-ib tables
on InnoDB startup.

row_drop_table_for_mysql_in_background(): Remove an unnecessary and
misplaced call to log_buffer_flush_to_disk(). (The call should have been
after the transaction commit. We do not care about flushing the redo log
here, because the table would be dropped again at server startup.)

Remove the entry from the list after the table no longer exists.

If server shutdown has been initiated, empty the list without actually
dropping any tables. They will be dropped again on startup.

row_drop_table_for_mysql(): Do not call lock_remove_all_on_table().
Instead, if locks exist, defer the DROP TABLE until they do not exist.
If the table name does not start with #sql-ib, rename it to that prefix
before adding it to the background DROP TABLE queue.
2018-09-07 22:10:03 +03:00
Marko Mäkelä
754727bb8a MDEV-14378 In ALGORITHM=INPLACE, use a common name for the intermediate tables or partitions
This is a backport of commit 07e9ff1fe1.

Allow DROP TABLE `#mysql50##sql-...._.` to drop tables that were
being rebuilt by ALGORITHM=INPLACE

NOTE: If the server is killed after the table-rebuilding ALGORITHM=INPLACE
commits inside InnoDB but before the .frm file has been replaced, then
the recovery will involve something else than DROP TABLE.

NOTE: If the server is killed in a true inplace ALTER TABLE commits
inside InnoDB but before the .frm file has been replaced, then we
are really out of luck. To properly handle that situation, we would
need a transactional mysql.ddl_fixup table that directs recovery to
rename or remove files.

prepare_inplace_alter_table_dict(): Use the altered_table->s->table_name
for generating the new_table_name.

table_name_t::part_suffix: The start of the partition name suffix.

table_name_t::dbend(): Return the end of the schema name.

table_name_t::dblen(): Return the length of the schema name, in bytes.

table_name_t::basename(): Return the name without the schema name.

table_name_t::part(): Return the partition name, or NULL if none.

row_drop_table_for_mysql(): Assert for #sql, not #sql-ib.
2018-09-07 22:10:03 +03:00
Marko Mäkelä
cf2a4426a2 MDEV-14717 RENAME TABLE in InnoDB is not crash-safe
This is a backport of commit 0bc36758ba
and commit 9eb3fcc9fb.

InnoDB in MariaDB 10.2 appears to only write MLOG_FILE_RENAME2
redo log records during table-rebuilding ALGORITHM=INPLACE operations.
We must write the records for any .ibd file renames, so that the
operations are crash-safe.

If InnoDB is killed during a RENAME TABLE operation, it can happen that
the transaction for updating the data dictionary will be rolled back.
But, nothing will roll back the renaming of the .ibd file
(the MLOG_FILE_RENAME2 only guarantees roll-forward), or for that matter,
the renaming of the dict_table_t::name in the dict_sys cache. We introduce
the undo log record TRX_UNDO_RENAME_TABLE to fix this.

fil_space_for_table_exists_in_mem(): Remove the parameters
adjust_space, table_id and some code that was trying to work around
these deficiencies.

fil_name_write_rename(): Write a MLOG_FILE_RENAME2 record.

dict_table_rename_in_cache(): Invoke fil_name_write_rename().

trx_undo_rec_copy(): Set the first 2 bytes to the length of the
copied undo log record.

trx_undo_page_report_rename(), trx_undo_report_rename():
Write a TRX_UNDO_RENAME_TABLE record with the old table name.

row_rename_table_for_mysql(): Invoke trx_undo_report_rename()
before modifying any data dictionary tables.

row_undo_ins_parse_undo_rec(): Roll back TRX_UNDO_RENAME_TABLE
by invoking dict_table_rename_in_cache(), which will take care
of both renaming the table and the file.

ha_innobase::truncate(): Remove a work-around.
2018-09-07 22:10:02 +03:00
Marko Mäkelä
e67b1070bb MDEV-17049 Enable innodb_undo tests on buildbot
Remove the innodb_undo suite, and move and adapt the tests.
Remove unnecessary restarts, and add innodb_page_size_small.inc
for combinations.

innodb.undo_truncate is the merge of innodb_undo.truncate
and innodb_undo.truncate_multi_client.

Add the global status variable innodb_undo_truncations.
Without this, the test innodb.undo_truncate would occasionally
report that truncation did not happen. The test was only waiting
for the history list length to reach 0, but the undo tablespace
truncation would only take place some time after that.

Undo tablespace truncation will only occasionally occur with
innodb_page_size=32k, and typically never occur (with this amount
of undo log operations) with innodb_page_size=64k. We disable
these combinations.

innodb.undo_truncate_recover was formerly called
innodb_undo.truncate_recover.
2018-09-07 22:10:02 +03:00
Marko Mäkelä
055a3334ad MDEV-13564 Mariabackup does not work with TRUNCATE
Implement undo tablespace truncation via normal redo logging.

Implement TRUNCATE TABLE as a combination of RENAME to #sql-ib name,
CREATE, and DROP.

Note: Orphan #sql-ib*.ibd may be left behind if MariaDB Server 10.2
is killed before the DROP operation is committed. If MariaDB Server 10.2
is killed during TRUNCATE, it is also possible that the old table
was renamed to #sql-ib*.ibd but the data dictionary will refer to the
table using the original name.

In MariaDB Server 10.3, RENAME inside InnoDB is transactional,
and #sql-* tables will be dropped on startup. So, this new TRUNCATE
will be fully crash-safe in 10.3.

ha_mroonga::wrapper_truncate(): Pass table options to the underlying
storage engine, now that ha_innobase::truncate() will need them.

rpl_slave_state::truncate_state_table(): Before truncating
mysql.gtid_slave_pos, evict any cached table handles from
the table definition cache, so that there will be no stale
references to the old table after truncating.

== TRUNCATE TABLE ==

WL#6501 in MySQL 5.7 introduced separate log files for implementing
atomic and crash-safe TRUNCATE TABLE, instead of using the InnoDB
undo and redo log. Some convoluted logic was added to the InnoDB
crash recovery, and some extra synchronization (including a redo log
checkpoint) was introduced to make this work. This synchronization
has caused performance problems and race conditions, and the extra
log files cannot be copied or applied by external backup programs.

In order to support crash-upgrade from MariaDB 10.2, we will keep
the logic for parsing and applying the extra log files, but we will
no longer generate those files in TRUNCATE TABLE.

A prerequisite for crash-safe TRUNCATE is a crash-safe RENAME TABLE
(with full redo and undo logging and proper rollback). This will
be implemented in MDEV-14717.

ha_innobase::truncate(): Invoke RENAME, create(), delete_table().
Because RENAME cannot be fully rolled back before MariaDB 10.3
due to missing undo logging, add some explicit rename-back in
case the operation fails.

ha_innobase::delete(): Introduce a variant that takes sqlcom as
a parameter. In TRUNCATE TABLE, we do not want to touch any
FOREIGN KEY constraints.

ha_innobase::create(): Add the parameters file_per_table, trx.
In TRUNCATE, the new table must be created in the same transaction
that renames the old table.

create_table_info_t::create_table_info_t(): Add the parameters
file_per_table, trx.

row_drop_table_for_mysql(): Replace a bool parameter with sqlcom.

row_drop_table_after_create_fail(): New function, wrapping
row_drop_table_for_mysql().

dict_truncate_index_tree_in_mem(), fil_truncate_tablespace(),
fil_prepare_for_truncate(), fil_reinit_space_header_for_table(),
row_truncate_table_for_mysql(), TruncateLogger,
row_truncate_prepare(), row_truncate_rollback(),
row_truncate_complete(), row_truncate_fts(),
row_truncate_update_system_tables(),
row_truncate_foreign_key_checks(), row_truncate_sanity_checks():
Remove.

row_upd_check_references_constraints(): Remove a check for
TRUNCATE, now that the table is no longer truncated in place.

The new test innodb.truncate_foreign uses DEBUG_SYNC to cover some
race-condition like scenarios. The test innodb-innodb.truncate does
not use any synchronization.

We add a redo log subformat to indicate backup-friendly format.
MariaDB 10.4 will remove support for the old TRUNCATE logging,
so crash-upgrade from old 10.2 or 10.3 to 10.4 will involve
limitations.

== Undo tablespace truncation ==

MySQL 5.7 implements undo tablespace truncation. It is only
possible when innodb_undo_tablespaces is set to at least 2.
The logging is implemented similar to the WL#6501 TRUNCATE,
that is, using separate log files and a redo log checkpoint.

We can simply implement undo tablespace truncation within
a single mini-transaction that reinitializes the undo log
tablespace file. Unfortunately, due to the redo log format
of some operations, currently, the total redo log written by
undo tablespace truncation will be more than the combined size
of the truncated undo tablespace. It should be acceptable
to have a little more than 1 megabyte of log in a single
mini-transaction. This will be fixed in MDEV-17138 in
MariaDB Server 10.4.

recv_sys_t: Add truncated_undo_spaces[] to remember for which undo
tablespaces a MLOG_FILE_CREATE2 record was seen.

namespace undo: Remove some unnecessary declarations.

fil_space_t::is_being_truncated: Document that this flag now
only applies to undo tablespaces. Remove some references.

fil_space_t::is_stopping(): Do not refer to is_being_truncated.
This check is for tablespaces of tables. Potentially used
tablespaces are never truncated any more.

buf_dblwr_process(): Suppress the out-of-bounds warning
for undo tablespaces.

fil_truncate_log(): Write a MLOG_FILE_CREATE2 with a nonzero
page number (new size of the tablespace in pages) to inform
crash recovery that the undo tablespace size has been reduced.

fil_op_write_log(): Relax assertions, so that MLOG_FILE_CREATE2
can be written for undo tablespaces (without .ibd file suffix)
for a nonzero page number.

os_file_truncate(): Add the parameter allow_shrink=false
so that undo tablespaces can actually be shrunk using this function.

fil_name_parse(): For undo tablespace truncation,
buffer MLOG_FILE_CREATE2 in truncated_undo_spaces[].

recv_read_in_area(): Avoid reading pages for which no redo log
records remain buffered, after recv_addr_trim() removed them.

trx_rseg_header_create(): Add a FIXME comment that we could write
much less redo log.

trx_undo_truncate_tablespace(): Reinitialize the undo tablespace
in a single mini-transaction, which will be flushed to the redo log
before the file size is trimmed.

recv_addr_trim(): Discard any redo logs for pages that were
logged after the new end of a file, before the truncation LSN.
If the rec_list becomes empty, reduce n_addrs. After removing
any affected records, actually truncate the file.

recv_apply_hashed_log_recs(): Invoke recv_addr_trim() right before
applying any log records. The undo tablespace files must be open
at this point.

buf_flush_or_remove_pages(), buf_flush_dirty_pages(),
buf_LRU_flush_or_remove_pages(): Add a parameter for specifying
the number of the first page to flush or remove (default 0).

trx_purge_initiate_truncate(): Remove the log checkpoints, the
extra logging, and some unnecessary crash points. Merge the code
from trx_undo_truncate_tablespace(). First, flush all to-be-discarded
pages (beyond the new end of the file), then trim the space->size
to make the page allocation deterministic. At the only remaining
crash injection point, flush the redo log, so that the recovery
can be tested.
2018-09-07 22:10:02 +03:00
Sergei Golubchik
908ac40bdb Merge branch 'bb-10.1-release' into 10.1 2018-09-07 20:24:49 +02:00
Sergei Golubchik
db947b7599 Merge branch '10.0-galera' into 10.1 2018-09-07 15:25:27 +02:00
Jan Lindström
edb3a32c6c MDEV-17143: Galera test failure on galera.MW-44
Test changes only.
2018-09-07 15:58:59 +03:00
Sergei Golubchik
f95d26b4d3 Merge branch '10.1' into bb-10.1-release 2018-09-07 11:52:05 +02:00
Jan Lindström
285969e1c6 Fix result file for wsrep.variables, for some reason had too new
galera library used.
2018-09-07 11:27:15 +03:00
Oleksandr Byelkin
62dbf4f18d post merge 2018-09-07 01:35:09 +02:00
Oleksandr Byelkin
31081593aa Merge branch '11.0' into 10.1 2018-09-06 22:45:19 +02:00
Jan Lindström
b0026e33af Disable failing galera test for now. 2018-09-06 18:55:57 +03:00
Vladislav Vaintroub
a0631e7221 MDEV-17149 mariabackup hangs if innodb is not started
Fix exit condition for the log copying thread.
2018-09-06 15:31:29 +01:00
Jan Lindström
fba683c069 MDEV-17062: Test failure on galera.MW-336
MDEV-17058: Test failure on wsrep.variables
MDEV-17060: Test failure on galera.galera_var_slave_threads

Fix incorrect calculation of increased applier (slave) threads.
Note that increase change takes effect "immediately" but we should
use proper wait condition to wait it. Reducing the number of
slave threads is not immediate as thread will only exit after a
replication event.
2018-09-06 16:05:31 +03:00
Jan Lindström
653038ccad
Merge pull request #855 from tempesta-tech/sysprg/10.1-MDEV-10756
MDEV-10756: wsrep_sst_xtrabackup-v2 does not support innodb_data_home_dir
2018-09-06 14:10:29 +03:00
Jan Lindström
6695fcead3 Galera test case cleanups. 2018-09-05 10:34:36 +03:00
Jan Lindström
b44b9f71bd MDEV-15436: If log_bin and log_bin_index is different SST with rsync fails.
Problem was that in SST log_bin_index name and directory was not
handled and passed to rsync SST script.

wsrep_sst_common.sh
	Read binlog index dirname and filename if --binlog-index
	parameter is provided. Read binlog filenames from that file
	from donor and write transfered binlog filenames to that
	file in joiner.

mysqld.cc, mysqld.h
	Moved opt_binlog_index_name from static to global and added
	it to extern.

wsrep_sst.cc

generate_binlog_index_opt_val
	New function to generate binlog index name if opt_binlog_index_name is
	given on configuration.

sst_prepare_other
	Add binlog index configuration to SST command.

wsrep_sst.h
	Add new SST parameter --binlog-index

Add test case.
2018-09-05 10:34:36 +03:00
Marko Mäkelä
4caf3e08a8 Add MDEV-11080, MDEV-16709 tests for the MDEV-13333 fix
The regression that was introduced in
commit 723f87e9d3
was fixed as part of MDEV-13333
(commit 3b37edee1a)
without a test case, because the MDEV-13333 test case
is even less deterministic than these ones.
2018-09-04 20:21:57 +03:00
Sergei Golubchik
09bc99fac9 cleanup: remove extra/rpl_tests/rpl_foreign_key.test 2018-09-04 09:49:53 +02:00
Sergei Golubchik
9180e8666b MDEV-16465 Invalid (old?) table or database name or hang in ha_innobase::delete_table and log semaphore wait upon concurrent DDL with foreign keys
ALTER TABLE locks the table with TL_READ_NO_INSERT, to prevent the
source table modifications while it's being copied. But there's an
indirect way of modifying a table, via cascade FK actions.

After previous commits, an attempt to modify an FK parent table
will cause FK children to be prelocked, so the table-being-altered
cannot be modified by a cascade FK action, because ALTER holds a
lock and prelocking will wait.

But if a new FK is being added by this very ALTER, then the target
table is not locked yet (it's a temporary table). So, we have to
lock FK parents explicitly.
2018-09-04 09:49:53 +02:00
Sergei Golubchik
dd74332d2c MDEV-12669 Circular foreign keys cause a loop and OOM upon LOCK TABLE
table_already_fk_prelocked() was looking for a table in the wrong
list (not the complete list of prelocked tables, but only in its tail,
starting from the current table - which is always empty for the last
added table), so for circular FKs it kept adding same tables to the list
indefinitely.

Backport of d6d7e169fb
2018-09-04 09:49:52 +02:00
Sergei Golubchik
64a23c1c8a extend prelocking to FK-accessed tables
Backport of f136291098
2018-09-04 08:37:44 +02:00
Oleksandr Byelkin
b9bc3c2463 Merge branch '5.5' into 10.0 2018-09-03 10:57:02 +02:00
Marko Mäkelä
6aa9219ae4 Remove a reference to a non-existing test 2018-08-31 18:10:55 +03:00
Jan Lindström
288212f489 Disable failing Galera tests. 2018-08-31 15:41:15 +03:00
Jan Lindström
c8a3c2bc96 Disable failing Galera tests. 2018-08-31 15:31:33 +03:00
Marko Mäkelä
206528f722 Merge 10.1 into 10.2 2018-08-31 15:10:02 +03:00
Marko Mäkelä
3b5d3cd68e Revert MDEV-9519 due to regressions
This reverts commit 75dfd4acb9.
2018-08-31 12:36:31 +03:00
Alexey Botchkov
c933970974 MDEV-16665 ed25519 describes itself as 1.0-alpha even though it's not alpha.
Plugin version name fixed.
2018-08-30 15:57:22 +04:00
Monty
42f09adab6 MDEV-16682 Assertion `(buff[7] & 7) == HEAD_PAGE' failed
Problem was that SQL level tried to read a record with rnd_pos()
that was already deleted by the same statement.
In the case where the page for the record had been deleted, this
caused an assert.
Fixed by extending the assert to also handle empty pages and
return HA_ERR_RECORD_DELETED for reads to deleted pages.
2018-08-30 13:45:27 +03:00
Monty
cded083a37 MDEV-15797 Assertion `thd->killed != 0' failed in ha_maria::enable_indexes
Problem was that a parallel open of a table, overwrote info->state that
was in used by repair.

Fixed by changing _ma_tmp_disable_logging_for_table() to use
a new state buffer state.no_logging to store the temporary state.

Other things:
- Use original number of rows when retrying repair to get rid of a
  potential warning "Number of rows changed from X to Y"
- Changed maria_commit() to make it easier to merge with 10.4
- If table is not locked (like with show commands), use the global
  number of rows as the local number may not be up to date.
  (Minor not critical fix)
- Added some missing DBUG_RETURN
2018-08-27 22:00:14 +03:00
Julius Goryavsky
c11fb374b5 MDEV-10756: wsrep_sst_xtrabackup-v2 does not support innodb_data_home_dir
Current versions of xtrabackup-v2 and mariabackup support the option
--innodb-data-home-dir, but this parameter is not passed to them from
the SST script, since the SST script does not receive this information
from mysqld. The transfer of this information to the SST is already
fixed by the MDEV-10754 patch, but we need to process it in the SST
script. Also, we should take into account that on the joiner side
the corresponding information is not read yet from the configuration
file (at the mysqld side) during the start of SST, so the script must
itself read it.

https://jira.mariadb.org/browse/MDEV-10756
2018-08-27 16:24:29 +02:00
Monty
490e220ad2 MDEV-17067 Server crash in write_block_record
Problem was that Create_field::create_length_to_internal_length()
calculated a different pack_length for NEWDECIMAL compared to
Field_new_decimal constructor which lead to some unused bytes
in the middle of the record, which Aria didn't like.
2018-08-24 21:03:22 +03:00
Monty
f195286a3e MDEV-17021 Server crash or assertion `length <= column->length' failure in write_block_record
Problem was that the number of NULL bit's was record wrong in the
.frm file because there could be more fields marked NOT_NULL after the
number of not_null fields where recorded.

Fixed by copying test for virtual fields from prepare_create_field()
The code change, only the test, doesn't have to be merged to 10.3
as this is fixed there.
2018-08-24 18:08:56 +03:00
Sergei Golubchik
5d650d366d MDEV-16961 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed upon concurrent DELETE and DDL with virtual blob column
After iterating all fields and setting PART_INDIRECT_KEY_FLAG as
necessary, TABLE::mark_columns_used_by_virtual_fields() remembers
in TABLE_SHARE that this operation was done and need not be repeated.

But as the flag is set in TABLE_SHARE, PART_INDIRECT_KEY_FLAG must
be set in TABLE_SHARE::field[], not only in TABLE::field[].

Otherwise all new TABLEs opened from this TABLE_SHARE will
never have it.
2018-08-22 22:18:44 +02:00
Jan Lindström
b87b8c1344
Merge pull request #828 from tempesta-tech/sysprg/10.1-MDEV-10754
MDEV-10754 wsrep_sst_rsync does not support innodb_data_home_dir
2018-08-21 15:58:09 +03:00
Marko Mäkelä
9258097fa3 Merge 10.1 into 10.2 2018-08-21 15:20:34 +03:00
Oleksandr Byelkin
b4210f3640 Merge branch '10.0' into 10.1 2018-08-21 10:07:26 +02:00
Marc Alff
bac287c315 Bug#27788907 SOME FILE OPERATIONS IN MF_IOCACHE2.C ARE NOT INSTRUMENTED
MySQL bug number 90264

Contribution by Yura Sorokin.

Problem:

File mysys/mf_iocache2.c contains non instrumented file io operations.
This causes inaccurate statistics in PERFORMANCE_SCHEMA.

Solution:

Use the instrumentation apis (mysql_file_tell instead of my_tell, etc).
2018-08-20 13:32:37 +02:00
Igor Babaev
4eac5df3fc MDEV-16934 Query with very large IN clause lists runs slowly
This patch introduces support for the system variable eq_range_index_dive_limit
that existed in MySQL starting from 5.6. The variable sets a limit for
index dives into equality ranges. Index dives are performed by optimizer
to estimate the number of rows in range scans. Index dives usually provide
good estimate but they are pretty expensive. To estimate the number of rows
in equality ranges statistical data on indexes can be employed. Its usage gives
not so good estimates but it's cheap. So if the number of equality dives
required by an index scan exceeds the set limit no dives for equality
ranges are performed by the optimizer for this index.

As the new system variable is introduced in a stable version the default
value for it is set to a special value meaning there is no limit for the number
of index dives performed by the optimizer.

The patch partially uses the MySQL code for WL 5957
'Statistics-based Range optimization for many ranges'.
2018-08-17 14:28:39 -07:00
Julius Goryavsky
4ff7f14fef Fixes of the base patch for compatibility with the 10.1 branch 2018-08-17 15:54:55 +02:00
Marko Mäkelä
d6f7fd6016 MDEV-13564: Refuse MLOG_TRUNCATE in mariabackup
The MySQL 5.7 TRUNCATE TABLE is inherently incompatible
with hot backup, because it is creating and deleting a separate
log file, and it is not writing redo log for all changes of the
InnoDB data dictionary tables. Refuse to create a corrupted backup
if the unsafe form of TRUNCATE was executed.

Note: Undo log tablespace truncation cannot be detected easily.
Also it is incompatible with backup, for similar reasons.

xtrabackup_backup_func(): "Subscribe to" the log events before
the first invocation of xtrabackup_copy_logfile().

recv_parse_or_apply_log_rec_body(): If the function pointer
log_truncate is set, invoke it to report MLOG_TRUNCATE.
2018-08-16 16:10:18 +03:00
Marko Mäkelä
1b49c89429 Re-enable the test mariabackup.unsupported_redo
Remove the logic for skipping the test if a log checkpoint occurred,
and the logic for tolerating failures. Thanks to MDEV-16791,
MLOG_INDEX_LOAD is supposed to always work.
2018-08-16 16:09:51 +03:00
Oleksandr Byelkin
bcc677bb72 Merge branch '5.5' into 10.0 2018-08-15 16:48:13 +02:00
Julius Goryavsky
75dfd4acb9 This is patch for the https://jira.mariadb.org/browse/MDEV-9519 issue:
If we have a 2+ node cluster which is replicating from an async master
and the binlog_format is set to STATEMENT and multi-row inserts are executed
on a table with an auto_increment column such that values are automatically
generated by MySQL, then the server node generates wrong auto_increment
values, which are different from what was generated on the async master.

The causes and fixes:

1. We need to improve processing of changing the auto-increment values
after changing the cluster size.

2. If wsrep auto_increment_control switched on during operation of
the node, then we should immediately update the auto_increment_increment
and auto_increment_offset global variables, without waiting of the next
invocation of the wsrep_view_handler_cb() callback. In the current version
these variables retain its initial values if wsrep_auto_increment_control
is switched on during operation of the node, which leads to inconsistent
results on the different nodes in some scenarios.

3. If wsrep auto_increment_control switched off during operation of the node,
then we must return the original values of the auto_increment_increment and
auto_increment_offset global variables, as the user has set. To make this
possible, we need to add a "shadow copies" of these variables (which stores
the latest values set by the user).
2018-08-15 14:17:28 +03:00
Jan Lindström
5960815630
Merge pull request #844 from codership/10.1-MDEV-15933
MDEV-15933 Cannot resume Node SYNCED state when wsrep_desync is done after FTWRL
2018-08-15 10:35:54 +03:00
Vladislav Vaintroub
922e7badfc MDEV-16791 mariabackup : Support DDL commands during backup 2018-08-14 15:11:13 +01:00
mkaruza
dfb19c06b8 MDEV-15933 Cannot resume Node SYNCED state when wsrep_desync is done after FTWRL
Manually setting wsrep_desync after FTWRL should not be allowed.
2018-08-14 12:06:21 +02:00
Vladislav Vaintroub
9a4998a35a adjust result file 2018-08-13 23:42:20 +01:00
Julius Goryavsky
36832711c1 Reverting changes made to support the mtr under the root 2018-08-13 10:40:47 +02:00
Julius Goryavsky
7e8ed15b95 Fixes after review and correction of the problems caused by the fact that during the SST innodb plugin is not yet initialized, as well as problems with running tests from the root user (not directly related to the MDEV-10754). 2018-08-09 02:24:12 +00:00
Julius Goryavsky
6d5b71e02a Merge branch '10.1' of https://github.com/MariaDB/server into sysprg/10.1-MDEV-10754 2018-08-08 15:47:57 +02:00
Jan Lindström
998b1c0e75 Fix galera test MW-44 2018-08-05 18:16:26 +03:00
Varun Gupta
9419908f38 MDEV-15433: Optimizer does not use group by optimization with distinct
After the commit b76b69cd5f
loose index scan for queries with DISTINCT stopped working.
That is why that commit has to be reverted.
Additionally this patch  fixes the problem of MDEV-10880.
2018-08-05 13:25:40 +03:00
sachin
68ebfb31f2 MDEV-16166 RBR breaks with HA_ERR_KEY_NOT_FOUND upon DELETE from table...
with spatial index

So the issue is since it is spatial index , at the time of searching index
for key (Rows_log_event::find_row) we use wrong field image we use
Field::itRAW while we should be using Field::itMBR
2018-08-04 01:39:35 +05:30
Jan Lindström
ea0356e1ad Add galera library dependency directly to test case. 2018-08-03 16:43:32 +03:00
Jan Lindström
9808e23a7a MariaDB adjustments. 2018-08-03 13:44:30 +03:00
Marko Mäkelä
814ae57daf Merge 10.1 into 10.2 2018-08-03 13:02:56 +03:00
Oleksandr Byelkin
9d42eb5e28 Disable an unstable test 2018-08-03 12:30:50 +03:00
mkaruza
639bd1c71f galera#505 mtr test
MTR test for galera#505
2018-08-03 12:16:36 +03:00
Teemu Ollakka
1d414d9491 codership/galera#501 Check cluster weight in galera_pc_weight test
Check that cluster weight have proper values in galera_pc_weight
test. Removed sleeps from tests and added condition waits for
expected cluster sizes. Replaced galera suspend/resume with
gmcast.isolate in order to avoid breaking client connections
to server which is isolated from the cluster and to avoid
the need to reset wsrep_cluster_address.

Re-recorded galera_defaults.
2018-08-03 12:05:14 +03:00
Marko Mäkelä
976f920514 MDEV-16850 Merge new release of InnoDB 5.7.23 to 10.2
This concludes the merge of all applicable InnoDB changes from
MySQL 5.7.23, with the exception of a performance fix, which we
plan to rewrite in MariaDB later in such a way that it does not
involve changing the storage engine API:

MDEV-16849 Extending indexed VARCHAR column should be instantaneous
2018-08-03 08:37:05 +03:00
Marko Mäkelä
de469a2f29 MDEV-14637: Fix hang due to persistent statistics
Similar to the tables SYS_FOREIGN and SYS_FOREIGN_COLS,
the tables mysql.innodb_table_stats and mysql.innodb_index_stats
are updated by the InnoDB internal SQL parser, which fails to
enforce the size limits of the data. Due to this, it is possible
for InnoDB to hang when there are persistent statistics defined on
partitioned tables where the total length of table name,
partition name and subpartition name exceeds the incorrectly
defined limit VARCHAR(64). That column should have been defined
as VARCHAR(199).

btr_node_ptr_max_size(): Interpret the VARCHAR(64) as VARCHAR(199),
to prevent a hang in the case that the upgrade script has not been
run.

dict_table_schema_check(): Ignore difference in the length of the
table_name column.

ha_innobase::max_supported_key_length(): For innodb_page_size=4k,
return a larger value so that the table mysql.innodb_index_stats
can be created. This could allow "impossible" tables to be created,
such that it is not possible to insert anything into a secondary
index when both the secondary key and the primary key are long,
but this is the easiest and most consistent way. The Oracle fix
would only ignore the maximum length violation for the two
statistics tables.

os_file_get_status_posix(), os_file_get_status_win32(): Handle
ENAMETOOLONG as well.

This patch is based on the following change in MySQL 5.7.23.
Not all changes were applied, and our variant allows persistent
statistics to work without hangs even if the table definitions
were not upgraded.

From fdbdce701ab8145ae234c9d401109dff4e4106cb Mon Sep 17 00:00:00 2001
From: Aditya A <aditya.a@oracle.com>
Date: Thu, 17 May 2018 16:11:43 +0530
Subject: [PATCH] Bug #26390736 THE FIELD TABLE_NAME (VARCHAR(64)) FROM
           MYSQL.INNODB_TABLE_STATS CAN OVERFLOW.

    In mysql.innodb_index_stats and mysql.innodb_table_stats
    tables the table name column didn't take into consideration
    partition names which can be more than varchar(64).
2018-08-03 08:33:38 +03:00
Oleksandr Byelkin
5ce21bc67f Merge branch '10.1' into 10.2 2018-08-02 21:41:41 +02:00
Oleksandr Byelkin
b4f7f12e2b fix galera test. 2018-08-02 20:27:10 +02:00
Jan Lindström
9b29bda0d6 Merge remote-tracking branch 'origin/5.5-galera' into 10.0-galera 2018-08-02 13:13:21 +03:00
Jan Lindström
c5a8583b31 Merge tag 'mariadb-10.0.36' into 10.0-galera 2018-08-02 11:44:02 +03:00
Daniele Sciascia
4d2b552369 Fix FK constraint violation in applier, after ALTER TABLE ADD FK
Adding a FK constraint to an existing table (ALTER TABLE ADD FOREIGN
KEY) causes the applier to fail, if a concurrent DML statement that
violate the new constraint (i.e. a DELETE or UPDATE of record in the
parent table).

For exmaple, the following scenario causes a crash in the applier:

1. ALTER successfully adds FK constraint in node_1
2. On node_2 is UPDATE is in pre_commit() and has certified successfully
3. ALTER is delivered in node_2 and BF aborts DML
4. Applying UPDATE event causes FK violation in node_1

To avoid this situation it is necessary for UPDATE to fail during
certification. And for the UPDATE to fail certfication it is necessary
that ALTER appends certification keys for both the child and the parent
table. Before this patch, ALTER TABLE ADD FK only appended keys for
child table which is ALTERed.
2018-08-02 09:03:27 +03:00
Marko Mäkelä
ef3070e997 Merge 10.1 into 10.2 2018-08-02 08:19:57 +03:00
Jan Lindström
b286a9f823 Merge tag 'mariadb-5.5.61' into 5.5-galera 2018-08-01 10:58:38 +03:00
Marko Mäkelä
2fb68244b4 Merge 10.0 into 10.1 2018-08-01 08:45:59 +03:00
Marko Mäkelä
a7f84f09bf MDEV-16865 InnoDB fts_query() ignores KILL
The functions fts_ast_visit() and fts_query() inside
InnoDB FULLTEXT INDEX query processing are not checking
for THD::killed (trx_is_interrupted()), like anything
that potentially takes a long time should do.

This is a port of the following change from MySQL 5.7.23,
with a completely rewritten test case.

commit c58c6f8f66ddd0357ecd0c99646aa6bf1dae49c8
Author: Aakanksha Verma <aakanksha.verma@oracle.com>
Date:   Fri May 4 15:53:13 2018 +0530

Bug #27155294 MAX_EXECUTION_TIME NOT INTERUPTED WITH FULLTEXT SEARCH USING MECAB
2018-08-01 08:43:12 +03:00
Marko Mäkelä
87ec6a0448 Merge 10.0 into 10.1 2018-07-31 15:19:56 +03:00
Oleksandr Byelkin
865e807125 Merge branch '10.0' into 10.1 2018-07-31 11:58:29 +02:00
Marko Mäkelä
e52315a4a2 MDEV-16855 Fix fts_sync_synchronization in InnoDB
This is a backport of the following fix from MySQL 5.7.23.
Some code refactoring has been omitted, and the test case has
been adapted to MariaDB.

commit 7a689acaa65e9d602575f7aa53fe36a64a07460f
Author: Krzysztof Kapuścik <krzysztof.kapuscik@oracle.com>
Date:   Tue Mar 13 12:34:03 2018 +0100

Bug#27082268 Invalid FTS sync synchronization

The fix closes two issues:
Bug #27082268 - INNODB: FAILING ASSERTION: SYM_NODE->TABLE != NULL DURING FTS SYNC
Bug #27095935 - DEADLOCK BETWEEN FTS_DROP_INDEX AND FTS_OPTIMIZE_SYNC_TABLE

Both issues were related to a FTS cache sync being done during
operations that perfomed DDL actions on internal FTS tables
(ALTER TABLE, TRUNCATE). In some cases the FTS tables and/or
internal cache structures could get removed while still being
used to perform FTS synchronization leading to crashes. In other
the sync operations could not get finishes as it was waiting for
dict lock which was taken by thread waiting for the background
sync to be finished.

The changes done includes:
- Stopping background operations during ALTER TABLE and TRUNCATE.
- Removal of unused code in FTS.
- Cleanup of FTS sync related code to make it more readable and
easier to maintain.

RB#18262
2018-07-30 18:06:30 +03:00
mleich1
fd378fc613 MDEV-16809 Allow full redo logging for ALTER TABLE
Add the usual basic test for the variable innodb_log_optimize_ddl.

Signed-off-by: mleich1 <Matthias.Leich@mariadb.com>
2018-07-30 13:55:24 +02:00
Marko Mäkelä
8bdd125067 MDEV-16851 On schema mismatch in IMPORT TABLESPACE, display ROW_FORMAT in clear text
This is motivated by Oracle MySQL Bug #27542720 SCHEMA MISMATCH
- TABLE FLAGS DON'T MATCH, BUT FLAGS ARE NUMBERS
but using a different approach.

row_import::match_schema(): In case of a mismatch, display the
ROW_FORMAT and optionally KEY_BLOCK_SIZE of the .cfg file.
2018-07-30 13:13:43 +03:00
Jan Lindström
14306bcbec MDEV-16831: Galera test failure on galera_sst_mysqldump_with_key
Test case was not written correctly.
2018-07-27 10:05:26 +03:00
Julius Goryavsky
46d5e1f2fd MDEV-10754 wsrep_sst_rsync does not support innodb_data_home_dir
If innodb_data_home_dir path specified in the configuration file
then rsync IST/SST will fail because the wsrep_sst_rsync.sh script
does not read this parameter from the configuration file and then
tries to find the data files in the default directory.

To fix this error, we need to add reading of the innodb_data_home_dir
configuration parameter to the rsync-related SST script.
2018-07-26 15:44:28 +02:00
Marko Mäkelä
0f90728bc0 MDEV-16809 Allow full redo logging for ALTER TABLE
Introduce the configuration option innodb_log_optimize_ddl
for controlling whether native index creation or table-rebuild
in InnoDB should keep optimizing the redo log
(and writing MLOG_INDEX_LOAD records to ensure that
concurrent backup would fail).

By default, we have innodb_log_optimize_ddl=ON, that is,
the default behaviour that was introduced in MariaDB 10.2.2
(with the merge of InnoDB from MySQL 5.7) will be unchanged.

BtrBulk::m_trx: Replaces m_trx_id. We must be able to check for
KILL QUERY even if !m_flush_observer (innodb_log_optimize_ddl=OFF).

page_cur_insert_rec_write_log(): Declare globally, so that this
can be called from PageBulk::insert().

row_merge_insert_index_tuples(): Remove the unused parameter trx_id.

row_merge_build_indexes(): Enable or disable redo logging based on
the innodb_log_optimize_ddl parameter.

PageBulk::init(), PageBulk::insert(), PageBulk::finish(): Write
redo log records if needed. For ROW_FORMAT=COMPRESSED, redo log
will be written in PageBulk::compress() unless we called
m_mtr.set_log_mode(MTR_LOG_NO_REDO).
2018-07-26 08:44:42 +03:00
Oleksandr Byelkin
cb5952b506 Merge branch '10.0' into bb-10.1-merge-sanja 2018-07-25 22:24:40 +02:00
Thirunarayanan Balathandayuthapani
de85355436 MDEV-16713 Hangs server with repeating log entry
At most one transaction can be active at a time for temporary
tables. There is no need to check previous version of record for the
temporary tables.
2018-07-25 13:56:39 +05:30
Sachin
969939e89c MDEV-16821 Set password for user makes rpl test to fail
Actually if we use "set password for " command this changes the checksum
of mysql.user table
-localhost      root            Y       Y       Y       Y       Y       Y       Y       Y     YY       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y     $
Y       Y       Y       Y       Y       Y       Y                                       0     00       0                       N       N               0.000000
+localhost      root            Y       Y       Y       Y       Y       Y       Y       Y     YY       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y     Y
Y       Y       Y       Y       Y       Y       Y                                       0     00       0       mysql_native_password           N       N               0.000000
In short we replace '' with mysql_native_password
which make checksum to be different, and hence check test case fails.

So we use UPDATE mysql.user command.
2018-07-25 12:54:37 +05:30
Jan Lindström
57cde8ccd1 MDEV-15822: WSREP: BF lock wait long for trx
In Galera BF (brute force) transactions may not wait for lock requests
and normally BF-transaction would select transaction holding conflicting
locks as a victim for rollback. However, background statistic calculation
transaction is InnoDB internal transaction and it has no thd i.e. it can't be
selected as a victim. If background statistics calculation transaction holds
conflicting locks to statistics tables it will cause BF lock wait long
error message. Correct way to handle background statistics calculation is to
acquire thd for transaction but that change is too big for GA-releases and
there are other reported problems on background statistics calculation.

This fix avoids adding a table to background statistics calculation if
2018-07-25 08:24:09 +03:00
Oleksandr Byelkin
9fbe360e9f make plugins.processlist more robust 2018-07-24 18:29:17 +02:00
Oleksandr Byelkin
e0139c2b92 fix plugins.processlist
make it not to fail when `show engine innodb status` output
contains a double quote
2018-07-24 18:16:41 +02:00
Oleksandr Byelkin
a0d33dc6ef MDEV-16689: core-file should become a real server variable
Mysql Bug#56124 bug analog fix using Sys_var_bit.
2018-07-20 17:35:52 +02:00
Oleksandr Byelkin
0896d7ebc3 Merge branch '10.0' into bb-10.1-merge 2018-07-19 12:55:54 +02:00
Sergei Golubchik
d57ddaa190 MDEV-15551 Server hangs or assertion `strcmp(share->unique_file_name,filename) || share->last_version' fails in test_if_reopen or unexpected ER_LOCK_DEADLOCK
only use HA_EXTRA_PREPARE_FOR_DROP when the table is going to be dropped
2018-07-19 11:35:39 +02:00
Sachin
9827c5e103 MDEV-16192 Table 't' is specified twice, both as a target for 'CREATE' and...
as a separate source for data

Actually MDEV-15867 and MDEV-16192 are same, Slave adds "or replace" to create
table stmt. So create table t1 is create or replace on slave. So this bug
is not because of replication, We can get this bug on general server if we
manually add or replace to create query.

Problem:- So if we try to create table t1 (same name as of temp table t1 ) via
   CREATE or replace TABLE t AS SELECT * FROM t;
Since in this query we are creating table from select * from t1 , we call
unique_table function to see whether if source and destination table are same.
But there is one issue unique_table does not account if source table is tmp table
in this case source and destination table can be same.

Solution:- We will change find_dup_table to not to look for temp table if
CHECK_DUP_SKIP_TEMP_TABLE flag is on.
2018-07-18 20:58:59 +05:30
sachin
ada54101a7 MDEV-9266 Creating index on temporaray table breaks replication
Problem:- Create/drop index was logged into binlog.

Goal:- Operation on temporary table should not be binlog when binlog format
is row.

Solution:-
We should add CF_FORCE_ORIGINAL_BINLOG_FORMAT when there is ddl on temp
table.
For optimize, analyze, repair we wont change anything ,Then will
be logged in binlog , But they also dont throw any error if operation fails
Since slave wont be having any temp table , but these operation on tmp
table will be processed without breaking replication.

For rename we need a different logic MDEV-16728 will solve it.
2018-07-18 17:13:24 +05:30
Oleksandr Byelkin
e5c26fdfab Merge branch '5.5' into bb-10.0-merge 2018-07-17 16:56:21 +02:00
Marko Mäkelä
1cc1d0429d MDEV-16664: Change the default to innodb_lock_schedule_algorithm=fcfs
The parameter innodb_lock_schedule_algorithm was introduced in
MariaDB Server 10.1.19, 10.2.13, 10.3.4 as part of MDEV-11039.
In MariaDB 10.1, the default value of the parameter is 'fcfs',
that is, the existing algorithm is used by default. But in
later versions of MariaDB Server, the parameter was 'vats',
enabling the new algorithm.

Because the new algorithm is triggering a debug assertion failure
that suggests corruption of the transactional lock data structures,
we will revert to the old algorithm by default until we have
resolved the problem.
2018-07-07 11:34:26 +03:00
Thirunarayanan Balathandayuthapani
8b0d4cff07 MDEV-15855 Deadlock between purge thread and DDL statement
Problem:
========
Truncate operation holds MDL on the table (t1) and tries to
acquire InnoDB dict_operation_lock. Purge holds dict_operation_lock
and tries to acquire MDL on the table (t1) to evaluate virtual
column expressions for indexed virtual columns.
It leads to deadlock of purge and truncate table (DDL).

Solution:
=========
If purge tries to acquire MDL on the table then it should do the following:

i) Purge should release all innodb latches (including dict_operation_lock)
before acquiring metadata lock on the table.

ii) After acquiring metadata lock on the table, it should check whether the
table was dropped or renamed. If the table is dropped then purge should
ignore the undo log record. If the table is renamed then it should
release the old MDL and acquire MDL on the new name.

iii) Once purge acquires MDL, it should use the SQL table handle for all
the remaining virtual index for the purge record.

purge_node_t: Introduce new virtual column information to know whether
the MDL was acquired successfully.

This is joint work with Marko Mäkelä.
2018-07-06 17:13:53 +03:00
Marko Mäkelä
e3207b6c13 MDEV-14188 mariabackup.incremental_encrypted wrong result
Add an explicit redo log flush. In this test
innodb_flush_log_at_trx_commit was 2 by default.
It is also possible that this failure occurs because of MDEV-15740.
2018-07-06 09:07:52 +03:00
Marko Mäkelä
fdb9e66fee Implement a parameter for wait_all_purged.inc 2018-07-05 15:47:13 +03:00
Vladislav Vaintroub
400cf01715 MDEV-16571 - some backup tests sometimes with missing data after restore.
Marko mentions, it could be caused by  MDEV-15740 where InnoDB does not
flush redo log as often as it should, with innodb_flush_log_at_trx_commit=1

The workaround is to use innodb_flush_log_at_trx_commit=2, which,
according to MDEV-15740 is more durable.
2018-07-02 18:06:10 +01:00
Sergei Golubchik
1dd3c8f8ba Merge branch '10.1' into 10.2 2018-06-28 22:46:12 +02:00
Sergei Golubchik
16c14d7ba0 mark ed25519 stable 2018-06-28 15:46:57 +02:00
Sergei Golubchik
78a0646fe4 make plugins.processlist more robust 2018-06-28 12:38:58 +02:00
Marko Mäkelä
31c950cca8 Merge 10.1 into 10.2 2018-06-26 18:16:49 +03:00
Marko Mäkelä
c6392d52ee Merge 10.0 into 10.1 2018-06-26 17:34:44 +03:00
Marko Mäkelä
cc8772f33e MDEV-15953 Alter InnoDB Partitioned Table ignores pre-existing DATA DIRECTORY attribute 2018-06-26 17:02:46 +03:00
Eugene Kosov
ff8b3c8df8 MDEV-15953 Alter InnoDB Partitioned Table Moves Files (which were originally not in the datadir) to the datadir
ha_innobase::prepare_inplace_alter_table: preserve DATA DICTIONARY for table
2018-06-26 11:11:15 +03:00
Alexander Barkov
90e608c6ac A test cleanup for MDEV-15834: fixing failure in "mtr --embedded" 2018-06-26 11:43:14 +04:00
Sergei Golubchik
b2190f859b fix vcol.vcol_misc --embedded 2018-06-24 15:18:36 +02:00
Sergei Golubchik
e561a346c3 fix mtr warnings after 5f0510225a 2018-06-24 15:18:36 +02:00
Vladislav Vaintroub
ecc4682672 MDEV-16519 : mariabackup should fail if MDL could not be acquired with lock-ddl-per-table
There is a tiny chance for race condition during MDL acquisition.

If table is renamed just prior to
SELECT 1 FROM <table_name> LIMIT 0

then this query would  fail, yet mariabackup --backup does not handle
it as fatal error and continues, only to fail later during file copy.

The fix is to die on error, of MDL lock query fails.
2018-06-22 15:24:09 +01:00
Sergei Golubchik
0d745343fc fix plugins.processlist
make it not to fail when `show engine innodb status` output
contains a double quote
2018-06-22 09:52:21 +02:00
Sergei Golubchik
b942aa34c1 Merge branch '10.1' into 10.2 2018-06-21 23:47:39 +02:00
Sergei Golubchik
5f0510225a MDEV-16238 root/localhost authn prioritizes authentication_string over Password
Don't let SET PASSWORD to set the password, if auth_string is set.

Now SET PASSWORD always sets the plugin/auth_string fields and clears
the password field (on pre-plugin mysql.user table it works as before).
2018-06-21 10:15:27 +02:00
Sergei Golubchik
c09a8b5b36 Merge branch '10.0' into 10.1 2018-06-21 08:34:35 +02:00
Sergei Golubchik
d8192f5495 Merge branch '5.5' into 10.0 2018-06-21 00:44:10 +02:00
Sergei Golubchik
2b8f2b3e88 Fix unit suite on Windows and in out-of-source builds 2018-06-21 00:06:15 +02:00
Sergei Golubchik
0a9d78f51d Revert "MDEV-16075: Workaround to run MTR test suite for make test"
This reverts commit d39629f01e.

Because running mtr for many hours with no output whatsoever
is not really what we should do.

And in 5.5 `make test` just works anyway, nothing to fix here.
2018-06-20 23:27:23 +02:00
Alexey Botchkov
621caad3ca MDEV-11917 enum/set command-line options aren't respecting max-*
settings.
2018-06-20 17:14:04 +04:00
Alexander Barkov
4b821e02f6 Merge remote-tracking branch 'origin/10.0' into 10.1 2018-06-20 16:57:21 +04:00
Alexander Barkov
6c08ff3eb7 Merge remote-tracking branch 'origin/5.5' into 10.0 2018-06-20 16:55:24 +04:00
Alexander Barkov
170b43c156 MDEV-16534 PPC64: Unexpected error with a negative value into auto-increment columns in HEAP, MyISAM, ARIA 2018-06-20 16:36:46 +04:00
Sergei Golubchik
bb24663f5a MDEV-13577 slave_parallel_mode=optimistic should not report the mode's specific temporary errors
Revert 7bbe324fc1
Fix the bug differently (in log_event.cc)
Fix the test case to actually fail without the bug fix
2018-06-20 11:10:27 +02:00
Monty
10d09a57f8 Fixed failing test acl_load_mutex-5170
Added flush tables to ensure that MyISAM tables are
properly flushed before reboot
2018-06-19 16:23:34 +03:00
Monty
ab19466656 MDEV-15114 ASAN heap-use-after-free in mem_heap_dup or dfield_data_is_binary_equal
The bug was that innobase_get_computed_value() trashed record[0] and data
in Field_blob::value

Fixed by using a record on the heap for innobase_get_computed_value()

Reviewer: Marko Mäkelä
2018-06-19 16:23:34 +03:00
Monty
831df10981 Add PART_INDIRECT_KEY_FLAG
This is to mark that a field is indirectly part of a key, which simplifes
checking if we need to have this field up to date to evaluate a key.

For example:
CREATE TABLE t1 (a int, b int as (a) virtual,
                 c int as (b) virtual, index(c))
would mark a and b with PART_INDIRECT_KEY_FLAG.
c is marked with PART_KEY_FLAG as before.
2018-06-19 16:23:34 +03:00
Alexander Barkov
f5b128dfad Merge remote-tracking branch 'origin/10.0' into 10.1 2018-06-19 14:04:53 +04:00
Alexander Barkov
c450f7d8d5 Merge remote-tracking branch 'origin/5.5' into 10.0 2018-06-19 14:03:41 +04:00
Alexander Barkov
15b92915ed MDEV-15834 The code in TABLE_SHARE::init_from_binary_frm_image() is not safe 2018-06-19 13:02:02 +04:00
Thirunarayanan Balathandayuthapani
eb77f8cf8d MDEV-16087 Inconsistent SELECT results when query cache is enabled
The following conditions will decide the query cache retrieval or
storing inside innodb:

    (1) There should not be any locks on the table.
    (2) Some other trx shouldn't invalidated the cache before the
    transaction started.
    (3) Read view shouldn't exist. If exists then the view
    low_limit_id should be greater than or equal to the transaction that
    invalidates the cache for the particular table.

 For read-only transaction: should satisfy  the above (1) and (3)
 For read-write transaction: should satisfy the above (1), (2), (3).

 - Changed the variable from query_cache_inv_id to query_cache_inv_trx_id.

 - Moved the function row_search_check_if_query_cache_permitted from
    row0sel.h and made it as static function in ha_innodb.cc
2018-06-18 14:26:37 +05:30
Sergei Golubchik
7fdb7d4058 more sst test failures
* xtrabackup no longer support --compact
* wsrep_sst_mysqldump wasn't always using --default-file
* wsrep_sst.cc overquoted --default-file for wsrep_sst_mysqldump

also remove redundant lines config and test lines, compiler warnings,
and mark big tests as big.
2018-06-15 22:32:07 +02:00
Marko Mäkelä
b8514c94f6 MDEV-16496 Mariabackup: Implement --verbose option to instrument InnoDB log apply
srv_print_verbose_log: Introduce the value 2 to refer to
mariabackup --verbose.

recv_recover_page(), recv_parse_log_recs(): Add output for
mariabackup --verbose.
2018-06-15 16:14:12 +03:00
Jan Lindström
c69357d8d4 MDEV-15611 Due to the failure of foreign key detection, Galera slave node killed himself.
Merge following change from 10.2

revision-id: d52cff9f10aeea208a1058f7b5527e602125584c (mariadb-10.2.14-25-gd52cff9)
parent(s): bc2501453c
author: Sachin Setiya
committer: Sachin Setiya
timestamp: 2018-04-04 12:26:06 +0530
message:

MDEV-15611 Due to the failure of foreign key detection, Galera...
slave node killed himself.

Problem:- If we try to delete table with foreign key and table whom it is
referring with wsrep_slave_threads>1 then galera tries to execute both
Delete_rows_log-event in parallel, which should not happen.

Solution:- This is happening because we do not have foreign key info in
write set. Upto version 10.2.7 it used to work fine. Actually it happening
because of issue in commit 2f342c4. wsrep_must_process_fk should be used
with negation.
2018-06-15 09:04:26 +03:00
Sergei Golubchik
5d6b7f46fb Merge branch '10.0' into 10.1 2018-06-14 18:06:08 +02:00
Marko Mäkelä
2ca904f0ca MDEV-13103 Deal with page_compressed page corruption
fil_page_decompress(): Replaces fil_decompress_page().
Allow the caller detect errors. Remove
duplicated code. Use the "safe" instead of "fast" variants of
decompression routines.

fil_page_compress(): Replaces fil_compress_page().
The length of the input buffer always was srv_page_size (innodb_page_size).
Remove printouts, and remove the fil_space_t* parameter.

buf_tmp_buffer_t::reserved: Make private; the accessors acquire()
and release() will use atomic memory access.

buf_pool_reserve_tmp_slot(): Make static. Remove the second parameter.
Do not acquire any mutex. Remove the allocation of the buffers.

buf_tmp_reserve_crypt_buf(), buf_tmp_reserve_compression_buf():
Refactored away from buf_pool_reserve_tmp_slot().

buf_page_decrypt_after_read(): Make static, and simplify the logic.
Use the encryption buffer also for decompressing.

buf_page_io_complete(), buf_dblwr_process(): Check more failures.

fil_space_encrypt(): Simplify the debug checks.

fil_space_t::printed_compression_failure: Remove.

fil_get_compression_alg_name(): Remove.

fil_iterate(): Allocate a buffer for compression and decompression
only once, instead of allocating and freeing it for every page
that uses compression, during IMPORT TABLESPACE. Also, validate the
page checksum before decryption, and reduce the scope of some variables.

fil_page_is_index_page(), fil_page_is_lzo_compressed(): Remove (unused).

AbstractCallback::operator()(): Remove the parameter 'offset'.
The check for it in FetchIndexRootPages::operator() was basically
redundant and dead code since the previous refactoring.
2018-06-14 14:23:01 +03:00
Marko Mäkelä
f5eb37129f MDEV-13103 Deal with page_compressed page corruption
fil_page_decompress(): Replaces fil_decompress_page().
Allow the caller detect errors. Remove
duplicated code. Use the "safe" instead of "fast" variants of
decompression routines.

fil_page_compress(): Replaces fil_compress_page().
The length of the input buffer always was srv_page_size (innodb_page_size).
Remove printouts, and remove the fil_space_t* parameter.

buf_tmp_buffer_t::reserved: Make private; the accessors acquire()
and release() will use atomic memory access.

buf_pool_reserve_tmp_slot(): Make static. Remove the second parameter.
Do not acquire any mutex. Remove the allocation of the buffers.

buf_tmp_reserve_crypt_buf(), buf_tmp_reserve_compression_buf():
Refactored away from buf_pool_reserve_tmp_slot().

buf_page_decrypt_after_read(): Make static, and simplify the logic.
Use the encryption buffer also for decompressing.

buf_page_io_complete(), buf_dblwr_process(): Check more failures.

fil_space_encrypt(): Simplify the debug checks.

fil_space_t::printed_compression_failure: Remove.

fil_get_compression_alg_name(): Remove.

fil_iterate(): Allocate a buffer for compression and decompression
only once, instead of allocating and freeing it for every page
that uses compression, during IMPORT TABLESPACE.

fil_node_get_space_id(), fil_page_is_index_page(),
fil_page_is_lzo_compressed(): Remove (unused code).
2018-06-14 13:46:07 +03:00
Alexander Barkov
2cdb483bc4 MDEV-15352 AUTO_INCREMENT breaks after updating a column value to a negative number 2018-06-14 13:13:23 +04:00
Sergei Golubchik
51254da52c MDEV-15359 Thread stay in "cleaning up" status after finishing
make thd_get_error_context_description() to show not just
thd->proc_info, but exactly the same thread state that SHOW PROCESSLIST
shows.
2018-06-13 20:26:51 +02:00
Marko Mäkelä
72005b7a1c MDEV-13103: Improve 'cannot be decrypted' error message
buf_page_check_corrupt(): Display the file name.
2018-06-13 16:02:40 +03:00
Vicențiu Ciorbaru
cec2219cc5 Merge branch '10.0' into 10.1
Pull rename_table test-fix from 10.0
2018-06-13 08:36:44 +03:00
Vicențiu Ciorbaru
d2e1ed8b93 Fix innodb.rename_table for embedded
An embedded run will output the full path name instead of a relative
one. Update results to cover both cases.
2018-06-13 08:33:25 +03:00
Vicențiu Ciorbaru
6e55236c0a Merge branch '10.0-galera' into 10.1 2018-06-12 19:39:37 +03:00
Vicențiu Ciorbaru
aa59ecec89 Merge branch '10.0' into 10.1 2018-06-12 18:55:27 +03:00
Vicențiu Ciorbaru
170bec36c0 Merge branch '5.5' into 10.0 2018-06-12 17:59:31 +03:00
Andrei Elkin
7bbe324fc1 MDEV-13577 slave_parallel_mode=optimistic should not report the mode's
specific temporary errors

The optimistic parallel slave's worker thread could face a run-time error due to
the algorithm's specifics which allows for conflicts like the reported
"Can't find record in 'table'".
A typical stack is like

{noformat}
#0  handler::print_error (this=0x61c00008f8a0, error=149, errflag=0) at handler.cc:3650
#1  0x0000555555e95361 in write_record (thd=thd@entry=0x62a0000a2208, table=table@entry=0x61f00008ce88, info=info@entry=0x7fffdee356d0) at sql_insert.cc:1944
#2  0x0000555555ea7767 in mysql_insert (thd=thd@entry=0x62a0000a2208, table_list=0x61b00012ada0, fields=..., values_list=..., update_fields=..., update_values=..., duplic=<optimized out>, ignore=<optimized out>) at sql_insert.cc:1039
#3  0x0000555555efda90 in mysql_execute_command (thd=thd@entry=0x62a0000a2208) at sql_parse.cc:3927
#4  0x0000555555f0cc50 in mysql_parse (thd=0x62a0000a2208, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>) at sql_parse.cc:7449
#5  0x00005555566d4444 in Query_log_event::do_apply_event (this=0x61200005b9c8, rgi=<optimized out>, query_arg=<optimized out>, q_len_arg=<optimized out>) at log_event.cc:4508
#6  0x00005555566d639e in Query_log_event::do_apply_event (this=<optimized out>, rgi=<optimized out>) at log_event.cc:4185
#7  0x0000555555d738cf in Log_event::apply_event (rgi=0x61d0001ea080, this=0x61200005b9c8) at log_event.h:1343
#8  apply_event_and_update_pos_apply (ev=ev@entry=0x61200005b9c8, thd=thd@entry=0x62a0000a2208, rgi=rgi@entry=0x61d0001ea080, reason=<optimized out>) at slave.cc:3479
#9  0x0000555555d8596b in apply_event_and_update_pos_for_parallel (ev=ev@entry=0x61200005b9c8, thd=thd@entry=0x62a0000a2208, rgi=rgi@entry=0x61d0001ea080) at slave.cc:3623
#10 0x00005555562aca83 in rpt_handle_event (qev=qev@entry=0x6190000fa088, rpt=rpt@entry=0x62200002bd68) at rpl_parallel.cc:50
#11 0x00005555562bd04e in handle_rpl_parallel_thread (arg=arg@entry=0x62200002bd68) at rpl_parallel.cc:1258
{noformat}

Here {{handler::print_error}} computes whether to error log the
current error when --log-warnings > 1. The decision flag is consulted
bu {{my_message_sql()}} which can be eventually called.
In the bug case the decision is to log.
However in the optimistic mode slave applier case any conflict is
attempted to resolve with rollback and retry to success. Hence the
logging is at least extraneous.

The case is fixed with adding a new flag {{ME_LOG_AS_WARN}} which
{{handler::print_error}} may propagate further on through {{my_error}}
when the error comes from an optimistically running slave worker thread.

The new flag effectively requests the warning level for the errlog record,
while the thread's DA records the actual error (which is regarded as temporary one
by the parallel slave error handler).
2018-06-12 15:29:16 +03:00
Marko Mäkelä
8f5f0575ab MDEV-16456 InnoDB error "returned OS error 71" complains about wrong path
When attempting to rename a table to a non-existing database,
InnoDB would misleadingly report "OS error 71" when in fact the
error code is InnoDB's own (OS_FILE_NOT_FOUND), and not report
both pathnames. Errors on rename could occur due to reasons
connected to either pathname.

os_file_handle_rename_error(): New function, to report errors in
renaming files.
2018-06-12 10:25:23 +03:00
Marko Mäkelä
0ad9c3a016 MDEV-16456 InnoDB error "returned OS error 71" complains about wrong path
When attempting to rename a table to a non-existing database,
InnoDB would misleadingly report "OS error 71" when in fact the
error code is InnoDB's own (OS_FILE_NOT_FOUND), and not report
both pathnames. Errors on rename could occur due to reasons
connected to either pathname.

os_file_handle_rename_error(): New function, to report errors in
renaming files.
2018-06-12 09:54:31 +03:00
Sergei Golubchik
ca733d03c8 MDEV-15729 Server crashes in Field::make_field upon HANDLER READ executed with PS protocol
update table->pos_in_table_list during prepare,
just like it's done in normal execution.

otherwise it'll be a dangling pointer
2018-06-11 09:57:54 +02:00
Sergei Golubchik
6da8192174 mysqltest: Allow HANDLER READ in --ps-protocol tests
adjust tests
2018-06-11 09:57:54 +02:00
Sergei Golubchik
e7ca377cb7 MDEV-16342 SHOW ENGINES: MyISAM description is useless
rewrite tautological engine descriptions
2018-06-11 09:57:54 +02:00
Vicențiu Ciorbaru
3ead951180 Merge branch '5.5' into 10.0 2018-06-10 17:16:27 +03:00
Teodor Mircea Ionita
d39629f01e MDEV-16075: Workaround to run MTR test suite for make test
Assign all tests added via MY_ADD_TEST to a bogus default_ignore target,
so that they are not ran by default when doing bare make test. Add default
test named MTR that calls mysql-test-run suite, which is now the single
test run by make test.

In consequence, modified unit/suite.pm to exclude the MTR test and run the
real ctests flagged for default_ignore target, thus no circular
loop.
2018-06-10 10:14:31 +03:00
Vladislav Vaintroub
aba2d7301f MDEV-13122 Backup myrocksdb with mariabackup. 2018-06-07 15:13:54 +01:00
Marko Mäkelä
3627dd7f6a MDEV-16416 Crash on IMPORT TABLESPACE of a ROW_FORMAT=COMPRESSED table
fil_iterate(): Invoke fil_encrypt_buf() correctly when
a ROW_FORMAT=COMPRESSED table with a physical page size of
innodb_page_size is being imported. Also, validate the page checksum
before decryption, and reduce the scope of some variables.

AbstractCallback::operator()(): Remove the parameter 'offset'.
The check for it in FetchIndexRootPages::operator() was basically
redundant and dead code since the previous refactoring.
2018-06-07 10:34:32 +03:00
Marko Mäkelä
df42830b28 Merge 10.1 into 10.2 2018-06-06 11:25:33 +03:00
Marko Mäkelä
3b7da8a44c MDEV-15824 innodb_defragment=ON trumps innodb_optimize_fulltext_only=ON in OPTIMIZE TABLE
ha_innobase::optimize(): If both innodb_defragment and
innodb_optimize_fulltext_only are at their default settings (OFF),
fall back to ALTER TABLE. Else process one or both options.
2018-06-05 11:39:47 +03:00
Marko Mäkelä
f6376bfd1c Add FLUSH TABLES to avoid corruption of MyISAM system tables 2018-06-05 11:39:47 +03:00
Marko Mäkelä
8dc70c862b MDEV-16376 ASAN: heap-use-after-free in gcol.innodb_virtual_debug
After a failed ADD INDEX, dict_index_remove_from_cache_low()
could iterate the index fields and dereference a freed virtual
column object when trying to remove the index from the v_indexes
of the virtual column.

This regression was caused by a merge of
MDEV-16119 InnoDB lock->index refers to a freed object.

ha_innobase_inplace_ctx::clear_added_indexes(): Detach the
indexes of uncommitted indexes from virtual columns, so that
the iteration in dict_index_remove_from_cache_low() can be avoided.

ha_innobase::prepare_inplace_alter_table(): Ignore uncommitted
corrupted indexes when rejecting ALTER TABLE. (This minor bug was
revealed by the extension of the test case.)

dict_index_t::detach_columns(): Detach an index from virtual columns.
Invoked by both dict_index_remove_from_cache_low() and
ha_innobase_inplace_ctx::clear_added_indexes().

dict_col_t::detach(const dict_index_t& index): Detach an index from
a column.

dict_col_t::is_virtual(): Replaces dict_col_is_virtual().

dict_index_t::has_virtual(): Replaces dict_index_has_virtual().
2018-06-04 15:55:37 +03:00
Marko Mäkelä
6f96ff7268 Allow tests to work with cmake -DPLUGIN_PARTITION=NO 2018-05-29 17:14:34 +03:00
Marko Mäkelä
7269c70821 Add an end-marker to ease future merges 2018-05-29 16:52:59 +03:00
Marko Mäkelä
18934fb583 Merge 10.1 into 10.2 2018-05-29 16:52:12 +03:00
Marko Mäkelä
35a9c90fff MDEV-14589 InnoDB should not lock a delete-marked record
When the transaction isolation level is SERIALIZABLE, or when
a locking read is performed in the REPEATABLE READ isolation level,
InnoDB must lock delete-marked records in order to prevent another
transaction from inserting something.

However, at READ UNCOMMITTED or READ COMMITTED isolation level or
when the parameter innodb_locks_unsafe_for_binlog is set, the
repeatability of the reads does not matter, and there is no need
to lock any records.

row_search_for_mysql(): Skip locks on delete-marked committed records
upfront, instead of invoking row_unlock_for_mysql() afterwards.
The unlocking never worked for secondary index records.
2018-05-29 08:54:33 +03:00
Monty
2d62a4cb2f Updated results for galera_encrypt_tmp_files 2018-05-26 17:01:42 +03:00
Monty
d8da920264 MDEV-10679 Crash in performance schema and partitioning with discovery
Crash happened because in discover, table->work_part_info was not properly
reset before execution.
Fixed by resetting before calling execute alter table, create table or
mysql_create_frm_image.
2018-05-26 12:49:25 +03:00
Monty
494c981d23 Merge remote-tracking branch 'origin/10.1' into 10.2 2018-05-24 18:57:52 +03:00
Monty
4cd2a0eb56 MDEV-15243 Crash with virtual fields and row based binary logging
The cause of this was several different bugs:

- When using binary logging with binlog_row_image=FULL
  the all bits in read_set was set, which caused a
  different (wrong) pattern for marking vcol_set.
- TABLE::mark_virtual_columns_for_write() didn't in all
  cases mark vcol_set with the vcol_field.
- TABLE::update_virtual_fields() has to update all
  vcol fields on REPLACE if binary logging with FULL
  is used.
- VCOL_UPDATE_INDEXED should update all vcol fields part
  of an index that was not updated by VCOL_UPDATE_FOR_READ
- max_row_length() calculated length of NULL and not
  used fields. This didn't cause any crash, but used
  more memory than needed.
2018-05-24 18:55:12 +03:00
Marko Mäkelä
bfed1bfe28 Add a missing dependency to a test 2018-05-24 11:55:27 +03:00
Monty
e744c687ca Merge remote-tracking branch 'origin/10.0' into 10.1 2018-05-24 11:08:02 +03:00
Monty
da71c1bad7 MDEV-16229 Replication aborts with ER_VIEW_SELECT_TMPTABLE after half-failed RENAME
Problem was that detection of temporary tables was all wrong for
RENAME TABLE.
(Temporary tables where opened by top level call to
open_temporary_tables(), which can't detect if a temporary table
was renamed to something and then reused).

Fixed by adding proper parsing of rename list to check against
the current name of a table at each rename stage.
Also change do_rename_temporary() to check against the current
state of temporary tables, not according to the state of start
of RENAME TABLE.
2018-05-22 23:05:48 +03:00
Monty
2f3779d31c Fixes for Aria transaction handling with lock tables
MDEV-10130 Assertion `share->in_trans == 0' failed in storage/maria/ma_close.c
MDEV-10378 Assertion `trn' failed in virtual int ha_maria::start_stmt

The problem was that maria_handler->trn was not properly reset
at commit/rollback and ha_maria::exernal_lock() could get confused
because.

There was some old code in ha_maria::implicit_commit() that tried
to take care of this, but it was not bullet proof.

Fixed by adding list of all tables that is part of the maria transaction to
TRN.

A nice side effect was of the fix is that loops in
ha_maria::implict_commit() got to be much simpler.

Other things:
- Fixed a bug in mysql_admin_table() where argument open_for_modify
  was wrongly reset for the next table in the chain
- rollback admin command also in case of fatal error.
- Split _ma_set_trn_for_table() to three version to simplify code
  and debugging.
- Several new asserts to detect the original problem (that file was
  not properly removed from trn before calling ma_close())
2018-05-22 23:05:48 +03:00
sachin
5797cbaf4a MDEV-10259 mysqld crash with certain statement length and...
order with Galera and encrypt-tmp-files=1

Problem:- If trans_cache (IO_CACHE) uses encrypted tmp file
then on next DML server will crash.

Case:-
 Lets take a case , we have a table t1 , We try to do 2 inserts in t1
  1. A really long insert so that trans_cache has to use temp_file
  2. Just a small insert

Analysis:- Actually server crashes from inside of galera
library.
/lib64/libc.so.6(abort+0x175)[0x7fb5ba779dc5]
/usr/lib64/galera/libgalera_smm.so(_ZN6galera3FSMINS_9TrxHandle5State...
mysys/stacktrace.c:247(my_print_stacktrace)[0x7fb5a714940e]
sql/signal_handler.cc:160(handle_fatal_signal)[0x7fb5a715c1bd]
sql/wsrep_hton.cc:257(wsrep_rollback)[0x7fb5bcce923a]
sql/wsrep_hton.cc:268(wsrep_rollback)[0x7fb5bcce9368]
sql/handler.cc:1658(ha_rollback_trans(THD*, bool))[0x7fb5bcd4f41a]
sql/handler.cc:1483(ha_commit_trans(THD*, bool))[0x7fb5bcd4f804]

but actual issue is not in galera but in mariadb, because for 2nd
insert we should never call rollback. We are calling rollback because
log_and_order fails it fails because write_cache fails , It fails
because after reinit_io_cache(trans_cache) , my_b_bytes_in_cache says 0
so we look into tmp_file for data , which is obviously wrong since temp
was used for previous insert and it no longer exist.
wsrep_write_cache_inc() reads the IO_CACHE in a loop, filling it with
my_b_fill() until it returns "0 bytes read". Later
MYSQL_BIN_LOG::write_cache() does the same.  wsrep_write_cache_inc()
assumes that reading a zero bytes past EOF leaves the old data in the
cache

Solution:- There is two issue in my_b_encr_read
1st we should never equal read_end to info->buffer. I mean this
does not make sense read_end should always point to end of buffer.
2nd For most of the case(apart from async IO_CACHE) info->pos_in_file
should be equal to info->buffer position wrt to temp file , since
in this case we are not changing info->buffer it should remain
unchanged.
2018-05-22 13:47:42 +05:30
Sergei Golubchik
ff1d10ef9c Merge branch '10.1' into 10.2 2018-05-20 20:25:35 +02:00
Sergei Golubchik
91dfb6141f Merge branch '10.0' into 10.1 2018-05-19 22:05:55 +02:00
Sergei Golubchik
c1b5d2801e Merge branch '5.5' into 10.0 2018-05-19 15:38:34 +02:00
Monty
d703e09cd6 Fix that FLUSH TABLES FOR EXPORT also works for Aria tables.
- Added missing test case for MyISAM
2018-05-16 15:34:27 +03:00
Shaohua Wang
a54b581d03 BUG#22385442 - INNODB: DIFFICULT TO FIND FREE BLOCKS IN THE BUFFER POOL
Problem:
We keep pinning pages in dict_stats_analyze_index_below_cur(),
but doesn't release these pages. When we have a relative small
buffer pool size, and big innodb_stats_persistent_sample_pages,
there will be no free pages for use.

Solution:
Use a separate mtr in dict_stats_analyze_index_below_cur(),
and commit mtr before return.

Reviewed-by: Jimmy Yang <jimmy.yang@oracle.com>
RB: 11362
2018-05-16 15:03:09 +05:30
Thirunarayanan Balathandayuthapani
64d6a65ab2 - Adjusted the test case for MariaDB 2018-05-16 15:03:09 +05:30
Marko Mäkelä
0ba299da02 Bug#21628087 innodb_log_checkpoint_now not fully compatible with WL#7142
In debug builds of MySQL, there is an configuration variable
that allows an InnoDB log checkpoint to be initiated:

SET GLOBAL innodb_log_checkpoint_now=ON;

Setting this variable while a table-rebuilding ALTER TABLE is executing
may result in an infinite loop.

checkpoint_now_set(): Account for log_sys->append_on_checkpoint->size().
Note that this function contains race conditions, because it is accessing
fields of log_sys without holding log_sys->mutex. We think that this is
acceptable, because this variable only exists for debugging purposes, in
debug builds of MySQL.

RB: 9947
Reviewed-by: Sunny Bains <sunny.bains@oracle.com>
2018-05-16 15:03:09 +05:30
Thirunarayanan Balathandayuthapani
be465cfb8c Move the test case from innodb.alter_page_size
to innodb.innodb-online-alter-gis
2018-05-16 15:03:09 +05:30
Annamalai Gurusami
21e02b2c92 Bug #19077964 ASSERT PAGE_SIZE.EQUALS_TO SPACE_PAGE_SIZE BTR_COPY_BLOB_PREFIX
Problem:

The function row_build_index_entry_low() takes a dtuple_t object ('row') and
dict_index_t object ('index') as input and returns a new dtuple_t object
('entry') as output.  The dtuple_t object 'row' that is given as input might
have been constructed from a different dict_index_t object (!= index).  So
when accessing the externally stored data of the given 'row' we need to make
use of the correct index object.

Solution:

Store the page size information in the associated row_ext_t object.

rb#6086 approved by Vasil and Jimmy.
2018-05-16 15:03:09 +05:30
Thirunarayanan Balathandayuthapani
6e76b402d4 Adjust the alter_foreign_crash test case for MariaDB 2018-05-16 15:03:09 +05:30
Annamalai Gurusami
a1f392a944 Bug #20476395 DICT_LOAD_FOREIGNS() FAILED IN COMMIT_INPLACE_ALTER_TABLE
Problem:

Suppose there are two tables in the database related through a foreign key
constraint - the parent table and the child table.  Suppose there is an ALTER
TABLE on the child table which gets interrupted in such a way that the child
table is not available any more.

After crash recovery, an ALTER TABLE on the parent table identifies that its
foreign keys cannot be loaded.  This results in an error and a debug assert.

Solution:

Remove the debug assert and change error to a warning.

rb#8658 approved by Marko.
2018-05-16 15:03:09 +05:30
Thirunarayanan Balathandayuthapani
91659983eb Adjust the tests for MariaDB.
New added test case: alter_kill in innodb suite.
2018-05-16 15:03:09 +05:30
Marko Mäkelä
ac2410f6d8 Bug#19330255 WL#7142 - CRASH DURING ALTER TABLE LEADS TO DATA DICTIONARY INCONSISTENCY
The server crashes on a SELECT because of space id mismatch. The
mismatch happens if the server crashes during an ALTER TABLE.

There are actually two cases of inconsistency, and three fixes needed
for the InnoDB problems.

We have dictionary data (tablespace or table name) in 3 places:

(a) The *.frm file is for the old table definition.
(b) The InnoDB data dictionary is for the new table definition.
(c) The file system did not rename the tablespace files yet.

In this fix, we will not care if the *.frm file is in sync with the
InnoDB data dictionary and file system. We will concentrate on the
mismatch between (b) and (c).

Two scenarios have been mentioned in this bug report. The simpler one
first:

1. The changes to SYS_TABLES were committed, and MLOG_FILE_RENAME2
records were written in a single mini-transaction commit.
The files were not yet renamed in the file system.
2a. The server is killed, without making a log checkpoint.
3a. The server refuses to start up, because replaying MLOG_FILE_RENAME2
fails.

I failed to repeat this myself. I repeated step 3a with a saved
dataset. The problem seems to be that MLOG_FILE_RENAME2 replay is
incorrectly being skipped when there is no page-redo log or
MLOG_FILE_NAME record for the old name of the tablespace.

FIX#1: Recover the id-to-name mapping also from MLOG_FILE_RENAME2
records when scanning the redo log. It is not necessary to write
MLOG_FILE_NAME records in addition to MLOG_FILE_RENAME2 records for
renaming tablespace files.

The scenario in the original Description involves a log checkpoint:
1. The changes to SYS_TABLES were committed, and MLOG_FILE_RENAME2
records were written in a single mini-transaction commit.
2. A log checkpoint and a server kill was injected.
3. Crash recovery will see no records (other than the MLOG_CHECKPOINT).
4. dict_check_tablespaces_and_store_max_id() will emit a message about
a non-found table #sql-ib22*.
5. A mismatch is triggering the assertion failure.

In my test, at step 4 the SYS_TABLES root page (0:8) contains these 3
records right before the page supremum:
* delete-marked (committed) name=#sql-ib21* record, with space=10.
* name=#sql-ib22*, space=9.
* name=t1, space=10.
space=10 is the rebuilt table (#sql-ib21*.ibd in the file system).
space=9 is the old table (t1.ibd in the file system).

The function dict_check_tablespaces_and_store_max_id() will enter
t1.ibd with space_id=10 into the fil_system cache without noticing
that t1.ibd contains space_id=9, because it invokes
fil_open_single_table_tablespace() with validate=false.

In MySQL 5.6, the space_id from all *.ibd files are being read when
the redo log checkpoint LSN disagrees with the FIL_PAGE_FILE_FLUSH_LSN
in the system tablespace. This field is only updated during a clean
shutdown, after performing the final log checkpoint.

FIX#2: dict_check_tablespaces_and_store_max_id() should pass
validate=true to fil_open_single_table_tablespace() when a non-clean
shutdown is detected, forcing the first page of each *.ibd file to be
read. (We do not want to slow down startup after a normal shutdown.)

With FIX#2, the SELECT would fail to find the table. This would
introduce a regression, because before WL#7142, a copy of the table
was accessible after recovery.

FIX#3: Maintain a list of MLOG_FILE_RENAME2 records that have been
written to the redo log, but not performed yet in the file system.
When performing a checkpoint, re-emit these records to the redo
log. In this way, a mismatch between (b) and (c) should be impossible.

fil_name_process(): Refactored from fil_name_parse(). Adds an item to
the id-to-filename mapping.

fil_name_parse(): Parses and applies a MLOG_FILE_NAME,
MLOG_FILE_DELETE or MLOG_FILE_RENAME2 record. This implements FIX#1.

fil_name_write_rename(): A wrapper function for writing
MLOG_FILE_RENAME2 records.

fil_op_replay_rename(): Apply MLOG_FILE_RENAME2 records. Replaces
fil_op_log_parse_or_replay(), whose logic was moved to fil_name_parse().

fil_tablespace_exists_in_mem(): Return fil_space_t* instead of bool.

dict_check_tablespaces_and_store_max_id(): Add the parameter
"validate" to implement FIX#2.

log_sys->append_on_checkpoint: Extra log records to append in case of
a checkpoint. Needed for FIX#3.

log_append_on_checkpoint(): New function, to update
log_sys->append_on_checkpoint.

mtr_write_log(): New function, to append mtr_buf_t to the redo log.

fil_names_clear(): Append the data from log_sys->append_on_checkpoint
if needed.

ha_innobase::commit_inplace_alter_table(): Add any MLOG_FILE_RENAME2
records to log_sys->append_on_checkpoint(), and remove them once the
files have been renamed in the file system.

mtr_buf_copy_t: A helper functor for copying a mini-transaction log.

rb#6282 approved by Jimmy Yang
2018-05-16 15:03:09 +05:30
Monty
b050df4fd3 MDEV-14943 Alter table ORDER BY bug
Problem was that if copy_data_between_tables() didn't do proper
clean up in case of failures:
- copy object was not properly freed
- end_bulk_insert() was not called
- mysql_trans_prepare_alter_copy_data() set THD->transaction.on to
  false which was not properly restored

The last part caused a crash in Aria as Aria depends on that THD
is correct.

Other things:
- Reset info->switched_transactional after usage (safety)
- Reset bulk_insert_single_undo (safety)
2018-05-15 13:12:35 +03:00
Sergei Golubchik
182db5a1b7 disable galera.pxc-421 test 2018-05-15 12:10:48 +02:00
Sergei Golubchik
c29312421e MDEV-14750 Valgrind Invalid read, ASAN heap-use-after-free in Item_ident::print upon SHOW CREATE on partitioned table
items in the partitioning function were taking
the table name from the table's field
(in set_field(from_field) in Item_field::fix_fields)
and field's table_name is TABLE::alias.

But alias is changed for every statement, and
can be realloced if next statement uses a longer
alias. But partitioning items are fixed once
and live as long as the TABLE does. So if
an alias is realloced, pointers to the old
alias string will become invalid.

Fix partitioning item table_name to point to
the actual table name instead.
2018-05-15 12:10:48 +02:00
Marko Mäkelä
681e8ca35e MDEV-16142: Update the InnoDB version number to 5.7.22 2018-05-15 08:18:44 +03:00
Marko Mäkelä
2b24b04220 Bug 27122803 - BACKPORT FIX FOR BUG 25899959 TO MYSQL-5.7
Merge a test case and a code change from MySQL 5.7.22.
There was no commit message, but a test case was included.
d3ec326bcd

There is no Bug 25899959 mentioned in the MySQL 8.0.11 history.
Based on the number, it should have been filed before August 2017.
Maybe it was initially fixed in a not-yet-public MySQL 9.0 branch?

The code change differs from MySQL 5.7, because the mbminmaxlen
were split in MariaDB in MDEV-7049.
2018-05-14 23:29:13 +03:00