db_options.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. #pragma once
  6. #include <string>
  7. #include <vector>
  8. #include "rocksdb/options.h"
  9. namespace ROCKSDB_NAMESPACE {
  10. class SystemClock;
  11. struct ImmutableDBOptions {
  12. static const char* kName() { return "ImmutableDBOptions"; }
  13. ImmutableDBOptions();
  14. explicit ImmutableDBOptions(const DBOptions& options);
  15. void Dump(Logger* log) const;
  16. bool create_if_missing;
  17. bool create_missing_column_families;
  18. bool error_if_exists;
  19. bool paranoid_checks;
  20. bool flush_verify_memtable_count;
  21. bool compaction_verify_record_count;
  22. bool track_and_verify_wals_in_manifest;
  23. bool track_and_verify_wals;
  24. bool verify_sst_unique_id_in_manifest;
  25. Env* env;
  26. std::shared_ptr<RateLimiter> rate_limiter;
  27. std::shared_ptr<SstFileManager> sst_file_manager;
  28. std::shared_ptr<Logger> info_log;
  29. InfoLogLevel info_log_level;
  30. int max_file_opening_threads;
  31. std::shared_ptr<Statistics> statistics;
  32. bool use_fsync;
  33. std::vector<DbPath> db_paths;
  34. std::string db_log_dir;
  35. // The wal_dir option from the file. To determine the
  36. // directory in use, the GetWalDir or IsWalDirSameAsDBPath
  37. // methods should be used instead of accessing this variable directly.
  38. std::string wal_dir;
  39. size_t max_log_file_size;
  40. size_t log_file_time_to_roll;
  41. size_t keep_log_file_num;
  42. size_t recycle_log_file_num;
  43. uint64_t max_manifest_file_size;
  44. int table_cache_numshardbits;
  45. uint64_t WAL_ttl_seconds;
  46. uint64_t WAL_size_limit_MB;
  47. uint64_t max_write_batch_group_size_bytes;
  48. size_t manifest_preallocation_size;
  49. bool allow_mmap_reads;
  50. bool allow_mmap_writes;
  51. bool use_direct_reads;
  52. bool use_direct_io_for_flush_and_compaction;
  53. bool allow_fallocate;
  54. bool is_fd_close_on_exec;
  55. bool advise_random_on_open;
  56. size_t db_write_buffer_size;
  57. std::shared_ptr<WriteBufferManager> write_buffer_manager;
  58. bool use_adaptive_mutex;
  59. std::vector<std::shared_ptr<EventListener>> listeners;
  60. bool enable_thread_tracking;
  61. bool enable_pipelined_write;
  62. bool unordered_write;
  63. bool allow_concurrent_memtable_write;
  64. bool enable_write_thread_adaptive_yield;
  65. uint64_t write_thread_max_yield_usec;
  66. uint64_t write_thread_slow_yield_usec;
  67. bool skip_stats_update_on_db_open;
  68. bool skip_checking_sst_file_sizes_on_db_open;
  69. WALRecoveryMode wal_recovery_mode;
  70. bool allow_2pc;
  71. std::shared_ptr<Cache> row_cache;
  72. WalFilter* wal_filter;
  73. bool dump_malloc_stats;
  74. bool avoid_flush_during_recovery;
  75. bool allow_ingest_behind;
  76. bool two_write_queues;
  77. bool manual_wal_flush;
  78. CompressionType wal_compression;
  79. bool background_close_inactive_wals;
  80. bool atomic_flush;
  81. bool avoid_unnecessary_blocking_io;
  82. bool prefix_seek_opt_in_only;
  83. bool persist_stats_to_disk;
  84. bool write_dbid_to_manifest;
  85. bool write_identity_file;
  86. size_t log_readahead_size;
  87. std::shared_ptr<FileChecksumGenFactory> file_checksum_gen_factory;
  88. bool best_efforts_recovery;
  89. int max_bgerror_resume_count;
  90. uint64_t bgerror_resume_retry_interval;
  91. bool allow_data_in_errors;
  92. std::string db_host_id;
  93. FileTypeSet checksum_handoff_file_types;
  94. CacheTier lowest_used_cache_tier;
  95. std::shared_ptr<CompactionService> compaction_service;
  96. bool enforce_single_del_contracts;
  97. uint64_t follower_refresh_catchup_period_ms;
  98. uint64_t follower_catchup_retry_count;
  99. uint64_t follower_catchup_retry_wait_ms;
  100. Temperature metadata_write_temperature;
  101. Temperature wal_write_temperature;
  102. CompactionStyleSet calculate_sst_write_lifetime_hint_set;
  103. // Beginning convenience/helper objects that are not part of the base
  104. // DBOptions
  105. std::shared_ptr<FileSystem> fs;
  106. SystemClock* clock;
  107. Statistics* stats;
  108. Logger* logger;
  109. // End of convenience/helper objects.
  110. bool IsWalDirSameAsDBPath() const;
  111. bool IsWalDirSameAsDBPath(const std::string& path) const;
  112. const std::string& GetWalDir() const;
  113. const std::string& GetWalDir(const std::string& path) const;
  114. };
  115. struct MutableDBOptions {
  116. static const char* kName() { return "MutableDBOptions"; }
  117. MutableDBOptions();
  118. explicit MutableDBOptions(const DBOptions& options);
  119. void Dump(Logger* log) const;
  120. int max_background_jobs;
  121. int max_background_compactions;
  122. uint32_t max_subcompactions;
  123. bool avoid_flush_during_shutdown;
  124. size_t writable_file_max_buffer_size;
  125. uint64_t delayed_write_rate;
  126. uint64_t max_total_wal_size;
  127. uint64_t delete_obsolete_files_period_micros;
  128. unsigned int stats_dump_period_sec;
  129. unsigned int stats_persist_period_sec;
  130. size_t stats_history_buffer_size;
  131. int max_open_files;
  132. uint64_t bytes_per_sync;
  133. uint64_t wal_bytes_per_sync;
  134. bool strict_bytes_per_sync;
  135. size_t compaction_readahead_size;
  136. int max_background_flushes;
  137. std::string daily_offpeak_time_utc;
  138. };
  139. Status GetStringFromMutableDBOptions(const ConfigOptions& config_options,
  140. const MutableDBOptions& mutable_opts,
  141. std::string* opt_string);
  142. Status GetMutableDBOptionsFromStrings(
  143. const MutableDBOptions& base_options,
  144. const std::unordered_map<std::string, std::string>& options_map,
  145. MutableDBOptions* new_options);
  146. bool MutableDBOptionsAreEqual(const MutableDBOptions& this_options,
  147. const MutableDBOptions& that_options);
  148. } // namespace ROCKSDB_NAMESPACE