diff --git a/cloud/src/common/config.h b/cloud/src/common/config.h index 828ad1b519b0602..584217f943ce53c 100644 --- a/cloud/src/common/config.h +++ b/cloud/src/common/config.h @@ -86,6 +86,8 @@ CONF_mInt64(recycle_task_threshold_seconds, "10800"); // 3h // **just for TEST** CONF_Bool(force_immediate_recycle, "false"); +CONF_Bool(enable_meta_checker_verbose_log, "false"); + CONF_String(test_s3_ak, ""); CONF_String(test_s3_sk, ""); CONF_String(test_s3_endpoint, ""); diff --git a/cloud/src/recycler/meta_checker.cpp b/cloud/src/recycler/meta_checker.cpp index 522015555de825e..19996567176e9b6 100644 --- a/cloud/src/recycler/meta_checker.cpp +++ b/cloud/src/recycler/meta_checker.cpp @@ -25,6 +25,8 @@ #include #include +#include "common/config.h" +#include "common/logging.h" #include "common/util.h" #include "meta-service/keys.h" #include "meta-service/txn_kv.h" @@ -54,6 +56,7 @@ struct PartitionInfo { int64_t db_id; int64_t table_id; int64_t partition_id; + int64_t tablet_id; int64_t visible_version; }; @@ -173,6 +176,12 @@ bool MetaChecker::check_fdb_by_fe_meta(MYSQL* conn) { MYSQL_ROW row = mysql_fetch_row(result); TabletInfo tablet_info = {0}; tablet_info.tablet_id = atoll(row[0]); + if (config::enable_meta_checker_verbose_log) { + LOG_INFO("get tablet info log") + .tag("db name", elem.first) + .tag("table name", table) + .tag("tablet id", tablet_info.tablet_id); + } tablet_info.schema_version = atoll(row[4]); tablets.push_back(std::move(tablet_info)); } @@ -201,6 +210,14 @@ bool MetaChecker::check_fdb_by_fe_meta(MYSQL* conn) { partition_info.db_id = atoll(row[4]); partition_info.table_id = atoll(row[5]); partition_info.partition_id = atoll(row[6]); + partition_info.tablet_id = tablet_info.tablet_id; + if (config::enable_meta_checker_verbose_log) { + LOG_INFO("get partition info log") + .tag("db id", partition_info.db_id) + .tag("table id", partition_info.table_id) + .tag("partition id", partition_info.partition_id) + .tag("tablet id", partition_info.tablet_id); + } partitions.insert({partition_info.partition_id, std::move(partition_info)}); } } @@ -217,9 +234,20 @@ bool MetaChecker::check_fdb_by_fe_meta(MYSQL* conn) { int num_row = mysql_num_rows(result); for (int i = 0; i < num_row; ++i) { MYSQL_ROW row = mysql_fetch_row(result); - int partition_id = atoll(row[0]); - int visible_version = atoll(row[2]); + int64_t partition_id = atoll(row[0]); + int64_t visible_version = atoll(row[2]); partitions[partition_id].visible_version = visible_version; + if (config::enable_meta_checker_verbose_log) { + LOG_INFO("get partition version log") + .tag("db name", elem.first) + .tag("table name", table) + .tag("raw partition id", row[0]) + .tag("first partition id", partition_id) + .tag("db id", partitions[partition_id].db_id) + .tag("table id", partitions[partition_id].table_id) + .tag("second partition id", partitions[partition_id].partition_id) + .tag("tablet id", partitions[partition_id].tablet_id); + } } } mysql_free_result(result); @@ -354,14 +382,23 @@ bool MetaChecker::check_fdb_by_fe_meta(MYSQL* conn) { int64_t db_id = elem.second.db_id; int64_t table_id = elem.second.table_id; int64_t partition_id = elem.second.partition_id; + int64_t tablet_id = elem.second.tablet_id; std::string ver_key = partition_version_key({instance_id_, db_id, table_id, partition_id}); std::string ver_val; err = txn->get(ver_key, &ver_val); if (err == TxnErrorCode::TXN_KEY_NOT_FOUND) { - LOG(WARNING) << "version key not found, partition id: " << partition_id; + LOG_WARNING("version key not found.") + .tag("db id", db_id) + .tag("table id", table_id) + .tag("partition id", partition_id) + .tag("tablet id", tablet_id); return false; } else if (err != TxnErrorCode::TXN_OK) { - LOG(WARNING) << "failed to get version: " << partition_id; + LOG_WARNING("failed to get version.") + .tag("db id", db_id) + .tag("table id", table_id) + .tag("partition id", partition_id) + .tag("tablet id", tablet_id); return false; }