[bugfix](memleak) fix memory leak for tabletschema and result cache (#51931)
### What problem does this PR solve? pick #51786 Related PR: #xxx Problem Summary: ### Release note None ### Check List (For Author) - Test <!-- At least one of them must be included. --> - [ ] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [ ] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [ ] No. - [ ] Yes. <!-- Add document PR link here. eg: https://github.com/apache/doris-website/pull/1214 --> ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
This commit is contained in:
@ -940,14 +940,6 @@ void TabletSchema::clear_columns() {
|
||||
_num_null_columns = 0;
|
||||
_num_key_columns = 0;
|
||||
_cols.clear();
|
||||
clear_column_cache_handlers();
|
||||
}
|
||||
|
||||
void TabletSchema::clear_column_cache_handlers() {
|
||||
for (auto* cache_handle : _column_cache_handlers) {
|
||||
TabletColumnObjectPool::instance()->release(cache_handle);
|
||||
}
|
||||
_column_cache_handlers.clear();
|
||||
}
|
||||
|
||||
void TabletSchema::init_from_pb(const TabletSchemaPB& schema, bool ignore_extracted_columns,
|
||||
@ -962,7 +954,6 @@ void TabletSchema::init_from_pb(const TabletSchemaPB& schema, bool ignore_extrac
|
||||
_field_name_to_index.clear();
|
||||
_field_id_to_index.clear();
|
||||
_cluster_key_idxes.clear();
|
||||
clear_column_cache_handlers();
|
||||
for (const auto& i : schema.cluster_key_idxes()) {
|
||||
_cluster_key_idxes.push_back(i);
|
||||
}
|
||||
@ -972,7 +963,10 @@ void TabletSchema::init_from_pb(const TabletSchemaPB& schema, bool ignore_extrac
|
||||
auto pair = TabletColumnObjectPool::instance()->insert(
|
||||
deterministic_string_serialize(column_pb));
|
||||
column = pair.second;
|
||||
_column_cache_handlers.push_back(pair.first);
|
||||
// Release the handle quickly, because we use shared ptr to manage column.
|
||||
// It often core during tablet schema copy to another schema because handle's
|
||||
// reference count should be managed mannually.
|
||||
TabletColumnObjectPool::instance()->release(pair.first);
|
||||
} else {
|
||||
column = std::make_shared<TabletColumn>();
|
||||
column->init_from_pb(column_pb);
|
||||
@ -1057,8 +1051,6 @@ void TabletSchema::shawdow_copy_without_columns(const TabletSchema& tablet_schem
|
||||
_num_key_columns = 0;
|
||||
_cols.clear();
|
||||
_vl_field_mem_size = 0;
|
||||
// notice : do not ref columns
|
||||
_column_cache_handlers.clear();
|
||||
}
|
||||
|
||||
void TabletSchema::update_index_info_from(const TabletSchema& tablet_schema) {
|
||||
@ -1120,7 +1112,6 @@ void TabletSchema::build_current_tablet_schema(int64_t index_id, int32_t version
|
||||
_sequence_col_idx = -1;
|
||||
_version_col_idx = -1;
|
||||
_cluster_key_idxes.clear();
|
||||
clear_column_cache_handlers();
|
||||
for (const auto& i : ori_tablet_schema._cluster_key_idxes) {
|
||||
_cluster_key_idxes.push_back(i);
|
||||
}
|
||||
|
||||
@ -489,13 +489,10 @@ private:
|
||||
friend bool operator!=(const TabletSchema& a, const TabletSchema& b);
|
||||
TabletSchema(const TabletSchema&) = default;
|
||||
|
||||
void clear_column_cache_handlers();
|
||||
|
||||
KeysType _keys_type = DUP_KEYS;
|
||||
SortType _sort_type = SortType::LEXICAL;
|
||||
size_t _sort_col_num = 0;
|
||||
std::vector<TabletColumnPtr> _cols;
|
||||
std::vector<Cache::Handle*> _column_cache_handlers;
|
||||
|
||||
std::vector<TabletIndex> _indexes;
|
||||
std::unordered_map<StringRef, int32_t, StringRefHash> _field_name_to_index;
|
||||
|
||||
6
be/src/runtime/cache/result_cache.h
vendored
6
be/src/runtime/cache/result_cache.h
vendored
@ -79,7 +79,11 @@ public:
|
||||
_partition_count = 0;
|
||||
}
|
||||
|
||||
virtual ~ResultCache() {}
|
||||
virtual ~ResultCache() {
|
||||
_node_list.clear();
|
||||
_node_map.clear();
|
||||
}
|
||||
|
||||
void update(const PUpdateCacheRequest* request, PCacheResponse* response);
|
||||
void fetch(const PFetchCacheRequest* request, PFetchCacheResult* result);
|
||||
bool contains(const UniqueId& sql_key);
|
||||
|
||||
@ -634,6 +634,7 @@ void ExecEnv::destroy() {
|
||||
// Free resource after threads are stopped.
|
||||
// Some threads are still running, like threads created by _new_load_stream_mgr ...
|
||||
SAFE_DELETE(_tablet_schema_cache);
|
||||
SAFE_DELETE(_tablet_column_object_pool);
|
||||
|
||||
// _scanner_scheduler must be desotried before _storage_page_cache
|
||||
SAFE_DELETE(_scanner_scheduler);
|
||||
|
||||
Reference in New Issue
Block a user