Commit graph

187858 commits

Author SHA1 Message Date
Vladislav Vaintroub
7c7f9bef28 Fix shutdown hang in dict_stats , caused by MDEV-16264
dict_stats_shutdown() can hang, waiting for timer callback to finish.
This happens because locks the same mutex, which can also used inside
timer callback, within dict_stats_schedule() function.

Fix is to make dict_stats_schedule() use mutex.try_lock() instead of
mutex.lock().

In the unlikely case of simultaneous dict_stats_schedule() setting
different timer delays, now the first one would win, which is fine.
Important is that shutdown won't hang.
2019-11-25 15:02:08 +01:00
Marko Mäkelä
312569e2fd MDEV-21132 Remove buf_page_t::newest_modification
At each mini-transaction commit, the log sequence number of the
mini-transaction must be written to each modified page, so that
it will be available in the FIL_PAGE_LSN field when the page is
being read in crash recovery.

InnoDB was unnecessarily allocating redundant storage for the
field, in buf_page_t::newest_modification. Let us access
FIL_PAGE_LSN directly.

Furthermore, on ALTER TABLE...IMPORT TABLESPACE, let us write
0 to FIL_PAGE_LSN instead of using log_sys.lsn.

buf_flush_init_for_writing(), buf_flush_update_zip_checksum(),
fil_encrypt_buf_for_full_crc32(), fil_encrypt_buf(),
fil_space_encrypt(): Remove the parameter lsn.

buf_page_get_newest_modification(): Merge with the only caller.

buf_tmp_reserve_compression_buf(), buf_tmp_page_encrypt(),
buf_page_encrypt(): Define static in the same compilation unit
with the only caller.

PageConverter::m_current_lsn: Remove. Write 0 to FIL_PAGE_LSN
on ALTER TABLE...IMPORT TABLESPACE.
2019-11-25 09:39:51 +02:00
Aleksey Midenkov
777b399618 MDEV-19903 Setup default partitions for system versioning
Implement syntax like:

create table t1 (x int) with system versioning partition by system_time;

which will create 1 history partition and 1 current partition.
Also it is possible to specify the number of history partitions:

create table t1 (x int) with system versioning partition by system_time partitions 5;

which will create 4 history partitions (and 1 current partition).

Tests:
partition.test cases are duplicated where it is appropriate for default partitions.
partition_rotation.test cases are replaced by default partitions where possible.
2019-11-22 18:34:28 +03:00
Vladislav Vaintroub
f60eeee952 MDEV-21062 Do not use popen() in text mode for mysql_upgrade. 2019-11-22 09:40:21 +01:00
Daniele Sciascia
9d4da68502 Fix MTR suppressions in inconsistency voting tests (#1412)
Message "WSREP: Failed to apply write set" has been turned into an
error, but tests were not adjusted accordingly.
2019-11-22 08:44:05 +02:00
Alexander Barkov
e76edf700f MDEV-21110 Unify turn_parser_debug_on() in sql_yacc.yy and sql_yacc_ora.yy
The block defining turn_parser_debug_on() now looks similar
in both sql_yacc.yy and sql_yacc_ora.yy.
2019-11-21 12:40:46 +04:00
Marko Mäkelä
747bed2e72 Upgrade accidentally downgraded libmariadb
In commit daabc5cc68 the libmariadb
component was accidentally downgraded. Restore the latest
libmariadb release, v3.1.5.
2019-11-21 05:34:00 +08:00
Marko Mäkelä
5b686af2ec Merge 10.4 into 10.5 2019-11-20 15:47:16 +02:00
Alexander Barkov
b40cab657b Bison parser cleanups: define yyerror() instead of MYSQLerror()/ORAerror()
To reduce the difference between sql_yacc.yy and sql_yacc_ora.yy,
using yyerror() in both files, instead of MYSQLerror() and ORAerror().
The pre-processor replaces yyerror() to MYSQLerror() and ORAerror()
anyway.
2019-11-20 14:35:21 +04:00
Aleksey Midenkov
927ea88084 MDEV-16264 fix unused variable ‘save_psi_thread’ 2019-11-20 13:19:01 +03:00
Aleksey Midenkov
daabc5cc68 MDEV-20729 Fix REFERENCES constraint in column definition
Add support of referential constraints directly in column defininions:

create table t1 (id1 int primary key);
create table t2 (id2 int references t1(id1));

Referenced field name can be omitted if equal to foreign field name:

create table t1 (id int primary key);
create table t2 (id int references t1);

Until 10.5 this syntax was understood by the parser but was silently
ignored.

In case of generated columns this syntax is disabled at parser level
by ER_PARSE_ERROR. Note that separate FOREIGN KEY clause for generated
columns is disabled at storage engine level.
2019-11-20 13:18:54 +03:00
Aleksey Midenkov
5130f5206c MDEV-20480 Obsolete internal parser for FK in InnoDB
Currently InnoDB uses internal parser for adding foreign keys. Remove
internal parser and use data parsed by SQL parser (sql_yacc) for
adding foreign keys.

- create_table_info_t::create_foreign_keys() replacement for
  dict_create_foreign_constraints_low();
- Pass constraint name via Foreign_key object.

Temporary until MDEV-20865:

- Pass alter_info as part of create_info.
2019-11-20 13:18:31 +03:00
Marko Mäkelä
6cedb671e9 MDEV-21088 Table cannot be loaded after instant ADD/DROP COLUMN
btr_cur_instant_init_low(): Accurately parse the metadata record
header for ROW_FORMAT=DYNAMIC and ROW_FORMAT=COMPACT. CHAR columns
used to be unnecessarily written as nonempty strings of bytes.
2019-11-20 14:12:53 +08:00
Marko Mäkelä
1c92406337 Merge 10.3 into 10.4 2019-11-20 14:11:54 +08:00
Marko Mäkelä
aa3d28ac34 MDEV-21088: Follow-up fix for ROW_FORMAT=REDUNDANT
For ROW_FORMAT=REDUNDANT, we must reserve fixed-length dummy values
for the CHAR columns in the metadata record. This is because in
MariaDB Server 10.4, btr_cur_instant_init_low() will rely on
dict_index_t::trx_id_offset being accurate for the metadata record.
2019-11-20 14:02:30 +08:00
Marko Mäkelä
89f487f2e2 MDEV-21088 Table cannot be loaded after instant ADD/DROP COLUMN
In MariaDB Server 10.4, btr_cur_instant_init_low() assumes that
all PRIMARY KEY columns that are internally variable-length will
be encoded in 0 bytes in the metadata record. Sometimes, CHAR
columns can be encoded as variable-length. We should not
unnecessarily reserve space for a dummy string value in the
metadata record.
2019-11-20 07:06:32 +02:00
Alexey Botchkov
7b5654f3e9 MDEV-14667 Assertion `used_parts > 0' failed in ha_partition::init_record_priority_queue.
Do not fail fi all the partitions were pruned out.
2019-11-20 00:33:32 +04:00
Sachin
20b474be5b MDEV-21063 Very many test failures on big-endian PowerPC
Memcpy is endian dependent, So instead of memcpy we will use int2store.
And m_metadata_size can be 0,1 or 2, And int2store will take care of it.
2019-11-19 17:42:48 +05:30
Alexander Barkov
251c6e1726 MDEV-21073 Collect different grammar rules into a single chunk
On order to unify the two *.yy files easier,
this patch collects all different rules to the end of *.yy files,
so the rule section looks like this:

%%
common rules
different rules
2019-11-19 08:06:04 +04:00
Marko Mäkelä
a9846f3299 Merge 10.4 into 10.5 2019-11-19 10:45:28 +08:00
Marko Mäkelä
589a1235b6 Merge 10.3 into 10.4 2019-11-19 01:32:50 +02:00
Marko Mäkelä
39d8652ca5 MDEV-13564 follow-up: Remove unused code
DropIndex, CreateIndex: Remove. The file row0trunc.cc only exists
in MariaDB Server 10.3 so that the crash recovery of TRUNCATE TABLE
operations from older 10.2 and 10.3 servers will work. This dead code
was being used for implementing the MySQL 5.7 WL#6501 TRUNCATE TABLE
that was replaced with a backup-safe implementation in MDEV-13564.
2019-11-19 00:42:10 +02:00
Marko Mäkelä
613e13072c Merge 10.2 into 10.3 2019-11-19 00:38:33 +02:00
Marko Mäkelä
b80df9eba2 MDEV-21069 Crash on DROP TABLE if the data file is corrupted
buf_read_ibuf_merge_pages(): Discard any page numbers that are
outside the current bounds of the tablespace, by invoking the
function ibuf_delete_recs() that was introduced in MDEV-20934.
This could avoid an infinite change buffer merge loop on
innodb_fast_shutdown=0, because normally the change buffer merge
would only be attempted if a page was successfully loaded into
the buffer pool.

dict_drop_index_tree(): Add the parameter trx_t*.
To prevent the DROP TABLE crash, do not invoke btr_free_if_exists()
if the entire .ibd file will be dropped. Thus, we will avoid a crash
if the BTR_SEG_LEAF or BTR_SEG_TOP of the index is corrupted,
and we will also avoid unnecessarily accessing the to-be-dropped
tablespace via the buffer pool.

In MariaDB 10.2, we disable the DROP TABLE fix if innodb_safe_truncate=0,
because the backup-unsafe MySQL 5.7 WL#6501 form of TRUNCATE TABLE
requires that the individual pages be freed inside the tablespace.
2019-11-19 00:07:06 +02:00
Marko Mäkelä
77a245fe56 MDEV-13564: Remove an unused return value
When commit 09af00cbde
removed the crash-upgrade logic of old TRUNCATE TABLE
from MariaDB 10.2 and 10.3, it actually made the return
value of dict_drop_index_tree() redundant.
2019-11-17 20:04:11 +02:00
Sergei Petrunia
409ed60bb8 Fix compile failure on Windows: use explicit type casts 2019-11-16 13:18:24 +03:00
Alexander Barkov
6d373e8b81 MDEV-21064 Add a new class sp_expr_lex and a new grammar rule expr_lex
Adding:
- new class sp_expr_lex
- new grammar rule expr_lex, which includes both reset_lex()
  and its corresponding restore_lex()

Also:
- Moving a few methods from LEX to sp_expr_lex.
- Moving the code from *.yy to new method sp_expr_lex methods
  sp_repeat_loop_finalize() and sp_if_expr().

This change makes it easier to edit the related grammar
(and makes it easier to unify sql_yacc.yy and sql_yacc_ora.yy later).
2019-11-16 08:32:15 +04:00
Vladislav Vaintroub
c233d406cb Fix compile error on centos6. it does not like std::this_thread::sleep()
Simplify task_group destructor.
No tasks must be running or queued into task group is being destroyed.
2019-11-15 23:51:49 +01:00
Marko Mäkelä
15c7f684ec MDEV-16264: Minor cleanup
Add missing static qualifiers.
2019-11-15 22:54:42 +02:00
Sergei Petrunia
86167e908f MDEV-20611: MRR scan over partitioned InnoDB table produces "Out of memory" error
Fix partitioning and DS-MRR to work together

- In ha_partition::index_end(): take into account that ha_innobase (and
  other engines using DS-MRR) will have inited=RND when initialized for
  DS-MRR scan.
- In ha_partition::multi_range_read_next(): if the MRR scan is using
  HA_MRR_NO_ASSOCIATION mode, it is not guaranteed that the partition's
  handler will store anything into *range_info.
- In DsMrr_impl::choose_mrr_impl(): ha_partition will inquire partitions
  about how much memory their MRR implementation needs by passing
  *buffer_size=0. DS-MRR code didn't know about this (actually it used
  uint for buffer size calculation and would have an under-flow).
  Returning *buffer_size=0 made ha_partition assume that partitions do
  not need MRR memory and pass the same buffer to each of them.

  Now, this is fixed. If DS-MRR gets *buffer_size=0, it will return
  the amount of buffer space needed, but not more than about
  @@mrr_buffer_size.

* Fix ha_{innobase,maria,myisam}::clone. If ha_partition uses MRR on its
  partitions, and partition use DS-MRR, the code will call handler->clone
  with TABLE (*NOT partition*) name as an argument.
  DS-MRR has no way of knowing the partition name, so the solution was
  to have the ::clone() function for the affected storage engine to ignore
  the name argument and get it elsewhere.
2019-11-15 23:37:28 +03:00
Marko Mäkelä
a69cff295c MDEV-16264: Remove IORequest::IGNORE_MISSING
After MDEV-11556, not even crash recovery should attempt to access
non-existing pages. But, buf_load() is not validating its input
and must thus be able to ignore missing pages, so that is why
buf_read_page_background() does that.
2019-11-15 19:55:40 +02:00
Marko Mäkelä
8040998624 MDEV-16264: Fix some white space 2019-11-15 19:55:13 +02:00
Marko Mäkelä
37f1ab2323 MDEV-21054 Crash on shutdown due to btr_search_latches=NULL
innodb_shutdown(): Invoke os_aio_free() before btr_search_sys_free().
2019-11-15 19:55:07 +02:00
Vladislav Vaintroub
a808c18b73 Make .clang-format work with clang-8
Remove keywords that are too new.
2019-11-15 18:09:30 +01:00
Vladislav Vaintroub
4e30a57e6b MDEV-20839 innodb-redo-badkey fails sporadically 2019-11-15 18:09:30 +01:00
Vladislav Vaintroub
5e62b6a5e0 MDEV-16264 Use threadpool for Innodb background work.
Almost all threads have gone
- the "ticking" threads, that sleep a while then do some work)
(srv_monitor_thread, srv_error_monitor_thread, srv_master_thread)
were replaced with timers. Some timers are periodic,
e.g the "master" timer.

- The btr_defragment_thread is also replaced by a timer , which
reschedules it self when current defragment "item" needs throttling

- the buf_resize_thread and buf_dump_threads are substitutes with tasks
Ditto with page cleaner workers.

- purge workers threads are not tasks as well, and purge cleaner
coordinator is a combination of a task and timer.

- All AIO is outsourced to tpool, Innodb just calls thread_pool::submit_io()
and provides the callback.

- The srv_slot_t was removed, and innodb_debug_sync used in purge
is currently not working, and needs reimplementation.
2019-11-15 18:09:30 +01:00
Vladislav Vaintroub
00ee8d85c9 MDEV-16264: Add threadpool library
The library is capable of
- asynchronous execution of tasks (and optionally waiting for them)
- asynchronous file IO
  This is implemented using libaio on Linux and completion ports on
  Windows. Elsewhere, async io is "simulated", which means worker threads
  are performing synchronous IO.
- timers, scheduling work asynchronously in some point of the future.
  Also periodic timers are implemented.
2019-11-15 16:50:22 +01:00
Vladislav Vaintroub
7e08dd85d6 MDEV-16264 prerequisite patch, ha_preshutdown.
This is a prerequisite patch required to remove Innodb's
thd_destructor_proxy thread.

The patch implement pre-shutdown functionality for handlers.

A storage engine might need to perform some work after all user
connections are shut down, but before killing off the plugins.

The reason is that an SE could still be using some of the
server infrastructure. In case of Innodb this would be purge threads,
that call into the server to calculate results of virtual function,
acquire MDL locks on tables, or possibly also use the audit plugins.
2019-11-15 16:50:22 +01:00
Vladislav Vaintroub
e7549917e1 MDEV-16264 - prerequisite patch - true background THDs
Create background THDs that are not counted, and do not block
close_connections(), in other words they are just something that plugin
can use internally.

These THD will be used later by Innodb purge threads, and they need THD
to calculate virtual functions.
2019-11-15 16:50:22 +01:00
Vladislav Vaintroub
2fb23b896e MDEV-16264 prerequisite patch, enable thr_timer in embedded
Since threadpool is using thr_timer, and it also exist in embedded version,
initialize timer also in embedded version
2019-11-15 16:50:22 +01:00
Vladislav Vaintroub
ad17c98dd5 MDEV-16264 - prerequisite patch, periodic thr_timer
Threadpool will need a functionality for periodic thr_timer
(the threadpool maintainence task is a timer that runs periodically).

Also increase the stack size for the timer thread, 8k won't be enough.
2019-11-15 16:50:22 +01:00
Vladislav Vaintroub
009674dc52 Fix a couple of clang-cl warnings 2019-11-15 15:39:31 +01:00
Vladislav Vaintroub
6df0bb7d38 MDEV-21062 Buildbot, Windows - sporadically missing lines from mtr's "exec"
Provide own version of popen/pclose, in attempt to workaround
sporadic erratic behavior of UCRT's one.
2019-11-15 15:39:31 +01:00
Marko Mäkelä
786b004972 Cleanup: More use of mtr_memo_type_t 2019-11-15 14:55:38 +02:00
Sergei Golubchik
bd2b05df6c update create_w_max_indexes_128.result
using create_w_max_indexes_64.result as a template
2019-11-15 11:14:25 +01:00
Marko Mäkelä
ae90f8431b Merge 10.4 into 10.5 2019-11-14 14:49:20 +02:00
Marko Mäkelä
89ae01fd00 Merge 10.3 into 10.4 2019-11-14 13:23:36 +02:00
Marko Mäkelä
746ee78535 MDEV-20949: Merge 10.3 into 10.4 2019-11-14 13:22:29 +02:00
Marko Mäkelä
3bee95d769 Merge 10.3 into 10.4 2019-11-14 13:20:57 +02:00
Jean Weisbuch
c454b8964c MDEV-4476: mytop tracker
- Added dynamic column width fro `user` and `db` columns
- Added option `%` to hide the progress
- Follow up changes from Ubuntu
- Take `INFORMATION_SCHEMA.PROCESSLIST` into account to determine
  progress of the `actual stage`
- Indentation fixes

Closes #215
2019-11-14 02:31:43 -08:00