Commit graph

183217 commits

Author SHA1 Message Date
Oleksandr Byelkin
cb4da5da74 MDEV-20604: Duplicate key value is silently truncated to 64 characters in print_keydup_error
Added indication of truncated string for "s" and "M" formats
2020-04-01 11:34:32 +02:00
Marko Mäkelä
a1846b7a64 MDEV-22035 Memory leak in main.mysqltest
The test main.mysqltest could crash or hang with
cmake -DWITH_ASAN=ON builds. The reason appears to be
a memory leak, which was found out by manually invoking

echo --replace_regex a > file
ASAN_OPTIONS=log_path=/dev/shm/asan mysqltest ... < file

and then examining the /dev/shm/asan.* file.
2020-04-01 12:08:45 +03:00
Marko Mäkelä
bc862c4ebe Merge 10.1 into 10.2 2020-04-01 09:19:37 +03:00
Marko Mäkelä
b1742a5c95 MDEV-13626: Improve innodb.xa_recovery_debug
Improve the test that was imported and adapted for MariaDB in
commit fb217449dc.

row_undo_step(): Move the DEBUG_SYNC point from trx_rollback_for_mysql().
This DEBUG_SYNC point is executed after rolling back one row.

trx_rollback_for_mysql(): Clarify the comments that describe the scenario,
and remove the DEBUG_SYNC point.

If the statement "if (trx->has_logged_persistent())" and its body are
removed from trx_rollback_for_mysql(), then the test
innodb.xa_recovery_debug will fail because the transaction would still
exist in the XA PREPARE state. If we allow the XA COMMIT statement
to succeed in the test, we would observe an incorrect state of the
XA transaction where the table would contain row (1,NULL). Depending
on whether the XA transaction was committed, the table should either
be empty or contain the record (1,1). The intermediate state of
(1,NULL) should never be observed after completed recovery.
2020-04-01 09:13:01 +03:00
Marko Mäkelä
fb217449dc MDEV-13626: Import and adapt innodb.xa_recovery_debug
Adapt the test that was added in
mysql/mysql-server@6b65d9032c
but omitted in commit 2e814d4702.

Instead of triggering a log checkpoint, we will only trigger
a redo log flush before killing the server.
Note: the mtr.commit() call in trx_rollback_for_mysql()
will not actually make the undo log header page state change durable.
A call to log_write_up_to(mtr.commit_lsn(), true) would do that.

It is unclear what the originally reported bug scenario was.
As long as innobase_rollback_by_xid() will not return without
ensuring that the redo log has been durably written, we should be safe.
2020-03-31 15:10:54 +03:00
mkaruza
2d16452a31 MDEV-22021: Galera database could get inconsistent with rollback to savepoint
When binlog is disabled, WSREP will not behave correctly when
SAVEPOINT ROLLBACK is executed since we don't register handlers for such case.
Fixed by registering WSREP handlerton for SAVEPOINT related commands.
2020-03-31 09:59:37 +03:00
Eugene Kosov
5001487632 MDEV-22074 UBSAN: applying zero offset to null pointer in hash.c
The fix: return fast when no work should be performed.
2020-03-31 00:44:01 +03:00
Eugene Kosov
edd7e7c85d MDEV-22069 UBSAN: runtime error: member access within null pointer of type 'MY_DIR_HANDLE' in mysys/my_lib.c
This is an error handling bug. When opendir() fails dirh is NULL and
we shouldn't try to free it.
2020-03-31 00:44:01 +03:00
Varun Gupta
b11ff3d495 MDEV-22019: Sig 11 in next_breadth_first_tab | max_sort_length setting + double GROUP BY leads to crash
No need to create a temp table for aggregation if we have encountered some error.
2020-03-30 08:03:54 +05:30
Eugene Kosov
0b00c1a22f MDEV-22005 UBSAN: applying non-zero offset 2 to null pointer in my_charpos_mb()
Empty comment has a correct length.
2020-03-26 18:33:47 +03:00
Oleksandr Byelkin
f9639c2d1a MDEV-22037: Add ability to skip content of some tables (work around for MDEV-20939)
--ignore-table-data parameter added.
2020-03-25 16:03:22 +01:00
Thirunarayanan Balathandayuthapani
1f7be88141 MDEV-19092 Server crash when renaming the column when
FOREIGN_KEY_CHECKS is disabled

- dict_foreign_find_index() can return NULL if InnoDB already dropped
the foreign index when FOREIGN_KEY_CHECKS is disabled.
2020-03-25 17:10:36 +05:30
seppo
5918b17004
MDEV-21473 conflicts with async slave BF aborting (#1475)
If async slave thread (slave SQL handler), becomes a BF victim, it may occasionally happen that rollbacker thread is used to carry out the rollback instead of the async slave thread.
This can happen, if async slave thread has flagged "idle" state when BF thread tries to figure out how to kill the victim.
The issue was possible to test by using a galera cluster as slave for external master, and issuing high load of conflicting writes through async replication and directly against galera cluster nodes.
However, a deterministic mtr test for the "conflict window" has not yet been worked on.

The fix, in this patch makes sure that async slave thread state is never set to IDLE. This prevents the rollbacker thread to intervene.
The wsrep_query_state change was refactored to happen by dedicated function to make controlling the idle state change in one place.
2020-03-24 11:01:42 +02:00
Eugene Kosov
a7cbce06d4 unoptimized -fsanitize=undefined build on clang requires more stack space 2020-03-23 17:42:57 +03:00
Sergei Golubchik
64dd396948 remove redundant info on rpl test failure
these three SHOW statements (and more) are issued from
include/analyze-sync_with_master.test too.
no need to do it twice.
2020-03-23 13:02:35 +01:00
Eugene Kosov
fb74de9728 MDEV-22006 runtime error: null pointer passed as argument 2, which is declared to never be null in JOIN::copy_ref_ptr_array()
Do not memcpy() a zero-length buffer
2020-03-23 14:30:18 +03:00
Thirunarayanan Balathandayuthapani
6697135c6d MDEV-21572 buf_page_get_gen() should apply buffered page initialized
redo log during recovery

- InnoDB unnecessarily reads the page even though it has fully initialized
buffered redo log records. Allow the page initialization redo log to
apply for the page in buf_page_get_gen() during recovery.
- Renamed buf_page_get_gen() to buf_page_get_low()
- Newly added buf_page_get_gen() will check for buffered redo log for
the particular page id during recovery
- Added new function buf_page_mtr_lock() which basically latches the page
for the given latch type.
- recv_recovery_create_page() is inline function which creates a page
if it has page initialization redo log records.
2020-03-23 16:41:48 +05:30
Eugene Kosov
1e6be69380 MDEV-19658 UBSAN: runtime error: load of value 2779096485, which is not a valid value for type 'enum_binlog_format'
This is an uninitialized read.

THD::THD: initialize current_stmt_binlog_format member
2020-03-23 13:46:09 +03:00
Vladislav Vaintroub
82b3f1a80f MDEV-21930 RocksDB does not compile anymore, with Visual Studio
Update submodule, change the source file list
rename CACHE_LINE_SIZE in ut0counter, so it does not conflics with
rocksdb sources, which also defines this constant now.
2020-03-23 11:25:01 +01:00
Alice Sherepa
ad6e421bd2 MDEV-21360 restore debud_dbug through a session variable instead of '-d,..' 2020-03-23 10:57:21 +01:00
Eugene Kosov
7e168634e9 blind fix for Windows building 2020-03-21 20:37:00 +03:00
Eugene Kosov
5e9e0b8e3b MDEV-21993 asan failure in encryption.innochecksum
simplify fix

field_ref_zero: make bigger

buf_is_zeroes(): remove a loop and check in one go
2020-03-21 17:57:04 +03:00
Eugene Kosov
23993c0036 MDEV-21993 asan failure in encryption.innochecksum
buf_is_zeroes(): stop assuming that argument buffer size
is always a multiply of 4096. And thus stop reading past
that buffer.
2020-03-21 17:08:52 +03:00
Marko Mäkelä
de9072ca19 Connect: Remove some unused variables 2020-03-21 12:52:07 +02:00
Eugene Kosov
45973ec610 InnoDB: reduce size of dtuple_t
Making a linked list of dtuple_t is needed only for inserting
records. It's better to store tuples in a non-intrusive
container to not affect all other use cases of dtuple_t

dtuple_t::tuple_list: removed, it was 2 * sizeof(void*) bytes

ins_node_t::entry_list: now it's std::vector<dtuple_t*>

ins_node_t::entry: now it's std::vector<dtuple_t*>::iterator

DBUG_EXECUTE_IF("row_ins_skip_sec": this dead code removed
2020-03-20 21:35:42 +03:00
Eugene Kosov
54b2da9535 correct comment in buf_page_is_corrupted() 2020-03-20 21:35:42 +03:00
Eugene Kosov
1f53335d37 st_::span fixes
move span.h to a proper place to make it available for the whole server

Reformat it.

Constuctors from a contigous container are fixed
to use cont.data() instead of cont.begin()

span<>::index_type is replaced with span<>::size_type
2020-03-20 21:35:42 +03:00
Eugene Kosov
884d22f288 remove fishy reinterpret_cast from buf_page_is_zeroes()
In my micro-benchmarks memcmp(4196) 3 times faster than old
implementation. Also, it's generally better to use as less
reinterpret_casts<> as possible.

buf_is_zeroes(): renamed from buf_page_is_zeroes() and
argument changed to span<> for convenience.

st_::span<T>::const_iterator: fixed

page_zip-verify_checksum(): make argument byte* instead of void*
2020-03-20 21:35:42 +03:00
Igor Babaev
2bde065525 MDEV-17177 Crash in Item_func_in::cleanup() for SELECT executed via
prepared statement

The method Item_func_in::build_clone() that builds a clone item for an
Item_func_in item first calls a generic method Item_func::build_item()
that builds the the clones for the arguments of the Item_func_in item
to be cloned, creates a copy of the Item_func_in object and attaches the
clones for the arguments to this copy. Then the method Item_func_in::build_clone()
makes the copy fully independent on the copied object in order to
guarantee a proper destruction of the clone. The fact is the copy of the
Item_func_in object is registered as any other item object and should be
destructed as any other item object.
If the method Item_func::build_item fails to build a clone of an argument
then it returns 0. In this case no copy of the Item_func_in object should
be created. Otherwise the finalizing actions for this copy would not be
performed and the copy would remain in a state that would prevent its
proper destruction.

The code of Item_func_in::build_clone() before this patch created the copy
of the Item_func_in object before cloning the argument items. If this
cloning failed the server crashed when trying to destruct the copy item.

The code of Item_row::build_clone() was changed similarly to the code of
Item_func::build_clone though this code could not cause any problems.
2020-03-20 09:36:25 -07:00
Marko Mäkelä
9f7b8625e6 MDEV-14431: Fix ulong/ulonglong type mismatch 2020-03-20 17:46:43 +02:00
Marko Mäkelä
b034d708c8 MDEV-21549: Clean up the import/export tests
Remove CREATE/DROP database.

Remove some unnecessary suppressions, replacements, and
SQL statements.

Populate tables via have_sequence.inc to avoid the creation of
explicit InnoDB record locks in INSERT...SELECT. This will remove
some gaps in AUTO_INCREMENT values.
2020-03-20 16:34:15 +02:00
Marko Mäkelä
b8b3edff13 MDEV-21549 IMPORT TABLESPACE fails to adjust all tablespace ID in root pages
After MDEV-12353, the consistency check that I originally added for
commit 1b9fe0bbac
(InnoDB Plugin for MySQL 5.1) started randomly failing.

It turns out that the IMPORT TABLESPACE code was always incorrect:
it did not update the (redundantly stored) tablespace ID
in index tree root pages. It only does that for page headers
and BLOB pointers.

PageConverter::update_index_page(): Update the tablespace ID
in the BTR_SEG_TOP and BTR_SEG_LEAF of index root pages.
2020-03-20 15:53:04 +02:00
Marko Mäkelä
c9ec1cc751 Merge 10.1 into 10.2 2020-03-20 15:51:30 +02:00
Alexander Barkov
328edf8560 MDEV-21977 main.func_math fails due to undefined behaviour
The problem happened in these line:

uval0= (ulonglong) (val0_negative ? -val0 : val0);
uval1= (ulonglong) (val1_negative ? -val1 : val1);

return check_integer_overflow(val0_negative ? -(longlong) res : res,
                              !val0_negative);

when unary minus was performed on -9223372036854775808.
This behavior is undefined in C/C++.
2020-03-20 15:24:06 +04:00
Marko Mäkelä
a66eebf57c MDEV-21981 Replace arithmetic + with bitwise OR when possible
Several macros such as sint2korr() and uint4korr() are using the
arithmetic + operator while a bitwise or operator would suffice.

GCC 5 and clang 5 and later can detect patterns consisting of
bitwise or and shifts by multiples of 8 bits, such as those used
in the InnoDB function mach_read_from_4(). They actually translate
that verbose low-level code into high-level machine language
(i486 bswap instruction or fused into the Haswell movbe instruction).

We should do the same for MariaDB Server code that is outside InnoDB.

Note: The Microsoft C compiler is lacking this optimization.
There, we might consider using _byteswap_ushort(), _byteswap_ulong(),
_byteswap_uint64(). But, those would lead to unaligned reads, which are
bad for reasons stated in MDEV-20277. Besides, outside InnoDB,
most data is already being stored in the native little-endian format
of that compiler.
2020-03-19 15:09:13 +02:00
Marko Mäkelä
6960e9ed24 MDEV-21983: Crash on DROP/RENAME TABLE after DISCARD TABLESPACE
fil_delete_tablespace(): Remove the unused parameter drop_ahi,
and add the parameter if_exists=false. We want to suppress
error messages if we know that the tablespace has been discarded.

dict_table_rename_in_cache(): Pass the new parameter to
fil_delete_tablespace(), that is, do not complain about
missing tablespace if the tablespace has been discarded.

row_make_new_pathname(): Declare as static.

row_drop_table_for_mysql(): Tolerate !table->data_dir_path
when the tablespace has been discarded.

row_rename_table_for_mysql(): Skip part of the RENAME TABLE
when fil_space_get_first_path() returns NULL.
2020-03-19 14:23:47 +02:00
Marko Mäkelä
9fd692aeca MDEV-13626: Clean up the buffer pool resizing tests from MySQL 5.7
buf_pool_resize(): Simplify the fault injection
for innodb.buf_pool_resize_oom.

innodb.buf_pool_resize_oom: Use a small buffer pool.

innodb.innodb_buffer_pool_load_now: Make use of the sequence engine,
to avoid creating explicit InnoDB record locks. Clean up the
accesses to information_schema.innodb_buffer_page_lru.
2020-03-19 13:01:20 +02:00
Marko Mäkelä
bfb5e1c3f0 MDEV-13626: Import and adjust buffer pool resizing tests from MySQL 5.7 2020-03-19 07:48:17 +02:00
Marko Mäkelä
e28b4b68d3 MDEV-14057: Fix some tests 2020-03-19 06:58:49 +02:00
Alexey Botchkov
a0ce62f804 MDEV-14057 InnoDB GIS tests fail.
Tests fixed.
MBR::Within() function fixed.
2020-03-18 13:55:21 +04:00
Thirunarayanan Balathandayuthapani
09e8707d90 MDEV-21826 Recovery failure : loop of Read redo log up to LSN
- This issue is caused by MDEV-19176
(bba59abb03).
- Problem is that there is miscalculation of available memory during
recovery if innodb_buffer_pool_instances > 1.
- Ignore the buffer pool instance while calculating available_memory
- Removed recv_n_pool_free_frames variable and use buf_pool_get_n_pages()
instead.
2020-03-18 15:25:28 +05:30
Oleksandr Byelkin
6ecbb211c0 new (fixed) version of CC. 2020-03-18 09:33:26 +01:00
Marko Mäkelä
ab0034a789 MDEV-20370 Crash after OPTIMIZE TABLE on TEMPORARY TABLE
Temporary tables are typically short-lived, and temporary tables
are assumed to be accessed only by the thread that is handling
the owning connection. Hence, they must not be subject to
defragmenting.

ha_innobase::optimize(): Do not add temporary tables to
the defragment_table() queue.
2020-03-17 16:28:16 +02:00
Thirunarayanan Balathandayuthapani
e61b99073f MDEV-14808 innodb_fts.sync fails in buildbot with wrong result
AUTO_INCREMENT values are nondeterministic after crash recovery.
While MDEV-6076 guarantees that the AUTO_INCREMENT values of committed
transactions will not roll back, it is possible that the AUTO_INCREMENT
values will be durably incremented for incomplete transactions. So
changing the test case to avoid showing the result of AUTO_INCREMENT value.
2020-03-17 19:40:13 +05:30
Alexey Botchkov
e64a3df4dc MDEV-21959 GIS error message doesn't show the wrong value, just the type.
Error message now shows the whole value.
2020-03-17 13:11:46 +04:00
Marko Mäkelä
89698cef72 MDEV-10570: Fix -Wmaybe-uninitialized
Rows_log_event::change_to_flashback_event(): Reduce the scope
of the variable swap_buff2, and do not duplicate conditions.

GCC 9.3.0 flagged the -Wmaybe-uninitialized when compiling the
10.5 branch using cmake -DWITH_ASAN=ON -DCMAKE_CXX_FLAGS=-O2
2020-03-17 10:35:56 +02:00
Petr Vaněk
b1d7ba472e innodb: fix typo in function description
Function os_file_get_last_error_low returns error number +
OS_FILE_ERROR_MAX (which is currently set to 200) for unknown numbers to
this program.
2020-03-16 17:36:16 +01:00
Sergei Golubchik
5c1ed707a3 mtr: update heuristics for --parallel=auto
to work better for CPUs with more than 2000 bogomips.
old behavior is preserved if less than 2500 bogomips.
2020-03-14 12:38:26 +01:00
Sergei Golubchik
0fe3d6d563 all status variables above questions MUST be ulong
see e.g. `add_to_status()`
2020-03-14 12:38:26 +01:00
Marko Mäkelä
ed21202a14 Fix GCC 10.0 -Wstringop-overflow
myrg_open(): Reduce the scope of the variable 'end' and
simplify the code.

For some reason, I got no warning for this code in the 10.2
branch, only 10.3 or later.

The ENGINE=MERGE is covered by the tests main.merge, main.merge_debug,
and main.merge-big.
2020-03-13 12:09:19 +02:00