diff --git a/HISTORY.md b/HISTORY.md index 28a0c704a..084764a8b 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,4 +1,8 @@ # Rocksdb Change Log +## Unreleased +### Bug Fixes +* Fixed bug in calls to `IngestExternalFiles()` with files for multiple column families. The bug could have introduced a delay in ingested file keys becoming visible after `IngestExternalFiles()` returned. Furthermore, mutations to ingested file keys while they were invisible could have been dropped (not necessarily immediately). + ## 6.25.2 (2021-10-11) ### Bug Fixes * Fix `DisableManualCompaction()` to cancel compactions even when they are waiting on automatic compactions to drain due to `CompactRangeOptions::exclusive_manual_compactions == true`. diff --git a/db/db_impl/db_impl.cc b/db/db_impl/db_impl.cc index bac5e6c7f..b49b09213 100644 --- a/db/db_impl/db_impl.cc +++ b/db/db_impl/db_impl.cc @@ -4679,14 +4679,11 @@ Status DBImpl::IngestExternalFiles( if (status.ok()) { int consumed_seqno_count = ingestion_jobs[0].ConsumedSequenceNumbersCount(); -#ifndef NDEBUG for (size_t i = 1; i != num_cfs; ++i) { - assert(!!consumed_seqno_count == - !!ingestion_jobs[i].ConsumedSequenceNumbersCount()); - consumed_seqno_count += - ingestion_jobs[i].ConsumedSequenceNumbersCount(); + consumed_seqno_count = + std::max(consumed_seqno_count, + ingestion_jobs[i].ConsumedSequenceNumbersCount()); } -#endif if (consumed_seqno_count > 0) { const SequenceNumber last_seqno = versions_->LastSequence(); versions_->SetLastAllocatedSequence(last_seqno + consumed_seqno_count); diff --git a/db/external_sst_file_ingestion_job.h b/db/external_sst_file_ingestion_job.h index c669089d9..fdf5d9fcf 100644 --- a/db/external_sst_file_ingestion_job.h +++ b/db/external_sst_file_ingestion_job.h @@ -139,7 +139,7 @@ class ExternalSstFileIngestionJob { IngestedFileInfo* file_to_ingest, SuperVersion* sv); - // Assign `file_to_ingest` the appropriate sequence number and the lowest + // Assign `file_to_ingest` the appropriate sequence number and the lowest // possible level that it can be ingested to according to compaction_style. // REQUIRES: Mutex held Status AssignLevelAndSeqnoForIngestedFile(SuperVersion* sv, diff --git a/db/external_sst_file_test.cc b/db/external_sst_file_test.cc index 633a0ddac..9213bb50d 100644 --- a/db/external_sst_file_test.cc +++ b/db/external_sst_file_test.cc @@ -2421,6 +2421,12 @@ TEST_P(ExternalSSTFileTest, IngestFilesIntoMultipleColumnFamilies_Success) { Options options = CurrentOptions(); options.env = fault_injection_env.get(); CreateAndReopenWithCF({"pikachu", "eevee"}, options); + + // Exercise different situations in different column families: two are empty + // (so no new sequence number is needed), but at least one overlaps with the + // DB and needs to bump the sequence number. + ASSERT_OK(db_->Put(WriteOptions(), "foo1", "oldvalue")); + std::vector column_families; column_families.push_back(handles_[0]); column_families.push_back(handles_[1]);