]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Disallow ingesting files into dropped CFs
authorIslam AbdelRahman <tec@fb.com>
Tue, 13 Dec 2016 08:47:52 +0000 (00:47 -0800)
committerIslam AbdelRahman <tec@fb.com>
Wed, 14 Dec 2016 21:05:06 +0000 (13:05 -0800)
Summary:
This PR update IngestExternalFile to return an error if we try to ingest a file into a dropped CF.

Right now if IngestExternalFile want to flush a memtable, and it's ingesting a file into a dropped CF, it will wait forever since flushing is not possible for the dropped CF
Closes https://github.com/facebook/rocksdb/pull/1657

Differential Revision: D4318657

Pulled By: IslamAbdelRahman

fbshipit-source-id: ed6ea2b

db/db_impl.cc
db/external_sst_file_test.cc

index b5d52a92c6861297c219928add53eef3f608c310..67658e9383e00119fe2a080d2f64d5d9b43a8364 100644 (file)
@@ -6418,13 +6418,22 @@ Status DBImpl::IngestExternalFile(
 
     num_running_ingest_file_++;
 
+    // We cannot ingest a file into a dropped CF
+    if (cfd->IsDropped()) {
+      status = Status::InvalidArgument(
+          "Cannot ingest an external file into a dropped CF");
+    }
+
     // Figure out if we need to flush the memtable first
-    bool need_flush = false;
-    status = ingestion_job.NeedsFlush(&need_flush);
-    if (status.ok() && need_flush) {
-      mutex_.Unlock();
-      status = FlushMemTable(cfd, FlushOptions(), true /* writes_stopped */);
-      mutex_.Lock();
+    if (status.ok()) {
+      bool need_flush = false;
+      status = ingestion_job.NeedsFlush(&need_flush);
+
+      if (status.ok() && need_flush) {
+        mutex_.Unlock();
+        status = FlushMemTable(cfd, FlushOptions(), true /* writes_stopped */);
+        mutex_.Lock();
+      }
     }
 
     // Run the ingestion job
index 89ed999a4ad1cb2908d009747ff209c8e987e252..731282b5e7dfb2f23eabc8fb711be37cad4392a2 100644 (file)
@@ -1843,6 +1843,13 @@ TEST_F(ExternalSSTFileTest, FileWithCFInfo) {
   ASSERT_OK(db_->IngestExternalFile(handles_[2], {unknown_sst}, ifo));
   // SST CF unknown
   ASSERT_OK(db_->IngestExternalFile(handles_[0], {unknown_sst}, ifo));
+
+  // Cannot ingest a file into a dropped CF
+  ASSERT_OK(db_->DropColumnFamily(handles_[1]));
+  ASSERT_NOK(db_->IngestExternalFile(handles_[1], {unknown_sst}, ifo));
+
+  // CF was not dropped, ok to Ingest
+  ASSERT_OK(db_->IngestExternalFile(handles_[2], {unknown_sst}, ifo));
 }
 
 class TestIngestExternalFileListener : public EventListener {