Commit graph

1648 commits

Author SHA1 Message Date
Vladislav Vaintroub
e5b67a46bc MDEV-12345 Performance : replace calls to clock() inside trx_start_low() by THD::start_utime 2017-03-23 11:50:22 +00:00
Sachin Setiya
9cf499724f Merge branch '10.0' into bb-10.0-galera 2017-03-20 18:11:56 +05:30
Jan Lindström
53c6195eed Fixed test failure on galere_wsrep_log_conflicts on XtraDB.
Problem was that trx_sys->mutex was acquired to print trx info
even when we already hold trx_sys->mutex. Fixed similarly as
in InnoDB, i.e. with wsrep_trx_print_locking() function that
does not acquire trx_sys->mutex.
2017-03-20 10:17:13 +02:00
Sachin Setiya
f66395f7c0 Merge tag 'mariadb-10.0.30' into bb-sachin-10.0-galera-merge
Signed-off-by: Sachin Setiya <sachin.setiya@mariadb.com>
2017-03-17 02:05:20 +05:30
Jan Lindström
b1ec35b903 Add assertions when key rotation list is used. 2017-03-16 17:30:13 +02:00
Jan Lindström
50eb40a2a8 MDEV-11738: Mariadb uses 100% of several of my 8 cpus doing nothing
MDEV-11581: Mariadb starts InnoDB encryption threads
when key has not changed or data scrubbing turned off

Background: Key rotation is based on background threads
(innodb-encryption-threads) periodically going through
all tablespaces on fil_system. For each tablespace
current used key version is compared to max key age
(innodb-encryption-rotate-key-age). This process
naturally takes CPU. Similarly, in same time need for
scrubbing is investigated. Currently, key rotation
is fully supported on Amazon AWS key management plugin
only but InnoDB does not have knowledge what key
management plugin is used.

This patch re-purposes innodb-encryption-rotate-key-age=0
to disable key rotation and background data scrubbing.
All new tables are added to special list for key rotation
and key rotation is based on sending a event to
background encryption threads instead of using periodic
checking (i.e. timeout).

fil0fil.cc: Added functions fil_space_acquire_low()
to acquire a tablespace when it could be dropped concurrently.
This function is used from fil_space_acquire() or
fil_space_acquire_silent() that will not print
any messages if we try to acquire space that does not exist.
fil_space_release() to release a acquired tablespace.
fil_space_next() to iterate tablespaces in fil_system
using fil_space_acquire() and fil_space_release().
Similarly, fil_space_keyrotation_next() to iterate new
list fil_system->rotation_list where new tables.
are added if key rotation is disabled.
Removed unnecessary functions fil_get_first_space_safe()
fil_get_next_space_safe()

fil_node_open_file(): After page 0 is read read also
crypt_info if it is not yet read.

btr_scrub_lock_dict_func()
buf_page_check_corrupt()
buf_page_encrypt_before_write()
buf_merge_or_delete_for_page()
lock_print_info_all_transactions()
row_fts_psort_info_init()
row_truncate_table_for_mysql()
row_drop_table_for_mysql()
    Use fil_space_acquire()/release() to access fil_space_t.

buf_page_decrypt_after_read():
    Use fil_space_get_crypt_data() because at this point
    we might not yet have read page 0.

fil0crypt.cc/fil0fil.h: Lot of changes. Pass fil_space_t* directly
to functions needing it and store fil_space_t* to rotation state.
Use fil_space_acquire()/release() when iterating tablespaces
and removed unnecessary is_closing from fil_crypt_t. Use
fil_space_t::is_stopping() to detect when access to
tablespace should be stopped. Removed unnecessary
fil_space_get_crypt_data().

fil_space_create(): Inform key rotation that there could
be something to do if key rotation is disabled and new
table with encryption enabled is created.
Remove unnecessary functions fil_get_first_space_safe()
and fil_get_next_space_safe(). fil_space_acquire()
and fil_space_release() are used instead. Moved
fil_space_get_crypt_data() and fil_space_set_crypt_data()
to fil0crypt.cc.

fsp_header_init(): Acquire fil_space_t*, write crypt_data
and release space.

check_table_options()
	Renamed FIL_SPACE_ENCRYPTION_* TO FIL_ENCRYPTION_*

i_s.cc: Added ROTATING_OR_FLUSHING field to
information_schema.innodb_tablespace_encryption
to show current status of key rotation.
2017-03-14 16:23:10 +02:00
Marko Mäkelä
9dc10d5851 Merge 10.0 into 10.1 2017-03-13 19:17:34 +02:00
Sergei Golubchik
b6a1d6538b compiler warnings 2017-03-10 18:21:22 +01:00
Marko Mäkelä
032678ad18 MDEV-12091 Shutdown fails to wait for rollback of recovered transactions to finish
In the 10.1 InnoDB Plugin, a call os_event_free(buf_flush_event) was
misplaced. The event could be signalled by rollback of resurrected
transactions while shutdown was in progress. This bug was caught
by cmake -DWITH_ASAN testing. This call was only present in the
10.1 InnoDB Plugin, not in other versions, or in XtraDB.

That said, the bug affects all InnoDB versions. Shutdown assumes the
cessation of any page-dirtying activity, including the activity of
the background rollback thread. InnoDB only waited for the background
rollback to finish as part of a slow shutdown (innodb_fast_shutdown=0).
The default is a clean shutdown (innodb_fast_shutdown=1). In a scenario
where InnoDB is killed, restarted, and shut down soon enough, the data
files could become corrupted.

logs_empty_and_mark_files_at_shutdown(): Wait for the
rollback to finish, except if innodb_fast_shutdown=2
(crash-like shutdown) was requested.

trx_rollback_or_clean_recovered(): Before choosing the next
recovered transaction to roll back, terminate early if non-slow
shutdown was initiated. Roll back everything on slow shutdown
(innodb_fast_shutdown=0).

srv_innodb_monitor_mutex: Declare as static, because the mutex
is only used within one module.

After each call to os_event_free(), ensure that the freed event
is not reachable via global variables, by setting the relevant
variables to NULL.
2017-03-10 18:54:29 +02:00
Marko Mäkelä
0094b6581d Merge 10.0 into 10.1 2017-03-10 15:16:13 +02:00
Marko Mäkelä
5aacb861f2 WSREP: Use TRX_ID_FMT for trx_id_t in messages. 2017-03-09 15:11:24 +02:00
Marko Mäkelä
b28adb6a62 Fix an error introduced in the previous commit.
fil_parse_write_crypt_data(): Correct the comparison operator.
This was broken in commit 498f4a825b
which removed a signed/unsigned mismatch in these comparisons.
2017-03-09 15:09:44 +02:00
Marko Mäkelä
1b2b209519 Use correct integer format with printf-like functions. 2017-03-09 11:28:07 +02:00
Marko Mäkelä
498f4a825b Fix InnoDB/XtraDB compilation warnings on 32-bit builds. 2017-03-09 08:54:07 +02:00
Marko Mäkelä
ad0c218a44 Merge 10.0 into 10.1
Also, implement MDEV-11027 a little differently from 5.5 and 10.0:

recv_apply_hashed_log_recs(): Change the return type back to void
(DB_SUCCESS was always returned).

Report progress also via systemd using sd_notifyf().
2017-03-09 08:53:08 +02:00
Marko Mäkelä
74fe0e03d5 Remove unused declarations. 2017-03-08 11:46:34 +02:00
Marko Mäkelä
47396ddea9 Merge 5.5 into 10.0
Also, implement MDEV-11027 a little differently from 5.5:

recv_sys_t::report(ib_time_t): Determine whether progress should
be reported.

recv_apply_hashed_log_recs(): Rename the parameter to last_batch.
2017-03-08 11:40:43 +02:00
Marko Mäkelä
9c47beb8bd MDEV-11027 InnoDB log recovery is too noisy
Provide more useful progress reporting of crash recovery.

recv_sys_t::progress_time: The time of the last report.

recv_scan_print_counter: Remove.

log_group_read_log_seg(): After after each I/O request,
report progress if needed.

recv_apply_hashed_log_recs(): At the start of each batch,
if there are pages to be recovered, issue a message.
2017-03-08 10:07:50 +02:00
Vicențiu Ciorbaru
c4f3e64c23 Merge branch 'bb-10.0-vicentiu' into 10.0 2017-03-06 21:50:42 +02:00
Marko Mäkelä
68d632bc5a Replace some functions with macros.
This is a non-functional change.

On a related note, the calls fil_system_enter() and fil_system_exit()
are often used in an unsafe manner. The fix of MDEV-11738 should
introduce fil_space_acquire() and remove potential race conditions.
2017-03-06 10:02:01 +02:00
Vicențiu Ciorbaru
5139c4b688 Update xtradb version to match the merged one 2017-03-05 01:06:01 +02:00
Vicențiu Ciorbaru
83da1a1e57 Merge branch 'merge-xtradb-5.6' into 10.0 2017-03-05 00:59:57 +02:00
Vicențiu Ciorbaru
8d69ce7b82 5.6.35-80.0 2017-03-04 20:50:02 +02:00
Marko Mäkelä
adc91387e3 Merge 10.0 into 10.1 2017-03-03 13:27:12 +02:00
Marko Mäkelä
29c776cfd1 MDEV-11520: Retry posix_fallocate() after EINTR.
The function posix_fallocate() as well as the Linux system call
fallocate() can return EINTR when the operation was interrupted
by a signal. In that case, keep retrying the operation, except
if InnoDB shutdown has been initiated.
2017-03-03 12:03:33 +02:00
Marko Mäkelä
6b8173b6e9 MDEV-11520: Retry posix_fallocate() after EINTR.
The function posix_fallocate() as well as the Linux system call
fallocate() can return EINTR when the operation was interrupted
by a signal. In that case, keep retrying the operation, except
if InnoDB shutdown has been initiated.
2017-03-03 11:47:31 +02:00
Daniel Black
bc28b305e5 Remove warning: unused variable 'volatile_var' [-Wunused-variable]
This occured in gcc-6.2.1.

The variable wasn't used so was no need to be volatile either.

Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
2017-03-03 13:00:41 +04:00
Vicențiu Ciorbaru
1acfa942ed Merge branch '5.5' into 10.0 2017-03-03 01:37:54 +02:00
Marko Mäkelä
fc673a2c12 MDEV-12127 InnoDB: Assertion failure loop_count < 5 in file log0log.cc
As suggested in MySQL Bug#58536, increase the limit in this
debug assertion in order to avoid false positives on heavily
loaded systems.
2017-02-28 09:54:12 +02:00
Marko Mäkelä
51af19851a MDEV-11454 post-merge fix:
buf_dump(): Correct the printf format passed to buf_dump_status()
to match the argument types.

Revert the changes to storage/xtradb. XtraDB is not being compiled
for 10.2. The unused copy that we have in the 10.2 branch is only
getting merges from 10.1.

Disable the test sys_vars.innodb_buffer_pool_dump_pct_function
because it is unstable on buildbot.
2017-02-24 22:12:01 +02:00
Marko Mäkelä
342b48b7b1 Merge pull request #264 from grooverdan/10.2-MDEV-11454-innodb_buffer_pool_dump_pct-entire-pool
MDEV-11454: Make innodb_buffer_pool_dump_pct refer to the entire buffer pool size
2017-02-24 15:12:09 +02:00
Marko Mäkelä
7f7673033e Remove an unused variable. 2017-02-22 22:32:29 +02:00
Marko Mäkelä
ec4cf111c0 MDEV-11520 after-merge fix for 10.1: Use sparse files.
If page_compression (introduced in MariaDB Server 10.1) is enabled,
the logical action is to not preallocate space to the data files,
but to only logically extend the files with zeroes.

fil_create_new_single_table_tablespace(): Create smaller files for
ROW_FORMAT=COMPRESSED tables, but adhere to the minimum file size of
4*innodb_page_size.

fil_space_extend_must_retry(), os_file_set_size(): On Windows,
use SetFileInformationByHandle() and FILE_END_OF_FILE_INFO,
which depends on bumping _WIN32_WINNT to 0x0600.
FIXME: The files are not yet set up as sparse, so
this will currently end up physically extending (preallocating)
the files, wasting storage for unused pages.

os_file_set_size(): Add the parameter "bool sparse=false" to declare
that the file is to be extended logically, instead of being preallocated.
The only caller with sparse=true is
fil_create_new_single_table_tablespace().
(The system tablespace cannot be created with page_compression.)

fil_space_extend_must_retry(), os_file_set_size(): Outside Windows,
use ftruncate() to extend files that are supposed to be sparse.
On systems where ftruncate() is limited to files less than 4GiB
(if there are any), fil_space_extend_must_retry() retains the
old logic of physically extending the file.
2017-02-22 22:29:56 +02:00
Marko Mäkelä
e1e920bf63 Merge 10.0 into 10.1 2017-02-22 15:53:05 +02:00
Marko Mäkelä
a0ce92ddc7 MDEV-11520 post-fix
fil_extend_space_to_desired_size(): Use a proper type cast when
computing start_offset for the posix_fallocate() call on 32-bit systems
(where sizeof(ulint) < sizeof(os_offset_t)). This could affect 32-bit
systems when extending files that are at least 4 MiB long.

This bug existed in MariaDB 10.0 before MDEV-11520. In MariaDB 10.1
it had been fixed in MDEV-11556.
2017-02-22 12:32:17 +02:00
Marko Mäkelä
81695ab8b5 MDEV-11520 Extending an InnoDB data file unnecessarily allocates
a large memory buffer on Windows

fil_extend_space_to_desired_size(), os_file_set_size(): Use calloc()
for memory allocation, and handle failures. Properly check the return
status of posix_fallocate(), and pass the correct arguments to
posix_fallocate().

On Windows, instead of extending the file by at most 1 megabyte at a time,
write a zero-filled page at the end of the file.
According to the Microsoft blog post
https://blogs.msdn.microsoft.com/oldnewthing/20110922-00/?p=9573
this will physically extend the file by writing zero bytes.
(InnoDB never uses DeviceIoControl() to set the file sparse.)

I tested that the file extension works properly with a multi-file
system tablespace, both with --innodb-use-fallocate and
--skip-innodb-use-fallocate (the default):

./mtr \
--mysqld=--innodb-use-fallocate \
--mysqld=--innodb-autoextend-increment=1 \
--mysqld=--innodb-data-file-path='ibdata1:5M;ibdata2:5M:autoextend' \
--parallel=auto --force --retry=0 --suite=innodb &

ls -lsh mysql-test/var/*/mysqld.1/data/ibdata2
(several samples while running the test)
2017-02-22 12:21:44 +02:00
Marko Mäkelä
365c4e971a MDEV-11520/MDEV-5746 post-fix: Do not posix_fallocate() too much.
Before the MDEV-11520 fixes, fil_extend_space_to_desired_size()
in MariaDB Server 5.5 incorrectly passed the desired file size as the
third argument to posix_fallocate(), even though the length of the
extension should have been passed. This looks like a regression
that was introduced in the 5.5 version of MDEV-5746.
2017-02-22 10:03:33 +02:00
Marko Mäkelä
6de50b2c7f MDEV-11520 post-fixes
Remove the unused variable desired_size.

Also, correct the expression for the posix_fallocate() start_offset,
and actually test that it works with a multi-file system tablespace.
Before MDEV-11520, the expression was wrong in both innodb_plugin and
xtradb, in different ways.

The start_offset formula was tested with the following:

./mtr --big-test --mysqld=--innodb-use-fallocate \
--mysqld=--innodb-data-file-path='ibdata1:5M;ibdata2:5M:autoextend' \
--parallel=auto --force --retry=0 --suite=innodb &

ls -lsh mysql-test/var/*/mysqld.1/data/ibdata2
2017-02-22 09:44:21 +02:00
Marko Mäkelä
978179a9d4 MDEV-11520 Extending an InnoDB data file unnecessarily allocates
a large memory buffer on Windows

fil_extend_space_to_desired_size(), os_file_set_size(): Use calloc()
for memory allocation, and handle failures. Properly check the return
status of posix_fallocate().

On Windows, instead of extending the file by at most 1 megabyte at a time,
write a zero-filled page at the end of the file.
According to the Microsoft blog post
https://blogs.msdn.microsoft.com/oldnewthing/20110922-00/?p=9573
this will physically extend the file by writing zero bytes.
(InnoDB never uses DeviceIoControl() to set the file sparse.)

For innodb_plugin, port the XtraDB fix for MySQL Bug#56433
(introducing fil_system->file_extend_mutex). The bug was
fixed differently in MySQL 5.6 (and MariaDB Server 10.0).
2017-02-21 16:45:03 +02:00
Marko Mäkelä
2bfe83adec Remove a bogus Valgrind "suppression".
fsp_init_file_page_low() does initialize all pages nowadays,
even those in the InnoDB system tablespace.
2017-02-21 16:45:03 +02:00
Marko Mäkelä
3c47ed4849 Merge 10.0 into 10.1 2017-02-20 14:02:40 +02:00
Marko Mäkelä
13493078e9 MDEV-11802 innodb.innodb_bug14676111 fails
The function trx_purge_stop() was calling os_event_reset(purge_sys->event)
before calling rw_lock_x_lock(&purge_sys->latch). The os_event_set()
call in srv_purge_coordinator_suspend() is protected by that X-latch.

It would seem a good idea to consistently protect both os_event_set()
and os_event_reset() calls with a common mutex or rw-lock in those
cases where os_event_set() and os_event_reset() are used
like condition variables, tied to changes of shared state.

For each os_event_t, we try to document the mutex or rw-lock that is
being used. For some events, frequent calls to os_event_set() seem to
try to avoid hangs. Some events are never waited for infinitely, only
timed waits, and os_event_set() is used for early termination of these
waits.

os_aio_simulated_put_read_threads_to_sleep(): Define as a null macro
on other systems than Windows. TODO: remove this altogether and disable
innodb_use_native_aio on Windows.

os_aio_segment_wait_events[]: Initialize only if innodb_use_native_aio=0.
2017-02-20 12:20:52 +02:00
Jan Lindström
108b211ee2 Fix gcc 6.3.x compiler warnings.
These are caused by fact that functions are declared with
__attribute__((nonnull)) or left shit like ~0 << macro
when ~0U << macro should be used.
2017-02-16 12:02:31 +02:00
Marko Mäkelä
01d5d6db4c Fix GCC 6.3.0 warnings. 2017-02-16 11:16:27 +02:00
Marko Mäkelä
32170cafad MDEV-12075 innodb_use_fallocate does not work in MariaDB Server 10.1.21
fil_space_extend_must_retry(): When innodb_use_fallocate=ON,
initialize pages_added = size - space->size so that posix_fallocate()
will actually attempt to extend the file, instead of keeping the same size.

This is a regression from MDEV-11556 which refactored
the InnoDB data file extension.
2017-02-16 11:12:24 +02:00
Sergei Golubchik
f3914d10b6 Merge branch 'bb-10.2-serg-merge' into 10.2 2017-02-11 09:45:34 +01:00
Sergei Golubchik
2195bb4e41 Merge branch '10.1' into 10.2 2017-02-10 17:01:45 +01:00
Jan Lindström
de9963b786 After reivew fixes. 2017-02-10 17:41:35 +02:00
Jan Lindström
41cd80fe06 After review fixes. 2017-02-10 16:05:37 +02:00
Nirbhay Choubey
3435e8a515 MDEV-7635: Part 1
innodb_autoinc_lock_mode            = 2
innodb_buffer_pool_dump_at_shutdown = ON
innodb_buffer_pool_dump_pct         = 25
innodb_buffer_pool_load_at_startup  = ON
innodb_checksum_algorithm           = CRC32
innodb_file_format                  = Barracuda
innodb_large_prefix                 = ON
innodb_log_compressed_pages         = ON
innodb_purge_threads                = 4
innodb_strict_mode                  = ON
binlog_annotate_row_events          = ON
binlog_format                       = MIXED
binlog-row-event-max-size           = 8192
group_concat_max_len                = 1M
lock_wait_timeout                   = 86400
log_slow_admin_statements           = ON
log_slow_slave_statements           = ON
log_warnings                        = 2
max_allowed_packet                  = 16M
replicate_annotate_row_events       = ON
slave_net_timeout                   = 60
sync_binlog                         = 1
aria_recover                        = BACKUP,QUICK
myisam_recover_options              = BACKUP,QUICK
2017-02-10 06:30:42 -05:00
Marko Mäkelä
99b2de92c6 Post-push fix for MDEV-11623: Remove an unused variable. 2017-02-09 09:36:10 +02:00
Marko Mäkelä
ef065dbbc2 Merge 10.0 into 10.1 2017-02-09 08:51:52 +02:00
Jan Lindström
0340067608 After review fixes for MDEV-11759.
buf_page_is_checksum_valid_crc32()
buf_page_is_checksum_valid_innodb()
buf_page_is_checksum_valid_none():
	Use ULINTPF instead of %lu and %u for ib_uint32_t

fil_space_verify_crypt_checksum():
	Check that page is really empty if checksum and
	LSN are zero.

fil_space_verify_crypt_checksum():
	Correct the comment to be more agurate.

buf0buf.h:
	Remove unnecessary is_corrupt variable from
	buf_page_t structure.
2017-02-09 08:49:13 +02:00
Marko Mäkelä
6011fb6daa Post-push fix for MDEV-11947 InnoDB purge workers fail to shut down
Use the ib_int64_t type alias instead of the standard type int64_t,
so that the code will compile on Microsoft Visual Studio 2013.
2017-02-09 08:47:38 +02:00
Marko Mäkelä
9017a05d87 Merge 10.0 into 10.1 2017-02-08 17:30:25 +02:00
Marko Mäkelä
d831e4c22a MDEV-12024 InnoDB startup fails to wait for recv_writer_thread to finish
recv_writer_thread(): Do not assign recv_writer_thread_active=true
in order to avoid a race condition with
recv_recovery_from_checkpoint_finish().

recv_init_crash_recovery(): Assign recv_writer_thread_active=true
before creating recv_writer_thread.
2017-02-08 17:23:13 +02:00
Marko Mäkelä
cbdc389ec9 MDEV-12022 InnoDB wrongly ignores the end of an .ibd file
InnoDB can wrongly ignore the end of data files when using
innodb_page_size=32k or innodb_page_size=64k. These page sizes
use an allocation extent size of 2 or 4 megabytes, not 1 megabyte.

This issue does not affect MariaDB Server 10.2, which is using
the correct WL#5757 code from MySQL 5.7.

That said, it does not make sense to ignore the tail of data files.
The next time the data file needs to be extended, it would be extended
to a multiple of the extent size, once the size exceeds one extent.
2017-02-08 11:35:35 +02:00
Marko Mäkelä
2e67e66c3a Merge 10.0 into 10.1 2017-02-08 08:53:34 +02:00
Jan Lindström
e53dfb24be MDEV-11707: Fix incorrect memset() for structures containing
dynamic class GenericPolicy<TTASEventMutex<GenericPolicy> >'; vtable

Instead using mem_heap_alloc and memset, use mem_heap_zalloc
directly.
2017-02-06 15:40:17 +02:00
Jan Lindström
ddf2fac733 MDEV-11759: Encryption code in MariaDB 10.1/10.2 causes
compatibility problems

Pages that are encrypted contain post encryption checksum on
different location that normal checksum fields. Therefore,
we should before decryption check this checksum to avoid
unencrypting corrupted pages. After decryption we can use
traditional checksum check to detect if page is corrupted
or unencryption was done using incorrect key.

Pages that are page compressed do not contain any checksum,
here we need to fist unencrypt, decompress and finally
use tradional checksum check to detect page corruption
or that we used incorrect key in unencryption.

buf0buf.cc: buf_page_is_corrupted() mofified so that
compressed pages are skipped.

buf0buf.h, buf_block_init(), buf_page_init_low():
removed unnecessary page_encrypted, page_compressed,
stored_checksum, valculated_checksum fields from
buf_page_t

buf_page_get_gen(): use new buf_page_check_corrupt() function
to detect corrupted pages.

buf_page_check_corrupt(): If page was not yet decrypted
check if post encryption checksum still matches.
If page is not anymore encrypted, use buf_page_is_corrupted()
traditional checksum method.

If page is detected as corrupted and it is not encrypted
we print corruption message to error log.
If page is still encrypted or it was encrypted and now
corrupted, we will print message that page is
encrypted to error log.

buf_page_io_complete(): use new buf_page_check_corrupt()
function to detect corrupted pages.

buf_page_decrypt_after_read(): Verify post encryption
checksum before tring to decrypt.

fil0crypt.cc: fil_encrypt_buf() verify post encryption
checksum and ind fil_space_decrypt() return true
if we really decrypted the page.

fil_space_verify_crypt_checksum(): rewrite to use
the method used when calculating post encryption
checksum. We also check if post encryption checksum
matches that traditional checksum check does not
match.

fil0fil.ic: Add missed page type encrypted and page
compressed to fil_get_page_type_name()

Note that this change does not yet fix innochecksum tool,
that will be done in separate MDEV.

Fix test failures caused by buf page corruption injection.
2017-02-06 15:40:16 +02:00
Marko Mäkelä
f162704570 Rewrite the innodb.log_file_size test with DBUG_EXECUTE_IF.
Remove the debug parameter innodb_force_recovery_crash that was
introduced into MySQL 5.6 by me in WL#6494 which allowed InnoDB
to resize the redo log on startup.

Let innodb.log_file_size actually start up the server, but ensure
that the InnoDB storage engine refuses to start up in each of the
scenarios.
2017-02-05 17:07:16 +02:00
Marko Mäkelä
20e8347447 MDEV-11985 Make innodb_read_only shutdown more robust
If InnoDB is started in innodb_read_only mode such that
recovered incomplete transactions exist at startup
(but the redo logs are clean), an assertion will fail at shutdown,
because there would exist some non-prepared transactions.

logs_empty_and_mark_files_at_shutdown(): Do not wait for incomplete
transactions to finish if innodb_read_only or innodb_force_recovery>=3.
Wait for purge to finish in only one place.

trx_sys_close(): Relax the assertion that would fail first.

trx_free_prepared(): Also free recovered TRX_STATE_ACTIVE transactions
if innodb_read_only or innodb_force_recovery>=3.
2017-02-04 17:33:19 +02:00
Marko Mäkelä
9f0dbb3120 MDEV-11947 InnoDB purge workers fail to shut down
srv_release_threads(): Actually wait for the threads to resume
from suspension. On CentOS 5 and possibly other platforms,
os_event_set() may be lost.

srv_resume_thread(): A counterpart of srv_suspend_thread().
Optionally wait for the event to be set, optionally with a timeout,
and then release the thread from suspension.

srv_free_slot(): Unconditionally suspend the thread. It is always
in resumed state when this function is entered.

srv_active_wake_master_thread_low(): Only call os_event_set().

srv_purge_coordinator_suspend(): Use srv_resume_thread() instead
of the complicated logic.
2017-02-04 17:33:01 +02:00
Jan Lindström
17cc619847 MDEV-11671: Duplicated [NOTE] output for changed innodb_page_size
Remove duplicated output and change output level to info.
2017-01-31 15:42:52 +02:00
Marko Mäkelä
732672c304 MDEV-11233 CREATE FULLTEXT INDEX with a token longer than 127 bytes
crashes server

This bug is the result of merging the Oracle MySQL follow-up fix
BUG#22963169 MYSQL CRASHES ON CREATE FULLTEXT INDEX
without merging the base bug fix:
Bug#79475 Insert a token of 84 4-bytes chars into fts index causes
server crash.

Unlike the above mentioned fixes in MySQL, our fix will not change
the storage format of fulltext indexes in InnoDB or XtraDB
when a character encoding with mbmaxlen=2 or mbmaxlen=3
and the length of a word is between 128 and 84*mbmaxlen bytes.
The Oracle fix would allocate 2 length bytes for these cases.

Compatibility with other MySQL and MariaDB releases is ensured by
persisting the used maximum length in the SYS_COLUMNS table in the
InnoDB data dictionary.

This fix also removes some unnecessary strcmp() calls when checking
for the legacy default collation my_charset_latin1
(my_charset_latin1.name=="latin1_swedish_ci").

fts_create_one_index_table(): Store the actual length in bytes.
This metadata will be written to the SYS_COLUMNS table.

fts_zip_initialize(): Initialize only the first byte of the buffer.
Actually the code should not even care about this first byte, because
the length is set as 0.

FTX_MAX_WORD_LEN: Define as HA_FT_MAXCHARLEN * 4 aka 336 bytes,
not as 254 bytes.

row_merge_create_fts_sort_index(): Set the actual maximum length of the
column in bytes, similar to fts_create_one_index_table().

row_merge_fts_doc_tokenize(): Remove the redundant parameter word_dtype.
Use the actual maximum length of the column. Calculate the extra_size
in the same way as row_merge_buf_encode() does.
2017-01-27 10:19:39 +02:00
Marko Mäkelä
f1f8ebc325 Merge 10.0 into 10.1 2017-01-26 23:40:11 +02:00
Marko Mäkelä
afb461587c MDEV-11915 Detect InnoDB system tablespace size mismatch early
InnoDB would refuse to start up if there is a mismatch on
the size of the system tablespace files. However, before this
check is conducted, the system tablespace may already have been
heavily modified.

InnoDB should perform the size check as early as possible.

recv_recovery_from_checkpoint_finish():
Move the recv_apply_hashed_log_recs() call to
innobase_start_or_create_for_mysql().

innobase_start_or_create_for_mysql(): Test the mutex functionality
before doing anything else. Use a compile_time_assert() for a
sizeof() constraint. Check the size of the system tablespace as
early as possible.
2017-01-26 23:10:36 +02:00
Marko Mäkelä
49fe9bad01 MDEV-11814 Refuse innodb_read_only startup if crash recovery is needed
recv_scan_log_recs(): Remember if redo log apply is needed,
even if starting up in innodb_read_only mode.

recv_recovery_from_checkpoint_start_func(): Refuse
innodb_read_only startup if redo log apply is needed.
2017-01-26 13:58:58 +02:00
Jan Lindström
b7b4c332c0 MDEV-11614: Syslog messages: "InnoDB: Log sequence number
at the start 759654123 and the end 0 do not match."

For page compressed and encrypted tables log sequence
number at end is not stored, thus disable this message
for them.
2017-01-22 08:46:15 +02:00
Jan Lindström
8a4d605500 MDEV-11838: Innodb-encryption-algorithm default should be != none
Change default to zlib, this has effect only if user has
explicitly requested page compression and then user
naturally expects that pages are really compressed
if they can be compressed.
2017-01-19 12:20:54 +02:00
Marko Mäkelä
b05bf8ff0f Merge 10.1 to 10.2.
Most notably, this includes MDEV-11623, which includes a fix and
an upgrade procedure for the InnoDB file format incompatibility
that is present in MariaDB Server 10.1.0 through 10.1.20.

In other words, this merge should address
MDEV-11202 InnoDB 10.1 -> 10.2 migration does not work
2017-01-19 12:06:13 +02:00
Jan Lindström
dc557ca817 MDEV-11835: InnoDB: Failing assertion: free_slot != NULL on
restarting server with encryption and read-only

buf0buf.cc: Temporary slots used in encryption was calculated
by read_threads * write_threads. However, in read-only mode
write_threads is zero. Correct way is to calculate
(read_threads + write_threads) * max pending IO requests.
2017-01-19 08:19:08 +02:00
Marko Mäkelä
ab1e6fefd8 MDEV-11623 MariaDB 10.1 fails to start datadir created with
MariaDB 10.0/MySQL 5.6 using innodb-page-size!=16K

The storage format of FSP_SPACE_FLAGS was accidentally broken
already in MariaDB 10.1.0. This fix is bringing the format in
line with other MySQL and MariaDB release series.

Please refer to the comments that were added to fsp0fsp.h
for details.

This is an INCOMPATIBLE CHANGE that affects users of
page_compression and non-default innodb_page_size. Upgrading
to this release will correct the flags in the data files.
If you want to downgrade to earlier MariaDB 10.1.x, please refer
to the test innodb.101_compatibility how to reset the
FSP_SPACE_FLAGS in the files.

NOTE: MariaDB 10.1.0 to 10.1.20 can misinterpret
uncompressed data files with innodb_page_size=4k or 64k as
compressed innodb_page_size=16k files, and then probably fail
when trying to access the pages. See the comments in the
function fsp_flags_convert_from_101() for detailed analysis.

Move PAGE_COMPRESSION to FSP_SPACE_FLAGS bit position 16.
In this way, compressed innodb_page_size=16k tablespaces will not
be mistaken for uncompressed ones by MariaDB 10.1.0 to 10.1.20.

Derive PAGE_COMPRESSION_LEVEL, ATOMIC_WRITES and DATA_DIR from the
dict_table_t::flags when the table is available, in
fil_space_for_table_exists_in_mem() or fil_open_single_table_tablespace().
During crash recovery, fil_load_single_table_tablespace() will use
innodb_compression_level for the PAGE_COMPRESSION_LEVEL.

FSP_FLAGS_MEM_MASK: A bitmap of the memory-only fil_space_t::flags
that are not to be written to FSP_SPACE_FLAGS. Currently, these will
include PAGE_COMPRESSION_LEVEL, ATOMIC_WRITES and DATA_DIR.

Introduce the macro FSP_FLAGS_PAGE_SSIZE(). We only support
one innodb_page_size for the whole instance.

When creating a dummy tablespace for the redo log, use
fil_space_t::flags=0. The flags are never written to the redo log files.

Remove many FSP_FLAGS_SET_ macros.

dict_tf_verify_flags(): Remove. This is basically only duplicating
the logic of dict_tf_to_fsp_flags(), used in a debug assertion.

fil_space_t::mark: Remove. This flag was not used for anything.

fil_space_for_table_exists_in_mem(): Remove the unnecessary parameter
mark_space, and add a parameter for table flags. Check that
fil_space_t::flags match the table flags, and adjust the (memory-only)
flags based on the table flags.

fil_node_open_file(): Remove some redundant or unreachable conditions,
do not use stderr for output, and avoid unnecessary server aborts.

fil_user_tablespace_restore_page(): Convert the flags, so that the
correct page_size will be used when restoring a page from the
doublewrite buffer.

fil_space_get_page_compressed(), fsp_flags_is_page_compressed(): Remove.
It suffices to have fil_space_is_page_compressed().

FSP_FLAGS_WIDTH_DATA_DIR, FSP_FLAGS_WIDTH_PAGE_COMPRESSION_LEVEL,
FSP_FLAGS_WIDTH_ATOMIC_WRITES: Remove, because these flags do not
exist in the FSP_SPACE_FLAGS but only in memory.

fsp_flags_try_adjust(): New function, to adjust the FSP_SPACE_FLAGS
in page 0. Called by fil_open_single_table_tablespace(),
fil_space_for_table_exists_in_mem(), innobase_start_or_create_for_mysql()
except if --innodb-read-only is active.

fsp_flags_is_valid(ulint): Reimplement from the scratch, with
accurate comments. Do not display any details of detected
inconsistencies, because the output could be confusing when
dealing with MariaDB 10.1.x data files.

fsp_flags_convert_from_101(ulint): Convert flags from buggy
MariaDB 10.1.x format, or return ULINT_UNDEFINED if the flags
cannot be in MariaDB 10.1.x format.

fsp_flags_match(): Check the flags when probing files.
Implemented based on fsp_flags_is_valid()
and fsp_flags_convert_from_101().

dict_check_tablespaces_and_store_max_id(): Do not access the
page after committing the mini-transaction.

IMPORT TABLESPACE fixes:

AbstractCallback::init(): Convert the flags.

FetchIndexRootPages::operator(): Check that the tablespace flags match the
table flags. Do not attempt to convert tablespace flags to table flags,
because the conversion would necessarily be lossy.

PageConverter::update_header(): Write back the correct flags.
This takes care of the flags in IMPORT TABLESPACE.
2017-01-15 19:05:50 +02:00
Marko Mäkelä
a9d00db155 MDEV-11799 InnoDB can abort if the doublewrite buffer
contains a bad and a good copy

Clean up the InnoDB doublewrite buffer code.

buf_dblwr_init_or_load_pages(): Do not add empty pages to the buffer.

buf_dblwr_process(): Do consider changes to pages that are all zero.
Do not abort when finding a corrupted copy of a page in the doublewrite
buffer, because there could be multiple copies in the doublewrite buffer,
and only one of them needs to be good.
2017-01-15 18:56:56 +02:00
Nirbhay Choubey
5fc1ba604e Fix for post-merge build failure. 2017-01-13 13:57:17 -05:00
Nirbhay Choubey
ee8b5c305a Merge tag 'mariadb-10.0.29' into 10.0-galera 2017-01-13 13:53:59 -05:00
Marko Mäkelä
fd0479ce59 Merge 10.1 into 10.2 2017-01-11 14:27:24 +02:00
Marko Mäkelä
4507f1e5d4 Remove an excessive copyright message. 2017-01-11 14:26:30 +02:00
Marko Mäkelä
5b5bce81e6 Merge 10.0 into 10.1 2017-01-11 14:19:06 +02:00
Marko Mäkelä
833fda8f1a InnoDB: Enable UNIV_DEBUG_VALGRIND for cmake -DWITH_VALGRIND
The symbol HAVE_VALGRIND_MEMCHECK_H was never defined.
Instead, the symbol HAVE_VALGRIND should have been used.
2017-01-11 14:13:30 +02:00
Marko Mäkelä
6790bf049c Merge 10.1 into 10.2 2017-01-07 15:35:34 +02:00
Marko Mäkelä
384f4d1e36 Post-push fix for MDEV-11556: Make the debug variable UINT.
Sometimes innodb_data_file_size_debug was reported as INT UNSIGNED
instead of BIGINT UNSIGNED. Make it uint instead of ulong to get
a more deterministic result.
2017-01-07 15:27:59 +02:00
Marko Mäkelä
4ce579d27f Merge 10.1 into 10.2 2017-01-05 20:44:26 +02:00
Marko Mäkelä
8049d2e9d9 Merge 10.0 into 10.1 2017-01-05 20:32:15 +02:00
Marko Mäkelä
f0c19b6a57 MDEV-11730 Memory leak in innodb.innodb_corrupt_bit
Memory was leaked when ALTER TABLE is attempted on a table
that contains corrupted indexes.
The memory leak was reported by AddressSanitizer for the test
innodb.innodb_corrupt_bit. The leak was introduced into
MariaDB Server 10.0.26, 10.1.15, 10.2.1 by the following:

commit c081c978a2
Merge: 1d21b22155 a482e76e65
Author: Sergei Golubchik <serg@mariadb.org>
Date:   Tue Jun 21 14:11:02 2016 +0200

   Merge branch '5.5' into bb-10.0
2017-01-05 20:30:51 +02:00
Marko Mäkelä
11b7dff5eb Merge 10.1 to 10.2.
This makes no functional change to MariaDB Server 10.2.
XtraDB is not being built, and in InnoDB, there was no
memory leak in buf_dblwr_process() in MariaDB Server 10.2.
2017-01-05 19:05:05 +02:00
Marko Mäkelä
fb5ee7d6d0 Plug a memory leak in buf_dblwr_process(). 2017-01-05 19:01:14 +02:00
Marko Mäkelä
4e7b382d31 Merge 10.1 to 10.2
Most conflicts are related to the MDEV-11638 InnoDB shutdown refactoring.
2017-01-05 10:48:03 +02:00
Marko Mäkelä
719321e78e MDEV-11638 Encryption causes race conditions in InnoDB shutdown
InnoDB shutdown failed to properly take fil_crypt_thread() into account.
The encryption threads were signalled to shut down together with other
non-critical tasks. This could be much too early in case of slow shutdown,
which could need minutes to complete the purge. Furthermore, InnoDB
failed to wait for the fil_crypt_thread() to actually exit before
proceeding to the final steps of shutdown, causing the race conditions.

Furthermore, the log_scrub_thread() was shut down way too early.
Also it should remain until the SRV_SHUTDOWN_FLUSH_PHASE.

fil_crypt_threads_end(): Remove. This would cause the threads to
be terminated way too early.

srv_buf_dump_thread_active, srv_dict_stats_thread_active,
lock_sys->timeout_thread_active, log_scrub_thread_active,
srv_monitor_active, srv_error_monitor_active: Remove a race condition
between startup and shutdown, by setting these in the startup thread
that creates threads, not in each created thread. In this way, once the
flag is cleared, it will remain cleared during shutdown.

srv_n_fil_crypt_threads_started, fil_crypt_threads_event: Declare in
global rather than static scope.

log_scrub_event, srv_log_scrub_thread_active, log_scrub_thread():
Declare in static rather than global scope. Let these be created by
log_init() and freed by log_shutdown().

rotate_thread_t::should_shutdown(): Do not shut down before the
SRV_SHUTDOWN_FLUSH_PHASE.

srv_any_background_threads_are_active(): Remove. These checks now
exist in logs_empty_and_mark_files_at_shutdown().

logs_empty_and_mark_files_at_shutdown(): Shut down the threads in
the proper order. Keep fil_crypt_thread() and log_scrub_thread() alive
until SRV_SHUTDOWN_FLUSH_PHASE, and check that they actually terminate.
2017-01-05 00:20:06 +02:00
Marko Mäkelä
0f8e17af92 Part 1 of MDEV-8139 Fix scrubbing tests
Port a bug fix from MySQL 5.7, so that all undo log pages will be freed
during a slow shutdown. We cannot scrub pages that are left allocated.

commit 173e171c6fb55f064eea278c76fbb28e2b1c757b
Author: Thirunarayanan Balathandayuthapani <thirunarayanan.balathandayuth@oracle.com>
Date:   Fri Sep 9 18:01:27 2016 +0530

    Bug #24450908   UNDO LOG EXISTS AFTER SLOW SHUTDOWN

    Problem:
    ========

    1) cached undo segment is not removed from rollback segment history
    (RSEG_HISTORY) during slow shutdown. In other words, If the segment is
    not completely free, we are failing to remove an entry from the history
    list. While starting the server, we traverse all rollback segment slots
    history list and make it as list of undo logs to be purged in purge
    queue.
    In that case, purge queue will never be empty after slow shutdown.

    2) Freeing of undo log segment is linked with removing undo log header
    from history.

    Fix:
    ====
    1) Have separate logic of removing the undo log header from
    history list from rollback segment slots and remove it from
    rollback segment history even though it is not completely free.

    Reviewed-by: Debarun Banerjee <debarun.banerjee@oracle.com>
    Reviewed-by: Marko Mäkelä <marko.makela@oracle.com>
    RB:13672
2017-01-04 18:21:42 +02:00
Marko Mäkelä
0c1de94db6 Merge 10.0 into 10.1 2017-01-04 13:56:11 +02:00
Marko Mäkelä
80d5d1452a MDEV-11694 InnoDB tries to create unused table SYS_ZIP_DICT
MariaDB Server 10.0.28 and 10.1.19 merged code from Percona XtraDB
that introduced support for compressed columns. Much but not all
of this code was disabled by placing #ifdef HAVE_PERCONA_COMPRESSED_COLUMNS
around it.

Among the unused but not disabled code is code to access
some new system tables related to compressed columns.

The creation of these system tables SYS_ZIP_DICT and SYS_ZIP_DICT_COLS
would cause a crash in --innodb-read-only mode when upgrading
from an earlier version to 10.0.28 or 10.1.19.

Let us remove all the dead code related to compressed columns.
Users who already upgraded to 10.0.28 and 10.1.19 will have the two
above mentioned empty tables in their InnoDB system tablespace.
Subsequent versions of MariaDB Server will completely ignore those tables.
2017-01-03 19:32:47 +02:00
Marko Mäkelä
a758479c10 Post-fix for MDEV-11688 fil_crypt_threads_end() tries to create threads
fil_crypt_threads_cleanup(): Do nothing if nothing was initialized.
2017-01-03 15:47:23 +02:00
Marko Mäkelä
ba8198a34c Post-fix for MDEV-11688 fil_crypt_threads_end() tries to create threads
fil_crypt_threads_cleanup(): Do nothing if nothing was initialized.
2017-01-03 15:44:44 +02:00
Sachin Setiya
b4616c40be MDEV-7955 WSREP() appears on radar in OLTP RO
This commit is for optimizing WSREP(thd) macro.

#define WSREP(thd) \
  (WSREP_ON && wsrep && (thd && thd->variables.wsrep_on))

In this we can safely remove wsrep and thd. We are not removing WSREP_ON
because this will change WSREP(thd) behaviour.

Patch Credit:- Nirbhay Choubay, Sergey Vojtovich
2017-01-03 10:45:55 +05:30
Marko Mäkelä
9ebd767331 Merge 10.1 into 10.2 2016-12-30 13:48:22 +02:00
Marko Mäkelä
8451e09073 MDEV-11556 InnoDB redo log apply fails to adjust data file sizes
fil_space_t::recv_size: New member: recovered tablespace size in pages;
0 if no size change was read from the redo log,
or if the size change was implemented.

fil_space_set_recv_size(): New function for setting space->recv_size.

innodb_data_file_size_debug: A debug parameter for setting the system
tablespace size in recovery even when the redo log does not contain
any size changes. It is hard to write a small test case that would
cause the system tablespace to be extended at the critical moment.

recv_parse_log_rec(): Note those tablespaces whose size is being changed
by the redo log, by invoking fil_space_set_recv_size().

innobase_init(): Correct an error message, and do not require a larger
innodb_buffer_pool_size when starting up with a smaller innodb_page_size.

innobase_start_or_create_for_mysql(): Allow startup with any initial
size of the ibdata1 file if the autoextend attribute is set. Require
the minimum size of fixed-size system tablespaces to be 640 pages,
not 10 megabytes. Implement innodb_data_file_size_debug.

open_or_create_data_files(): Round the system tablespace size down
to pages, not to full megabytes, (Our test truncates the system
tablespace to more than 800 pages with innodb_page_size=4k.
InnoDB should not imagine that it was truncated to 768 pages
and then overwrite good pages in the tablespace.)

fil_flush_low(): Refactored from fil_flush().

fil_space_extend_must_retry(): Refactored from
fil_extend_space_to_desired_size().

fil_mutex_enter_and_prepare_for_io(): Extend the tablespace if
fil_space_set_recv_size() was called.

The test case has been successfully run with all the
innodb_page_size values 4k, 8k, 16k, 32k, 64k.
2016-12-30 09:52:24 +02:00
Marko Mäkelä
970f17cbfc Merge 10.1 into 10.2 2016-12-30 08:56:13 +02:00
Marko Mäkelä
341c375d4b Merge 10.1 into 10.2 2016-12-30 08:53:54 +02:00
Sergei Golubchik
4a5d25c338 Merge branch '10.1' into 10.2 2016-12-29 13:23:18 +01:00
Jan Lindström
283e9cf4cb MDEV-11656: 'Data structure corruption' IMPORT TABLESPACE doesn't work for encrypted InnoDB tables if space_id changed
Problem was that for encryption we use temporary scratch area for
reading and writing tablespace pages. But if page was not really
decrypted the correct updated page was not moved to scratch area
that was then written. This can happen e.g. for page 0 as it is
newer encrypted even if encryption is enabled and as we write
the contents of old page 0 to tablespace it contained naturally
incorrect space_id that is then later noted and error message
was written. Updated page with correct space_id was lost.

If tablespace is encrypted we use additional
temporary scratch area where pages are read
for decrypting readptr == crypt_io_buffer != io_buffer.

Destination for decryption is a buffer pool block
block->frame == dst == io_buffer that is updated.
Pages that did not require decryption even when
tablespace is marked as encrypted are not copied
instead block->frame is set to src == readptr.

If tablespace was encrypted we copy updated page to
writeptr != io_buffer. This fixes above bug.

For encryption we again use temporary scratch area
writeptr != io_buffer == dst
that is then written to the tablespace

(1) For normal tables src == dst ==  writeptr
ut_ad(!encrypted && !page_compressed ?
	src == dst && dst == writeptr + (i * size):1);
(2) For page compressed tables src == dst == writeptr
ut_ad(page_compressed && !encrypted ?
	src == dst && dst == writeptr + (i * size):1);
(3) For encrypted tables src != dst != writeptr
ut_ad(encrypted ?
	src != dst && dst != writeptr + (i * size):1);
2016-12-28 16:32:45 +02:00
Marko Mäkelä
d50cf42bc0 MDEV-9282 Debian: the Lintian complains about "shlib-calls-exit" in ha_innodb.so
Replace all exit() calls in InnoDB with abort() [possibly via ut_a()].
Calling exit() in a multi-threaded program is problematic also for
the reason that other threads could see corrupted data structures
while some data structures are being cleaned up by atexit() handlers
or similar.

In the long term, all these calls should be replaced with something
that returns an error all the way up the call stack.
2016-12-28 15:54:24 +02:00
Marko Mäkelä
545c912696 Remove an unnecessary comparison. 2016-12-22 15:10:39 +02:00
Marko Mäkelä
7e02fd1f71 MDEV-11630 Call mutex_free() before freeing the mutex list
Make some global fil_crypt_ variables static.

fil_close(): Call mutex_free(&fil_system->mutex) also in InnoDB, not
only in XtraDB. In InnoDB, sync_close() was called before fil_close().

innobase_shutdown_for_mysql(): Call fil_close() before sync_close(),
similar to XtraDB shutdown.

fil_space_crypt_cleanup(): Call mutex_free() to pair with
fil_space_crypt_init().

fil_crypt_threads_cleanup(): Call mutex_free() to pair with
fil_crypt_threads_init().
2016-12-22 14:33:58 +02:00
Sergei Golubchik
cba2ac6ef1 5.5.53-38.5 2016-12-22 13:06:44 +01:00
Monty
c51c885dee Fixed compiler warning 2016-12-21 22:41:07 +02:00
Marko Mäkelä
561b6d213c Revert "Merge pull request #275 from grooverdan/10.2-MDEV-11075-crc32-runtime-detect-getauxval"
This reverts commit edf4cc7519, reversing
changes made to 9320d8ae30.
2016-12-20 22:46:29 +02:00
Marko Mäkelä
a01bfc9fc2 MDEV-11602 InnoDB leaks foreign key metadata on DDL operations
Essentially revert MDEV-6759, which addressed a double free of memory
by removing the freeing altogether, introducing the memory leaks.
No double free was observed when running the test suite -DWITH_ASAN.

Replace some mem_heap_free(foreign->heap) with dict_foreign_free(foreign)
so that the calls can be located and instrumented more easily when needed.
2016-12-19 17:27:15 +02:00
Marko Mäkelä
44da95e5ed Merge branch '10.0' into 10.1 2016-12-19 17:15:25 +02:00
Marko Mäkelä
9f863a15b0 MDEV-11602 InnoDB leaks foreign key metadata on DDL operations
Essentially revert MDEV-6759, which addressed a double free of memory
by removing the freeing altogether, introducing the memory leaks.
No double free was observed when running the test suite -DWITH_ASAN.

Replace some mem_heap_free(foreign->heap) with dict_foreign_free(foreign)
so that the calls can be located and instrumented more easily when needed.
2016-12-19 15:57:41 +02:00
Jan Lindström
72cc73cea2 MDEV-10368: get_latest_version() called too often
Reduce the number of calls to encryption_get_key_get_latest_version
when doing key rotation with two different methods:

(1) We need to fetch key information when tablespace not yet
have a encryption information, invalid keys are handled now
differently (see below). There was extra call to detect
if key_id is not found on key rotation.

(2) If key_id is not found from encryption plugin, do not
try fetching new key_version for it as it will fail anyway.
We store return value from encryption_get_key_get_latest_version
call and if it returns ENCRYPTION_KEY_VERSION_INVALID there
is no need to call it again.
2016-12-13 11:51:33 +02:00
Daniel Black
e76183f099 MDEV-11075: Power - runtime detection of optimized instructions
Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
2016-12-12 15:35:08 +11:00
Sergei Golubchik
2f20d297f8 Merge branch '10.0' into 10.1 2016-12-11 09:53:42 +01:00
Marko Mäkelä
64d29c6575 Merge branch '10.2-MDEV-9872-crc32-generic-message' of https://github.com/grooverdan/mariadb-server into grooverdan-10.2-MDEV-9872-crc32-generic-message 2016-12-09 09:04:35 +02:00
Daniel Black
d04cb70cc3 Report any innodb_buf_pool_dump_pct restriction 2016-12-06 13:37:17 +11:00
Daniel Black
050a05bdb7 xtradb: new style ib_logf logging rather than stderr 2016-12-06 13:37:16 +11:00
Daniel Black
1e3f351e92 MDEV-11454: Make innodb_buffer_pool_dump_pct refer to the entire buffer pool size
Rather than innodb_buffer_pool_dump_pct referring to the percentage of hot data
in the buffer pool, it refers to the entire buffer pool size. This means that a
completed load followed by a shutdown will write the exact same data.

The problem was:

With innodb_buffer_pool_dump_pct say 25% (the default since 10.2.2), a server
started will restore 25% of the buffer pool size with the expectation that over
time the rest of the buffer pool will be populated. Then on shutdown 25% will
be saved.

If a server is started and then is shutdown a) without much activity occurring
b) is started as a hot spare and shutdown before being used, then 6.25% (25%
of 25%) of the buffer pool is saved.

This will generate bigger dump files for users who don't have a full
innodb_buffer_pool however a realistic scenario is a buffer pool should be
completely used.

Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
2016-12-06 13:37:05 +11:00
Marko Mäkelä
cc85ba8f2e MDEV-11233 CREATE FULLTEXT INDEX with a token longer than 127 bytes
crashes server

This bug is the result of merging the Oracle MySQL follow-up fix
BUG#22963169 MYSQL CRASHES ON CREATE FULLTEXT INDEX
without merging the base bug fix:
Bug#79475 Insert a token of 84 4-bytes chars into fts index causes
server crash.

Unlike the above mentioned fixes in MySQL, our fix will not change
the storage format of fulltext indexes in InnoDB or XtraDB
when a character encoding with mbmaxlen=2 or mbmaxlen=3
and the length of a word is between 128 and 84*mbmaxlen bytes.
The Oracle fix would allocate 2 length bytes for these cases.

Compatibility with other MySQL and MariaDB releases is ensured by
persisting the used maximum length in the SYS_COLUMNS table in the
InnoDB data dictionary.

This fix also removes some unnecessary strcmp() calls when checking
for the legacy default collation my_charset_latin1
(my_charset_latin1.name=="latin1_swedish_ci").

fts_create_one_index_table(): Store the actual length in bytes.
This metadata will be written to the SYS_COLUMNS table.

fts_zip_initialize(): Initialize only the first byte of the buffer.
Actually the code should not even care about this first byte, because
the length is set as 0.

FTX_MAX_WORD_LEN: Define as HA_FT_MAXCHARLEN * 4 aka 336 bytes,
not as 254 bytes.

row_merge_create_fts_sort_index(): Set the actual maximum length of the
column in bytes, similar to fts_create_one_index_table().

row_merge_fts_doc_tokenize(): Remove the redundant parameter word_dtype.
Use the actual maximum length of the column. Calculate the extra_size
in the same way as row_merge_buf_encode() does.
2016-12-05 16:32:03 +02:00
Marko Mäkelä
9199d72759 MDEV-11233 CREATE FULLTEXT INDEX with a token longer than 127 bytes
crashes server

This bug is the result of merging the Oracle MySQL follow-up fix
BUG#22963169 MYSQL CRASHES ON CREATE FULLTEXT INDEX
without merging the base bug fix:
Bug#79475 Insert a token of 84 4-bytes chars into fts index causes
server crash.

Unlike the above mentioned fixes in MySQL, our fix will not change
the storage format of fulltext indexes in InnoDB or XtraDB
when a character encoding with mbmaxlen=2 or mbmaxlen=3
and the length of a word is between 128 and 84*mbmaxlen bytes.
The Oracle fix would allocate 2 length bytes for these cases.

Compatibility with other MySQL and MariaDB releases is ensured by
persisting the used maximum length in the SYS_COLUMNS table in the
InnoDB data dictionary.

This fix also removes some unnecessary strcmp() calls when checking
for the legacy default collation my_charset_latin1
(my_charset_latin1.name=="latin1_swedish_ci").

fts_create_one_index_table(): Store the actual length in bytes.
This metadata will be written to the SYS_COLUMNS table.

fts_zip_initialize(): Initialize only the first byte of the buffer.
Actually the code should not even care about this first byte, because
the length is set as 0.

FTX_MAX_WORD_LEN: Define as HA_FT_MAXCHARLEN * 4 aka 336 bytes,
not as 254 bytes.

row_merge_create_fts_sort_index(): Set the actual maximum length of the
column in bytes, similar to fts_create_one_index_table().

row_merge_fts_doc_tokenize(): Remove the redundant parameter word_dtype.
Use the actual maximum length of the column. Calculate the extra_size
in the same way as row_merge_buf_encode() does.
2016-12-05 15:25:59 +02:00
Daniel Black
410bf82b98 MDEV-9872: Valgrind supports CRC32B and CRC32Q since valgrind-3.6.1
We don't need to drop down to unoptimized crc because of valgrind now.

Valgrind-3.6.1 was released 16 February 2011.

The Power8 ASM instructions seem to be supported in 3.9.0 (31 October 2013).

Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
2016-12-05 08:35:55 +11:00
Sergei Golubchik
f35b0d8ef8 Merge branch 'merge/merge-xtradb-5.6' into 10.0 2016-12-04 01:37:55 +01:00
Marko Mäkelä
33ed16c750 MDEV-11236 Failing assertion: state == TRX_STATE_NOT_STARTED
trx_state_eq(): Add the parameter bool relaxed=false, to
allow trx->state==TRX_STATE_NOT_STARTED where a different
state is expected, if an error has been reported.

trx_release_savepoint_for_mysql(): Pass relaxed=true to
trx_state_eq(). That is, allow the transaction to be idle
when ROLLBACK TO SAVEPOINT is attempted after an error
has been reported to the client.
2016-12-02 16:44:53 +02:00
Marko Mäkelä
f1b80d8ef1 MDEV-11236 Failing assertion: state == TRX_STATE_NOT_STARTED
trx_state_eq(): Add the parameter bool relaxed=false, to
allow trx->state==TRX_STATE_NOT_STARTED where a different
state is expected, if an error has been reported.

trx_release_savepoint_for_mysql(): Pass relaxed=true to
trx_state_eq(). That is, allow the transaction to be idle
when ROLLBACK TO SAVEPOINT is attempted after an error
has been reported to the client.
2016-12-02 16:25:47 +02:00
Marko Mäkelä
1e7f961d00 MDEV-9451 innodb_buffer_pool_populate does not seem to work on 10.1.10
Instead of interpreting --innodb-buffer-pool-populate as
--innodb-numa-interleave, display warning when the option is set,
saying that the option will be removed in MariaDB 10.2.3.
2016-12-02 15:57:34 +02:00
Sergei Golubchik
7436c3d6ab 5.6.34-79.1 2016-12-02 10:22:18 +01:00
sensssz
2fd3af4483 MDEV-11168: InnoDB: Failing assertion: !other_lock || wsrep_thd_is_BF(lock->trx->mysql_thd, FALSE) || wsrep_thd_is_BF(other_lock->trx->mysql_thd, FALSE)
Merged pull request:
Fix error in lock_has_higher_priority #266
https://github.com/MariaDB/server/pull/266

Added test case.
2016-12-02 11:08:18 +02:00
Daniel Black
6d1256973a MDEV-9872: crc32 initialization (innodb/xtradb)
Reorder logic as suggested by Svoj.

Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
2016-12-01 13:17:19 +11:00
Daniel Black
ba6af68c0f MDEV-9872: Generic CRC32 message using ptr
Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
2016-12-01 12:35:59 +11:00
Daniel Black
09b825bf71 MDEV-9451: Remove innodb_buffer_pool_populate from xtradb
innodb_buffer_pool_populate has not had an effect since 10.0.23
in commit 1e270d504d when its
functionality was removed.

As we've only just enabled LIBNUMA in MDEV-10829 it isn't logical
to have innodb_buffer_pool_populate aliasing for innodb_numa_interleave
this late in the game.

So the simpliest way is just to remove innodb_buffer_pool_populate.

Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
2016-12-01 09:17:00 +11:00
Jan Lindström
9f31949b64 MDEV-10739: encryption.innodb-page_encryption_compression fails with timeout on valgrind
Test moved to big_test and not run on valgrind. Test heavy especially on debug builds.
2016-11-29 08:35:51 +02:00
Marko Mäkelä
d247d64988 MDEV-11349 (2/2) Fix some bogus-looking Valgrind warnings
buf_block_init(): Initialize buf_page_t::flush_type.
For some reason, Valgrind 3.12.0 would seem to flag some
bits in adjacent bitfields as uninitialized, even though only
the two bits of flush_type were left uninitialized. Initialize
the field to get rid of many warnings.

buf_page_init_low(): Initialize buf_page_t::old.
For some reason, Valgrind 3.12.0 would seem to flag all 32
bits uninitialized when buf_page_init_for_read() invokes
buf_LRU_add_block(bpage, TRUE). This would trigger bogus warnings
for buf_page_t::freed_page_clock being uninitialized.
(The V-bits would later claim that only "old" is initialized
in the 32-bit word.) Perhaps recent compilers
(GCC 6.2.1 and clang 4.0.0) generate more optimized x86_64 code
for bitfield operations, confusing Valgrind?

mach_write_to_1(), mach_write_to_2(), mach_write_to_3():
Rewrite the assertions that ensure that the most significant
bits are zero. Apparently, clang 4.0.0 would optimize expressions
of the form ((n | 0xFF) <= 0x100) to (n <= 0x100). The redundant
0xFF was added in the first place in order to suppress a
Valgrind warning. (Valgrind would warn about comparing uninitialized
values even in the case when the uninitialized bits do not affect
the result of the comparison.)
2016-11-25 12:43:43 +02:00
Marko Mäkelä
cdaa1d768e MDEV-11349 (1/2) Fix some clang 4.0 warnings
In functions that declare pointer parameters as nonnull,
remove nullness checks, because GCC would optimize them away anyway.

Use #ifdef instead of #if when checking for a configuration flag.

Clang says that left shifts of negative values are undefined.
So, use ~0U instead of ~0 in a number of macros.

Some functions that were defined as UNIV_INLINE were declared as
UNIV_INTERN. Consistently use the same type of linkage.

ibuf_merge_or_delete_for_page() could pass bitmap_page=NULL to
buf_page_print(), conflicting with the __attribute__((nonnull)).
2016-11-25 12:43:34 +02:00
Marko Mäkelä
a68d1352b6 MDEV-11349 (2/2) Fix some bogus-looking Valgrind warnings
buf_block_init(): Initialize buf_page_t::flush_type.
For some reason, Valgrind 3.12.0 would seem to flag some
bits in adjacent bitfields as uninitialized, even though only
the two bits of flush_type were left uninitialized. Initialize
the field to get rid of many warnings.

buf_page_init_low(): Initialize buf_page_t::old.
For some reason, Valgrind 3.12.0 would seem to flag all 32
bits uninitialized when buf_page_init_for_read() invokes
buf_LRU_add_block(bpage, TRUE). This would trigger bogus warnings
for buf_page_t::freed_page_clock being uninitialized.
(The V-bits would later claim that only "old" is initialized
in the 32-bit word.) Perhaps recent compilers
(GCC 6.2.1 and clang 4.0.0) generate more optimized x86_64 code
for bitfield operations, confusing Valgrind?

mach_write_to_1(), mach_write_to_2(), mach_write_to_3():
Rewrite the assertions that ensure that the most significant
bits are zero. Apparently, clang 4.0.0 would optimize expressions
of the form ((n | 0xFF) <= 0x100) to (n <= 0x100). The redundant
0xFF was added in the first place in order to suppress a
Valgrind warning. (Valgrind would warn about comparing uninitialized
values even in the case when the uninitialized bits do not affect
the result of the comparison.)
2016-11-25 12:34:02 +02:00
Marko Mäkelä
8da33e3a86 MDEV-11349 (1/2) Fix some clang 4.0 warnings
In InnoDB and XtraDB functions that declare pointer parameters as nonnull,
remove nullness checks, because GCC would optimize them away anyway.

Use #ifdef instead of #if when checking for a configuration flag.

Clang says that left shifts of negative values are undefined.
So, use ~0U instead of ~0 in a number of macros.

Some functions that were defined as UNIV_INLINE were declared as
UNIV_INTERN. Consistently use the same type of linkage.

ibuf_merge_or_delete_for_page() could pass bitmap_page=NULL to
buf_page_print(), conflicting with the __attribute__((nonnull)).
2016-11-25 09:09:51 +02:00
Jan Lindström
03ddc19ab2 MDEV-6424: MariaDB server crashes with assertion failure in file ha_innodb.c line 11652
This is not a fix, this is instrumentation to find out is MySQL frm dictionary
and InnoDB data dictionary really out-of-sync when this assertion is fired,
or is there some other reason (bug).
2016-11-17 15:15:20 +02:00
Jan Lindström
1fee0171bc MDEV-10692: InnoDB: Failing assertion: lock->trx->lock.wait_lock == lock
When we enter here wait_lock could be already gone i.e. NULL, that
should be allowed.
2016-11-09 15:23:25 +02:00
Jan Lindström
8e5f532dc2 MDEV-10692: InnoDB: Failing assertion: lock->trx->lock.wait_lock == lock
This is not a fix, this is instrumentation to find the bug.
2016-11-09 13:32:43 +02:00
Jan Lindström
ea24480c4e Merge pull request #255 from rasmushoj/MDEV-9820
MDEV-9820 Added server variable compression_default, which if 1/ON sets compres…
2016-11-07 10:25:49 +02:00
Rasmus Johansson
bba224dd53 Added server variable compression_default, which if 1/ON sets compression on for all new InnoDB/XtraDB tables by default by setting PAGE_COMPRESSED=1 2016-11-04 13:33:37 +02:00
Nirbhay Choubey
7971360ffa Fix a build failure noticed on Yakkety. 2016-11-02 21:08:44 -04:00
Sergei Golubchik
a98c85bb50 Merge branch '10.0-galera' into 10.1 2016-11-02 13:44:07 +01:00
Daniel Black
58ac8dd255 MDEV-11195: Simplify enablement of NUMA in innodb/xtradb
Move common parts of {innodb,xtradb}/CmakeLists.txt to the macro.
2016-11-02 14:37:43 +11:00
Jan Lindström
9741e0ea72 Initialize zip_dict_ids table and avoid referencing array items
as currently MariaDB does not support compressed columns.
2016-11-01 07:52:28 +02:00
Daniel Black
ab0e5031e4 MDEV-11195: Correct enablement of NUMA in innodb/xtradb
No -DHAVE_LIBNUMA=1 was passed to the source compile (and the
global include/my_config.h wasn't used).

This also is Linux only so corrected the cmake macro.

Fixed indenting in cmake macro.

Removed NUMA defination from include/my_config.h as its only
in the storage engine.

Thanks Elena Stepanova and Vladislav Vaintroub for the detailed
list of bugs/questions.

Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
2016-11-01 11:09:47 +11:00
Jan Lindström
554c60ab0d MDEV-11182: InnoDB: Assertion failure in file buf0buf.cc line 4730 (encryption.create_or_replace fails in buildbot and outside)
Analysis: Problem is that page is encrypted but encryption information
on page 0 has already being changed.

Fix: If page header contains key_version != 0 and even if based on
current encryption information tablespace is not encrypted we
need to check is page corrupted. If it is not, then we know that
page is not encrypted. If page is corrupted, we need to try to
decrypt it and then compare the stored and calculated checksums
to see is page corrupted or not.
2016-10-31 12:44:06 +02:00
Jan Lindström
923a7f8675 MDEV-11188: rpl.rpl_parallel_partition fails with valgrind warnings in buildbot and outside 2016-10-31 12:16:53 +02:00
Sergey Vojtovich
71e11bce34 MDEV-8791 - AIX: Unresolved Symbols during linking
Clean-up nolock.h: it doesn't serve any purpose anymore. Appropriate code moved
to x86-gcc.h and my_atomic.h.

If gcc sync bultins were detected, we want to make use of them independently of
__GNUC__ definition. E.g. XLC simulates those, but doesn't define __GNUC__.

HS/Spider: According to AIX manual alloca() returns char*, which cannot be
casted to any type with static_cast. Use explicit cast instead.

MDL: Removed namemangling pragma, which didn't let MariaDB build with XLC.

WSREP: _int64 seem to be conflicting name with XLC, replaced with _integer64.

CONNECT: RTLD_NOLOAD is GNU extention. Removed rather meaningless check if
library is loaded. Multiple dlopen()'s of the same library are permitted,
and it never gets closed anyway. Except for error, which was a bug: it may
close library, which can still be referenced by other subsystems.

InnoDB: __ppc_get_timebase() is GNU extention. Only use it when __GLIBC__ is
defined.

Based on contribution by flynn1973.
2016-10-31 12:18:23 +04:00
Jan Lindström
de0f77a2a8 MDEV-11106: Improve error messages when importing tablespaces
Add error message when used index_id in index page is not found
from configuration file.
2016-10-29 10:09:06 +03:00
Jan Lindström
84ce681969 MDEV-10917: Warning suggesting that innodb_page_size is experimental may be inaccurate
Removed experimental from message.
2016-10-29 10:09:06 +03:00
Jan Lindström
885577fb10 MDEV-11004: Unable to start (Segfault or os error 2) when encryption key missing
Two problems:

(1) When pushing warning to sql-layer we need to check that thd != NULL
to avoid NULL-pointer reference.

(2) At tablespace key rotation if used key_id is not found from
encryption plugin tablespace should not be rotated.
2016-10-29 10:09:06 +03:00
Jan Lindström
bc323727de MDEV-10977: [ERROR] InnoDB: Block in space_id 0 in file ibdata1 encrypted.
MDEV-10394: Innodb system table space corrupted

Analysis: After we have read the page in buf_page_io_complete try to
find if the page is encrypted or corrupted. Encryption was determined
by reading FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION field from FIL-header
as a key_version. However, this field is not always zero even when
encryption is not used. Thus, incorrect key_version could lead situation where
decryption is tried to page that is not encrypted.

Fix: We still read key_version information from FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION
field but also check if tablespace has encryption information before trying
encrypt the page.
2016-10-29 10:09:06 +03:00
Nirbhay Choubey
5db2195a35 Merge tag 'mariadb-10.0.28' into 10.0-galera 2016-10-28 15:50:13 -04:00
Vladislav Vaintroub
ad5b88a892 Fix build error in XtraDB on Windows.
coming from Percona's workaround for glibc bug
http://bugs.mysql.com/bug.php?id=82886
2016-10-26 09:26:34 +00:00
Jan Lindström
ea0ae42d83 Merge pull request #250 from sensssz/10.1-vats
A few fixes for VATS in 10.1
2016-10-26 08:34:04 +03:00
sensssz
74961760a4 A few fixes for VATS in 10.1 2016-10-25 18:57:03 -04:00
Sergei Golubchik
675f27b382 Merge branch 'merge/merge-xtradb-5.6' into 10.0
commented out the "compressed columns" feature
2016-10-25 18:28:31 +02:00
Sergei Golubchik
d7dc03a267 5.6.33-79.0 2016-10-25 17:01:37 +02:00
Sergei Golubchik
12c3e16dfa Merge branch '5.5' into 10.0 2016-10-25 16:41:43 +02:00
Jan Lindström
4edd4ad698 MDEV-10970: Crash while loading mysqldump backup when InnoDB encryption is enabled
Follow-up: Make sure we do not reference NULL-pointer when space is being
dropped and does not contain any nodes.
2016-10-24 22:27:27 +03:00
Jan Lindström
021212b525 Merge pull request #245 from sensssz/10.1-vats
MDEV-11039 - Add new scheduling algorithm for reducing tail latencies
2016-10-24 21:51:42 +03:00
Jan Lindström
1bfa37a79c Add more information if encryption information is already stored for
tablespace but page0 is not yet read.
2016-10-24 16:55:36 +03:00
Jan Lindström
f35f61b5a9 Merge branch '10.2-numa' of https://github.com/grooverdan/mariadb-server into grooverdan-10.2-numa 2016-10-24 09:07:49 +03:00
Hyeonseok Oh
9401e6befd Remove unnecessary semicolons 2016-10-24 14:58:41 +09:00
Vladislav Vaintroub
ee1d08c115 Revert "Prepare XtraDB to be used with xtrabackup."
This reverts commit de5646f1a9.
2016-10-23 00:10:37 +00:00
Vladislav Vaintroub
de5646f1a9 Prepare XtraDB to be used with xtrabackup.
The changes are deliberately kept minimal

- some functions are made global instead of static (they will be used in
xtrabackup later on)

- functions got additional parameter, deliberately unused for now :
  fil_load_single_tablespaces
  srv_undo_tablespaces_init

- Global variables added, also unused for now :
   srv_archive_recovery
   srv_archive_recovery_limit_lsn
   srv_apply_log_only
   srv_backup_mode
   srv_close_files

- To make xtrabackup link with sql.lib on Windows, added some missing
  source files to sql.lib

- Fixed os_thread_ret_t to be DWORD on Windows
2016-10-22 14:10:12 +00:00
Kristian Nielsen
cc49f00994 Move InnoDB/XtraDB to async deadlock kill for parallel replication.
In 10.2, use the thd_rpl_deadlock_check() API. This way, all the
locking hacks around thd_report_wait_for() can be removed. Now
parallel replication deadlock kill happens asynchroneously, from the
slave background thread.

In InnoDB, remove also the buffering of wait reports, to simplify the
code, as this is no longer needed when the locking issues are gone.

In XtraDB, the buffering is kept for now. This is just because
presumably XtraDB will eventually be updated to MySQL 5.7-based InnoDB
as well, so there is little need to modify the existing code only for
clean-up purposes.

The old synchronous function thd_report_wait_for() is no longer used
and removed in this patch.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2016-10-17 12:52:14 +02:00
Sergei Golubchik
eac8d95ffc compilation warning after xtradb merge 2016-10-14 12:51:53 +02:00
Sergei Golubchik
e4957de4fd Merge branch 'merge-xtradb-5.5' into 5.5 2016-10-13 12:40:24 +02:00
Sergei Golubchik
6010a27c87 5.5.52-38.3 2016-10-13 12:23:16 +02:00
sensssz
183c02839f Move the lock after deadlock is resolved. 2016-10-13 01:23:21 -04:00
sensssz
0a769b00b5 Get thd by lock->trx->mysql_thd. 2016-10-12 21:54:31 -04:00
sensssz
5dc7ad87b8 Reduce conflict during in-order replication. 2016-10-12 21:52:14 -04:00
sensssz
288796f927 Bug fix: missing * and ; 2016-10-11 23:05:02 -04:00
sensssz
e93d44f2d7 Bug fix: add undeclared variables. 2016-10-11 23:02:26 -04:00
sensssz
6100f59ffa Implement VATS both in InnoDB and XtraDB. Add configuration options for it in both of them. 2016-10-11 20:52:35 -04:00
Alexander Barkov
5058ced5df MDEV-7769 MY_CHARSET_INFO refactoring# On branch 10.2
Part 3 (final): removing MY_CHARSET_HANDLER::well_formed_len().
2016-10-10 14:36:09 +04:00
Monty
c1125c3218 Fixed compiler warnings and failing tests 2016-10-05 01:11:08 +03:00
Sergei Golubchik
66d9696596 Merge branch '10.0' into 10.1 2016-09-28 17:55:28 +02:00
Sergei Petrunia
23af6f5942 Merge branch '10.0' of github.com:MariaDB/server into 10.0 2016-09-28 16:19:58 +03:00
Sergei Petrunia
66a58f46e9 Merge fix for MDEV-10649 from 10.0 to 10.1
- storage/innobase/dict/dict0stats.cc
- storage/xtradb/dict/dict0stats.cc
2016-09-28 16:19:05 +03:00
Sergei Petrunia
a53f3c6d3c MDEV-10649: Optimizer sometimes use "index" instead of "range" access for UPDATE
(Fixing both InnoDB and XtraDB)

Re-opening a TABLE object (after e.g. FLUSH TABLES or open table cache
eviction) causes ha_innobase to call
dict_stats_update(DICT_STATS_FETCH_ONLY_IF_NOT_IN_MEMORY).

Inside this call, the following is done:
  dict_stats_empty_table(table);
  dict_stats_copy(table, t);

On the other hand, commands like UPDATE make this call to get the "rows in
table" statistics in table->stats.records:

  ha_innobase->info(HA_STATUS_VARIABLE|HA_STATUS_NO_LOCK)

note the HA_STATUS_NO_LOCK parameter. It means, no locks are taken by
::info() If the ::info() call happens between dict_stats_empty_table
and dict_stats_copy calls, the UPDATE's optimizer will get an estimate
of table->stats.records=1, which causes it to pick a full table scan,
which in turn will take a lot of row locks and cause other bad
consequences.
2016-09-28 16:12:58 +03:00
Sergei Golubchik
bb8b658954 Merge branch 'merge/merge-xtradb-5.6' into 10.0 2016-09-27 18:58:57 +02:00
Sergei Golubchik
93ab3093cb 5.6.32-78.1 2016-09-27 18:00:59 +02:00
Jan Lindström
452e849522 MDEV-10886: encryption.innodb-bad-key-change fails (crashes) in buildbot
Problem was that NULL-pointer was accessed inside a macro when
page read from tablespace is encrypted but decrypt fails because
of incorrect key file.

Removed unsafe macro using inlined function where used pointers
are checked.
2016-09-27 07:54:27 +03:00
Jan Lindström
7d7b92c107 Disable encryption info and first page read info for every tablespace
on product builds.
2016-09-24 14:22:44 +03:00
Daniel Black
f05dfbebcc Merge 10.2
Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
2016-09-23 09:24:22 +10:00
Daniel Black
8e8e65ed1c MDEV-10829: innodb_numa_interleave=1, use numa numa_get_mems_allowed
Using numa_all_nodes_ptr was excessively optimistic. Due to
constraints in systemd, containers or otherwise mysqld could of been
limited to a smaller set of cpus. Use the numa_get_mems_allowed
library function to see what we can interleave between before doing
so. The alternative is to fail interleaving overall.

Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
2016-09-23 09:05:02 +10:00
Daniel Black
8103f6f223 MDEV-10829: Enable Innodb NUMA interleave
Code was already existing within the innobase/xtradb storage engines
however without this cmake code it was never enabled.

num.cmake heavily based off work by Annamalai Gurusami <annamalai.gurusami@oracle.com>

Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
2016-09-23 08:33:38 +10:00
Jan Lindström
1d55cfce10 Do not use os_file_read() directly for reading first page of the
tablespace. Instead use fil_read() with syncronous setting.
Fix test failures and mask tablespace number as it could
change in concurrent mtr runs.
2016-09-22 21:47:27 +03:00
Jan Lindström
2bedc3978b MDEV-9931: InnoDB reads first page of every .ibd file at startup
Analysis: By design InnoDB was reading first page of every .ibd file
at startup to find out is tablespace encrypted or not. This is
because tablespace could have been encrypted always, not
encrypted newer or encrypted based on configuration and this
information can be find realible only from first page of .ibd file.

Fix: Do not read first page of every .ibd file at startup. Instead
whenever tablespace is first time accedded we will read the first
page to find necessary information about tablespace encryption
status.

TODO: Add support for SYS_TABLEOPTIONS where all table options
encryption information included will be stored.
2016-09-22 16:38:24 +03:00
Sergei Golubchik
f9bdc7c01a Merge branch '10.2' into bb-10.2-jan 2016-09-19 09:47:08 +02:00
Sergei Golubchik
d019af402c misc after-merge changes:
* remove new InnoDB-specific ER_ and HA_ERR_ codes
* renamed few old ER_ and HA_ERR_ error messages to be less MyISAM-specific
* remove duplicate enum definitions (durability_properties, icp_result)
* move new mysql-test include files to their owner suite
* rename xtradb.rdiff files to *-disabled
* remove mistakenly committed helper perl module
* remove long obsolete handler::ha_statistic_increment() method
* restore the standard C xid_t structure to not have setters and getters
* remove xid_t::reset that was cleaning too much
* move MySQL-5.7 ER_ codes where they belong
* fir innodb to include service_wsrep.h not internal wsrep headers
* update tests and results
2016-09-10 16:04:44 +02:00
Sergei Golubchik
06b7fce9f2 Merge branch '10.1' into 10.2 2016-09-09 08:33:08 +02:00
Alexey Botchkov
225440047d MDEV-10421 duplicate CHECK CONSTRAINTs.
mysql_prepare_create_table fixed so it doesn't let duplicating
        constraint names. Syntax for CONSTRAINT IF NOT EXISTS added
        and handled in mysql_alter_table.
2016-09-06 14:42:33 +04:00
Sergei Golubchik
61fd38a1de update plugin maturities 2016-09-05 17:11:14 +02:00
Jan Lindström
2e814d4702 Merge InnoDB 5.7 from mysql-5.7.9.
Contains also

MDEV-10547: Test multi_update_innodb fails with InnoDB 5.7

	The failure happened because 5.7 has changed the signature of
	the bool handler::primary_key_is_clustered() const
	virtual function ("const" was added). InnoDB was using the old
	signature which caused the function not to be used.

MDEV-10550: Parallel replication lock waits/deadlock handling does not work with InnoDB 5.7

	Fixed mutexing problem on lock_trx_handle_wait. Note that
	rpl_parallel and rpl_optimistic_parallel tests still
	fail.

MDEV-10156 : Group commit tests fail on 10.2 InnoDB (branch bb-10.2-jan)
  Reason: incorrect merge

MDEV-10550: Parallel replication can't sync with master in InnoDB 5.7 (branch bb-10.2-jan)
  Reason: incorrect merge
2016-09-02 13:22:28 +03:00
Nirbhay Choubey
90266e8a0e Merge branch '10.0-galera' into bb-10.1-serg 2016-08-25 15:39:39 -04:00
Sergei Golubchik
6b1863b830 Merge branch '10.0' into 10.1 2016-08-25 12:40:09 +02:00
Nirbhay Choubey
c309e99ff9 Merge branch '10.0' into 10.0-galera 2016-08-24 19:30:32 -04:00
Vicențiu Ciorbaru
ed99e2cdd3 MDEV-10341: InnoDB: Failing assertion: mutex_own(mutex) - mutex_exit_func
Followup from 5.5 patch. Removing memory barriers on intel is wrong as
this doesn't prevent the compiler and/or processor from reorganizing reads
before the mutex release. Forcing a memory barrier before reading the waiters will
guarantee that no speculative reading takes place.
2016-08-23 21:24:36 +03:00
Nirbhay Choubey
3f481e52e4 Fixes for failing tests (post-merge). 2016-08-21 20:09:05 -04:00
sjaakola
415823a41c Refs: MW-279
- fixes in innodb to skip wsrep processing (like kill victim) when running in native mysql mode
- similar fixes in mysql server side
- forcing tc_log_dummy in native mysql mode when no binlog used. wsrep hton messes up handler counter
  and used to lead in using tc_log_mmap instead. Bad news is that tc_log_mmap does not seem to work at all
2016-08-21 16:20:09 -04:00
Sergei Golubchik
47a1087ff6 Merge branch 'bb-10.0-serg' into 10.0 2016-08-14 09:16:07 +02:00
Jan Lindström
9b23f8054d MDEV-10535: ALTER TABLE causes standalone/wsrep cluster crash
When checking is any of the renamed columns part of the
columns for new indexes we accessed NULL pointer if checked
column used on index was added on same statement. Additionally,
we tried to check too many indexes, added_index_count
is enough here.
2016-08-13 09:27:50 +03:00
Jan Lindström
b3df257cfd MDEV-10469: innodb.innodb-alter-tempfile fails in buildbot: InnoDB: Warning: database page corruption or a failed
Test case intentionally crashes the server and that could lead partially
written pages that are then restored from doublewrite buffer.
2016-08-13 09:27:50 +03:00
Sergei Golubchik
3863e72380 Merge branch 'merge/merge-xtradb-5.6' into 10.0
5.6.31-77.0
2016-08-10 19:55:45 +02:00
Sergei Golubchik
64752acf72 5.6.31-77.0 2016-08-10 19:24:58 +02:00
Sergei Golubchik
309c08c17c Merge branch '5.5' into 10.0 2016-08-10 19:19:05 +02:00
Vicențiu Ciorbaru
5ad02062d9 MDEV-10341: InnoDB: Failing assertion: mutex_own(mutex) - mutex_exit_func
Fix memory barrier issues on releasing mutexes. We must have a full
memory barrier between releasing a mutex lock and reading its waiters.
This prevents us from missing to release waiters due to reading the
number of waiters speculatively before releasing the lock. If threads
try and wait between us reading the waiters count and releasing the
lock, those threads might stall indefinitely.

Also, we must use proper ACQUIRE/RELEASE semantics for atomic
operations, not ACQUIRE/ACQUIRE.
2016-08-09 23:34:44 +03:00
Daniel Black
a2c826b6aa MDEV-9872: New Power8 crc32(ieee) optimized functions
These are different from the existing crc32 functions which
where really crc32c.
2016-08-05 11:50:46 +04:00
Sergey Vojtovich
9c2215e022 MDEV-9872 - Add common optimized CRC32 function interface
Move crc32-vpmsum to extra.
Compile static crc32-vpmsum instead of adding sources directly.
Make use of crc32-vpmsum via my_checksum().

Based on contribution by Daniel Black.
2016-08-04 10:45:20 +04:00
Oleksandr Byelkin
86975e0492 MDEV-7901: re-implement analyze table for low impact
Table before collecting engine independent statistics now is reopened in read mode,
InnoDB allow write operations in this case.
2016-08-03 21:37:19 +02:00
Sergei Golubchik
5265243cc4 Merge branch 'merge/merge-xtradb-5.5' into 5.5 2016-08-03 20:44:08 +02:00
Sergei Golubchik
e316c46f43 5.5.50-38.0 2016-08-03 20:43:29 +02:00
Jan Lindström
35c9c85634 MDEV-10217: innodb.innodb_bug59641 fails sporadically in buildbot: InnoDB: Failing assertion: current_rec != insert_rec in file page0cur.c line 1052
Added record printout when current_rec == insert_rec with lengths for
debug builds.
2016-08-03 13:46:01 +03:00
Hyeonseok Oh
558c8ce0f0 Remove unnecessary semicolon 2016-08-01 12:13:14 +09:00
Sergei Golubchik
326a8dcd87 Merge branch '10.0' into 10.1 2016-07-13 12:09:59 +02:00
Jan Lindström
406fe77763 Add more diagnostic to find out the problem on
innodb_shutdown_for_mysql in ppc64el on test
case innodb_fts.innodb_fts_stopword_charset.
2016-07-04 17:38:47 +03:00
Sergei Golubchik
5c764a0eb8 clarify ER_CANT_DROP_FIELD_OR_KEY
include the dropped object type
2016-07-02 14:52:20 +02:00
Sergei Golubchik
932646b1ff Merge branch '10.1' into 10.2 2016-06-30 16:38:05 +02:00
Nirbhay Choubey
10880d67b9 Postfix: memory leak in XtraDB 2016-06-30 10:24:54 -04:00
Michael Widenius
db7edfed17 MDEV-7563 Support CHECK constraint as in (or close to) SQL Standard
MDEV-10134 Add full support for DEFAULT

- Added support for using tables with MySQL 5.7 virtual fields,
  including MySQL 5.7 syntax
- Better error messages also for old cases
- CREATE ... SELECT now also updates timestamp columns
- Blob can now have default values
- Added new system variable "check_constraint_checks", to turn of
  CHECK constraint checking if needed.
- Removed some engine independent tests in suite vcol to only test myisam
- Moved some tests from 'include' to 't'. Should some day be done for all tests.
- FRM version increased to 11 if one uses virtual fields or constraints
- Changed to use a bitmap to check if a field has got a value, instead of
  setting HAS_EXPLICIT_VALUE bit in field flags
- Expressions can now be up to 65K in total
- Ensure we are not refering to uninitialized fields when handling virtual fields or defaults
- Changed check_vcol_func_processor() to return a bitmap of used types
- Had to change some functions that calculated cached value in fix_fields to do
  this in val() or getdate() instead.
- store_now_in_TIME() now takes a THD argument
- fill_record() now updates default values
- Add a lookahead for NOT NULL, to be able to handle DEFAULT 1+1 NOT NULL
- Automatically generate a name for constraints that doesn't have a name
- Added support for ALTER TABLE DROP CONSTRAINT
- Ensure that partition functions register virtual fields used. This fixes
  some bugs when using virtual fields in a partitioning function
2016-06-30 11:43:02 +02:00
Sergei Golubchik
8354c0c4d6 Merge remote-tracking branch 'refs/remotes/github/10.1' into 10.1 2016-06-28 22:13:59 +02:00
Sergei Golubchik
3361aee591 Merge branch '10.0' into 10.1 2016-06-28 22:01:55 +02:00
Jan Lindström
e786a57255 Output more information when assertion
ut_a(state == BUF_BLOCK_NOT_USED
     || state == BUF_BLOCK_REMOVE_HASH);
is hit.
2016-06-28 17:27:47 +03:00
Nirbhay Choubey
f629f53548 Fix memory leak in XtraDB. 2016-06-27 14:44:07 -04:00
Alexey Botchkov
09d902d84b MDEV-9618 solaris sparc build fails on 10.1.
Compiler on Sparc is strict about the 'const' modifiers
    in function declarations and definitions. Meaning
    they should be exactly same.
2016-06-27 18:02:28 +04:00
Nirbhay Choubey
fc799e317d Fix build failure. 2016-06-24 13:54:04 -04:00
Nirbhay Choubey
14d62505d9 Merge tag 'mariadb-10.0.26' into 10.0-galera 2016-06-24 12:01:22 -04:00
Monty
4dc5075860 Fixed compiler warnings and test failures found by buildbot
Fixed ccfilter to detect errors where the column is included in the error message
2016-06-24 02:25:14 +03:00
Jan Lindström
26de9061e8 Merge following commit from 5.5:
commit ef92aaf9ec
Author: Jan Lindström <jan.lindstrom@mariadb.com>
Date:   Wed Jun 22 22:37:28 2016 +0300

    MDEV-10083: Orphan ibd file when playing with foreign keys

    Analysis: row_drop_table_for_mysql did not allow dropping
    referenced table even in case when actual creating of the
    referenced table was not successfull if foreign_key_checks=1.

    Fix: Allow dropping referenced table even if foreign_key_checks=1
    if actual table create returned error.
2016-06-23 07:42:40 +03:00
Jan Lindström
ef92aaf9ec MDEV-10083: Orphan ibd file when playing with foreign keys
Analysis: row_drop_table_for_mysql did not allow dropping
referenced table even in case when actual creating of the
referenced table was not successfull if foreign_key_checks=1.

Fix: Allow dropping referenced table even if foreign_key_checks=1
if actual table create returned error.
2016-06-23 06:46:05 +03:00
Monty
e4062d4d20 Fixed compiler warnings
Added my_global.h to PerconeFT to avoid "error <my_config.h> MUST be included first"
2016-06-22 22:04:55 +03:00
Sergei Golubchik
805703fa8e Fixed for failures in buildbot: Windows
fix constants to stay 64-bit instead of being truncated by VS.
this fixes a hang on startup.
2016-06-22 10:40:28 +02:00
Sergei Golubchik
b3f4cf7c13 Merge branch 'merge-xtradb-5.6' into 0.0 2016-06-21 15:27:09 +02:00
Sergei Golubchik
b42664e85e 5.6.30-76.3 2016-06-21 14:20:09 +02:00
Sergei Golubchik
c081c978a2 Merge branch '5.5' into bb-10.0 2016-06-21 14:11:02 +02:00
Elena Stepanova
cc3190e367 Follow-up for MDEV-6720 (enable connection log in mysqltest by default)
Some rdiff files in storage_engine test suite need to be updated accordingly
2016-06-19 20:30:03 +03:00
Sergei Golubchik
260699e91b Merge branch 'merge-xtradb-5.5' into 5.5 2016-06-14 13:59:41 +02:00
Sergei Golubchik
f54dcf1e87 5.5.49-37.9 2016-06-14 12:38:47 +02:00
Otto Kekäläinen
effbe7dd7b General spell fixing in comments and strings 2016-06-08 14:17:23 +03:00
Jan Lindström
0f252702b1 MDEV-7139: Sporadic failure in innodb.innodb_corrupt_bit on P8
Use direct persistent index corruption set on InnoDB dictionary
for this test. Do not allow creating new indexes if one of the
existing indexes is already marked as corrupted.
2016-06-08 08:40:10 +03:00
Alexey Kopytov
49ad084503 Few improvements related to CPU cache line size and padding:
Bug #79636: CACHE_LINE_SIZE should be 128 on AArch64
Bug #79637: Hard-coded cache line size
Bug #79638: Reconcile CACHE_LINE_SIZE with CPU_LEVEL1_DCACHE_LINESIZE
Bug #79652: Suspicious padding in srv_conc_t

- changed CPU_LEVEL1_DCACHE_LINESIZE to default to 128 bytes on POWER
  and AArch64 architectures in cases when no value could be detected
  by CMake using getconf

- changed CACHE_LINE_SIZE definition in ut0counter.h to be an alias of
  CPU_LEVEL1_DCACHE_LINESIZE

- changed a number of hard-coded 64-byte cache line size values in the
  InnoDB code

- fixed insufficient padding for srv_conc members in srv0conc.cc

Ported to Mariadb by Daniel Black <daniel.black@au.ibm.com>
Added s390 cache size of 256 at same time.
2016-06-07 13:02:31 +04:00
Jan Lindström
66dd9fa397 Merge pull request #174 from Cona19/10.1
MDEV-10154 - Remove some unnecessary parentheses
2016-06-02 11:46:35 +03:00
Daniel Black
a0b11b9033 Remove btr_search_n_succ and btr_search_n_hash_fail counters 2016-06-02 17:03:31 +10:00
Vladislav Vaintroub
3a7bc23a16 MDEV-9154 : Remove workarounds (mainly dynamic function loading)
for running obsolete versions of Windows
2016-06-01 20:29:10 +02:00
Hyeonseok Oh
500b03fe30 Fix spelling: shhould -> should 2016-06-01 06:09:13 +00:00
Nirbhay Choubey
de7eafc7ce MDEV-6368: assertion xid_seqno > trx_sys_cur_xid_seqno
- Validate the specified wsrep_start_position value by also
checking the return status of wsrep->sst_received. This also
ensures that changes in wsrep_start_position is not allowed
when the node is not in JOINING state.
- Do not allow decrease in seqno within same UUID.
- The initial checkpoint in SEs should be [0...:-1].
2016-05-31 20:37:00 -04:00
Hyeonseok Oh
389c51f4bd Remove some unnecessary parentheses 2016-05-26 10:33:17 +00:00
Jan Lindström
5534d81430 Merged following change from MySQL 5.6 to MariaDB 10.1 XtraDB
including the test case:

https://github.com/mysql/mysql-server/commit/520aedfe
INNODB: "DATA DIRECTORY" OPTION OF CREATE TABLE FAILS WITH PWRITE() OS
ERROR 22
Fix for version mysql-5.6
PROBLEM
========
For version mysql-5.6.27 onwards InnoDB fails to create a table
with explicit 'data directory' option when Innodb_flush_method
is set to O_DIRECT.While creating link file we get a  a pwrite
error 22 due to the alignment restrictions imposed by O_DIRECT
flag  which is being set for the link file created.

FIX
===
Fixed the above issue by making use of file IO functions while
creating the link file that wouldn't let the O_DIRECT flag
restrictions arise.

Reviewed-by: Kevin Lewis <kevin.lewis@oracle.com>
Reviewed-by: Shaohua Wang <shaohua.wang@oracle.com>
RB: 11387
2016-05-06 13:56:25 +03:00