revision-id: 45070647927a4ec4451a9833091ee21e2818a032 parent(s): 66c14d3a8d31e877ede75d23f96dc61a4aa12971 committer: Sergei Petrunia branch nick: 10.2-r4 timestamp: 2018-04-19 14:11:53 +0300 message: MyRocks: MDEV-15911: Reduce debug logging on default levels in error log MyRocks internally will print non-critical messages to sql_print_verbose_info() which will do what InnoDB does in similar cases: check if (global_system_variables.log_warnings > 2). --- sql/log.cc | 12 ++++++++---- sql/log.h | 1 + storage/rocksdb/ha_rocksdb.cc | 34 +++++++++++++++++++++++----------- storage/rocksdb/ha_rocksdb.h | 4 ++++ storage/rocksdb/rdb_datadic.cc | 8 ++++---- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index f1a0834..7241aa6 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -8747,16 +8747,20 @@ void sql_print_information(const char *format, ...) va_list args; DBUG_ENTER("sql_print_information"); - if (disable_log_notes) - DBUG_VOID_RETURN; // Skip notes during start/shutdown - va_start(args, format); - error_log_print(INFORMATION_LEVEL, format, args); + sql_print_information_v(format, args); va_end(args); DBUG_VOID_RETURN; } +void sql_print_information_v(const char *format, va_list ap) +{ + if (disable_log_notes) + return; // Skip notes during start/shutdown + + error_log_print(INFORMATION_LEVEL, format, ap); +} void TC_LOG::run_prepare_ordered(THD *thd, bool all) diff --git a/sql/log.h b/sql/log.h index c09ae14..2a3912a 100644 --- a/sql/log.h +++ b/sql/log.h @@ -1075,6 +1075,7 @@ int vprint_msg_to_log(enum loglevel level, const char *format, va_list args); void sql_print_error(const char *format, ...); void sql_print_warning(const char *format, ...); void sql_print_information(const char *format, ...); +void sql_print_information_v(const char *format, va_list ap); typedef void (*sql_print_message_func)(const char *format, ...); extern sql_print_message_func sql_print_message_handlers[]; diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 18d5c6e..03086db 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -220,8 +220,8 @@ static int rocksdb_compact_column_family(THD *const thd, if (const char *const cf = value->val_str(value, buff, &len)) { auto cfh = cf_manager.get_cf(cf); if (cfh != nullptr && rdb != nullptr) { - sql_print_information("RocksDB: Manual compaction of column family: %s\n", - cf); + sql_print_verbose_info("RocksDB: Manual compaction of column family: %s\n", + cf); rdb->CompactRange(getCompactRangeOptions(), cfh, nullptr, nullptr); } } @@ -7776,8 +7776,8 @@ int ha_rocksdb::check(THD *const thd, HA_CHECK_OPT *const check_opt) { /* For each secondary index, check that we can get a PK value from it */ // NO_LINT_DEBUG - sql_print_information("CHECKTABLE %s: Checking table %s", table_name, - table_name); + sql_print_verbose_info("CHECKTABLE %s: Checking table %s", table_name, + table_name); ha_rows UNINIT_VAR(row_checksums_at_start); // set/used iff first_index==true ha_rows row_checksums = ha_rows(-1); bool first_index = true; @@ -7792,8 +7792,8 @@ int ha_rocksdb::check(THD *const thd, HA_CHECK_OPT *const check_opt) { row_checksums_at_start = m_row_checksums_checked; int res; // NO_LINT_DEBUG - sql_print_information("CHECKTABLE %s: Checking index %s", table_name, - table->key_info[keyno].name); + sql_print_verbose_info("CHECKTABLE %s: Checking index %s", table_name, + table->key_info[keyno].name); while (1) { if (!rows) res = index_first(table->record[0]); @@ -7881,9 +7881,9 @@ int ha_rocksdb::check(THD *const thd, HA_CHECK_OPT *const check_opt) { } } // NO_LINT_DEBUG - sql_print_information("CHECKTABLE %s: ... %lld index entries checked " - "(%lld had checksums)", - table_name, rows, checksums); + sql_print_verbose_info("CHECKTABLE %s: ... %lld index entries checked " + "(%lld had checksums)", + table_name, rows, checksums); if (first_index) { row_checksums = m_row_checksums_checked - row_checksums_at_start; @@ -7894,8 +7894,8 @@ int ha_rocksdb::check(THD *const thd, HA_CHECK_OPT *const check_opt) { } if (row_checksums != ha_rows(-1)) { // NO_LINT_DEBUG - sql_print_information("CHECKTABLE %s: %lld table records had checksums", - table_name, row_checksums); + sql_print_verbose_info("CHECKTABLE %s: %lld table records had checksums", + table_name, row_checksums); } extra(HA_EXTRA_NO_KEYREAD); @@ -12655,8 +12655,20 @@ double ha_rocksdb::read_time(uint index, uint ranges, ha_rows rows) { DBUG_RETURN((rows / 20.0) + 1); } +void sql_print_verbose_info(const char *format, ...) +{ + va_list args; + + if (global_system_variables.log_warnings > 2) { + va_start(args, format); + sql_print_information_v(format, args); + va_end(args); + } +} + } // namespace myrocks + /** Construct and emit duplicate key error message using information from table's record buffer. diff --git a/storage/rocksdb/ha_rocksdb.h b/storage/rocksdb/ha_rocksdb.h index 31adef8..d929ca1 100644 --- a/storage/rocksdb/ha_rocksdb.h +++ b/storage/rocksdb/ha_rocksdb.h @@ -1415,4 +1415,8 @@ struct Rdb_inplace_alter_ctx : public my_core::inplace_alter_handler_ctx { const int MYROCKS_MARIADB_PLUGIN_MATURITY_LEVEL= MariaDB_PLUGIN_MATURITY_GAMMA; extern bool prevent_myrocks_loading; + +void sql_print_verbose_info(const char *format, ...); + } // namespace myrocks + diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc index 68ad8e0..01dc2d6 100644 --- a/storage/rocksdb/rdb_datadic.cc +++ b/storage/rocksdb/rdb_datadic.cc @@ -4906,8 +4906,8 @@ void Rdb_dict_manager::add_create_index( rocksdb::WriteBatch *const batch) const { for (const auto &gl_index_id : gl_index_ids) { // NO_LINT_DEBUG - sql_print_information("RocksDB: Begin index creation (%u,%u)", - gl_index_id.cf_id, gl_index_id.index_id); + sql_print_verbose_info("RocksDB: Begin index creation (%u,%u)", + gl_index_id.cf_id, gl_index_id.index_id); start_create_index(batch, gl_index_id); } } @@ -4986,8 +4986,8 @@ void Rdb_dict_manager::rollback_ongoing_index_creation() const { for (const auto &gl_index_id : gl_index_ids) { // NO_LINT_DEBUG - sql_print_information("RocksDB: Removing incomplete create index (%u,%u)", - gl_index_id.cf_id, gl_index_id.index_id); + sql_print_verbose_info("RocksDB: Removing incomplete create index (%u,%u)", + gl_index_id.cf_id, gl_index_id.index_id); start_drop_index(batch, gl_index_id); }