Skip to content

Commit

Permalink
Remove schema_hash from consistency check
Browse files Browse the repository at this point in the history
Signed-off-by: trueeyu <lxhhust350@qq.com>
  • Loading branch information
trueeyu committed Aug 24, 2023
1 parent feb03db commit ccfaa4f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 38 deletions.
4 changes: 2 additions & 2 deletions be/src/agent/agent_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ void run_check_consistency_task(const std::shared_ptr<CheckConsistencyTaskReques
LOG(WARNING) << "check consistency failed: " << check_limit_st.message();
status_code = TStatusCode::MEM_LIMIT_EXCEEDED;
} else {
EngineChecksumTask engine_task(mem_tracker, check_consistency_req.tablet_id, check_consistency_req.schema_hash,
check_consistency_req.version, &checksum);
EngineChecksumTask engine_task(mem_tracker, check_consistency_req.tablet_id, check_consistency_req.version,
&checksum);
Status res = StorageEngine::instance()->execute_task(&engine_task);
if (!res.ok()) {
LOG(WARNING) << "check consistency failed. status: " << res << ", signature: " << agent_task_req->signature;
Expand Down
20 changes: 4 additions & 16 deletions be/src/http/action/checksum_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ const std::string TABLET_ID = "tablet_id";
const std::string TABLET_VERSION = "version";
const std::string SCHEMA_HASH = "schema_hash";

ChecksumAction::ChecksumAction(ExecEnv* exec_env) : _exec_env(exec_env) {}

void ChecksumAction::handle(HttpRequest* req) {
LOG(INFO) << "accept one request " << req->debug_string();

Expand All @@ -76,31 +74,21 @@ void ChecksumAction::handle(HttpRequest* req) {
return;
}

// Get schema hash
const std::string& schema_hash_str = req->param(SCHEMA_HASH);
if (schema_hash_str.empty()) {
std::string error_msg = std::string("parameter " + SCHEMA_HASH + " not specified in url.");
HttpChannel::send_reply(req, HttpStatus::BAD_REQUEST, error_msg);
return;
}

// valid str format
int64_t tablet_id;
int64_t version;
int32_t schema_hash;
try {
tablet_id = boost::lexical_cast<int64_t>(tablet_id_str);
version = boost::lexical_cast<int64_t>(version_str);
schema_hash = boost::lexical_cast<int64_t>(schema_hash_str);
} catch (boost::bad_lexical_cast& e) {
std::string error_msg = std::string("param format is invalid: ") + std::string(e.what());
HttpChannel::send_reply(req, HttpStatus::BAD_REQUEST, error_msg);
return;
}

VLOG_ROW << "get checksum tablet info: " << tablet_id << "-" << version << "-" << schema_hash;
VLOG_ROW << "get checksum tablet info: " << tablet_id << "-" << version;

int64_t checksum = do_checksum(tablet_id, version, schema_hash, req);
int64_t checksum = _do_checksum(tablet_id, version);
if (checksum == -1L) {
std::string error_msg = std::string("checksum failed");
HttpChannel::send_reply(req, HttpStatus::INTERNAL_SERVER_ERROR, error_msg);
Expand All @@ -115,7 +103,7 @@ void ChecksumAction::handle(HttpRequest* req) {
LOG(INFO) << "deal with checksum request finished! tablet id: " << tablet_id;
}

int64_t ChecksumAction::do_checksum(int64_t tablet_id, int64_t version, int32_t schema_hash, HttpRequest* req) {
int64_t ChecksumAction::_do_checksum(int64_t tablet_id, int64_t version) {
MemTracker* mem_tracker = GlobalEnv::GetInstance()->consistency_mem_tracker();
Status check_limit_st = mem_tracker->check_mem_limit("Start consistency check.");
if (!check_limit_st.ok()) {
Expand All @@ -125,7 +113,7 @@ int64_t ChecksumAction::do_checksum(int64_t tablet_id, int64_t version, int32_t

Status res = Status::OK();
uint32_t checksum;
EngineChecksumTask engine_task(mem_tracker, tablet_id, schema_hash, version, &checksum);
EngineChecksumTask engine_task(mem_tracker, tablet_id, version, &checksum);
res = engine_task.execute();
if (!res.ok()) {
LOG(WARNING) << "checksum failed. status: " << res << ", signature: " << tablet_id;
Expand Down
12 changes: 3 additions & 9 deletions be/src/http/action/checksum_action.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,15 @@

namespace starrocks {

class ExecEnv;

class ChecksumAction : public HttpHandler {
public:
explicit ChecksumAction(ExecEnv* exec_env);

ChecksumAction() = default;
~ChecksumAction() override = default;

void handle(HttpRequest* req) override;

private:
int64_t do_checksum(int64_t tablet_id, int64_t version, int32_t schema_hash, HttpRequest* req);

[[maybe_unused]] ExecEnv* _exec_env;

}; // end class ChecksumAction
int64_t _do_checksum(int64_t tablet_id, int64_t version);
};

} // end namespace starrocks
2 changes: 1 addition & 1 deletion be/src/service/service_be/http_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Status HttpServiceBE::start() {

#ifndef BE_TEST
// Register BE checksum action
auto* checksum_action = new ChecksumAction(_env);
auto* checksum_action = new ChecksumAction();
_ev_http_server->register_handler(HttpMethod::GET, "/api/checksum", checksum_action);
_http_handlers.emplace_back(checksum_action);

Expand Down
13 changes: 6 additions & 7 deletions be/src/storage/task/engine_checksum_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,21 @@

namespace starrocks {

EngineChecksumTask::EngineChecksumTask(MemTracker* mem_tracker, TTabletId tablet_id, TSchemaHash schema_hash,
TVersion version, uint32_t* checksum)
: _tablet_id(tablet_id), _schema_hash(schema_hash), _version(version), _checksum(checksum) {
EngineChecksumTask::EngineChecksumTask(MemTracker* mem_tracker, TTabletId tablet_id, TVersion version,
uint32_t* checksum)
: _tablet_id(tablet_id), _version(version), _checksum(checksum) {
_mem_tracker = std::make_unique<MemTracker>(-1, "checksum instance", mem_tracker);
}

Status EngineChecksumTask::execute() {
SCOPED_THREAD_LOCAL_MEM_TRACKER_SETTER(_mem_tracker.get());

Status res = _compute_checksum();
return res;
} // execute
return _compute_checksum();
}

Status EngineChecksumTask::_compute_checksum() {
LOG(INFO) << "begin to process compute checksum."
<< "tablet_id=" << _tablet_id << ", schema_hash=" << _schema_hash << ", version=" << _version;
<< "tablet_id=" << _tablet_id << ", version=" << _version;

if (_checksum == nullptr) {
LOG(WARNING) << "The input checksum is a null pointer";
Expand Down
4 changes: 1 addition & 3 deletions be/src/storage/task/engine_checksum_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class EngineChecksumTask : public EngineTask {
public:
Status execute() override;

EngineChecksumTask(MemTracker* mem_tracker, TTabletId tablet_id, TSchemaHash schema_hash, TVersion version,
uint32_t* checksum);
EngineChecksumTask(MemTracker* mem_tracker, TTabletId tablet_id, TVersion version, uint32_t* checksum);

~EngineChecksumTask() override = default;

Expand All @@ -57,7 +56,6 @@ class EngineChecksumTask : public EngineTask {
std::unique_ptr<MemTracker> _mem_tracker;

TTabletId _tablet_id;
TSchemaHash _schema_hash;
TVersion _version;
uint32_t* _checksum;
}; // EngineTask
Expand Down

0 comments on commit ccfaa4f

Please sign in to comment.