Support GetLiveFiles on secondary DB instances#14475
Closed
archang19 wants to merge 1 commit into
Closed
Conversation
Summary: GetLiveFiles was previously blocked on secondary instances with Status::NotSupported, even though the operation is safe to perform. The only reason GetLiveFiles was originally blocked is that it defaults to flushing the memtable (flush_memtable=true), which is a write operation. However, the actual implementation in DBImpl::GetLiveFiles (db_filesnapshot.cc) does two things: 1. Optionally flush the memtable — which we skip by passing flush_memtable=false. The secondary already overrides FlushForGetLiveFiles() as a no-op, so even if true were passed it would not actually flush. 2. Read live file state from versions_ under the mutex — this is purely read-only. It iterates the ColumnFamilySet to collect live table and blob file numbers, builds relative file paths for SST files, blob files, CURRENT, MANIFEST, and OPTIONS, and reads the manifest file size. The secondary maintains its own VersionSet which it keeps up to date via MANIFEST replay in TryCatchUpWithPrimary(). So all of this state is valid and accurate — it reflects exactly which files the secondary considers live at its current replay point. This is the same approach used by DBImplReadOnly and CompactedDBImpl, which both delegate to DBImpl::GetLiveFiles with flush_memtable=false. Differential Revision: D97563143
|
@archang19 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D97563143. |
✅ clang-tidy: No findings on changed linesCompleted in 116.0s. |
xingbowang
approved these changes
Mar 21, 2026
|
This pull request has been merged in 89e384c. |
doxtop
pushed a commit
to flyingw/rocksdb
that referenced
this pull request
Apr 7, 2026
Summary: Pull Request resolved: facebook#14475 GetLiveFiles was previously blocked on secondary instances with Status::NotSupported, even though the operation is safe to perform. The only reason GetLiveFiles was originally blocked is that it defaults to flushing the memtable (flush_memtable=true), which is a write operation. However, the actual implementation in DBImpl::GetLiveFiles (db_filesnapshot.cc) does two things: 1. Optionally flush the memtable — which we skip by passing flush_memtable=false. The secondary already overrides FlushForGetLiveFiles() as a no-op, so even if true were passed it would not actually flush. 2. Read live file state from versions_ under the mutex — this is purely read-only. It iterates the ColumnFamilySet to collect live table and blob file numbers, builds relative file paths for SST files, blob files, CURRENT, MANIFEST, and OPTIONS, and reads the manifest file size. The secondary maintains its own VersionSet which it keeps up to date via MANIFEST replay in TryCatchUpWithPrimary(). So all of this state is valid and accurate — it reflects exactly which files the secondary considers live at its current replay point. This is the same approach used by DBImplReadOnly and CompactedDBImpl, which both delegate to DBImpl::GetLiveFiles with flush_memtable=false. Reviewed By: xingbowang Differential Revision: D97563143 fbshipit-source-id: 8d5b52e26a478ef190eba598819de6527817bcfc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
GetLiveFiles was previously blocked on secondary instances with
Status::NotSupported, even though the operation is safe to perform.
The only reason GetLiveFiles was originally blocked is that it defaults
to flushing the memtable (flush_memtable=true), which is a write
operation. However, the actual implementation in DBImpl::GetLiveFiles
(db_filesnapshot.cc) does two things:
Optionally flush the memtable — which we skip by passing
flush_memtable=false. The secondary already overrides
FlushForGetLiveFiles() as a no-op, so even if true were passed
it would not actually flush.
Read live file state from versions_ under the mutex — this is
purely read-only. It iterates the ColumnFamilySet to collect live
table and blob file numbers, builds relative file paths for SST
files, blob files, CURRENT, MANIFEST, and OPTIONS, and reads the
manifest file size.
The secondary maintains its own VersionSet which it keeps up to date
via MANIFEST replay in TryCatchUpWithPrimary(). So all of this state
is valid and accurate — it reflects exactly which files the secondary
considers live at its current replay point.
This is the same approach used by DBImplReadOnly and CompactedDBImpl,
which both delegate to DBImpl::GetLiveFiles with flush_memtable=false.
Differential Revision: D97563143