Commit graph

189072 commits

Author SHA1 Message Date
Sergey Vojtovich
06fae75859 tc_remove_all_unused_tables() cleanup
As tc_purge() never marks share flushed, let tdc_remove_table() do it
directly.

Part of MDEV-17882 - Cleanup refresh version
2020-04-03 13:01:21 +04:00
Sergey Vojtovich
14e1385691 Proper locking for mysql.gtid_slave_pos truncation
Aim of this patch is to remove tdc_remove_table(TDC_RT_REMOVE_UNUSED),
which was mistakenly introduced by 055a3334a.

InnoDB allows only one open TABLE instance while performing table
truncation. To fulfill this requirement:
1. MDL_EXCLUSIVE has to be acquired to block concurrent threads from
   accessing given table
2. cached TABLE instances have to be flushed
3. another InnoDB requirement is such that TABLE_SHARE and remaining
   TABLE instance have to be invalidated and re-opened after truncation

This goes more or less inline with what regular TRUNCATE TABLE does.

Alternative solution would be handler::ha_delete_all_rows(), but InnoDB
doesn't implement it unfortunately.

Part of MDEV-17882 - Cleanup refresh version
2020-04-03 13:01:21 +04:00
Sergey Vojtovich
bfdd30d3e9 Fixed close_cached_connection_tables() flushing
Let DROP SERVER and ALTER SERVER perform fair affected tables flushing.
That is acquire MDL_EXCLUSIVE and do tdc_remove_table(TDC_RT_REMOVE_ALL).

Aim of this patch is elimination of another inconsistent use of
TDC_RT_REMOVE_UNUSED. It fixes (to some extent) a problem described in the
beginning of sql_server.cc, when close_cached_connection_tables()
interferes with concurrent transaction.

A better fix should probably introduce proper MDL locks for server
objects?

Part of MDEV-17882 - Cleanup refresh version
2020-04-03 13:01:21 +04:00
Sergey Vojtovich
54c03cb4f0 Cleanup mysql_inplace_alter_table()
Removed redundant tdc_remove_table(TDC_RT_REMOVE_ALL). Share was marked
flushed by preceding wait_while_table_is_used() and eventually flushed by
close_all_tables_for_name().

Part of MDEV-17882 - Cleanup refresh version
2020-04-03 13:01:21 +04:00
Sergey Vojtovich
02619ed73b Cleanup close_all_tables_for_name()
close_all_tables_for_name() is always preceded by
wait_while_table_is_used(), which makes tdc_remove_table() redundant.
The only (now fixed) exception was close_cached_tables().

Part of MDEV-17882 - Cleanup refresh version
2020-04-03 13:01:21 +04:00
Sergey Vojtovich
e0743bd1a5 Let "FTWRL <table_list>" use extra(HA_EXTRA_FLUSH)
Rather than flushing caches with tdc_remove_table(TDC_RT_REMOVE_UNUSED)
flush them with extra(HA_EXTRA_FLUSH) instead. This goes inline with
regular FTWRL.

Part of MDEV-17882 - Cleanup refresh version
2020-04-03 13:01:21 +04:00
Marko Mäkelä
0870b75af7 MDEV-22126 Rename confusing constant mtr_t::OPT
The template parameter mtr_t::OPT refers to optional, not optimized.
Also the default parameter mtr_t::NORMAL refers to optimized writes.
The name MAYBE_NOP would be more descriptive, conveying the idea
that a write to a durable page might not actually have any effect.
2020-04-03 08:50:46 +03:00
Marko Mäkelä
406ca20b49 MDEV-22108 Recovery fails with InnoDB: Malformed log record
mtr_t::log_write(): Fix an off-by-one error.
2020-04-03 08:50:46 +03:00
Daniel Black
e8351934b6
Merge pull request #1221 from grooverdan/10.4-MDEV-18851-multiple-sized-large-page-support
MDEV-18851: multiple sized large page support (linux)
2020-04-02 23:54:08 +04:00
Sergei Golubchik
3bb5c6b0c2 MDEV-22113 SIGSEGV, ASAN use-after-poison, Assertion `next_insert_id == 0' in handler::ha_external_lock
if the lookup_handler is allocated on the THD's memroot, it may
not live long enough to be deleted in handler::ha_external_lock()
2020-04-02 14:03:54 +02:00
Daniel Black
a5686e14d9 MDEV-21303 Use mariadbd as the library plugins link to on non-Linux
Prevent errors like on FreeBSD

[ 56%] Linking CXX shared module ha_test_sql_discovery.so
cd /usr/home/dan/build-mariadb-server-10.5/storage/test_sql_discovery && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/test_sql_discovery.dir/link.txt --verbose=1
/usr/bin/c++ -fPIC  -Wl,-z,relro,-z,now -fstack-protector --param=ssp-buffer-size=4 -O2 -g -DNDEBUG -D_FORTIFY_SOURCE=2 -DDBUG_OFF  -shared  -o ha_test_sql_discovery.so CMakeFiles/test_sql_discovery.dir/test_sql_discovery.cc.o -lpthread ../../libservices/libmysqlservices.a -lmysqld -lpthread
/usr/bin/ld: error: unable to find library -lmysqld

Also tested on OpenIndiana successfully.

Closes #1480
2020-04-02 14:03:54 +02:00
Rasmus Johansson
5f3501a6e5 MDEV-22120 Add author to SHOW AUTHORS 2020-04-02 10:54:31 +00:00
Sergei Petrunia
a219006636 MDEV-22014: Rowid Filtering is not displayed well in the optimizer trace
- Print the rowid filters that are available for use with each table.
- Make print_best_access_for_table() print which filter it has picked.
- Make best_access_path() print the filter for considered ref accesses.
2020-04-02 11:50:47 +03:00
Otto Kekäläinen
a135f0ab88 Travis-CI: Update default distro from Ubuntu Xenial to Bionic
Ubuntu Bionic 18.04 LTS will be around until 2023 while Xenial is only to
2021. Thus Bionic is much more suitable as the Travis-CI default build
environment for the 10.5 branch.

For now, still keep one Xenial build to ensure backwards compatibility.

Disable main.udf test until MDEV-21976 is addressed.
2020-04-02 11:22:41 +03:00
Otto Kekäläinen
dda61ade11 Travis-CI: Slim down number of parallel jobs to speed up total run time
Number of jobs dropped from 23 -> 17 and build time from 8-10 hours to
3-4 hours.

Drop GCC 6 and Clang 6 from build dependencies and version 6 is dropped
from the jobs matrix.

Also ignore arm64 and ppc64le on Bionic builds since they sporadically
fail.
2020-04-02 11:22:41 +03:00
Marko Mäkelä
33ffcecc89 MDEV-22114 Assertion failure on SET GLOBAL innodb_buffer_pool_evict='uncompressed'
innodb_buffer_pool_evict_uncompressed(): Remove the mutex acquisition
that was inadvertently added in 1a6f708ec5.
2020-04-02 09:39:43 +03:00
Marko Mäkelä
b212f1dac2 MDEV-22107 Restore accidentally orphaned MTR_MEMO_MODIFY
In MDEV-12353, the calls to mtr_t::memo_modify_page()
were accidentally removed along with
mlog_open_and_write_index() and its callers.

Let us resurrect the function to enable better debug checks.

mtr_t::flag_modified(): Renamed from mtr_t::set_modified()
and made private.

mtr_t::set_modified(): Take const buf_block_t& as a parameter.

In several mtr_t member functions, replace const buf_page_t&
parameters with const buf_block_t&, so that we can pass the
parameter to set_modified().

mtr_t::modify(): Add a MTR_MEMO_MODIFY entry for a block that
is guaranteed to be modified in the mini-transaction.
2020-04-01 18:00:02 +03:00
Marko Mäkelä
587f3e0d9f MDEV-12353: Fix a warning in RelWithDebInfo build
page_zip_clear_rec(): Explicitly initialize len
in non-debug builds to avoid a warning about possibly
invalid memset() length.
2020-04-01 11:38:26 +03:00
Marko Mäkelä
51a9dd6793 Fix GCC 9.3.0 -Wstrict-aliasing
copy_keys_from_share(): Use reinterpret_cast instead of
manipulating a reference to a type-punned pointer.

This cleans up after the cleanup
commit 0515577d12.
2020-04-01 11:33:58 +03:00
Marko Mäkelä
abaeeffbf9 MDEV-22103 INNODB_ENCRYPTION_NUM_KEY_REQUESTS is missing from INFORMATION_SCHEMA.GLOBAL_STATUS
In commit a5584b13d1
some scrubbing-related status variables were removed along with
the background scrubbing code.
The status variable INNODB_ENCRYPTION_NUM_KEY_REQUESTS
was inadvertently removed as part of that.

innodb_status_variables[]: Restore "encryption_num_key_requests".

We introduce the test innodb.innodb_status_variables
in order to catch similar regressions in the future.
2020-04-01 11:19:12 +03:00
Marko Mäkelä
a1077ab287 MDEV-22102 Assertion w==OPT failed in trx_undo_header_create()
Because InnoDB is not freeing undo pages to the normal
free-page management, old undo log pages can be reused. Due to that,
it is possible (but unlikely) that the fields TRX_UNDO_NEEDS_PURGE
and TRX_UNDO_LOG_START relative to the free offset that is stored at
TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_START already have the correct value.
Hence, we must pass the mtr_t::OPT template parameter to silence the
debug assertion.

Other writes in trx_undo_header_create() that are using the default
template parameter seem to be correct (the data fields should be
guaranteed to change even in the event of reusing pages).
2020-04-01 10:40:53 +03:00
Nikita Malyavin
244ff3e5a0 forbid REPLACE/ODKU on tables containing WITHOUT OVERLAPS 2020-03-31 17:42:34 +02:00
Sergei Golubchik
62e7ad2bbc cleanup: move initializations from query exec to prepare time
that is don't call alloc_lookup_buffer() and create_lookup_handler()
for every row

also, don't call ha_check_overlaps() for every partition,
after it was already done on the ha_partition level
2020-03-31 17:42:34 +02:00
Nikita Malyavin
259fb1cbed MDEV-16978 Application-time periods: WITHOUT OVERLAPS
* The overlaps check is implemented on a handler level per row command.
  It creates a separate cursor (actually, another handler instance) and
  caches it inside the original handler, when ha_update_row or
  ha_insert_row is issued. Cursor closes on unlocking the handler.

* Containing the same key in index means unique constraint violation
  even in usual terms. So we fetch left and right neighbours and check
  that they have same key prefix, excluding from the key only the period part.
  If it doesnt match, then there's no such neighbour, and the check passes.
  Otherwise, we check if this neighbour intersects with the considered key.

* The check does not introduce new error and fails with ER_DUPP_KEY error.
  This might break REPLACE workflow and should be fixed separately
2020-03-31 17:42:34 +02:00
Sergei Golubchik
0515577d12 cleanup: prepare "update_handler" for WITHOUT OVERLAPS
* rename to a generic name
* move remaning initializations from query exec to prepare time
* simplify/unify key handling in open_table_from_share and delayed
* remove dead code
* move tests where they belong
2020-03-31 17:42:34 +02:00
Nikita Malyavin
045510cb92 fix mroonga: change field's table as well as ptr for ad-hoc // fixes ptr_in_record usage 2020-03-31 17:42:34 +02:00
Nikita Malyavin
db6f02bb98 fix key_copy to use from_record argument data
key_copy is supposed to take field values from the from_record
argument, but it was mostly ignoring it and instead relying on the
caller to set field->ptr pointers accordingly. Inconsistently,
it was checking the null bitmap in the from_record, not
at the field->null_ptr.

Now key_copy correctly takes all field values from the from_record.
2020-03-31 17:42:34 +02:00
Nikita Malyavin
7f9b3ea951 pass ptr into more Field methods 2020-03-31 17:42:34 +02:00
Nikita Malyavin
6334b57621 cleanup: const 2020-03-31 17:42:34 +02:00
Nikita Malyavin
b9df4d2a35 Fix real keyread count for partitions
Sergei's commit ac6b3c4430 implemented handler status counters
compensation for underlying handlers like ha_partition.
`index_read_idx_map` is missing there, but it should have been fixed as
well (proof: ha_partition::index_read_idx_map never calls
ha_partition::index_read_map).

Note: all this compensation logic could be broken for subpartitions! (We
can experience double decrement)
2020-03-31 17:42:34 +02:00
Nikita Malyavin
e6af62189e unify "partitioning cannot do X" error messages 2020-03-31 17:42:34 +02:00
Nikita Malyavin
3bef848226 cleanup: reduce code duplication in read_extra2() 2020-03-31 17:42:33 +02:00
Sergei Golubchik
8ab693847e cleanup: remove unused PLUGIN_INIT_SKIP_DYNAMIC_LOADING 2020-03-31 17:42:33 +02:00
Sergei Golubchik
64be8c2bf2 mysqld --help will now load mysqld.plugin table
Remove special treatment for Aria.
Add a test with --help and mysql.plugin table being InnoDB

MyISAM is still treated specially, as we need to be able
to initialize global_system_variables.table_plugin reliably
2020-03-31 17:42:33 +02:00
Sergei Golubchik
dc3185c759 cleanup: pk_is_clustering_key() -> is_clustering_key()
where PK is neither required nor implied
2020-03-31 17:42:33 +02:00
Sergei Golubchik
27bf97aa00 cleanup: dead code, comments, avoid current_thd 2020-03-31 17:42:33 +02:00
Marko Mäkelä
63f922dae1 MDEV-22090 Change buffer is not freed after dropping or rebuilding table
When MDEV-19514 removed the change buffer merges in the background,
it introduced a minor regression: After a DDL operation that drops
or rebuilds a table or partition, any entries in the change buffer
could survive until a slow shutdown (innodb_fast_shutdown=0) is executed.

fil_delete_tablespace(). Before returning, invoke
ibuf_delete_for_discarded_space(). With this, the only way to have
change buffer ‘leaks’ is to kill and restart the server at an
appropriate moment and never initiate a slow shutdown.
2020-03-31 14:42:07 +03:00
Marko Mäkelä
14c72bd3e0 MDEV-19514: Correct a few outdated comments
There is no background change buffer merge any more.
Change buffer merge will only take place during a slow shutdown
(a shutdown initiated after SET GLOBAL innodb_fast_shutdown=0).
2020-03-31 14:37:11 +03:00
Daniele Sciascia
bdcecfa22c 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 and we will not rollback transaction.
2020-03-31 14:18:21 +03:00
Marko Mäkelä
b2bc837ebe Cassandra: Define ha_cassandra::records_in_range()
The definition of the member function ha_cassandra::records_in_range()
was inadvertently removed (renamed to a non-member function) in
commit ff64152bc7.

Let us define the overridden member function inline, and add C++11
override qualifiers.
2020-03-31 08:48:00 +03:00
Marko Mäkelä
37c14690fc Merge 10.4 into 10.5 2020-03-30 19:07:25 +03:00
Marko Mäkelä
aae3f921ad Cleanup recv_sys: Move things to members
recv_sys.recovery_on: Replaces recv_recovery_on.

recv_sys_t::apply(): Replaces recv_apply_hashed_log_recs().

recv_sys_var_init(): Remove.

recv_sys_t::recover_low(): Attempt to initialize a page based
on buffered redo log records.
2020-03-30 18:45:09 +03:00
Marko Mäkelä
a8b04c3ee0 MDEV-12353: Remove a trace of pre-MDEV-13564 crash-upgrade
In commit f8a9f90667
we removed support for crash-upgrade from older versions,
but forgot to remove a check for recovering TRUNCATE TABLE
if MariaDB 10.2.18 or 10.3.9 or earlier were killed and
we are attempting to upgrade to MariaDB 10.5.2 or later.
Already MariaDB 10.4 would refuse to recover such TRUNCATE
operations.
2020-03-30 18:08:38 +03:00
Marko Mäkelä
e2f1f88fa6 Merge 10.3 into 10.4 2020-03-30 14:50:23 +03:00
Marko Mäkelä
b092d35f13 MDEV-20590 Introduce a file format constraint to ALTER TABLE
If a table is altered using the MDEV-11369/MDEV-15562/MDEV-13134
ALGORITHM=INSTANT, it can force the table to use a non-canonical
format:

* A hidden metadata record at the start of the clustered index
is used to store each column's DEFAULT value. This makes it possible
to add new columns that have default values without rebuilding the table.

* Starting with MDEV-15562 in MariaDB Server 10.4, a BLOB in the
hidden metadata record is used to store column mappings. This makes
it possible to drop or reorder columns without rebuilding the table.
This also makes it possible to add columns to any position or drop
columns from any position in the table without rebuilding the table.

If a column is dropped without rebuilding the table, old records
will contain garbage in that column's former position, and new records
will be written with NULL values, empty strings, or dummy values.

This is generally not a problem. However, there may be cases where
users may want to avoid putting a table into this format.
For example, users may want to ensure that future UPDATE operations
after an ADD COLUMN will be performed in-place, to reduce write
amplification. (Instantly added columns are essentially always
variable-length.) Users might also want to avoid bugs similar to
MDEV-19916, or they may want to be able to export tables to
older versions of the server.

We will introduce the option innodb_instant_alter_column_allowed,
with the following values:

* never (0): Do not allow instant add/drop/reorder,
to maintain format compatibility with MariaDB 10.x and MySQL 5.x.
If the table (or partition) is not in the canonical format, then
any ALTER TABLE (even one that does not involve instant column
operations) will force a table rebuild.

* add_last (1, default in 10.3): Store a hidden metadata record that
allows columns to be appended to the table instantly (MDEV-11369).
In 10.4 or later, if the table (or partition) is not in this format,
then any ALTER TABLE (even one that does not involve column changes)
will force a table rebuild.

Starting with 10.4:

* add_drop_reorder (2, default): Like 'add_last', but allow the
metadata record to store a column map, to support instant
add/drop/reorder of columns (MDEV-15562).
2020-03-30 12:41:59 +03:00
Thirunarayanan Balathandayuthapani
f8ec3ba01b MDEV-21832 FORCE all partition to rebuild if any one of the
partition does rebuild

- In ha_innobase::commit_inplace_alter_table() assumes that all partition
should do the same kind of alter operations. During DDL, if one partition
requires table rebuild and other partition doesn't need rebuild
then all partition should be forced to rebuild.
2020-03-30 12:41:59 +03:00
Marko Mäkelä
67f2782413 Fix GCC -Wstringop-truncation 2020-03-30 12:16:07 +03:00
Marko Mäkelä
1a9b6c4c7f Merge 10.2 into 10.3 2020-03-30 11:12:56 +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
Marko Mäkelä
6be56dd1c8 MDEV-20377: Enable MemorySanitizer user-poisoning
For ENGINE=Aria, we work around bugs in various tests that catch
writes of uninitialized bytes from the Aria page cache.
(Why do we even write anything on DROP TABLE?)
2020-03-28 21:42:59 +02:00