diff options
-rw-r--r-- | mysql-test/suite/innodb/r/log_file.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/log_file.test | 2 | ||||
-rw-r--r-- | storage/innobase/buf/buf0buf.cc | 14 | ||||
-rw-r--r-- | storage/innobase/buf/buf0dump.cc | 15 | ||||
-rw-r--r-- | storage/innobase/data/data0data.cc | 8 | ||||
-rw-r--r-- | storage/innobase/fsp/fsp0file.cc | 2 | ||||
-rw-r--r-- | storage/innobase/fsp/fsp0sysspace.cc | 8 | ||||
-rw-r--r-- | storage/innobase/fts/fts0fts.cc | 2 | ||||
-rw-r--r-- | storage/innobase/include/ut0ut.h | 10 | ||||
-rw-r--r-- | storage/innobase/srv/srv0start.cc | 22 | ||||
-rw-r--r-- | storage/innobase/ut/ut0ut.cc | 12 |
11 files changed, 66 insertions, 31 deletions
diff --git a/mysql-test/suite/innodb/r/log_file.result b/mysql-test/suite/innodb/r/log_file.result index 10479e5004a..ae60174de7b 100644 --- a/mysql-test/suite/innodb/r/log_file.result +++ b/mysql-test/suite/innodb/r/log_file.result @@ -290,7 +290,7 @@ WHERE engine='innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); 1 1 -NOT FOUND /Resizing redo log from 1\*\d+ to 3\*\d+ bytes; LSN=\d+/ in mysqld.1.err +NOT FOUND /Resizing redo log from 1\*\d+ to 3\*\d+[KMGT]iB; LSN=\d+/ in mysqld.1.err # restart # Cleanup bak_ib_logfile0 diff --git a/mysql-test/suite/innodb/t/log_file.test b/mysql-test/suite/innodb/t/log_file.test index f03bce804f6..366bcd82f61 100644 --- a/mysql-test/suite/innodb/t/log_file.test +++ b/mysql-test/suite/innodb/t/log_file.test @@ -211,7 +211,7 @@ eval $check_no_innodb; --source include/start_mysqld.inc eval $check_yes_innodb; --source include/shutdown_mysqld.inc ---let SEARCH_PATTERN=Resizing redo log from 1\*\d+ to 3\*\d+ bytes; LSN=\d+ +--let SEARCH_PATTERN=Resizing redo log from 1\*\d+ to 3\*\d+[KMGT]iB; LSN=\d+ --source include/search_pattern_in_file.inc --let $restart_parameters= diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index c31d9aef8eb..6090d869bac 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -1638,11 +1638,15 @@ inline void buf_pool_t::resize() ut_ad(srv_buf_pool_chunk_unit > 0); ulint new_instance_size = srv_buf_pool_size >> srv_page_size_shift; - - buf_resize_status("Resizing buffer pool from " ULINTPF " to " - ULINTPF " (unit=" ULINTPF ").", - srv_buf_pool_old_size, srv_buf_pool_size, - srv_buf_pool_chunk_unit); + std::ostringstream str_old_size, str_new_size, str_chunk_size; + str_old_size << ib::bytes_iec{srv_buf_pool_old_size}; + str_new_size << ib::bytes_iec{srv_buf_pool_size}; + str_chunk_size << ib::bytes_iec{srv_buf_pool_chunk_unit}; + + buf_resize_status("Resizing buffer pool from %s to %s (unit=%s).", + str_old_size.str().c_str(), + str_new_size.str().c_str(), + str_chunk_size.str().c_str()); #ifdef BTR_CUR_HASH_ADAPT /* disable AHI if needed */ diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc index bc39e6bfaec..b4b3dd75f30 100644 --- a/storage/innobase/buf/buf0dump.cc +++ b/storage/innobase/buf/buf0dump.cc @@ -315,11 +315,13 @@ buf_dump( n_pages * sizeof(*dump))); if (dump == NULL) { + std::ostringstream str_bytes; mysql_mutex_unlock(&buf_pool.mutex); fclose(f); + str_bytes << ib::bytes_iec{n_pages * sizeof(*dump)}; buf_dump_status(STATUS_ERR, - "Cannot allocate " ULINTPF " bytes: %s", - (ulint) (n_pages * sizeof(*dump)), + "Cannot allocate %s: %s", + str_bytes.str().c_str(), strerror(errno)); /* leave tmp_filename to exist */ return; @@ -561,11 +563,14 @@ buf_load() } if (dump == NULL) { + std::ostringstream str_bytes; fclose(f); - buf_load_status(STATUS_ERR, - "Cannot allocate " ULINTPF " bytes: %s", - dump_n * sizeof(*dump), + str_bytes << ib::bytes_iec{dump_n * sizeof(*dump)}; + buf_dump_status(STATUS_ERR, + "Cannot allocate %s: %s", + str_bytes.str().c_str(), strerror(errno)); + /* leave tmp_filename to exist */ return; } diff --git a/storage/innobase/data/data0data.cc b/storage/innobase/data/data0data.cc index 14a0b3e19fd..13efd7f3665 100644 --- a/storage/innobase/data/data0data.cc +++ b/storage/innobase/data/data0data.cc @@ -466,8 +466,10 @@ dfield_print_raw( ulint print_len = ut_min(len, static_cast<ulint>(1000)); ut_print_buf(f, dfield_get_data(dfield), print_len); if (len != print_len) { - fprintf(f, "(total %lu bytes%s)", - (ulong) len, + std::ostringstream str_bytes; + str_bytes << ib::bytes_iec{len}; + fprintf(f, "(total %s%s)", + str_bytes.str().c_str(), dfield_is_ext(dfield) ? ", external" : ""); } } else { @@ -600,7 +602,7 @@ dtuple_convert_big_rec( size = rec_get_converted_size(index, entry, *n_ext); if (UNIV_UNLIKELY(size > 1000000000)) { - ib::warn() << "Tuple size is very big: " << size; + ib::warn() << "Tuple size is very big: " << ib::bytes_iec{size}; fputs("InnoDB: Tuple contents: ", stderr); dtuple_print(stderr, entry); putc('\n', stderr); diff --git a/storage/innobase/fsp/fsp0file.cc b/storage/innobase/fsp/fsp0file.cc index 95eb9007944..030e030d474 100644 --- a/storage/innobase/fsp/fsp0file.cc +++ b/storage/innobase/fsp/fsp0file.cc @@ -794,7 +794,7 @@ Datafile::restore_from_doublewrite() ib::info() << "Restoring page " << page_id << " of datafile '" << m_filepath << "' from the doublewrite buffer. Writing " - << physical_size << " bytes into file '" + << ib::bytes_iec{physical_size} << " into file '" << m_filepath << "'"; return(os_file_write( diff --git a/storage/innobase/fsp/fsp0sysspace.cc b/storage/innobase/fsp/fsp0sysspace.cc index 56ef4959690..4c3507538c7 100644 --- a/storage/innobase/fsp/fsp0sysspace.cc +++ b/storage/innobase/fsp/fsp0sysspace.cc @@ -396,8 +396,8 @@ SysTablespace::set_size( /* We created the data file and now write it full of zeros */ ib::info() << "Setting file '" << file.filepath() << "' size to " - << (file.m_size >> (20U - srv_page_size_shift)) << " MB." - " Physically writing the file full; Please wait ..."; + << ib::bytes_iec{file.m_size << srv_page_size_shift} << + ". Physically writing the file full; Please wait ..."; bool success = os_file_set_size( file.m_filepath, file.m_handle, @@ -405,8 +405,8 @@ SysTablespace::set_size( if (success) { ib::info() << "File '" << file.filepath() << "' size is now " - << (file.m_size >> (20U - srv_page_size_shift)) - << " MB."; + << ib::bytes_iec{file.m_size << srv_page_size_shift} + << "."; } else { ib::error() << "Could not set the file size of '" << file.filepath() << "'. Probably out of disk space"; diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 2a3a780228d..42beefeb4d5 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -3942,7 +3942,7 @@ fts_sync_begin( ib::info() << "FTS SYNC for table " << sync->table->name << ", deleted count: " << ib_vector_size(cache->deleted_doc_ids) - << " size: " << cache->total_size << " bytes"; + << " size: " << ib::bytes_iec{cache->total_size}; } } diff --git a/storage/innobase/include/ut0ut.h b/storage/innobase/include/ut0ut.h index 69abd932375..166d8132a3e 100644 --- a/storage/innobase/include/ut0ut.h +++ b/storage/innobase/include/ut0ut.h @@ -305,6 +305,16 @@ operator<<( return(lhs); } +/** This is a wrapper class, used to print any number in IEC style */ +struct bytes_iec { + explicit bytes_iec(unsigned long long t): m_val(t) {} + double get_double() const { return static_cast<double>(m_val); } + const unsigned long long m_val; +}; + +/** Like hex operator above, except for bytes_iec */ +std::ostream &operator<<(std::ostream &lhs, const bytes_iec &rhs); + /** The class logger is the base class of all the error log related classes. It contains a std::ostringstream object. The main purpose of this class is to forward operator<< to the underlying std::ostringstream object. Do not diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 52eee800dae..58cdfda9574 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -269,13 +269,13 @@ static dberr_t create_log_file(bool create_new_db, lsn_t lsn, } ib::info() << "Setting log file " << logfile0 << " size to " - << srv_log_file_size << " bytes"; + << ib::bytes_iec{srv_log_file_size}; ret = os_file_set_size(logfile0.c_str(), file, srv_log_file_size); if (!ret) { os_file_close(file); ib::error() << "Cannot set log file " << logfile0 - << " size to " << srv_log_file_size << " bytes"; + << " size to " << ib::bytes_iec{srv_log_file_size}; return DB_ERROR; } @@ -406,7 +406,8 @@ static dberr_t srv_undo_tablespace_create(const char* name) " be created"; ib::info() << "Setting file " << name << " size to " - << (SRV_UNDO_TABLESPACE_SIZE_IN_PAGES >> (20 - srv_page_size_shift)) << " MB"; + << ib::bytes_iec{SRV_UNDO_TABLESPACE_SIZE_IN_PAGES + << srv_page_size_shift}; ib::info() << "Database physically writes the file full: " << "wait..."; @@ -922,7 +923,8 @@ static lsn_t srv_prepare_to_delete_redo_log_file(bool old_exists) " and resizing"; } - info << " redo log from " << srv_log_file_size + info << " redo log from " + << ib::bytes_iec{srv_log_file_size} << " to "; } else if (srv_encrypt_log) { info << "Encrypting redo log: "; @@ -930,8 +932,8 @@ static lsn_t srv_prepare_to_delete_redo_log_file(bool old_exists) info << "Removing redo log encryption: "; } - info << srv_log_file_size_requested - << " bytes; LSN=" << flushed_lsn; + info << ib::bytes_iec{srv_log_file_size_requested} + << "; LSN=" << flushed_lsn; } mysql_mutex_unlock(&log_sys.mutex); @@ -1207,8 +1209,8 @@ dberr_t srv_start(bool create_new_db) fil_system.create(srv_file_per_table ? 50000 : 5000); ib::info() << "Initializing buffer pool, total size = " - << srv_buf_pool_size - << ", chunk size = " << srv_buf_pool_chunk_unit; + << ib::bytes_iec{srv_buf_pool_size} + << ", chunk size = " << ib::bytes_iec{srv_buf_pool_chunk_unit}; if (buf_pool.create()) { ib::error() << "Cannot allocate memory for the buffer pool"; @@ -1225,8 +1227,8 @@ dberr_t srv_start(bool create_new_db) if (srv_buf_pool_size <= 5 * 1024 * 1024) { ib::info() << "Small buffer pool size (" - << srv_buf_pool_size / 1024 / 1024 - << "M), the flst_validate() debug function can cause a" + << ib::bytes_iec{srv_buf_pool_size} + << "), the flst_validate() debug function can cause a" << " deadlock if the buffer pool fills up."; } #endif /* UNIV_DEBUG */ diff --git a/storage/innobase/ut/ut0ut.cc b/storage/innobase/ut/ut0ut.cc index d127f2138c9..cc128a494ea 100644 --- a/storage/innobase/ut/ut0ut.cc +++ b/storage/innobase/ut/ut0ut.cc @@ -478,6 +478,18 @@ ut_strerr( namespace ib { +std::ostream &operator<<(std::ostream &lhs, const bytes_iec &rhs) +{ + static const char *sizes[]= {"B", "KiB", "MiB", "GiB", "TiB", "PiB", + "EiB", "ZiB", "YiB"}; + size_t i= 0; + double d= rhs.get_double(); + for (; d > 512.0 && i < array_elements(sizes); i++, d/= 1024.0); + lhs.precision(3); + lhs << std::fixed << d << sizes[i]; + return lhs; +} + ATTRIBUTE_COLD logger& logger::operator<<(dberr_t err) { m_oss << ut_strerr(err); |