Commit graph

194367 commits

Author SHA1 Message Date
Vladislav Vaintroub
12cea09713 MDEV-27535 Service does not start after MSI install into restricted directory
This happens for example if one installs into home directory of a user
C:\Users\<username>\mariadb

The reason is that the service user "NT SERVICE\<service_name>" does
not have read and execute permissions for service executable mysqld.exe
in this directory.
Moreover, it would not have read permissions for server.dll loaded by the
exe, or to plugin directory, where plugins may reside.

The fix is to give service users read and execute permissions to bin, share, and
lib\plugin subdirectories.

The permission setting is doneby  mysql_install_db.exe, but also in MSI.
It is important to do that in MSI, as we want permissions to survive
the MSI upgrade.
2022-01-31 20:10:08 +01:00
Alexander Barkov
2a0962f39b MDEV-27696 Json table columns accept redundant COLLATE syntax 2022-01-31 21:18:43 +04:00
Sergei Golubchik
2d4a0f6079 pass MYSQL_MAINTAINER_MODE down to srpm builds
fixes errors on rpm-*-debug builder
2022-01-30 22:52:59 +01:00
Sergei Golubchik
77b3777bab update columnstore to 6.2.3-1 2022-01-30 16:37:12 +01:00
Sergei Golubchik
bc10f58a58 MDEV-24909 JSON functions don't respect KILL QUERY / max_statement_time limit
pass the pointer to thd->killed down to the json library,
check it while scanning,
use thd->check_killed() to generate the proper error message
2022-01-30 12:07:31 +01:00
Sergei Golubchik
bae9fb5904 MDEV-24909 JSON functions don't respect KILL QUERY / max_statement_time limit
preallocate the string in json_nice()
to avoid reallocs on every 1-character append()
2022-01-30 12:07:16 +01:00
Sergei Golubchik
3add51b769 cleanup: move the common code into the function 2022-01-30 12:07:16 +01:00
Sergei Golubchik
3cc278e960 enable main.mysqldump-system test
that was permanently disabled in a merge mistake. also
* use auth_test_plugin to test dumping of plugins and user auth,
  as the original test intended
* s/USER/foobar/ to make a username searchable
2022-01-30 12:07:16 +01:00
Marko Mäkelä
c478a5533e MDEV-27667 Fix MDEV-26720 on 64-bit Microsoft Windows
The correct macro to detect the AMD64 ISA is _M_X64, not M_IX64.

This is the 10.6 version of
commit fb8fea3490 (10.5).
2022-01-28 16:42:37 +02:00
Marko Mäkelä
f0f5ce58c7 MDEV-27402 'asm goto' is not supported on Apple Xcode 9.4.1
Even though Apple Xcode is based on and similar to Clang,
it does not support the asm goto construct which was added
in commit 668a5f3d12 (MDEV-26720)
to work around a compiler deficiency that results in suboptimal
code being generated for IA-32 and AMD64.

We will disable this manual optimization if __APPLE_CC__ is defined.

Similar constructs are also used in sync/srw_lock.cc, but that code
is not used on Apple, because we have not implemented a Linux futex
compatible interface on Apple macOS.

Thanks to Valerii Kravchuk for reporting and testing this.
2022-01-28 08:31:57 +02:00
Marko Mäkelä
48b974b267 MDEV-27026 innodb_fts.concurrent_insert failed
Most of this was likely already fixed by MDEV-27017.
On one implementation of the AMD64 ISA, the test
innodb_fts.concurrent_insert would still occasionally hang,
with both dict_sys_t::evict_table_LRU() and
dict_index_set_merge_threshold() waiting in dict_sys_t::lock()
several threads waiting in dict_sys_t::freeze(),
no thread holding exclusive dict_sys.latch and also no thread
in the stack traces apparently holding any dict_sys.latch,
even though dict_sys.latch_readers == 1.

To prevent this scenario, we will remove the dict_sys.latch
acquisition from dict_index_set_merge_threshold(). It is actually
not needed, because dict_sys.sys_indexes will not change after
InnoDB startup. The SYS_INDEXES leaf page will be sufficiently
protected by the page latch.

There potentially is a bug in the srw_lock implementation,
which will have to be investigated further.
2022-01-27 18:14:37 +02:00
Oleksandr Byelkin
b09a744383 new CC 3.2 2022-01-26 09:51:22 +01:00
Marko Mäkelä
21778b8aa8 Merge 10.5 into 10.6 2022-01-20 07:39:11 +02:00
Marko Mäkelä
66465914c1 MDEV-27550: Disable galera.MW-328D 2022-01-20 07:37:43 +02:00
Marko Mäkelä
764ca7e6e7 MDEV-27499 fixup: Add a wait to buf_flush_sync()
The test innodb.log_file_size would occasionally fail with
an assertion failure !buf_pool.any_io_pending(). Let us wait
for the page cleaner thread to become idle already in
srv_prepare_to_delete_redo_log_file(), like we used to.
2022-01-19 19:12:17 +02:00
Sergei Petrunia
7259b299a5 MDEV-27382: OFFSET is ignored when combined with DISTINCT
A query in form

  SELECT DISTINCT expr_that_is_inferred_to_be_const LIMIT 0 OFFSET n

produces one row when it should produce none. The issue was in
JOIN_TAB::remove_duplicates() in the piece of logic that tried to
avoid duplicate removal for such cases but didn't account for possible
"LIMIT 0".

Fixed by making Select_limit_counters::set_limit() change OFFSET to 0
when LIMIT is 0.
2022-01-19 14:04:10 +03:00
Marko Mäkelä
965c0d2240 MDEV-27025: Null merge 10.5 into 10.6 2022-01-19 09:57:28 +02:00
Vlad Lesin
be8113861c MDEV-27025 insert-intention lock conflicts with waiting ORDINARY lock
The code was backported from 10.6 bd03c0e516
commit. See that commit message for details.

Apart from the above commit trx_lock_t::wait_trx was also backported from
MDEV-24738. trx_lock_t::wait_trx is protected with lock_sys.wait_mutex
in 10.6, but that mutex was implemented only in MDEV-24789. As there is no
need to backport MDEV-24789 for MDEV-27025,
trx_lock_t::wait_trx is protected with the same mutexes as
trx_lock_t::wait_lock.

This fix should not break innodb-lock-schedule-algorithm=VATS. This
algorithm uses an Eldest-Transaction-First (ETF) heuristic, which prefers
older transactions over new ones. In this fix we just insert granted lock
just before the last granted lock of the same transaction, what does not
change transactions execution order.

The changes in lock_rec_create_low() should not break Galera Cluster,
there is a big "if" branch for WSREP. This branch is necessary to provide
the correct transactions execution order, and should not be changed for
the current bug fix.
2022-01-18 18:15:10 +03:00
Vlad Lesin
bd03c0e516 MDEV-27025 insert-intention lock conflicts with waiting ORDINARY lock
When lock is checked for conflict, ignore other locks on the record if
they wait for the requesting transaction.

lock_rec_has_to_wait_in_queue() iterates not all locks for
the page, but only the locks located before the waiting lock in the
queue. So there is some invariant - any lock in the queue can wait only
lock which is located before the waiting lock in the queue.

In the case when conflicting lock waits for the transaction of
requesting lock, we need to place the requesting lock before the waiting
lock in the queue to preserve the invariant. That is why we are looking
for the first waiting for requesting transation lock and place the new
lock just after the last granted requesting transaction lock before the
first waiting for requesting transaction lock.

Example:

trx1 waiting lock, trx1 granted lock, ..., trx2 lock - waiting for trx1
place new lock here -----------------^

There are also implicit locks which are lazily converted to explicit
ones, and we need to place the newly created explicit lock to the correct
place in a queue. All explicit locks converted from implicit ones are
placed just after the last non-waiting lock of the same transaction before
the first waiting for the transaction lock.

Code review and cleanup was made by Marko Mäkelä.
2022-01-18 15:18:42 +03:00
Marko Mäkelä
1abc476f0b Merge 10.5 into 10.6 2022-01-18 12:59:50 +02:00
Marko Mäkelä
e44439ab73 MDEV-27499 Performance regression in log_checkpoint_margin()
In commit 4c3ad24413 (MDEV-27416)
an unnecessarily strict wait condition was introduced in the
function buf_flush_wait(). Most callers actually only care that
the pages have been flushed, not that a checkpoint has completed.

Only in the buf_flush_sync() call for log resizing, we might care
about the log checkpoint. But, in fact,
srv_prepare_to_delete_redo_log_file() is explicitly disabling
checkpoints. So, we can simply remove the unnecessary wait loop.

Thanks to Krunal Bauskar for reporting this performance regression
that we failed to repeat in our testing.
2022-01-18 12:57:15 +02:00
Sergei Golubchik
745aa8bee7 MDEV-26230 mysql_upgrade fails to load type_mysql_json due to insufficient maturity level
bump maturity to beta
2022-01-17 18:16:27 +01:00
Sergei Golubchik
5af6a13771 MDEV-25373 DROP TABLE doesn't raise error while dropping non-existing table in MariaDB 10.5.9 when OQGraph SE is loaded to the server
don't auto-succeed every DROP TABLE
2022-01-17 18:16:27 +01:00
Marko Mäkelä
f18e25649d MDEV-27461: Buffer pool resize fails to wake up the page cleaner
buf_pool_t::realloc(): Invoke page_cleaner_wakeup()
if buf_LRU_get_free_only() returns a null pointer.

Ever since commit 7b1252c03d (MDEV-24278)
the page cleaner would remain in untimed sleep, expecting explicit
calls to buf_pool_t::page_cleaner_wakeup() when the ratio of dirty pages
could change.

Failure to wake up the page cleaner will cause all page writes to be
initiated by buf_flush_LRU_list_batch(). That might work too,
provided that the buffer pool size is at least BUF_LRU_MIN_LEN (256)
pages, but it would not advance the log checkpoint.
2022-01-17 16:09:09 +02:00
Marko Mäkelä
343f695c7f MDEV-27469: Assertion failure in defragment due to tx_read_only
In commit c5fd9aa562 (MDEV-25919)
we prevented the function dict_stats_save_index_stat()
from being called in read-only mode in dict_stats_save(),
but not elsewhere.

dict_stats_save_defrag_summary(), dict_stats_save_defrag_stats():
If the transaction is in read-only mode, return DB_READ_ONLY
and do not attempt to lock or modify anything.
2022-01-17 11:19:41 +02:00
Nayuta Yanagisawa
b7e4dc121a MDEV-27240 fixup: remove dead code 2022-01-15 21:24:25 +09:00
Nayuta Yanagisawa
64f844b611 MDEV-27240 fixup: remove #ifdef in macro call
Windows builds failed due to the following error:
'#': invalid character: possibly the result of a macro expansion
2022-01-15 17:33:48 +09:00
Nayuta Yanagisawa
2ecd39c983 MDEV-27240 SIGSEGV in ha_spider::store_lock on LOCK TABLE
The commit e954d9de gave different lifetime to wide_share and
partition_handler_share. This introduced the possibility that
partition_handler_share could be accessed even after it was freed.

We stop sharing partitoiin_handler_share and make it belong to
a single wide_handler to fix the problem.
2022-01-15 13:25:09 +09:00
Marko Mäkelä
8535c260dd Remove FIXME comments that refer to an early MDEV-14425 plan
In MDEV-14425, an early plan was to introduce a separate log file
for file-level records and checkpoint information. The reasoning was
that fil_system.mutex contention would be reduced by not having to
maintain fil_system.named_spaces. The mutex contention was actually
fixed in MDEV-23855 by making some data fields in fil_space_t and
fil_node_t use std::atomic.

Using a single circular log file simplifies recovery and backup.
2022-01-14 20:27:51 +02:00
Marko Mäkelä
16b87f9890 Merge 10.5 into 10.6 2022-01-14 18:19:04 +02:00
Marko Mäkelä
c104a01b50 MDEV-27500 buf_page_free() fails to drop the adaptive hash index
The function buf_page_free() that was introduced
in commit a35b4ae898 (MDEV-15528)
failed to remove any adaptive hash index entries for the page
before freeing the page.

This caused an assertion failure on shutdown of 10.6 server of
in the function buf_pool_t::clear_hash_index() with the expression:
(s >= buf_page_t::UNFIXED || s == buf_page_t::REMOVE_HASH).
The assertion would fail for a block that is in the freed state.

The failing assertion was added in
commit aaef2e1d8c
in the 10.6 branch.

Thanks to Matthias Leich for finding the bug and testing the fix.
2022-01-14 17:42:19 +02:00
Marko Mäkelä
e6a0611388 MDEV-27058 fixup: Bogus assertion !block->page.is_io_fixed()
buf_page_get_gen(): After recv_sys_t::recover_low() returned,
the page must not be read-fixed, but it may be write-fixed,
because the io-fix state is protected by block->page.lock,
which we are not holding yet.

Also, let us copy the block descriptor state to a local variable
for examination, so that in case an assertion would fail again,
we will have the sampled state in the core dump. In a core dump of
the assertion failure, we had block->page.fix() == buf_page_t::UNFIXED,
that is, the assertion expression was holding again.
2022-01-13 16:45:31 +02:00
Aleksey Midenkov
6831b3f2a0 MDEV-26824 Can't add foreign key with empty referenced columns list
create_table_info_t::create_foreign_keys() expects equal number of
iterations through fk->columns and fk->ref_columns. If fk->ref_columns
is empty copy it from fk->columns.
2022-01-12 17:18:38 +03:00
Marko Mäkelä
ba5ef63ae1 MDEV-27476 heap-use-after-free in buf_pool_t::is_block_field()
This follows up commit 017d1b867b.
In commit aaef2e1d8c (MDEV-27058)
some more problematic debug assertions were added.

btr_search_update_block_hash_info(), trx_purge_truncate_history():
Use simpler assertions to check that an uncompressed page is present.
2022-01-12 12:34:07 +02:00
Marko Mäkelä
0261eac57f Merge 10.5 into 10.6 2022-01-12 12:33:19 +02:00
Marko Mäkelä
017d1b867b MDEV-27476 heap-use-after-free in buf_pool_t::is_block_field()
mtr_t::modify(): Remove a debug assertion that had been added
in commit 05fa4558e0 (MDEV-22110).
The function buf_pool_t::is_uncompressed() is only safe to invoke
while holding a buf_pool.page_hash latch so that buf_pool_t::resize()
cannot concurrently invoke free() on any chunks.
2022-01-12 12:29:16 +02:00
Eugene Kosov
f443cd1100 MDEV-27022 Buffer pool is being flushed during recovery
The problem was introduced by the removal of buf_pool.flush_rbt
in commit 46b1f50098 (MDEV-23399)

recv_sys_t::apply(): don't write to disc and fsync() the last batch.
Insead, sort it by oldest_modification for MariaDB server and some
mariabackup operations.

log_sort_flush_list(): a thread-safe function which sorts buf_pool::flush_list
2022-01-11 16:20:20 +03:00
Thirunarayanan Balathandayuthapani
428b057ee0 MDEV-27640 trx_has_lock_x() gives wrong result if the table has pending table lock
trx_has_lock_x() fails to find whether the trx has X-lock on the table
when other transactions are waiting for an X or S lock on the table.
2022-01-10 19:19:15 +05:30
Marko Mäkelä
fcbd398924 Cleanup: Remove unused log_cmdq_key
There was an intention to add a CommandQueue in
mysql/mysql-server@eca5b0fc17
but it never appeared in any release (not even MySQL 5.7.3
where that commit appeared).
2022-01-10 11:21:17 +02:00
Rucha Deodhar
81e00485c3 MDEV-23836: Assertion `! is_set() || m_can_overwrite_status' in
Diagnostics_area::set_error_status (interrupted ALTER TABLE under LOCK)

Analysis: KILL_QUERY is not ignored when local memory used exceeds maximum
session memory. Hence the query proceeds, OK is sent and we end up
reopening tables that are marked for reopen. During this, kill status is
eventually checked and assertion failure happens during trying to send error
message because OK has already been sent.
Fix: Ok is already sent so statement has already executed. It is too
late to give error. So ignore kill.
2022-01-10 13:31:01 +05:30
Vladislav Vaintroub
c62bb9c3b4 Silence CMake warning from exteral cmake project (pcre2)
The warning reads:

CMake Deprecation Warning at CMakeLists.txt:101 (CMAKE_MINIMUM_REQUIRED):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
2022-01-09 23:52:24 +01:00
Marko Mäkelä
75d4c530c5 MDEV-26879: Detach innodb_evict_tables_on_commit_debug from SAFE_MUTEX
In commit 18535a4028 (MDEV-24811)
the implementation of innodb_evict_tables_on_commit_debug
depended on dict_sys.mutex and SAFE_MUTEX.
That is no longer the case.

SAFE_MUTEX is not available on Microsoft Windows.
2022-01-09 14:09:00 +02:00
Thirunarayanan Balathandayuthapani
e8d1bb0459 MDEV-27017 Assertion failure 'table->get_ref_count() == 0' on DDL that involves FULLTEXT INDEX
purge_sys.stop_FTS() does not wait for purge operation
on FTS tables to finish. InnoDB DDL does purge_sys.stop_FTS()
and lock all fts tables. It eventually fails due to
n_ref_count value.

fts_stop_purge(): Stops the purge thread to process new FTS tables,
check n_ref_count of all fts index auxiliary, common tables.
This should make sure that consecutive fts_lock_tables()
is always successful.
2022-01-05 20:09:50 +05:30
Marko Mäkelä
59e8a12657 MDEV-26879 innodb_evict_tables_on_commit_debug=on makes table creation hang
In commit c5fd9aa562 (MDEV-25919)
an incorrect change to lock_release() was applied.

The setting innodb_evict_tables_on_commit_debug=on should only be
applied to normal transactions, not DDL transactions in the likes of
CREATE TABLE, nor transactions that are holding dict_sys.latch,
such as dict_stats_save().
2022-01-05 12:14:01 +02:00
Vladislav Vaintroub
2a6e086902 MDEV-27335 Windows, MSI - Bring the datadir location into the instance config UI 2022-01-05 10:46:54 +01:00
Vladislav Vaintroub
3712808ad2 Windows installer - fix UI of the "Uninstall" Dialog.
Give RemoveDatadirText field extra 10 pixels in height, to avoid
truncated display of directory path
2022-01-05 10:46:54 +01:00
Jesús Marín
b773416888 Update errmsg-utf8.txt (spa) part 2
Further changes to 3e0304884b

New changes in translation:

* Converted to LATAM countries treatment: tú for vd. This way it serves good for Spain and all LATAM countries.
* Minor changes
2022-01-05 12:19:59 +11:00
Marko Mäkelä
cd751f0259 Work around MDEV-27421 ./mtr --ps-protocol main.opt_trace 2022-01-04 15:53:02 +02:00
Marko Mäkelä
3f5726768f Merge 10.5 into 10.6 2022-01-04 09:26:38 +02:00
Marko Mäkelä
4c3ad24413 MDEV-27416 InnoDB hang in buf_flush_wait_flushed(), on log checkpoint
InnoDB could sometimes hang when triggering a log checkpoint. This is
due to commit 7b1252c03d (MDEV-24278),
which introduced an untimed wait to buf_flush_page_cleaner().

The hang was noticed by occasional failures of IMPORT TABLESPACE tests,
such as innodb.innodb-wl5522, which would (unnecessarily) invoke
log_make_checkpoint() from row_import_cleanup().

The reason of the hang was that buf_flush_page_cleaner() would enter
untimed sleep despite buf_flush_sync_lsn being set. The exact failure
scenario is unclear, because buf_flush_sync_lsn should actually be
protected by buf_pool.flush_list_mutex. We prevent the hang by
invoking buf_pool.page_cleaner_set_idle(false) whenever we are
setting buf_flush_sync_lsn and signaling buf_pool.do_flush_list.

The bulk of these changes was originally developed as a preparation
for MDEV-26827, to invoke buf_flush_list() from fewer threads,
and tested on 10.6 by Matthias Leich.

This fix was tested by running 100 repetitions of 100 concurrent instances
of the test innodb.innodb-wl5522 on a RelWithDebInfo build, using ext4fs
and innodb_flush_method=O_DIRECT on a SATA SSD with 4096-byte block size.
During the test, the call to log_make_checkpoint() in row_import_cleanup()
was present.

buf_flush_list(): Make static.

buf_flush_wait(): Wait for buf_pool.get_oldest_modification()
to reach a target, by work done in the buf_flush_page_cleaner.
If buf_flush_sync_lsn is going to be set, we will invoke
buf_pool.page_cleaner_set_idle(false).

buf_flush_ahead(): If buf_flush_sync_lsn or buf_flush_async_lsn
is going to be set and the page cleaner woken up, we will invoke
buf_pool.page_cleaner_set_idle(false).

buf_flush_wait_flushed(): Invoke buf_flush_wait().

buf_flush_sync(): Invoke recv_sys.apply() at the start in case
crash recovery is active. Invoke buf_flush_wait().

buf_flush_sync_batch(): A lower-level variant of buf_flush_sync()
that is only called by recv_sys_t::apply().

buf_flush_sync_for_checkpoint(): Do not trigger log apply
or checkpoint during recovery.

buf_dblwr_t::create(): Only initiate a buffer pool flush, not
a checkpoint.

row_import_cleanup(): Do not unnecessarily invoke log_make_checkpoint().
Invoking buf_flush_list_space() before starting to generate redo log
for the imported tablespace should suffice.

srv_prepare_to_delete_redo_log_file():
Set recv_sys.recovery_on in order to prevent
buf_flush_sync_for_checkpoint() from initiating a checkpoint
while the log is inaccessible. Remove a wait loop that is already
part of buf_flush_sync().
Do not invoke fil_names_clear() if the log is being upgraded,
because the FILE_MODIFY record is specific to the latest format.

create_log_file(): Clear recv_sys.recovery_on only after calling
log_make_checkpoint(), to prevent buf_flush_page_cleaner from
invoking a checkpoint.

innodb_shutdown(): Simplify the logic in mariadb-backup --prepare.

os_aio_wait_until_no_pending_writes(): Update the function comment.
Apart from row_quiesce_table_start() during FLUSH TABLES...FOR EXPORT,
this is being called by buf_flush_list_space(), which is invoked
by ALTER TABLE...IMPORT TABLESPACE as well as some encryption operations.
2022-01-04 07:40:31 +02:00