Commit graph

45 commits

Author SHA1 Message Date
Marko Mäkelä
7c7ac6d4a4 Merge 10.6 into 10.7 2022-09-21 09:33:07 +03:00
Marko Mäkelä
44fd2c4b24 Merge 10.5 into 10.6 2022-09-20 16:53:20 +03:00
Alexander Barkov
23a8654cdb A cleanup for MDEV-29446 Change SHOW CREATE TABLE to display default collation
Recording test results according to MDEV-29446 changes:

  mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result
  mysql-test/suite/galera/r/galera_sync_wait_show.result
  mysql-test/suite/galera/r/lp1376747-4.result
  mysql-test/suite/s3/replication_partition.result
  mysql-test/suite/s3/replication_stmt.result
2022-09-15 12:20:50 +04:00
Alexander Barkov
2fd4d25d8f A cleanup for MDEV-29446 Change SHOW CREATE TABLE to display default collation
Recording test results according to MDEV-29446 changes:

  mysql-test/suite/galera/r/galera-features#117.result
  mysql-test/suite/galera/r/galera_can_run_toi.result
  mysql-test/suite/galera/r/wsrep_strict_ddl.result
  mysql-test/suite/s3/alter.result
  mysql-test/suite/s3/arguments.result
  mysql-test/suite/s3/basic.result
  mysql-test/suite/s3/encryption.result
  mysql-test/suite/s3/innodb.result
  mysql-test/suite/s3/mysqldump.result
  mysql-test/suite/s3/partition.result
  mysql-test/suite/s3/partition_move.result
  mysql-test/suite/s3/replication_delayed.result
  mysql-test/suite/s3/replication_mixed.result
2022-09-15 07:44:35 +04:00
Marko Mäkelä
9791d4b4af After-merge fix: Correct s3.mysqldump result 2021-10-05 19:28:09 +03:00
Marko Mäkelä
4ca56e8348 Merge 10.5 into 10.6 2021-10-05 09:21:34 +03:00
Daniel Black
32839c4df2 MDEV-19867: postfix - syntax spelling ALTER TABLE
Fixes: 5c5ea59bf8
2021-10-04 22:31:18 +11:00
Marko Mäkelä
7730dd392b Merge 10.5 into 10.6 2021-09-06 10:31:32 +03:00
Monty
10f08aff15 Added support for CHECK TABLE for S3 tables
Other things:
- Don't allocate an IO_CACHE for scanning tables of type BLOCK
  (It was never used in this case)
- Fixed bug in page cache that cased a hang when trying to read a
  not existing S3 block.
2021-09-01 13:47:26 +03:00
Monty
49ae199604 Added support for ANALYZE TABLE to S3 tables
Other things
- Cleaned up error messages for CHECK, REPAIR and OPTIMIZE
2021-09-01 13:47:02 +03:00
Oleksandr Byelkin
6efb5e9f5e Merge branch '10.5' into 10.6 2021-08-02 10:11:41 +02:00
Sergei Golubchik
a49f5525bb MDEV-26226 Change Maturity of plugins inet6 and s3 to stable
from gamma
2021-07-28 23:18:46 +02:00
Sergei Golubchik
b5f50e2de8 errors after altering a table has finished aren't fatal
We cannot revert the ALTER, so anything happening after
the point of no return should not be treated as an error. A
very unfortunate condition that a user needs to be warned about - yes,
but we cannot say "ALTER TABLE has failed" if the table was successfully
altered.
2021-07-02 16:44:00 +02:00
Monty
7762ee5dbe MDEV-25180 Atomic ALTER TABLE
MDEV-25604 Atomic DDL: Binlog event written upon recovery does not
           have default database

The purpose of this task is to ensure that ALTER TABLE is atomic even if
the MariaDB server would be killed at any point of the alter table.
This means that either the ALTER TABLE succeeds (including that triggers,
the status tables and the binary log are updated) or things should be
reverted to their original state.

If the server crashes before the new version is fully up to date and
commited, it will revert to the original table and remove all
temporary files and tables.
If the new version is commited, crash recovery will use the new version,
and update triggers, the status tables and the binary log.
The one execption is ALTER TABLE .. RENAME .. where no changes are done
to table definition. This one will work as RENAME and roll back unless
the whole statement completed, including updating the binary log (if
enabled).

Other changes:
- Added handlerton->check_version() function to allow the ddl recovery
  code to check, in case of inplace alter table, if the table in the
  storage engine is of the new or old version.
- Added handler->table_version() so that an engine can report the current
  version of the table. This should be changed each time the table
  definition changes.
- Added  ha_signal_ddl_recovery_done() and
  handlerton::signal_ddl_recovery_done() to inform all handlers when
  ddl recovery has been done. (Needed by InnoDB).
- Added handlerton call inplace_alter_table_committed, to signal engine
  that ddl_log has been closed for the alter table query.
- Added new handerton flag
  HTON_REQUIRES_NOTIFY_TABLEDEF_CHANGED_AFTER_COMMIT to signal when we
  should call hton->notify_tabledef_changed() during
  mysql_inplace_alter_table. This was required as MyRocks and InnoDB
  needed the call at different times.
- Added function server_uuid_value() to be able to generate a temporary
  xid when ddl recovery writes the query to the binary log. This is
  needed to be able to handle crashes during ddl log recovery.
- Moved freeing of the frm definition to end of mysql_alter_table() to
  remove duplicate code and have a common exit strategy.

-------
InnoDB part of atomic ALTER TABLE
(Implemented by Marko Mäkelä)
innodb_check_version(): Compare the saved dict_table_t::def_trx_id
to determine whether an ALTER TABLE operation was committed.

We must correctly recover dict_table_t::def_trx_id for this to work.
Before purge removes any trace of DB_TRX_ID from system tables, it
will make an effort to load the user table into the cache, so that
the dict_table_t::def_trx_id can be recovered.

ha_innobase::table_version(): return garbage, or the trx_id that would
be used for committing an ALTER TABLE operation.

In InnoDB, table names starting with #sql-ib will remain special:
they will be dropped on startup. This may be revisited later in
MDEV-18518 when we implement proper undo logging and rollback
for creating or dropping multiple tables in a transaction.

Table names starting with #sql will retain some special meaning:
dict_table_t::parse_name() will not consider such names for
MDL acquisition, and dict_table_rename_in_cache() will treat such
names specially when handling FOREIGN KEY constraints.

Simplify InnoDB DROP INDEX.
Prevent purge wakeup

To ensure that dict_table_t::def_trx_id will be recovered correctly
in case the server is killed before ddl_log_complete(), we will block
the purge of any history in SYS_TABLES, SYS_INDEXES, SYS_COLUMNS
between ha_innobase::commit_inplace_alter_table(commit=true)
(purge_sys.stop_SYS()) and purge_sys.resume_SYS().
The completion callback purge_sys.resume_SYS() must be between
ddl_log_complete() and MDL release.

--------

MyRocks support for atomic ALTER TABLE
(Implemented by Sergui Petrunia)

Implement these SE API functions:
- ha_rocksdb::table_version()
- hton->check_version = rocksdb_check_versionMyRocks data dictionary
  now stores table version for each table.
  (Absence of table version record is interpreted as table_version=0,
  that is, which means no upgrade changes are needed)
- For inplace alter table of a partitioned table, call the underlying
  handlerton when checking if the table is ok. This assumes that the
  partition engine commits all changes at once.
2021-05-19 22:54:13 +02:00
Varun Gupta
f691d9865b MDEV-7317: Make an index ignorable to the optimizer
This feature adds the functionality of ignorability for indexes.
Indexes are not ignored be default.

To control index ignorability explicitly for a new index,
use IGNORE or NOT IGNORE as part of the index definition for
CREATE TABLE, CREATE INDEX, or ALTER TABLE.

Primary keys (explicit or implicit) cannot be made ignorable.

The table INFORMATION_SCHEMA.STATISTICS get a new column named IGNORED that
would store whether an index needs to be ignored or not.
2021-03-04 22:50:00 +05:30
Daniel Black
c7edbe5bb1 MDEV-24366: s3 test postfix - use default for S3_BUCKET
and S3_HOST_NAME.

Required environment variables are now S3_ACCESS_KEY and S3_SECRET_KEY.

Or a running minio instance on localhost:9000.
2021-02-11 12:51:29 +11:00
Monty
ffc5d06489 MDEV-24087 s3.replication_partition fails in buildbot wiht replication failure
A few of the failures was because of missing sync_slave_to_master in
the test suite.

However, the biggest reason for most faulures was that in case of
ALTER PARTITION the master writes the query to the binary log before
it has updated the .frm and .par files. This causes a problem for an
S3 slave as it will start execute the ALTER PARTITION but get old .frm and
.par files from S3 which causes "open table" to fail, either with an error
or in some case with a crash.
Fixed
2021-02-08 21:03:04 +02:00
zhaorenhai
ee69c153d9 MDEV-24366 Use environment variables as S3 test case variables
Move the S3 test case variables to suite.pm to use environment variables.

Use minio credentials if a TCP connection to localhost:9000 is accepted
so the current build works corrected.

Reviewer: Daniel Black

closes #1711
2020-12-15 15:39:56 +11:00
Sergei Petrunia
6859e80df7 MDEV-24351: S3, same-backend replication: Dropping a table on master...
..causes error on slave.
Cause: if the master doesn't have the frm file for the table,
DROP TABLE code will call ha_delete_table_force() to drop the table
in all available storage engines.
The issue was that this code path didn't check for
HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE flag for the storage engine,
and so did not add "... IF EXISTS" to the statement that's written
to the binary log.  This can cause error on the slave when it tries to
drop a table that's already gone.
2020-12-08 17:58:22 +03:00
Monty
8c074df6ac MDEV-23648 s3.partition_move 'innodb' test failure - object deleted before copy attempted
Updated submodule libmarias3 which fixes the problem
Enabled disable S3 tests.
2020-10-21 03:09:30 +03:00
Monty
dd757ee02f Update S3 engine to maturity Gamma 2020-10-21 03:09:29 +03:00
Monty
2c8c15483d MDEV-23730 s3.replication_partition 'innodb,mix' segv
This failure was caused because of several bugs:
- Someone had removed s3-slave-ignore-updates=1 from slave.cnf, which
  caused the slave to remove files that the master was working on.
- Bug in ha_partition::change_partitions() that didn't reset m_new_file
  in case of errors. This caused crashes in ha_maria::extra() as the
  maria handler was called on files that was already closed.
- In ma_pagecache there was a bug that when one got a read error one a
  big block (s3 block), it left the flag PCBLOCK_BIG_READ on for the page
  which cased an assert when the page where flushed.
- Flush all cached tables in case of ignored ALTER TABLE

Note that when merging code from 10.3, that fixes the partition bug, use
the code from this patch instead.

Changes to ma_pagecache.cc written or reviewed by Sanja
2020-10-21 03:09:29 +03:00
Monty
71d263a198 MDEV-23691 S3 storage engine: delayed slave can drop the table
This commit fixed the problems with S3 after the "DROP TABLE FORCE" changes.
It also fixes all failing replication S3 tests.

A slave is delayed if it is trying to execute replicated queries on a
table that is already converted to S3 by the master later in the binlog.

Fixes for replication events on S3 tables for delayed slaves:
- INSERT and INSERT ... SELECT and CREATE TABLE are ignored but written
  to the binary log.   UPDATE & DELETE will be fixed in a future commit.

Other things:
- On slaves with --s3-slave-ignore-updates set, allow S3 tables to be
  opened in read-write mode. This was done to be able to
  ignore-but-replicate queries like insert.  Without this change any
  open of an S3 table failed with 'Table is read only' which is too
  early to be able to replicate the original query.
- Errors are now printed if handler::extra() call fails in
  wait_while_tables_are_used().
- Error message for row changes are changed from HA_ERR_WRONG_COMMAND
  to HA_ERR_TABLE_READONLY.
- Disable some maria_extra() calls for S3 tables. This could cause
  S3 tables to fail in some cases.
- Added missing thr_lock_delete() to ma_open() in case of failure.
- Removed from mysql_prepare_insert() the not needed argument 'table'.
2020-10-21 03:09:29 +03:00
Elena Stepanova
6ab6b1510e MDEV-23650 Test S3 in buildbot
Temporarily disable failing S3 tests to allow the suite to run in buildbot:

s3.partition and s3.partition_move are disabled due to MDEV-23648.
While the problem is supposedly generic, the tests don't fail with Amazon
setup, so they are disabled conditionally for emulator (MinIO).

s3.replication_partition is disabled due to MDEV-23730,
it fails both with Amazon and MinIO.

s3.replication_mixed and s3.replication_stmt are disabled due to MDEV-23770,
they also fail both with Amazon and the emulator.
2020-09-20 17:26:15 +03:00
Sergei Golubchik
897b51db43 make S3 tests to run when S3 is statically linked
* use the environment variable HA_S3_SO, not a literal ha_s3 in cnf files
* make ConfigFactory to support empty option values
* update no_s3.result after MDEV-11412
2020-09-10 13:32:27 +02:00
Daniel Black
f98b8d36bd MDEV-23662: Make S3 Storage Engine tests better
To ensure that S3 is using its access and secret
key in the right way, make these different in the test
suite.
2020-09-08 13:42:55 +03:00
Daniel Black
64c10b03a0 MDEV-23662: Make S3 Storage Engine tests usable
added plugin-maturity = alpha to s3 mtr cnf files
and a missing  plugin-load-add=ha_s3 in the slave
configuration.
2020-09-08 13:42:55 +03:00
Sergei Petrunia
e38ac39104 MDEV-23662: Make S3 Storage Engine usable with MinIO
Add @@s3_port and @@s3_use_http. One can set these to access the
local MinIO, for example.
2020-09-08 13:42:55 +03:00
Sergei Golubchik
35034d819c S3 is pluggable now 2020-06-19 19:43:07 +02:00
Monty
60f08dd555 MDEV-22925 ALTER TABLE s3_table ENGINE=Aria can cause failure on slave
When converting a table (test.s3_table) from S3 to another engine, the
following will be logged to the binary log:

DROP TABLE IF EXISTS test.t1;
CREATE OR REPLACE TABLE test.t1 (...) ENGINE=new_engine
INSERT rows to test.t1 in binary-row-log-format

The bug is that the above statements are logged one by one to the binary
log. This means that a fast slave, configured to use the same S3 storage
as the master, would be able to execute the DROP and CREATE from the
binary log before the master has finished the ALTER TABLE.
In this case the slave would ignore the DROP (as it's on a S3 table) but
it will stop on CREATE of the local tale, as the table is still exists in
S3. The REPLACE part will be ignored by the slave as it can't touch the
S3 table.

The fix is to ensure that all the above statements is written to binary
log AFTER the table has been deleted from S3.
2020-06-19 12:03:13 +03:00
Monty
6a0c05b761 Fixed bugs in s3 test cases 2020-06-19 12:03:13 +03:00
Oleksandr Byelkin
d7a9cdc627 Fixed hang in Aria page cache with concurrent SELECT
MDEV-20302 Server hangs upon concurrent SELECT from partitioned S3
2020-06-14 19:39:43 +03:00
Monty
eca5c2c67f Added support for more functions when using partitioned S3 tables
MDEV-22088 S3 partitioning support

All ALTER PARTITION commands should now work on S3 tables except

REBUILD PARTITION
TRUNCATE PARTITION
REORGANIZE PARTITION

In addition, PARTIONED S3 TABLES can also be replicated.
This is achived by storing the partition tables .frm and .par file on S3
for partitioned shared (S3) tables.

The discovery methods are enchanced by allowing engines that supports
discovery to also support of the partitioned tables .frm and .par file

Things in more detail

- The .frm and .par files of partitioned tables are stored in S3 and kept
  in sync.
- Added hton callback create_partitioning_metadata to inform handler
  that metadata for a partitoned file has changed
- Added back handler::discover_check_version() to be able to check if
  a table's or a part table's definition has changed.
- Added handler::check_if_updates_are_ignored(). Needed for partitioning.
- Renamed rebind() -> rebind_psi(), as it was before.
- Changed CHF_xxx hadnler flags to an enum
- Changed some checks from using table->file->ht to use
  table->file->partition_ht() to get discovery to work with partitioning.
- If TABLE_SHARE::init_from_binary_frm_image() fails, ensure that we
  don't leave any .frm or .par files around.
- Fixed that writefrm() doesn't leave unusable .frm files around
- Appended extension to path for writefrm() to be able to reuse to function
  for creating .par files.
- Added DBUG_PUSH("") to a a few functions that caused a lot of not
  critical tracing.
2020-04-19 17:33:51 +03:00
Monty
6a9e24d046 Added support for replication for S3
MDEV-19964 S3 replication support

Added new configure options:
s3_slave_ignore_updates
"If the slave has shares same S3 storage as the master"

s3_replicate_alter_as_create_select
"When converting S3 table to local table, log all rows in binary log"

This allows on to configure slaves to have the S3 storage shared or
independent from the master.

Other thing:
Added new session variable '@@sql_if_exists' to force IF_EXIST to DDL's.
2020-03-24 21:00:02 +02:00
Monty
fac81c6752 Updated libmarias3 to latest version
This fixed a bug that caused the amazon.test to fail
2019-08-29 12:49:56 +03:00
Monty
1b5e5bdef3 MDEV-20306 Assert when converting encrypted Aria table to S3
Changes:
- maria_create() now uses a bit in the parameter flags to check if table
  should be encrypted instead of using maria_encrypted_tables.
- Don't encrypt tables that are to be converted to S3
- Added encrypted flag to ARIA_TABLE_CAPABILITIES
- maria_chk --description now prints if table is encrypted. Other
  operations is not allowed on encrypted tables.
2019-08-23 22:02:39 +02:00
Monty
bb6d674df9 Fixed assertion Assertion `!table->pos_in_locked_tables' failed
MDEV-19591
Assertion `!table->pos_in_locked_tables' failed in tc_release_table upon
altering table into S3 under lock.

The problem was that thd->open_tables->pos_in_locked_tables was not reset
when alter table failed to reopen a locked table.
2019-08-23 22:02:39 +02:00
Monty
e133aa1e2e Added testcase for MDEV-19585
MDEV-19585  Assertion with S3 table and flush_tables
2019-06-27 01:33:15 +03:00
Monty
f48943468f MDEV-19575 Fixed assert in ma_pagecache
There was a bug in the page cache that didn't take into account that
another thread could be waiting for a page to be read by read_big_block().
Fixed by releasing all waiters in read_big_block()
2019-06-26 23:39:12 +03:00
Vlad Lesin
5c5ea59bf8 MDEV-19867: fix mysqldump to by default not copy S3 tables
There are two options when coping S3 tables with mysqldump
(there is startup option --copy_s3_tables, boolean, default no)
1) Ignore all tables with engine S3, as the data is already safe in S3 and any
computer where you restore the backup will automatically discover the S3 table.
2) Copy the table as a normal table with the following 2 changes:
- Change ENGINE=S3 to ENGINE=ARIA;
- After copy add to log 'ALTER TABLE table_name ENGINE=S3'
2019-06-26 20:59:35 +03:00
Vlad Lesin
878ad986fd MDEV-19464: Altering partitioned table into S3 causes an obscure error
The error occured because aria_copy_to_s3() function tried to copy .frm file
of partition, but partition does not have it's own .frm file. The same is true
for aria_rename_s3().

To fix this issue the new parameter was added to those two functions to specify
if .frm file must be copied or not. The parameter is set to 'false' for
partitions.

Also there was other issue with EXCHANGE PARTITION. Briefly, there is the
following sequence of operations(see  exchange_name_with_ddl_log() for details):
1) rename swap table to temporary table,
2) rename partition to swap table,
3) rename temporary table to partition.

On step (1) .frm file is renamed too. On step (2) the swap table does not
have .frm file, as partition does not have it. On step (3) partition will have
.frm file, because it will be renamed from temporary table. All of this causes
error on different stages of the table access. To fix it, .frm is not touched
at all for s3 during EXCHANGE PARTITION operation. This is implemented in
ha_s3::rename_table() by additional checking of
current_thd->lex->alter_info.partition_flags(see also ALTER_PARTITION_EXCHANGE
in sql_yacc.yy).
2019-06-26 13:01:32 +03:00
Monty
8d4c159b1b Added s3_debug to be able to debug s3 connections 2019-06-25 13:09:06 +03:00
Monty
6aebaafe03 Added S3 test case with InnoDB 2019-06-24 12:13:19 +03:00
Monty
c51f615bf5 Added options --s3-protocol-version and --s3-host-name 2019-06-01 15:21:50 +03:00
Monty
ab38b7511b MDEV-17841 S3 storage engine
A read-only storage engine that stores it's data in (aws) S3

To store data in S3 one could use ALTER TABLE:
ALTER TABLE table_name ENGINE=S3

libmarias3 integration done by Sergei Golubchik
libmarias3 created by Andrew Hutchings
2019-05-23 02:28:23 +03:00