-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-38412 System tablespace fails to shrink due to legacy tables #4884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Thirunarayanan
wants to merge
1
commit into
11.4
Choose a base branch
from
MDEV-38412
base: 11.4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+260
−103
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1822,6 +1822,17 @@ static int innodb_check_version(handlerton *hton, const char *path, | |
| DBUG_RETURN(2); | ||
| } | ||
|
|
||
| static bool should_drop_garbage_table(const rec_t* rec, ulint len) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is missing |
||
| { | ||
| if (len < tmp_file_prefix_length) | ||
| return false; | ||
|
|
||
| if (const char *f= static_cast<const char*> | ||
| (memchr(rec, '/', len - tmp_file_prefix_length))) | ||
| return !memcmp(f + 1, tmp_file_prefix, tmp_file_prefix_length); | ||
| return false; | ||
| } | ||
|
|
||
| /** Drop any garbage intermediate tables that existed in the system | ||
| after a backup was restored. | ||
|
|
||
|
|
@@ -1833,109 +1844,7 @@ data dictionary (while the data files themselves are missing). | |
| We will attempt to drop the tables here. */ | ||
| static void drop_garbage_tables_after_restore() | ||
| { | ||
| btr_pcur_t pcur; | ||
| trx_t *trx= trx_create(); | ||
| mtr_t mtr{trx}; | ||
|
|
||
| ut_ad(!purge_sys.enabled()); | ||
| ut_d(purge_sys.stop_FTS()); | ||
|
|
||
| mtr.start(); | ||
| if (pcur.open_leaf(true, dict_sys.sys_tables->indexes.start, BTR_SEARCH_LEAF, | ||
| &mtr) != DB_SUCCESS) | ||
| goto all_fail; | ||
| for (;;) | ||
| { | ||
| btr_pcur_move_to_next_user_rec(&pcur, &mtr); | ||
|
|
||
| if (!btr_pcur_is_on_user_rec(&pcur)) | ||
| break; | ||
|
|
||
| const rec_t *rec= btr_pcur_get_rec(&pcur); | ||
| if (rec_get_deleted_flag(rec, 0)) | ||
| continue; | ||
|
|
||
| static_assert(DICT_FLD__SYS_TABLES__NAME == 0, "compatibility"); | ||
| size_t len; | ||
| if (rec_get_1byte_offs_flag(rec)) | ||
| { | ||
| len= rec_1_get_field_end_info(rec, 0); | ||
| if (len & REC_1BYTE_SQL_NULL_MASK) | ||
| continue; /* corrupted SYS_TABLES.NAME */ | ||
| } | ||
| else | ||
| { | ||
| len= rec_2_get_field_end_info(rec, 0); | ||
| static_assert(REC_2BYTE_EXTERN_MASK == 16384, "compatibility"); | ||
| if (len >= REC_2BYTE_EXTERN_MASK) | ||
| continue; /* corrupted SYS_TABLES.NAME */ | ||
| } | ||
|
|
||
| if (len < tmp_file_prefix_length) | ||
| continue; | ||
| if (const char *f= static_cast<const char*> | ||
| (memchr(rec, '/', len - tmp_file_prefix_length))) | ||
| { | ||
| if (memcmp(f + 1, tmp_file_prefix, tmp_file_prefix_length)) | ||
| continue; | ||
| } | ||
| else | ||
| continue; | ||
|
|
||
| btr_pcur_store_position(&pcur, &mtr); | ||
| btr_pcur_commit_specify_mtr(&pcur, &mtr); | ||
|
|
||
| trx_start_for_ddl(trx); | ||
| std::vector<pfs_os_file_t> deleted; | ||
| dberr_t err= DB_TABLE_NOT_FOUND; | ||
| row_mysql_lock_data_dictionary(trx); | ||
|
|
||
| if (dict_table_t *table= dict_sys.load_table | ||
| ({reinterpret_cast<const char*>(pcur.old_rec), len}, | ||
| DICT_ERR_IGNORE_DROP)) | ||
| { | ||
| table->acquire(); | ||
| row_mysql_unlock_data_dictionary(trx); | ||
| err= lock_table_for_trx(table, trx, LOCK_X); | ||
| if (err == DB_SUCCESS && | ||
| (table->flags2 & (DICT_TF2_FTS_HAS_DOC_ID | DICT_TF2_FTS))) | ||
| { | ||
| fts_optimize_remove_table(table); | ||
| err= fts_lock_tables(trx, *table); | ||
| } | ||
| if (err == DB_SUCCESS) | ||
| err= lock_sys_tables(trx); | ||
| row_mysql_lock_data_dictionary(trx); | ||
| table->release(); | ||
|
|
||
| if (err == DB_SUCCESS) | ||
| err= trx->drop_table(*table); | ||
| if (err != DB_SUCCESS) | ||
| goto fail; | ||
| trx->commit(deleted); | ||
| } | ||
| else | ||
| { | ||
| fail: | ||
| trx->rollback(); | ||
| sql_print_error("InnoDB: cannot drop %.*s: %s", | ||
| static_cast<int>(len), pcur.old_rec, ut_strerr(err)); | ||
| } | ||
|
|
||
| row_mysql_unlock_data_dictionary(trx); | ||
| for (pfs_os_file_t d : deleted) | ||
| os_file_close(d); | ||
|
|
||
| mtr.start(); | ||
| if (pcur.restore_position(BTR_SEARCH_LEAF, &mtr) == btr_pcur_t::CORRUPTED) | ||
| break; | ||
| } | ||
|
|
||
| all_fail: | ||
| mtr.commit(); | ||
| trx->clear_and_free(); | ||
| ut_free(pcur.old_rec_buf); | ||
| ut_d(purge_sys.resume_FTS()); | ||
| drop_tables_by_filter(should_drop_garbage_table); | ||
| } | ||
|
|
||
| static int innodb_ddl_recovery_done(handlerton*) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.