Commit graph

20705 commits

Author SHA1 Message Date
Marko Mäkelä
93b6552182 Merge 10.2 into 10.3 2018-07-26 09:19:52 +03:00
Marko Mäkelä
0f90728bc0 MDEV-16809 Allow full redo logging for ALTER TABLE
Introduce the configuration option innodb_log_optimize_ddl
for controlling whether native index creation or table-rebuild
in InnoDB should keep optimizing the redo log
(and writing MLOG_INDEX_LOAD records to ensure that
concurrent backup would fail).

By default, we have innodb_log_optimize_ddl=ON, that is,
the default behaviour that was introduced in MariaDB 10.2.2
(with the merge of InnoDB from MySQL 5.7) will be unchanged.

BtrBulk::m_trx: Replaces m_trx_id. We must be able to check for
KILL QUERY even if !m_flush_observer (innodb_log_optimize_ddl=OFF).

page_cur_insert_rec_write_log(): Declare globally, so that this
can be called from PageBulk::insert().

row_merge_insert_index_tuples(): Remove the unused parameter trx_id.

row_merge_build_indexes(): Enable or disable redo logging based on
the innodb_log_optimize_ddl parameter.

PageBulk::init(), PageBulk::insert(), PageBulk::finish(): Write
redo log records if needed. For ROW_FORMAT=COMPRESSED, redo log
will be written in PageBulk::compress() unless we called
m_mtr.set_log_mode(MTR_LOG_NO_REDO).
2018-07-26 08:44:42 +03:00
Marko Mäkelä
32eb5823e4 Remove pointer indirection for BtrBulk::m_page_bulks 2018-07-26 08:44:41 +03:00
Marko Mäkelä
4a456eac2a Remove unused BtrBulk::m_heap 2018-07-26 08:44:41 +03:00
Marko Mäkelä
a3b22147ca Remove pointer indirection for PageBulk::m_mtr 2018-07-26 08:44:41 +03:00
Marko Mäkelä
172199b88c PageBulk: Remove dead code
Native ALTER TABLE is never invoked on temporary tables.
2018-07-26 08:44:41 +03:00
Marko Mäkelä
7f54894329 Remove mtr_set_flush_observer() 2018-07-26 08:44:41 +03:00
Thirunarayanan Balathandayuthapani
de85355436 MDEV-16713 Hangs server with repeating log entry
At most one transaction can be active at a time for temporary
tables. There is no need to check previous version of record for the
temporary tables.
2018-07-25 13:56:39 +05:30
Jacob Mathew
45ab00f097 MDEV-15786: ERROR 1062 (23000) at line 365: Duplicate entry 'spider' for key 'PRIMARY'
The problem occurs on Ubuntu where a Spider package is installed on the system
separately from the MariaDB package.  MariaDB and Spider upgrades leave the
Spider plugin improperly installed.  Spider is present in the mysql.plugin
table but is not present in information_schema.

The problem has been corrected in Spider's installation script.  Logic has
been added to check for Spider entries in both information_schema and
mysql.plugin.  If Spider is present in mysql.plugin but is not present in
information_schema, then Spider is first removed from mysql.plugin.  The
subsequent plugin install of Spider will insert entries in both mysql.plugin
and information_schema.

Author:
  Jacob Mathew.

Reviewer:
  Kentoku Shiba.

Cherry-Picked:
  Commit 0897d81 on branch bb-10.3-MDEV-15786
2018-07-23 14:14:23 -07:00
Jacob Mathew
a86a02a844 MDEV-15786: ERROR 1062 (23000) at line 365: Duplicate entry 'spider' for key 'PRIMARY'
The problem occurs on Ubuntu where a Spider package is installed on the system
separately from the MariaDB package.  MariaDB and Spider upgrades leave the
Spider plugin improperly installed.  Spider is present in the mysql.plugin
table but is not present in information_schema.

The problem has been corrected in Spider's installation script.  Logic has
been added to check for Spider entries in both information_schema and
mysql.plugin.  If Spider is present in mysql.plugin but is not present in
information_schema, then Spider is first removed from mysql.plugin.  The
subsequent plugin install of Spider will insert entries in both mysql.plugin
and information_schema.

Author:
  Jacob Mathew.

Reviewer:
  Kentoku Shiba.

Cherry-Picked:
  Commit 0897d81 on branch bb-10.3-MDEV-15786
2018-07-23 13:57:35 -07:00
Marko Mäkelä
f418661efa Merge 10.2 into 10.3 2018-07-23 18:56:52 +03:00
Marko Mäkelä
9d1f3bf2e9 row_purge_poss_sec(): Add debug instrumentation
This helped fix MDEV-16779.
2018-07-23 18:34:06 +03:00
Marko Mäkelä
c5ba13dda0 MDEV-15855 cleanup: Privatize purge_vcol_info_t
Declare all fields of purge_vcol_info_t private, and add
accessor functions.
2018-07-23 18:31:42 +03:00
Marko Mäkelä
a7a0c533c2 Follow-up to MDEV-15855: Remove bogus debug assertions
During a table-rebuilding operation, the function table_name_parse()
can encounter a table name that starts with #sql. Here is an example
of a failure:

CURRENT_TEST: gcol.innodb_virtual_basic
mysqltest: At line 1204: query 'alter table t drop column d ' failed:
2013: Lost connection to MySQL server during query

Let us just remove these bogus debug assertions.

If the final renaming phase during ALTER TABLE never fails, it
should not do any harm to skip the purge. If it does fail, then
we might end up 'leaking' some delete-marked records in the
indexes on virtual columns of the original table, and these
garbage records would keep consuming space until the indexes are
dropped or the table is successfully rebuilt.
2018-07-23 17:50:56 +03:00
Thirunarayanan Balathandayuthapani
730f6c912c MDEV-16779 Assertion !rw_lock_own failed upon purge
This is a regression caused by the fix of MDEV-15855.

purge_vcol_info_t::set_used(): Add a missing condition.

row_purge_poss_sec(): Invoke set_used() in order to
have !is_first_fetch() when retrying.
2018-07-23 17:50:20 +03:00
Marko Mäkelä
b660261be1 ut_print_buf_hex(): Correctly dump the hex
This should affect at least rec_printer() output.
2018-07-23 17:49:01 +03:00
Marko Mäkelä
73af075366 Reduce the number of rw_lock_own() calls
Replace pairs of rw_lock_own() calls with
calls to rw_lock_own_flagged().

These calls are only present in debug builds.
2018-07-23 17:49:01 +03:00
Marko Mäkelä
b9865b289a Follow-up to MDEV-12266: Remove latch_t::m_temp_fsp
There is only one temporary tablespace. Reserving a data member in
each read-write lock object for a Boolean flag seems like a huge waste,
especially because this field was only actually used in debug builds.

LatchDebug::check_order(): Compare to fil_system.temp_space->latch.
2018-07-23 12:09:59 +03:00
Jacob Mathew
813b739850 MDEV-16246: insert timestamp into spider table from mysqldump gets wrong time zone.
The problem occurred because the Spider node was incorrectly handling
timestamp values sent to and received from the data nodes.

The problem has been corrected as follows:
- Added logic to set and maintain the UTC time zone on the data nodes.
  To prevent timestamp ambiguity, it is necessary for the data nodes to use
  a time zone such as UTC which does not have daylight savings time.
- Removed the spider_sync_time_zone configuration variable, which did not
  solve the problem and which interfered with the solution.
- Added logic to convert to the UTC time zone all timestamp values sent to
  and received from the data nodes.  This is done for both unique and
  non-unique timestamp columns.  It is done for WHERE clauses, applying to
  SELECT, UPDATE and DELETE statements, and for UPDATE columns.
- Disabled Spider's use of direct update when any of the columns to update is
  a timestamp column.  This is necessary to prevent false duplicate key value
  errors.
- Added a new test spider.timestamp to thoroughly test Spider's handling of
  timestamp values.

Author:
  Jacob Mathew.

Reviewer:
  Kentoku Shiba.

Cherry-Picked:
  Commit 97cc9d3 on branch bb-10.3-MDEV-16246
2018-07-09 16:09:20 -07:00
Marko Mäkelä
bbf780efcd Merge 10.2 into 10.3 2018-07-07 11:39:38 +03:00
Marko Mäkelä
1cc1d0429d MDEV-16664: Change the default to innodb_lock_schedule_algorithm=fcfs
The parameter innodb_lock_schedule_algorithm was introduced in
MariaDB Server 10.1.19, 10.2.13, 10.3.4 as part of MDEV-11039.
In MariaDB 10.1, the default value of the parameter is 'fcfs',
that is, the existing algorithm is used by default. But in
later versions of MariaDB Server, the parameter was 'vats',
enabling the new algorithm.

Because the new algorithm is triggering a debug assertion failure
that suggests corruption of the transactional lock data structures,
we will revert to the old algorithm by default until we have
resolved the problem.
2018-07-07 11:34:26 +03:00
Marko Mäkelä
934d5f95d3 Merge 10.2 into 10.3 2018-07-06 22:18:35 +03:00
Thirunarayanan Balathandayuthapani
8b0d4cff07 MDEV-15855 Deadlock between purge thread and DDL statement
Problem:
========
Truncate operation holds MDL on the table (t1) and tries to
acquire InnoDB dict_operation_lock. Purge holds dict_operation_lock
and tries to acquire MDL on the table (t1) to evaluate virtual
column expressions for indexed virtual columns.
It leads to deadlock of purge and truncate table (DDL).

Solution:
=========
If purge tries to acquire MDL on the table then it should do the following:

i) Purge should release all innodb latches (including dict_operation_lock)
before acquiring metadata lock on the table.

ii) After acquiring metadata lock on the table, it should check whether the
table was dropped or renamed. If the table is dropped then purge should
ignore the undo log record. If the table is renamed then it should
release the old MDL and acquire MDL on the new name.

iii) Once purge acquires MDL, it should use the SQL table handle for all
the remaining virtual index for the purge record.

purge_node_t: Introduce new virtual column information to know whether
the MDL was acquired successfully.

This is joint work with Marko Mäkelä.
2018-07-06 17:13:53 +03:00
Marko Mäkelä
b4c377f215 Merge 10.2 into 10.3 2018-07-05 17:08:44 +03:00
Thirunarayanan Balathandayuthapani
d897b4dc25 MDEV-15855: Use atomics for dict_table_t::n_ref_count
Make dict_table_t::n_ref_count private, and protect it with
a combination of dict_sys->mutex and atomics. We want to be
able to invoke dict_table_t::release() without holding
dict_sys->mutex.
2018-07-05 15:47:51 +03:00
Marko Mäkelä
e9f1d8da57 Fix warnings about possibly uninitialized variables 2018-07-05 14:14:31 +03:00
Marko Mäkelä
1748a31ae8 MDEV-16675 Unnecessary explicit lock acquisition during UPDATE or DELETE
In InnoDB, an INSERT will not create an explicit lock object. Instead,
the inserted record is initially implicitly locked by the transaction
that wrote its trx_t::id to the hidden system column DB_TRX_ID.
(Other transactions would check if DB_TRX_ID is referring to a
transaction that has not been committed.)

If a record was inserted in the current transaction, it would be
implicitly locked by that transaction. Only if some other transaction
is requesting access to the record, the implicit lock should be
converted to an explicit one, so that the waits-for graph can be
constructed for detecting deadlocks and lock wait timeouts.

Before this fix, InnoDB would convert implicit locks to
explicit ones, even if no conflict exists.

lock_rec_convert_impl_to_expl(): Return whether caller_trx
already holds an explicit lock that covers the record.

row_vers_impl_x_locked_low(): Avoid a lookup if the record matches
caller_trx->id.

lock_trx_has_expl_x_lock(): Renamed from lock_trx_has_rec_x_lock().

row_upd_clust_step(): In a debug assertion, check for implicit lock
before invoking lock_trx_has_expl_x_lock().

rw_trx_hash_t::find(): Make do_ref_count a mandatory parameter.
Assert that trx_id is not 0 (the caller should check it).

trx_sys_t::is_registered(): Only invoke find() if id != 0.

trx_sys_t::find(): Add the optional parameter do_ref_count.

lock_rec_queue_validate(): Avoid lookup for trx_id == 0.
2018-07-03 15:10:06 +03:00
Marko Mäkelä
186a998b5b Merge 10.2 into 10.3 2018-07-03 10:25:38 +03:00
Marko Mäkelä
c3289d27ee Merge mariadb-10.3.8 into 10.3 2018-07-03 10:22:43 +03:00
Marko Mäkelä
502f1a3c11 MDEV-16623 ASAN: use-after-free in create_index()
Before attempting to create an index, copy any fields from
dict_table_t, because the table would be freed after a failed
index creation.
2018-07-02 12:27:28 +03:00
Vladislav Vaintroub
b71c9ae030 amend fix for MDEV-16596 - do not use CREATE_NEW flag when reopening redo log file.
use OPEN_ALWAYS instead, since we know file already exist.
2018-07-01 14:00:29 +01:00
Sergei Golubchik
36e59752e7 Merge branch '10.2' into 10.3 2018-06-30 16:39:20 +02:00
Vladislav Vaintroub
c612a1e77c MDEV-16596 : Windows - redo log does not work on native 4K sector disks.
Disks with native 4K sectors need 4K alignment and size for  unbuffered IO
(i.e for files opened with FILE_FLAG_NO_BUFFERING)

Innodb opens redo log with FILE_FLAG_NO_BUFFERING, however it always does
512byte IOs. Thus, the IO on 4K native sectors will fail, rendering
Innodb non-functional.

The fix is to check whether OS_FILE_LOG_BLOCK_SIZE is multiple of logical
sector size, and if it is not, reopen the redo log without
FILE_FLAG_NO_BUFFERING flag.
2018-06-30 11:04:51 +01:00
Vladislav Vaintroub
04677f44c7 Innodb : do not use errno on Windows to print os_file_pwrite() error.
Use GetLastError() instead.
2018-06-28 17:23:05 +01:00
Marko Mäkelä
377cd52064 Pretty-print table names in some error messages 2018-06-27 23:22:08 +03:00
Marko Mäkelä
31c950cca8 Merge 10.1 into 10.2 2018-06-26 18:16:49 +03:00
Marko Mäkelä
c6392d52ee Merge 10.0 into 10.1 2018-06-26 17:34:44 +03:00
Marko Mäkelä
1b4ac075bf Merge 10.1 into 10.2 2018-06-26 15:39:23 +03:00
Thirunarayanan Balathandayuthapani
fe76e68e0e MDEV-16365 Setting a column NOT NULL fails to return error for
NULL values when there is no DEFAULT

- Fixed the test failure, assigned number of rows read to new table.
2018-06-26 14:10:58 +05:30
Marko Mäkelä
c4eb4bcef6 MDEV-16515 InnoDB: Failing assertion: ++retries < 10000 in file
dict0dict.cc

buf_LRU_drop_page_hash_for_tablespace(): Return whether any adaptive
hash index entries existed. If yes, the caller should keep retrying to
drop the adaptive hash index.

row_import_for_mysql(), row_truncate_table_for_mysql(),
row_drop_table_for_mysql(): Ensure that the adaptive hash index was
entirely dropped for the table.
2018-06-26 11:34:51 +03:00
Eugene Kosov
ff8b3c8df8 MDEV-15953 Alter InnoDB Partitioned Table Moves Files (which were originally not in the datadir) to the datadir
ha_innobase::prepare_inplace_alter_table: preserve DATA DICTIONARY for table
2018-06-26 11:11:15 +03:00
Thirunarayanan Balathandayuthapani
1ba5b38bfa MDEV-16365 Setting a column NOT NULL fails to return error for
NULL values when there is no DEFAULT

- Fixed typecasting failure for log->n_rows in row0log.cc
2018-06-25 20:49:22 +05:30
Thirunarayanan Balathandayuthapani
69b9ed063b MDEV-16365 Setting a column NOT NULL fails to return error for
NULL values when there is no DEFAULT

- Post push fix for adding n_rows in row_log_t.
2018-06-25 18:16:29 +05:30
Thirunarayanan Balathandayuthapani
88aaf590ac MDEV-16365 Setting a column NOT NULL fails to return error for
NULL values when there is no DEFAULT

Copy and inplace algorithm works similarly for
NULL to NOT NULL conversion for the following cases:
(1) strict sql mode - Should give error.
(2) non-strict sql mode - Should give warnings alone
(3) alter ignore table command. - Should give warnings alone.
2018-06-25 14:52:38 +05:30
Sergei Golubchik
a40c06e03a Merge branch 'connect/10.2' into 10.2 2018-06-24 15:27:38 +02:00
Sergei Golubchik
f577311027 fix mroonga post-install script
it only worked if mroonga plugin wasn't installed before (normal case),
but then it didn't need to delete anything.

if, by some glitch, mroonga was already installed, it would delete
mroonga from mysql.plugin, but INSTALL would fail (as mroonga was running),
and the script aborted, leaving mroonga not in mysql.plugin at all.
2018-06-24 15:18:36 +02:00
Sergei Golubchik
ef64856b97 don't crash on innodb_undo_tablespaces=1 2018-06-21 23:49:37 +02:00
Sergei Golubchik
b942aa34c1 Merge branch '10.1' into 10.2 2018-06-21 23:47:39 +02:00
Sergei Golubchik
5f0510225a MDEV-16238 root/localhost authn prioritizes authentication_string over Password
Don't let SET PASSWORD to set the password, if auth_string is set.

Now SET PASSWORD always sets the plugin/auth_string fields and clears
the password field (on pre-plugin mysql.user table it works as before).
2018-06-21 10:15:27 +02:00
Sergei Golubchik
1033fa4bcc MDEV-13403 Mariadb (with TokuDB) excessive memory usage/leak
In RPM/DEB packages - always ld-preload jemalloc, instead
of linking ha_tokudb.so with it.

Keep linking in bintars, because they don't install cnf files
in the correct locations.
2018-06-21 10:15:27 +02:00