Implement undo tablespace truncation via normal redo logging. Implement TRUNCATE TABLE as a combination of RENAME to #sql-ib name, CREATE, and DROP. Note: Orphan #sql-ib*.ibd may be left behind if MariaDB Server 10.2 is killed before the DROP operation is committed. If MariaDB Server 10.2 is killed during TRUNCATE, it is also possible that the old table was renamed to #sql-ib*.ibd but the data dictionary will refer to the table using the original name. In MariaDB Server 10.3, RENAME inside InnoDB is transactional, and #sql-* tables will be dropped on startup. So, this new TRUNCATE will be fully crash-safe in 10.3. ha_mroonga::wrapper_truncate(): Pass table options to the underlying storage engine, now that ha_innobase::truncate() will need them. rpl_slave_state::truncate_state_table(): Before truncating mysql.gtid_slave_pos, evict any cached table handles from the table definition cache, so that there will be no stale references to the old table after truncating. == TRUNCATE TABLE == WL#6501 in MySQL 5.7 introduced separate log files for implementing atomic and crash-safe TRUNCATE TABLE, instead of using the InnoDB undo and redo log. Some convoluted logic was added to the InnoDB crash recovery, and some extra synchronization (including a redo log checkpoint) was introduced to make this work. This synchronization has caused performance problems and race conditions, and the extra log files cannot be copied or applied by external backup programs. In order to support crash-upgrade from MariaDB 10.2, we will keep the logic for parsing and applying the extra log files, but we will no longer generate those files in TRUNCATE TABLE. A prerequisite for crash-safe TRUNCATE is a crash-safe RENAME TABLE (with full redo and undo logging and proper rollback). This will be implemented in MDEV-14717. ha_innobase::truncate(): Invoke RENAME, create(), delete_table(). Because RENAME cannot be fully rolled back before MariaDB 10.3 due to missing undo logging, add some explicit rename-back in case the operation fails. ha_innobase::delete(): Introduce a variant that takes sqlcom as a parameter. In TRUNCATE TABLE, we do not want to touch any FOREIGN KEY constraints. ha_innobase::create(): Add the parameters file_per_table, trx. In TRUNCATE, the new table must be created in the same transaction that renames the old table. create_table_info_t::create_table_info_t(): Add the parameters file_per_table, trx. row_drop_table_for_mysql(): Replace a bool parameter with sqlcom. row_drop_table_after_create_fail(): New function, wrapping row_drop_table_for_mysql(). dict_truncate_index_tree_in_mem(), fil_truncate_tablespace(), fil_prepare_for_truncate(), fil_reinit_space_header_for_table(), row_truncate_table_for_mysql(), TruncateLogger, row_truncate_prepare(), row_truncate_rollback(), row_truncate_complete(), row_truncate_fts(), row_truncate_update_system_tables(), row_truncate_foreign_key_checks(), row_truncate_sanity_checks(): Remove. row_upd_check_references_constraints(): Remove a check for TRUNCATE, now that the table is no longer truncated in place. The new test innodb.truncate_foreign uses DEBUG_SYNC to cover some race-condition like scenarios. The test innodb-innodb.truncate does not use any synchronization. We add a redo log subformat to indicate backup-friendly format. MariaDB 10.4 will remove support for the old TRUNCATE logging, so crash-upgrade from old 10.2 or 10.3 to 10.4 will involve limitations. == Undo tablespace truncation == MySQL 5.7 implements undo tablespace truncation. It is only possible when innodb_undo_tablespaces is set to at least 2. The logging is implemented similar to the WL#6501 TRUNCATE, that is, using separate log files and a redo log checkpoint. We can simply implement undo tablespace truncation within a single mini-transaction that reinitializes the undo log tablespace file. Unfortunately, due to the redo log format of some operations, currently, the total redo log written by undo tablespace truncation will be more than the combined size of the truncated undo tablespace. It should be acceptable to have a little more than 1 megabyte of log in a single mini-transaction. This will be fixed in MDEV-17138 in MariaDB Server 10.4. recv_sys_t: Add truncated_undo_spaces[] to remember for which undo tablespaces a MLOG_FILE_CREATE2 record was seen. namespace undo: Remove some unnecessary declarations. fil_space_t::is_being_truncated: Document that this flag now only applies to undo tablespaces. Remove some references. fil_space_t::is_stopping(): Do not refer to is_being_truncated. This check is for tablespaces of tables. Potentially used tablespaces are never truncated any more. buf_dblwr_process(): Suppress the out-of-bounds warning for undo tablespaces. fil_truncate_log(): Write a MLOG_FILE_CREATE2 with a nonzero page number (new size of the tablespace in pages) to inform crash recovery that the undo tablespace size has been reduced. fil_op_write_log(): Relax assertions, so that MLOG_FILE_CREATE2 can be written for undo tablespaces (without .ibd file suffix) for a nonzero page number. os_file_truncate(): Add the parameter allow_shrink=false so that undo tablespaces can actually be shrunk using this function. fil_name_parse(): For undo tablespace truncation, buffer MLOG_FILE_CREATE2 in truncated_undo_spaces[]. recv_read_in_area(): Avoid reading pages for which no redo log records remain buffered, after recv_addr_trim() removed them. trx_rseg_header_create(): Add a FIXME comment that we could write much less redo log. trx_undo_truncate_tablespace(): Reinitialize the undo tablespace in a single mini-transaction, which will be flushed to the redo log before the file size is trimmed. recv_addr_trim(): Discard any redo logs for pages that were logged after the new end of a file, before the truncation LSN. If the rec_list becomes empty, reduce n_addrs. After removing any affected records, actually truncate the file. recv_apply_hashed_log_recs(): Invoke recv_addr_trim() right before applying any log records. The undo tablespace files must be open at this point. buf_flush_or_remove_pages(), buf_flush_dirty_pages(), buf_LRU_flush_or_remove_pages(): Add a parameter for specifying the number of the first page to flush or remove (default 0). trx_purge_initiate_truncate(): Remove the log checkpoints, the extra logging, and some unnecessary crash points. Merge the code from trx_undo_truncate_tablespace(). First, flush all to-be-discarded pages (beyond the new end of the file), then trim the space->size to make the page allocation deterministic. At the only remaining crash injection point, flush the redo log, so that the recovery can be tested. |
7 years ago | |
---|---|---|
BUILD | Disable rocksdb when building with ASAN | 8 years ago |
Docs | Merge branch '10.0' into 10.1 | 10 years ago |
client | Merge 10.1 into 10.2 | 7 years ago |
cmake | Merge 10.1 into 10.2 | 7 years ago |
dbug | Make debug multi thread safe | 8 years ago |
debian | Merge 10.1 into 10.2 | 7 years ago |
extra | MDEV-13564 Mariabackup does not work with TRUNCATE | 7 years ago |
include | Merge 10.1 into 10.2 | 7 years ago |
libmariadb@d0f201451d | SLES11 OpenSSL 0.9.8 support | 7 years ago |
libmysqld | Merge remote-tracking branch 'origin/10.1' into 10.2 | 8 years ago |
libservices | MDEV-11663 Create services for functionality used by plugins | 9 years ago |
man | After-merge fix: Rename tokudb_logdump to tokudb_logprint | 7 years ago |
mysql-test | MDEV-13564 Mariabackup does not work with TRUNCATE | 7 years ago |
mysys | Merge 10.1 into 10.2 | 7 years ago |
mysys_ssl | MDEV-14567: CRYPTO_set_mem_functions fails in FIPS mode | 8 years ago |
pcre | Merge branch '10.1' into 10.2 | 8 years ago |
plugin | Merge 10.1 into 10.2 | 7 years ago |
randgen/conf | Group commit for maria engine. | 16 years ago |
scripts | Merge 10.1 into 10.2 | 7 years ago |
sql | MDEV-13564 Mariabackup does not work with TRUNCATE | 7 years ago |
sql-bench | MDEV-15448 Remove "innodb_additional_mem_pool_size" setting from my-innodb-heavy-4G.cnf file | 8 years ago |
sql-common | Merge 10.1 into 10.2 | 7 years ago |
storage | MDEV-13564 Mariabackup does not work with TRUNCATE | 7 years ago |
strings | Merge 10.1 into 10.2 | 7 years ago |
support-files | Merge 10.1 into 10.2 | 7 years ago |
tests | fix failing main.mysql_client_test test on 32bit | 8 years ago |
unittest | MDEV-14014 Multi-Slave Replication Fail: bogus data in log event | 7 years ago |
vio | MDEV-15596 10.2 doesn't work with openssl 1.1.1 | 7 years ago |
win | Fix 2 more VS2015 warnings | 8 years ago |
wsrep | Prevent building WSREP without INNODB | 8 years ago |
zlib | Build improvements and cleanups. | 8 years ago |
.gitattributes | Merge branch '10.0' into 10.1 | 8 years ago |
.gitignore | Merge branch '10.1' into 10.2 | 7 years ago |
.gitmodules | Use https instead of ssh(git@) for rocksdb submodule. | 9 years ago |
.travis.compiler.sh | travis: add clang-5.0 | 8 years ago |
.travis.yml | travis: osx - xcode 8.3 -> 9.1 | 8 years ago |
BUILD-CMAKE | various documentation updates | 13 years ago |
CMakeLists.txt | Merge 10.1 into 10.2 | 7 years ago |
COPYING | Use a new version of "COPYING", the GPL text. | 16 years ago |
COPYING.thirdparty | Correct FSF address | 9 years ago |
CREDITS | Update contributors | 8 years ago |
EXCEPTIONS-CLIENT | MDEV-5262: Missing retry after temp error in parallel replication | 12 years ago |
INSTALL-SOURCE | Update AskMonty and Atlassian references to MariaDB | 10 years ago |
INSTALL-WIN-SOURCE | Update AskMonty and Atlassian references to MariaDB | 10 years ago |
KNOWN_BUGS.txt | various documentation updates | 13 years ago |
README.md | Better Link Spacing | 7 years ago |
VERSION | bump the VERSION | 7 years ago |
appveyor.yml | Add some hints for finding bison on its usual locations on Windows. | 8 years ago |
config.h.cmake | MDEV-13785: move defination HAVE_LARGE_PAGES -> HAVE_LINUX_LARGE_PAGES | 8 years ago |
configure.cmake | Merge remote-tracking branch 'origin/10.1' into 10.2 | 8 years ago |
README.md
MariaDB: drop-in replacement for MySQL
MariaDB is designed as a drop-in replacement of MySQL(R) with more features, new storage engines, fewer bugs, and better performance.
MariaDB is brought to you by the MariaDB Foundation. Please read the CREDITS file for details about the MariaDB Foundation, and who is developing MariaDB.
MariaDB is developed by many of the original developers of MySQL who now work for the MariaDB Foundation and the MariaDB Corporation, and by many people in the community.
MySQL, which is the base of MariaDB, is a product and trademark of Oracle Corporation, Inc. For a list of developers and other contributors, see the Credits appendix. You can also run 'SHOW authors' to get a list of active contributors.
A description of the MariaDB project and a manual can be found at:
https://mariadb.com/kb/en/mariadb-vs-mysql-features/
https://mariadb.com/kb/en/mariadb-versus-mysql-features/
https://mariadb.com/kb/en/mariadb-versus-mysql-compatibility/
As MariaDB is a full replacement of MySQL, the MySQL manual at http://dev.mysql.com/doc is generally applicable.
Help:
More help is available from the Maria Discuss mailing list https://launchpad.net/~maria-discuss and the #maria IRC channel on Freenode.
License:
NOTE:
MariaDB is specifically available only under version 2 of the GNU General Public License (GPLv2). (I.e. Without the "any later version" clause.) This is inherited from MySQL. Please see the README file in the MySQL distribution for more information.
License information can be found in the COPYING, COPYING.LESSER, and COPYING.thirdparty files.
Bug Reports:
Bug and/or error reports regarding MariaDB should be submitted at https://mariadb.org/jira
Bugs in the MySQL code can also be submitted at https://bugs.mysql.com
The code for MariaDB, including all revision history, can be found at: https://github.com/MariaDB/server