Skip to content

Commit

Permalink
[bugfix](fd) Recycle the segment file fds directly when delete stale …
Browse files Browse the repository at this point in the history
…rowset (#22705) (#22795)
  • Loading branch information
Lchangliang authored Aug 9, 2023
1 parent b884f9f commit 87db7c2
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
3 changes: 1 addition & 2 deletions be/src/olap/olap_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,8 @@ Status StorageEngine::start_bg_threads() {
}

void StorageEngine::_fd_cache_clean_callback() {
int32_t interval = 600;
int32_t interval = config::cache_clean_interval;
while (!_stop_background_threads_latch.wait_for(std::chrono::seconds(interval))) {
interval = config::cache_clean_interval;
if (interval <= 0) {
LOG(WARNING) << "config of file descriptor clean interval is illegal: [" << interval
<< "], force set to 3600 ";
Expand Down
2 changes: 1 addition & 1 deletion be/src/olap/segment_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Status SegmentLoader::load_segments(const BetaRowsetSharedPtr& rowset,
return Status::OK();
}

void SegmentLoader::erase_segment(const SegmentCache::CacheKey& key) {
void SegmentLoader::erase_segments(const SegmentCache::CacheKey& key) {
_segment_cache->erase(key);
}

Expand Down
2 changes: 1 addition & 1 deletion be/src/olap/segment_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class SegmentLoader {
Status load_segments(const BetaRowsetSharedPtr& rowset, SegmentCacheHandle* cache_handle,
bool use_cache = false);

void erase_segment(const SegmentCache::CacheKey& key);
void erase_segments(const SegmentCache::CacheKey& key);

private:
SegmentLoader();
Expand Down
2 changes: 2 additions & 0 deletions be/src/olap/tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,8 @@ void Tablet::_delete_stale_rowset_by_version(const Version& version) {
return;
}
_tablet_meta->delete_stale_rs_meta_by_version(version);
// If the stale rowset was deleted, it need to remove the fds directly
SegmentLoader::instance()->erase_segments(SegmentCache::CacheKey(rowset_meta->rowset_id()));
VLOG_NOTICE << "delete stale rowset. tablet=" << full_name() << ", version=" << version;
}

Expand Down
2 changes: 1 addition & 1 deletion be/src/olap/txn_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ Status TxnManager::publish_txn(OlapMeta* meta, TPartitionId partition_id,
rowset->merge_rowset_meta(transient_rowset->rowset_meta());

// erase segment cache cause we will add a segment to rowset
SegmentLoader::instance()->erase_segment(rowset->rowset_id());
SegmentLoader::instance()->erase_segments(rowset->rowset_id());
}
stats->partial_update_write_segment_us = MonotonicMicros() - t3;
int64_t t4 = MonotonicMicros();
Expand Down
3 changes: 2 additions & 1 deletion be/src/vec/olap/vertical_block_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ Status VerticalBlockReader::_get_segment_iterators(const ReaderParams& read_para
// segment iterator will be inited here
// In vertical compaction, every group will load segment so we should cache
// segment to avoid tot many s3 head request
bool use_cache = !rs_split.rs_reader->rowset()->is_local();
RETURN_IF_ERROR(rs_split.rs_reader->get_segment_iterators(&_reader_context, segment_iters,
{}, true));
{}, use_cache));
// if segments overlapping, all segment iterator should be inited in
// heap merge iterator. If segments are none overlapping, only first segment of this
// rowset will be inited and push to heap, other segment will be inited later when current
Expand Down

0 comments on commit 87db7c2

Please sign in to comment.