[improvement](session variable)Add enable_file_cache session variable (#16268)
Add enable_file_cache session variable, so that we can close file cache without restart BE.
This commit is contained in:
@ -35,6 +35,7 @@
|
||||
#include "io/local_file_writer.h"
|
||||
#include "io/s3_reader.h"
|
||||
#include "io/s3_writer.h"
|
||||
#include "olap/iterators.h"
|
||||
#include "runtime/exec_env.h"
|
||||
#include "runtime/stream_load/load_stream_mgr.h"
|
||||
#include "runtime/stream_load/new_load_stream_mgr.h"
|
||||
@ -155,7 +156,7 @@ Status FileFactory::create_file_reader(RuntimeProfile* /*profile*/,
|
||||
io::FileReaderSPtr* file_reader, IOContext* io_ctx) {
|
||||
TFileType::type type = system_properties.system_type;
|
||||
auto cache_policy = io::FileCachePolicy::NO_CACHE;
|
||||
if (config::enable_file_cache) {
|
||||
if (config::enable_file_cache && io_ctx->enable_file_cache) {
|
||||
cache_policy = io::FileCachePolicy::FILE_BLOCK_CACHE;
|
||||
}
|
||||
io::FileReaderOptions reader_options(cache_policy, io::FileBlockCachePathPolicy());
|
||||
|
||||
@ -38,18 +38,20 @@ struct IOContext {
|
||||
IOContext() = default;
|
||||
|
||||
IOContext(const TUniqueId* query_id_, FileCacheStatistics* stats_, bool is_presistent_,
|
||||
bool use_disposable_cache_, bool read_segment_index_)
|
||||
bool use_disposable_cache_, bool read_segment_index_, bool enable_file_cache)
|
||||
: query_id(query_id_),
|
||||
is_persistent(is_presistent_),
|
||||
use_disposable_cache(use_disposable_cache_),
|
||||
read_segment_index(read_segment_index_),
|
||||
file_cache_stats(stats_) {}
|
||||
file_cache_stats(stats_),
|
||||
enable_file_cache(enable_file_cache) {}
|
||||
ReaderType reader_type;
|
||||
const TUniqueId* query_id = nullptr;
|
||||
bool is_persistent = false;
|
||||
bool use_disposable_cache = false;
|
||||
bool read_segment_index = false;
|
||||
FileCacheStatistics* file_cache_stats = nullptr;
|
||||
bool enable_file_cache = true;
|
||||
};
|
||||
namespace vectorized {
|
||||
struct IteratorRowRef;
|
||||
|
||||
@ -77,6 +77,7 @@ Status VFileScanner::prepare(
|
||||
_io_ctx.reset(new IOContext());
|
||||
_io_ctx->file_cache_stats = _file_cache_statistics.get();
|
||||
_io_ctx->query_id = &_state->query_id();
|
||||
_io_ctx->enable_file_cache = _state->query_options().enable_file_cache;
|
||||
|
||||
if (vconjunct_ctx_ptr != nullptr) {
|
||||
// Copy vconjunct_ctx_ptr from scan node to this scanner's _vconjunct_ctx.
|
||||
|
||||
@ -567,3 +567,7 @@ Translated with www.DeepL.com/Translator (free version)
|
||||
* `group_by_and_having_use_alias_first`
|
||||
|
||||
Specifies whether group by and having clauses use column aliases rather than searching for column name in From clause. The default value is false.
|
||||
|
||||
* `enable_file_cache`
|
||||
|
||||
Set wether to use block file cache. This variable takes effect only if the BE config enable_file_cache=true. The cache is not used when BE config enable_file_cache=false.
|
||||
|
||||
@ -555,4 +555,8 @@ SELECT /*+ SET_VAR(query_timeout = 1, enable_partition_cache=true) */ sleep(3);
|
||||
* `group_by_and_having_use_alias_first`
|
||||
|
||||
指定group by和having语句是否优先使用列的别名,而非从From语句里寻找列的名字。默认为false。
|
||||
|
||||
* `enable_file_cache`
|
||||
|
||||
控制是否启用block file cache。该变量只有在be.conf中enable_file_cache=true时才有效,如果be.conf中enable_file_cache=false,则block file cache一直处于禁用状态。
|
||||
|
||||
|
||||
@ -259,6 +259,7 @@ public class SessionVariable implements Serializable, Writable {
|
||||
|
||||
public static final String ENABLE_TWO_PHASE_READ_OPT = "enable_two_phase_read_opt";
|
||||
public static final String TWO_PHASE_READ_OPT_LIMIT_THRESHOLD = "two_phase_read_opt_limit_threshold";
|
||||
public static final String ENABLE_FILE_CACHE = "enable_file_cache";
|
||||
|
||||
public static final String GROUP_BY_AND_HAVING_USE_ALIAS_FIRST = "group_by_and_having_use_alias_first";
|
||||
|
||||
@ -686,6 +687,10 @@ public class SessionVariable implements Serializable, Writable {
|
||||
@VariableMgr.VarAttr(name = GROUP_BY_AND_HAVING_USE_ALIAS_FIRST)
|
||||
public boolean groupByAndHavingUseAliasFirst = false;
|
||||
|
||||
// Whether enable block file cache. Only take effect when BE config item enable_file_cache is true.
|
||||
@VariableMgr.VarAttr(name = ENABLE_FILE_CACHE, needForward = true)
|
||||
public boolean enableFileCache = true;
|
||||
|
||||
// If this fe is in fuzzy mode, then will use initFuzzyModeVariables to generate some variables,
|
||||
// not the default value set in the code.
|
||||
public void initFuzzyModeVariables() {
|
||||
@ -1388,6 +1393,14 @@ public class SessionVariable implements Serializable, Writable {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEnableFileCache() {
|
||||
return enableFileCache;
|
||||
}
|
||||
|
||||
public void setEnableFileCache(boolean enableFileCache) {
|
||||
this.enableFileCache = enableFileCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize to thrift object.
|
||||
* Used for rest api.
|
||||
@ -1450,6 +1463,8 @@ public class SessionVariable implements Serializable, Writable {
|
||||
|
||||
tResult.setExternalSortBytesThreshold(externalSortBytesThreshold);
|
||||
|
||||
tResult.setEnableFileCache(enableFileCache);
|
||||
|
||||
return tResult;
|
||||
}
|
||||
|
||||
|
||||
@ -192,6 +192,8 @@ struct TQueryOptions {
|
||||
58: optional i64 external_sort_bytes_threshold = 0
|
||||
|
||||
59: optional i32 partitioned_hash_agg_rows_threshold = 0
|
||||
|
||||
60: optional bool enable_file_cache = true
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user