Commit graph

6463 commits

Author SHA1 Message Date
Marko Mäkelä
ef44ec4afa Merge 10.2 into 10.3 2019-07-19 12:31:56 +03:00
Eugene Kosov
9c29d06862 MDEV-20097 potential use-after-free
row_merge_read_clustered_index(): fix one more place with buf and merge_buf[i]
2019-07-19 11:42:08 +03:00
Marko Mäkelä
6a55aeb2af Merge 10.1 into 10.2 2019-07-18 23:38:48 +03:00
Eugene Kosov
5b205458d9 MDEV-20097 potential use-after-free
row_merge_read_clustered_index(): make buf always equals to merge_buf[i]
2019-07-18 22:28:11 +03:00
Marko Mäkelä
e55cc2d8cc Merge 10.1 into 10.2
MDEV-20094 was filed for the unexpected result differences for the test
innodb.check_ibd_filesize.
2019-07-18 18:01:04 +03:00
Marko Mäkelä
adbab0d4cd MDEV-13625: Add the test innodb.innodb-wl5980-debug 2019-07-18 17:01:59 +03:00
Marko Mäkelä
6962855185 Merge 10.1 into 10.2 2019-07-18 13:10:09 +03:00
Eugene Kosov
0f83c8878d Merge 10.2 into 10.3 2019-07-16 18:39:21 +03:00
Thirunarayanan Balathandayuthapani
aba2b41e9e MDEV-19978 Page read from tablespace is corrupted
Problem:
=======
  Checksum fields can have value as zero. In that case, InnoDB falsely
consider that page should be all zeroes. It leads to wrong detection of page
corruption.

Solution:
========
	Remove the condition that checks if checksum fields are zero then
page should be all zeroes.
2019-07-11 18:25:25 +05:30
Thirunarayanan Balathandayuthapani
07b1a26c33 MDEV-19630 ALTER TABLE ... ADD COLUMN damages foreign keys
which are pointed to the table being altered
Problem:
========
	InnoDB failed to change the column name present in foreign key cache
for instant add column. So it leads to column mismatch for the consecutive
rename of column.

Solution:
=========
	Evict the foreign key information from cache and load the foreign
key information again for instant operation.
2019-07-10 13:24:10 +05:30
Thirunarayanan Balathandayuthapani
7df17ca8aa MDEV-19974 InnoDB: Cannot load compressed BLOB
Problem:
=======
	During online alter, fts tokenization thread uses new table page size
to read the externally stored page from old table. If the alter changes
the page size then it leads to failure of alter table.

Solution:
=========
	fts tokenization thread should use old table page size to read the
externally stored page from old table.
2019-07-10 13:21:40 +05:30
Thirunarayanan Balathandayuthapani
64900e3d7c MDEV-15641 InnoDB crash while committing table-rebuilding ALTER TABLE
Problem:
========
 There is a possibility that there can be more concurrent DMLs While the
alter table thread is waiting for upgrading to MDL_EXCLUSIVE before commit phase.
In commit phase, InnoDB acquires dict_operation_lock and it already holds MDL_EXCLUSIVE
on the table. After that, InnoDB applies the concurrent DML logs in commit phase.
This could lead to blocking of the following things:

  1) DML on the particular table (due to MDL_EXCLUSIVE on the table)
  2) InnoDB DDLs (due to dict_operation_lock)
  3) Purge thread, stats thread, the master thread (due to dict_operation_lock)

Fix:
====
Apply the concurrent DML logs in commit phase but before acquiring
dict_operation_lock in commit phase. It makes sure that (2), (3) can't be
blocked for longer time.
2019-07-10 12:43:51 +05:30
Eugene Kosov
26c389b7b7 Merge 10.1 into 10.2 2019-07-09 13:22:22 +03:00
Aleksey Midenkov
cf7a8b9eb2 MDEV-16222 Assertion `0' failed in row_purge_remove_sec_if_poss_leaf on table with virtual columns and indexes
Cause
Stale thd->m_stmt_da->m_sql_errno which is from different invocation.

Fix
Reset error state before attempt to open table.
2019-07-09 10:01:54 +03:00
Aleksey Midenkov
53dd0e4f75 MDEV-16222 Assertion `0' failed in row_purge_remove_sec_if_poss_leaf on table with virtual columns and indexes
Cause
Stale thd->m_stmt_da->m_sql_errno which is from different invocation.

Fix
Reset error state before attempt to open table.
2019-07-08 20:14:51 +03:00
Eugene Kosov
5ebef42238 MDEV-19292 "Row size too large" error when creating table with lots columns when row format is DYNAMIC or COMPRESSED
Basic idea of the patch: disallow creating tables which allow to create
rows which are too big to insert. In other words, if user created a table user
should never see an errors like 'can not insert row as it is too big for current
page size'.

SET innodb_strict_mode=OFF; will allow to create very long tables and only a
warning will be issued.

dict_table_t::get_overflow_field_local_len(): this function lets know a maximum
local field len for overflow fields for every file and row format.

innobase_check_column_length(): improve name to too_big_key_part_length()
and reuse in a different part of code.

create_table_info_t::prepare_create_table(): add check for maximum allowed
key part length to keep ALGORITHM=COPY behavior similar to ALGORITHM=INPLACE
behavior. Affected test is innodb.strict_mode

Rename dict_index_too_big_for_tree() to
dict_index_t::rec_potentially_too_big(): copy overflow-related size computation
from dtuple_convert_big_rec(). A lot of tests was changed because of that.
I wonder whether users will complain about it?

Test innodb.max_record_size tests dict_index_t::rec_potentially_too_big()
for different row formats and page sizes.
2019-07-05 17:02:21 +03:00
Marko Mäkelä
a946b36601 Fix the compilation after the parent commit
Up to MariaDB 10.2, field_name is still a C-style string.
2019-07-02 22:25:48 +03:00
Marko Mäkelä
1d45b3b055 Merge 10.2 into 10.3 2019-07-02 21:41:40 +03:00
Marko Mäkelä
c1cb5c17be MDEV-19869: Correct the logic, and avoid type mismatch 2019-07-02 21:40:34 +03:00
Marko Mäkelä
e82fe21e3a Merge 10.2 into 10.3 2019-07-02 17:46:22 +03:00
Marko Mäkelä
6bb922e58e MDEV-13626: Import and adjust innodb.blob-crash 2019-07-02 15:18:12 +03:00
Jan Lindström
b105427745 MDEV-19660: wsrep_rec_get_foreign_key() is dereferencing a stale pointer to a page that was previously latched
In row_ins_foreign_check_on_constraint(), clustered index record is being passed to wsrep_append_foreign_key() after releasing the latch. If a record has been changed by other thread in the meantime then it could lead to a crash when
wsrep_rec_get_foreign_key () tries to access the record.

row_ins_foreign_check_on_constraint
	Use cascade->pcur->old_rec instead of clust_rec.

row_ins_check_foreign_constraint
	Add missing error printout.
2019-07-02 10:06:13 +03:00
Thirunarayanan Balathandayuthapani
41f6e68878 MDEV-19781 Add page id matching check in innochecksum tool
- Changed the assert to ignore SRV_LOG_SPACE_FIRST_ID. Post push
fix to address the previous commit failure.
2019-07-01 21:58:20 +05:30
Marko Mäkelä
0e1ba364a1 MDEV-19916 Corruption after instant ADD/DROP and shrinking the tree
btr_lift_page_up(): Correct the incorrect condition.

page_validate(): Validate the page type.
2019-07-01 18:24:54 +03:00
Marko Mäkelä
92bbf4f53d MDEV-19916: Improve page_validate()
page_validate(): Validate also the page type, and try to list all
errors that were encountered for the page, with a little more detail.
2019-07-01 18:24:35 +03:00
Thirunarayanan Balathandayuthapani
40c1f4bd4c MDEV-19781 Add page id matching check in innochecksum tool
Changed the debug insert inside fil_io() to check whether it writes
the page to wrong offset only for user tablespace.
2019-07-01 20:21:26 +05:30
Thirunarayanan Balathandayuthapani
dca9792a24 MDEV-17228 Encrypted temporary tables are not encrypted
- log_crypt_init() should be called from create_log_files(). Because
it should re-create the new random nonce compared to the old ones.
2019-07-01 18:50:44 +05:30
Marko Mäkelä
5a136d84f3 MDEV-19766: Disable page dump output in debug builds
The test innodb.leaf_page_corrupted_during_recovery
fails on buildbot with

Warning	1406	Data too long for column 'line' at row 10
line
 len 16384; hex ...

because of a page dumps that InnoDB is generating for a corrupted page

Since this test is using debug instrumentation, we will solve the
issue by disabling page dumps in debug builds altogether. Users of
debug builds will likely know how to extract page dumps in other means.

Page dump output could sometimes be useful when diagnosing problems
that users are facing. Hence we will keep the page dump output in
non-debug (release) builds.
2019-07-01 13:27:12 +03:00
Thirunarayanan Balathandayuthapani
85d0a1955f MDEV-19914 Server startup fails while dropping garbage encrypted tablespace if innodb_encryption_threads > 0
- Avoiding accessing encryption thread mutex before initiating
the encryption threads
2019-07-01 15:21:17 +05:30
Thirunarayanan Balathandayuthapani
ed6da51f3e MDEV-19869 Port innodb_fts.fulltext2 from mysql to mariadb.
- Ported mysql Bug#20597981 test case to mariadb-10.2
- InnoDB never used fts_doc_id_in_read_set. Basically it tells
innodb to read the fts_doc_id from the index record itself.
2019-07-01 13:46:56 +05:30
Thirunarayanan Balathandayuthapani
723a4b1d78 MDEV-17228 Encrypted temporary tables are not encrypted
- Introduce a new variable called innodb_encrypt_temporary_tables which is
a boolean variable. It decides whether to encrypt the temporary tablespace.
- Encrypts the temporary tablespace based on full checksum format.
- Introduced a new counter to track encrypted and decrypted temporary
tablespace pages.
- Warnings issued if temporary table creation has conflict value with
innodb_encrypt_temporary_tables
- Added a new test case which reads and writes the pages from/to temporary
tablespace.
2019-06-28 19:07:59 +05:30
Thirunarayanan Balathandayuthapani
e4a0dbfb4a MDEV-19781 Add page id matching check in innochecksum tool
Added the condition in innochecksum tool to check page id mismatch.
This could catch the write corruption caused by InnoDB.

Added the debug insert inside fil_io() to check whether it writes
the page to wrong offset.
2019-06-28 18:58:52 +05:30
Marko Mäkelä
92feac53a6 MDEV-19886 InnoDB returns misleading ER_NO_SUCH_TABLE_IN_ENGINE
A fix in MySQL 5.7.6 was not completely merged to MariaDB:
Bug#19419026 WHEN A TABLESPACE IS NOT FOUND, DO NOT REPORT "TABLE NOT FOUND"
2019-06-27 15:39:04 +03:00
Marko Mäkelä
f5c080c735 MDEV-19845: Fix the build on some platforms
On some platforms, MY_RELAX_CPU() falls back to an atomic
memory operation, but my_cpu.h fails to include my_atomic.h.
2019-06-27 15:04:00 +03:00
Marko Mäkelä
042fc29597 MDEV-19845: Adaptive spin loops
Starting with the Intel Skylake microarchitecture, the PAUSE
instruction latency is about 140 clock cycles instead of earlier 10.
On AMD processors, the latency could be 10 or 50 clock cycles,
depending on microarchitecture.

Because of this big range of latency, let us scale the loops around
the PAUSE instruction based on timing results at server startup.

my_cpu_relax_multiplier: New variable: How many times to invoke PAUSE
in a loop. Only defined for IA-32 and AMD64.

my_cpu_init(): Determine with RDTSC the time to run 16 PAUSE instructions
in two unrolled loops according, and based on the quicker of the two
runs, initialize my_cpu_relax_multiplier. This form of calibration was
suggested by Mikhail Sinyavin from Intel.

LF_BACKOFF(), ut_delay(): Use my_cpu_relax_multiplier when available.

ut_delay(): Define inline in my_cpu.h.

UT_COMPILER_BARRIER(): Remove. This does not seem to have any effect,
because in our ut_delay() implementation, no computations are being
performed inside the loop. The purpose of UT_COMPILER_BARRIER() was to
prohibit the compiler from reordering computations. It was not
emitting any code.
2019-06-27 10:53:18 +03:00
Eugene Kosov
d36c107a6b imporve clang build
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug

Maintainer mode makes all warnings errors. This patch fix warnings. Mostly about
deprecated `register` keyword.

Too much warnings came from Mroonga and I gave up on it.
2019-06-25 13:21:36 +03:00
Eugene Kosov
ddeeb42e0b Merge 10.1 into 10.2 2019-06-23 20:33:13 +03:00
Eugene Kosov
cf40393471 Merge 5.5 into 10.1 2019-06-20 12:26:01 +03:00
Marko Mäkelä
192aa295b4 Merge 10.2 into 10.3 2019-06-19 08:56:10 +03:00
Nikita Malyavin
a626abb669 Fix LEX_CSTRING passed as argument of printf-like functions 2019-06-17 19:31:17 +10:00
Marko Mäkelä
2b660fb4c2 mtr_t::is_block_dirtied(): Define inline 2019-06-16 15:55:09 +03:00
Marko Mäkelä
a94638f155 Clarify the purpose of MTR_LOG_NONE 2019-06-16 15:54:14 +03:00
Marko Mäkelä
e9795d0208 Add mtr_buf_t::for_each_block_in_reverse() const
Avoid unnecessary creation of named objects for invoking
mtr_buf_t::for_each_block_in_reverse().
2019-06-16 15:53:06 +03:00
Oleksandr Byelkin
4a3d51c76c Merge branch '10.2' into 10.3 2019-06-14 07:36:47 +02:00
Oleksandr Byelkin
50653e021f Merge branch '10.1' into 10.2 2019-06-13 16:42:21 +02:00
Thirunarayanan Balathandayuthapani
e9145aab44 MDEV-19435 buf_fix_count > 0 for corrupted page when it exits the LRU list
Problem:
=========
One of the purge thread access the corrupted page and tries to remove from
LRU list. In the mean time, other purge threads are waiting for same page
in buf_wait_for_read(). Assertion(buf_fix_count == 0) fails for the
purge thread which tries to remove the page from LRU list.

Solution:
========
- Set the page id as FIL_NULL to indicate the page is corrupted before
removing the block from LRU list. Acquire hash lock for the particular
page id and wait for the other threads to release buf_fix_count
for the block.

- Added the error check for btr_cur_open() in row_search_on_row_ref().
2019-06-13 16:13:51 +03:00
Oleksandr Byelkin
5b65d61d93 Merge branch '5.5' into 10.1 2019-06-12 22:54:46 +02:00
Eugene Kosov
039b8782d4 MDEV-13631 Make use of clang-format
Explicitly mention every options in .clang-format to protect us from possible
future changes.

Remove separate InnoDB style.

Change style to look more like this script:
for x in $@
do
 indent -kr -bl -bli0 -l79 -i2 -nut -c48 -dj -cp0 $x
 sed -ri -e 's/ = /= /g'\
         -e '/switch.*\)$/{N;s/\n[ ]+/ /}' $x
done

Significant different is that 'switch' and '{' are put on different lines
because it's impossible in clang-format to set formatting rules just for
'switch' statement.
2019-06-12 22:36:43 +03:00
Marko Mäkelä
94e665596d MDEV-19740: Remove some broken InnoDB systemd code
GCC 9.1.1 noticed that sd_notifyf() was always being invoked with
str=NULL argument for "%s". This code was added in
commit 2e814d4702
but not mentioned in the commit comment.

The STATUS messages for systemd matter during startup and shutdown,
and should not be emitted during normal operation.

ib_senderrf(): Remove the potentially harmful sd_notifyf() calls.
2019-06-12 16:25:55 +03:00
Thirunarayanan Balathandayuthapani
b2f76bac03 MDEV-16866 InnoDB fails to start upon crash recovery with "[ERROR] InnoDB: Redo log crypto: failed to decrypt log block"
- Post-push fix to change the copyright of both xtradb and innodb file.
2019-06-12 12:25:00 +05:30