Commit graph

191360 commits

Author SHA1 Message Date
Eugene Kosov
fccd810404 MDEV-24333 Data race in os_file_pread at os/os0file.cc:3308 on os_n_file_reads
os_n_file_reads: make Atomic_counter and correct the semantics of an imprecise
counter.

Reviewed by: Marko Mäkelä
2020-12-03 11:55:21 +03:00
Marko Mäkelä
f146969fb3 MDEV-22929 fixup: root_name() clash with clang++ <fstream>
The clang++ -stdlib=libc++ header file <fstream> depends on
<filesystem> that defines a member function path::root_name(),
which conflicts with the rather unused #define root_name()
that had been introduced in
commit 7c58e97bf6.

Because an instrumented -stdlib=libc++ (rather than the default
-stdlib=libstdc++) is easier to build for a working -fsanitize=memory
(cmake -DWITH_MSAN=ON), let us remove the conflicting #define for now.
2020-12-03 07:45:48 +02:00
Marko Mäkelä
f3a58ed801 MDEV-24295: Fix the non-clang build
Sorry, only tested commit 4174fc1a1b
on clang. Other compilers do not define __has_feature().
2020-12-02 22:04:57 +02:00
Marko Mäkelä
4174fc1a1b MDEV-24295: Fix the WITH_MSAN build
For some reason, commit 5bb5d4ad3a
made clang++-11 unhappy about a constexpr declaration.
2020-12-02 21:46:01 +02:00
Marko Mäkelä
9b725f9aef MDEV-20051 fixup: Correct galera.galera_defaults result
For some reason, the test was never adjusted for
commit e6a50e41da.
2020-12-02 21:28:18 +02:00
Marko Mäkelä
6a1e655cb0 Merge 10.4 into 10.5 2020-12-02 18:29:49 +02:00
Marko Mäkelä
24ec8eaf66 MDEV-15532 after-merge fixes from Monty
The Galera tests were massively failing with debug assertions.
2020-12-02 16:16:29 +02:00
Marko Mäkelä
589cf8dbf3 Merge 10.3 into 10.4 2020-12-01 19:51:14 +02:00
Vlad Lesin
e30a05f454 MDEV-22929 MariaBackup option to report and/or continue when corruption is encountered
Post-push Windows compilation errors fix.
2020-12-01 18:33:10 +03:00
Monty
7edfed6305 After merge fixes
Change thd->mdl_context.release_transactional_locks() to
thd->mdl_release_transactional_locks()
2020-12-01 16:23:28 +02:00
Marko Mäkelä
73f34336e3 MDEV-24323 Crash on recovery after kill during instant ADD COLUMN
row_undo_ins_parse_undo_rec(): Do not try to read non-existing
virtual column information for the metadata record.
2020-12-01 15:24:49 +02:00
Marko Mäkelä
81ab9ea63f Merge 10.2 into 10.3 2020-12-01 14:55:46 +02:00
Marko Mäkelä
e76e12886f MDEV-21962 fixup: Remove buf_pool_contains_zip()
The replacement is buf_pool.contains_zip().
2020-12-01 12:04:32 +02:00
Vlad Lesin
e6b3e38d62 MDEV-22929 MariaBackup option to report and/or continue when corruption is encountered
The new option --log-innodb-page-corruption is introduced.

When this option is set, backup is not interrupted if innodb corrupted
page is detected. Instead it logs all found corrupted pages in
innodb_corrupted_pages file in backup directory and finishes with error.

For incremental backup corrupted pages are also copied to .delta file,
because we can't do LSN check for such pages during backup,
innodb_corrupted_pages will also be created in incremental backup
directory.

During --prepare, corrupted pages list is read from the file just after
redo log is applied, and each page from the list is checked if it is allocated
in it's tablespace or not. If it is not allocated, then it is zeroed out,
flushed to the tablespace and removed from the list. If all pages are removed
from the list, then --prepare is finished successfully and
innodb_corrupted_pages file is removed from backup directory. Otherwise
--prepare is finished with error message and innodb_corrupted_pages contains
the list of the pages, which are detected as corrupted during backup, and are
allocated in their tablespaces, what means backup directory contains corrupted
innodb pages, and backup can not be considered as consistent.

For incremental --prepare corrupted pages from .delta files are applied
to the base backup, innodb_corrupted_pages is read from both base in
incremental directories, and the same action is proceded for corrupted
pages list as for full --prepare. innodb_corrupted_pages file is
modified or removed only in base directory.

If DDL happens during backup, it is also processed at the end of backup
to have correct tablespace names in innodb_corrupted_pages.
2020-12-01 08:08:57 +03:00
Monty
828471cbf8 MDEV 15532 Assertion `!log->same_pk' failed in row_log_table_apply_delete
The reason for the failure is that
thd->mdl_context.release_transactional_locks()
was called after commit & rollback even in cases where the current
transaction is still active.

For 10.2, 10.3 and 10.4 the fix is simple:
- Replace all calls to thd->mdl_context.release_transactional_locks() with
  thd->release_transactional_locks(). The thd function will only call
  the mdl_context function if there are no active transactional locks.
  In 10.6 we will better fix where we will change the return value for
  some trans_xxx() functions to indicate if transaction did close the
  transaction or not. This will avoid the need of the indirect call.

Other things:
- trans_xa_commit() and trans_xa_rollback() will automatically
  call release_transactional_locks() if the transaction is closed.
- We can't do that for the other functions as the caller of many of these
  are doing additional work (like close_thread_tables) before calling
  release_transactional_locks().
- Added missing abort_result_set() and missing DBUG_RETURN in
  select_create::send_eof()
- Fixed wrong indentation in injector::transaction::commit()
2020-11-30 22:21:43 +02:00
Monty
c537576495 Fixed maria.create test 2020-11-30 19:57:50 +02:00
Monty
a3531775b1 MDEV-15532 Assertion `!log->same_pk' failed in row_log_table_apply_delete
The real fix for MDEV-15532 will be pushed into 10.2 and 10.6
This is an additional fix for 10.4.

In 10.4 trans_xa_detach was introduced.  However THD::cleanup() assumes
that after trans_xa_detach() is done, there is no registered transactions
anymore. In the 10.2 patch there will be an assert to ensure this, which
will cause 10.4 to fail.

The fix used is to reset the transaction flags in trans_xa_detach().
2020-11-30 19:53:58 +02:00
Monty
6261b1f45e Fixed maria.create test 2020-11-30 19:49:06 +02:00
Vladislav Vaintroub
1435f35bda Clarify some comments.
- the intention for my_getevents syscall is now better explained,
why are we using it (to be able to interrupt io_getevents syscall via
io_destroy()).

- Fix comment for MAX_EVENTS in getevent_thread_routine.
MAX_EVENTS is more of less arbitrary constant, chosen such that events array
is big enough to get multiple simultaneous io completions, but small
enough so it does not blow the thread's stack.
2020-11-30 16:46:06 +01:00
Vladislav Vaintroub
5bb5d4ad3a MDEV-24295 Reduce wakeups by tpool maintenance timer, when server is idle
If maintenance timer does not do much for prolonged time, it will
wake up less frequently, once every 4 seconds instead of once every 0.4
second.

It will wakeup more often if thread creation is throttled, to avoid stalls.
2020-11-30 16:46:05 +01:00
Monty
37352c4b55 Disable mysqldump-system.test if auth socket plugin is not dynamic 2020-11-30 15:02:33 +02:00
Sergei Petrunia
111963477b Make LEX::print support single-table DELETE. 2020-11-30 15:19:25 +03:00
Marko Mäkelä
e34e53b554 MDEV-24308: Revert for Windows
For some reason, InnoDB debug tests on Windows fail due to rw_lock_t
if the function call overhead for some os_thread_ code is removed.

This change worked fine on Windows in combination with MDEV-24142.
2020-11-30 13:59:20 +02:00
Varun Gupta
b4379df5b4 MDEV-21265: IN predicate conversion to IN subquery should be allowed for a broader set of datatype comparison
Allow materialization strategy when collations on the
inner and outer sides of an IN subquery are the same and the
character set of the inner side is a proper subset of the character
set on the outer side.
This allows conversion from utf8mb3 to utf8mb4
as the former is a subset of the later.
This is only allowed when IN predicate is converted to an IN subquery

Backported part of the patch (d6a00d9b18) of MDEV-17905.
2020-11-30 17:16:43 +05:30
Marko Mäkelä
8fa6e36375 MDEV-24308: Remove some os_thread_ functions
os_thread_pf(): Remove.

os_thread_eq(), os_thread_yield(), os_thread_get_curr_id():
Define as macros.

ut_print_timestamp(), ut_sprintf_timestamp(): Simplify.
2020-11-30 11:15:31 +02:00
Igor Babaev
b92391d5b1 MDEV-24242 Query returns wrong result while using big_tables=1
When executing set operations in a pipeline using only one temporary table
additional scans of intermediate results may be needed. The scans are
performed with usage of the rnd_next() handler function that might
leave record buffers used for the temporary table not in a state that
is good for following writes into the table. For example it happens for
aria engine when the last call of rnd_next() encounters only deleted
records. Thus a cleanup of record buffers is needed after each such scan
of the temporary table.

Approved by Oleksandr Byelkin <sanja@mariadb.com>
2020-11-27 10:43:47 -08:00
Monty
1555c6d125 Fixed compiler warnings from crc32c.cc 2020-11-26 19:13:37 +02:00
Monty
279b5f87de Avoid some DBUG prints from idle server in thread pool 2020-11-26 19:13:37 +02:00
Monty
55f734ed87 Change to LONGLONG_BUFFER_SIZE usage to avoid extra mallocs
This change is needed in 10.5 to avoid extra malloc calls in val_str().
In 10.6 it's not needed anymore but the extra +1 byte doesn't harm
that much.
2020-11-26 19:13:37 +02:00
Monty
c8992fc35b Trivial cleanups, no logic changes
- Fold long comment rows and updated comments
- Moved one private function in class Item_func_rand among other private
  functions
2020-11-26 19:13:37 +02:00
Monty
3d56bea3ef Allow field_name NOT NULL ENABLED
This is for Oracle compatiblity. ENABLED is in Oracle the default case
and just ensures that the NOT NULL constraints will be tested, which is
also default in MariaDB
2020-11-26 19:13:37 +02:00
Monty
55b2788800 Fixed length estimate for REPLACE() 2020-11-26 19:13:37 +02:00
Anel Husakovic
1ccd1daaff MDEV-24289: show grants missing with grant option
Reviewed by:serg@mariadb.com
2020-11-26 18:10:40 +01:00
Sergei Golubchik
f3b10354a9 MDEV-24230 subquery on information_schema fails with error message
disable thd->count_cuted_fields when populating internal temporary
tables for I_S, because this is how SELECT works standalone.
And if the SELECT is a part of INSERT or UPDATE or RETURN or SET or
anything else that enables thd->count_cuted_fields, this counting should
only apply when storing the result of the SELECT in a field or a
variable, not when populating internal temporary tables for I_S.
2020-11-25 22:19:59 +01:00
Sergei Golubchik
00f54b56b1 cleanup: RAII helper for changing thd->count_cuted_rows 2020-11-25 22:19:59 +01:00
Eugene Kosov
5991bd6215 MDEV-24275 InnoDB persistent stats analyze forces full scan forcing lock crash
This is a fixup patch for MDEV-23991 afc9d00c66

We really should read result.n_leaf_pages, which was set previously.

Analysis and fix was provided by Jukka Santala. Thanks!

Reviewed by: Marko Mäkelä
2020-11-25 18:28:40 +03:00
Marko Mäkelä
657fcdf430 MDEV-24280 InnoDB triggers too many independent periodic tasks
A side effect of MDEV-16264 is that a large number of threads will
be created at server startup, to be destroyed after a minute or two.

One source of such thread creation is srv_start_periodic_timer().
InnoDB is creating 3 periodic tasks: srv_master_callback (1Hz)
srv_error_monitor_task (1Hz), and srv_monitor_task (0.2Hz).

It appears that we can merge srv_error_monitor_task and srv_monitor_task
and have them invoked 4 times per minute (every 15 seconds). This will
affect our ability to enforce innodb_fatal_semaphore_wait_threshold and
some computations around BUF_LRU_STAT_N_INTERVAL.

We could remove srv_master_callback along with the DROP TABLE queue
at some point of time in the future. We must keep it independent
of the innodb_fatal_semaphore_wait_threshold detection, because
the background DROP TABLE queue could get stuck due to dict_sys
being locked by another thread. For now, srv_master_callback
must be invoked once per second, so that
innodb_flush_log_at_timeout=1 can work.

BUF_LRU_STAT_N_INTERVAL: Reduce the precision and extend the time
from 50*1 second to 4*15 seconds.

srv_error_monitor_timer: Remove.

MAX_MUTEX_NOWAIT: Increase from 20*1 second to 2*15 seconds.

srv_refresh_innodb_monitor_stats(): Avoid a repeated call to time(NULL).
Change the interval to less than 60 seconds.

srv_monitor(): Renamed from srv_monitor_task.

srv_monitor_task(): Renamed from srv_error_monitor_task().
Invoked only once in 15 seconds. Invoke also srv_monitor().
Increase the fatal_cnt threshold from 10*1 second to 1*15 seconds.

sync_array_print_long_waits_low(): Invoke time(NULL) only once.
Remove a bogus message about printouts for 30 seconds. Those
printouts were effectively already disabled in MDEV-16264
(commit 5e62b6a5e0).
2020-11-25 16:54:00 +02:00
Marko Mäkelä
7b1252c03d MDEV-24278 InnoDB page cleaner keeps waking up on idle server
The purpose of the InnoDB page cleaner subsystem is to write out
modified pages from the buffer pool to data files. When the
innodb_max_dirty_pages_pct_lwm is not exceeded or
innodb_adaptive_flushing=ON decides not to write out anything,
the page cleaner should keep sleeping indefinitely until the state
of the system changes: a dirty page is added to the buffer pool such
that the page cleaner would no longer be idle.

buf_flush_page_cleaner(): Explicitly note when the page cleaner is idle.
When that happens, use mysql_cond_wait() instead of mysql_cond_timedwait().

buf_flush_insert_into_flush_list(): Wake up the page cleaner if needed.

innodb_max_dirty_pages_pct_update(),
innodb_max_dirty_pages_pct_lwm_update():
Wake up the page cleaner just in case.

Note: buf_flush_ahead(), buf_flush_wait_flushed() and shutdown are
already waking up the page cleaner thread.
2020-11-25 16:09:47 +02:00
Marko Mäkelä
f693b72547 MDEV-24270: Clarify some comments 2020-11-25 16:08:26 +02:00
Vladislav Vaintroub
2de95f7a1e Fix misspelling.
Kudos to Marko for finding.
2020-11-25 13:07:49 +01:00
Vladislav Vaintroub
af98fddc2b Cleanup. Remove obsolete comment 2020-11-25 13:07:08 +01:00
Vladislav Vaintroub
c130c60b2b Cleanup. Provide accurate comment on my_getevents(). 2020-11-25 13:07:08 +01:00
Vladislav Vaintroub
78df9e37a6 Partially Revert "MDEV-24270: Collect multiple completed events at a time"
This partially reverts commit 6479006e14.

Remove the constant tpool::aio::N_PENDING, which has no
intrinsic meaning for the tpool.
2020-11-25 13:07:08 +01:00
Marko Mäkelä
10eaa43f86 Skip main.lock_view for cmake -DPLUGIN_PERFSCHEMA=NO 2020-11-25 13:13:47 +02:00
Marko Mäkelä
3dfeae0e22 Cleanup: Fix Intel compiler warnings about sign conversions 2020-11-25 11:32:49 +02:00
Marko Mäkelä
4a22056c97 Cleanup: Remove redundant nonnull attributes 2020-11-25 11:28:26 +02:00
Marko Mäkelä
1c9833c511 Cleanup: row_log_free()
The nonnull attribute is not applicable to parameters that are
passed by reference, at least not in the Intel compiler.
Let us remove the reference indirection, which was only there
so that the pointer could be assigned to NULL, and let the
callers perform that task.

row_log_allocate(): Fix a bug in out-of-memory error handling
that would leave a pointer to freed memory.
2020-11-25 10:54:38 +02:00
Marko Mäkelä
6479006e14 MDEV-24270: Collect multiple completed events at a time
tpool::aio::N_PENDING: Replaces OS_AIO_N_PENDING_IOS_PER_THREAD.
This limits two similar things: the number of outstanding requests
that a thread may io_submit(), and the number of completed requests
collected at a time by io_getevents().
2020-11-25 09:42:38 +02:00
Marko Mäkelä
7a9405e3dc MDEV-24270 Misuse of io_getevents() causes wake-ups at least twice per second
In the asynchronous I/O interface, InnoDB is invoking io_getevents()
with a timeout value of half a second, and requesting exactly 1 event
at a time.

The reason to have such a short timeout is to facilitate shutdown.

We can do better: Use an infinite timeout, wait for a larger maximum
number of events. On shutdown, we will invoke io_destroy(), which
should lead to the io_getevents system call reporting EINVAL.

my_getevents(): Reimplement the libaio io_getevents() by only invoking
the system call. The library implementation would try to elide the
system call and return 0 immediately if aio_ring_is_empty() holds.
Here, we do want a blocking system call, not 100% CPU usage. Neither
do we want the aio_ring_is_empty() trigger SIGSEGV because it is
dereferencing some memory that was freed by io_destroy().
2020-11-25 09:40:12 +02:00
Marko Mäkelä
1b12e251cd MDEV-24271 rw_lock::read_lock_yield() may cause writer starvation
The greedy fetch_add(1) approach of read_trylock() may cause
starvation of a waiting write lock request. Let us use a
compare-and-swap for the read lock acquisition in order to
guarantee the progress of writers.
2020-11-24 14:01:00 +02:00