Skip to content

Commit

Permalink
[CF] Flush all memtables on column family drop
Browse files Browse the repository at this point in the history
Summary: When column family is dropped, we want to delete all WALs that refer to it. To do that, we need to make them obsolete by flushing all the memtables

Test Plan: column_family_test

Reviewers: dhruba, haobo

CC: leveldb

Differential Revision: https://reviews.facebook.net/D16557
  • Loading branch information
igorcanadi committed Mar 5, 2014
1 parent fa34697 commit e21d5b8
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions db/db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3155,17 +3155,23 @@ Status DBImpl::DropColumnFamily(ColumnFamilyHandle* column_family) {
edit.DropColumnFamily();
edit.SetColumnFamily(cfd->GetID());

MutexLock l(&mutex_);
Status s;
if (cfd->IsDropped()) {
s = Status::InvalidArgument("Column family already dropped!\n");
}
if (s.ok()) {
s = versions_->LogAndApply(cfd, &edit, &mutex_);
{
MutexLock l(&mutex_);
if (cfd->IsDropped()) {
s = Status::InvalidArgument("Column family already dropped!\n");
}
if (s.ok()) {
s = versions_->LogAndApply(cfd, &edit, &mutex_);
}
}

if (s.ok()) {
Log(options_.info_log, "Dropped column family with id %u\n", cfd->GetID());
// Flush the memtables. This will make all WAL files referencing dropped
// column family to be obsolete. They will be deleted when user deletes
// column family handle
Write(WriteOptions(), nullptr); // ignore error
} else {
Log(options_.info_log, "Dropping column family with id %u FAILED -- %s\n",
cfd->GetID(), s.ToString().c_str());
Expand Down

0 comments on commit e21d5b8

Please sign in to comment.