Skip to content

Commit

Permalink
[BugFix] make sure metadata cache quit safety (StarRocks#49702)
Browse files Browse the repository at this point in the history
Signed-off-by: luohaha <[email protected]>
  • Loading branch information
luohaha authored Aug 12, 2024
1 parent b7c96a9 commit 4f5a9d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion be/src/storage/rowset/rowset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ Rowset::~Rowset() {
if (_keys_type != PRIMARY_KEYS) {
// ONLY support non-pk table now.
// evict rowset before destroy, in case this rowset no close yet.
StorageEngine::instance()->tablet_manager()->metadata_cache()->evict_rowset(this);
auto metadata_cache = StorageEngine::instance()->tablet_manager()->metadata_cache();
if (metadata_cache != nullptr) {
metadata_cache->evict_rowset(this);
}
}
#endif
MEM_TRACKER_SAFE_RELEASE(GlobalEnv::GetInstance()->rowset_metadata_mem_tracker(), _mem_usage());
Expand Down
6 changes: 3 additions & 3 deletions be/src/storage/tablet_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ class TabletManager {
static Status _remove_tablet_directories(const TabletSharedPtr& tablet);
static Status _move_tablet_directories_to_trash(const TabletSharedPtr& tablet);

// LRU cache for metadata
std::unique_ptr<MetadataCache> _metadata_cache;

std::vector<TabletsShard> _tablets_shards;
const int64_t _tablets_shards_mask;
LockTable _schema_change_lock_tbl;
Expand All @@ -300,9 +303,6 @@ class TabletManager {
// context for compaction checker
size_t _cur_shard = 0;
std::unordered_set<int64_t> _shard_visited_tablet_ids;

// LRU cache for metadata
std::unique_ptr<MetadataCache> _metadata_cache;
};

inline bool TabletManager::LockTable::is_locked(int64_t tablet_id) {
Expand Down

0 comments on commit 4f5a9d6

Please sign in to comment.