diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp index ba8c7668d6810e4..23592b32232b147 100644 --- a/be/src/common/config.cpp +++ b/be/src/common/config.cpp @@ -985,9 +985,7 @@ DEFINE_Bool(enable_file_cache, "false"); // format: [{"path":"/path/to/file_cache","total_size":21474836480,"query_limit":10737418240},{"path":"/path/to/file_cache2","total_size":21474836480,"query_limit":10737418240}] DEFINE_String(file_cache_path, ""); DEFINE_Int64(file_cache_each_block_size, "1048576"); // 1MB -DEFINE_Validator(file_cache_each_block_size, [](const int64_t config) -> bool { - return config <= config::s3_write_buffer_size && config::s3_write_buffer_size % config == 0; -}); + DEFINE_Bool(clear_file_cache, "false"); DEFINE_Bool(enable_file_cache_query_limit, "false"); DEFINE_mInt32(file_cache_enter_disk_resource_limit_mode_percent, "90"); @@ -1035,7 +1033,7 @@ DEFINE_mInt32(tablet_path_check_batch_size, "1000"); // Page size of row column, default 4KB DEFINE_mInt64(row_column_page_size, "4096"); // it must be larger than or equal to 5MB -DEFINE_mInt32(s3_write_buffer_size, "5242880"); +DEFINE_mInt64(s3_write_buffer_size, "5242880"); // The timeout config for S3 buffer allocation DEFINE_mInt32(s3_writer_buffer_allocation_timeout, "300"); DEFINE_mInt64(file_cache_max_file_reader_cache_size, "1000000"); diff --git a/be/src/common/config.h b/be/src/common/config.h index 1b93fc15f75ffcd..d9056dacd02df22 100644 --- a/be/src/common/config.h +++ b/be/src/common/config.h @@ -1077,7 +1077,7 @@ DECLARE_mInt32(tablet_path_check_batch_size); // Page size of row column, default 4KB DECLARE_mInt64(row_column_page_size); // it must be larger than or equal to 5MB -DECLARE_mInt32(s3_write_buffer_size); +DECLARE_mInt64(s3_write_buffer_size); // The timeout config for S3 buffer allocation DECLARE_mInt32(s3_writer_buffer_allocation_timeout); // the max number of cached file handle for block segemnt diff --git a/be/src/io/fs/local_file_reader.cpp b/be/src/io/fs/local_file_reader.cpp index 18c4892f143ac16..1953778e34427f8 100644 --- a/be/src/io/fs/local_file_reader.cpp +++ b/be/src/io/fs/local_file_reader.cpp @@ -19,6 +19,7 @@ #include // IWYU pragma: no_include +#include #include // IWYU pragma: keep #include #include @@ -40,11 +41,14 @@ namespace doris { namespace io { struct IOContext; +bvar::Adder local_file_open_reading("doris_be_local_file_open_reading"); +bvar::Adder local_file_reader_total("doris_be_local_file_reader_total"); + LocalFileReader::LocalFileReader(Path path, size_t file_size, int fd, std::shared_ptr fs) : _fd(fd), _path(std::move(path)), _file_size(file_size), _fs(std::move(fs)) { - DorisMetrics::instance()->local_file_open_reading->increment(1); - DorisMetrics::instance()->local_file_reader_total->increment(1); + local_file_open_reading << 1; + local_file_reader_total << 1; } LocalFileReader::~LocalFileReader() { @@ -54,7 +58,7 @@ LocalFileReader::~LocalFileReader() { Status LocalFileReader::close() { bool expected = false; if (_closed.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) { - DorisMetrics::instance()->local_file_open_reading->increment(-1); + local_file_open_reading << -1; DCHECK(bthread_self() == 0); if (-1 == ::close(_fd)) { std::string err = errno_to_str(); diff --git a/be/src/io/fs/s3_file_bufferpool.cpp b/be/src/io/fs/s3_file_bufferpool.cpp index 2d362942a52c869..3ea30af3811bb10 100644 --- a/be/src/io/fs/s3_file_bufferpool.cpp +++ b/be/src/io/fs/s3_file_bufferpool.cpp @@ -17,6 +17,8 @@ #include "s3_file_bufferpool.h" +#include + #include #include diff --git a/be/src/runtime/exec_env.h b/be/src/runtime/exec_env.h index ceb6c83c40f7cfd..1b05b282fa2e0dd 100644 --- a/be/src/runtime/exec_env.h +++ b/be/src/runtime/exec_env.h @@ -105,6 +105,7 @@ class RowCache; class DummyLRUCache; class CacheManager; class WalManager; +class DorisMetrics; inline bool k_doris_exit = false; diff --git a/be/src/runtime/exec_env_init.cpp b/be/src/runtime/exec_env_init.cpp index 40b0f22cdba5451..31be4f83d4e8f17 100644 --- a/be/src/runtime/exec_env_init.cpp +++ b/be/src/runtime/exec_env_init.cpp @@ -314,6 +314,15 @@ Status ExecEnv::init_pipeline_task_scheduler() { void ExecEnv::init_file_cache_factory() { // Load file cache before starting up daemon threads to make sure StorageEngine is read. if (doris::config::enable_file_cache) { + if (config::file_cache_each_block_size > config::s3_write_buffer_size || + config::s3_write_buffer_size % config::file_cache_each_block_size != 0) { + LOG_FATAL( + "The config file_cache_each_block_size {} must less than or equal to config " + "s3_write_buffer_size {} and config::s3_write_buffer_size % " + "config::file_cache_each_block_size must be zero", + config::file_cache_each_block_size, config::s3_write_buffer_size); + exit(-1); + } std::unordered_set cache_path_set; std::vector cache_paths; Status rest = doris::parse_conf_cache_paths(doris::config::file_cache_path, cache_paths); @@ -617,6 +626,7 @@ void ExecEnv::destroy() { _buffered_reader_prefetch_thread_pool.reset(nullptr); _s3_file_upload_thread_pool.reset(nullptr); _send_batch_thread_pool.reset(nullptr); + _file_cache_open_fd_cache.reset(nullptr); SAFE_DELETE(_broker_client_cache); SAFE_DELETE(_frontend_client_cache); diff --git a/be/test/io/cache/block_file_cache_test.cpp b/be/test/io/cache/block_file_cache_test.cpp index a3ac893ca7eee0a..cd54361fafcebe2 100644 --- a/be/test/io/cache/block_file_cache_test.cpp +++ b/be/test/io/cache/block_file_cache_test.cpp @@ -128,6 +128,7 @@ class BlockFileCacheTest : public testing::Test { ASSERT_TRUE(writer->close().ok()); } ExecEnv::GetInstance()->_file_cache_factory = factory.get(); + ExecEnv::GetInstance()->_file_cache_open_fd_cache = std::make_unique(); } static void TearDownTestSuite() { config::file_cache_enter_disk_resource_limit_mode_percent = 90;