-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
MDEV-39548 Further cleanup of MDL_request boilerplate #5160
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8811,19 +8811,15 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate) | |
| } | ||
| else | ||
| { | ||
| MDL_request mdl_request; | ||
|
|
||
| MDL_REQUEST_INIT(&mdl_request, MDL_key::BACKUP, "", "", MDL_BACKUP_COMMIT, | ||
| MDL_EXPLICIT); | ||
| if (thd->mdl_context.acquire_lock(&mdl_request, | ||
| thd->variables.lock_wait_timeout)) | ||
| if (!(thd->backup_commit_lock= thd->mdl_context.MDL_ACQUIRE_LOCK( | ||
| MDL_key::BACKUP, "", "", MDL_BACKUP_COMMIT, | ||
| MDL_EXPLICIT, thd->variables.lock_wait_timeout))) | ||
| DBUG_RETURN(1); | ||
| thd->backup_commit_lock= &mdl_request; | ||
|
|
||
| if ((res= thd->wait_for_prior_commit())) | ||
| { | ||
| if (mdl_request.ticket) | ||
| thd->mdl_context.release_lock(mdl_request.ticket); | ||
| if (thd->backup_commit_lock) | ||
| thd->mdl_context.release_lock(thd->backup_commit_lock); | ||
| thd->backup_commit_lock= 0; | ||
| DBUG_RETURN(res); | ||
| } | ||
|
|
@@ -8833,8 +8829,8 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate) | |
| prev_binlog_id= current_binlog_id; | ||
| res= write_gtid_event(thd, nullptr, true, using_trans, commit_id, | ||
| false, false, false); | ||
| if (mdl_request.ticket) | ||
| thd->mdl_context.release_lock(mdl_request.ticket); | ||
| if (thd->backup_commit_lock) | ||
| thd->mdl_context.release_lock(thd->backup_commit_lock); | ||
| thd->backup_commit_lock= 0; | ||
| if (res) | ||
| goto err; | ||
|
|
@@ -8944,7 +8940,6 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate) | |
| &cache_data->engine_binlog_info; | ||
| engine_context->gtid_offset= my_b_tell(file); | ||
| my_off_t binlog_total_bytes; | ||
| MDL_request mdl_request; | ||
| int res; | ||
|
|
||
| if (engine_context->out_of_band_offset) | ||
|
|
@@ -8957,17 +8952,15 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate) | |
| goto engine_fail; | ||
| } | ||
|
|
||
| MDL_REQUEST_INIT(&mdl_request, MDL_key::BACKUP, "", "", MDL_BACKUP_COMMIT, | ||
| MDL_EXPLICIT); | ||
| if (thd->mdl_context.acquire_lock(&mdl_request, | ||
| thd->variables.lock_wait_timeout)) | ||
| if (!(thd->backup_commit_lock= thd->mdl_context.MDL_ACQUIRE_LOCK( | ||
| MDL_key::BACKUP, "", "", MDL_BACKUP_COMMIT, | ||
| MDL_EXPLICIT, thd->variables.lock_wait_timeout))) | ||
| goto engine_fail; | ||
| thd->backup_commit_lock= &mdl_request; | ||
|
|
||
| if (thd->wait_for_prior_commit()) | ||
| { | ||
| if (mdl_request.ticket) | ||
| thd->mdl_context.release_lock(mdl_request.ticket); | ||
| if (thd->backup_commit_lock) | ||
| thd->mdl_context.release_lock(thd->backup_commit_lock); | ||
| thd->backup_commit_lock= 0; | ||
| goto engine_fail; | ||
| } | ||
|
|
@@ -8985,8 +8978,8 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate) | |
| mysql_mutex_lock(&LOCK_log); | ||
| res= write_gtid_event(thd, cache_data, true, using_trans, commit_id, | ||
| false, false, false); | ||
| if (mdl_request.ticket) | ||
| thd->mdl_context.release_lock(mdl_request.ticket); | ||
| if (thd->backup_commit_lock) | ||
| thd->mdl_context.release_lock(thd->backup_commit_lock); | ||
| thd->backup_commit_lock= 0; | ||
| if (res) | ||
| { | ||
|
|
@@ -10258,12 +10251,12 @@ MYSQL_BIN_LOG::queue_for_group_commit(group_commit_entry *orig_entry) | |
| yet have the MDL_BACKUP_COMMIT_LOCK) and any threads using | ||
| BACKUP LOCK BLOCK_COMMIT. | ||
| */ | ||
| if (thd->backup_commit_lock && thd->backup_commit_lock->ticket && | ||
| if (thd->backup_commit_lock && | ||
| !backup_lock_released) | ||
|
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. Any reason to keep |
||
| { | ||
| backup_lock_released= 1; | ||
| thd->mdl_context.release_lock(thd->backup_commit_lock->ticket); | ||
| thd->backup_commit_lock->ticket= 0; | ||
| thd->mdl_context.release_lock(thd->backup_commit_lock); | ||
| thd->backup_commit_lock= 0; | ||
| } | ||
|
|
||
| /* | ||
|
|
@@ -10527,8 +10520,9 @@ MYSQL_BIN_LOG::queue_for_group_commit(group_commit_entry *orig_entry) | |
|
|
||
| end: | ||
| if (backup_lock_released) | ||
| thd->mdl_context.acquire_lock(thd->backup_commit_lock, | ||
| thd->variables.lock_wait_timeout); | ||
| thd->backup_commit_lock= thd->mdl_context.MDL_ACQUIRE_LOCK( | ||
| MDL_key::BACKUP, "", "", MDL_BACKUP_COMMIT, | ||
| MDL_EXPLICIT, thd->variables.lock_wait_timeout); | ||
| DBUG_RETURN(result); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1876,14 +1876,14 @@ bool lock_db_routines(THD *thd, const Lex_ident_db_normalized &db) | |
| continue; | ||
|
|
||
| longlong sp_type= table->field[MYSQL_PROC_MYSQL_TYPE]->val_int(); | ||
| MDL_request *mdl_request= new (thd->mem_root) MDL_request; | ||
| const Sp_handler *sph= Sp_handler::handler((enum_sp_type) | ||
| sp_type); | ||
| if (!sph) | ||
| sph= &sp_handler_procedure; | ||
| MDL_REQUEST_INIT(mdl_request, sph->get_mdl_type(), db.str, sp_name, | ||
| MDL_EXCLUSIVE, MDL_TRANSACTION); | ||
| mdl_requests.push_front(mdl_request); | ||
| if (MDL_REQUEST_LIST_ADD(&mdl_requests, thd->mem_root, | ||
| sph->get_mdl_type(), db.str, sp_name, | ||
| MDL_EXCLUSIVE, MDL_TRANSACTION)) | ||
| goto error; | ||
|
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. You can't just |
||
| } while (! (nxtres= table->file->ha_index_next_same(table->record[0], keybuf, key_len))); | ||
| } | ||
| table->file->ha_index_end(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -173,18 +173,13 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, | |
| tmp_write_to_binlog= 0; | ||
| if (mysql_bin_log.is_open()) | ||
| { | ||
| MDL_request mdl_request; | ||
| MDL_REQUEST_INIT(&mdl_request, MDL_key::BACKUP, "", "", MDL_BACKUP_START, | ||
| MDL_EXPLICIT); | ||
| if (thd && | ||
| thd->mdl_context.acquire_lock(&mdl_request, | ||
| thd->variables.lock_wait_timeout)) | ||
| !(thd->backup_commit_lock= thd->mdl_context.MDL_ACQUIRE_LOCK( | ||
|
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. Please don't use |
||
| MDL_key::BACKUP, "", "", MDL_BACKUP_START, | ||
| MDL_EXPLICIT, thd->variables.lock_wait_timeout))) | ||
| result= 1; | ||
| else | ||
| { | ||
| if (thd) | ||
| thd->backup_commit_lock= &mdl_request; | ||
|
|
||
| DYNAMIC_ARRAY *drop_gtid_domain= | ||
| (thd && (thd->lex->delete_gtid_domain.elements > 0)) ? | ||
| &thd->lex->delete_gtid_domain : NULL; | ||
|
|
@@ -200,8 +195,8 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, | |
| } | ||
| if (thd) | ||
| { | ||
| if (mdl_request.ticket) | ||
| thd->mdl_context.release_lock(mdl_request.ticket); | ||
| if (thd->backup_commit_lock) | ||
|
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 condition looks redundant, you already check that ticket contains valid value when you acquire the lock. |
||
| thd->mdl_context.release_lock(thd->backup_commit_lock); | ||
| thd->backup_commit_lock= 0; | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backup_commit_lock_acquired == trueimplies validthd->backup_commit_lock.