[Unused] Remove unused GC function in DataDir (#3019)
This commit is contained in:
@ -799,73 +799,6 @@ void DataDir::remove_pending_ids(const std::string& id) {
|
||||
_pending_path_ids.erase(id);
|
||||
}
|
||||
|
||||
// path consumer
|
||||
void DataDir::perform_path_gc() {
|
||||
// init the set of valid path
|
||||
// validate the path in data dir
|
||||
std::unique_lock<std::mutex> lck(_check_path_mutex);
|
||||
cv.wait(lck, [this]{return _all_check_paths.size() > 0;});
|
||||
LOG(INFO) << "start to path gc.";
|
||||
int counter = 0;
|
||||
for (auto& path : _all_check_paths) {
|
||||
++counter;
|
||||
if (config::path_gc_check_step > 0 && counter % config::path_gc_check_step == 0) {
|
||||
usleep(config::path_gc_check_step_interval_ms * 1000);
|
||||
}
|
||||
TTabletId tablet_id = -1;
|
||||
TSchemaHash schema_hash = -1;
|
||||
bool is_valid = _tablet_manager->get_tablet_id_and_schema_hash_from_path(path,
|
||||
&tablet_id, &schema_hash);
|
||||
if (!is_valid) {
|
||||
LOG(WARNING) << "unknown path:" << path;
|
||||
continue;
|
||||
}
|
||||
if (tablet_id > 0 && schema_hash > 0) {
|
||||
// tablet schema hash path or rowset file path
|
||||
// gc thread should get tablet include deleted tablet
|
||||
// or it will delete rowset file before tablet is garbage collected
|
||||
TabletSharedPtr tablet = _tablet_manager->get_tablet(tablet_id, schema_hash, true);
|
||||
if (tablet == nullptr) {
|
||||
std::string tablet_path_id = TABLET_ID_PREFIX + std::to_string(tablet_id);
|
||||
bool exist_in_pending = _check_pending_ids(tablet_path_id);
|
||||
if (!exist_in_pending) {
|
||||
_process_garbage_path(path);
|
||||
}
|
||||
} else {
|
||||
bool valid = tablet->check_path(path);
|
||||
// TODO(ygl): should change a method to do gc
|
||||
if (!valid) {
|
||||
RowsetId rowset_id;
|
||||
bool is_rowset_file = _tablet_manager->get_rowset_id_from_path(path, &rowset_id);
|
||||
if (is_rowset_file) {
|
||||
std::string rowset_path_id = ROWSET_ID_PREFIX + rowset_id.to_string();
|
||||
bool exist_in_pending = _check_pending_ids(rowset_path_id);
|
||||
if (!exist_in_pending) {
|
||||
_process_garbage_path(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (tablet_id > 0 && schema_hash <= 0) {
|
||||
// tablet id path
|
||||
if (!FileUtils::is_dir(path)) {
|
||||
LOG(WARNING) << "unknown path:" << path;
|
||||
continue;
|
||||
}
|
||||
bool exist = _tablet_manager->check_tablet_id_exist(tablet_id);
|
||||
if (!exist) {
|
||||
std::string tablet_path_id = TABLET_ID_PREFIX + std::to_string(tablet_id);
|
||||
bool exist_in_pending = _check_pending_ids(tablet_path_id);
|
||||
if (!exist_in_pending) {
|
||||
_process_garbage_path(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_all_check_paths.clear();
|
||||
LOG(INFO) << "finished one time path gc.";
|
||||
}
|
||||
|
||||
void DataDir::perform_path_gc_by_rowsetid() {
|
||||
// init the set of valid path
|
||||
// validate the path in data dir
|
||||
|
||||
@ -110,10 +110,6 @@ public:
|
||||
// this is a producer function. After scan, it will notify the perform_path_gc function to gc
|
||||
void perform_path_scan();
|
||||
|
||||
// this function is a consumer function
|
||||
// this function will collect garbage paths scaned by last function
|
||||
void perform_path_gc();
|
||||
|
||||
void perform_path_gc_by_rowsetid();
|
||||
|
||||
OLAPStatus remove_old_meta_and_files();
|
||||
|
||||
Reference in New Issue
Block a user