mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-26 07:30:54 +00:00
cff0d1e8e6
Summary: The primary goal of this change is to add support for backing up and restoring (applying on restore) file temperature metadata, without committing to either the DB manifest or the FS reported "current" temperatures being exclusive "source of truth". To achieve this goal, we need to add temperature information to backup metadata, which requires updated backup meta schema. Fortunately I prepared for this in https://github.com/facebook/rocksdb/issues/8069, which began forward compatibility in version 6.19.0 for this kind of schema update. (Previously, backup meta schema was not extensible! Making this schema update public will allow some other "nice to have" features like taking backups with hard links, and avoiding crc32c checksum computation when another checksum is already available.) While schema version 2 is newly public, the default schema version is still 1. Until we change the default, users will need to set to 2 to enable features like temperature data backup+restore. New metadata like temperature information will be ignored with a warning in versions before this change and since 6.19.0. The metadata is considered ignorable because a functioning DB can be restored without it. Some detail: * Some renaming because "future schema" is now just public schema 2. * Initialize some atomics in TestFs (linter reported) * Add temperature hint support to SstFileDumper (used by BackupEngine) Pull Request resolved: https://github.com/facebook/rocksdb/pull/9660 Test Plan: related unit test majorly updated for the new functionality, including some shared testing support for tracking temperatures in a FS. Some other tests and testing hooks into production code also updated for making the backup meta schema change public. Reviewed By: ajkr Differential Revision: D34686968 Pulled By: pdillinger fbshipit-source-id: 3ac1fa3e67ee97ca8a5103d79cc87d872c1d862a
119 lines
4.5 KiB
C++
119 lines
4.5 KiB
C++
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
|
|
#pragma once
|
|
|
|
#include <map>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "rocksdb/advanced_options.h"
|
|
#include "rocksdb/options.h"
|
|
#include "rocksdb/status.h"
|
|
#include "rocksdb/table.h"
|
|
|
|
namespace ROCKSDB_NAMESPACE {
|
|
struct ColumnFamilyOptions;
|
|
struct ConfigOptions;
|
|
struct DBOptions;
|
|
struct ImmutableCFOptions;
|
|
struct ImmutableDBOptions;
|
|
struct MutableDBOptions;
|
|
struct MutableCFOptions;
|
|
struct Options;
|
|
|
|
std::vector<CompressionType> GetSupportedCompressions();
|
|
|
|
std::vector<CompressionType> GetSupportedDictCompressions();
|
|
|
|
std::vector<ChecksumType> GetSupportedChecksums();
|
|
|
|
inline bool IsSupportedChecksumType(ChecksumType type) {
|
|
// Avoid annoying compiler warning-as-error (-Werror=type-limits)
|
|
auto min = kNoChecksum;
|
|
auto max = kXXH3;
|
|
return type >= min && type <= max;
|
|
}
|
|
|
|
// Checks that the combination of DBOptions and ColumnFamilyOptions are valid
|
|
Status ValidateOptions(const DBOptions& db_opts,
|
|
const ColumnFamilyOptions& cf_opts);
|
|
|
|
DBOptions BuildDBOptions(const ImmutableDBOptions& immutable_db_options,
|
|
const MutableDBOptions& mutable_db_options);
|
|
|
|
ColumnFamilyOptions BuildColumnFamilyOptions(
|
|
const ColumnFamilyOptions& ioptions,
|
|
const MutableCFOptions& mutable_cf_options);
|
|
|
|
void UpdateColumnFamilyOptions(const ImmutableCFOptions& ioptions,
|
|
ColumnFamilyOptions* cf_opts);
|
|
void UpdateColumnFamilyOptions(const MutableCFOptions& moptions,
|
|
ColumnFamilyOptions* cf_opts);
|
|
|
|
#ifndef ROCKSDB_LITE
|
|
std::unique_ptr<Configurable> DBOptionsAsConfigurable(
|
|
const MutableDBOptions& opts);
|
|
std::unique_ptr<Configurable> DBOptionsAsConfigurable(
|
|
const DBOptions& opts,
|
|
const std::unordered_map<std::string, std::string>* opt_map = nullptr);
|
|
std::unique_ptr<Configurable> CFOptionsAsConfigurable(
|
|
const MutableCFOptions& opts);
|
|
std::unique_ptr<Configurable> CFOptionsAsConfigurable(
|
|
const ColumnFamilyOptions& opts,
|
|
const std::unordered_map<std::string, std::string>* opt_map = nullptr);
|
|
|
|
extern Status StringToMap(
|
|
const std::string& opts_str,
|
|
std::unordered_map<std::string, std::string>* opts_map);
|
|
#endif // !ROCKSDB_LITE
|
|
|
|
struct OptionsHelper {
|
|
static const std::string kCFOptionsName /*= "ColumnFamilyOptions"*/;
|
|
static const std::string kDBOptionsName /*= "DBOptions" */;
|
|
static std::map<CompactionStyle, std::string> compaction_style_to_string;
|
|
static std::map<CompactionPri, std::string> compaction_pri_to_string;
|
|
static std::map<CompactionStopStyle, std::string>
|
|
compaction_stop_style_to_string;
|
|
static std::map<Temperature, std::string> temperature_to_string;
|
|
static std::unordered_map<std::string, ChecksumType> checksum_type_string_map;
|
|
static std::unordered_map<std::string, CompressionType>
|
|
compression_type_string_map;
|
|
#ifndef ROCKSDB_LITE
|
|
static std::unordered_map<std::string, CompactionStopStyle>
|
|
compaction_stop_style_string_map;
|
|
static std::unordered_map<std::string, EncodingType> encoding_type_string_map;
|
|
static std::unordered_map<std::string, CompactionStyle>
|
|
compaction_style_string_map;
|
|
static std::unordered_map<std::string, CompactionPri>
|
|
compaction_pri_string_map;
|
|
static std::unordered_map<std::string, Temperature> temperature_string_map;
|
|
#endif // !ROCKSDB_LITE
|
|
};
|
|
|
|
// Some aliasing
|
|
static auto& compaction_style_to_string =
|
|
OptionsHelper::compaction_style_to_string;
|
|
static auto& compaction_pri_to_string = OptionsHelper::compaction_pri_to_string;
|
|
static auto& compaction_stop_style_to_string =
|
|
OptionsHelper::compaction_stop_style_to_string;
|
|
static auto& temperature_to_string = OptionsHelper::temperature_to_string;
|
|
static auto& checksum_type_string_map = OptionsHelper::checksum_type_string_map;
|
|
#ifndef ROCKSDB_LITE
|
|
static auto& compaction_stop_style_string_map =
|
|
OptionsHelper::compaction_stop_style_string_map;
|
|
static auto& compression_type_string_map =
|
|
OptionsHelper::compression_type_string_map;
|
|
static auto& encoding_type_string_map = OptionsHelper::encoding_type_string_map;
|
|
static auto& compaction_style_string_map =
|
|
OptionsHelper::compaction_style_string_map;
|
|
static auto& compaction_pri_string_map =
|
|
OptionsHelper::compaction_pri_string_map;
|
|
static auto& temperature_string_map = OptionsHelper::temperature_string_map;
|
|
#endif // !ROCKSDB_LITE
|
|
|
|
} // namespace ROCKSDB_NAMESPACE
|