Skip to content

Commit

Permalink
Fix logging
Browse files Browse the repository at this point in the history
  • Loading branch information
JaySon-Huang committed Nov 9, 2023
1 parent dbde257 commit 4178513
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
6 changes: 3 additions & 3 deletions dbms/src/TiDB/Schema/SchemaBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ void SchemaBuilder<Getter, NameMapper>::applyDropSchema(const String & db_name)
auto db = context.tryGetDatabase(db_name);
if (db == nullptr)
{
LOG_INFO(log, "Database {} does not exists", db_name);
LOG_INFO(log, "Database does not exist, db_name={}", db_name);
return;
}

Expand Down Expand Up @@ -1046,7 +1046,7 @@ void SchemaBuilder<Getter, NameMapper>::applyDropPhysicalTable(const String & db
auto storage = tmt_context.getStorages().get(keyspace_id, table_id);
if (storage == nullptr)
{
LOG_DEBUG(log, "table {} does not exist.", table_id);
LOG_DEBUG(log, "table does not exist, table_id={}", table_id);
return;
}
GET_METRIC(tiflash_schema_internal_ddl_count, type_drop_table).Increment();
Expand Down Expand Up @@ -1087,7 +1087,7 @@ void SchemaBuilder<Getter, NameMapper>::applyDropTable(DatabaseID database_id, T
auto * storage = tmt_context.getStorages().get(keyspace_id, table_id).get();
if (storage == nullptr)
{
LOG_DEBUG(log, "table {} does not exist.", table_id);
LOG_DEBUG(log, "table does not exist, table_id={}", table_id);
return;
}
const auto & table_info = storage->getTableInfo();
Expand Down
25 changes: 13 additions & 12 deletions dbms/src/TiDB/Schema/SchemaGetter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,10 @@ std::optional<SchemaDiff> SchemaGetter::getSchemaDiff(Int64 ver)
String data = TxnStructure::get(snap, key);
if (data.empty())
{
LOG_WARNING(log, "The schema diff for version {}, key {} is empty.", ver, key);
LOG_WARNING(log, "The schema diff is empty, schema_version={} key={}", ver, key);
return std::nullopt;
}
LOG_DEBUG(log, "Get SchemaDiff from TiKV: {}", data); // TODO: turn it into trace level
LOG_TRACE(log, "Get SchemaDiff from TiKV, schema_version={} data={}", ver, data);
SchemaDiff diff;
diff.deserialize(data);
return diff;
Expand All @@ -275,7 +275,7 @@ TiDB::DBInfoPtr SchemaGetter::getDatabase(DatabaseID db_id)
if (json.empty())
return nullptr;

LOG_DEBUG(log, "Get DB Info from TiKV : " + json);
LOG_DEBUG(log, "Get DB Info from TiKV: {}", json);
auto db_info = std::make_shared<TiDB::DBInfo>(json, keyspace_id);
return db_info;
}
Expand All @@ -285,25 +285,26 @@ TiDB::TableInfoPtr SchemaGetter::getTableInfo(DatabaseID db_id, TableID table_id
String db_key = getDBKey(db_id);
if (!checkDBExists(db_key))
{
LOG_ERROR(log, "The database {} does not exist.", db_id);
LOG_ERROR(log, "The database does not exist, database_id={}", db_id);
return nullptr;
}
String table_key = getTableKey(table_id);
String table_info_json = TxnStructure::hGet(snap, db_key, table_key);
if (table_info_json.empty())
{
LOG_WARNING(log, "The table {} is dropped in TiKV, try to get the latest table_info", table_id);
LOG_WARNING(log, "The table is dropped in TiKV, try to get the latest table_info, table_id={}", table_id);
table_info_json = TxnStructure::mvccGet(snap, db_key, table_key);
if (table_info_json.empty())
{
LOG_ERROR(
log,
"The table {} is dropped in TiKV, and the latest table_info is still empty, it should by gc",
"The table is dropped in TiKV, and the latest table_info is still empty, it should be GCed, "
"table_id={}",
table_id);
return nullptr;
}
}
LOG_DEBUG(log, "Get Table Info from TiKV : " + table_info_json);
LOG_DEBUG(log, "Get Table Info from TiKV: {}", table_info_json);
TiDB::TableInfoPtr table_info = std::make_shared<TiDB::TableInfo>(table_info_json, keyspace_id);

return table_info;
Expand All @@ -319,26 +320,26 @@ std::tuple<TiDB::DBInfoPtr, TiDB::TableInfoPtr> SchemaGetter::getDatabaseAndTabl
if (db_json.empty())
return std::make_tuple(nullptr, nullptr);

LOG_DEBUG(log, "Get DB Info from TiKV : " + db_json);
LOG_DEBUG(log, "Get DB Info from TiKV: {}", db_json);
auto db_info = std::make_shared<TiDB::DBInfo>(db_json, keyspace_id);

String table_key = getTableKey(table_id);
String table_info_json = TxnStructure::hGet(snap, db_key, table_key);
if (table_info_json.empty())
{
LOG_WARNING(log, "The table {} is dropped in TiKV, try to get the latest table_info", table_id);
LOG_WARNING(log, "The table is dropped in TiKV, try to get the latest table_info, table_id={}", table_id);
table_info_json = TxnStructure::mvccGet(snap, db_key, table_key);
if (table_info_json.empty())
{
LOG_ERROR(
log,
"The table {} is dropped in TiKV, and the latest table_info is still empty, it should by gc",
"The table is dropped in TiKV, and the latest table_info is still empty, it should be GCed, "
"table_id={}",
table_id);
return std::make_tuple(db_info, nullptr);
;
}
}
LOG_DEBUG(log, "Get Table Info from TiKV : " + table_info_json);
LOG_DEBUG(log, "Get Table Info from TiKV: {}", table_info_json);
TiDB::TableInfoPtr table_info = std::make_shared<TiDB::TableInfo>(table_info_json, keyspace_id);

return std::make_tuple(db_info, table_info);
Expand Down

0 comments on commit 4178513

Please sign in to comment.