Commit graph

193309 commits

Author SHA1 Message Date
Marko Mäkelä
e04bbf73dc MDEV-25496 Assertion 'trx->bulk_insert' failed on INSERT
row_get_prebuilt_insert_row(): Remove some fallback code that had been
added in commit 8ea923f55b (MDEV-24818).
It seems that after all, statement boundaries are being reliably
indicated by ha_innobase::start_stmt() or
(for partitioned tables) ha_innobase::external_lock().
2021-06-29 15:20:33 +03:00
Marko Mäkelä
4b0070f642 MDEV-26029: Implement my_test_if_thinly_provisioned() for ScaleFlux
This is based on code that was contributed by Ning Zheng and Ray Kuan
from ScaleFlux.
2021-06-29 15:20:16 +03:00
Marko Mäkelä
30edd5549d MDEV-26029: Sparse files are inefficient on thinly provisioned storage
The MariaDB implementation of page_compressed tables for InnoDB used
sparse files. In the worst case, in the data file, every data page
will consist of some data followed by a hole. This may be extremely
inefficient in some file systems.

If the underlying storage device is thinly provisioned (can compress
data on the fly), it would be good to write regular files (with sequences
of NUL bytes at the end of each page_compressed block) and let the
storage device take care of compressing the data.

For reads, sparse file regions and regions containing NUL bytes will be
indistinguishable.

my_test_if_disable_punch_hole(): A new predicate for detecting thinly
provisioned storage. (Not implemented yet.)

innodb_atomic_writes: Correct the comment.

buf_flush_page(): Support all values of fil_node_t::punch_hole.
On a thinly provisioned storage device, we will always write
NUL-padded innodb_page_size bytes also for page_compressed tables.

buf_flush_freed_pages(): Remove a redundant condition.

fil_space_t::atomic_write_supported: Remove. (This was duplicating
fil_node_t::atomic_write.)

fil_space_t::punch_hole: Remove. (Duplicated fil_node_t::punch_hole.)

fil_node_t: Remove magic_n, and consolidate flags into bitfields.
For punch_hole we introduce a third value that indicates a
thinly provisioned storage device.

fil_node_t::find_metadata(): Detect all attributes of the file.
2021-06-29 15:18:22 +03:00
Marko Mäkelä
b11aa0df85 Merge 10.5 into 10.6 2021-06-29 15:18:18 +03:00
Marko Mäkelä
3d15e3c085 MDEV-22640 fixup: clang -Winconsistent-missing-override 2021-06-29 15:02:10 +03:00
Marko Mäkelä
58252fff15 MDEV-26040 os_file_set_size() may not work on O_DIRECT files
os_file_set_size(): Trim the current size down to the file system
block size, to obey the constraints for unbuffered I/O.
2021-06-29 14:28:23 +03:00
Andrei Elkin
390014781b MDEV-26031 unnessary xid logging in one phase commit case
The bug was originally observed as hanging binlog background thread at
shutdown similar to one of MDEV-21120.
It occurred through unnessary xid logging in 1pc execution.

Two parts of the issue are fixed.  Per engine loop by involved engine
with attempt to mark a group requiring xid unlogging gets corrected in
two ways. Do not execute it when the termination event is irrelevant
for recovery, does not have xid in particular.  Do not break the loop
anymore unconditionally at the end of the 1st iteration.
2021-06-29 14:13:37 +03:00
Julius Goryavsky
6431862022 MDEV-25978 post-merge: updated mtr result files 2021-06-29 12:44:42 +02:00
Julius Goryavsky
58700a426a MDEV-26019: Upgrading MariaDB breaks TLS mariabackup SST
Fixed typo in variable name that breaks SST in some scenatios.

Also fixed one small inaccuracy after MDEV-25978 which leads
to the use of an uninitialized variable when the --log-bin
option is specified without an argument.
2021-06-29 12:42:14 +02:00
Vicențiu Ciorbaru
c29f45ce77 MDEV-25481 Memory leak in Cached_item_str::Cached_item_str WITH TIES involving a blob
Make sure to call cached item's destructors.
2021-06-29 00:13:57 +03:00
Marko Mäkelä
63e9a05440 MDEV-25942: Assertion !table.n_waiting_or_granted_auto_inc_locks
trx_t::drop_table(): Remove a bogus debug assertion.
The current transaction may hold an AUTO_INCREMENT
lock on the table while
CREATE TABLE t2 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB SELECT...
is being rolled back due to lock wait timeout.
Remaining debug assertions will check that only this transaction
is holding locks on the table, and that one of them is an exclusive lock.
2021-06-28 15:37:29 +03:00
Alexey Botchkov
8147d2e618 MDEV-25461 Assertion `je->state == JST_KEY' failed in Geometry::create_from_json.
Handle invalid GEOJSON-s in Geometry::create_from_json().
2021-06-28 11:53:33 +04:00
Alexey Botchkov
98c7916f0f MDEV-23004 When using GROUP BY with JSON_ARRAYAGG with joint table, the
square brackets are not included.

Item_func_json_arrayagg::copy_or_same() should be implemented.
2021-06-28 11:14:18 +04:00
Igor Babaev
4e4f742ed7 Adjusted test results after the fix for MDEV-20411 (2) 2021-06-26 23:11:10 -07:00
Igor Babaev
8b3f816cab Adjusted test results after the fix for MDEV-20411 2021-06-26 08:51:17 -07:00
Marko Mäkelä
891a927e80 Merge 10.5 into 10.6 2021-06-26 11:53:28 +03:00
Marko Mäkelä
fc2ff46469 MDEV-26017: Assertion stat.flush_list_bytes <= curr_pool_size
buf_flush_relocate_on_flush_list(): If we are removing the block from
buf_pool.flush_list, subtract its size from buf_pool.stat.flush_list_bytes.
This fixes a regression that was introduced in
commit 22b62edaed (MDEV-25113).
2021-06-26 11:52:25 +03:00
Marko Mäkelä
aa95c42360 Cleanup: Remove unused mtr_block_dirtied 2021-06-26 11:17:05 +03:00
Marko Mäkelä
759deaa0a2 MDEV-26010 fixup: Use acquire/release memory order
In commit 5f22511e35 we depend on
Total Store Ordering. For correct operation on ISAs that implement
weaker memory ordering, we must explicitly use release/acquire stores
and loads on buf_page_t::oldest_modification_ to prevent a race condition
when buf_page_t::list does not happen to be on the same cache line.

buf_page_t::clear_oldest_modification(): Assert that the block is
not in buf_pool.flush_list, and use std::memory_order_release.

buf_page_t::oldest_modification_acquire(): Read oldest_modification_
with std::memory_order_acquire. In this way, if the return value is 0,
the caller may safely assume that it will not observe the buf_page_t
as being in buf_pool.flush_list, even if it is not holding
buf_pool.flush_list_mutex.

buf_flush_relocate_on_flush_list(), buf_LRU_free_page():
Invoke buf_page_t::oldest_modification_acquire().
2021-06-26 11:16:40 +03:00
Igor Babaev
12c80df482 MDEV-20411 Procedure containing CTE incorrectly stored in mysql.proc
If the first token of the body of a stored procedure was 'WITH' then
the beginning of the body was determined incorrectly and that token was
missing in the string representing the body of the SP in mysql.proc. As a
resultnany call of such procedure failed as the string representing the
body could not be parsed.

The patch corrects the code of the functions get_tok_start() and
get_cpp_tok_start() of the class Lex_input_stream to make them take into
account look ahead tokens. The patch is needed only for 10.2 as this
problem has neen resolved in 10.3+.
2021-06-25 18:06:08 -07:00
Jan Lindström
1c03e7a667 MDEV-25978 : rsync SST does not work with custom binlog name
wsrep_sst_common did not correctly set name for binlog index
file if custom binlog name was used and this name was
not added to script command line.

Added test case for both log_basename and log_binlog.
2021-06-25 21:23:04 +02:00
Julius Goryavsky
29098083f7 MDEV-26019: Upgrading MariaDB breaks TLS mariabackup SST
Fixed typo in variable name that breaks SST in some scenatios.

Also fixed one small inaccuracy after MDEV-25978 which leads
to the use of an uninitialized variable when the --log-bin
option is specified without an argument.
2021-06-25 07:15:55 +02:00
Jan Lindström
05a4996c5c MDEV-25978 : rsync SST does not work with custom binlog name
wsrep_sst_common did not correctly set name for binlog index
file if custom binlog name was used and this name was
not added to script command line.

Added test case for both log_basename and log_binlog.
2021-06-25 07:15:00 +02:00
Julius Goryavsky
4ad148b148 MDEV-26019: Upgrading MariaDB breaks TLS mariabackup SST
Fixed typo in variable name that breaks SST in some scenatios.

Also fixed one small inaccuracy after MDEV-25978 which leads
to the use of an uninitialized variable when the --log-bin
option is specified without an argument.
2021-06-25 07:09:54 +02:00
Marko Mäkelä
a8350cfb5e Merge 10.5 into 10.6 2021-06-24 21:56:44 +03:00
Marko Mäkelä
5f22511e35 MDEV-26010: Assertion lsn > 2 failed in buf_pool_t::get_oldest_modification
In commit 22b62edaed (MDEV-25113)
we introduced a race condition. buf_LRU_free_page() would read
buf_page_t::oldest_modification() as 0 and assume that
buf_page_t::list can be used (for attaching the block to the
buf_pool.free list). In the observed race condition,
buf_pool_t::delete_from_flush_list() had cleared the field,
and buf_pool_t::delete_from_flush_list_low() was executing
concurrently with buf_LRU_block_free_non_file_page(),
which resulted in buf_pool.flush_list.end becoming corrupted.

buf_pool_t::delete_from_flush_list(), buf_flush_relocate_on_flush_list():
First remove the block from buf_pool.flush_list, and only then
invoke buf_page_t::clear_oldest_modification(), to ensure that
reading oldest_modification()==0 really implies that the block
no longer is in buf_pool.flush_list.
2021-06-24 21:55:10 +03:00
Marko Mäkelä
e329dc8d86 MDEV-25948 fixup: Demote a warning to a note
buf_dblwr_t::recover(): Issue a note, not a warning, about
pages whose FIL_PAGE_LSN is in the future. This was supposed to be
part of commit 762bcb81b5 (MDEV-25948)
but had been accidentally omitted.
2021-06-24 18:51:05 +03:00
Marko Mäkelä
82fe83a34c MDEV-26012 InnoDB purge and shutdown hangs after failed ALTER TABLE
ha_innobase::commit_inplace_alter_table(): Invoke
purge_sys.resume_FTS() on all error handling paths
if purge_sys.stop_FTS() had been called.

This fixes a regression that had been introduced in
commit 1bd681c8b3 (MDEV-25506).
2021-06-24 16:07:27 +03:00
Marko Mäkelä
033e29b6a1 MDEV-26007 Rollback unnecessarily initiates redo log write
trx_t::commit_in_memory(): Do not initiate a redo log write if
the transaction has no visible effect. If anything for this
transaction had been made durable, crash recovery will roll back
the transaction just fine even if the end of ROLLBACK is not
durably written.

Rollbacks of transactions that are associated with XA identifiers
(possibly internally via the binlog) will always be persisted.
The test rpl.rpl_gtid_crash covers this.
2021-06-24 15:00:34 +03:00
Marko Mäkelä
b4c9cd201b Merge 10.5 into 10.6 2021-06-24 12:39:34 +03:00
Marko Mäkelä
60ed479711 MDEV-26004 Excessive wait times in buf_LRU_get_free_block()
buf_LRU_get_free_block(): Initially wait for a single block to be
freed, signaled by buf_pool.done_free. Only if that fails and no
LRU eviction flushing batch is already running, we initiate a
flushing batch that should serve all threads that are currently
waiting in buf_LRU_get_free_block().

Note: In an extreme case, this may introduce a performance regression
at larger numbers of connections. We observed this in sysbench
oltp_update_index with 512MiB buffer pool, 4GiB of data on fast NVMe,
and 1000 concurrent connections, on a 20-thread CPU. The contention point
appears to be buf_pool.mutex, and the improvement would turn into a
regression somewhere beyond 32 concurrent connections.

On slower storage, such regression was not observed; instead, the
throughput was improving and maximum latency was reduced.

The excessive waits were pointed out by Vladislav Vaintroub.
2021-06-24 11:01:18 +03:00
Marko Mäkelä
101da87228 Merge 10.5 into 10.6 2021-06-23 19:36:45 +03:00
Marko Mäkelä
6441bc614a MDEV-25113: Introduce a page cleaner mode before 'furious flush'
MDEV-23855 changed the way how the page cleaner is signaled by
user threads. If a threshold is exceeded, a mini-transaction commit
would invoke buf_flush_ahead() in order to initiate page flushing
before all writers would eventually grind to halt in
log_free_check(), waiting for the checkpoint age to reduce.

However, buf_flush_ahead() would always initiate 'furious flushing',
making the buf_flush_page_cleaner thread write innodb_io_capacity_max
pages per batch, and sleeping no time between batches, until the
limit LSN is reached. Because this could saturate the I/O subsystem,
system throughput could significantly reduce during these
'furious flushing' spikes.

With this change, we introduce a gentler version of flush-ahead,
which would write innodb_io_capacity_max pages per second until
the 'soft limit' is reached.

buf_flush_ahead(): Add a parameter to specify whether furious flushing
is requested.

buf_flush_async_lsn: Similar to buf_flush_sync_lsn, a limit for
the less intrusive flushing.

buf_flush_page_cleaner(): Keep working until buf_flush_async_lsn
has been reached.

log_close(): Suppress a warning message in the event that a new log
is being created during startup, when old logs did not exist.
Return what type of page cleaning will be needed.

mtr_t::finish_write(): Also when m_log.is_small(), invoke log_close().
Return what type of page cleaning will be needed.

mtr_t::commit(): Invoke buf_flush_ahead() based on the return value of
mtr_t::finish_write().
2021-06-23 19:06:52 +03:00
Marko Mäkelä
22b62edaed MDEV-25113: Make page flushing faster
buf_page_write_complete(): Reduce the buf_pool.mutex hold time,
and do not acquire buf_pool.flush_list_mutex at all.
Instead, mark blocks clean by setting oldest_modification to 1.
Dirty pages of temporary tables will be identified by the special
value 2 instead of the previous special value 1.
(By design of the ib_logfile0 format, actual LSN values smaller
than 2048 are not possible.)

buf_LRU_free_page(), buf_pool_t::get_oldest_modification()
and many other functions will remove the garbage (clean blocks)
from buf_pool.flush_list while holding buf_pool.flush_list_mutex.

buf_pool_t::n_flush_LRU, buf_pool_t::n_flush_list:
Replaced with non-atomic variables, protected by buf_pool.mutex,
to avoid unnecessary synchronization when modifying the counts.

export_vars: Remove unnecessary indirection for
innodb_pages_created, innodb_pages_read, innodb_pages_written.
2021-06-23 19:06:52 +03:00
Marko Mäkelä
8af538979b MDEV-25801: buf_flush_dirty_pages() is very slow
In commit 7cffb5f6e8 (MDEV-23399)
the implementation of buf_flush_dirty_pages() was replaced with
a slow one, which would perform excessive scans of the
buf_pool.flush_list and make little progress.

buf_flush_list(), buf_flush_LRU(): Split from buf_flush_lists().
Vladislav Vaintroub noticed that we will not need to invoke
log_flush_task.wait() for the LRU eviction flushing.

buf_flush_list_space(): Replaces buf_flush_dirty_pages().
This is like buf_flush_list(), but operating on a single
tablespace at a time. Writes at most innodb_io_capacity
pages. Returns whether some of the tablespace might remain
in the buffer pool.
2021-06-23 19:06:52 +03:00
Marko Mäkelä
762bcb81b5 MDEV-25948 Remove log_flush_task
Vladislav Vaintroub suggested that invoking log_flush_up_to()
for every page could perform better than invoking a log write
between buf_pool.flush_list batches, like we started doing in
commit 3a9a3be1c6 (MDEV-23855).
This could depend on the sequence in which pages are being
modified. The buf_pool.flush_list is ordered by
oldest_modification, while the FIL_PAGE_LSN of the pages is
theoretically independent of that. In the pathological case,
we will wait for a log write before writing each individual page.

It turns out that we can defer the call to log_flush_up_to()
until just before submitting the page write. If the doublewrite
buffer is being used, we can submit a write batch of "future" pages
to the doublewrite buffer, and only wait for the log write right
before we are writing an already doublewritten page.
The next doublewrite batch will not be initiated before the last
page write from the current batch has completed.

When a future version introduces asynchronous writes if the log,
we could initiate a write at the start of a flushing batch, to
reduce waiting further.
2021-06-23 19:06:52 +03:00
Marko Mäkelä
6dfd44c828 MDEV-25954: Trim os_aio_wait_until_no_pending_writes()
It turns out that we had some unnecessary waits for no outstanding
write requests to exist. They were basically working around a
bug that was fixed in MDEV-25953.

On write completion callback, blocks will be marked clean.
So, it is sufficient to consult buf_pool.flush_list to determine
which writes have not been completed yet.

On FLUSH TABLES...FOR EXPORT we must still wait for all pending
asynchronous writes to complete, because buf_flush_file_space()
would merely guarantee that writes will have been initiated.
2021-06-23 19:06:49 +03:00
Marko Mäkelä
6e12ebd4a7 MDEV-25062: Reduce trx_rseg_t::mutex contention
redo_rseg_mutex, noredo_rseg_mutex: Remove the PERFORMANCE_SCHEMA keys.
The rollback segment mutex will be uninstrumented.

trx_sys_t: Remove pointer indirection for rseg_array, temp_rseg.
Align each element to the cache line.

trx_sys_t::rseg_id(): Replaces trx_rseg_t::id.

trx_rseg_t::ref: Replaces needs_purge, trx_ref_count, skip_allocation
in a single std::atomic<uint32_t>.

trx_rseg_t::latch: Replaces trx_rseg_t::mutex.

trx_rseg_t::history_size: Replaces trx_sys_t::rseg_history_len

trx_sys_t::history_size_approx(): Replaces trx_sys.rseg_history_len
in those places where the exact count does not matter. We must not
acquire any trx_rseg_t::latch while holding index page latches, because
normally the trx_rseg_t::latch is acquired before any page latches.

trx_sys_t::history_exists(): Replaces trx_sys.rseg_history_len!=0
with an approximation.

We remove some unnecessary trx_rseg_t::latch acquisition around
trx_undo_set_state_at_prepare() and trx_undo_set_state_at_finish().
Those operations will only access fields that remain constant
after trx_rseg_t::init().
2021-06-23 13:42:11 +03:00
Marko Mäkelä
b3e8788009 MDEV-25967: Correctly extend deferred-recovery files
recv_sys_t::recover_deferred(): Set the file size to match the number
of pages. Mariabackup might copy the file while it was being extended.
2021-06-23 13:37:11 +03:00
Marko Mäkelä
592a925c0c MDEV-25996 sux_lock::s_lock(): Assertion !have_s() failed on startup
dict_check_sys_tables(): Correctly advance the cursor position.
This fixes a regression that was caused by
commit 49e2c8f0a6 (MDEV-25743).
2021-06-23 13:36:04 +03:00
Marko Mäkelä
3a566de22d Merge 10.5 into 10.6 2021-06-23 09:24:32 +03:00
Marko Mäkelä
344e59904d Merge 10.4 into 10.5 2021-06-23 08:17:49 +03:00
Jan Lindström
9258cfa4b4 MDEV-25978 : rsync SST does not work with custom binlog name
wsrep_sst_common did not correctly set name for binlog index
file if custom binlog name was used and this name was
not added to script command line.

Added test case for both log_basename and log_binlog.
2021-06-23 08:11:05 +03:00
Jan Lindström
83464029ce Fix try for Galera test lp1376747-4 2021-06-23 08:10:35 +03:00
Marko Mäkelä
09b03ff31b Merge 10.3 into 10.4 2021-06-23 08:05:27 +03:00
Daniel Bartholomew
55b3a3f4dd
bump the VERSION 2021-06-22 23:00:01 -04:00
Daniel Bartholomew
bf2680ea09
bump the VERSION 2021-06-22 22:42:42 -04:00
Daniel Bartholomew
1deb630484
bump the VERSION 2021-06-22 22:21:24 -04:00
Daniel Bartholomew
f67aee000d
bump the VERSION 2021-06-22 22:00:23 -04:00
Igor Babaev
7f24e37fbe MDEV-25679 Wrong result selecting from simple view with LIMIT and ORDER BY
Cherry-picking only test case.
2021-06-22 12:23:13 -07:00