rocksdb/env
Peter Dillinger 879357fdb0 Make backups openable as read-only DBs (#8142)
Summary:
A current limitation of backups is that you don't know the
exact database state of when the backup was taken. With this new
feature, you can at least inspect the backup's DB state without
restoring it by opening it as a read-only DB.

Rather than add something like OpenAsReadOnlyDB to the BackupEngine API,
which would inhibit opening stackable DB implementations read-only
(if/when their APIs support it), we instead provide a DB name and Env
that can be used to open as a read-only DB.

Possible follow-up work:

* Add a version of GetBackupInfo for a single backup.
* Let CreateNewBackup return the BackupID of the newly-created backup.

Implementation details:

Refactored ChrootFileSystem to split off new base class RemapFileSystem,
which allows more general remapping of files. We use this base class to
implement BackupEngineImpl::RemapSharedFileSystem.

To minimize API impact, I decided to just add these fields `name_for_open`
and `env_for_open` to those set by GetBackupInfo when
include_file_details=true. Creating the RemapSharedFileSystem adds a bit
to the memory consumption, perhaps unnecessarily in some cases, but this
has been mitigated by (a) only initialize the RemapSharedFileSystem
lazily when GetBackupInfo with include_file_details=true is called, and
(b) using the existing `shared_ptr<FileInfo>` objects to hold most of the
mapping data.

To enhance API safety, RemapSharedFileSystem is wrapped by new
ReadOnlyFileSystem which rejects any attempts to write. This uncovered a
couple of places in which DB::OpenForReadOnly would write to the
filesystem, so I fixed these. Added a release note because this affects
logging.

Additional minor refactoring in backupable_db.cc to support the new
functionality.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/8142

Test Plan:
new test (run with ASAN and UBSAN), added to stress test and
ran it for a while with amplified backup_one_in

Reviewed By: ajkr

Differential Revision: D27535408

Pulled By: pdillinger

fbshipit-source-id: 04666d310aa0261ef6b2385c43ca793ce1dfd148
2021-04-06 14:37:53 -07:00
..
composite_env_wrapper.h Remove Legacy and Custom FileWrapper classes from header files (#7851) 2021-01-28 22:10:32 -08:00
composite_env.cc Add new Append API with DataVerificationInfo to Env WritableFile (#8071) 2021-03-19 11:44:13 -07:00
env_basic_test.cc Improvements to Env::GetChildren (#7819) 2021-01-09 09:44:34 -08:00
env_chroot.cc Make backups openable as read-only DBs (#8142) 2021-04-06 14:37:53 -07:00
env_chroot.h Make backups openable as read-only DBs (#8142) 2021-04-06 14:37:53 -07:00
env_encryption_ctr.h Changes to EncryptedEnv public API (#7279) 2020-09-15 17:14:10 -07:00
env_encryption.cc Make ChRootEnv, EncryptedEnv, and TimedEnv into FileSystems (#7968) 2021-03-15 19:50:11 -07:00
env_hdfs.cc Use thread-safe strerror_r() to get error message (#8087) 2021-03-24 23:07:27 -07:00
env_posix.cc Use thread-safe strerror_r() to get error message (#8087) 2021-03-24 23:07:27 -07:00
env_test.cc Use thread-safe strerror_r() to get error message (#8087) 2021-03-24 23:07:27 -07:00
env.cc Remove Legacy and Custom FileWrapper classes from header files (#7851) 2021-01-28 22:10:32 -08:00
file_system_tracer.cc Add request_id in IODebugContext. (#8045) 2021-04-01 13:14:51 -07:00
file_system_tracer.h Use SystemClock* instead of std::shared_ptr<SystemClock> in lower level routines (#8033) 2021-03-15 04:34:11 -07:00
file_system.cc Create a CustomEnv class; Add WinFileSystem; Make LegacyFileSystemWrapper private (#7703) 2021-01-06 10:49:32 -08:00
fs_posix.cc Adding safer permissions to PosixFilesystem::NewLogger (#8106) 2021-03-29 20:47:21 -07:00
fs_readonly.h Make backups openable as read-only DBs (#8142) 2021-04-06 14:37:53 -07:00
fs_remap.cc Make backups openable as read-only DBs (#8142) 2021-04-06 14:37:53 -07:00
fs_remap.h Make backups openable as read-only DBs (#8142) 2021-04-06 14:37:53 -07:00
io_posix_test.cc Status check enforcement for io_posix_test and options_settable_test (#6857) 2020-05-19 19:22:28 -07:00
io_posix.cc Always truncate the latest WAL file on DB Open (#8122) 2021-03-28 10:00:08 -07:00
io_posix.h Add AppendWithVerify and PositionedAppendWithVerify to Env and FileSystem (#7419) 2020-09-23 19:02:26 -07:00
mock_env_test.cc Replace namespace name "rocksdb" with ROCKSDB_NAMESPACE (#6433) 2020-02-20 12:09:57 -08:00
mock_env.cc Always truncate the latest WAL file on DB Open (#8122) 2021-03-28 10:00:08 -07:00
mock_env.h Use SystemClock* instead of std::shared_ptr<SystemClock> in lower level routines (#8033) 2021-03-15 04:34:11 -07:00