Commit graph

181442 commits

Author SHA1 Message Date
Sergei Golubchik
e4a73acc63 Merge branch '10.1' into 10.2 2018-02-22 16:46:02 +01:00
Sergei Golubchik
a04e4f531a Merge branch '10.0' into 10.1 2018-02-22 14:12:02 +01:00
Jan Lindström
504beb1325 Add supressions for possible warning. 2018-02-22 14:22:44 +02:00
Sergey Vojtovich
988ec800ed MDEV-15155 - ReadView::is_open() assertion failure
ReadView::is_open() was supposed to be called by view owner thread
exclusively. Use ReadView::get_state() instead.
2018-02-22 12:26:18 +04:00
Sergei Golubchik
b728641e86 Merge branch '5.5' into 10.0 2018-02-22 09:22:03 +01:00
Marko Mäkelä
a8656d58d4 Fix the startup with innodb_force_recovery=5
At innodb_force_recovery=5 or bigger, trx_lists_init_at_db_start()
no longer initialises the purge_sys. Adjust an assertion accordingly.
2018-02-22 09:49:50 +02:00
Sergei Golubchik
e119799a92 fix compilation wih -DPLUGIN_PARTITION=NO
rocksdb and spider
2018-02-22 08:40:54 +01:00
Sergei Golubchik
2daa005800 Merge branch '10.1' into 10.2 2018-02-22 08:39:24 +01:00
Marko Mäkelä
fb335b48b5 Allocate purge_sys statically
There is only one purge_sys. Allocate it statically in order to avoid
dereferencing a pointer whenever accessing it. Also, align some
members to their own cache line in order to avoid false sharing.

purge_sys_t::create(): The deferred constructor.

purge_sys_t::close(): The early destructor.

undo::Truncate::create(): The deferred constructor.
Because purge_sys.undo_trunc is constructed before the start-up
parameters are parsed, the normal constructor would copy a
wrong value of srv_purge_rseg_truncate_frequency.

TrxUndoRsegsIterator: Do not forward-declare an inline constructor,
because the static construction of purge_sys.rseg_iter would not have
access to it.
2018-02-22 09:30:41 +02:00
Marko Mäkelä
a3a2b898a0 Cleanup: Do not pass globals as parameters
trx_purge(): Remove the parameter limit or batch_size, which is
always passed as srv_purge_batch_size.

trx_purge_attach_undo_recs(): Remove the parameters purge_sys, batch_size.
Refer to srv_purge_batch_size.

trx_purge_wait_for_workers_to_complete(): Remove the parameter purge_sys.
2018-02-22 09:18:53 +02:00
Daniel Black
9b8d0d9ff9 MDEV-11455: test case for status variable innodb_buffer_pool_load_incomplete
Add innodb debug system variable, innodb_buffer_pool_load_pages_abort, to test
the behaviour of innodb_buffer_pool_load_incomplete.
(innodb_buufer_pool_dump_abort_loads.test)
2018-02-22 15:50:50 +11:00
Daniel Black
8440e8fa98 MDEV-11455: create status variable innodb_buffer_pool_load_incomplete
This status variable indicates that an innodb buffer pool load never
completed and dumping at shutdown would result in an incomplete dump file.

This status variable is set to 1 once a buffer pool loads. Upon a successful
load this status variable returns to 0.

With this status variable set, the system variable
innodb_buffer_pool_dump_at_shutdown==1 will have no effect as dumping after
an incomplete load will generate a less complete dump file than the current
one.

If a user aborts a buffer pool load by changing the system variable
innodb_buffer_pool_load_abort=1 will cause the the status variable
innodb_buffer_pool_load_incomplete to remain set to 1.

A shutdown that occurs while innodb is loading the buffer pool will
not save the buffer pool on shutdown.

A user may indirectly set innodb_buffer_pool_load_incomplete
to 0 by:
* Forcing a load, by setting innodb_buffer_pool_load_now=ON, or
* Forcing a dump, by setting innodb_buffer_pool_dump_now=ON

This will enable the next dump on shutdown to complete.

Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
2018-02-22 15:50:47 +11:00
Marko Mäkelä
fe0e263e6d MDEV-15370 Upgrade fails when both insert_undo and update_undo exist
Before MDEV-12288 in MariaDB 10.3.1, InnoDB used to partition
the persistent transaction undo log into insert_undo and update_undo.

MDEV-12288 repurposes the update_undo as the single undo log.
In order to support an upgrade from earlier MariaDB versions,
the insert_undo is recovered in data structures, called old_insert.

An assertion failure occurred in TrxUndoRsegsIterator::set_next()
when an incomplete transaction was recovered with both insert_undo
and update_undo log. This could be easily demonstrated by starting
./mysql-test-run --manual-gdb innodb.read_only_recovery
in MariaDB 10.2, and after the first kill, start up the MariaDB 10.3
server with the same parameters.

The problem is that MariaDB 10.3 would roll back the recovered
transaction, and finally "commit" it twice (with all changes to
data rolled back), both insert_undo and update_undo with the same
commit end identifier (trx->no).

Our fix is to introduce a "commit number" that comprises two components:
(trx->no << 1 | !old_insert). In this way, the assertion in the purge
subsystem can be relaxed so that only the trx->no component must match.
2018-02-21 21:49:56 +02:00
Daniel Black
868bca5c4f MDEV-15356: tp_timeout_handler needs to call set_killed_no_mutex as it has the mutex
Regression introducted in c2118a08b1 where LOCK_thd_data was moveed
to LOCK_thd_kill
2018-02-21 18:33:17 +00:00
Vladislav Vaintroub
23d7b77358 Fix truncation warning on Windows. 2018-02-21 18:22:43 +00:00
Marko Mäkelä
6a370e4301 Refactor TrxUndoRsegsIterator for further simplification
TrxUndoRsegs::append(): Remove.

TrxUndoRsegsIterator::set_next(): Add a debug assertion that
demonstrates that the merging of rollback segments never occurs.
Since MDEV-12289 or earlier, MariaDB 10.2 will not make any
temporary undo log accessible to the purge subsystem.
(Also MySQL 5.7 would skip the purge of any undo log for
temporary tables, but not before parsing and buffering those
temporary undo log records.)
2018-02-21 19:16:47 +02:00
Marko Mäkelä
6ae7fa6878 Simplify TrxUndoRsegs
Construct directly from trx_rseg_t&.
push_back(), size(): Remove.
2018-02-21 19:16:47 +02:00
Marko Mäkelä
d4187bdc51 Replace purge_iter_t with purge_sys_t::iterator
Also, remove the field undo_rseg_space.
Apparently its purpose was to avoid problems with
temporary undo logs, which MySQL 5.7 unnecessarily adds to
the purge system. (Temporary undo log records are not purged.)
MariaDB 10.2 fixed this in MDEV-12289 or earlier.
2018-02-21 19:16:47 +02:00
Marko Mäkelä
28d844fd07 Rename the purge_sys_t iterators
purge_iter_t::operator<=(): Ordering comparison.
This replaces trx_purge_check_limit() with the difference that
we are not comparing undo_rseg_space. (In MariaDB, temporary
undo logs do not enter the purge subsystem at all.)

purge_sys_t::done: Remove. This was not used for anything.

purge_sys_t::tail: Renamed from purge_sys_t::iter.

purge_sys_t::head: Renamed from purge_sys_t::limit.
2018-02-21 19:16:47 +02:00
Marko Mäkelä
7bfe33ee28 MDEV-10814 innodb large allocations - Don't dump
Merge pull request #364
2018-02-21 19:15:20 +02:00
Daniel Black
8f50a26eb7 MDEV-15356: tp_timeout_handler needs to call set_killed_no_mutex as it has the mutex
Regression introducted in c2118a08b1 where LOCK_thd_data was moveed
to LOCK_thd_kill
2018-02-21 18:07:43 +01:00
Sergei Golubchik
5d8ac1ece1 log all mtr output in vardir/log/stdout.log
despite the name, it logs both stdout and stderr
2018-02-21 17:48:25 +01:00
Sergei Golubchik
50359719f0 fix compilation -DWITH_PERFSCHEMA=NO
tokudb apparently requires perfschema now
2018-02-21 17:48:25 +01:00
Sergei Golubchik
18455ec3f1 fix compilation wih -DPLUGIN_PARTITION=NO 2018-02-21 17:48:25 +01:00
Vladislav Vaintroub
e2ac8d3ff1 Windows : Fix /permissive- compile error 2018-02-21 16:33:55 +00:00
Sergei Petrunia
db0484f355 Change MyRocks Maturity Level from Beta to Gamma (RC) 2018-02-21 17:27:46 +03:00
Daniel Black
4e6dab94d0 MDEV-10.1.31 does not join an existing cluster with SST xtrabackup-v2
Analysis:- The problem  is the change in the implementation of wait_for_listen
in wsrep_sst_xtrabackup-v2.sh. The new script uses lsof which will always
exit with an error code if it can't find all the items, and because the
script has the -e option set in the hashbang line (#!/bin/bash -ue), the
script will abort right after running lsof if lsof can't find even a single
item among all the items listed in its arguments. This will happen even if
socat is running and listening, because it can't find nc. The loop in
wait_for_listen will therefore always quit after one iteration without
writing the "ready" line to signal the parent.

Solution:- We will or the lsof with true.

Patch Credit :Daniel Black and David Wang
2018-02-21 19:48:18 +05:30
Sergei Petrunia
00a556c0c2 MDEV-15372: Parallel slave speedup very limited when log_slave_updates=OFF
Part #2: some transactions have m_rocksdb_tx==NULL (and most functions of
Rdb_transction_impl handle this case. Do like they do)
2018-02-21 17:00:03 +03:00
Sergei Golubchik
88d1c1c551 MDEV-15288 Configure errors when building without INNOBASE 2018-02-21 14:42:56 +01:00
Sergei Petrunia
01e89d6a86 MDEV-15372: Parallel slave speedup very limited when log_slave_updates=OFF
Make MyRocks' non-XA commit path to first do the commit without syncing
and then sync.
2018-02-21 15:42:34 +03:00
Alexander Barkov
144c7f8b6e Adding Field_timestamp::sql_mode_for_timestamp() to reuse duplicate code 2018-02-21 13:11:04 +04:00
Marko Mäkelä
094cf73045 Avoid some dead code 2018-02-21 09:46:51 +02:00
Alexander Barkov
5417002dae A cleanup for MDEV-15340 + fix MDEV-15363 Wrong result for CAST(LAST_DAY(TIME'00:00:00') AS TIME)
The change N7 in MDEV-15340 (see the commit message) introduced
a regression in how CAST(AS TIME), HOUR(), TIME_TO_SEC() treat datetimes
'0000-00-DD mm:hh:ss' (i.e. with zero YYYYMM part and a non-zero day).
These functions historically do not mix days to hours on datetime-to-time
conversion. Implementations of the underlying methods used get_arg0_time()
to fetch MYSQL_TIME. After MDEV-15340, get_arg0_time() went through the
Time() constructor, which always adds '0000-00-DD' to hours automatically
(as in all other places in the code we do mix days to hours).

Changes:
1. Extending Time() to make it possible to choose a desired way of treating
   '0000-00-DD' (ignore or mix to hours) on datetime-to-time conversion.
   Adding a helper class Time::Options for this, which now describes two aspects
   of Time() creation:
   1. Flags for get_date()
   2. Days/hours mixing behavior.

2. Removing Item_func::get_arg0_time(). Using Time() directly
   in all affected classes. Forcing Time() to ignore (rather than mix)
   '0000-00-DD' in these affected classes by passing a suitable Options value.

3. Adding Time::to_seconds(), to reuse the code between
   Item_func_time_to_sec::decimal_op() and Item_func_time_to_sec::int_op().

4. Item_func::get_arg0_date() now returns only a datetime value,
   with automatic time-to-datetime conversion if needed. An assert was
   added to catch attempts to pass TIME_TIME_ONLY to get_arg0_date().
   All callers were checked not to pass TIME_TIME_ONLY, this revealed
   a bug MDEV-15363.

5. Changing Item_func_last_day::get_date() to remove the TIME_TIME_ONLY flag
   before calling get_arg0_date(). This fixes MDEV-15363.
2018-02-21 08:18:44 +04:00
Vladislav Vaintroub
56e7b7eaed Make possible to use clang on Windows (clang-cl)
-DWITH_ASAN can be used as well now, on x64

Fix many clang-cl warnings.
2018-02-20 21:17:36 +00:00
Vladislav Vaintroub
56d6776524 Windows : remove freopen(), "to keep fd = 0 busy".
a) We do not need this on Windows, and it is not clear what it does,inside
service.

b) It hinders debugging.
mysql-test-run.pl --debugger=vsjitdebugger more often than , would stop here
throwing "invalid handle" exception.
2018-02-20 20:03:23 +00:00
Galina Shalygina
9d97e6010e MDEV-14835 Server crashes in Field_iterator_table::create_item when number of
elements of BIGINT or YEAR type in the IN list reaches in_predicate_conversion_threshold

The bug appears at the prepare stage when IN-predicate with the long list
of values is converted into IN-subquery. It happens because values in the
right operand of the IN-predicate that have BIGINT or YEAR types are converted
into the Item_int_with_ref.
To fix it in the procedure Item_func_in::create_value_list_for_tvc
real_item() is taken for each value in the right operand of the IN-predicate.
2018-02-20 21:56:52 +02:00
Marko Mäkelä
947efe17ed MDEV-15158 On commit, do not write to the TRX_SYS page
This is based on a prototype by
Thirunarayanan Balathandayuthapani <thiru@mariadb.com>.

Binlog and Galera write-set replication information was written into
TRX_SYS page on each commit. Instead of writing to the TRX_SYS during
normal operation, InnoDB can make use of rollback segment header pages,
which are already being written to during a commit.

The following list of fields in rollback segment header page are added:
    TRX_RSEG_BINLOG_OFFSET
    TRX_RSEG_BINLOG_NAME (NUL-terminated; empty name = not present)
    TRX_RSEG_WSREP_XID_FORMAT (0=not present; 1=present)
    TRX_RSEG_WSREP_XID_GTRID
    TRX_RSEG_WSREP_XID_BQUAL
    TRX_RSEG_WSREP_XID_DATA

trx_sys_t: Introduce the fields
recovered_binlog_filename, recovered_binlog_offset, recovered_wsrep_xid.

To facilitate upgrade from older mysql or mariaDB versions, we will read
the information in TRX_SYS page. It will be overridden by the
information that we find in rollback segment header pages.

Mariabackup --prepare will read the metadata from the rollback
segment header pages via trx_rseg_array_init(). It will still
not read any undo log pages or recover any transactions.
2018-02-20 21:36:36 +02:00
Marko Mäkelä
f6544353e0 Pull request #625: ASAN unpoison system versioning related buffer 2018-02-20 15:08:16 +02:00
Eugene Kosov
d4822bef04 remove uint 2018-02-20 15:09:31 +03:00
Marko Mäkelä
cd63f43c40 Fix the Windows build
my_atomic_load32() expects a pointer to non-const on Windows.
2018-02-20 13:08:43 +02:00
Eugene Kosov
8ed9ef54f9 ASAN unpoison system versioning related buffer
Fixes this report:
==3165==ERROR: AddressSanitizer: use-after-poison on address 0x61e0000270a0 at pc 0x00000114b78c bp 0x7f15d65fe120 sp 0x7f15d65fd8d0
WRITE of size 1366 at 0x61e0000270a0 thread T28
    #0 0x114b78b in __asan_memcpy fun/cpp_projects/llvm_toolchain/llvm/projects/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cc:23
    #1 0x208208d in TABLE::init(THD*, TABLE_LIST*) work/mariadb/sql/table.cc:4662:3
    #2 0x19df85b in open_table(THD*, TABLE_LIST*, Open_table_context*) work/mariadb/sql/sql_base.cc:1993:10
    #3 0x19eb968 in open_and_process_table(THD*, LEX*, TABLE_LIST*, unsigned int*, unsigned int, Prelocking_strategy*, bool, Open_table_context*) work/mariadb/sql/sql_base.cc:3483:14
    #4 0x19e7c05 in open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) work/mariadb/sql/sql_base.cc:4001:14
    #5 0x19f4dac in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) work/mariadb/sql/sql_base.cc:4879:7
    #6 0x1627263 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) work/mariadb/sql/sql_base.h:487:10
    #7 0x1c3839c in mysql_execute_command(THD*) work/mariadb/sql/sql_parse.cc:5113:13
    #8 0x1c1b72c in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) work/mariadb/sql/sql_parse.cc:7980:18
    #9 0x1c13464 in handle_bootstrap_impl(THD*) work/mariadb/sql/sql_parse.cc:1044:5
    #10 0x1c11ff7 in do_handle_bootstrap(THD*) work/mariadb/sql/sql_parse.cc:1096:3
    #11 0x1c11d14 in handle_bootstrap work/mariadb/sql/sql_parse.cc:1079:3
    #12 0x115a6ae in __asan::AsanThread::ThreadStart(unsigned long, __sanitizer::atomic_uintptr_t*) fun/cpp_projects/llvm_toolchain/llvm/projects/compiler-rt/lib/asan/asan_thread.cc:259
    #13 0x7f15fe1407fb in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x77fb)
    #14 0x7f15fbb64b5e in clone /build/glibc-itYbWN/glibc-2.26/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
2018-02-20 13:50:23 +03:00
Marko Mäkelä
1fa14a7c08 Replace trx_undo_mem_free() with ut_free() 2018-02-20 10:30:14 +02:00
Marko Mäkelä
60a68fdf71 Clarify the access to trx_sys.rseg_history_len
trx_sys_t::rseg_history_len: Make private, and clarify the
documentation.

trx_sys_t::history_size(): Read rseg_history_len.

trx_sys_t::history_insert(), trx_sys_t::history_remove(),
trx_sys_t::history_add(): Update rseg_history_len.
2018-02-20 10:30:08 +02:00
Jan Lindström
c3a3b77f9a Disable failing Galera tests:
* galera_gtid_slave
* galera_unicode_identifiers
2018-02-20 09:27:31 +02:00
Jan Lindström
3a7126cbb7 Disable galera_gtid until 1047: WSREP has not yet prepared node for application use is fixed. 2018-02-20 09:18:33 +02:00
Galina Shalygina
a128fe4346 MDEV-14297: Lost name of a explicitly named CTE column used in
the non-recursive CTE via prepared statement

The problem appears as the column names of the CTE were allocated on the
wrong MEMROOT and after the preparation of the statement they disappear.

To fix it in the procedure With_element::rename_columns_of_derived_unit
the CTE column names are now allocated in the permanent MEMROOT for the
prepared statements and stored procedures.
2018-02-20 01:16:50 +02:00
Alexander Barkov
aef530bb69 MDEV-15340 Wrong result HOUR(case_expression_with_time_and_datetime)
The problem was that Item_func_hybrid_field_type::get_date() did not
convert the result to the correct data type, so MYSQL_TIME::time_type
of the get_date() result could be not in sync with field_type().

Changes:
1. Adding two new classes Datetime and Date to store MYSQL_TIMESTAMP_DATETIME
   and MYSQL_TIMESTAMP_DATE values respectively
   (in addition to earlier added class Time, for MYSQL_TIMESTAMP_TIME values).
2. Adding Item_func_hybrid_field_type::time_op().
   It performs the operation using TIME representation,
   and always returns a MYSQL_TIME value with time_type=MYSQL_TIMESTAMP_TIME.
   Implementing time_op() for all affected children classes.
3. Fixing all implementations of date_op() to perform the operation
   using strictly DATETIME representation. Now they always return a MYSQL_TIME
   value with time_type=MYSQL_TIMESTAMP_{DATE|DATETIME},
   according to the result data type.
4. Removing assignment of ltime.time_type to mysql_timestamp_type()
   from all val_xxx_from_date_op(), because now date_op() makes sure
   to return a proper MYSQL_TIME value with a good time_type (and other member)
5. Adding Item_func_hybrid_field_type::val_xxx_from_time_op().
6. Overriding Type_handler_time_common::Item_func_hybrid_field_type_val_xxx()
   to call val_xxx_from_time_op() instead of val_xxx_from_date_op().
7. Modified Item_func::get_arg0_date() to return strictly a TIME value
   if TIME_TIME_ONLY is passed, or return strictly a DATETIME value otherwise.
   If args[0] returned a value of a different temporal type,
   (for example a TIME value when TIME_TIME_ONLY was not passed,
    or a DATETIME value when TIME_TIME_ONLY was passed), the conversion
   is automatically applied.
   Earlier, get_arg0_date() did not guarantee a result in
   accordance to TIME_TIME_ONLY flag.
2018-02-19 23:41:01 +04:00
Alexey Botchkov
d23fcc427c MDEV-14593 human-readable XA RECOVER.
sql_yacc_ora.yy fixed.
2018-02-19 23:29:51 +04:00
Hartmut Holzgraefe
5c3d0c6bad apply XA RECOVER FORMAT=... from MDEV-14593 to Oracle parser variant, too 2018-02-19 21:12:43 +04:00
Vladislav Vaintroub
84e8e07e8e Revert "Fix 2 more VS2015 warnings"
This reverts commit 0ea45725d8,
since it breaks clang
2018-02-19 16:38:21 +00:00