Skip to content

Commit

Permalink
add debug
Browse files Browse the repository at this point in the history
  • Loading branch information
eldenmoon committed Oct 31, 2024
1 parent d492717 commit 5db093e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions be/src/olap/tablet_schema_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <gen_cpp/olap_file.pb.h>
#include <glog/logging.h>
#include <json2pb/pb_to_json.h>

#include <boost/uuid/name_generator_md5.hpp>
#include <boost/uuid/uuid.hpp>
Expand Down Expand Up @@ -56,8 +57,20 @@ std::pair<Cache::Handle*, TabletSchemaSPtr> TabletSchemaCache::insert(const std:
if (lru_handle) {
auto* value = (CacheValue*)LRUCachePolicy::value(lru_handle);
tablet_schema_ptr = value->tablet_schema;
// check signature to prevent from hash collision
LOG_IF(FATAL, value->signature != key_signature) << "key signature not match";
std::string original_key = tablet_schema_ptr->to_key();
if (original_key != key) {
TabletSchemaPB pb1;
pb1.ParseFromString(key);
TabletSchemaPB pb2;
pb2.ParseFromString(original_key);
json2pb::Pb2JsonOptions json_options;
json_options.pretty_json = true;
std::string org;
std::string cur;
json2pb::ProtoMessageToJson(pb2, &org, json_options);
json2pb::ProtoMessageToJson(pb1, &cur, json_options);
LOG(FATAL) << "original " << org << " current " << cur;
}
g_tablet_schema_cache_hit_count << 1;
} else {
auto* value = new CacheValue;
Expand All @@ -67,7 +80,6 @@ std::pair<Cache::Handle*, TabletSchemaSPtr> TabletSchemaCache::insert(const std:
// We should reuse the memory of the same TabletColumn object, set reuse_cached_column to true
tablet_schema_ptr->init_from_pb(pb, false, true);
value->tablet_schema = tablet_schema_ptr;
value->signature = key_signature;
lru_handle = LRUCachePolicy::insert(key_signature, value, tablet_schema_ptr->num_columns(),
0, CachePriority::NORMAL);
g_tablet_schema_cache_count << 1;
Expand Down

0 comments on commit 5db093e

Please sign in to comment.