Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1316 bugfix_trackable_gc_emptydir #1319

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/master/tablet_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1175,9 +1175,14 @@ bool Table::TryCollectInheritedFile() {
std::vector<TabletFile> tablet_files;
CollectInheritedFileFromFilesystem(name_, *it, &tablet_files);

for (uint32_t i = 0; i < tablet_files.size(); i++) {
if (tablet_files.empty()) {
MutexLock l(&mutex_);
AddInheritedFile(tablet_files[i], false);
AddEmptyDeadTablet(*it);
} else {
for (uint32_t i = 0; i < tablet_files.size(); i++) {
MutexLock l(&mutex_);
AddInheritedFile(tablet_files[i], false);
}
}
}
return dead_tablets.size() > 0;
Expand Down Expand Up @@ -1300,6 +1305,17 @@ void Table::AddInheritedFile(const TabletFile& file, bool need_ref) {
VLOG(10) << "[gc] [" << name_ << "] file " << file << " ref increment to " << file_info.ref;
}

void Table::AddEmptyDeadTablet(uint64_t tablet_id) {
mutex_.AssertHeld();

if (useful_inh_files_.find(tablet_id) == useful_inh_files_.end()) {
LOG(INFO) << "[gc] [" << name_ << "] new empty dead tablet "
<< tablet_id << ", gc disabled";
gc_disabled_dead_tablets_.insert(tablet_id);
useful_inh_files_[tablet_id];
}
}

uint64_t Table::CleanObsoleteFile() {
leveldb::Env* env = io::LeveldbBaseEnv();
std::string table_path = FLAGS_tera_tabletnode_path_prefix + name_;
Expand Down
1 change: 1 addition & 0 deletions src/master/tablet_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ class Table {
void EnableDeadTabletGarbageCollect(uint64_t tablet_id);
void ReleaseInheritedFile(const TabletFile& file);
void AddInheritedFile(const TabletFile& file, bool need_ref);
void AddEmptyDeadTablet(uint64_t tablet_id);
uint64_t CleanObsoleteFile();

private:
Expand Down