Commit graph

19829 commits

Author SHA1 Message Date
Vladislav Vaintroub
ea70586282 MDEV-16300 : remove rocksdb checkpoint created by mariabackup.
Add variable rocksdb_remove_mariabackup_checkpoint.
If set, it will remove $rocksdb_datadir/mariabackup-checkpoint directory.
The variable is to be used by exclusively by mariabackup,
to remove temporary checkpoints.
2018-06-07 15:12:26 +01:00
Marko Mäkelä
df42830b28 Merge 10.1 into 10.2 2018-06-06 11:25:33 +03:00
Marko Mäkelä
1d4e1d3263 Merge 10.0 to 10.1 2018-06-06 11:04:17 +03:00
Marko Mäkelä
55abcfa7b7 MDEV-16124 fil_rename_tablespace() times out and crashes server during table-rebuilding ALTER TABLE
InnoDB insisted on closing the file handle before renaming a file.
Renaming a file should never be a problem on POSIX systems. Also on
Windows it should work if the file was opened in FILE_SHARE_DELETE
mode.

fil_space_t::stop_ios: Remove. We no longer need to stop file access
during rename operations.

fil_mutex_enter_and_prepare_for_io(): Remove the wait for stop_ios.

fil_rename_tablespace(): Remove the retry logic; do not close the
file handle. Remove the unused fault injection that was added along
with the DATA DIRECTORY functionality (MySQL WL#5980).

os_file_create_simple_func(), os_file_create_func(),
os_file_create_simple_no_error_handling_func(): Include FILE_SHARE_DELETE
in the share_mode. (We will still prevent multiple InnoDB instances
from using the same files by not setting FILE_SHARE_WRITE.)
2018-06-05 18:16:12 +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ä
41cbe92bf1 Remove dead code that was added in MDEV-5834
ha_innobase::set_partition_owner_stats(): Remove (unused function).

ha_innobase::ha_partition_stats: Remove (the variable is never read).

Remove unused ut_timer functions.
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ä
5932a4e77d MDEV-13834: Upgrade failure from 10.1 innodb_encrypt_log
log_crypt_101_read_block(): Mimic MariaDB 10.1, and use the first
encryption key if the key for the checkpoint cannot be found.
Redo log encryption key rotation was ultimately disabled
in MDEV-9422 (MariaDB 10.1.13) due to design issues. So, from
MariaDB 10.1.13 onwards only one log encryption key should matter.

recv_log_format_0_recover(): Add the parameter 'bool crypt'.
Indicate when the log cannot be decrypted for upgrade, instead of
making a possibly false claim that the log requires crash recovery.

init_crypt_key(): Remove extra space from a message.
2018-06-04 11:40:10 +03:00
Marko Mäkelä
a31e99a89c Remove an unnecessary #include 2018-05-30 10:48:48 +03:00
Marko Mäkelä
18934fb583 Merge 10.1 into 10.2 2018-05-29 16:52:12 +03:00
Marko Mäkelä
6aa50bad39 MDEV-16283 ALTER TABLE...DISCARD TABLESPACE still takes long on a large buffer pool
Also fixes MDEV-14727, MDEV-14491
InnoDB: Error: Waited for 5 secs for hash index ref_count (1) to drop to 0
by replacing the flawed wait logic in dict_index_remove_from_cache_low().

On DISCARD TABLESPACE, there is no need to drop the adaptive hash index.
We must drop it on IMPORT TABLESPACE, and eventually on DROP TABLE or
DROP INDEX. As long as the dict_index_t object remains in the cache
and the table remains inaccessible, the adaptive hash index entries
to orphaned pages would not do any harm. They would be dropped when
buffer pool pages are reused for something else.

btr_search_drop_page_hash_when_freed(), buf_LRU_drop_page_hash_batch():
Remove the parameter zip_size, and pass 0 to buf_page_get_gen().

buf_page_get_gen(): Ignore zip_size if mode==BUF_PEEK_IF_IN_POOL.

buf_LRU_drop_page_hash_for_tablespace(): Drop the adaptive hash index
even if the tablespace is inaccessible.

buf_LRU_drop_page_hash_for_tablespace(): New global function, to drop
the adaptive hash index.

buf_LRU_flush_or_remove_pages(), fil_delete_tablespace():
Remove the parameter drop_ahi.

dict_index_remove_from_cache_low(): Actively drop the adaptive hash index
if entries exist. This should prevent InnoDB hangs on DROP TABLE or
DROP INDEX.

row_import_for_mysql(): Drop any adaptive hash index entries for the table.

row_drop_table_for_mysql(): Drop any adaptive hash index for the table,
except if the table resides in the system tablespace. (DISCARD TABLESPACE
does not apply to the system tablespace, and we do no want to drop the
adaptive hash index for other tables than the one that is being dropped.)

row_truncate_table_for_mysql(): Drop any adaptive hash index entries for
the table, except if the table resides in the system tablespace.
2018-05-29 14:00:20 +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
Marko Mäkelä
8a42ad7a5d MDEV-13834 10.2 wrongly recognizes 10.1.10 innodb_encrypt_log=ON data as after-crash and refuses to start
infos[]: Allocate enough entries to accommodate all keys from both
checkpoint pages.

infos_used: The size of infos[].

get_crypt_info(): Merge to the only caller, log_crypt_101_read_block().

log_crypt_101_read_block(): Do not validate the log block checksum,
because it will not be valid when upgrading from MariaDB 10.1.10.
Instead, check that the encryption key exists.

log_crypt_101_read_checkpoint(): Append to infos[] instead of overwriting.
2018-05-28 14:31:31 +03:00
Sergei Petrunia
1a8afb4885 MDEV-16310: rocksdb.check_ignore_unknown_options fails on OS X
Use a compatible xargs command-line arguments.
2018-05-28 13:02:48 +03:00
Monty
5a16fe0e6f Fixed compiler warnings
When merging this with 10.2 and later, one can just use the 10.2 or later code
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
72a8d29e00 Fixed archive to work with record[1]
ha_archive::max_row_length() and ha_archive::pack_row()
didn't use record parameter properly. Especially testing
of null was wrong for record[1]
2018-05-24 18:55:18 +03:00
Marko Mäkelä
1c8c6bcd6f MDEV-13779 InnoDB fails to shut down purge, causing hang
thd_destructor_proxy(): Ensure that purge actually exits,
like the logic should have been ever since MDEV-14080.

srv_purge_shutdown(): A new function to wait for the
purge coordinator to exit. Before exiting, the
purge coordinator will ensure that all purge workers have exited.
2018-05-24 15:30:22 +03:00
Marko Mäkelä
c38cc3165d Merge 10.0 into 10.1 2018-05-24 11:43:32 +03:00
Marko Mäkelä
a61724a3ca MDEV-16267 Wrong INFORMATION_SCHEMA.INNODB_BUFFER_PAGE.TABLE_NAME
i_s_innodb_buffer_page_fill(), i_s_innodb_buf_page_lru_fill():
Only invoke Field::set_notnull() if the index was found.
2018-05-24 11:38:34 +03:00
Marko Mäkelä
52df804026 MDEV-16267 Wrong INFORMATION_SCHEMA.INNODB_BUFFER_PAGE.TABLE_NAME
This is the MariaDB 10.2 version of the patch.

field_store_string(): Simplify the code.

field_store_index_name(): Remove, and use field_store_string()
instead. Starting with MariaDB 10.2.2, there is the predicate
dict_index_t::is_committed(), and dict_index_t::name never
contains the magic byte 0xff.

Correct some comments to refer to TEMP_INDEX_PREFIX_STR.

i_s_cmp_per_index_fill_low(): Use the appropriate value NULL to
identify that an index was not found. Check that storing each
column value succeeded.

i_s_innodb_buffer_page_fill(), i_s_innodb_buf_page_lru_fill():
Only invoke Field::set_notnull() if the index was found.
(This fixes the bug.)

i_s_dict_fill_sys_indexes(): Adjust the index->name that was
directly loaded from SYS_INDEXES.NAME (which can start with
the 0xff byte). This was the only function that depended
on the translation in field_store_index_name().
2018-05-24 11:09:59 +03:00
Monty
e744c687ca Merge remote-tracking branch 'origin/10.0' into 10.1 2018-05-24 11:08:02 +03:00
Sergei Petrunia
fdb8d0181e MDEV-16262: rocksdb.issue255 test sometimes fails in buildbot
Fix an obvious typo: replace_column should be applied to SHOW TABLE STATUS,
not to SELECT * FROM t1.
2018-05-23 15:27:28 +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
Sergei Petrunia
a107c79fcd MDEV-12439: MariaRocks produces numerous (spurious?) valgrind failures
Step#1: RocksDB files require a special #define when they are compiled
with valgrind. Without that, valgrind fails with an 'unimplemented syscall'
error for fcntl call.
2018-05-22 19:40:40 +03:00
Jacob Mathew
519060da45 MDEV-12900: spider tests failed in buildbot with valgrind
The failures with valgrind occur as a result of Spider sometimes using the
wrong transaction for operations in background threads that send requests to
the data nodes.  The use of the wrong transaction caused the networking to the
data nodes to use the wrong thread in some cases.  Valgrind eventually
detects this when such a thread is destroyed before it is used to disconnect
from the data node by that wrong transaction when it is freed.

I have fixed the problem by correcting the transaction used in each of these
cases.

Author:
  Jacob Mathew.

Reviewer:
  Kentoku Shiba.

Cherry-Picked:
  Commit afe5a51 on branch 10.2
2018-05-21 19:17:03 -07:00
Jacob Mathew
afe5a51c2d MDEV-12900: spider tests failed in buildbot with valgrind
The failures with valgrind occur as a result of Spider sometimes using the
wrong transaction for operations in background threads that send requests to
the data nodes.  The use of the wrong transaction caused the networking to the
data nodes to use the wrong thread in some cases.  Valgrind eventually
detects this when such a thread is destroyed before it is used to disconnect
from the data node by that wrong transaction when it is freed.

I have fixed the problem by correcting the transaction used in each of these
cases.

Author:
  Jacob Mathew.

Reviewer:
  Kentoku Shiba.

Merged:
  Commit 4d576d9 on branch bb-10.3-MDEV-12900
2018-05-21 18:16:03 -07:00
Sergei Petrunia
31584c8bb8 Set MyRocks plugin version to Stable 2018-05-21 13:43:50 +03:00
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
Sergei Petrunia
dd51082eca MDEV-12465: Server crashes in my_scan_weight_utf8_bin upon collecting stats for RocksDB table
Apply patch by Oleksandr Byelkin:
Do not use "only index read" in analyzing indices if there is a field which present in the index only partially.
2018-05-19 00:26:35 +03:00
Sergei Petrunia
06aaaef51a MDEV-16200: -DPLUGIN_ROCKSDB=YES leads to errors during build
Mark the plugin as dynamic-only.
2018-05-18 23:58:24 +03:00
Jacob Mathew
f76a17e355 MDEV-7914: spider/bg.ha, spider/bg.ha_part crash server sporadically in buildbot
The crash occurs when a thread that is closing its connection attempts to
access Spider transaction information when another thread has freed that memory
while processing Spider plugin deinit.  This occurs because Spider does not
adjust the plugin's reference count when it sets a transaction information
pointer for the plugin.

The fix I implemented changes the way Spider sets the transaction information
pointer to use thd_set_ha_data() so that Spider's plugin reference counter is
adjusted as well.

Author:
  Jacob Mathew.

Reviewer:
  Kentoku Shiba.

Merged From:
  Commit ab9d420 on branch 10.2
2018-05-18 11:14:26 -07:00
Sergei Petrunia
727d0d4f9b MDEV-15304: Server crash in print_keydup_error / key_unpack or unexpected ER_DUP_KEY
Fix two issues:
1. Rdb_ddl_manager::rename() loses the value of m_hidden_pk_val. new
object used to get 0, which means "not loaded from the db yet".

2. ha_rocksdb::load_hidden_pk_value() uses current transaction (and its
snapshot) when loading hidden PK value from disk. This may cause it to
load an out-of-date value.
2018-05-18 17:41:56 +03:00
Jacob Mathew
ab9d420df3 MDEV-7914: spider/bg.ha, spider/bg.ha_part crash server sporadically in buildbot
The crash occurs when a thread that is closing its connection attempts to
access Spider transaction information when another thread has freed that memory
while processing Spider plugin deinit.  This occurs because Spider does not
adjust the plugin's reference count when it sets a transaction information
pointer for the plugin.

The fix I implemented changes the way Spider sets the transaction information
pointer to use thd_set_ha_data() so that Spider's plugin reference counter is
adjusted as well.

Author:
  Jacob Mathew.

Reviewer:
  Kentoku Shiba.

Merged From:
  Commit eabfadc on branch bb-10.3-MDEV-7914
2018-05-17 11:21:13 -07:00
Sergei Golubchik
50275321c3 Merge branch '10.2' into bb-10.2-release 2018-05-17 11:25:35 +02:00
Sergei Golubchik
bb045e7931 MDEV-16183 TokuDB tests fail on Fedora 28
jemalloc > 5.0.0 doesn't like to be linked with
a dlopen-ed module.

Don't link tokudb with jemalloc on Fedora 28,
LD_PRELOAD it instead with mysqld_safe
and with systemd.
2018-05-16 23:24:14 +02:00
Marko Mäkelä
a4e7800701 MDEV-13779 InnoDB fails to shut down purge workers, causing hang
srv_purge_coordinator_thread(): Wait for all purge worker threads
to actually exit. An analysis of a core dump of a hung 10.3 server
revealed that one srv_worker_thread did not exit, even though the
purge coordinator had exited. This caused kill_server_thread and
mysqld_main to wait indefinitely. The main InnoDB shutdown was
never called, because unireg_end() was never called.
2018-05-16 16:35:33 +03: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
Sergei Golubchik
0e296947db add missing test result
followup for 21bcfeb996
2018-05-15 15:13:33 +02:00
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 Petrunia
21bcfeb996 MDEV-16155: UPDATE on RocksDB table with unique constraint does not work
RocksDB now supports "iterator bounds" which are min and max keys
that an iterator is interested in.

Iterator initialization function doesn't copy the keys, though, it keeps
pointers to them.
So if the buffer space for the keys is used for another iterator (the one
for checking for UNIUQE constraint violation in ha_rocksdb::ha_update_row)
then one can get incorrect query result.

Fixed by using a separate buffer for iterator bounds in the unique constraint
violation check.
2018-05-15 12:34:10 +03:00
Monty
2b749a7bf4 MDEV-654 Assertion `share->now_transactional' failed in flush_log_for_bitmap on concurrent workload with Aria tables
Problem was that we the bitmap needs to be flushed before disabling
logging of redo entires, as writing the bitmap to disk by
background checkpoint may cause redo entries.
2018-05-15 11:46:55 +03:00
Marko Mäkelä
681e8ca35e MDEV-16142: Update the InnoDB version number to 5.7.22 2018-05-15 08:18:44 +03:00
Sergei Petrunia
0d033b6d34 Down-scale rocksdb.bulk_load* tests by 2x. This should fix MDEV-13904 2018-05-14 23:54:43 +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
Sergei Petrunia
4d2a36e8bc Post-merge fix for rocksdb.add_index_inplace_sstfilewriter
MariaDB has a scaled-down version of the test so we need to set
@@rocksdb_max_row_locks lower to trigger the desired error

(didn't catch this on test BB run because this test is marked as "big")
2018-05-14 20:25:02 +03:00
Sergei Petrunia
279184a04d MDEV-14562: rocksdb.bloomfilter failed in buildbot
Bloom filter is only used when reading the data from disk. If the data
happens to be still in the memtable, bloomfilter wont be used.

Stabilize the testcase by making sure the data is on disk before we
read it.
2018-05-14 19:51:19 +03:00
Marko Mäkelä
fb5d579462 MDEV-13987 Hang in FLUSH TABLES...FOR EXPORT
trx_purge_stop(): Release purge_sys->latch before attempting to
wake up the purge threads, so that they can actually wake up.
This is a regression of commit a13a636c74
which attempted to fix MDEV-11802 by ensuring that srv_purge_wakeup()
will actually wait until all purge threads wake up.
Due to the purge_sys->latch, the threads might never wake up,
because some purge threads could end up waiting for purge_sys->latch
in trx_undo_prev_version_build() while holding dict_operation_lock
in shared mode. This in turn would block any DDL operations, the
InnoDB master thread, and InnoDB shutdown.
2018-05-14 18:19:20 +03:00