diff options
author | Eugene Kosov <claprix@yandex.ru> | 2021-03-16 16:09:41 +0300 |
---|---|---|
committer | Eugene Kosov <claprix@yandex.ru> | 2021-03-19 11:44:03 +0300 |
commit | 62e4aaa2407cc880618fb909c349c9c73174f84a (patch) | |
tree | 6fd57b0e99f07dd5d71b8540c417b0f40f9cec45 /storage | |
parent | 40fd42f7f50ce9c85a4b277b3060f865e6852fd5 (diff) | |
download | mariadb-git-62e4aaa2407cc880618fb909c349c9c73174f84a.tar.gz |
cleanup: os_thread_sleep() -> std::this_thread::sleep_for()
std version has an advantage of a more convenient units implementation from
std::chrono. Now it's no need to multipy/divide to bring anything to
micro seconds.
Diffstat (limited to 'storage')
27 files changed, 101 insertions, 112 deletions
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 416e8be746c..e452a05445e 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -310,8 +310,7 @@ void page_hash_latch::write_lock_wait() while (!write_lock_poll()); } -/** Value in microseconds */ -constexpr int WAIT_FOR_READ= 100; +constexpr std::chrono::microseconds WAIT_FOR_READ(100); constexpr int WAIT_FOR_WRITE= 100; /** Number of attempts made to read in a page in the buffer pool */ constexpr ulint BUF_PAGE_READ_MAX_RETRIES= 100; @@ -1810,7 +1809,8 @@ withdraw_retry: if (should_retry_withdraw) { ib::info() << "Will retry to withdraw " << retry_interval << " seconds later."; - os_thread_sleep(retry_interval * 1000000); + std::this_thread::sleep_for( + std::chrono::seconds(retry_interval)); if (retry_interval > 5) { retry_interval = 10; @@ -1831,7 +1831,9 @@ withdraw_retry: should_wait = false; DBUG_EXECUTE_IF( "ib_buf_pool_resize_wait_before_resize", - should_wait = true; os_thread_sleep(10000);); + should_wait = true; + std::this_thread::sleep_for( + std::chrono::milliseconds(10));); } } #endif /* !DBUG_OFF */ @@ -2375,7 +2377,7 @@ got_block: if (must_read) /* Let us wait until the read operation completes */ while (bpage->io_fix() == BUF_IO_READ) - os_thread_sleep(WAIT_FOR_READ); + std::this_thread::sleep_for(WAIT_FOR_READ); return bpage; } @@ -2763,7 +2765,8 @@ got_block: Avoid returning reference to this page. Instead wait for the flush action to complete. */ fix_block->unfix(); - os_thread_sleep(WAIT_FOR_WRITE); + std::this_thread::sleep_for( + std::chrono::microseconds(WAIT_FOR_WRITE)); goto loop; } @@ -2814,7 +2817,7 @@ evict_from_pool: /* The block is buffer-fixed or I/O-fixed. Try again later. */ - os_thread_sleep(WAIT_FOR_READ); + std::this_thread::sleep_for(WAIT_FOR_READ); goto loop; } diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc index 5244d3949a6..db7b0032ec7 100644 --- a/storage/innobase/buf/buf0dump.cc +++ b/storage/innobase/buf/buf0dump.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -472,7 +472,8 @@ buf_load_throttle_if_needed( ut_time_ms() that often may turn out to be too expensive. */ if (elapsed_time < 1000 /* 1 sec (1000 milli secs) */) { - os_thread_sleep((1000 - elapsed_time) * 1000 /* micro secs */); + std::this_thread::sleep_for( + std::chrono::milliseconds(1000 - elapsed_time)); } *last_check_time = ut_time_ms(); diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 7e02ed4ccf0..ee9a58b8d0e 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -2219,7 +2219,7 @@ do_checkpoint: #ifdef UNIV_DEBUG while (innodb_page_cleaner_disabled_debug && !buf_flush_sync_lsn && srv_shutdown_state == SRV_SHUTDOWN_NONE) - os_thread_sleep(100000); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); #endif /* UNIV_DEBUG */ #ifndef DBUG_OFF diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index a23d9a24aae..45379bccb8c 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2020, MariaDB Corporation. +Copyright (c) 2015, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -748,7 +748,8 @@ void buf_read_recv_pages(ulint space_id, const uint32_t* page_nos, ulint n) } for (ulint count = 0; buf_pool.n_pend_reads >= limit; ) { - os_thread_sleep(10000); + std::this_thread::sleep_for( + std::chrono::milliseconds(10)); if (!(++count % 1000)) { diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index f302bbd4ddd..b6528e5d26c 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2009, 2019, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2020, MariaDB Corporation. +Copyright (c) 2015, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -37,6 +37,7 @@ Created Jan 06, 2010 Vasil Dimov #include <algorithm> #include <map> #include <vector> +#include <thread> /* Sampling algorithm description @{ @@ -3775,7 +3776,8 @@ dict_stats_rename_table( if (ret != DB_SUCCESS) { dict_sys_unlock(); - os_thread_sleep(200000 /* 0.2 sec */); + std::this_thread::sleep_for( + std::chrono::milliseconds(200)); dict_sys_lock(); } } while ((ret == DB_DEADLOCK @@ -3828,7 +3830,8 @@ dict_stats_rename_table( if (ret != DB_SUCCESS) { dict_sys_unlock(); - os_thread_sleep(200000 /* 0.2 sec */); + std::this_thread::sleep_for( + std::chrono::milliseconds(200)); dict_sys_lock(); } } while ((ret == DB_DEADLOCK diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index 6bc799f8f2d..01b103a726f 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -2349,7 +2349,7 @@ fil_space_crypt_close_tablespace( pthread_cond_broadcast(&fil_crypt_threads_cond); mysql_mutex_unlock(&fil_crypt_threads_mutex); - os_thread_sleep(20000); + std::this_thread::sleep_for(std::chrono::milliseconds(20)); dict_sys.mutex_lock(); mysql_mutex_lock(&crypt_data->mutex); diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index dbc074767f1..7eb3abfbf21 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -435,7 +435,7 @@ static bool fil_node_open_file(fil_node_t *node) else { mysql_mutex_unlock(&fil_system.mutex); - os_thread_sleep(20000); + std::this_thread::sleep_for(std::chrono::milliseconds(20)); /* Flush tablespaces so that we can close modified files. */ fil_flush_file_spaces(); mysql_mutex_lock(&fil_system.mutex); @@ -557,7 +557,7 @@ fil_space_extend_must_retry( It'd have been better to use event driven mechanism but the entire module is peppered with polling stuff. */ mysql_mutex_unlock(&fil_system.mutex); - os_thread_sleep(100000); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); return(true); } @@ -731,7 +731,7 @@ inline pfs_os_file_t fil_node_t::close_to_free(bool detach_handle) { mysql_mutex_unlock(&fil_system.mutex); while (space->referenced()) - os_thread_sleep(100); + std::this_thread::sleep_for(std::chrono::microseconds(100)); mysql_mutex_lock(&fil_system.mutex); } @@ -826,7 +826,7 @@ fil_space_free_low( fil_system_t::detach(), the tablespace cannot be found, so fil_space_t::get() would return NULL */ while (space->referenced()) { - os_thread_sleep(100); + std::this_thread::sleep_for(std::chrono::microseconds(100)); } for (fil_node_t* node = UT_LIST_GET_FIRST(space->chain); @@ -1355,7 +1355,8 @@ next: goto next; } mysql_mutex_unlock(&fil_system.mutex); - os_thread_sleep(100); + std::this_thread::sleep_for( + std::chrono::microseconds(100)); mysql_mutex_lock(&fil_system.mutex); if (!node->is_open()) { goto next; @@ -1673,7 +1674,8 @@ fil_check_pending_operations( mysql_mutex_unlock(&fil_system.mutex); if (count) { - os_thread_sleep(20000); // Wait 0.02 seconds + std::this_thread::sleep_for( + std::chrono::milliseconds(20)); } else if (!sp) { return nullptr; } @@ -1704,7 +1706,7 @@ fil_check_pending_operations( break; } - os_thread_sleep(20000); // Wait 0.02 seconds + std::this_thread::sleep_for(std::chrono::milliseconds(20)); mysql_mutex_lock(&fil_system.mutex); sp = fil_space_get_by_id(id); diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index db45eeca6ed..1872e1481e5 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -85,7 +85,7 @@ static const ulint FTS_CACHE_SIZE_UPPER_LIMIT_IN_MB = 1024; #endif /** Time to sleep after DEADLOCK error before retrying operation. */ -static const ulint FTS_DEADLOCK_RETRY_WAIT = 100000; +static const std::chrono::milliseconds FTS_DEADLOCK_RETRY_WAIT(100); /** InnoDB default stopword list: There are different versions of stopwords, the stop words listed @@ -2684,7 +2684,7 @@ func_exit: fts_sql_rollback(trx); if (error == DB_DEADLOCK) { - os_thread_sleep(FTS_DEADLOCK_RETRY_WAIT); + std::this_thread::sleep_for(FTS_DEADLOCK_RETRY_WAIT); goto retry; } } @@ -3938,8 +3938,10 @@ fts_sync_write_words( word = rbt_value(fts_tokenizer_word_t, rbt_node); - DBUG_EXECUTE_IF("fts_instrument_write_words_before_select_index", - os_thread_sleep(300000);); + DBUG_EXECUTE_IF( + "fts_instrument_write_words_before_select_index", + std::this_thread::sleep_for( + std::chrono::milliseconds(300));); selected = fts_select_index( index_cache->charset, word->text.f_str, @@ -3975,9 +3977,10 @@ fts_sync_write_words( DBUG_EXECUTE_IF("fts_write_node_crash", DBUG_SUICIDE();); - DBUG_EXECUTE_IF("fts_instrument_sync_sleep", - os_thread_sleep(1000000); - ); + DBUG_EXECUTE_IF( + "fts_instrument_sync_sleep", + std::this_thread::sleep_for( + std::chrono::seconds(1));); if (unlock_cache) { mysql_mutex_lock( @@ -4279,7 +4282,8 @@ begin_sync: } DBUG_EXECUTE_IF("fts_instrument_sync_before_syncing", - os_thread_sleep(300000);); + std::this_thread::sleep_for( + std::chrono::milliseconds(300));); error = fts_sync_index(sync, index_cache); if (error != DB_SUCCESS) { diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc index e5164fcc4fa..b815d23394f 100644 --- a/storage/innobase/fts/fts0opt.cc +++ b/storage/innobase/fts/fts0opt.cc @@ -2583,7 +2583,7 @@ fts_optimize_remove_table( ib::info() << "Try to remove table " << table->name << " after FTS optimize thread exiting."; while (fts_optimize_wq) - os_thread_sleep(10000); + std::this_thread::sleep_for(std::chrono::milliseconds(10)); return; } @@ -2784,7 +2784,8 @@ static void fts_optimize_sync_table(dict_table_t *table, } } - DBUG_EXECUTE_IF("ib_optimize_wq_hang", os_thread_sleep(6000000);); + DBUG_EXECUTE_IF("ib_optimize_wq_hang", + std::this_thread::sleep_for(std::chrono::seconds(6));); if (mdl_ticket) dict_table_close(sync_table, false, false, fts_opt_thd, mdl_ticket); @@ -2870,7 +2871,9 @@ static void fts_optimize_callback(void *) case FTS_MSG_SYNC_TABLE: DBUG_EXECUTE_IF( "fts_instrument_msg_sync_sleep", - os_thread_sleep(300000);); + std::this_thread::sleep_for( + std::chrono::milliseconds( + 300));); fts_optimize_sync_table( static_cast<dict_table_t*>(msg->ptr), diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 4701929b42d..a1bcf74eea0 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -241,7 +241,7 @@ static void innodb_max_purge_lag_wait_update(THD *thd, st_mysql_sys_var *, if (thd_kill_level(thd)) break; srv_wake_purge_thread_if_not_active(); - os_thread_sleep(100000); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } mysql_mutex_lock(&LOCK_global_system_variables); } @@ -17445,7 +17445,8 @@ innodb_buffer_pool_evict_update(THD*, st_mysql_sys_var*, void*, return; } - os_thread_sleep(10000); + std::this_thread::sleep_for( + std::chrono::milliseconds(10)); } /* We failed to evict all uncompressed pages. */ diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h index f64c2771204..966cb73cdbf 100644 --- a/storage/innobase/include/btr0cur.h +++ b/storage/innobase/include/btr0cur.h @@ -934,9 +934,9 @@ is still a good change of success a little later. Try this many times. */ #define BTR_CUR_RETRY_DELETE_N_TIMES 100 /** If pessimistic delete fails because of lack of file space, there -is still a good change of success a little later. Sleep this many -microseconds between retries. */ -#define BTR_CUR_RETRY_SLEEP_TIME 50000 +is still a good change of success a little later. Sleep this time +between retries. */ +static const std::chrono::milliseconds BTR_CUR_RETRY_SLEEP_TIME(50); /** The reference in a field for which data is stored on a different page. The reference is at the end of the 'locally' stored part of the field. diff --git a/storage/innobase/include/dict0stats_bg.h b/storage/innobase/include/dict0stats_bg.h index 5abbdf7fd25..e9318a0116d 100644 --- a/storage/innobase/include/dict0stats_bg.h +++ b/storage/innobase/include/dict0stats_bg.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -52,7 +52,7 @@ for the background thread to stop accessing a table. @param trx transaction holding the data dictionary locks */ #define DICT_BG_YIELD(trx) do { \ row_mysql_unlock_data_dictionary(trx); \ - os_thread_sleep(250000); \ + std::this_thread::sleep_for(std::chrono::milliseconds(250)); \ row_mysql_lock_data_dictionary(trx); \ } while (0) diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h index bc75b5b6796..b3cfb2a1914 100644 --- a/storage/innobase/include/log0recv.h +++ b/storage/innobase/include/log0recv.h @@ -32,6 +32,7 @@ Created 9/20/1997 Heikki Tuuri #include "mtr0types.h" #include <deque> +#include <map> /** @return whether recovery is currently running. */ #define recv_recovery_is_on() UNIV_UNLIKELY(recv_sys.recovery_on) diff --git a/storage/innobase/include/os0thread.h b/storage/innobase/include/os0thread.h index f9eb4b15745..3eca521937d 100644 --- a/storage/innobase/include/os0thread.h +++ b/storage/innobase/include/os0thread.h @@ -74,10 +74,3 @@ os_thread_t os_thread_create(os_thread_func_t func, void *arg= nullptr); /** Detach and terminate the current thread. */ ATTRIBUTE_NORETURN void os_thread_exit(); - -#ifdef _WIN32 -# define os_thread_sleep(usec) Sleep((DWORD) usec / 1000) -#else -/** Sleep for some time */ -void os_thread_sleep(ulint usec); -#endif diff --git a/storage/innobase/include/ut0new.h b/storage/innobase/include/ut0new.h index 47198dbff99..78ceb2cccfe 100644 --- a/storage/innobase/include/ut0new.h +++ b/storage/innobase/include/ut0new.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2014, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -120,9 +120,8 @@ InnoDB: #ifndef ut0new_h #define ut0new_h -#include <algorithm> /* std::min() */ #include <limits> /* std::numeric_limits */ -#include <map> /* std::map */ +#include <thread> #include <stddef.h> #include <stdlib.h> /* malloc() */ @@ -136,7 +135,6 @@ InnoDB: #include "mysql/psi/psi_memory.h" /* PSI_memory_key, PSI_memory_info */ -#include "os0thread.h" /* os_thread_sleep() */ #include "ut0ut.h" /* ut_strcmp_functor, ut_basename_noext() */ #define OUT_OF_MEMORY_MSG \ @@ -381,7 +379,7 @@ public: break; } - os_thread_sleep(1000000 /* 1 second */); + std::this_thread::sleep_for(std::chrono::seconds(1)); } if (ptr == NULL) { @@ -516,7 +514,7 @@ public: break; } - os_thread_sleep(1000000 /* 1 second */); + std::this_thread::sleep_for(std::chrono::seconds(1)); } if (pfx_new == NULL) { diff --git a/storage/innobase/include/ut0pool.h b/storage/innobase/include/ut0pool.h index e0a1f7c04ca..41b02e0a985 100644 --- a/storage/innobase/include/ut0pool.h +++ b/storage/innobase/include/ut0pool.h @@ -254,7 +254,8 @@ struct PoolManager { except crash and burn, however lets be a little optimistic and wait for a resource to be freed. */ - os_thread_sleep(delay * 1000000); + std::this_thread::sleep_for( + std::chrono::seconds(delay)); if (delay < 32) { delay <<= 1; diff --git a/storage/innobase/innodb.cmake b/storage/innobase/innodb.cmake index 7461da4c575..626de751294 100644 --- a/storage/innobase/innodb.cmake +++ b/storage/innobase/innodb.cmake @@ -108,11 +108,6 @@ IF(HAVE_SCHED_GETCPU) ADD_DEFINITIONS(-DHAVE_SCHED_GETCPU=1) ENDIF() -CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP) -IF(HAVE_NANOSLEEP) - ADD_DEFINITIONS(-DHAVE_NANOSLEEP=1) -ENDIF() - IF(HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE) ADD_DEFINITIONS(-DHAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE=1) ENDIF() diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index ff81f9099df..f5da279f676 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -963,7 +963,8 @@ func_exit: /* We must wait to prevent the tail of the log overwriting the head. */ buf_flush_wait_flushed(std::min(sync_lsn, checkpoint + (1U << 20))); - os_thread_sleep(10000); /* Sleep 10ms to avoid a thundering herd */ + /* Sleep to avoid a thundering herd */ + std::this_thread::sleep_for(std::chrono::milliseconds(10)); } } @@ -1027,7 +1028,7 @@ loop: #define COUNT_INTERVAL 600U #define CHECK_INTERVAL 100000U - os_thread_sleep(CHECK_INTERVAL); + std::this_thread::sleep_for(std::chrono::microseconds(CHECK_INTERVAL)); count++; diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 60f3c0db760..8f05d227d9d 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -1438,7 +1438,8 @@ os_file_create_func( << "Retrying to lock the first data file"; for (int i = 0; i < 100; i++) { - os_thread_sleep(1000000); + std::this_thread::sleep_for( + std::chrono::seconds(1)); if (!os_file_lock(file, name)) { *success = true; @@ -2747,8 +2748,7 @@ os_file_delete_if_exists_func( ib::warn() << "Delete of file '" << name << "' failed."; } - /* Sleep for a second */ - os_thread_sleep(1000000); + std::this_thread::sleep_for(std::chrono::seconds(1)); if (count > 2000) { @@ -2796,8 +2796,7 @@ os_file_delete_func( << "another program accessing it?"; } - /* sleep for a second */ - os_thread_sleep(1000000); + std::this_thread::sleep_for(std::chrono::seconds(1)); if (count > 2000) { @@ -3435,13 +3434,13 @@ os_file_handle_error_cond_exit( case OS_FILE_SHARING_VIOLATION: - os_thread_sleep(10000000); /* 10 sec */ + std::this_thread::sleep_for(std::chrono::seconds(10)); return(true); case OS_FILE_OPERATION_ABORTED: case OS_FILE_INSUFFICIENT_RESOURCE: - os_thread_sleep(100000); /* 100 ms */ + std::this_thread::sleep_for(std::chrono::milliseconds(100)); return(true); default: diff --git a/storage/innobase/os/os0thread.cc b/storage/innobase/os/os0thread.cc index cca488dd9d8..cb627a6392d 100644 --- a/storage/innobase/os/os0thread.cc +++ b/storage/innobase/os/os0thread.cc @@ -97,25 +97,3 @@ ATTRIBUTE_NORETURN void os_thread_exit() pthread_exit(NULL); #endif } - -#ifndef _WIN32 -/** Sleep for some time */ -void os_thread_sleep(ulint tm) -{ -# ifdef HAVE_NANOSLEEP - struct timespec t; - - t.tv_sec = tm / 1000000; - t.tv_nsec = (tm % 1000000) * 1000; - - ::nanosleep(&t, NULL); -# else - struct timeval t; - - t.tv_sec = tm / 1000000; - t.tv_usec = tm % 1000000; - - select(0, NULL, NULL, NULL, &t); -# endif -} -#endif /* !_WIN32 */ diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index d74adadedc6..40295a7416e 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -674,7 +674,8 @@ row_merge_buf_add( while (psort_info[bucket].memory_used > FTS_PENDING_DOC_MEMORY_LIMIT && trial_count++ < max_trial_count) { - os_thread_sleep(1000); + std::this_thread::sleep_for( + std::chrono::milliseconds(1)); } n_row_added = 1; @@ -4629,9 +4630,9 @@ row_merge_build_indexes( buf, i + 1, n_indexes); } - DBUG_EXECUTE_IF( - "ib_merge_wait_after_sort", - os_thread_sleep(20000000);); /* 20 sec */ + DBUG_EXECUTE_IF("ib_merge_wait_after_sort", + std::this_thread::sleep_for( + std::chrono::seconds(20));); if (error == DB_SUCCESS) { BtrBulk btr_bulk(sort_idx, trx); diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index d7e3e37ad9e..8e9f30815a9 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -65,8 +65,8 @@ Created 9/17/2000 Heikki Tuuri #include "srv0start.h" #include <algorithm> -#include <deque> #include <vector> +#include <thread> #ifdef WITH_WSREP #include "mysql/service_wsrep.h" @@ -127,7 +127,7 @@ row_wait_for_background_drop_list_empty() mysql_mutex_lock(&row_drop_list_mutex); empty = (UT_LIST_GET_LEN(row_mysql_drop_list) == 0); mysql_mutex_unlock(&row_drop_list_mutex); - os_thread_sleep(100000); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } } #endif /* UNIV_DEBUG */ @@ -140,7 +140,8 @@ row_mysql_delay_if_needed(void) /*===========================*/ { if (srv_dml_needed_delay) { - os_thread_sleep(srv_dml_needed_delay); + std::this_thread::sleep_for( + std::chrono::microseconds(srv_dml_needed_delay)); } } @@ -3946,7 +3947,8 @@ loop: if (!dict_stats_stop_bg(table)) { row_mysql_unlock_data_dictionary(trx); - os_thread_sleep(250000); + std::this_thread::sleep_for( + std::chrono::milliseconds(250)); ut_free(table_name); @@ -3964,7 +3966,7 @@ loop: " there are still open handles to table " << table->name << "."; - os_thread_sleep(1000000); + std::this_thread::sleep_for(std::chrono::seconds(1)); ut_free(table_name); diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc index 0ddd4b059d1..3b8af6ecd53 100644 --- a/storage/innobase/row/row0purge.cc +++ b/storage/innobase/row/row0purge.cc @@ -25,6 +25,7 @@ Created 3/14/1997 Heikki Tuuri *******************************************************/ #include "row0purge.h" +#include "btr0cur.h" #include "fsp0fsp.h" #include "mach0data.h" #include "dict0stats.h" @@ -194,7 +195,7 @@ row_purge_remove_clust_if_poss( return(true); } - os_thread_sleep(BTR_CUR_RETRY_SLEEP_TIME); + std::this_thread::sleep_for(BTR_CUR_RETRY_SLEEP_TIME); } return(false); @@ -576,7 +577,7 @@ retry: n_tries++; - os_thread_sleep(BTR_CUR_RETRY_SLEEP_TIME); + std::this_thread::sleep_for(BTR_CUR_RETRY_SLEEP_TIME); goto retry; } @@ -955,7 +956,7 @@ already_locked: if (srv_shutdown_state > SRV_SHUTDOWN_INITIATED) { return(false); } - os_thread_sleep(1000000); + std::this_thread::sleep_for(std::chrono::seconds(1)); goto try_again; } } @@ -1116,7 +1117,7 @@ row_purge( } /* Retry the purge in a second. */ - os_thread_sleep(1000000); + std::this_thread::sleep_for(std::chrono::seconds(1)); } } } diff --git a/storage/innobase/row/row0quiesce.cc b/storage/innobase/row/row0quiesce.cc index 54e5ca3c134..e14e8846ee4 100644 --- a/storage/innobase/row/row0quiesce.cc +++ b/storage/innobase/row/row0quiesce.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -587,8 +587,7 @@ row_quiesce_table_complete( << " to complete"; } - /* Sleep for a second. */ - os_thread_sleep(1000000); + std::this_thread::sleep_for(std::chrono::seconds(1)); ++count; } diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc index 88db631676f..0818a35c480 100644 --- a/storage/innobase/row/row0uins.cc +++ b/storage/innobase/row/row0uins.cc @@ -198,7 +198,7 @@ retry: n_tries++; - os_thread_sleep(BTR_CUR_RETRY_SLEEP_TIME); + std::this_thread::sleep_for(BTR_CUR_RETRY_SLEEP_TIME); goto retry; } @@ -334,7 +334,7 @@ retry: n_tries++; - os_thread_sleep(BTR_CUR_RETRY_SLEEP_TIME); + std::this_thread::sleep_for(BTR_CUR_RETRY_SLEEP_TIME); goto retry; } diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 21bfe81f9a8..91e41390b3b 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -2069,7 +2069,8 @@ void srv_purge_shutdown() while(!srv_purge_should_exit()) { ut_a(!purge_sys.paused()); srv_wake_purge_thread_if_not_active(); - os_thread_sleep(1000); + std::this_thread::sleep_for( + std::chrono::milliseconds(1)); } purge_sys.coordinator_shutdown(); srv_shutdown_purge_tasks(); diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 120fb4f3ac8..fe6225e9ccb 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -967,7 +967,8 @@ static lsn_t srv_prepare_to_delete_redo_log_file(bool old_exists) count = 0; } - os_thread_sleep(100000); + std::this_thread::sleep_for( + std::chrono::milliseconds(100)); continue; } @@ -1953,7 +1954,7 @@ void innodb_preshutdown() if (trx_sys.is_initialised()) while (trx_sys.any_active_transactions()) - os_thread_sleep(1000); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } srv_shutdown_bg_undo_sources(); srv_purge_shutdown(); |