diff --git a/db/db_with_timestamp_compaction_test.cc b/db/db_with_timestamp_compaction_test.cc index d28f67e05..403d9907c 100644 --- a/db/db_with_timestamp_compaction_test.cc +++ b/db/db_with_timestamp_compaction_test.cc @@ -323,6 +323,27 @@ TEST_F(TimestampCompatibleCompactionTest, CompactFilesRangeCheckL1) { static_cast(compaction_job_info.input_files.size())); } } + +TEST_F(TimestampCompatibleCompactionTest, EmptyCompactionOutput) { + Options options = CurrentOptions(); + options.env = env_; + options.comparator = test::BytewiseComparatorWithU64TsWrapper(); + DestroyAndReopen(options); + + std::string ts_str = Timestamp(1); + WriteOptions wopts; + ASSERT_OK( + db_->DeleteRange(wopts, db_->DefaultColumnFamily(), "k1", "k3", ts_str)); + ASSERT_OK(Flush()); + + ts_str = Timestamp(3); + Slice ts = ts_str; + CompactRangeOptions cro; + // range tombstone will be dropped during compaction + cro.full_history_ts_low = &ts; + cro.bottommost_level_compaction = BottommostLevelCompaction::kForce; + ASSERT_OK(db_->CompactRange(cro, nullptr, nullptr)); +} #endif // !ROCKSDB_LITE } // namespace ROCKSDB_NAMESPACE diff --git a/db/table_properties_collector.h b/db/table_properties_collector.h index 9035ba793..968115c3d 100644 --- a/db/table_properties_collector.h +++ b/db/table_properties_collector.h @@ -150,8 +150,10 @@ class TimestampTablePropertiesCollector : public IntTblPropCollector { } Status Finish(UserCollectedProperties* properties) override { + // timestamp is empty is table is empty assert(timestamp_min_.size() == timestamp_max_.size() && - timestamp_max_.size() == cmp_->timestamp_size()); + (timestamp_min_.empty() || + timestamp_max_.size() == cmp_->timestamp_size())); properties->insert({"rocksdb.timestamp_min", timestamp_min_}); properties->insert({"rocksdb.timestamp_max", timestamp_max_}); return Status::OK();