Commit graph

184573 commits

Author SHA1 Message Date
Eugene Kosov
a97ca9fe5b remove dead code 2019-03-22 22:31:26 +04:00
Eugene Kosov
a523444eda remove dead code 2019-03-22 22:30:36 +04:00
Alexander Barkov
1c60f40868 Merge remote-tracking branch 'origin/10.2' into 10.3 2019-03-22 14:41:36 +04:00
Marko Mäkelä
50a8fc5298 MDEV-18224 MTR's internal check of the test case 'innodb.recovery_shutdown' failed due to extra #sql-ib*.ibd files
The test innodb.recovery_shutdown would occasionally fail,
because recovered incomplete transactions would be conflicting
with DROP TABLE, causing the background drop table queue to be invoked.

Add a slow shutdown before dropping the tables, so that the
recovered transactions will be rolled back. Starting with MDEV-14705,
normal shutdown would abort the rollback of recovered transactions.
2019-03-22 11:16:06 +02:00
Marko Mäkelä
031fa8f1d2 Merge 10.1 into 10.2 2019-03-22 11:15:21 +02:00
Alexander Barkov
f4484dfdbf MDEV-19008 Slow EXPLAIN SELECT ... WHERE col IN (const1,const2,(subquery)) 2019-03-22 07:28:59 +04:00
FaramosCZ
8be02be08b Fix USE_AFTER_FREE (CWE-672)
The file will be closed on line 540
2019-03-22 02:32:47 +04:00
Marko Mäkelä
8c493a910f Merge 10.0 into 10.1 2019-03-21 21:06:01 +02:00
Marko Mäkelä
925b503058 Merge 5.5 into 10.0 2019-03-21 10:34:00 +02:00
Marko Mäkelä
5d454181a8 MDEV-6262 follow-up: Ensure NUL termination on strncpy() 2019-03-21 10:29:59 +02:00
Marko Mäkelä
482710b20c Remove an unused variable 2019-03-21 10:14:57 +02:00
Marko Mäkelä
5a780f2ec8 Merge 10.2 into 10.3 2019-03-21 10:14:23 +02:00
Marko Mäkelä
1caec9c898 Remove unnecessary trx_rsegf_get_new() calls
trx_rseg_header_create(): Return the block descriptor, and
remove the redundant trx_rsegf_get_new() call. Apparently
the idea of that call was some kind of encapsulation or
abstraction, to discourage the direct use of the constant TRX_RSEG.

This also removes the trx_purge_initiate_truncate() local
variable rseg_header, which was only used in debug builds.
2019-03-21 09:40:01 +02:00
Marko Mäkelä
5c1720f8af Remove unused variables from non-debug build 2019-03-21 09:30:37 +02:00
Marko Mäkelä
dcc4458aa0 Add appropriate #ifdef around a declaration 2019-03-21 09:30:03 +02:00
Marko Mäkelä
185a5000e6 Silence bogus -Wmaybe-uninitialized 2019-03-21 09:24:03 +02:00
Marko Mäkelä
3d1b6f68f1 Mariabackup: Ensure NUL termination in strncpy() 2019-03-21 08:54:35 +02:00
Alexander Barkov
e9c494c843 Fixing a failure in tests for "MDEV-18892 Regression in slow log and admin statements"
Tests for MDEV-18892 failed, because of extra 'Prepare' and 'Close stmt'
entries in the output.

Filtering out PS related entries (where it is necessary).
2019-03-21 08:48:44 +04:00
Marko Mäkelä
f41166133b Merge 10.2 into 10.3 2019-03-20 18:37:53 +02:00
Marko Mäkelä
630199e724 MDEV-18981 Possible corruption when using FOREIGN KEY with virtual columns
row_ins_foreign_fill_virtual(): Construct update->old_vrow
with ROW_COPY_DATA instead of ROW_COPY_POINTERS. With the latter,
the object would be pointing to a buffer pool page frame. That page
frame can become stale and invalid as soon as
row_ins_foreign_check_on_constraint() invokes mtr_t::commit().

Most of the time, the pointer target is not going to be overwritten
by anything, and everything appears to work correctly.
Buffer pool page replacement is highly unlikely, and any pessimistic
operation that would overwrite the old location of the record is only
slightly more likely. It is not known whether there is an actual bug.
This came up while diagnosing MDEV-18879 in MariaDB 10.3.
2019-03-20 18:34:49 +02:00
Marko Mäkelä
b47cec6c55 MDEV-18879/MDEV-18972 Corrupted record inserted by FOREIGN KEY operation
row_ins_foreign_check_on_constraint(): When constructing
cascade->historical_row for tables WITH SYSTEM VERSIONING,
use the appropriate mode ROW_COPY_DATA, because the pointers
will be stale after mtr_commit() is invoked.
2019-03-20 18:10:23 +02:00
Alexander Barkov
ef81d2ea64 Fixing "mtr func_math" failure in the test for MDEV-17643
Adding an intermediate volatile variable to avoid using co-processor registers
on some platforms (e.g. 32-bit x86).
This change makes test results stable accross all platforms.
2019-03-20 13:17:24 +04:00
Marko Mäkelä
117291db8b Merge 10.2 into 10.3 2019-03-19 16:04:59 +02:00
Marko Mäkelä
26e5bff003 trx_purge_rseg_get_next_history_log(): Remove a parameter
Access purge_sys.rseg directly, instead of obscuring it with a parameter.
2019-03-19 15:49:53 +02:00
Marko Mäkelä
a77e266866 MDEV-18084: Crash on UPDATE after upgrade from 10.0 or 10.1
MariaDB Server 10.0 and 10.1 support non-indexed virtual columns,
which are hidden from the storage engine. Starting with MDEV-5800
in MariaDB 10.2.2, the virtual columns are visible to storage engines.

calc_row_difference(): Follow up the MDEV-17199 fix, which forgot
to increment num_v when skipping virtual columns in tables that
were created before MariaDB 10.2.2. This caused a corruption of
the update vector when an updated persistent column is preceded
by virtual columns.
2019-03-19 15:30:42 +02:00
Marko Mäkelä
1efda582ad Replace innobase_is_v_fld() with Field::stored_in_db()
The macro innobase_is_v_fld() turns out to be equivalent with
the opposite of Field::stored_in_db(). Remove the macro and
invoke the member function directly.

innodb_base_col_setup_for_stored(): Simplify a condition to only
check Field::vcol_info.

innobase_create_index_def(): Replace some redundant code with
DBUG_ASSERT().
2019-03-19 14:35:05 +02:00
Marko Mäkelä
9471dbafce MDEV-18960: Assertion !omits_virtual_cols(*form->s) on TRUNCATE
MariaDB before MDEV-5800 in version 10.2.2 did not support
indexed virtual columns. Non-persistent virtual columns were
hidden from storage engines. Only starting with MDEV-5800, InnoDB
would create internal metadata on virtual columns.

On TRUNCATE TABLE, an old .frm file from before MDEV-5800 may be
used as the table schema. When the table is being re-created by
InnoDB, the old schema must be used. That is, we may hide
the existence of virtual columns from InnoDB.

create_table_check_doc_id_col(): Remove the assertion that failed.
This function can actually correctly deal with virtual columns
that could have been created before MariaDB 10.2.2 introduced MDEV-5800.

create_table_info_t::create_table_def(): Do not create metadata for
virtual columns if the table definition was created before MariaDB 10.2.2.
2019-03-19 13:45:23 +02:00
Marko Mäkelä
cdb2208cd6 MDEV-18966 Transaction recovery may be broken after upgrade to 10.3
This bug was introduced by MDEV-12288, which made InnoDB use
a single undo log for persistent transactions, instead of
maintaining separate insert_undo and update_undo logs.

trx_undo_reuse_cached(): Initialize the TRX_UNDO_PAGE_TYPE
after reusing a cached undo log page for undo log.
Failure to do so can cause trx_undo_mem_create_at_db_start()
to misclassify new undo log records as TRX_UNDO_INSERT.
This in turn would trigger an assertion failure in
trx_roll_pop_top_rec_of_trx() due to undo==insert.
2019-03-19 11:09:53 +02:00
Marko Mäkelä
6893e9940a trx_purge_add_undo_to_history(): Non-functional cleanup
Simplify the debug code, and use mach_read_from_4() instead of
the wrapper function mtr_read_ulint().
2019-03-19 11:09:10 +02:00
Alexander Barkov
3b98c65c4e MDEV-18881 Assertion `0' failed in make_sortkey upon SELECT with GROUP BY after LOAD DATA 2019-03-18 15:33:59 +04:00
Marko Mäkelä
00572a0b0c MDEV-17482 InnoDB fails to say which fatal error fsync() returned
os_file_fsync_posix(): If fsync() returns a fatal error,
do include errno in the error message.

In the future, we might handle fsync() or write or allocation failures
on InnoDB data files a little more gracefully: flag the affected index
or table as corrupted, and deny any subsequent writes to the table.

If a write to the undo log or redo log fails, an alternative to
killing the server could be to deny any writes to InnoDB tables
until the server has been restarted.
2019-03-18 12:32:10 +02:00
Marko Mäkelä
1d728a98d8 Fixup MDEV-17262: Remove a unused variable 2019-03-18 12:31:58 +02:00
Marko Mäkelä
e3618a333e Post-merge fix after 0508d327ae 2019-03-18 10:23:57 +02:00
Marko Mäkelä
397b6b13d0 MDEV-18946 munmap of 1 byte during shutdown is EINVAL
In MDEV-10814, a missing argument caused a later optional argument
(bool true) to be treated as a size. The unmap of this memory occurs
during shutdown and resizing innodb buffer pool. As a result the
memory is lost but still allocated until shutdown is completed.
2019-03-18 09:35:35 +02:00
sysprg
26432e49d3 MDEV-17262: mysql crashed on galera while node rejoined cluster (#895)
This patch contains a fix for the MDEV-17262/17243 issues and
new mtr test.

These issues (MDEV-17262/17243) have two reasons:

1) After an intermediate commit, a transaction loses its status
of "transaction that registered in the MySQL for 2pc coordinator"
(in the InnoDB) due to the fact that since version 10.2 the
write_row() function (which located in the ha_innodb.cc) does
not call trx_register_for_2pc(m_prebuilt->trx) during the processing
of split transactions. It is necessary to restore this call inside
the write_row() when an intermediate commit was made (for a split
transaction).

Similarly, we need to set the flag of the started transaction
(m_prebuilt->sql_stat_start) after intermediate commit.

The table->file->extra(HA_EXTRA_FAKE_START_STMT) called from the
wsrep_load_data_split() function (which located in sql_load.cc)
will also do this, but it will be too late. As a result, the call
to the wsrep_append_keys() function from the InnoDB engine may be
lost or function may be called with invalid transaction identifier.

2) If a transaction with the LOAD DATA statement is divided into
logical mini-transactions (of the 10K rows) and binlog is rotated,
then in rare cases due to the wsrep handler re-registration at the
boundary of the split, the last portion of data may be lost. Since
splitting of the LOAD DATA into mini-transactions is technical,
I believe that we should not allow these mini-transactions to fall
into separate binlogs. Therefore, it is necessary to prohibit the
rotation of binlog in the middle of processing LOAD DATA statement.

https://jira.mariadb.org/browse/MDEV-17262 and
https://jira.mariadb.org/browse/MDEV-17243
2019-03-18 07:39:51 +02:00
Sergei Golubchik
4f410473ed post-merge: --ps-protocol fixes 2019-03-17 13:07:01 +01:00
Sergei Golubchik
f38c352172 post-merge: gcc 8 warnings 2019-03-17 13:06:56 +01:00
Sergei Golubchik
b64fde8f38 Merge branch '10.2' into 10.3 2019-03-17 13:06:41 +01:00
Marko Mäkelä
a89ee3cd15 MDEV-18952 CHECK TABLE should use READ UNCOMMITED if innodb_force_recovery>=5
MDEV-15418 changed InnoDB to use the READ UNCOMMITTED isolation level
when the transaction recovery is disabled by setting
innodb_force_recovery to 5 or 6. Alas, CHECK TABLE would still
internally use REPEATABLE READ. If the server was started without
purge running into completion (and resetting all DB_TRX_ID thanks
to MDEV-12288), this would cause errors about any DB_TRX_ID that
had not been reset to 0.
2019-03-17 13:06:12 +01:00
Igor Babaev
5e044f78c0 MDEV-18945 Assertion `fixed == 1' failed in Item_cond_and::val_int
In the function make_cond_for_table_from_pred a call of ix_fields()
missed checking of the return code. As a result an extracted constant
condition could be not well formed and this caused an assertion failure.
2019-03-16 15:08:17 -07:00
Jan Lindström
6c08174e36 MDEV-18908: Remove galera and wsrep suites from default run suites in mtr
Idea is that many users do not install galera library and do not want
to unnecessary run galera and wsrep suites. Furthermore, failures on
these suites disturb development as buildbot shows red failing column
and causes unnecessary work for those who do not care galera tests.
There will be other way to run these suites on buildbot.
2019-03-16 07:21:40 +02:00
Daniel Black
a9056a2b89 MDEV-18946: innodb: {de|}allocate_large_{dodump|dontdump} added
In 1dc78d35a0beb9620bae1f4841cc07389b425707 the arguments
to a deallocate_large(dontdump=true) was passed a wrong value.

To avoid accidential calling large memory function that have
DODUMP/DONTDUMP options and missing arguments, the functions
have been given distinct names.
2019-03-16 11:04:19 +11:00
Daniel Black
8678a1052d MDEV-18946: innodb: buffer_pool - unallocate large pages requires size
MDEV-10814 introduce a bug where the size argument to
deallocate_large was passed true, evaluating to 1, as the size.

When this is passed to munmap this resulted in EINVAL and the
page not being released. This only occured the buf_pool_free_instance
when called on shutdown so no impact as the process termination
correctly frees the memory.
2019-03-16 11:03:32 +11:00
Sergei Golubchik
1f020299f8 post-merge: --ps-protocol fixes
Includes:

MDEV-17302 Add support for ALTER USER command in prepared statement

and

MDEV-17673 main.cte_recursive fails in bb-10.4-ps branch in --ps

  Set correct SELECT_LEX linkage for recursive CTEs.
  Do not delegate this job to TABLE_LIST::set_as_with_table,
  because it is only run on prepare, while With_element::move_anchors_ahead
  is run both on prepare and execute (fix by Igor)
2019-03-15 21:00:56 +01:00
Sergei Golubchik
f1134d5676 post-merge: gcc 8 warnings
note: Inherit String from Sql_alloc,
to get operators new and new[] in sync

in rocksdb gcc was complaining that non-lvalue was cast to const.
2019-03-15 21:00:50 +01:00
Sergei Golubchik
0508d327ae Merge branch '10.1' into 10.2 2019-03-15 21:00:41 +01:00
Vladislav Vaintroub
cd805a5f1c Cleanup - remove unused variables and functions after MDEV-18917 2019-03-15 11:42:15 +01:00
Alexander Barkov
b6dc47a0f7 MDEV-17643 Assertion `nr >= 0.0' failed in Item_sum_std::val_real() 2019-03-15 14:12:05 +04:00
Marko Mäkelä
34db9958e2 MDEV-18936 Purge thread fails to exit on shutdown
When there is a huge transaction in the undo log, the purge threads
may get stuck in trx_purge_attach_undo_recs() for a long time,
causing the server to hang on a normal shutdown (innodb_fast_shutdown>0).

Apparently the innodb_purge_batch_size does not work correctly, or the
n_pages_handled is not being incremented correctly. We do not fix that
for now, but we will instead check if shutdown has been initiated,
allowing the purge threads to shut down without delays.
2019-03-15 12:09:46 +02:00
Vladislav Vaintroub
396cf60ac0 MDEV-18917 Don't create xtrabackup_binlog_pos_innodb with Mariabackup 2019-03-15 11:02:00 +01:00