Skip to content

Commit 6a83adc

Browse files
huangmengbinjaykorean
authored andcommitted
prevent data loss when all entries are expired in Remote Compaction (facebook#13743)
Summary: **Issue**: When running remote compaction, if all entries in the input files are expired, RocksDB incorrectly deletes an active file from the primary DB, leading to data loss and corruption. **Root Cause**: The current logic mistakenly mixed up the input and output file paths during the cleanup phase when no keys survive the compaction (all expired). This results in deleting the input files (which belong to the primary DB) instead of the output files (which belong to the SecondaryDB). **Fix**: Use `GetTableFileName` (virtual function) instead of `TableFileName` Pull Request resolved: facebook#13743 Reviewed By: hx235 Differential Revision: D79108650 Pulled By: jaykorean fbshipit-source-id: 1c9ba971a0e9a62c15ebc014436cb8fc961af95c
1 parent ab42881 commit 6a83adc

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

db/compaction/compaction_job.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,9 +1741,7 @@ Status CompactionJob::FinishCompactionOutputFile(
17411741
// If there is nothing to output, no necessary to generate a sst file.
17421742
// This happens when the output level is bottom level, at the same time
17431743
// the sub_compact output nothing.
1744-
std::string fname =
1745-
TableFileName(sub_compact->compaction->immutable_options().cf_paths,
1746-
meta->fd.GetNumber(), meta->fd.GetPathId());
1744+
std::string fname = GetTableFileName(meta->fd.GetNumber());
17471745

17481746
// TODO(AR) it is not clear if there are any larger implications if
17491747
// DeleteFile fails here

0 commit comments

Comments
 (0)