summaryrefslogtreecommitdiff
path: root/storage/innobase/btr/btr0scrub.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/btr/btr0scrub.cc')
-rw-r--r--storage/innobase/btr/btr0scrub.cc41
1 files changed, 31 insertions, 10 deletions
diff --git a/storage/innobase/btr/btr0scrub.cc b/storage/innobase/btr/btr0scrub.cc
index c30227ef085..4cb46dd415f 100644
--- a/storage/innobase/btr/btr0scrub.cc
+++ b/storage/innobase/btr/btr0scrub.cc
@@ -118,21 +118,33 @@ log_scrub_failure(
Lock dict mutexes */
static
bool
-btr_scrub_lock_dict_func(ulint space, bool lock_to_close_table,
+btr_scrub_lock_dict_func(ulint space_id, bool lock_to_close_table,
const char * file, uint line)
{
time_t start = time(0);
time_t last = start;
+ /* FIXME: this is not the proper way of doing things. The
+ dict_sys->mutex should not be held by any thread for longer
+ than a few microseconds. It must not be held during I/O,
+ for example. So, what is the purpose for this busy-waiting?
+ This function should be rewritten as part of MDEV-8139:
+ Fix scrubbing tests. */
+
while (mutex_enter_nowait(&(dict_sys->mutex))) {
/* if we lock to close a table, we wait forever
* if we don't lock to close a table, we check if space
* is closing, and then instead give up
*/
if (lock_to_close_table == false) {
- if (fil_crypt_is_closing(space)) {
+ fil_space_t* space = fil_space_acquire(space_id);
+ if (!space || space->stop_new_ops) {
+ if (space) {
+ fil_space_release(space);
+ }
return false;
}
+ fil_space_release(space);
}
os_thread_sleep(250000);
@@ -141,9 +153,10 @@ btr_scrub_lock_dict_func(ulint space, bool lock_to_close_table,
if (now >= last + 30) {
fprintf(stderr,
"WARNING: %s:%u waited %lu seconds for"
- " dict_sys lock, space: %lu"
+ " dict_sys lock, space: " ULINTPF
" lock_to_close_table: %u\n",
- file, line, (unsigned long)(now - start), space,
+ file, line, (unsigned long)(now - start),
+ space_id,
lock_to_close_table);
last = now;
@@ -189,16 +202,24 @@ void
btr_scrub_table_close_for_thread(
btr_scrub_t *scrub_data)
{
- if (scrub_data->current_table == NULL)
+ if (scrub_data->current_table == NULL) {
return;
+ }
- bool lock_for_close = true;
- btr_scrub_lock_dict(scrub_data->space, lock_for_close);
+ fil_space_t* space = fil_space_acquire(scrub_data->space);
- /* perform the actual closing */
- btr_scrub_table_close(scrub_data->current_table);
+ /* If tablespace is not marked as stopping perform
+ the actual close. */
+ if (space && !space->is_stopping()) {
+ mutex_enter(&dict_sys->mutex);
+ /* perform the actual closing */
+ btr_scrub_table_close(scrub_data->current_table);
+ mutex_exit(&dict_sys->mutex);
+ }
- btr_scrub_unlock_dict();
+ if (space) {
+ fil_space_release(space);
+ }
scrub_data->current_table = NULL;
scrub_data->current_index = NULL;