Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mysql-test/suite/innodb/r/log_file.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/innodb/t/log_file.test
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
14 changes: 9 additions & 5 deletions storage/innobase/buf/buf0buf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
15 changes: 10 additions & 5 deletions storage/innobase/buf/buf0dump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
8 changes: 5 additions & 3 deletions storage/innobase/data/data0data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/fsp/fsp0file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,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(
Expand Down
8 changes: 4 additions & 4 deletions storage/innobase/fsp/fsp0sysspace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -396,17 +396,17 @@ 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,
static_cast<os_offset_t>(file.m_size) << srv_page_size_shift);

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";
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/fts/fts0fts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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};
}
}

Expand Down
10 changes: 10 additions & 0 deletions storage/innobase/include/ut0ut.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Comment thread
grooverdan marked this conversation as resolved.

/** 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
Expand Down
22 changes: 12 additions & 10 deletions storage/innobase/srv/srv0start.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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...";
Expand Down Expand Up @@ -922,16 +923,17 @@ 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: ";
} else {
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);
Expand Down Expand Up @@ -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";
Expand All @@ -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 */
Expand Down
12 changes: 12 additions & 0 deletions storage/innobase/ut/ut0ut.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down