Skip to content

Commit

Permalink
fix and add comment
Browse files Browse the repository at this point in the history
Change-Id: I838bd4ec4400f11bfaebd67abb9596e0995cf6e8
  • Loading branch information
zhangyifan27 committed Jan 7, 2022
1 parent 6d6b191 commit ef3171c
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/kudu/master/catalog_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,14 @@ TAG_FLAG(enable_deleted_tables_and_tablets_cleanup, runtime);

DEFINE_int32(deleted_table_and_tablet_reserved_secs, 60 * 60,
"After this amount of time, a deleted table/tablet could be actually removed by "
"catalog manager if '--enable_deleted_tables_and_tablets_cleanup=true'. ");
"catalog manager if --enable_deleted_tables_and_tablets_cleanup=true. ");
TAG_FLAG(deleted_table_and_tablet_reserved_secs, experimental);
TAG_FLAG(deleted_table_and_tablet_reserved_secs, runtime);

DEFINE_bool(enable_chucked_tablet_writes, true, "");
DEFINE_bool(enable_chucked_tablet_writes, true,
"Whether to split tablet actions into chunks when persisting them in sys.catalog "
"table. If disabled, any update of the sys.catalog table would be rejected if exceeds "
"--rpc_max_message_size.");
TAG_FLAG(enable_chucked_tablet_writes, experimental);
TAG_FLAG(enable_chucked_tablet_writes, runtime);

Expand Down Expand Up @@ -5582,7 +5585,7 @@ Status CatalogManager::ProcessDeletedTablets(const vector<scoped_refptr<TabletIn
vector<scoped_refptr<TabletInfo>> tablets_to_clean_up;
const time_t now = time(nullptr);
for (const auto& tablet : tablets) {
CHECK(tablet->metadata().state().is_deleted());
DCHECK(tablet->metadata().state().is_deleted());
if (!tablet->metadata().state().pb.has_delete_timestamp()) {
// Set delete timestamp for the tablet.
tablet->mutable_metadata()->mutable_dirty()->pb.set_delete_timestamp(now);
Expand All @@ -5593,7 +5596,7 @@ Status CatalogManager::ProcessDeletedTablets(const vector<scoped_refptr<TabletIn
actions.tablets_to_delete.emplace_back(tablet);
}
}
// Persist the changes to the syscatalog table.
// Persist the changes to the sys.catalog table.
const auto write_mode = FLAGS_enable_chucked_tablet_writes ? SysCatalogTable::WriteMode::CHUNKED
: SysCatalogTable::WriteMode::ATOMIC;
Status s = sys_catalog_->Write(std::move(actions), write_mode);
Expand All @@ -5606,10 +5609,8 @@ Status CatalogManager::ProcessDeletedTablets(const vector<scoped_refptr<TabletIn
{
std::lock_guard<LockType> l(lock_);
for (const auto& t : tablets_to_clean_up) {
if (tablet_map_.erase(t->id()) != 1) {
return Status::Corruption(
Substitute("Failed to remove tablet $0 from 'tablet_map_'.", t->id()));
}
DCHECK(ContainsKey(tablet_map_, t->id()));
tablet_map_.erase(t->id());
VLOG(1) << "Cleaned up deleted tablet: " << t->id();
}
}
Expand All @@ -5626,7 +5627,7 @@ Status CatalogManager::ProcessDeletedTables(const vector<scoped_refptr<TableInfo
const time_t now = time(nullptr);
bool needs_clean_up_table;
for (const auto& table : tables) {
CHECK(table->metadata().state().is_deleted());
DCHECK(table->metadata().state().is_deleted());
SysCatalogTable::Actions action;
if (!table->metadata().state().pb.has_delete_timestamp()) {
table->mutable_metadata()->mutable_dirty()->pb.set_delete_timestamp(now);
Expand All @@ -5647,11 +5648,10 @@ Status CatalogManager::ProcessDeletedTables(const vector<scoped_refptr<TableInfo
if (!needs_clean_up_table) {
continue;
}

std::lock_guard<LockType> l(lock_);
if (table_ids_map_.erase(table->id()) != 1) {
return Status::Corruption(
Substitute("Failed to remove table $0 from 'table_id_map_'.", table->ToString()));
}
DCHECK(ContainsKey(table_ids_map_, table->id()));
table_ids_map_.erase(table->id());
VLOG(1) << "Cleaned up deleted table: " << table->ToString();
}

Expand Down

0 comments on commit ef3171c

Please sign in to comment.