Commit graph

192150 commits

Author SHA1 Message Date
Varun Gupta
d9c5eb2f33 MDEV-25078: ALTER INDEX is inconsistent with ADD/DROP/RENAME index
Allowing ALTER KEY syntax in ALTER TABLE,so one can use:

ALTER TABLE tbl ALTER INDEX index_name IGNORED
ALTER TABLE tbl ALTER KEY index_name IGNORED
2021-03-17 13:45:45 +03:00
Varun Gupta
0540e50873 MDEV-25075: Ignorable index makes the resulting CREATE TABLE invalid
- The patch itself
- More changes to the parser
- Fix by Sergei P to make the tests pass with --embedded
2021-03-17 13:45:45 +03:00
Eugene Kosov
a4d3e04659 MDEV-24883 follow up: unset variables in CMake 2021-03-17 10:57:45 +03:00
Marko Mäkelä
f87a944c79 Merge 10.5 into 10.6 2021-03-16 15:51:26 +02:00
Marko Mäkelä
8ea923f55b MDEV-24818: Optimize multi-statement INSERT into an empty table
If the user "opts in" (as in the parent
commit 92b2a911e5),
we can optimize multiple INSERT statements to use table-level locking
and undo logging.

There will be a change of behavior:

    CREATE TABLE t(a PRIMARY KEY) ENGINE=InnoDB;
    SET foreign_key_checks=0, unique_checks=0;
    BEGIN; INSERT INTO t SET a=1; INSERT INTO t SET a=1; COMMIT;

will end up with an empty table, because in case of an error,
the entire transaction will be rolled back, instead of rolling
back the failing statement. Previously, the second INSERT statement
would have been logged row by row, and only that second statement
would have been rolled back, leaving the first INSERT intact.

lock_table_x_unlock(), trx_mod_table_time_t::WAS_BULK: Remove.
Because we cannot really support statement rollback in this
optimized mode, we will not optimize the locking. The exclusive
table lock will be held until the end of the transaction.
2021-03-16 15:21:34 +02:00
Marko Mäkelä
92b2a911e5 MDEV-24818 Concurrent use of InnoDB table is impossible until the first transaction is finished
In MDEV-515, we enabled an optimization where an insert into an
empty table will use table-level locking and undo logging.
This may break applications that expect row-level locking.

The SQL statements created by the mysqldump utility will include the
following:

    SET unique_checks=0, foreign_key_checks=0;

We will use these flags to enable the table-level locked and logged
insert. Unless the parameters are set, INSERT will be executed in
the old way, with row-level undo logging and implicit record locks.
2021-03-16 15:20:26 +02:00
Vladislav Vaintroub
8dd35a2507 update libmariadb
CONC-534 memory leak in ps_bugs.c
2021-03-15 20:19:04 +01:00
Vlad Lesin
8cbada87f0 MDEV-24184 InnoDB RENAME TABLE recovery failure if names are reused
fil_op_replay_rename(): Remove.

fil_rename_tablespace_check(): Remove a parameter is_discarded=false.

recv_sys_t::parse(): Instead of applying FILE_RENAME operations,
buffer the operations in renamed_spaces.

recv_sys_t::apply(): In the last_batch, apply renamed_spaces.
2021-03-15 16:11:23 +03:00
Vladislav Vaintroub
2f53ad4b7d update libmariadb 2021-03-15 12:36:30 +01:00
Marko Mäkelä
a0558b8c96 MDEV-24883 fixup: Add a dependency
In commit 783625d78f we forgot to
declare a dependency on the generated file mysqld_error.h.
2021-03-15 12:11:41 +02:00
Otto Kekäläinen
211e9b3e0a MDEV-24927: Deb: Use liburing-dev instead of libaio-dev
Updating the debian/control file will automatically update the dependencies
in all CI environments that directly read the debian/control file, such
as Salsa-CI and buildbot.mariadb.org to some degree.
(https://github.com/MariaDB/mariadb.org-tools/issues/43)

On Debian/Ubuntu releases that don't have liburing-dev available,
automatically downgrade to libaio-dev (just like libcurl4->3 is done).
This ensures the debian/control file is always up-to-date and works for
latest Debian and Ubuntu releases, while the backwards compatibility mods
are maintained in autobake-deb.sh separately, and can be dropped from there
once support for certain platforms end.

Debian/Ubuntu availability visible at:
- https://packages.debian.org/search?searchon=names&keywords=liburing-dev
- https://packages.ubuntu.com/search?searchon=names&keywords=liburing-dev

Also modify debian/rules to force a build without libaio. Use YES instead
of ON to make the flag more logical (=turning libaio check "off").

Stop running Salsa-CI for Debian Stretch-backports, as it does not have
liburing-dev available nor is the old-old Debian stable a relevant platform
for MariaDB 10.6 to test against anymore. Since the Stretch-backports build
can no longer be made, neither can the MySQL 5.7 on Bionic upgrade test be
run, as it depended on the Stretch binary.

This commit does not modify the .travis.yml file, as Travis-CI does not
have new enough Ubuntu releases available yet. Also Travis-CI.org is
practically dead now as build times have been shrunk to near zero.

The scope of this change is also Debian/Ubuntu only. No RPM or Windows or
Mac changes are included in this commit.

This commit does not update the external libmariadb or ColumnStore
CI pipelines, as those are maintained in different repositories.
2021-03-15 11:34:02 +02:00
Marko Mäkelä
783625d78f MDEV-24883 add io_uring support for tpool
liburing is a new optional dependency (WITH_URING=auto|yes|no)
that replaces libaio when it is available.

aio_uring: class which wraps io_uring stuff

aio_uring::bind()/unbind(): optional optimization

aio_uring::submit_io(): mutex prevents data race. liburing calls are
thread-unsafe. But if you look into it's implementation you'll see
atomic operations. They're used for synchronization between kernel and
user-space only. That's why our own synchronization is still needed.

For systemd, we add LimitMEMLOCK=524288 (ulimit -l 524288)
because the io_uring_setup system call that is invoked
by io_uring_queue_init() requests locked memory. The value
was found empirically; with 262144, we would occasionally
fail to enable io_uring when using the maximum values of
innodb_read_io_threads=64 and innodb_write_io_threads=64.

aio_uring::thread_routine(): Tolerate -EINTR return from
io_uring_wait_cqe(), because it may occur on shutdown
on Ubuntu 20.10 (Groovy Gorilla).

This was mostly implemented by Eugene Kosov. Systemd integration
and improved startup/shutdown error handling by Marko Mäkelä.
2021-03-15 11:30:17 +02:00
Marko Mäkelä
3dfda08702 MDEV-21212 fixup: GCC -Wclass-memaccess 2021-03-12 14:09:39 +02:00
Krunal Bauskar
8d4e3ec2f7 MDEV-21212: buf_page_get_gen -> buf_pool->stat.n_page_gets++ is a cpu waste
n_page_gets is a global counter that is updated on each page access.
This also means it is updated pretty often and with a multi-core machine
it easily boils up to be the hottest counter as also reported by perf.

Using existing distributed counter framework help ease the contention
and improve the performance.

Patch also tend to increase the slot of the distributed counter from original
64 to 128 given that is new normal for next-generation machines.

The original idea and patch came from Daniel Black which is now ported
to 10.6 with some improvement and adjustment.
2021-03-12 12:56:23 +02:00
Vladislav Vaintroub
031b3dfc22 MDEV-25123 support MSVC ASAN 2021-03-12 08:44:55 +01:00
Marko Mäkelä
4984449956 Merge 10.5 into 10.6 2021-03-12 08:36:26 +02:00
Marko Mäkelä
4c2b6be38e One more try: Fix -Wconversion on GCC 4 to 9 2021-03-11 21:43:43 +02:00
Marko Mäkelä
64f89b1f60 Merge 10.5 into 10.6 2021-03-11 21:03:59 +02:00
Marko Mäkelä
abe25c31a6 After-merge fix: -Wconversion in GCC 4 to 9 2021-03-11 21:02:15 +02:00
Marko Mäkelä
a43ff483fa Merge 10.5 into 10.6 2021-03-11 20:20:07 +02:00
Marko Mäkelä
a4b7232b2c Merge 10.4 into 10.5 2021-03-11 20:09:34 +02:00
Marko Mäkelä
1ea6ac3c95 Merge 10.3 into 10.4 2021-03-11 19:33:45 +02:00
Marko Mäkelä
2c3014e8a7 MDEV-24668 fixup: uninitialized return value with Galera 2021-03-11 19:14:35 +02:00
Thirunarayanan Balathandayuthapani
06df0b0dce MDEV-25107 Check TABLE miscalutates the length of column
- This is caused by merge commit a26e7a3726.
InnoDB fails to fetch the next index field when there is a externally
stored column length check involved.
2021-03-11 20:52:54 +05:30
Marko Mäkelä
a8650b64ed MDEV-25110 [FATAL] InnoDB: Trying to write ... outside the bounds
In commit 118e258aaa (part of MDEV-23855)
we inadvertently broke crash recovery, reintroducing MDEV-11556.

fil_system_t::extend_to_recv_size(): Extend all open tablespace files
to the recovered size.

recv_sys_t::apply(): Invoke fil_system.extend_to_recv_size() at the
start of each batch. In this way, any fil_space_t::recv_size
changes that were parsed after the file was opened will be applied.
2021-03-11 14:21:28 +02:00
Marko Mäkelä
549a70d7f0 MDEV-25031 Not applying INSERT_*_REDUNDANT due to corruption on page
page_apply_insert_redundant(): Replace a too strict condition
hdr_c > pextra_size. It turns out that page_cur_insert_rec_low()
is not even computing the extra_size of cur->rec when it is trying
to reuse header bytes of the preceding record.
2021-03-11 14:21:28 +02:00
Marko Mäkelä
08e8ad7c71 MDEV-25106 Deprecation warning for innodb_checksum_algorithm=none,innodb,...
MDEV-25105 (commit 7a4fbb55b0)
in MariaDB 10.6 will refuse the innodb_checksum_algorithm
values none, innodb, strict_none, strict_innodb.

We will issue a deprecation warning if innodb_checksum_algorithm
is set to any of these non-default unsafe values.

innodb_checksum_algorithm=crc32 was made the default in
MySQL 5.7 and MariaDB Server 10.2, and given that older versions
of the server have reached their end of life, there is no valid
reason to use anything else than innodb_checksum_algorithm=crc32
or innodb_checksum_algorithm=strict_crc32 in MariaDB 10.3.

Reviewed by: Sergei Golubchik
2021-03-11 12:50:04 +02:00
Marko Mäkelä
7a4fbb55b0 MDEV-25105 Remove innodb_checksum_algorithm values none,innodb,...
Historically, InnoDB supported a buggy page checksum algorithm that did not
compute a checksum over the full page. Later, well before MySQL 4.1
introduced .ibd files and the innodb_file_per_table option, the algorithm
was corrected and the first 4 bytes of each page were redefined to be
a checksum.

The original checksum was so slow that an option to disable page checksum
was introduced for benchmarketing purposes.

The Intel Nehalem microarchitecture introduced the SSE4.2 instruction set
extension, which includes instructions for faster computation of CRC-32C.
In MySQL 5.6 (and MariaDB 10.0), innodb_checksum_algorithm=crc32 was
implemented to make of that. As that option was changed to be the default
in MySQL 5.7, a bug was found on big-endian platforms and some work-around
code was added to weaken that checksum further. MariaDB disables that
work-around by default since MDEV-17958.

Later, SIMD-accelerated CRC-32C has been implemented in MariaDB for POWER
and ARM and also for IA-32/AMD64, making use of carry-less multiplication
where available.

Long story short, innodb_checksum_algorithm=crc32 is faster and more secure
than the pre-MySQL 5.6 checksum, called innodb_checksum_algorithm=innodb.
It should have removed any need to use innodb_checksum_algorithm=none.

The setting innodb_checksum_algorithm=crc32 is the default in
MySQL 5.7 and MariaDB Server 10.2, 10.3, 10.4. In MariaDB 10.5,
MDEV-19534 made innodb_checksum_algorithm=full_crc32 the default.
It is even faster and more secure.

The default settings in MariaDB do allow old data files to be read,
no matter if a worse checksum algorithm had been used.
(Unfortunately, before innodb_checksum_algorithm=full_crc32,
the data files did not identify which checksum algorithm is being used.)

The non-default settings innodb_checksum_algorithm=strict_crc32 or
innodb_checksum_algorithm=strict_full_crc32 would only allow CRC-32C
checksums. The incompatibility with old data files is why they are
not the default.

The newest server not to support innodb_checksum_algorithm=crc32
were MySQL 5.5 and MariaDB 5.5. Both have reached their end of life.
A valid reason for using innodb_checksum_algorithm=innodb could have
been the ability to downgrade. If it is really needed, data files
can be converted with an older version of the innochecksum utility.

Because there is no good reason to allow data files to be written
with insecure checksums, we will reject those option values:

    innodb_checksum_algorithm=none
    innodb_checksum_algorithm=innodb
    innodb_checksum_algorithm=strict_none
    innodb_checksum_algorithm=strict_innodb

Furthermore, the following innochecksum options will be removed,
because only strict crc32 will be supported:

    innochecksum --strict-check=crc32
    innochecksum -C crc32
    innochecksum --write=crc32
    innochecksum -w crc32

If a user wishes to convert a data file to use a different checksum
(so that it might be used with the no-longer-supported
MySQL 5.5 or MariaDB 5.5, which do not support IMPORT TABLESPACE
nor system tablespace format changes that were made in MariaDB 10.3),
then the innochecksum tool from MariaDB 10.2, 10.3, 10.4, 10.5 or
MySQL 5.7 can be used.

Reviewed by: Thirunarayanan Balathandayuthapani
2021-03-11 12:46:18 +02:00
Marko Mäkelä
6e7ac4060d MDEV-25070 fixup: Correct the result 2021-03-11 12:34:56 +02:00
David CARLIER
a6cd4612a9 connect storage, little compile issues fix proposal. 2021-03-11 09:36:23 +01:00
Otto Kekäläinen
0da6d67a3a Deb: Rename mariadb.init 10.5->10.6 on 10.6 branch
Also fix a few other occurences of 10.5 -> 10.6.

This commit complements commit 4501c7e875
that seem to have missed these changes.
2021-03-11 10:21:52 +02:00
Krunal Bauskar
f11b60879b MDEV-24949: Enabling idle flushing (possible regression from MDEV-23855)
- Currently page cleaner thread will stop flushing if
  dirty_pct < innodb_max_dirty_pages_pct_lwm.

- If the server is not performing any activity then said resources/time
  could be used to flush the pending dirty pages and keep buffer pool
  clean for the next burst of the cycle. This flushing is called idle flushing.

- flushing logic underwent a complete revamp in 10.5.7/8
  and as part of the revamp idle flushing logic got removed.

- New proposed logic of idle flushing is based on updated logic of the
  page cleaner that will enable idle flushing if
  - buf page cleaner is idle
  - there are dirty pages (< innodb_max_dirty_pages_pct_lwm)
  - server is not performing any activity

  Logic will kickstart the idle flushing bounded by innodb_io_capacity.

(Thanks to Marko Makela for reviewing the patch and idea
 right from the its inception).
2021-03-11 08:14:26 +02:00
Hollow Man
f386fdd70e Fix several typos in sql/item_jsonfunc.cc
insencitive -> insensitive
excapint -> excipient
Jost -> Just
belive -> believe
2021-03-11 13:25:44 +11:00
Rinat Ibragimov
fa5f60681f MDEV-20946: Hard FTWRL deadlock under user level locks
It was possibile for a user to create an interlocked state which may go on
for a significant period of time. There is a tight loop in the FTWRL code
path that tries to repeatedly acquire a read lock. As the weight of FTWRL
lock is the smallest among others, it's always selected by the deadlock
detector, but can never be killed.

Imaging the following sequence:

    connection_0                 connection_1

 GET_LOCK("l1", 0);
                             LOCK TABLES t WRITE;
 FLUSH TABLES WITH READ LOCK;
                             GET_LOCK("l1", 1000);

The GET_LOCK statement in connection_1 triggers the deadlock detector,
which tries to select the lock in FTWRL, since its weight is 0. However,
since a loop in Global_read_lock::lock_global_read_lock() tries to always
win, it tries to acquire lock again. Which invokes the deadlock detector,
and that cycle continues until GET_LOCK in connection_1 times out.

This patch resolves the live-locking by introducing a dynamic bonus to the
deadlock weight associated with every lock. Each lock gets a bonus weight
each time it's selected by the deadlock detector. In case of a live-lock
situation, those locks that cannot be killed, get additional weight each
iteration. Eventually their weight becomes so high that the deadlock
detector shifts its attention to other lock, until it find the one that
can be killed.
2021-03-10 18:08:29 +02:00
Monty
1799caa3a1 MDEV-24422 Server crashes in ha_connect::GetRealType upon ALTER TABLE
The problem was that the CONNECT engine is trying to open the .frm file
during drop_table(), which the code did not take into account.
Fixed by adding the HA_REUSES_FILE_NAMES table flag to CONNECT.

Other things:
- Fixed a wrong test of HA_REUSE_FILE_NAMES of in mysql_alter_table()
  (Comment was correct, no the code)
- Added a test in the connect engine that if the .frm it tries to use in
  delete is not made for connect, it will generate an error instead of
  crash.
2021-03-10 17:27:10 +02:00
Vicențiu Ciorbaru
322129dfb4 Skip mysql_json_mysql_upgrade if plugin is not built
Do not use --source directive as we don't want to load the plugin when
the test starts.
2021-03-10 14:06:43 +02:00
Thirunarayanan Balathandayuthapani
cc9c303a45 MDEV-25070 SIGSEGV in fts_create_in_mem_aux_table
InnoDB set the space in dict_table_t as NULL when table
is discarded. So InnoDB shouldn't use the space present
in table to detect whether the given tablespace is
temporary tablespace.
2021-03-10 16:50:10 +05:30
Otto Kekäläinen
bba6c38630 Deb: Sync downstream changes upstream
- Reduce Build-Depends
  150bf990c6

  Dependencies chrpath, dh-apparmor and libarchive-dev are not needed.
  Fixes buildbot sid failures that error on:
    Unmet build dependencies: chrpath dh-apparmor libarchive-dev

- Salsa-CI: Remove mysql-5.7 upgrade in Sid test as package was removed
  6f55ac620c

  Also clean away extra Salsa-CI markup not needed anymore.

- Autopkgtest: Simplify autopkgtest 'smoke' to be easier to debug
  836907989a

- Autopkgtest: Skip main.failed_auth_unixsocket on armhf and i386
  74601f8b31
2021-03-10 08:50:12 +02:00
Thirunarayanan Balathandayuthapani
8f4a3bf07c MDEV-25057 Assertion `n_fields < dtuple_get_n_fields(entry)'
failed in dtuple_convert_big_rec

In dtuple_convert_big_rec(), InnoDB fails to consider the
instant metadata blob while choosing the variable length
field.
2021-03-09 19:37:27 +05:30
David CARLIER
1dff411e84 arguments overflow fix proposal. the list is assumed to be implictly null terminated at usage time. 2021-03-09 15:51:38 +02:00
David CARLIER
e3a597378e mariabackup utility, binary path implementation for Mac.
implements in a native way get_exepath which gives reliably the full
path.
2021-03-09 15:51:38 +02:00
Vladislav Vaintroub
baddbaa0e3 fixup 449871458b 2021-03-09 11:44:29 +01:00
Marko Mäkelä
bda8a2a63a MDEV-24671 fixup: Merge lock_sys_t::wait_pending into wait_count
The maximum number of concurrently waiting transactions is one less
than the maximum number of concurrent transactions.

A 45-bit cumulative counter of lock waits will support more than
one million lock waits per second for a year.
2021-03-09 09:05:26 +02:00
Marko Mäkelä
78284a4c11 MDEV-25085: Simplify instrumentation for LRU eviction
Let us add the status variable innodb_buffer_pool_pages_LRU_freed
to monitor the number of pages that were freed by a buffer pool LRU
eviction scan, without flushing.

Also, let us simplify the monitor interface:
MONITOR_LRU_BATCH_FLUSH_COUNT, MONITOR_LRU_BATCH_FLUSH_PAGES,
MONITOR_LRU_BATCH_EVICT_COUNT, MONITOR_LRU_BATCH_EVICT_PAGES:
Remove.

MONITOR_LRU_BATCH_FLUSH_TOTAL_PAGE: Track buf_lru_flush_page_count
(innodb_buffer_pool_pages_LRU_flushed).

MONITOR_LRU_BATCH_EVICT_TOTAL_PAGE: Track buf_lru_freed_page_count
(buffer_pool_pages_LRU_freed).

Reviewed by: Vladislav Vaintroub
2021-03-09 09:05:26 +02:00
Nayuta Yanagisawa
75f781f0d2 MDEV-24868 Server crashes in optimize_schema_tables_memory_usage after select from information_schema.innodb_sys_columns
optimize_schema_tables_memory_usage() crashed when its argument included
TABLE struct that was not fully initialized.

To prevent such a crash, we check if a table is an information schema table at
the beginning of each iteration.

Closes #1768
2021-03-08 21:24:38 +01:00
Sergey Zolotarev
d317350a76 Remove trailing newline from error message in dlerror() on Windows
1. Add FORMAT_MESSAGE_MAX_WIDTH_MASK flag to remove trailing \r\n from
   the error message returned by FormatMessageA().
2. Also, add FORMAT_MESSAGE_IGNORE_INSERTS to avoid potential problems
   with system messages that have argument placeholders.

Quote from FormatMessage docs on MSDN:

If this function is called without FORMAT_MESSAGE_IGNORE_INSERTS, the
Arguments parameter must contain enough parameters to satisfy all insertion
sequences in the message string, and they must be of the correct type.
Therefore, do not use untrusted or unknown message strings with inserts
enabled because they can contain more insertion sequences than Arguments
provides, or those that may be of the wrong type. In particular, it is
unsafe to take an arbitrary system error code returned from an API and use
FORMAT_MESSAGE_FROM_SYSTEM without FORMAT_MESSAGE_IGNORE_INSERTS.
2021-03-08 18:23:42 +01:00
Vladislav Vaintroub
449871458b Fix Windows clang build with newest cmake 2021-03-08 18:00:55 +01:00
Robert Bindar
1d762ee8fe MDEV-24363 (followup fix) mysql.user view should
not be dropped if the DEFINER is custom. Revert changes
to MDEV-23102 tests as they were designed to catch
this corner case.
The explanation for this corner case is that users
historically used to tweak the mysql.user table and
probably still do even though mysql.user is now a view.
Thus, if the DEFINER of the view is not default, i.e.
root@localhost or mariadb.sys@localhost, we should avoid
dropping the view during upgrade process to not discard
potential custom changes.
2021-03-08 18:02:45 +02:00
Kartik Soneji
37546842a9 MDEV-24963: Document flush-ssl in the mysqladmin manpage. 2021-03-08 16:15:07 +02:00
Sergei Golubchik
01a0d739c8 MDEV-24975 Server consumes extra 4G memory upon querying INFORMATION_SCHEMA.OPTIIMIZER_TRACE
if a query used no fields from an I_S table, we were creating a temp
table with one, first, field (as a table cannot have zero fields),
with its length truncated to 1.

Now - force also this dummy field to be a normal field, not a BLOB
2021-03-08 15:00:45 +01:00