branch-2.1: [fix](trash) Fix shadow variable causing garbage scheduling time errors #51647 (#51996)

Cherry-picked from #51647

Co-authored-by: deardeng <dengxin@selectdb.com>
This commit is contained in:
github-actions[bot]
2025-06-28 11:12:25 +08:00
committed by GitHub
parent c671a09a56
commit cb60589c0a

View File

@ -323,7 +323,7 @@ void StorageEngine::_garbage_sweeper_thread_callback() {
// when usage = 0.88, ratio is approximately 0.0057.
double ratio = (1.1 * (pi / 2 - std::atan(usage * 100 / 5 - 14)) - 0.28) / pi;
ratio = ratio > 0 ? ratio : 0;
auto curr_interval = uint32_t(max_interval * ratio);
curr_interval = uint32_t(max_interval * ratio);
curr_interval = std::max(curr_interval, min_interval);
curr_interval = std::min(curr_interval, max_interval);
@ -338,6 +338,8 @@ void StorageEngine::_garbage_sweeper_thread_callback() {
<< "see previous message for detail. err code=" << res;
// do nothing. continue next loop.
}
LOG(INFO) << "trash thread check usage=" << usage << " ratio=" << ratio
<< " curr_interval=" << curr_interval;
} while (!_stop_background_threads_latch.wait_for(std::chrono::seconds(curr_interval)));
}