Skip to content

Commit

Permalink
3
Browse files Browse the repository at this point in the history
  • Loading branch information
Yukang-Lian committed Nov 30, 2024
1 parent 5ae1274 commit 7a33b23
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
2 changes: 2 additions & 0 deletions cloud/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, "");
Expand Down
45 changes: 41 additions & 4 deletions cloud/src/recycler/meta_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <chrono>
#include <set>

#include "common/config.h"
#include "common/logging.h"
#include "common/util.h"
#include "meta-service/keys.h"
#include "meta-service/txn_kv.h"
Expand Down Expand Up @@ -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;
};

Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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)});
}
}
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 7a33b23

Please sign in to comment.