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

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 91e9da6905b [Fix](timezone) Introduce a config to use Doris tzdata 
directly (#31561) (#31573)
91e9da6905b is described below

commit 91e9da6905bc4873df3e800b862aaf8216e5091c
Author: zclllyybb <[email protected]>
AuthorDate: Thu Mar 7 11:36:45 2024 +0800

    [Fix](timezone) Introduce a config to use Doris tzdata directly (#31561) 
(#31573)
---
 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 | 11 ++++++++++-
 docs/zh-CN/docs/advanced/time-zone.md            |  4 ++--
 7 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp
index 728f0e005d9..1619cdaf2b4 100644
--- a/be/src/common/config.cpp
+++ b/be/src/common/config.cpp
@@ -1104,6 +1104,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");
 
 // the max package bytes be thrift server can receive
 // avoid accepting error or too large package causing OOM,default 20000000(20M)
diff --git a/be/src/common/config.h b/be/src/common/config.h
index 29d6d56fb80..a46ef7ed646 100644
--- a/be/src/common/config.h
+++ b/be/src/common/config.h
@@ -1158,6 +1158,7 @@ DECLARE_Bool(ignore_always_true_predicate_for_segment);
 
 // Dir of default timezone files
 DECLARE_String(default_tzfiles_path);
+DECLARE_Bool(use_doris_tzfile);
 
 // the max package bytes be thrift server can receive
 // avoid accepting error or too large package causing OOM,default 20000000(20M)
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 c11d03345a1..a46411ddf5d 100644
--- a/docs/en/docs/admin-manual/config/be-config.md
+++ b/docs/en/docs/admin-manual/config/be-config.md
@@ -1500,3 +1500,13 @@ Indicates how many tablets failed to load in the data 
directory. At the same tim
 
 * Description: BE Whether to enable the use of java-jni. When enabled, mutual 
calls between c++ and java are allowed. Currently supports hudi, java-udf, 
jdbc, max-compute, paimon, preload, avro
 * Default value: true
+
+#### `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 7e1259c7f48..7c8d9657dbc 100644
--- a/docs/zh-CN/docs/admin-manual/config/be-config.md
+++ b/docs/zh-CN/docs/admin-manual/config/be-config.md
@@ -1530,8 +1530,17 @@ load tablets from header failed, failed tablets size: 
xxx, path=xxx
 * Description: BE 是否开启使用java-jni,开启后允许 c++  与 java 
之间的相互调用。目前已经支持hudi、java-udf、jdbc、max-compute、paimon、preload、avro
 * Default value: true
 
-
 #### `be_thrift_max_pkg_bytes`
 
 * 描述: be节点thrift端口最大接收包大小(字节)
 * 默认值: 20000000
+
+#### `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]

Reply via email to