Commit graph

186890 commits

Author SHA1 Message Date
Jan Lindström
eff898f2a0 MDEV-20335: Extra trans_commit_stmt after rollback caused by incorrect fix of MDEV-14401
Fix incorrect else that should have been else if.
2019-08-13 12:37:08 +03:00
Alexander Barkov
95cdc1ca5f Merge commit '43882e764d6867c6855b1ff057758a3f08b25c55' into 10.4 2019-08-13 11:42:31 +04:00
Marko Mäkelä
ae1d17f52d MDEV-20316 InnoDB writes uninitialised tail of XID buffer
Starting with commit 210855ce5d
Valgrind became aware that the unused tail of the buffer that
is returned by thd_get_xid() is actually uninitialized.

The problem should exist already in MySQL 5.0. I was able to
repeat it on MariaDB Server 5.5 with some additional instrumentation.
InnoDB is allocating 128+4+4 bytes for the XID and the lengths of
its components, even when the XID is shorter than 64+64 bytes.
In MariaDB Server 10.3, while running the test main.xa_binlog,
in the xid_t::set() that is called by sql_yacc.yy, the 128-byte data
buffer was uninitialized according to Valgrind, and only the first bytes
were initialized. When the xid_t::data was copied to
thd.transaction.xid_state.xid.data, it happened so that the entire
target buffer was considered initialized. With MariaDB Server 10.4 since
the said commit, Valgrind will correctly be detect the tail of the buffer
as uninitialized.

The impact of this bug is as follows:

(1) InnoDB will write unnecessarily much redo log for XA PREPARE.
(2) InnoDB will write garbage bytes to the redo log and undo log pages.
(3) The garbage should be 'harmless', because on recovery, only the
actual payload of the XID will be used, based on the written length.

trx_rseg_write_wsrep_checkpoint(), trx_undo_write_xid(): Write only
the actually used length of xid->data to the data page, and
zero out the rest of the buffer by mlog_memset().
2019-08-12 19:37:24 +03:00
Marko Mäkelä
97bbac8ec6 Revert part of 05619f6989
This fixes the following test failures related to index cardinality:
main.join main.stat_tables main.partition main.stat_tables_innodb
innodb.innodb_bug57252
2019-08-12 19:37:24 +03:00
Marko Mäkelä
609ea2f37b MDEV-17614: After-merge fix
MDEV-17614 flags INSERT…ON DUPLICATE KEY UPDATE unsafe for statement-based
replication when there are multiple unique indexes. This correctly fixes
something whose attempted fix in MySQL 5.7
in mysql/mysql-server@c93b0d9a97
caused lock conflicts. That change was reverted in MySQL 5.7.26
in mysql/mysql-server@066b6fdd43
(with a substantial amount of other changes).

In MDEV-17073 we already disabled the unfortunate MySQL change when
statement-based replication was not being used. Now, thanks to MDEV-17614,
we can actually remove the change altogether.

This reverts commit 8a346f31b9 (MDEV-17073)
and mysql/mysql-server@c93b0d9a97 while
keeping the test cases.
2019-08-12 18:50:54 +03:00
Marko Mäkelä
be33124c9d Merge 10.1 into 10.2 2019-08-12 18:25:35 +03:00
Monty
fe8181aca1 Fixed issues found by valgrind
- mysqltest didn't free read_command_buf
- wait_for_slave_param did write different things to the log if valgrind
  was used.
- Table open cache should not write the initial variable value as it
  can depend on the configuration or if valgrind is used
- A variable in GetResult was used uninitalized
2019-08-12 15:41:14 +03:00
Marko Mäkelä
15c1ab52a9 Merge 5.5 into 10.1 2019-08-12 14:46:28 +03:00
Marko Mäkelä
7a9e1fcd45 MDEV-17614: Re-record a result 2019-08-12 14:45:53 +03:00
Marko Mäkelä
1217e4a0c0 Fix -Wimplicit-fallthrough 2019-08-12 14:14:17 +03:00
Marko Mäkelä
b2a387a3f1 Document TRASH_FILL, TRASH_ALLOC, TRASH_FREE 2019-08-12 14:14:17 +03:00
Monty
05619f6989 Fixes based on warnings from gcc/clang and valgrind
- Initialize variables that could be used uninitialized
- Added extra end space to DbugStringItemTypeValue to get rid of warnings
  from c_ptr()
- Session_sysvars_tracker::update() accessed unitialized memory if called
  with NULL value.
- get_schema_stat_record() accessed unitialized memory if HA_KEY_LONG_HASH
  was used
- parse_vcol_defs() accessed random memory for tables without keys.
2019-08-12 10:48:38 +03:00
Aleksey Midenkov
98b24da038 MDEV-17609 mysql client sets wrong application name for Readline library
initialize_readline() is called with full pathname of executable which
sets rl_readline_name to that value.

It is expected that rl_readline_name is initialized with static name
not depending on the file name at all. Needed for setting custom
hotkeys in .inputrc
2019-08-11 12:32:08 +03:00
Aleksey Midenkov
22914ec793 MDEV-18154 Deadlock and assertion upon no-op ALTER under LOCK TABLES
1. Fix DBUG_ASSERT(!table->pos_in_locked_tables) in tc_release_table();
2. Fix access of prematurely freed MDL_ticket: don't close ticket if table was not closed;
3. Fix deadlock after erroneous ALTER.

mysql_alter_table() leaves dirty table->m_needs_reopen in case of
error exit which then incorrectly treated by mysql_lock_tables().
2019-08-11 12:32:08 +03:00
Aleksey Midenkov
0b74c8832d MDEV-19127 Assertion `row_start_field' failed in vers_prepare_keys upon ALTER TABLE
Prevent conflicting clauses at parser level.

Clear HA_VERSIONED_TABLE flag for DROP SYSTEM VERSIONING (for the sake
of strictness).
2019-08-11 12:32:08 +03:00
Aleksey Midenkov
638e78853f MDEV-18862 Unfortunate error message upon attempt to drop system versioning
Special case for DROP PERIOD when system fields are implicit.
2019-08-11 12:32:08 +03:00
Aleksey Midenkov
5851e668d7 MDEV-19304 Segfault in ALTER TABLE after UPDATE for SIMULTANEOUS_ASSIGNMENT
For MODE_SIMULTANEOUS_ASSIGNMENT it is required to return back field
offsets from record[1] to record[0]. 'continue' in warning branch did
skip of rfield->move_field_offset() call.
2019-08-11 12:32:08 +03:00
Aleksey Midenkov
98758b52b3 MDEV-20068 History partition rotation is not done under LOCK TABLES
Wrong value F_WRLCK for thr_lock_type.
2019-08-11 12:32:08 +03:00
Aleksey Midenkov
cdbac54df0 MDEV-17613 MIN/MAX Optimization (Select tables optimized away) does not work
Prune to now-partition when there is no FOR SYSTEM_TIME clause.
2019-08-11 12:32:08 +03:00
Sergei Petrunia
3b234104ae MDEV-16955: rocksdb_sys_vars.rocksdb_update_cf_options_basic
... produces "bytes lost" warnings

When rocksdb_validate_update_cf_options() returns an error,
the update won't happen.
Free the copy of the string in this case.
2019-08-10 01:46:50 +03:00
Sachin
284c72eacf MDEV-17614 INSERT on dup key update is replication unsafe
Problem:-
When mysql executes INSERT ON DUPLICATE KEY INSERT, the storage engine checks
if the inserted row would generate a duplicate key error. If yes, it returns
the existing row to mysql, mysql updates it and sends it back to the storage
engine.When the table has more than one unique or primary key, this statement
is sensitive to the order in which the storage engines checks the keys.
Depending on this order, the storage engine may determine different rows
to mysql, and hence mysql can update different rows.The order that the
storage engine checks keys is not deterministic. For example, InnoDB checks
keys in an order that depends on the order in which indexes were added to
the table. The first added index is checked first. So if master and slave
have added indexes in different orders, then slave may go out of sync.

Solution:-
Make INSERT...ON DUPLICATE KEY UPDATE unsafe while using stmt or mixed format
When there is more then one unique key.
Although there is two exception.
  1. Auto Increment key is not counted because Innodb will get gap lock for
    failed Insert and concurrent insert will get a next increment value. But if
    user supplies auto inc value it can be unsafe.
  2. Count only unique keys for which insertion is performed.

So this patch also addresses the bug id #72921
2019-08-09 19:36:56 +05:30
Alexander Barkov
43882e764d MDEV-20303 SPACE(-1) returns a wrong data type 2019-08-09 14:18:13 +04:00
Alexander Barkov
2dac123515 A cleanup for MDEV-20273 Add class Item_sum_min_max - removing duplicate code
Reusing the MIN()/MAX() fix_length_and_dec() related code for window functions
- FIRST_VALUE()
- LAST_VALUE()
- NTH_VALUE()
- LEAD()
- LAG
2019-08-09 09:00:17 +04:00
Monty
6765cc6077 Fixed assertion Assertion `!table->pos_in_locked_tables' failed
MDEV-17717
Assertion `!table->pos_in_locked_tables' failed in tc_release_table on
flushing RocksDB table under SERIALIZABLE
MDEV-17998
Deadlock and eventual Assertion `!table->pos_in_locked_tables' failed
in tc_release_table on KILL_TIMEOUT
MDEV-19591
Assertion `!table->pos_in_locked_tables' failed in tc_release_table upon
altering table into S3 under lock.

The problem was that thd->open_tables->pos_in_locked_tables was not reset
when alter table failed to reopen a locked table.
2019-08-08 23:08:23 +03:00
Monty
dbac2039e8 Fixed some errors & warnings found by clang
- pcretest.c could use macro with side effect
- maria_chk could access freed memory
- Initialized some variables that could be accessed uninitalized
- Fixed compiler warning in my_atomic-t.c
2019-08-08 23:08:23 +03:00
Monty
5fa2eb6f3d Fixed connect_debug.test to not depend on system error message 2019-08-08 23:08:23 +03:00
Monty
6168f41401 Updated BUILD/compile-pentium64-asan-max 2019-08-08 23:08:22 +03:00
Eugene Kosov
6dca5f6726 revert accidental libmariadb change 2019-08-08 22:55:35 +03:00
Alexander Barkov
c3d67c17c1 MDEV-20292 REPEAT(x,-1) returns a wrong data type 2019-08-08 17:08:56 +04:00
Alexander Barkov
e555df648c MDEV-20285 Wrong result on INSERT..SELECT when converting from SIGNED to UNSIGNED 2019-08-08 13:47:50 +04:00
Alexander Barkov
7fc86a73d8 MDEV-20272 PERCENTILE_DISC() crashes on a temporal type input 2019-08-07 22:44:54 +04:00
Alexander Barkov
d70dac2079 MDEV-20278 PERCENTILE_DISC() returns a wrong data type 2019-08-07 21:01:22 +04:00
Vlad Lesin
d39d5dd2bc MDEV-20060: Failing assertion: srv_log_file_size <= 512ULL << 30 while preparing backup
The general reason why innodb redo log file is limited by 512G is that
log_block_convert_lsn_to_no() returns value limited by 1G. But there is no
need to have unique log block numbers in log group. The fix removes 512G
limit and limits log group size by
(uint32_t maximum value) * (minimum page size), which, in turns, can be
removed if fil_io() is no longer used for innodb redo log io.
2019-08-07 17:26:44 +03:00
Alexander Barkov
e978efd96b MDEV-20273 Add class Item_sum_min_max 2019-08-07 14:13:44 +04:00
Thirunarayanan Balathandayuthapani
47f8a18fec MDEV-20247 Replication hangs with "preparing" and never starts
- The commit ab6dd77408 wrongly sets the
condition inside innobase_srv_conc_enter_innodb().  Problem is that
InnoDB makes the thread to sleep indefinitely if it is a replication
slave thread.

Thanks to Sujatha Sivakumar for contributing the replication test case.
2019-08-07 12:35:04 +05:30
Alexander Barkov
a8def12e8a MDEV-20263 sql_mode=ORACLE: BLOB(65535) should not translate to LONGBLOB 2019-08-06 18:02:03 +04:00
Sergei Petrunia
f36c0189b1 MDEV-17544: No warning when trying to name a primary key constraint
Part#2: update .result files for affected MyRocks tests
2019-08-06 14:37:08 +03:00
Eugene Kosov
88abca55f9 fix build (-Werror + -Wignored-qualifiers) 2019-08-06 12:56:16 +03:00
Alexander Barkov
13f36fffea MDEV-19301 Assertion `!is_valid_datetime() || fraction_remainder(((item->decimals) < (6) ? (item->decimals) : (6))) == 0' failed in Datetime_truncation_not_needed::Datetime_truncation_not_needed 2019-08-06 10:53:55 +04:00
Eugene Kosov
a5a7ab1957 Cleanup: this is how to use span 2019-08-05 21:11:48 +03:00
Eugene Kosov
da7d82b8ea MDEV-20103 add a class similar to std::span
Non-owning reference to elements.

Use it as function argument instead of pointer+size pair or instead of
const std::vector<T>.

Do not use it for strings!

More info is here http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
Or just google about it.
2019-08-05 21:11:48 +03:00
Alexander Barkov
4c4e379ba9 MDEV-20101 Assertion failure on select @@global.'m2'.replicate_ignore_table;
- Removing the wrong assert
- Re-enabling  multi_source.mdev-8874
2019-08-05 16:03:33 +04:00
Alexander Barkov
6b48bdf269 MDEV-18456 Assertion `item->maybe_null' failed in Type_handler_temporal_result::make_sort_key
Adding tests only.

This problem was earlier fixed in 10.4 by MDEV-17325 and backported to 10.3
with this commit:

  f4019f5b35
2019-08-05 15:25:31 +04:00
Alexander Barkov
c99f9766b1 MDEV-19166 Assertion `!is_zero_datetime()' failed in Timestamp_or_zero_datetime::tv 2019-08-05 14:41:17 +04:00
Sujatha
eef7540405 MDEV-18930: Failed CREATE OR REPLACE TEMPORARY not written into binary log makes data on master and slave diverge
Problem:
=======
Failed CREATE OR REPLACE TEMPORARY TABLE statement which dropped the table but
failed at a later stage of creation of temporary table is not written to
binarylog in row based replication. This causes the slave to diverge.

Analysis:
========
CREATE OR REPLACE statements work as shown below.

CREATE OR REPLACE TABLE table_name (a int);
is basically the same as:

DROP TABLE IF EXISTS table_name;
CREATE TABLE table_name (a int);

Hence every CREATE OR REPLACE TABLE command which dropped the table should be
written to binary log, even when following CREATE TABLE part fails. In order
to achieve this, during the execution of CREATE OR REPLACE command, when a
table is dropped 'thd->log_current_statement' flag is set. When table creation
results in an error within 'mysql_create_table' code, the error handling part
looks for this flag. If it is set the failed CREATE OR REPLACE statement is
written into the binary log inspite of error. This ensure that slave doesn't
diverge from the master. In case of row based replication the error handling
code returns very early, if the table is of type temporary. This is done based
on the assumption that temporary tables are not replicated in row based
replication.

It fails to handle the cases where a temporary table was created as part of
statement based replication at an earlier stage and the binary log format was
changed to row because of an unsafe statement. In this case when a CREATE OR
REPLACE statement is executed on this temporary table it will dropped but the
query will not be written to binary log. Hence slave diverges.

Fix:
===
In error handling code check the return status of create table operation. If
it is successful and replication mode is row based and table is of type
temporary then return. Other wise proceed further to the code which checks for
thd->log_current_statement flag and does appropriate logging.
2019-08-05 14:34:31 +05:30
Sergei Petrunia
988ff90256 MDEV-20227: rocksdb.rocksdb_concurrent_delete fails on windows
A combination of:
* lots of include'd test files where each has "--source
  include/have_rocksdb.inc"
* for each such occurrence, MTR adds testsuite's arguments into server
  arguments
* which hits some limit on the length of argv array on Windows, causing
  the server to get garbage data in the last argument.

Work around this by commenting out one of the totally redundant
"source include/have_rocksdb.inc" lines.
2019-08-04 23:37:47 +03:00
Sergei Petrunia
09a85692a6 Post-merge fixes for rocksdb.group_min_max test
- Fix the LooseScan code to support storage engines that return
  HA_ERR_END_OF_FILE if the index scan goes out of provided range
  bounds
- Add a DBUG_EXECUTE_IF("force_group_by",...) to allow a test to
  force a LooseScan
- Adjust rocksdb.group_min_max test not to use features not present
  in MariaDB 10.2 (e.g. optimizer_trace.  In MariaDB 10.4 it's present
  but it doesn't meet the  assumptions that the test makes about it
- Adjust the test result file:
  = MariaDB doesn't support "Enhanced Loose Scan" that FB/MySQL has
  = MariaDB has different cost calculations.
2019-08-04 17:25:17 +03:00
Alexey Botchkov
e244652831 MDEV-20246 Error compiling PAM plugin.
Ignore the setreuid() return here.
2019-08-03 01:02:32 +04:00
Eugene Kosov
319cec959c MDEV-17638 Improve error message about corruption of encrypted page
Help user distinguish between space ID and page number.
2019-08-01 16:49:17 +03:00
Varun Gupta
60a37783ae MDEV-20224: main.derived crashes with ASAN with error use-after-poison
Make sure that the references in the GROUP BY clause that need to be considered for
pushdown from having to where are of Item_field objects
2019-08-01 12:26:36 +05:30