summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Reviewbb-10.11-midenok-MDEV-20865Aleksey Midenkov2023-03-265-32/+73
|
* MDEV-20865 Store foreign key info in TABLE_SHAREAleksey Midenkov2023-03-05162-1591/+6586
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Access foreign keys via TABLE_SHARE::foreign_keys and TABLE_SHARE::referenced_keys; foreign_keys and referenced_keys are objects in TABLE_SHARE. 2. Remove handler FK interface: - get_foreign_key_list() - get_parent_foreign_key_list() - referenced_by_foreign_key() 3. Invalidate referenced shares on: - RENAME TABLE - DROP TABLE - RENAME COLUMN - ADD FOREIGN KEY When foreign table is created or altered by the above operations all referenced shares are closed. This blocks the operation while any referenced shares are used (when at least one its TABLE instance is locked). 4. Update referenced shares on: - CREATE TABLE On CREATE TABLE add items to referenced_keys of referenced shares. 5. Invalidate foreign shares on: - RENAME TABLE - RENAME COLUMN The above-mentioned blocking takes effect. 6. Check foreign/referenced shares consistency on: - CHECK TABLE 7. Temporary change until MDEV-21051: InnoDB fill foreign key info at handler open(). On first TABLE open FK info is loaded from storage engine into TABLE_SHARE. All referenced shares (if any exist) are closed. This leads to blocking of first time foreign table open while referenced tables are used. Restore states of referenced shares in case of errors. FOREIGN_KEY_INFO refactored to FK_info holding Lex_cstring (MDEV-21311) Converge Foreign_key and supplemental generated Key together mysql_prepare_create_table() does data validation and such utilities as automatic name generation. But it does that only for indexes and ignores Foreign_key objects. Now as Foreign_key data needs to be stored in FRM files as well this processing must be done for them like for any other Key objects. Replace Key::FOREIGN_KEY type with Key::foreign flag of type Key::MULTIPLE and Key::generated set to true. Construct one object with Key::foreign == true instead of two objects of type Key::FOREIGN_KEY and Key::MULTIPLE. (MDEV-21051) datadict refactorings - Move read_extra2() to datadict.cc - Refactored extra2_fields to Extra2_info - build_frm_image() readability (MDEV-21051) build_table_shadow_filename() refactoring mysql_prepare_alter_table() leaks fixes (MDEV-21051) amend system tables locking restriction Table mysql.help_relation has foreign key to mysql.help_keyword. On bootstrap when help_relation is opened, it preopens help_keyword for READ and fails in lock_tables_check(). If system table is opened for write then fk references are opened for write. Related to: Bug#25422, WL#3984 Tests: main.lock (MDEV-21051) Store and read foreign key info into/from FRM files 1. Introduce Foreign_key_io class which creates/parses binary stream containing foreign key structures. Referenced tables store there only hints about foreign tables (their db and name), they restore full info from the corresponding tables. Foreign_key_io is stored under new EXTRA2_FOREIGN_KEY_INFO field in extra2 section of FRM file. 2. Modify mysql_prepare_create_table() to generate names for foreign keys. Until InnoDB storage of foreign keys is removed, FK names must be unique across the database: the FK name must be based on table name. 3. Keep stored data in sync on DDL changes. Referenced tables update their foreign hints after following operations on foreign tables: - RENAME TABLE - DROP TABLE - CREATE TABLE - ADD FOREIGN KEY - DROP FOREIGN KEY Foreign tables update their foreign info after following operations on referenced tables: - RENAME TABLE - RENAME COLUMN 4. To achieve 3. there must be ability to rewrite extra2 section of FRM file without full reparse. FRM binary is built from primary structures like HA_CREATE_INFO and cannot be built from TABLE_SHARE. Use shadow write and rename like fast_alter_partition_table() does. Shadow FRM is new FRM file that replaces the old one. Create table workflow: 1. Foreign_key is constructed in parser, placed into alter_info->key_list; 2. mysql_prepare_create_table() translates them to FK_info, assigns foreign_id if needed; 3. build_frm_image() writes two FK_info lists into FRM's extra2 section, for referenced keys it stores only table names (hints); 4. init_from_binary_frm_image() parses extra2 section and fills foreign_keys and referenced_keys of TABLE_SHARE. It restores referenced_keys by reading hint list of table names, opening corresponding shares and restoring FK_info from their foreign_keys. Hints resolution is done only when initializing non-temporary shares. Usually temporary share has different (temporary) name and it is impossible to resolve foreign keys by that name (as we identify them by both foreign and referenced table names). Another not unimportant reason is performance: this saves spare share acquisitions. Alter table workflow: 1. Foreign_key is constructed in parser, placed into alter_info->key_list; 2. mysql_prepare_alter_table() prepares action lists and share list of foreigns/references; 3. mysql_prepare_alter_table() locks list of foreigns/references by MDL_INTENTION_EXCLUSIVE, acquires shares; 4. prepare_create_table() converts key_list into FK_list, assigns foreign_id; 5. shadow FRM of altered table is created; 6. data is copied; 7. altered table is locked by MDL_EXCLUSIVE; 8. fk_handle_alter() processes action lists, creates FK backups, modifies shares, writes shadow FRMs; 9. altered table is closed; 10. shadow FRMs are installed; 11. altered table is renamed, FRM backup deleted; 12. (TBD in MDEV-21053) shadow FRMs installation log closed, backups deleted; On FK backup system: In case of failed DDL operation all shares that was modified must be restored into original state. This is done by FK_ddl_backup (CREATE, DROP), FK_rename_backup (RENAME), FK_alter_backup (ALTER). On STL usage: STL is used for utility not performance-critical algorithms, core structures hold native List. A wrapper was made to convert STL exception into bool error status or NULL value. MDEV-20865 fk_check_consistency() in CHECK TABLE Self-refs fix Test table_flags fix: "debug" deviation is now gone.
* MDEV-20865 Cleanups: dead code, typo.Aleksey Midenkov2022-12-053-8/+5
|
* MDEV-20865 extra2_fields refactored to Extra2_info classAleksey Midenkov2022-12-054-97/+191
| | | | | | | read_extra2() is now Extra2_info::read() Additional assertions for checking size consistency. Extra2_info::write() is used by further MDEV-20865 development.
* MDEV-20865 extra2_write_len() fixAleksey Midenkov2022-12-052-10/+20
| | | | | | | | Current implementation of extra2_write_len() does not guarantee of writing correct 2-byte values as it skips writing zero at the beginning. Refined DBUG_ASSERT() to more truthful limit.
* MDEV-20865 build_frm_image() readability cleanupAleksey Midenkov2022-12-051-20/+18
| | | | More clear names and constants use.
* MDEV-20865 extra2 structures moved to datadict.hAleksey Midenkov2022-12-055-114/+130
| | | | | | | | datadict.h is appropriate place for such types. These data types are used by Extra2_info, which is added to datadict.h later. unireg.cc is for older FRM routines. datadict.cc accepts new and refactored routines.
* Merge 10.10 into 10.11Marko Mäkelä2022-11-3041-340/+584
|\
| * Merge 10.9 into 10.10Marko Mäkelä2022-11-3041-342/+586
| |\
| | * Merge 10.8 into 10.9Marko Mäkelä2022-11-3041-342/+586
| | |\
| | | * Merge 10.7 into 10.8Marko Mäkelä2022-11-3041-342/+586
| | | |\
| | | | * Merge 10.6 into 10.7Marko Mäkelä2022-11-3041-345/+590
| | | | |\
| | | | | * MDEV-30069 fixup: Do not truncate files on recoveryMarko Mäkelä2022-11-302-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | recv_sys_t::recover_deferred(): If the file has been determined to be large enough, skip the call to os_file_set_size(), which would use the current value of FSP_SIZE, which during a multi-batch recovery can be smaller than the actual file size. os_file_io(): Also display the file offset in the warning message about partial I/O.
| | | | | * MDEV-30132 Crash after recovery, with InnoDB: Tried to read ...Marko Mäkelä2022-11-3015-254/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | os_file_read(): Merged with os_file_read_no_error_handling(). Crashing on a partial page read is as unhelpful as crashing on a corrupted page read (commit 0b47c126e31cddda1e94588799599e138400bcf8). Report the file name if it is available via IORequest.
| | | | | * Cleanup: Remove fil_space_t::is_deferred()Marko Mäkelä2022-11-302-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | The public data member can be checked directly by the only caller.
| | | | | * MDEV-30132 Crash after recovery, with InnoDB: Tried to read ... bytes at offsetMarko Mäkelä2022-11-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fil_space_t::prepare_acquired(): Do not attempt to extend (or shrink) files that will be processed by recv_sys_t::recover_deferred().
| | | | | * Merge 10.5 into 10.6Marko Mäkelä2022-11-301-0/+2
| | | | | |\
| | | | | | * MDEV-24412: Disable the test on ./mtr --embeddedMarko Mäkelä2022-11-301-0/+2
| | | | | | |
| | | | | * | Merge 10.5 into 10.6Marko Mäkelä2022-11-3012-63/+180
| | | | | |\ \ | | | | | | |/
| | | | | | * MDEV-24412: Create a separate testMarko Mäkelä2022-11-305-54/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some builders in our CI, most notably FreeBSD and IBM AIX, do not support sparse files. Also, Microsoft Windows requires special means for creating sparse files. Since these platforms do not run ./mtr --big-test, we will for now simply move the test to a separate file that requires that option.
| | | | | | * MDEV-23230 wsrep files installed when built without WSREP (#2334)Daniel Black2022-11-287-10/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prevent wsrep files from being installed if WITH_WSREP=OFF. Reviewed by Daniel Black Additionally excluded #include wsrep files and galera* files along with galera/wsrep tests. mysql-test/include/have_wsrep.inc remainds as its used by a few isolated tests. Co-authored-by: Chris Ross <cross2@cisco.com>
| | | | | * | MDEV-30119 INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION.NAME is NULL for ↵Thirunarayanan Balathandayuthapani2022-11-2911-13/+206
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | undo tablespaces - Information_schema.innodb_tablespaces_encryption should print undo tablespace name as innodb_undo001, innodb_undo002 and soon. - Encryption test should include undo tablespaces count when the tests are waiting for the condition to check whether all tables are encrypted or decrypted.
| | | | | * | Extend GitLab CI with build and test jobs for sanitizers (#2174)anson10142022-11-291-4/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a build and test job for each of ASAN, MSAN, TSAN, and UBSAN to the GitLab pipeline such that current vulnerabilities will be more easily visible and on each new commit, we can ensure that there are no additional errors introduced. Furthermore, sanitizer test runs are run separate from the existing mysql-test-run to isolate sanitizer error from functional errors. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.
* | | | | | | MDEV-30122 mariabackup.skip_innodb crashes when innodb_undo_tablespaces > 0Thirunarayanan Balathandayuthapani2022-11-292-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Assign srv_undo_space_id_start when InnoDB opens extra unused InnoDB undo tablespaces in srv_all_undo_tablespaces_open(). Mariabackup can detect the undo tablespaces using srv_undo_space_id_start variable
* | | | | | | Merge 10.10 into 10.11Marko Mäkelä2022-11-2821-189/+193
|\ \ \ \ \ \ \ | |/ / / / / /
| * | | | | | Merge 10.9 into 10.10Marko Mäkelä2022-11-2821-189/+193
| |\ \ \ \ \ \ | | |/ / / / /
| | * | | | | Merge 10.8 into 10.9Marko Mäkelä2022-11-2821-189/+193
| | |\ \ \ \ \ | | | |/ / / /
| | | * | | | Merge 10.7 into 10.8Marko Mäkelä2022-11-2821-162/+188
| | | |\ \ \ \ | | | | |/ / /
| | | | * | | Merge 10.6 into 10.7Marko Mäkelä2022-11-2819-162/+187
| | | | |\ \ \ | | | | | |/ /
| | | | | * | Merge 10.5 into 10.6Marko Mäkelä2022-11-2816-149/+181
| | | | | |\ \ | | | | | | |/
| | | | | | * MDEV-24412 InnoDB: Upgrade after a crash is not supportedMarko Mäkelä2022-11-284-3/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | recv_log_recover_10_4(): Widen the operand of bitwise and to 64 bits, so that the upgrade check will work when the redo log record is located more than 4 gigabytes from the start of the first file.
| | | | | | * MDEV-30106 InnoDB fails to validate the change buffer on startupMarko Mäkelä2022-11-284-33/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ibuf_init_at_db_start(): Validate the change buffer root page. A later version may stop creating a change buffer, and this validation check will prevent a downgrade from such later versions. ibuf_max_size_update(): If the change buffer was not loaded, do nothing. dict_boot(): Merge the local variable "error" to "err". Ignore failures of ibuf_init_at_db_start() if innodb_force_recovery>=4.
| | | | | | * MDEV-30089 Metrics not incremented for 1st iteration in ↵Marko Mäkelä2022-11-281-10/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | buf_LRU_free_from_common_LRU_list() In commit a03dd94be804a4b8b1406696920834bb2c0bedbd as well as mysql/mysql-server@6ef8c343445a26aaf9ebd76d72cf57db44b481f5 the iterations were changed so that the variable "scanned" would remain 0 when the first list item qualifies for eviction. buf_LRU_free_from_unzip_LRU_list(), buf_LRU_free_from_common_LRU_list(): Increment "scanned" when a block can be freed. buf_LRU_free_from_common_LRU_list(): Remove a redundant condition. Whenever this function is invoked, buf_pool.LRU should be nonempty, hence something should always be scanned. Thanks to Jean-François Gagné for reporting this.
| | | | | | * MDEV-25417: Remove innodb buffer pool load throttlingDaniel Black2022-11-281-72/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The very lightest of load would decimate any buffer pool loading to ~1 page per second. As seen in MDEV-29343 this resulting in a load taking over an hour on a high end system. Since MDEV-26547 the fetching is asynchronous, however the loading has equal access to the IO as the SQL queries.
| | | | | | * MDEV-29607: binlog.binlog_checkpoint fails in buildbot with result content ↵Brandon Nesterenko2022-11-252-23/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mismatch Problem: ======== There is a race condition in binlog.binlog_checkpoint between the binlog background thread creating a binlog checkpoint event, and the connection thread binlogging a query event for creating a table. Because the test outputs the events for validation, the order between these two events can be different, resulting in a failed test. Solution: ======== Instead of outputting the binlog events, use assert_grep to validate the content of the binlog is correct. Reviewed By: ============ Andrei Elkin <andrei.elkin@mariadb.com>
| | | | | | * Query cache: removed unused THD from few functionsDaniel Black2022-11-262-12/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A few query cache functions don't use THD pointer so its removed from their interface.
| | | | | | * MDEV-29760: DROP DATABASE hangs when particular query cache is presentDaniel Black2022-11-263-2/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the regression introduced in dfb41fddf69ccbca89fd322901f2809bc3bcc0e9. In the restructure of mysql_rm_table_no_locks the early condition of !frm_error that enabled non_tmp_table_deleted, and hence the query cache invalidation, was removed. The query_cache_invalidate1(thd, dbnorm) called after mysql_rm_table_no_locks depends on the query cache removal (for unexamined reasons). Under DROP DATABASE, in mysql_rm_table_no_locks, dont_log_query is true preventing the late setting of non_tmp_table_deleted (which retained one of its purposes as a replication deletion of temporary tables, but not query cache invalidation). The non_temp_tables_count however can still be used to invalidate the query cache.
| | | | | * | MDEV-29603 fixup: GCC -Wunused-but-set-variableMarko Mäkelä2022-11-241-2/+2
| | | | | | |
| | | | | * | MDEV-21452 fixup: Remove PFS_NOT_INSTRUMENTEDMarko Mäkelä2022-11-241-9/+0
| | | | | | |
| | | | | * | Fixed a memory leak in aria_read_logMonty2022-11-241-2/+4
| | | | | | |
| | | | * | | MDEV-29841 fixup: Correct error message translationsMarko Mäkelä2022-11-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes up 0e6f2757d11502d74d21e4a75fa5247fc3334024 and 6f8fb41f213dd34b43ef6f3819b4be12f6b26c01 which corrupted the Chinese and Spanish translations of the changed error message ER_PARTITION_WRONG_TYPE.
| | | | * | | fix password_reuse_check plugin to link in embeddedSergei Golubchik2022-11-241-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | it uses C client API, so needs RECOMPILE_FOR_EMBEDDED
| | | * | | | MDEV-14425 fixup for MDEV-25312: Remove dead codeMarko Mäkelä2022-11-251-27/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In commit cf552f5886968fc022122960d3a9274ce9f27819 we removed the function os_normalize_path() and started writing file names to the InnoDB redo log always using the same path separator, even on Microsoft Windows. In commit 685d958e38b825ad9829be311f26729cccf37c46 the ability to recover from previous log file formats was removed. Thus, the log file can never contain the Microsoft specific path separator and the conversion code can be removed. Note: *.isl files may still contain Microsoft Windows path separators. They will be replaced with standard ones in read_link_file().
* | | | | | | Merge 10.10 into 10.11Marko Mäkelä2022-11-2412-137/+184
|\ \ \ \ \ \ \ | |/ / / / / /
| * | | | | | Merge 10.9 into 10.10Marko Mäkelä2022-11-2412-137/+184
| |\ \ \ \ \ \ | | |/ / / / /
| | * | | | | Merge 10.8 into 10.9Marko Mäkelä2022-11-2412-137/+184
| | |\ \ \ \ \ | | | |/ / / /
| | | * | | | Merge 10.7 into 10.8Marko Mäkelä2022-11-2412-137/+184
| | | |\ \ \ \ | | | | |/ / /
| | | | * | | Merge 10.6 into 10.7Marko Mäkelä2022-11-2412-137/+184
| | | | |\ \ \ | | | | | |/ /
| | | | | * | Merge 10.5 into 10.6Marko Mäkelä2022-11-2311-131/+170
| | | | | |\ \ | | | | | | |/
| | | | | | * MDEV-30009 InnoDB shutdown hangs when the change buffer is corruptedMarko Mäkelä2022-11-232-100/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The InnoDB change buffer (ibuf.index, stored in the system tablespace) and the change buffer bitmaps in persistent tablespaces could get out of sync with each other: According to the bitmap, no changes exist for a page, while there actually exist buffered entries in ibuf.index. InnoDB performs lazy deletion of buffered changes. When a secondary index leaf page is freed (possibly as part of DROP INDEX), any buffered changes will not be deleted. Instead, they would be deleted on a subsequent buf_page_create_low(). One scenario where InnoDB failed to delete buffered changes is as follows: 1. Some changes were buffered for a secondary index leaf page. 2. The index page had been freed. 3. ibuf_read_merge_pages() invoked ibuf_merge_or_delete_for_page(), which noticed that the page had been freed, and reset the change buffer bits, but did not delete the records from ibuf.index. 4. The index page was reallocated for something else. 5. The index page was removed from the buffer pool. 6. Some changes were buffered for the newly created page. 7. Finally, the buffered changes from both 1. and 6. were merged. 8. The index is corrupted. An alternative outcome is: 4. Shutdown with innodb_fast_shutdown=0 gets into an infinite loop. An alternative scenario is: 3. ibuf_set_bitmap_for_bulk_load() reset the IBUF_BITMAP_BUFFERED bit but did not delete the ibuf.index records for that page number. The shutdown hang was already once fixed in commit d7a2401750bb29dfdb45929a536539b9f17b347f, refactored for 10.5 in commit 77e8a311e1f919f15845c75d08de4340965c0bc4 and disabled in commit 310dff5d847b3c117ab6bca8e6ccbcc8bca818d9 due to corruption. We will fix this as follows: ibuf_delete_recs(): Delete all ibuf.index entries for the specified page. ibuf_merge_or_delete_for_page(): When the change buffer bitmap bits were set and the page had been freed, and the page does not belong to ibuf.index itself, invoke ibuf_delete_recs(). This prevents the corruption from occurring when a DML operation is allocating a previously freed page for which changes had been buffered. ibuf_set_bitmap_for_bulk_load(): When the change buffer bitmap bits were set, invoke ibuf_delete_recs(). This prevents the corruption from occurring when CREATE INDEX is reusing a previously freed page. ibuf_read_merge_pages(): On slow shutdown, remove the orphan records by invoking ibuf_delete_recs(). This fixes the hang when the change buffer had become corrupted. We also remove the dops[] accounting, because nothing can monitor it during shutdown. We invoke ibuf_delete_recs() if: (a) buf_page_get_gen() failed to load the page or merge changes (b) the page is not a valid index leaf page (c) the page number is out of tablespace bounds srv_shutdown(): Invoke ibuf_max_size_update(0) to ensure that the race condition that motivated us to disable the code in ibuf_read_merge_pages() in commit 310dff5d847b3c117ab6bca8e6ccbcc8bca818d9 is no longer possible. That is, during slow shutdown, both the rollback of transactions and the purge of history will return early from ibuf_insert_low(). ibuf_merge_space(), ibuf_delete_for_discarded_space(): Cleanup: Do not allocate a memory heap. This was implemented by Thirunarayanan Balathandayuthapani and tested with innodb_change_buffering_debug=1 by Matthias Leich.