This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 82add8dfc1b12441edf9659a0e1825b7123579df Author: zclllyybb <[email protected]> AuthorDate: Thu Feb 29 11:04:57 2024 +0800 [Fix](timezone) Introduce a config to use Doris tzdata directly (#31561) --- be/src/common/config.cpp | 1 + be/src/common/config.h | 1 + be/src/util/timezone_utils.cpp | 13 +++++++++---- docs/en/docs/admin-manual/config/be-config.md | 10 ++++++++++ docs/en/docs/advanced/time-zone.md | 4 ++-- docs/zh-CN/docs/admin-manual/config/be-config.md | 10 ++++++++++ docs/zh-CN/docs/advanced/time-zone.md | 4 ++-- 7 files changed, 35 insertions(+), 8 deletions(-) diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp index b49b95e8e5d..a433b7ee8a1 100644 --- a/be/src/common/config.cpp +++ b/be/src/common/config.cpp @@ -1141,6 +1141,7 @@ DEFINE_Bool(ignore_always_true_predicate_for_segment, "true"); // Dir of default timezone files DEFINE_String(default_tzfiles_path, "${DORIS_HOME}/zoneinfo"); +DEFINE_Bool(use_doris_tzfile, "false"); // Ingest binlog work pool size, -1 is disable, 0 is hardware concurrency DEFINE_Int32(ingest_binlog_work_pool_size, "-1"); diff --git a/be/src/common/config.h b/be/src/common/config.h index c82d42a9ef4..5c298f906c1 100644 --- a/be/src/common/config.h +++ b/be/src/common/config.h @@ -1217,6 +1217,7 @@ DECLARE_Bool(ignore_always_true_predicate_for_segment); // Dir of default timezone files DECLARE_String(default_tzfiles_path); +DECLARE_Bool(use_doris_tzfile); // Ingest binlog work pool size DECLARE_Int32(ingest_binlog_work_pool_size); diff --git a/be/src/util/timezone_utils.cpp b/be/src/util/timezone_utils.cpp index d3f6ff9af4c..16827a6504c 100644 --- a/be/src/util/timezone_utils.cpp +++ b/be/src/util/timezone_utils.cpp @@ -82,6 +82,9 @@ void TimezoneUtils::load_timezone_names() { path = config::default_tzfiles_path + '/'; CHECK(std::filesystem::exists(path)) << "Can't find system tzfiles or default tzfiles neither."; + } else if (config::use_doris_tzfile) { + path = config::default_tzfiles_path + '/'; + LOG(INFO) << "Directly use Doris' tzfiles in " << path; } auto path_prefix_len = path.size(); @@ -239,12 +242,14 @@ void TimezoneUtils::load_timezones_to_cache() { base_str += tzdir; base_str += '/'; - auto root_path = std::filesystem::path {base_str}; - if (!std::filesystem::exists(root_path)) { + if (!std::filesystem::exists(base_str)) { LOG_WARNING("Cannot find system tzfile. Use default instead."); - root_path = config::default_tzfiles_path + '/'; - CHECK(std::filesystem::exists(root_path)) + base_str = config::default_tzfiles_path + '/'; + CHECK(std::filesystem::exists(base_str)) << "Can't find system tzfiles or default tzfiles neither."; + } else if (config::use_doris_tzfile) { + base_str = config::default_tzfiles_path + '/'; + LOG(INFO) << "Directly use Doris' tzfiles in " << base_str; } std::set<std::string> ignore_paths = {"posix", "right"}; // duplications diff --git a/docs/en/docs/admin-manual/config/be-config.md b/docs/en/docs/admin-manual/config/be-config.md index d364e1b7b56..4f233ed92f9 100644 --- a/docs/en/docs/admin-manual/config/be-config.md +++ b/docs/en/docs/admin-manual/config/be-config.md @@ -1495,3 +1495,13 @@ Indicates how many tablets failed to load in the data directory. At the same tim * Description: The `max_filter_ratio` limit can only work if the total rows of `group commit` is less than this value. See [Group Commit](../../data-operate/import/import-way/group-commit-manual.md) for more details * Default: 10000 + +#### `default_tzfiles_path` + +* Description: Doris comes with its own time zone database. If the time zone file is not found in the system directory, the data in that directory is enabled. +* Default: "${DORIS_HOME}/zoneinfo" + +#### `use_doris_tzfile` + +* Description: Whether to use the time zone database that comes with Doris directly. Enabled to stop trying to find in the system directory. +* Default: false diff --git a/docs/en/docs/advanced/time-zone.md b/docs/en/docs/advanced/time-zone.md index 7fa30c855db..6a102abe893 100644 --- a/docs/en/docs/advanced/time-zone.md +++ b/docs/en/docs/advanced/time-zone.md @@ -50,9 +50,9 @@ The following two time zone related parameters exist within Doris: The time zone data contains the name of the time zone, the corresponding time offset, and the change of daylight saving time. On the machine where the BE is located, the sources of the data are as follows: 1. the directory returned by command `TZDIR`. If was not supported, the directory `/usr/share/zoneinfo`. -2. the `zoneinfo` directory generated under the doris BE deployment directory. The `resource/zoneinfo.tar.gz` directory from the doris repository. +2. the `zoneinfo` directory generated under the Doris BE deployment directory. The `resource/zoneinfo.tar.gz` directory from the Doris Repository. -Look up the above data sources in order and use the current item if found. If neither is found, the doris BE will fail to start, please rebuild the BE correctly or get the distribution. +Look up the above data sources in order and use the current item if found. If the BE configuration item `use_doris_tzfile` is true, the search for the first item is skipped. If neither is found, the Doris BE will fail to start, please rebuild the BE correctly or get the distribution. ## Impact of time zone diff --git a/docs/zh-CN/docs/admin-manual/config/be-config.md b/docs/zh-CN/docs/admin-manual/config/be-config.md index 0a07e704450..471fbe7a216 100644 --- a/docs/zh-CN/docs/admin-manual/config/be-config.md +++ b/docs/zh-CN/docs/admin-manual/config/be-config.md @@ -1525,3 +1525,13 @@ load tablets from header failed, failed tablets size: xxx, path=xxx * 描述: 当 group commit 导入的总行数不高于该值,`max_filter_ratio` 正常工作,否则不工作,请参考 [Group Commit](../../data-operate/import/import-way/group-commit-manual.md) * 默认值: 10000 + +#### `default_tzfiles_path` + +* 描述:Doris 自带的时区数据库。如果系统目录下未找到时区文件,则启用该目录下的数据。 +* 默认值:"${DORIS_HOME}/zoneinfo" + +#### `use_doris_tzfile` + +* 描述:是否直接使用 Doris 自带的时区数据库。开启后不再尝试查找系统目录。 +* 默认值:false diff --git a/docs/zh-CN/docs/advanced/time-zone.md b/docs/zh-CN/docs/advanced/time-zone.md index d0e65fd4c3d..d1e8ffe4be5 100644 --- a/docs/zh-CN/docs/advanced/time-zone.md +++ b/docs/zh-CN/docs/advanced/time-zone.md @@ -50,9 +50,9 @@ Doris 内部存在以下两个时区相关参数: 时区数据包含时区名、对应时间偏移量、夏令时变化情况等。在 BE 所在机器上,其数据来源依次为: 1. `TZDIR` 命令返回的目录,如不支持该命令,则为 `/usr/share/zoneinfo` 目录 -2. doris BE 部署目录下生成的 `zoneinfo` 目录。来自 doris repository 下的 `resource/zoneinfo.tar.gz` +2. Doris BE 部署目录下生成的 `zoneinfo` 目录。产生自 Doris Repository 下的 `resource/zoneinfo.tar.gz` -按顺序查找以上数据源,如果找到则使用当前项。两项均未找到,则 doris BE 将启动失败,请重新正确构建 BE 或获取发行版。 +按顺序查找以上数据源,如果找到则使用当前项。如果 BE 配置项 `use_doris_tzfile` 为 true,则跳过对第一项的查找。如均未找到,则 Doris BE 将启动失败,请重新正确构建 BE 或获取发行版。 ## 时区的影响 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
