You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pegasus.apache.org by zh...@apache.org on 2022/06/20 05:53:02 UTC

[incubator-pegasus] branch master updated: feat: support to restrict the size of rocksdb info logs (#1009)

This is an automated email from the ASF dual-hosted git repository.

zhaoliwei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git


The following commit(s) were added to refs/heads/master by this push:
     new 1b726c88 feat: support to restrict the size of rocksdb info logs (#1009)
1b726c88 is described below

commit 1b726c884509936e3ae79be637c3c23c752d9dff
Author: Dan Wang <em...@126.com>
AuthorDate: Mon Jun 20 13:52:57 2022 +0800

    feat: support to restrict the size of rocksdb info logs (#1009)
---
 src/server/config.ini                   |  4 ++++
 src/server/pegasus_server_impl_init.cpp | 41 +++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/src/server/config.ini b/src/server/config.ini
index e4b32188..4c7f5e5d 100644
--- a/src/server/config.ini
+++ b/src/server/config.ini
@@ -356,6 +356,10 @@
   rocksdb_total_size_across_write_buffer = 0
   rocksdb_max_open_files = -1
 
+  rocksdb_max_log_file_size = 8388608
+  rocksdb_log_file_time_to_roll = 86400
+  rocksdb_keep_log_file_num = 32
+
   rocksdb_index_type = binary_search
   rocksdb_partition_filters = false
   rocksdb_metadata_block_size = 4096
diff --git a/src/server/pegasus_server_impl_init.cpp b/src/server/pegasus_server_impl_init.cpp
index 80d7069d..c1bdc19a 100644
--- a/src/server/pegasus_server_impl_init.cpp
+++ b/src/server/pegasus_server_impl_init.cpp
@@ -95,6 +95,38 @@ DSN_DEFINE_uint64(
     "batch-get operation iterate count exceed this threshold will be logged, 0 means no check");
 DSN_TAG_VARIABLE(rocksdb_abnormal_batch_get_count_threshold, FT_MUTABLE);
 
+// In production environment, it has been observed that an instance of rocksdb about 20GB in total
+// size which has run beyond 199 days, generated a big log file sized 96MB, with 492KB for each
+// day.
+//
+// Accordingly, default value for `rocksdb_log_file_time_to_roll` can be set to one day, and
+// that for `rocksdb_keep_log_file_num` can be set to 32, which means log files for recent one
+// month will be reserved.
+//
+// On the other hand, the max size of a log file is restricted to 8MB. In practice, the size of
+// logs over a day tends to be less than 1MB; however, once errors are reported very frequently,
+// the log file will grow larger and go far beyond several hundreds of KB.
+DSN_DEFINE_uint64("pegasus.server",
+                  rocksdb_max_log_file_size,
+                  8 * 1024 * 1024,
+                  "specify the maximal size of the info log file: once the log file is larger "
+                  "than this option, a new info log file will be created; if this option is set "
+                  "to 0, all logs will be written to one log file.");
+
+DSN_DEFINE_uint64("pegasus.server",
+                  rocksdb_log_file_time_to_roll,
+                  24 * 60 * 60,
+                  "specify time for the info log file to roll (in seconds): if this option is "
+                  "specified with non-zero value, log file will be rolled if it has been active "
+                  "longer than this option; otherwise, if this options is set to 0, log file will "
+                  "never be rolled by life time");
+
+DSN_DEFINE_uint64("pegasus.server",
+                  rocksdb_keep_log_file_num,
+                  32,
+                  "specify the maximal numbers of info log files to be kept: once the number of "
+                  "info logs goes beyond this option, stale log files will be cleaned.");
+
 static const std::unordered_map<std::string, rocksdb::BlockBasedTableOptions::IndexType>
     INDEX_TYPE_STRING_MAP = {
         {"binary_search", rocksdb::BlockBasedTableOptions::IndexType::kBinarySearch},
@@ -404,6 +436,15 @@ pegasus_server_impl::pegasus_server_impl(dsn::replication::replica *r)
     _db_opts.max_open_files = static_cast<int>(max_open_files);
     ddebug_replica("rocksdb_max_open_files = {}", _db_opts.max_open_files);
 
+    _db_opts.max_log_file_size = static_cast<size_t>(FLAGS_rocksdb_max_log_file_size);
+    ddebug_replica("rocksdb_max_log_file_size = {}", _db_opts.max_log_file_size);
+
+    _db_opts.log_file_time_to_roll = static_cast<size_t>(FLAGS_rocksdb_log_file_time_to_roll);
+    ddebug_replica("rocksdb_log_file_time_to_roll = {}", _db_opts.log_file_time_to_roll);
+
+    _db_opts.keep_log_file_num = static_cast<size_t>(FLAGS_rocksdb_keep_log_file_num);
+    ddebug_replica("rocksdb_keep_log_file_num = {}", _db_opts.keep_log_file_num);
+
     std::string index_type =
         dsn_config_get_value_string("pegasus.server",
                                     "rocksdb_index_type",


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pegasus.apache.org
For additional commands, e-mail: commits-help@pegasus.apache.org