Commit graph

24115 commits

Author SHA1 Message Date
Marko Mäkelä
4b77d38c26 Fix GCC -Og -Wmaybe-uninitialized 2022-07-28 08:51:19 +03:00
Marko Mäkelä
e5c4f4e590 Merge 10.3 into 10.4 2022-07-27 14:25:36 +03:00
Marko Mäkelä
0ee1082bd2 MDEV-28495 InnoDB corruption due to lack of file locking
Starting with commit da094188f6 (MDEV-24393),
MariaDB will no longer acquire advisory file locks on InnoDB data
files by default, because it would create a large number of
entries in Linux /proc/locks.

The motivation for acquiring the file locks is to prevent accidental
concurrent startup of multiple server processes on the same data files.
Such mistake still turns out to be relatively common, based on
corruption bug reports from the community.

To prevent corruption due to concurrent startup attempts, the
Aria storage engine would unconditionally acquire an advisory lock
on one of its log files.

Solution: InnoDB will always lock its system tablespace files.
(Ever since commit 685d958e38
the InnoDB log file will not necessarily be open while the
server is running, because it can be accessed via memory-mapped I/O.)

If more protection is desired, then the option --external-locking
can be used.

The mandatory advisory lock also fixes intermittent failures of
some crash recovery tests. It turns out that when the mtr test harness
kills and restarts the server, it will not actually ensure that the
old process has terminated before starting the new one.
2022-07-27 14:15:14 +03:00
Oleksandr Byelkin
3bb36e9495 Merge branch '10.3' into 10.4 2022-07-27 11:02:57 +02:00
Marko Mäkelä
9a897335eb MDEV-26420 Buffer overflow on instant ADD/DROP of generated column
prepare_inplace_add_virtual(): Over-estimate the size of the arrays
by not subtracting table->s->virtual_fields (which may refer to
stored, not virtual generated columns). InnoDB only distinguishes
virtual columns.
2022-07-26 16:45:10 +03:00
Thirunarayanan Balathandayuthapani
15a68fc255 MDEV-29058 Assertion `index->type == 32' failed in dict_index_build_internal_fts
- Import tablespace re-evicts and reload the table definition. During that
time, innodb has to load the table even though the secondary fts index
marked as corrupted
2022-07-26 15:01:38 +05:30
Thirunarayanan Balathandayuthapani
f076dc2f66 MDEV-20797 FULLTEXT search with apostrophe, and mandatory words
- InnoDB should ignore the single word followed by apostrophe while
tokenising the document. Example is that if the input string is O'brien
then right now, InnoDB seperates into two tokens as O, brien. But
after this patch, InnoDB can ignore the token 'O' and consider
only 'brien'.
2022-07-26 15:01:17 +05:30
Marko Mäkelä
a8a27f1edf Correct a bogus comment.
The logic on Windows was originally simplified in
commit 4bca1a786f
for storage/xtradb and later in
commit 6304c0bfc7
for storage/innobase.
2022-07-26 11:03:53 +03:00
Mikhail Chalov
19af1890b5 Use memory safe snprintf() in Connect Engine
This commit replaces sprintf(buf, ...) with
snprintf(buf, sizeof(buf), ...),
specifically in the "easy" cases where buf is allocated with a size
known at compile time.

The changes make sure we are not write outside array/string bounds which
will lead to undefined behaviour. In case the code is trying to write
outside bounds - safe version of functions simply cut the string
messages so we process this gracefully.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the BSD-new
license.  I am contributing on behalf of my employer Amazon Web Services,
Inc.

bsonudf.cpp warnings cleanup by Daniel Black

Reviewer: Daniel Black
2022-07-26 16:28:59 +10:00
Marko Mäkelä
95eb5e5a12 Fix clang -Wunused-but-set-variable in unit tests 2022-07-26 08:18:36 +03:00
Marko Mäkelä
f1c8749f46 Fix DBUG_ENTER/return mismatch
Spotted by Thirunarayanan Balathandayuthapani.
2022-07-25 15:58:16 +03:00
Marko Mäkelä
8aa37c264f MDEV-28980 InnoDB: Failing assertion: len <= MAX_TABLE_NAME_LEN
dict_load_foreigns(): Use a correctly sized buffer for the maximum-length
SYS_FOREIGN.ID. In case of overflow, do not crash the server but instead
return DB_CORRUPTION.
2022-07-25 10:28:45 +03:00
Brad Smith
e55c3dc33f Fix building Connect storage engine ioapi code on OpenBSD / NetBSD / DragonFly 2022-07-25 15:06:32 +10:00
Alexander Barkov
57f5c319af MDEV-21445 Strange/inconsistent behavior of IN condition when mixing numbers and strings 2022-07-06 15:42:21 +04:00
Alexander Barkov
bdc1134dea MDEV-29041 Redundant truncation warning on CAST(string_column AS DECIMAL) 2022-07-06 15:05:25 +04:00
Nayuta Yanagisawa
2f3f1cd05b MDEV-26544 Assertion `part_share->auto_inc_initialized' failed in ha_partition::get_auto_increment on INSERT
The partition storage engine ignores return (error) values of
handler::info(). As a result, a query that should be aborted is
not aborted and then the server violates the assertion.
2022-07-05 23:07:49 +09:00
Nayuta Yanagisawa
4bc7c03b5f MDEV-29011 Server crash in spider_db_open_item_cond with XOR operator
Item_func_xor and Item_cond are both derived class of Item_bool_func.
Spider converts *Item_func_xor to *Item_cond and then calls the member
function argument_list(), which Item_func_xor does not implement.
2022-07-05 23:02:19 +09:00
Marko Mäkelä
9a0cbd31ce MDEV-26294 Duplicate entries in unique index not detected when changing collation
ha_innobase::check_if_supported_inplace_alter(): Refuse to change the
collation of a column that would become or remain indexed as part of
the ALTER TABLE operation.

In MariaDB Server 10.6, we will allow this type of operation;
that fix depends on MDEV-15250.
2022-07-04 08:04:44 +03:00
Marko Mäkelä
392ee571c1 Merge 10.3 into 10.4 2022-07-01 13:10:36 +03:00
Thirunarayanan Balathandayuthapani
990cde800a MDEV-28912 NON-UNIQUE FTS_DOC_ID index mistaken as FTS_DOC_ID_INDEX
- InnoDB mistakenly identifies the non-unique FTS_DOC_ID index as
FTS_DOC_ID_INDEX while loading the table. dict_load_indexes()
should check whether the index is unique before assigning
fts_doc_id_index
2022-07-01 13:03:52 +03:00
Marko Mäkelä
7c35ad16e3 MDEV-28389 fixup: Fix pre-GCC 10 -Wconversion
Before version 10, GCC would think that a right shift of an
unsigned char returns int. Let us explicitly cast that back,
to silence a bogus -Wconversion warning.
2022-07-01 13:02:43 +03:00
Marko Mäkelä
045771c050 Fix most clang-15 -Wunused-but-set-variable
Also, refactor trx_i_s_common_fill_table() to remove dead code.

Warnings about yynerrs in Bison-generated yyparse() will remain for now.
2022-07-01 09:48:36 +03:00
Thirunarayanan Balathandayuthapani
99de8cc028 MDEV-28919 Assertion `(((core_null) + 7) >> 3) == oindex.n_core_null_bytes || !not_redundant()' failed
- In case of discarded tablespace, InnoDB can't read the root page to
assign the n_core_null_bytes. Consecutive instant DDL fails because
of non-matching n_core_null_bytes.
2022-06-30 17:30:13 +05:30
Thirunarayanan Balathandayuthapani
e34f878139 MDEV-28706 Redundant InnoDB table fails during alter
- Redundant InnoDB table fails to set the flags2 while loading
the table. It leads to "Upgrade index name failure" during alter
operation. InnoDB should set the flags2 to FTS_AUX_HEX_NAME when
fts is being loaded
2022-06-30 11:19:49 +05:30
Nayuta Yanagisawa
dbd562787a MDEV-24343 Spider Left join failed Unknown column 't0.ID' in 'on clause'
The Spider mixes the comma join with other join types, and thus
ERROR 1054 occurs. This is well-known issue caused by the higher
precedence of JOIN over the comma (,).

We can fix the problem simply by using JOINs instead of commas.
2022-06-28 05:23:14 +09:00
Nayuta Yanagisawa
5375f0b495 MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table | Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed.
The bug is caused by a similar mechanism as MDEV-21027.

The function, check_insert_or_replace_autoincrement, failed to open
all the partitions on INSERT SELECT statements and it results in the
assertion error.
2022-06-28 01:48:55 +09:00
Marko Mäkelä
b922ae5fc9 Merge 10.3 into 10.4 2022-06-27 16:16:20 +03:00
Marko Mäkelä
f339ef3f97 MDEV-26577 InnoDB: Failing assertion: dict_tf2_is_valid(flags, flags2) during ADD COLUMN
prepare_inplace_alter_table_dict(): If the table will not be rebuilt,
preserve all of the original ROW_FORMAT, including the compressed
page size flags related to ROW_FORMAT=COMPRESSED.
2022-06-27 16:00:34 +03:00
Marko Mäkelä
a75ad73545 MDEV-28389 fixup: Fix compiler warnings
hex_to_ascii(): Add #if around the definition to avoid
clang -Wunused-function. Avoid GCC 5 -Wconversion with a cast.
2022-06-27 14:50:00 +03:00
Marko Mäkelä
dd7e9fb38a MDEV-28854 after-merge fix: Remove a test for MDEV-26583 2022-06-27 10:47:05 +03:00
Marko Mäkelä
01d757036f Merge 10.3 into 10.4 2022-06-27 10:14:37 +03:00
Marko Mäkelä
c86b1389de MDEV-28389: Simplify the InnoDB corrupted page output
buf_page_print(): Dump the buffer page 32 bytes (64 hexadecimal digits)
per line. In this way, the limitation in mtr
("Data too long for column 'line'") will not be triggered.

Also, do not bother decoding the page contents, because everything
is present in the hexadecimal output.

dict_index_find_on_id_low(): Merge to dict_index_get_if_in_cache_low().
The direct call in buf_page_print() was prone to crashing, in case the
table definition was concurrently evicted or dropped from the
data dictionary cache.
2022-06-27 09:49:49 +03:00
Hirokazu Hata
2c1aaa6664
MDEV-28854 Disallow INSERT DELAYED on Spider table
Spider supports (or at least allows) INSERT DELAYED but the
documentation does not specify spider as a storage engine that supports
"INSERT DELAYED".
Also, although not mentioned in the documentation, "INSERT DELAYED" is
not intended to be executed inside a transaction, as can be seen from
the list of supported storage engines.
The current implementation allows executing a delayed insert on a
remote transactional table and this breaks the consistency ensured by
the transaction.

We too remove "internal_delayed", one of the Spider table parameters.
Documentation says,

> Whether to transmit existence of delay to remote servers when
> executing an INSERT DELAYED statement on local server.

This table parameter is only used for "INSERT DELAYED".

Reviewed by: Nayuta Yanagisawa
2022-06-27 14:58:18 +09:00
Shunsuke Tokunaga
c4f65d8fed
MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed in ha_partition::set_auto_increment_if_higher
ha_partition::set_auto_increment_if_higher expects
part_share->auto_inc_initialized is true or can_use_for_auto_inc_init()
is false (but as the comment of this method says, it returns false
only if we use Spider engine with DROP TABLE or ALTER TABLE query).
However, part_share->auto_inc_initialized becomes true only after all
partitions are opened (since 6dce6aeceb).

Therefore, I added a conditional expression in order to read all
partitions when we execute REPLACE on a table that has an
AUTO_INCREMENT column.           

Reviewed by: Nayuta Yanagisawa
Reviewed by: Alexey Botchkov
2022-06-16 13:28:24 +09:00
Mathew Heard
b59bc629c8 MDEV-27766: connect engine; INSERT ignore option, was ignored
Test prior to this change:

CURRENT_TEST: connect.mysql
mysqltest: At line 485: query 'INSERT IGNORE INTO t3 VALUES (5),(10),(30)' failed: ER_GET_ERRMSG (1296): Got error 122 '(1062) Duplicate entry '10' for key 'PRIMARY' [INSERT INTO `t1` (`a`) VALUES (10)]' from CONNECT

So the ignore table option wasn't getting passed to the remove server.
Closes #2008
2022-06-10 11:36:59 +10:00
Marko Mäkelä
c89e3b70a7 Merge 10.3 into 10.4 2022-06-09 11:53:46 +03:00
Marko Mäkelä
98293130c3 MDEV-28779: ALTER TABLE IMPORT TABLESPACE corrupts an encrypted table
PageConverter::update_header(): Remove an unnecessary write.
The field that was originally called FIL_PAGE_FILE_FLUSH_LSN only
made sense for the first page of the system tablespace
(initially, for the first page of each file of the system tablespace).
It never had any meaning for .ibd files, and it lost its original
meaning in MariaDB Server 10.8.1 when
commit b07920b634 (MDEV-27199)
removed the ability to start without ib_logfile0.

If the most significant 32 bits of the LSN are nonzero, this
unnecessary write would write the wrong encryption key identifier
to the page. The first page of any file is never encrypted,
so normally those bytes should be 0 for any .ibd file.
2022-06-09 10:57:28 +03:00
Oleg Smirnov
5efadf8d8c MDEV-28747 Index condition pushdown may be configured incorrectly
ha_innobase::build_template may initialize m_prebuilt->idx_cond
even if there is no valid pushed_idx_cond_keyno.
This potentially problematic piece of code was found while
working on MDEV-27366
2022-06-08 16:23:20 +04:00
Marko Mäkelä
44ab6cba76 Cleanup: Remove unused error code DB_FORCED_ABORT
MariaDB never supported this form of preemption via high-priority
transactions. This error code shold not have been added in the
first place, in commit 2e814d4702.
2022-06-08 14:23:21 +03:00
Marko Mäkelä
09177eadc3 MDEV-25257 follow-up: full_crc32 format is garbage-free
In any files that were created in the
innodb_checksum_algorithm=full_crc32 format
(commit c0f47a4a58)
any unused data fields will have been zero-initialized
(commit 3926673ce7).
2022-06-07 16:00:49 +03:00
Marko Mäkelä
96f4b4a55b Merge 10.3 into 10.4 2022-06-02 16:34:17 +03:00
Marko Mäkelä
fde99e006d MDEV-28716: Portability: unlink() can return EPERM instead of EISDIR 2022-06-01 11:13:15 +03:00
Monty
9d10b7107c Fixed bug in ma_loghandler.cc that could cause an assert
The assert happens in 10.6 with the following command:

./mtr --no-reorder --verbose-restart main.update_ignore_216 main.upgrade_MDEV-19650 main.upgrade_MDEV-23102-1 main.upgrade_MDEV-23102-2 main.upgrade_geometrycolumn_procedure_definer main.upgrade_mdev_24363 main.varbinary sys_vars.aria_log_file_size_basic

Reviewer: Oleksandr Byelkin <sanja@mariadb.com>
2022-05-30 17:26:48 +03:00
Mathew Heard
c4e87cb22c MDEV-9020: Connect issues ALTER TABLE DISABLE KEYS when inserting data
If the connecting user doesn't have alter table privilege this isn't
allowed.

This patch removes enable / disable key commands that should never have been here

Closes #2002
2022-05-27 11:15:07 +10:00
Marko Mäkelä
99c8aed00d MDEV-28601 InnoDB history list length was reverted to 32 bits
srv_do_purge(): In commit edde1f6e0d
when the de-facto 32-bit trx_sys_t::history_size() was replaced with
32-bit trx_sys.rseg_history_len, some more variables were changed
from ulint (size_t) to uint32_t.

The history list length is the number of committed transactions whose
undo logs are waiting to be purged. Each TRX_RSEG_HISTORY list is
storing the number of entries in a 32-bit field and each transaction
will occupy at least one undo log page. It is thinkable that the
length of each TRX_RSEG_HISTORY list may approach the maximum
representable number. The number cannot be exceeded, because the
rollback segment header is allocated from the same tablespace as
the undo log header pages it is pointing to, and because the page
numbers of a tablespace are stored in 32 bits. In any case, it is
possible that the total number of unpurged committed transactions
cannot be represented in 32 but 39 bits (corresponding to
128 rollback segments and undo tablespaces).
2022-05-25 14:06:04 +03:00
Thirunarayanan Balathandayuthapani
7fe474fe7e MDEV-25257 SEGV in fts_get_next_doc_id upon some INSERT
- InnoDB fails to create a fts cache while loading the innodb fts
table which is stored in system tablespace. InnoDB should create
the fts cache while loading FTS_DOC_ID column from system column.
2022-05-25 13:32:58 +05:30
Sergei Golubchik
23ddc3518f Merge branch '10.3' into 10.4 2022-05-18 01:25:30 +02:00
Marko Mäkelä
3e564d468d MDEV-28541 Unused counter Innodb_encryption_key_rotation_list_length
The counter srv_stats.key_rotation_list_length is never updated, and
therefore Innodb_encryption_key_rotation_list_length will always be 0.

The view INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION comes close
to reporting this information.
2022-05-16 13:45:17 +03:00
Marko Mäkelä
4e1bf2bb23 MDEV-28537 Unused or useless InnoDB counters num_index_pages_written, num_non_index_pages_written
The counters were added in commit 5e55d1ced5
and any code to update them was
inadvertently removed in commit 2e814d4702
when applying InnoDB changes from MySQL 5.7.

Let us remove these counters that never reported anything useful. If such
statistics are really needed in a special case, they can be obtained by
instrumenting the code by some means, such as eBPF or a source code patch.
2022-05-16 13:41:53 +03:00
Nayuta Yanagisawa
8c28b27f00 MDEV-28301 Spider: Fix GCC warnings, comparing the result of pointer addition ... and NULL
The condition of the if statements are always true.
2022-05-13 21:32:49 +09:00