Skip to content

Commit e21d5b8

Browse files
committed
[CF] Flush all memtables on column family drop
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
1 parent fa34697 commit e21d5b8

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

db/db_impl.cc

+12-6
Original file line numberDiff line numberDiff line change
@@ -3155,17 +3155,23 @@ Status DBImpl::DropColumnFamily(ColumnFamilyHandle* column_family) {
31553155
edit.DropColumnFamily();
31563156
edit.SetColumnFamily(cfd->GetID());
31573157

3158-
MutexLock l(&mutex_);
31593158
Status s;
3160-
if (cfd->IsDropped()) {
3161-
s = Status::InvalidArgument("Column family already dropped!\n");
3162-
}
3163-
if (s.ok()) {
3164-
s = versions_->LogAndApply(cfd, &edit, &mutex_);
3159+
{
3160+
MutexLock l(&mutex_);
3161+
if (cfd->IsDropped()) {
3162+
s = Status::InvalidArgument("Column family already dropped!\n");
3163+
}
3164+
if (s.ok()) {
3165+
s = versions_->LogAndApply(cfd, &edit, &mutex_);
3166+
}
31653167
}
31663168

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

0 commit comments

Comments
 (0)