Merge branch '3.0' of https://github.com/taosdata/TDengine into feat/TD-26056
This commit is contained in:
commit
b04d57fcc3
|
@ -83,6 +83,16 @@ ELSE ()
|
||||||
SET(TAOS_LIB taos)
|
SET(TAOS_LIB taos)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
# build TSZ by default
|
||||||
|
IF ("${TSZ_ENABLED}" MATCHES "false")
|
||||||
|
set(VAR_TSZ "" CACHE INTERNAL "global variant empty" )
|
||||||
|
ELSE()
|
||||||
|
# define add
|
||||||
|
MESSAGE(STATUS "build with TSZ enabled")
|
||||||
|
ADD_DEFINITIONS(-DTD_TSZ)
|
||||||
|
set(VAR_TSZ "TSZ" CACHE INTERNAL "global variant tsz" )
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
IF (TD_WINDOWS)
|
IF (TD_WINDOWS)
|
||||||
MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
|
MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
|
||||||
SET(COMMON_FLAGS "/w /D_WIN32 /DWIN32 /Zi /MTd")
|
SET(COMMON_FLAGS "/w /D_WIN32 /DWIN32 /Zi /MTd")
|
||||||
|
|
|
@ -195,6 +195,20 @@ if (TD_LINUX)
|
||||||
ELSE()
|
ELSE()
|
||||||
set(TD_DEPS_DIR "x86")
|
set(TD_DEPS_DIR "x86")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
elseif (TD_DARWIN)
|
||||||
|
IF (TD_ARM_64 OR TD_ARM_32)
|
||||||
|
set(TD_DEPS_DIR "darwin/arm")
|
||||||
|
ELSE ()
|
||||||
|
set(TD_DEPS_DIR "darwin/x64")
|
||||||
|
ENDIF ()
|
||||||
|
elseif (TD_WINDOWS)
|
||||||
|
IF (TD_WINDOWS_64)
|
||||||
|
set(TD_DEPS_DIR "win/x64")
|
||||||
|
ELSEIF (TD_WINDOWS_32)
|
||||||
|
set(TD_DEPS_DIR "win/i386")
|
||||||
|
ENDIF ()
|
||||||
|
else ()
|
||||||
|
MESSAGE(FATAL_ERROR "unsupported platform")
|
||||||
endif()
|
endif()
|
||||||
MESSAGE(STATUS "DEPS_DIR: " ${TD_DEPS_DIR})
|
MESSAGE(STATUS "DEPS_DIR: " ${TD_DEPS_DIR})
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# curl
|
# curl
|
||||||
ExternalProject_Add(curl
|
ExternalProject_Add(curl
|
||||||
URL https://curl.se/download/curl-8.2.1.tar.gz
|
URL https://curl.se/download/curl-8.2.1.tar.gz
|
||||||
|
URL_HASH MD5=b25588a43556068be05e1624e0e74d41
|
||||||
DOWNLOAD_NO_PROGRESS 1
|
DOWNLOAD_NO_PROGRESS 1
|
||||||
DOWNLOAD_DIR "${TD_CONTRIB_DIR}/deps-download"
|
DOWNLOAD_DIR "${TD_CONTRIB_DIR}/deps-download"
|
||||||
#GIT_REPOSITORY https://github.com/curl/curl.git
|
#GIT_REPOSITORY https://github.com/curl/curl.git
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -23,20 +23,30 @@ By subscribing to a topic, a consumer can obtain the latest data in that topic i
|
||||||
|
|
||||||
To implement these features, TDengine indexes its write-ahead log (WAL) file for fast random access and provides configurable methods for replacing and retaining this file. You can define a retention period and size for this file. For information, see the CREATE DATABASE statement. In this way, the WAL file is transformed into a persistent storage engine that remembers the order in which events occur. However, note that configuring an overly long retention period for your WAL files makes database compression inefficient. TDengine then uses the WAL file instead of the time-series database as its storage engine for queries in the form of topics. TDengine reads the data from the WAL file; uses a unified query engine instance to perform filtering, transformations, and other operations; and finally pushes the data to consumers.
|
To implement these features, TDengine indexes its write-ahead log (WAL) file for fast random access and provides configurable methods for replacing and retaining this file. You can define a retention period and size for this file. For information, see the CREATE DATABASE statement. In this way, the WAL file is transformed into a persistent storage engine that remembers the order in which events occur. However, note that configuring an overly long retention period for your WAL files makes database compression inefficient. TDengine then uses the WAL file instead of the time-series database as its storage engine for queries in the form of topics. TDengine reads the data from the WAL file; uses a unified query engine instance to perform filtering, transformations, and other operations; and finally pushes the data to consumers.
|
||||||
|
|
||||||
Tips:(c interface for example)
|
The following are some explanations about data subscription, which require some understanding of the architecture of TDengine and the use of various language linker interfaces.
|
||||||
1. A consumption group consumes all data under the same topic, and different consumption groups are independent of each other;
|
- A consumption group consumes all data under the same topic, and different consumption groups are independent of each other;
|
||||||
2. A consumption group consumes all vgroups of the same topic, which can be composed of multiple consumers, but a vgroup is only consumed by one consumer. If the number of consumers exceeds the number of vgroups, the excess consumers do not consume data;
|
- A consumption group consumes all vgroups of the same topic, which can be composed of multiple consumers, but a vgroup is only consumed by one consumer. If the number of consumers exceeds the number of vgroups, the excess consumers do not consume data;
|
||||||
3. On the server side, only one offset is saved for each vgroup, and the offsets for each vgroup are monotonically increasing, but not necessarily continuous. There is no correlation between the offsets of various vgroups;
|
- On the server side, only one offset is saved for each vgroup, and the offsets for each vgroup are monotonically increasing, but not necessarily continuous. There is no correlation between the offsets of various vgroups;
|
||||||
4. Each poll server will return a result block, which belongs to a vgroup and may contain data from multiple versions of wal. This block can be accessed through tmq_get_vgroup_offset. The offset interface obtains the offset of the first record in the block;
|
- Each poll server will return a result block, which belongs to a vgroup and may contain data from multiple versions of wal. This block can be accessed through offset interface. The offset interface obtains the offset of the first record in the block;
|
||||||
5. If a consumer group has never committed an offset, when its member consumers restart and pull data again, they start consuming from the set value of the parameter auto.offset.reset; In a consumer lifecycle, the client locally records the offset of the most recent pull data and will not pull duplicate data;
|
- If a consumer group has never committed an offset, when its member consumers restart and pull data again, they start consuming from the set value of the parameter auto.offset.reset; In a consumer lifecycle, the client locally records the offset of the most recent pull data and will not pull duplicate data;
|
||||||
6. If a consumer terminates abnormally (without calling tmq_close), they need to wait for about 12 seconds to trigger their consumer group rebalance. The consumer's status on the server will change to LOST, and after about 1 day, the consumer will be automatically deleted; Exit normally, and after exiting, the consumer will be deleted; Add a new consumer, wait for about 2 seconds to trigger Rebalance, and the consumer's status on the server will change to ready;
|
- If a consumer terminates abnormally (without calling tmq_close), they need to wait for about 12 seconds to trigger their consumer group rebalance. The consumer's status on the server will change to LOST, and after about 1 day, the consumer will be automatically deleted; Exit normally, and after exiting, the consumer will be deleted; Add a new consumer, wait for about 2 seconds to trigger Rebalance, and the consumer's status on the server will change to ready;
|
||||||
7. The consumer group Rebalance will reassign Vgroups to all consumer members in the ready state of the group, and consumers can only assign/see/commit/poll operations to the Vgroups they are responsible for;
|
- The consumer group Rebalance will reassign Vgroups to all consumer members in the ready state of the group, and consumers can only assign/see/commit/poll operations to the Vgroups they are responsible for;
|
||||||
8. Consumers can tmq_position to obtain the offset of the current consumption, seek to the specified offset, and consume again;
|
- Consumers can call position interface to obtain the offset of the current consumption, seek to the specified offset, and consume again;
|
||||||
9. Seek points the position to the specified offset without executing the commit operation. Once the seek is successful, it can poll the specified offset and subsequent data;
|
- Seek points the position to the specified offset without executing the commit operation. Once the seek is successful, it can poll the specified offset and subsequent data;
|
||||||
10. Before the seek operation, tmq must be call tmq_get_topic_assignment, The assignment interface obtains the vgroup ID and offset range of the consumer. The seek operation will detect whether the vgroup ID and offset are legal, and if they are illegal, an error will be reported;
|
- Position is to obtain the current consumption position, which is the position to be taken next time, not the current consumption position
|
||||||
11. Due to the existence of a WAL expiration deletion mechanism, even if the seek operation is successful, it is possible that the offset has expired when polling data. If the offset of poll is less than the WAL minimum version number, it will be consumed from the WAL minimum version number;
|
- Commit is the submission of the consumption location. Without parameters, it is the submission of the current consumption location (the location to be taken next time, not the current consumption location). With parameters, it is the location in the submission parameters (i.e. the location to be taken after the next exit and restart)
|
||||||
12. The tmq_get_vgroup_offset interface obtains the offset of the first data in the result block where the record is located. When seeking to this offset, it will consume all the data in this block. Refer to point four;
|
- Seek is to set the consumer's consumption position. Wherever the seek goes, the position will be returned, all of which are the positions to be taken next time
|
||||||
13. Data subscription is to consume data from the wal. If some wal files are deleted according to WAL retention policy, the deleted data can't be consumed any more. So you need to set a reasonable value for parameter `WAL_RETENTION_PERIOD` or `WAL_RETENTION_SIZE` when creating the database and make sure your application consume the data in a timely way to make sure there is no data loss. This behavior is similar to Kafka and other widely used message queue products.
|
- Seek does not affect commit, commit does not affect seek, independent of each other, the two are different concepts
|
||||||
|
- The begin interface is the offset of the first data in wal, and the end interface is the offset+1 of the last data in wal10.
|
||||||
|
- Before the seek operation, tmq must be call assignment interface, The assignment interface obtains the vgroup ID and offset range of the consumer. The seek operation will detect whether the vgroup ID and offset are legal, and if they are illegal, an error will be reported;
|
||||||
|
- Due to the existence of a WAL expiration deletion mechanism, even if the seek operation is successful, it is possible that the offset has expired when polling data. If the offset of poll is less than the WAL minimum version number, it will be consumed from the WAL minimum version number;
|
||||||
|
- The offset interface obtains the offset of the first data in the result block where the record is located. When seeking to this offset, it will consume all the data in this block. Refer to point four;
|
||||||
|
- Data subscription is to consume data from the wal. If some wal files are deleted according to WAL retention policy, the deleted data can't be consumed any more. So you need to set a reasonable value for parameter `WAL_RETENTION_PERIOD` or `WAL_RETENTION_SIZE` when creating the database and make sure your application consume the data in a timely way to make sure there is no data loss. This behavior is similar to Kafka and other widely used message queue products.
|
||||||
|
|
||||||
|
This document does not provide any further introduction to the knowledge of message queues themselves. If you need to know more, please search for it yourself.
|
||||||
|
|
||||||
|
Starting from version 3.2.0.0, data subscription supports vnode migration and splitting.
|
||||||
|
Due to the dependence of data subscription on wal files, wal does not synchronize during vnode migration and splitting. Therefore, after migration or splitting, wal data that has not been consumed before cannot be consumed. So please ensure that all data has been consumed before proceeding with vnode migration or splitting, otherwise data loss may occur during consumption.
|
||||||
|
|
||||||
## Data Schema and API
|
## Data Schema and API
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ database_option: {
|
||||||
- WAL_FSYNC_PERIOD: specifies the interval (in milliseconds) at which data is written from the WAL to disk. This parameter takes effect only when the WAL parameter is set to 2. The default value is 3000. Enter a value between 0 and 180000. The value 0 indicates that incoming data is immediately written to disk.
|
- WAL_FSYNC_PERIOD: specifies the interval (in milliseconds) at which data is written from the WAL to disk. This parameter takes effect only when the WAL parameter is set to 2. The default value is 3000. Enter a value between 0 and 180000. The value 0 indicates that incoming data is immediately written to disk.
|
||||||
- MAXROWS: specifies the maximum number of rows recorded in a block. The default value is 4096.
|
- MAXROWS: specifies the maximum number of rows recorded in a block. The default value is 4096.
|
||||||
- MINROWS: specifies the minimum number of rows recorded in a block. The default value is 100.
|
- MINROWS: specifies the minimum number of rows recorded in a block. The default value is 100.
|
||||||
- KEEP: specifies the time for which data is retained. Enter a value between 1 and 365000. The default value is 3650. The value of the KEEP parameter must be greater than or equal to the value of the DURATION parameter. TDengine automatically deletes data that is older than the value of the KEEP parameter. You can use m (minutes), h (hours), and d (days) as the unit, for example KEEP 100h or KEEP 10d. If you do not include a unit, d is used by default. TDengine Enterprise supports [Tiered Storage](https://docs.tdengine.com/tdinternal/arch/#tiered-storage) function, thus multiple KEEP values (comma separated and up to 3 values supported, and meet keep 0 <= keep 1 <= keep 2, e.g. KEEP 100h,100d,3650d) are supported; TDengine OSS does not support Tiered Storage function (although multiple keep values are configured, they do not take effect, only the maximum keep value is used as KEEP).
|
- KEEP: specifies the time for which data is retained. Enter a value between 1 and 365000. The default value is 3650. The value of the KEEP parameter must be greater than or equal to three times of the value of the DURATION parameter. TDengine automatically deletes data that is older than the value of the KEEP parameter. You can use m (minutes), h (hours), and d (days) as the unit, for example KEEP 100h or KEEP 10d. If you do not include a unit, d is used by default. TDengine Enterprise supports [Tiered Storage](https://docs.tdengine.com/tdinternal/arch/#tiered-storage) function, thus multiple KEEP values (comma separated and up to 3 values supported, and meet keep 0 <= keep 1 <= keep 2, e.g. KEEP 100h,100d,3650d) are supported; TDengine OSS does not support Tiered Storage function (although multiple keep values are configured, they do not take effect, only the maximum keep value is used as KEEP).
|
||||||
- PAGES: specifies the number of pages in the metadata storage engine cache on each vnode. Enter a value greater than or equal to 64. The default value is 256. The space occupied by metadata storage on each vnode is equal to the product of the values of the PAGESIZE and PAGES parameters. The space occupied by default is 1 MB.
|
- PAGES: specifies the number of pages in the metadata storage engine cache on each vnode. Enter a value greater than or equal to 64. The default value is 256. The space occupied by metadata storage on each vnode is equal to the product of the values of the PAGESIZE and PAGES parameters. The space occupied by default is 1 MB.
|
||||||
- PAGESIZE: specifies the size (in KB) of each page in the metadata storage engine cache on each vnode. The default value is 4. Enter a value between 1 and 16384.
|
- PAGESIZE: specifies the size (in KB) of each page in the metadata storage engine cache on each vnode. The default value is 4. Enter a value between 1 and 16384.
|
||||||
- PRECISION: specifies the precision at which a database records timestamps. Enter ms for milliseconds, us for microseconds, or ns for nanoseconds. The default value is ms.
|
- PRECISION: specifies the precision at which a database records timestamps. Enter ms for milliseconds, us for microseconds, or ns for nanoseconds. The default value is ms.
|
||||||
|
|
|
@ -731,16 +731,6 @@ The charset that takes effect is UTF-8.
|
||||||
| Value Range | 0: not change; 1: change by modification |
|
| Value Range | 0: not change; 1: change by modification |
|
||||||
| Default Value | 0 |
|
| Default Value | 0 |
|
||||||
|
|
||||||
### keepTimeOffset
|
|
||||||
|
|
||||||
| Attribute | Description |
|
|
||||||
| ------------- | ------------------------- |
|
|
||||||
| Applicable | Server Only |
|
|
||||||
| Meaning | Latency of data migration |
|
|
||||||
| Unit | hour |
|
|
||||||
| Value Range | 0-23 |
|
|
||||||
| Default Value | 0 |
|
|
||||||
|
|
||||||
### tmqMaxTopicNum
|
### tmqMaxTopicNum
|
||||||
|
|
||||||
| Attribute | Description |
|
| Attribute | Description |
|
||||||
|
@ -807,4 +797,4 @@ The charset that takes effect is UTF-8.
|
||||||
| 53 | udf | Yes | Yes | |
|
| 53 | udf | Yes | Yes | |
|
||||||
| 54 | enableCoreFile | Yes | Yes | |
|
| 54 | enableCoreFile | Yes | Yes | |
|
||||||
| 55 | ttlChangeOnWrite | No | Yes | |
|
| 55 | ttlChangeOnWrite | No | Yes | |
|
||||||
| 56 | keepTimeOffset | Yes | Yes | |
|
| 56 | keepTimeOffset | Yes | Yes(discarded since 3.2.0.0) | |
|
||||||
|
|
|
@ -23,22 +23,30 @@ import CDemo from "./_sub_c.mdx";
|
||||||
|
|
||||||
为了实现上述功能,TDengine 会为 WAL (Write-Ahead-Log) 文件自动创建索引以支持快速随机访问,并提供了灵活可配置的文件切换与保留机制:用户可以按需指定 WAL 文件保留的时间以及大小(详见 create database 语句)。通过以上方式将 WAL 改造成了一个保留事件到达顺序的、可持久化的存储引擎(但由于 TSDB 具有远比 WAL 更高的压缩率,我们不推荐保留太长时间,一般来说,不超过几天)。 对于以 topic 形式创建的查询,TDengine 将对接 WAL 而不是 TSDB 作为其存储引擎。在消费时,TDengine 根据当前消费进度从 WAL 直接读取数据,并使用统一的查询引擎实现过滤、变换等操作,将数据推送给消费者。
|
为了实现上述功能,TDengine 会为 WAL (Write-Ahead-Log) 文件自动创建索引以支持快速随机访问,并提供了灵活可配置的文件切换与保留机制:用户可以按需指定 WAL 文件保留的时间以及大小(详见 create database 语句)。通过以上方式将 WAL 改造成了一个保留事件到达顺序的、可持久化的存储引擎(但由于 TSDB 具有远比 WAL 更高的压缩率,我们不推荐保留太长时间,一般来说,不超过几天)。 对于以 topic 形式创建的查询,TDengine 将对接 WAL 而不是 TSDB 作为其存储引擎。在消费时,TDengine 根据当前消费进度从 WAL 直接读取数据,并使用统一的查询引擎实现过滤、变换等操作,将数据推送给消费者。
|
||||||
|
|
||||||
本文档不对消息队列本身的基础知识做介绍,如果需要了解,请自行搜索。
|
下面为关于数据订阅的一些说明,需要对TDengine的架构有一些了解,结合各个语言链接器的接口使用。
|
||||||
|
- 一个消费组消费同一个topic下的所有数据,不同消费组之间相互独立;
|
||||||
|
- 一个消费组消费同一个topic所有的vgroup,消费组可由多个消费者组成,但一个vgroup仅被一个消费者消费,如果消费者数量超过了vgroup数量,多余的消费者不消费数据;
|
||||||
|
- 在服务端每个vgroup仅保存一个offset,每个vgroup的offset是单调递增的,但不一定连续。各个vgroup的offset之间没有关联;
|
||||||
|
- 每次poll服务端会返回一个结果block,该block属于一个vgroup,可能包含多个wal版本的数据,可以通过 offset 接口获得是该block第一条记录的offset;
|
||||||
|
- 一个消费组如果从未commit过offset,当其成员消费者重启重新拉取数据时,均从参数auto.offset.reset设定值开始消费;在一个消费者生命周期中,客户端本地记录了最近一次拉取数据的offset,不会拉取重复数据;
|
||||||
|
- 消费者如果异常终止(没有调用tmq_close),需等约12秒后触发其所属消费组rebalance,该消费者在服务端状态变为LOST,约1天后该消费者自动被删除;正常退出,退出后就会删除消费者;新增消费者,需等约2秒触发rebalance,该消费者在服务端状态变为ready;
|
||||||
|
- 消费组rebalance会对该组所有ready状态的消费者成员重新进行vgroup分配,消费者仅能对自己负责的vgroup进行assignment/seek/commit/poll操作;
|
||||||
|
- 消费者可利用 position 获得当前消费的offset,并seek到指定offset,重新消费;
|
||||||
|
- seek将position指向指定offset,不执行commit操作,一旦seek成功,可poll拉取指定offset及以后的数据;
|
||||||
|
- seek 操作之前须调用 assignment 接口获取该consumer的vgroup ID和offset范围。seek 操作会检测vgroup ID 和 offset是否合法,如非法将报错;
|
||||||
|
- position是获取当前的消费位置,是下次要取的位置,不是当前消费到的位置
|
||||||
|
- commit是提交消费位置,不带参数的话,是提交当前消费位置(下次要取的位置,不是当前消费到的位置),带参数的话,是提交参数里的位置(也即下次退出重启后要取的位置)
|
||||||
|
- seek是设置consumer消费位置,seek到哪,position就返回哪,都是下次要取的位置
|
||||||
|
- seek不会影响commit,commit不影响seek,相互独立,两个是不同的概念
|
||||||
|
- begin接口为wal 第一条数据的offset,end 接口为wal 最后一条数据的offset + 1
|
||||||
|
- offset接口获取的是记录所在结果block块里的第一条数据的offset,当seek至该offset时,将消费到这个block里的全部数据。参见第四点;
|
||||||
|
- 由于存在 WAL 过期删除机制,即使seek 操作成功,poll数据时有可能offset已失效。如果poll 的offset 小于 WAL 最小版本号,将会从WAL最小版本号消费;
|
||||||
|
- 数据订阅是从 WAL 消费数据,如果一些 WAL 文件被基于 WAL 保留策略删除,则已经删除的 WAL 文件中的数据就无法再消费到。需要根据业务需要在创建数据库时合理设置 `WAL_RETENTION_PERIOD` 或 `WAL_RETENTION_SIZE` ,并确保应用及时消费数据,这样才不会产生数据丢失的现象。数据订阅的行为与 Kafka 等广泛使用的消息队列类产品的行为相似;
|
||||||
|
|
||||||
说明(以c接口为例):
|
本文档不对消息队列本身的知识做更多的介绍,如果需要了解,请自行搜索。
|
||||||
1. 一个消费组消费同一个topic下的所有数据,不同消费组之间相互独立;
|
|
||||||
2. 一个消费组消费同一个topic所有的vgroup,消费组可由多个消费者组成,但一个vgroup仅被一个消费者消费,如果消费者数量超过了vgroup数量,多余的消费者不消费数据;
|
从3.2.0.0版本开始,数据订阅支持vnode迁移和分裂。
|
||||||
3. 在服务端每个vgroup仅保存一个offset,每个vgroup的offset是单调递增的,但不一定连续。各个vgroup的offset之间没有关联;
|
由于数据订阅依赖wal文件,而在vnode迁移和分裂的过程中,wal并不会同步过去,所以迁移或分裂后,之前没消费完的wal数据后消费不到。所以请保证之前把数据全部消费完后,再进行vnode迁移或分裂,否则,消费会丢失数据。
|
||||||
4. 每次poll服务端会返回一个结果block,该block属于一个vgroup,可能包含多个wal版本的数据,可以通过 tmq_get_vgroup_offset 接口获得是该block第一条记录的offset;
|
|
||||||
5. 一个消费组如果从未commit过offset,当其成员消费者重启重新拉取数据时,均从参数auto.offset.reset设定值开始消费;在一个消费者生命周期中,客户端本地记录了最近一次拉取数据的offset,不会拉取重复数据;
|
|
||||||
6. 消费者如果异常终止(没有调用tmq_close),需等约12秒后触发其所属消费组rebalance,该消费者在服务端状态变为LOST,约1天后该消费者自动被删除;正常退出,退出后就会删除消费者;新增消费者,需等约2秒触发rebalance,该消费者在服务端状态变为ready;
|
|
||||||
7. 消费组rebalance会对该组所有ready状态的消费者成员重新进行vgroup分配,消费者仅能对自己负责的vgroup进行assignment/seek/commit/poll操作;
|
|
||||||
8. 消费者可利用 tmq_position 获得当前消费的offset,并seek到指定offset,重新消费;
|
|
||||||
9. seek将position指向指定offset,不执行commit操作,一旦seek成功,可poll拉取指定offset及以后的数据;
|
|
||||||
10. seek 操作之前须调用 tmq_get_topic_assignment 接口获取该consumer的vgroup ID和offset范围。seek 操作会检测vgroup ID 和 offset是否合法,如非法将报错;
|
|
||||||
11. tmq_get_vgroup_offset接口获取的是记录所在结果block块里的第一条数据的offset,当seek至该offset时,将消费到这个block里的全部数据。参见第四点;
|
|
||||||
12. 由于存在 WAL 过期删除机制,即使seek 操作成功,poll数据时有可能offset已失效。如果poll 的offset 小于 WAL 最小版本号,将会从WAL最小版本号消费;
|
|
||||||
13. 数据订阅是从 WAL 消费数据,如果一些 WAL 文件被基于 WAL 保留策略删除,则已经删除的 WAL 文件中的数据就无法再消费到。需要根据业务需要在创建数据库时合理设置 `WAL_RETENTION_PERIOD` 或 `WAL_RETENTION_SIZE` ,并确保应用及时消费数据,这样才不会产生数据丢失的现象。数据订阅的行为与 Kafka 等广泛使用的消息队列类产品的行为相似;
|
|
||||||
|
|
||||||
## 主要数据结构和 API
|
## 主要数据结构和 API
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ database_option: {
|
||||||
- WAL_FSYNC_PERIOD:当 WAL 参数设置为 2 时,落盘的周期。默认为 3000,单位毫秒。最小为 0,表示每次写入立即落盘;最大为 180000,即三分钟。
|
- WAL_FSYNC_PERIOD:当 WAL 参数设置为 2 时,落盘的周期。默认为 3000,单位毫秒。最小为 0,表示每次写入立即落盘;最大为 180000,即三分钟。
|
||||||
- MAXROWS:文件块中记录的最大条数,默认为 4096 条。
|
- MAXROWS:文件块中记录的最大条数,默认为 4096 条。
|
||||||
- MINROWS:文件块中记录的最小条数,默认为 100 条。
|
- MINROWS:文件块中记录的最小条数,默认为 100 条。
|
||||||
- KEEP:表示数据文件保存的天数,缺省值为 3650,取值范围 [1, 365000],且必须大于或等于 DURATION 参数值。数据库会自动删除保存时间超过 KEEP 值的数据。KEEP 可以使用加单位的表示形式,如 KEEP 100h、KEEP 10d 等,支持 m(分钟)、h(小时)和 d(天)三个单位。也可以不写单位,如 KEEP 50,此时默认单位为天。企业版支持[多级存储](https://docs.taosdata.com/tdinternal/arch/#%E5%A4%9A%E7%BA%A7%E5%AD%98%E5%82%A8)功能, 因此, 可以设置多个保存时间(多个以英文逗号分隔,最多 3 个,满足 keep 0 <= keep 1 <= keep 2,如 KEEP 100h,100d,3650d); 社区版不支持多级存储功能(即使配置了多个保存时间, 也不会生效, KEEP 会取最大的保存时间)。
|
- KEEP:表示数据文件保存的天数,缺省值为 3650,取值范围 [1, 365000],且必须大于或等于3倍的 DURATION 参数值。数据库会自动删除保存时间超过 KEEP 值的数据。KEEP 可以使用加单位的表示形式,如 KEEP 100h、KEEP 10d 等,支持 m(分钟)、h(小时)和 d(天)三个单位。也可以不写单位,如 KEEP 50,此时默认单位为天。企业版支持[多级存储](https://docs.taosdata.com/tdinternal/arch/#%E5%A4%9A%E7%BA%A7%E5%AD%98%E5%82%A8)功能, 因此, 可以设置多个保存时间(多个以英文逗号分隔,最多 3 个,满足 keep 0 <= keep 1 <= keep 2,如 KEEP 100h,100d,3650d); 社区版不支持多级存储功能(即使配置了多个保存时间, 也不会生效, KEEP 会取最大的保存时间)。
|
||||||
- PAGES:一个 VNODE 中元数据存储引擎的缓存页个数,默认为 256,最小 64。一个 VNODE 元数据存储占用 PAGESIZE \* PAGES,默认情况下为 1MB 内存。
|
- PAGES:一个 VNODE 中元数据存储引擎的缓存页个数,默认为 256,最小 64。一个 VNODE 元数据存储占用 PAGESIZE \* PAGES,默认情况下为 1MB 内存。
|
||||||
- PAGESIZE:一个 VNODE 中元数据存储引擎的页大小,单位为 KB,默认为 4 KB。范围为 1 到 16384,即 1 KB 到 16 MB。
|
- PAGESIZE:一个 VNODE 中元数据存储引擎的页大小,单位为 KB,默认为 4 KB。范围为 1 到 16384,即 1 KB 到 16 MB。
|
||||||
- PRECISION:数据库的时间戳精度。ms 表示毫秒,us 表示微秒,ns 表示纳秒,默认 ms 毫秒。
|
- PRECISION:数据库的时间戳精度。ms 表示毫秒,us 表示微秒,ns 表示纳秒,默认 ms 毫秒。
|
||||||
|
|
|
@ -716,16 +716,6 @@ charset 的有效值是 UTF-8。
|
||||||
| 取值范围 | 0: 不改变;1:改变 |
|
| 取值范围 | 0: 不改变;1:改变 |
|
||||||
| 缺省值 | 0 |
|
| 缺省值 | 0 |
|
||||||
|
|
||||||
### keepTimeOffset
|
|
||||||
|
|
||||||
| 属性 | 说明 |
|
|
||||||
| -------- | -------------- |
|
|
||||||
| 适用范围 | 仅服务端适用 |
|
|
||||||
| 含义 | 迁移操作的延时 |
|
|
||||||
| 单位 | 小时 |
|
|
||||||
| 取值范围 | 0-23 |
|
|
||||||
| 缺省值 | 0 |
|
|
||||||
|
|
||||||
### tmqMaxTopicNum
|
### tmqMaxTopicNum
|
||||||
|
|
||||||
| 属性 | 说明 |
|
| 属性 | 说明 |
|
||||||
|
@ -803,7 +793,7 @@ charset 的有效值是 UTF-8。
|
||||||
| 53 | udf | 是 | 是 | |
|
| 53 | udf | 是 | 是 | |
|
||||||
| 54 | enableCoreFile | 是 | 是 | |
|
| 54 | enableCoreFile | 是 | 是 | |
|
||||||
| 55 | ttlChangeOnWrite | 否 | 是 | |
|
| 55 | ttlChangeOnWrite | 否 | 是 | |
|
||||||
| 56 | keepTimeOffset | 是 | 是 | |
|
| 56 | keepTimeOffset | 否 | 是(从3.2.0.0开始,该配置废弃) | |
|
||||||
|
|
||||||
## 2.x->3.0 的废弃参数
|
## 2.x->3.0 的废弃参数
|
||||||
|
|
||||||
|
|
|
@ -145,6 +145,7 @@ extern bool tsUseAdapter;
|
||||||
extern int32_t tsMetaCacheMaxSize;
|
extern int32_t tsMetaCacheMaxSize;
|
||||||
extern int32_t tsSlowLogThreshold;
|
extern int32_t tsSlowLogThreshold;
|
||||||
extern int32_t tsSlowLogScope;
|
extern int32_t tsSlowLogScope;
|
||||||
|
extern int32_t tsTimeSeriesThreshold;
|
||||||
|
|
||||||
// client
|
// client
|
||||||
extern int32_t tsMinSlidingTime;
|
extern int32_t tsMinSlidingTime;
|
||||||
|
@ -159,10 +160,11 @@ extern char buildinfo[];
|
||||||
|
|
||||||
// lossy
|
// lossy
|
||||||
extern char tsLossyColumns[];
|
extern char tsLossyColumns[];
|
||||||
extern double tsFPrecision;
|
extern float tsFPrecision;
|
||||||
extern double tsDPrecision;
|
extern double tsDPrecision;
|
||||||
extern uint32_t tsMaxRange;
|
extern uint32_t tsMaxRange;
|
||||||
extern uint32_t tsCurRange;
|
extern uint32_t tsCurRange;
|
||||||
|
extern bool tsIfAdtFse;
|
||||||
extern char tsCompressor[];
|
extern char tsCompressor[];
|
||||||
|
|
||||||
// tfs
|
// tfs
|
||||||
|
@ -206,7 +208,6 @@ extern int32_t tsRpcRetryInterval;
|
||||||
extern bool tsDisableStream;
|
extern bool tsDisableStream;
|
||||||
extern int64_t tsStreamBufferSize;
|
extern int64_t tsStreamBufferSize;
|
||||||
extern bool tsFilterScalarMode;
|
extern bool tsFilterScalarMode;
|
||||||
extern int32_t tsKeepTimeOffset;
|
|
||||||
extern int32_t tsMaxStreamBackendCache;
|
extern int32_t tsMaxStreamBackendCache;
|
||||||
extern int32_t tsPQSortMemThreshold;
|
extern int32_t tsPQSortMemThreshold;
|
||||||
extern int32_t tsResolveFQDNRetryTime;
|
extern int32_t tsResolveFQDNRetryTime;
|
||||||
|
|
|
@ -30,6 +30,8 @@ extern "C" {
|
||||||
#define GRANTS_COL_MAX_LEN 196
|
#define GRANTS_COL_MAX_LEN 196
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define GRANT_HEART_BEAT_MIN 2
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_GRANT_ALL,
|
TSDB_GRANT_ALL,
|
||||||
TSDB_GRANT_TIME,
|
TSDB_GRANT_TIME,
|
||||||
|
@ -49,6 +51,9 @@ typedef enum {
|
||||||
} EGrantType;
|
} EGrantType;
|
||||||
|
|
||||||
int32_t grantCheck(EGrantType grant);
|
int32_t grantCheck(EGrantType grant);
|
||||||
|
#ifdef TD_ENTERPRISE
|
||||||
|
int32_t grantAlterActiveCode(const char* old, const char* new, char* out, int8_t type);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef GRANTS_CFG
|
#ifndef GRANTS_CFG
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
|
|
|
@ -1096,6 +1096,7 @@ typedef struct {
|
||||||
int32_t daysToKeep0;
|
int32_t daysToKeep0;
|
||||||
int32_t daysToKeep1;
|
int32_t daysToKeep1;
|
||||||
int32_t daysToKeep2;
|
int32_t daysToKeep2;
|
||||||
|
int32_t keepTimeOffset;
|
||||||
int32_t minRows;
|
int32_t minRows;
|
||||||
int32_t maxRows;
|
int32_t maxRows;
|
||||||
int32_t walFsyncPeriod;
|
int32_t walFsyncPeriod;
|
||||||
|
@ -1133,6 +1134,7 @@ typedef struct {
|
||||||
int32_t daysToKeep0;
|
int32_t daysToKeep0;
|
||||||
int32_t daysToKeep1;
|
int32_t daysToKeep1;
|
||||||
int32_t daysToKeep2;
|
int32_t daysToKeep2;
|
||||||
|
int32_t keepTimeOffset;
|
||||||
int32_t walFsyncPeriod;
|
int32_t walFsyncPeriod;
|
||||||
int8_t walLevel;
|
int8_t walLevel;
|
||||||
int8_t strict;
|
int8_t strict;
|
||||||
|
@ -1239,6 +1241,7 @@ typedef struct {
|
||||||
int32_t daysToKeep0;
|
int32_t daysToKeep0;
|
||||||
int32_t daysToKeep1;
|
int32_t daysToKeep1;
|
||||||
int32_t daysToKeep2;
|
int32_t daysToKeep2;
|
||||||
|
int32_t keepTimeOffset;
|
||||||
int32_t minRows;
|
int32_t minRows;
|
||||||
int32_t maxRows;
|
int32_t maxRows;
|
||||||
int32_t walFsyncPeriod;
|
int32_t walFsyncPeriod;
|
||||||
|
@ -1464,6 +1467,11 @@ typedef struct {
|
||||||
int32_t learnerProgress; // use one reservered
|
int32_t learnerProgress; // use one reservered
|
||||||
} SVnodeLoad;
|
} SVnodeLoad;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t vgId;
|
||||||
|
int64_t nTimeSeries;
|
||||||
|
} SVnodeLoadLite;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t syncState;
|
int8_t syncState;
|
||||||
int64_t syncTerm;
|
int64_t syncTerm;
|
||||||
|
@ -1511,6 +1519,16 @@ int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
|
||||||
int32_t tDeserializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
|
int32_t tDeserializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
|
||||||
void tFreeSStatusReq(SStatusReq* pReq);
|
void tFreeSStatusReq(SStatusReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t dnodeId;
|
||||||
|
int64_t clusterId;
|
||||||
|
SArray* pVloads;
|
||||||
|
} SNotifyReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSNotifyReq(void* buf, int32_t bufLen, SNotifyReq* pReq);
|
||||||
|
int32_t tDeserializeSNotifyReq(void* buf, int32_t bufLen, SNotifyReq* pReq);
|
||||||
|
void tFreeSNotifyReq(SNotifyReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
int64_t clusterId;
|
int64_t clusterId;
|
||||||
|
@ -1576,6 +1594,7 @@ typedef struct {
|
||||||
int32_t daysToKeep0;
|
int32_t daysToKeep0;
|
||||||
int32_t daysToKeep1;
|
int32_t daysToKeep1;
|
||||||
int32_t daysToKeep2;
|
int32_t daysToKeep2;
|
||||||
|
int32_t keepTimeOffset;
|
||||||
int32_t minRows;
|
int32_t minRows;
|
||||||
int32_t maxRows;
|
int32_t maxRows;
|
||||||
int32_t walFsyncPeriod;
|
int32_t walFsyncPeriod;
|
||||||
|
@ -1655,6 +1674,7 @@ typedef struct {
|
||||||
int32_t daysToKeep0;
|
int32_t daysToKeep0;
|
||||||
int32_t daysToKeep1;
|
int32_t daysToKeep1;
|
||||||
int32_t daysToKeep2;
|
int32_t daysToKeep2;
|
||||||
|
int32_t keepTimeOffset;
|
||||||
int32_t walFsyncPeriod;
|
int32_t walFsyncPeriod;
|
||||||
int8_t walLevel;
|
int8_t walLevel;
|
||||||
int8_t strict;
|
int8_t strict;
|
||||||
|
|
|
@ -179,8 +179,7 @@ enum { // WARN: new msg should be appended to segment tail
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_HEARTBEAT, "stream-heartbeat", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_HEARTBEAT, "stream-heartbeat", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_RETRIEVE_IP_WHITE, "retrieve-ip-white", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_RETRIEVE_IP_WHITE, "retrieve-ip-white", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_GET_USER_WHITELIST, "get-user-whitelist", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_GET_USER_WHITELIST, "get-user-whitelist", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_NOTIFY, "notify", NULL, NULL)
|
||||||
|
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_BALANCE_VGROUP_LEADER, "balance-vgroup-leader", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_BALANCE_VGROUP_LEADER, "balance-vgroup-leader", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_RESTORE_DNODE, "restore-dnode", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_RESTORE_DNODE, "restore-dnode", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_PAUSE_STREAM, "pause-stream", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_PAUSE_STREAM, "pause-stream", NULL, NULL)
|
||||||
|
@ -189,6 +188,8 @@ enum { // WARN: new msg should be appended to segment tail
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_BEGIN_CHECKPOINT, "stream-begin-checkpoint", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_BEGIN_CHECKPOINT, "stream-begin-checkpoint", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_NODECHANGE_CHECK, "stream-nodechange-check", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_NODECHANGE_CHECK, "stream-nodechange-check", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_TRIM_DB_TIMER, "trim-db-tmr", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_TRIM_DB_TIMER, "trim-db-tmr", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_GRANT_NOTIFY, "grant-notify", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_VND_MSG)
|
TD_NEW_MSG_SEG(TDMT_VND_MSG)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp)
|
||||||
|
|
|
@ -115,250 +115,252 @@
|
||||||
#define TK_STT_TRIGGER 96
|
#define TK_STT_TRIGGER 96
|
||||||
#define TK_TABLE_PREFIX 97
|
#define TK_TABLE_PREFIX 97
|
||||||
#define TK_TABLE_SUFFIX 98
|
#define TK_TABLE_SUFFIX 98
|
||||||
#define TK_NK_COLON 99
|
#define TK_KEEP_TIME_OFFSET 99
|
||||||
#define TK_BWLIMIT 100
|
#define TK_NK_COLON 100
|
||||||
#define TK_START 101
|
#define TK_BWLIMIT 101
|
||||||
#define TK_TIMESTAMP 102
|
#define TK_START 102
|
||||||
#define TK_END 103
|
#define TK_TIMESTAMP 103
|
||||||
#define TK_TABLE 104
|
#define TK_END 104
|
||||||
#define TK_NK_LP 105
|
#define TK_TABLE 105
|
||||||
#define TK_NK_RP 106
|
#define TK_NK_LP 106
|
||||||
#define TK_STABLE 107
|
#define TK_NK_RP 107
|
||||||
#define TK_COLUMN 108
|
#define TK_STABLE 108
|
||||||
#define TK_MODIFY 109
|
#define TK_COLUMN 109
|
||||||
#define TK_RENAME 110
|
#define TK_MODIFY 110
|
||||||
#define TK_TAG 111
|
#define TK_RENAME 111
|
||||||
#define TK_SET 112
|
#define TK_TAG 112
|
||||||
#define TK_NK_EQ 113
|
#define TK_SET 113
|
||||||
#define TK_USING 114
|
#define TK_NK_EQ 114
|
||||||
#define TK_TAGS 115
|
#define TK_USING 115
|
||||||
#define TK_BOOL 116
|
#define TK_TAGS 116
|
||||||
#define TK_TINYINT 117
|
#define TK_BOOL 117
|
||||||
#define TK_SMALLINT 118
|
#define TK_TINYINT 118
|
||||||
#define TK_INT 119
|
#define TK_SMALLINT 119
|
||||||
#define TK_INTEGER 120
|
#define TK_INT 120
|
||||||
#define TK_BIGINT 121
|
#define TK_INTEGER 121
|
||||||
#define TK_FLOAT 122
|
#define TK_BIGINT 122
|
||||||
#define TK_DOUBLE 123
|
#define TK_FLOAT 123
|
||||||
#define TK_BINARY 124
|
#define TK_DOUBLE 124
|
||||||
#define TK_NCHAR 125
|
#define TK_BINARY 125
|
||||||
#define TK_UNSIGNED 126
|
#define TK_NCHAR 126
|
||||||
#define TK_JSON 127
|
#define TK_UNSIGNED 127
|
||||||
#define TK_VARCHAR 128
|
#define TK_JSON 128
|
||||||
#define TK_MEDIUMBLOB 129
|
#define TK_VARCHAR 129
|
||||||
#define TK_BLOB 130
|
#define TK_MEDIUMBLOB 130
|
||||||
#define TK_VARBINARY 131
|
#define TK_BLOB 131
|
||||||
#define TK_GEOMETRY 132
|
#define TK_VARBINARY 132
|
||||||
#define TK_DECIMAL 133
|
#define TK_GEOMETRY 133
|
||||||
#define TK_COMMENT 134
|
#define TK_DECIMAL 134
|
||||||
#define TK_MAX_DELAY 135
|
#define TK_COMMENT 135
|
||||||
#define TK_WATERMARK 136
|
#define TK_MAX_DELAY 136
|
||||||
#define TK_ROLLUP 137
|
#define TK_WATERMARK 137
|
||||||
#define TK_TTL 138
|
#define TK_ROLLUP 138
|
||||||
#define TK_SMA 139
|
#define TK_TTL 139
|
||||||
#define TK_DELETE_MARK 140
|
#define TK_SMA 140
|
||||||
#define TK_FIRST 141
|
#define TK_DELETE_MARK 141
|
||||||
#define TK_LAST 142
|
#define TK_FIRST 142
|
||||||
#define TK_SHOW 143
|
#define TK_LAST 143
|
||||||
#define TK_PRIVILEGES 144
|
#define TK_SHOW 144
|
||||||
#define TK_DATABASES 145
|
#define TK_PRIVILEGES 145
|
||||||
#define TK_TABLES 146
|
#define TK_DATABASES 146
|
||||||
#define TK_STABLES 147
|
#define TK_TABLES 147
|
||||||
#define TK_MNODES 148
|
#define TK_STABLES 148
|
||||||
#define TK_QNODES 149
|
#define TK_MNODES 149
|
||||||
#define TK_FUNCTIONS 150
|
#define TK_QNODES 150
|
||||||
#define TK_INDEXES 151
|
#define TK_FUNCTIONS 151
|
||||||
#define TK_ACCOUNTS 152
|
#define TK_INDEXES 152
|
||||||
#define TK_APPS 153
|
#define TK_ACCOUNTS 153
|
||||||
#define TK_CONNECTIONS 154
|
#define TK_APPS 154
|
||||||
#define TK_LICENCES 155
|
#define TK_CONNECTIONS 155
|
||||||
#define TK_GRANTS 156
|
#define TK_LICENCES 156
|
||||||
#define TK_QUERIES 157
|
#define TK_GRANTS 157
|
||||||
#define TK_SCORES 158
|
#define TK_QUERIES 158
|
||||||
#define TK_TOPICS 159
|
#define TK_SCORES 159
|
||||||
#define TK_VARIABLES 160
|
#define TK_TOPICS 160
|
||||||
#define TK_CLUSTER 161
|
#define TK_VARIABLES 161
|
||||||
#define TK_BNODES 162
|
#define TK_CLUSTER 162
|
||||||
#define TK_SNODES 163
|
#define TK_BNODES 163
|
||||||
#define TK_TRANSACTIONS 164
|
#define TK_SNODES 164
|
||||||
#define TK_DISTRIBUTED 165
|
#define TK_TRANSACTIONS 165
|
||||||
#define TK_CONSUMERS 166
|
#define TK_DISTRIBUTED 166
|
||||||
#define TK_SUBSCRIPTIONS 167
|
#define TK_CONSUMERS 167
|
||||||
#define TK_VNODES 168
|
#define TK_SUBSCRIPTIONS 168
|
||||||
#define TK_ALIVE 169
|
#define TK_VNODES 169
|
||||||
#define TK_NORMAL 170
|
#define TK_ALIVE 170
|
||||||
#define TK_CHILD 171
|
#define TK_NORMAL 171
|
||||||
#define TK_LIKE 172
|
#define TK_CHILD 172
|
||||||
#define TK_TBNAME 173
|
#define TK_LIKE 173
|
||||||
#define TK_QTAGS 174
|
#define TK_TBNAME 174
|
||||||
#define TK_AS 175
|
#define TK_QTAGS 175
|
||||||
#define TK_SYSTEM 176
|
#define TK_AS 176
|
||||||
#define TK_INDEX 177
|
#define TK_SYSTEM 177
|
||||||
#define TK_FUNCTION 178
|
#define TK_INDEX 178
|
||||||
#define TK_INTERVAL 179
|
#define TK_FUNCTION 179
|
||||||
#define TK_COUNT 180
|
#define TK_INTERVAL 180
|
||||||
#define TK_LAST_ROW 181
|
#define TK_COUNT 181
|
||||||
#define TK_META 182
|
#define TK_LAST_ROW 182
|
||||||
#define TK_ONLY 183
|
#define TK_META 183
|
||||||
#define TK_TOPIC 184
|
#define TK_ONLY 184
|
||||||
#define TK_CONSUMER 185
|
#define TK_TOPIC 185
|
||||||
#define TK_GROUP 186
|
#define TK_CONSUMER 186
|
||||||
#define TK_DESC 187
|
#define TK_GROUP 187
|
||||||
#define TK_DESCRIBE 188
|
#define TK_DESC 188
|
||||||
#define TK_RESET 189
|
#define TK_DESCRIBE 189
|
||||||
#define TK_QUERY 190
|
#define TK_RESET 190
|
||||||
#define TK_CACHE 191
|
#define TK_QUERY 191
|
||||||
#define TK_EXPLAIN 192
|
#define TK_CACHE 192
|
||||||
#define TK_ANALYZE 193
|
#define TK_EXPLAIN 193
|
||||||
#define TK_VERBOSE 194
|
#define TK_ANALYZE 194
|
||||||
#define TK_NK_BOOL 195
|
#define TK_VERBOSE 195
|
||||||
#define TK_RATIO 196
|
#define TK_NK_BOOL 196
|
||||||
#define TK_NK_FLOAT 197
|
#define TK_RATIO 197
|
||||||
#define TK_OUTPUTTYPE 198
|
#define TK_NK_FLOAT 198
|
||||||
#define TK_AGGREGATE 199
|
#define TK_OUTPUTTYPE 199
|
||||||
#define TK_BUFSIZE 200
|
#define TK_AGGREGATE 200
|
||||||
#define TK_LANGUAGE 201
|
#define TK_BUFSIZE 201
|
||||||
#define TK_REPLACE 202
|
#define TK_LANGUAGE 202
|
||||||
#define TK_STREAM 203
|
#define TK_REPLACE 203
|
||||||
#define TK_INTO 204
|
#define TK_STREAM 204
|
||||||
#define TK_PAUSE 205
|
#define TK_INTO 205
|
||||||
#define TK_RESUME 206
|
#define TK_PAUSE 206
|
||||||
#define TK_TRIGGER 207
|
#define TK_RESUME 207
|
||||||
#define TK_AT_ONCE 208
|
#define TK_TRIGGER 208
|
||||||
#define TK_WINDOW_CLOSE 209
|
#define TK_AT_ONCE 209
|
||||||
#define TK_IGNORE 210
|
#define TK_WINDOW_CLOSE 210
|
||||||
#define TK_EXPIRED 211
|
#define TK_IGNORE 211
|
||||||
#define TK_FILL_HISTORY 212
|
#define TK_EXPIRED 212
|
||||||
#define TK_UPDATE 213
|
#define TK_FILL_HISTORY 213
|
||||||
#define TK_SUBTABLE 214
|
#define TK_UPDATE 214
|
||||||
#define TK_UNTREATED 215
|
#define TK_SUBTABLE 215
|
||||||
#define TK_KILL 216
|
#define TK_UNTREATED 216
|
||||||
#define TK_CONNECTION 217
|
#define TK_KILL 217
|
||||||
#define TK_TRANSACTION 218
|
#define TK_CONNECTION 218
|
||||||
#define TK_BALANCE 219
|
#define TK_TRANSACTION 219
|
||||||
#define TK_VGROUP 220
|
#define TK_BALANCE 220
|
||||||
#define TK_LEADER 221
|
#define TK_VGROUP 221
|
||||||
#define TK_MERGE 222
|
#define TK_LEADER 222
|
||||||
#define TK_REDISTRIBUTE 223
|
#define TK_MERGE 223
|
||||||
#define TK_SPLIT 224
|
#define TK_REDISTRIBUTE 224
|
||||||
#define TK_DELETE 225
|
#define TK_SPLIT 225
|
||||||
#define TK_INSERT 226
|
#define TK_DELETE 226
|
||||||
#define TK_NULL 227
|
#define TK_INSERT 227
|
||||||
#define TK_NK_QUESTION 228
|
#define TK_NULL 228
|
||||||
#define TK_NK_ARROW 229
|
#define TK_NK_QUESTION 229
|
||||||
#define TK_ROWTS 230
|
#define TK_NK_ARROW 230
|
||||||
#define TK_QSTART 231
|
#define TK_ROWTS 231
|
||||||
#define TK_QEND 232
|
#define TK_QSTART 232
|
||||||
#define TK_QDURATION 233
|
#define TK_QEND 233
|
||||||
#define TK_WSTART 234
|
#define TK_QDURATION 234
|
||||||
#define TK_WEND 235
|
#define TK_WSTART 235
|
||||||
#define TK_WDURATION 236
|
#define TK_WEND 236
|
||||||
#define TK_IROWTS 237
|
#define TK_WDURATION 237
|
||||||
#define TK_ISFILLED 238
|
#define TK_IROWTS 238
|
||||||
#define TK_CAST 239
|
#define TK_ISFILLED 239
|
||||||
#define TK_NOW 240
|
#define TK_CAST 240
|
||||||
#define TK_TODAY 241
|
#define TK_NOW 241
|
||||||
#define TK_TIMEZONE 242
|
#define TK_TODAY 242
|
||||||
#define TK_CLIENT_VERSION 243
|
#define TK_TIMEZONE 243
|
||||||
#define TK_SERVER_VERSION 244
|
#define TK_CLIENT_VERSION 244
|
||||||
#define TK_SERVER_STATUS 245
|
#define TK_SERVER_VERSION 245
|
||||||
#define TK_CURRENT_USER 246
|
#define TK_SERVER_STATUS 246
|
||||||
#define TK_CASE 247
|
#define TK_CURRENT_USER 247
|
||||||
#define TK_WHEN 248
|
#define TK_CASE 248
|
||||||
#define TK_THEN 249
|
#define TK_WHEN 249
|
||||||
#define TK_ELSE 250
|
#define TK_THEN 250
|
||||||
#define TK_BETWEEN 251
|
#define TK_ELSE 251
|
||||||
#define TK_IS 252
|
#define TK_BETWEEN 252
|
||||||
#define TK_NK_LT 253
|
#define TK_IS 253
|
||||||
#define TK_NK_GT 254
|
#define TK_NK_LT 254
|
||||||
#define TK_NK_LE 255
|
#define TK_NK_GT 255
|
||||||
#define TK_NK_GE 256
|
#define TK_NK_LE 256
|
||||||
#define TK_NK_NE 257
|
#define TK_NK_GE 257
|
||||||
#define TK_MATCH 258
|
#define TK_NK_NE 258
|
||||||
#define TK_NMATCH 259
|
#define TK_MATCH 259
|
||||||
#define TK_CONTAINS 260
|
#define TK_NMATCH 260
|
||||||
#define TK_IN 261
|
#define TK_CONTAINS 261
|
||||||
#define TK_JOIN 262
|
#define TK_IN 262
|
||||||
#define TK_INNER 263
|
#define TK_JOIN 263
|
||||||
#define TK_SELECT 264
|
#define TK_INNER 264
|
||||||
#define TK_NK_HINT 265
|
#define TK_SELECT 265
|
||||||
#define TK_DISTINCT 266
|
#define TK_NK_HINT 266
|
||||||
#define TK_WHERE 267
|
#define TK_DISTINCT 267
|
||||||
#define TK_PARTITION 268
|
#define TK_WHERE 268
|
||||||
#define TK_BY 269
|
#define TK_PARTITION 269
|
||||||
#define TK_SESSION 270
|
#define TK_BY 270
|
||||||
#define TK_STATE_WINDOW 271
|
#define TK_SESSION 271
|
||||||
#define TK_EVENT_WINDOW 272
|
#define TK_STATE_WINDOW 272
|
||||||
#define TK_SLIDING 273
|
#define TK_EVENT_WINDOW 273
|
||||||
#define TK_FILL 274
|
#define TK_SLIDING 274
|
||||||
#define TK_VALUE 275
|
#define TK_FILL 275
|
||||||
#define TK_VALUE_F 276
|
#define TK_VALUE 276
|
||||||
#define TK_NONE 277
|
#define TK_VALUE_F 277
|
||||||
#define TK_PREV 278
|
#define TK_NONE 278
|
||||||
#define TK_NULL_F 279
|
#define TK_PREV 279
|
||||||
#define TK_LINEAR 280
|
#define TK_NULL_F 280
|
||||||
#define TK_NEXT 281
|
#define TK_LINEAR 281
|
||||||
#define TK_HAVING 282
|
#define TK_NEXT 282
|
||||||
#define TK_RANGE 283
|
#define TK_HAVING 283
|
||||||
#define TK_EVERY 284
|
#define TK_RANGE 284
|
||||||
#define TK_ORDER 285
|
#define TK_EVERY 285
|
||||||
#define TK_SLIMIT 286
|
#define TK_ORDER 286
|
||||||
#define TK_SOFFSET 287
|
#define TK_SLIMIT 287
|
||||||
#define TK_LIMIT 288
|
#define TK_SOFFSET 288
|
||||||
#define TK_OFFSET 289
|
#define TK_LIMIT 289
|
||||||
#define TK_ASC 290
|
#define TK_OFFSET 290
|
||||||
#define TK_NULLS 291
|
#define TK_ASC 291
|
||||||
#define TK_ABORT 292
|
#define TK_NULLS 292
|
||||||
#define TK_AFTER 293
|
#define TK_ABORT 293
|
||||||
#define TK_ATTACH 294
|
#define TK_AFTER 294
|
||||||
#define TK_BEFORE 295
|
#define TK_ATTACH 295
|
||||||
#define TK_BEGIN 296
|
#define TK_BEFORE 296
|
||||||
#define TK_BITAND 297
|
#define TK_BEGIN 297
|
||||||
#define TK_BITNOT 298
|
#define TK_BITAND 298
|
||||||
#define TK_BITOR 299
|
#define TK_BITNOT 299
|
||||||
#define TK_BLOCKS 300
|
#define TK_BITOR 300
|
||||||
#define TK_CHANGE 301
|
#define TK_BLOCKS 301
|
||||||
#define TK_COMMA 302
|
#define TK_CHANGE 302
|
||||||
#define TK_CONCAT 303
|
#define TK_COMMA 303
|
||||||
#define TK_CONFLICT 304
|
#define TK_CONCAT 304
|
||||||
#define TK_COPY 305
|
#define TK_CONFLICT 305
|
||||||
#define TK_DEFERRED 306
|
#define TK_COPY 306
|
||||||
#define TK_DELIMITERS 307
|
#define TK_DEFERRED 307
|
||||||
#define TK_DETACH 308
|
#define TK_DELIMITERS 308
|
||||||
#define TK_DIVIDE 309
|
#define TK_DETACH 309
|
||||||
#define TK_DOT 310
|
#define TK_DIVIDE 310
|
||||||
#define TK_EACH 311
|
#define TK_DOT 311
|
||||||
#define TK_FAIL 312
|
#define TK_EACH 312
|
||||||
#define TK_FILE 313
|
#define TK_FAIL 313
|
||||||
#define TK_FOR 314
|
#define TK_FILE 314
|
||||||
#define TK_GLOB 315
|
#define TK_FOR 315
|
||||||
#define TK_ID 316
|
#define TK_GLOB 316
|
||||||
#define TK_IMMEDIATE 317
|
#define TK_ID 317
|
||||||
#define TK_IMPORT 318
|
#define TK_IMMEDIATE 318
|
||||||
#define TK_INITIALLY 319
|
#define TK_IMPORT 319
|
||||||
#define TK_INSTEAD 320
|
#define TK_INITIALLY 320
|
||||||
#define TK_ISNULL 321
|
#define TK_INSTEAD 321
|
||||||
#define TK_KEY 322
|
#define TK_ISNULL 322
|
||||||
#define TK_MODULES 323
|
#define TK_KEY 323
|
||||||
#define TK_NK_BITNOT 324
|
#define TK_MODULES 324
|
||||||
#define TK_NK_SEMI 325
|
#define TK_NK_BITNOT 325
|
||||||
#define TK_NOTNULL 326
|
#define TK_NK_SEMI 326
|
||||||
#define TK_OF 327
|
#define TK_NOTNULL 327
|
||||||
#define TK_PLUS 328
|
#define TK_OF 328
|
||||||
#define TK_PRIVILEGE 329
|
#define TK_PLUS 329
|
||||||
#define TK_RAISE 330
|
#define TK_PRIVILEGE 330
|
||||||
#define TK_RESTRICT 331
|
#define TK_RAISE 331
|
||||||
#define TK_ROW 332
|
#define TK_RESTRICT 332
|
||||||
#define TK_SEMI 333
|
#define TK_ROW 333
|
||||||
#define TK_STAR 334
|
#define TK_SEMI 334
|
||||||
#define TK_STATEMENT 335
|
#define TK_STAR 335
|
||||||
#define TK_STRICT 336
|
#define TK_STATEMENT 336
|
||||||
#define TK_STRING 337
|
#define TK_STRICT 337
|
||||||
#define TK_TIMES 338
|
#define TK_STRING 338
|
||||||
#define TK_VALUES 339
|
#define TK_TIMES 339
|
||||||
#define TK_VARIABLE 340
|
#define TK_VALUES 340
|
||||||
#define TK_VIEW 341
|
#define TK_VARIABLE 341
|
||||||
#define TK_WAL 342
|
#define TK_VIEW 342
|
||||||
|
#define TK_WAL 343
|
||||||
|
|
||||||
|
|
||||||
#define TK_NK_SPACE 600
|
#define TK_NK_SPACE 600
|
||||||
#define TK_NK_COMMENT 601
|
#define TK_NK_COMMENT 601
|
||||||
|
|
|
@ -142,6 +142,7 @@ typedef struct SSnapContext {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t uid;
|
int64_t uid;
|
||||||
int64_t ctbNum;
|
int64_t ctbNum;
|
||||||
|
int32_t colNum;
|
||||||
} SMetaStbStats;
|
} SMetaStbStats;
|
||||||
|
|
||||||
// void tqReaderSetColIdList(STqReader *pReader, SArray *pColIdList);
|
// void tqReaderSetColIdList(STqReader *pReader, SArray *pColIdList);
|
||||||
|
@ -286,8 +287,8 @@ typedef struct SStoreMeta {
|
||||||
|
|
||||||
// db name, vgId, numOfTables, numOfSTables
|
// db name, vgId, numOfTables, numOfSTables
|
||||||
int32_t (*getNumOfChildTables)(
|
int32_t (*getNumOfChildTables)(
|
||||||
void* pVnode, int64_t uid,
|
void* pVnode, int64_t uid, int64_t* numOfTables,
|
||||||
int64_t* numOfTables); // int32_t metaGetStbStats(SMeta *pMeta, int64_t uid, SMetaStbStats *pInfo);
|
int32_t* numOfCols); // int32_t metaGetStbStats(SMeta *pMeta, int64_t uid, SMetaStbStats *pInfo);
|
||||||
void (*getBasicInfo)(void* pVnode, const char** dbname, int32_t* vgId, int64_t* numOfTables,
|
void (*getBasicInfo)(void* pVnode, const char** dbname, int32_t* vgId, int64_t* numOfTables,
|
||||||
int64_t* numOfNormalTables); // vnodeGetInfo(void *pVnode, const char **dbname, int32_t *vgId) &
|
int64_t* numOfNormalTables); // vnodeGetInfo(void *pVnode, const char **dbname, int32_t *vgId) &
|
||||||
// metaGetTbNum(SMeta *pMeta) & metaGetNtbNum(SMeta *pMeta);
|
// metaGetTbNum(SMeta *pMeta) & metaGetNtbNum(SMeta *pMeta);
|
||||||
|
|
|
@ -191,7 +191,7 @@ typedef struct {
|
||||||
} SMonBmInfo;
|
} SMonBmInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SArray *pVloads; // SVnodeLoad
|
SArray *pVloads; // SVnodeLoad/SVnodeLoadLite
|
||||||
} SMonVloadInfo;
|
} SMonVloadInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -206,6 +206,11 @@ typedef struct {
|
||||||
bool comp;
|
bool comp;
|
||||||
} SMonCfg;
|
} SMonCfg;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t state;
|
||||||
|
tsem_t sem;
|
||||||
|
} SDmNotifyHandle;
|
||||||
|
|
||||||
int32_t monInit(const SMonCfg *pCfg);
|
int32_t monInit(const SMonCfg *pCfg);
|
||||||
void monCleanup();
|
void monCleanup();
|
||||||
void monRecordLog(int64_t ts, ELogLevel level, const char *content);
|
void monRecordLog(int64_t ts, ELogLevel level, const char *content);
|
||||||
|
|
|
@ -66,6 +66,7 @@ typedef struct SDatabaseOptions {
|
||||||
int32_t minRowsPerBlock;
|
int32_t minRowsPerBlock;
|
||||||
SNodeList* pKeep;
|
SNodeList* pKeep;
|
||||||
int64_t keep[3];
|
int64_t keep[3];
|
||||||
|
int32_t keepTimeOffset;
|
||||||
int32_t pages;
|
int32_t pages;
|
||||||
int32_t pagesize;
|
int32_t pagesize;
|
||||||
int32_t tsdbPageSize;
|
int32_t tsdbPageSize;
|
||||||
|
|
|
@ -124,6 +124,7 @@ int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
||||||
int32_t nodesListPushFront(SNodeList* pList, SNode* pNode);
|
int32_t nodesListPushFront(SNodeList* pList, SNode* pNode);
|
||||||
SListCell* nodesListErase(SNodeList* pList, SListCell* pCell);
|
SListCell* nodesListErase(SNodeList* pList, SListCell* pCell);
|
||||||
void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc);
|
void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc);
|
||||||
|
void nodesListInsertListAfterPos(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc);
|
||||||
SNode* nodesListGetNode(SNodeList* pList, int32_t index);
|
SNode* nodesListGetNode(SNodeList* pList, int32_t index);
|
||||||
SListCell* nodesListGetCell(SNodeList* pList, int32_t index);
|
SListCell* nodesListGetCell(SNodeList* pList, int32_t index);
|
||||||
void nodesDestroyList(SNodeList* pList);
|
void nodesDestroyList(SNodeList* pList);
|
||||||
|
|
|
@ -536,6 +536,9 @@ int32_t nodesMergeConds(SNode** pDst, SNodeList** pSrc);
|
||||||
const char* operatorTypeStr(EOperatorType type);
|
const char* operatorTypeStr(EOperatorType type);
|
||||||
const char* logicConditionTypeStr(ELogicConditionType type);
|
const char* logicConditionTypeStr(ELogicConditionType type);
|
||||||
|
|
||||||
|
bool nodesIsStar(SNode* pNode);
|
||||||
|
bool nodesIsTableStar(SNode* pNode);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -64,7 +64,7 @@ typedef struct SParseContext {
|
||||||
SArray* pTableMetaPos; // sql table pos => catalog data pos
|
SArray* pTableMetaPos; // sql table pos => catalog data pos
|
||||||
SArray* pTableVgroupPos; // sql table pos => catalog data pos
|
SArray* pTableVgroupPos; // sql table pos => catalog data pos
|
||||||
int64_t allocatorId;
|
int64_t allocatorId;
|
||||||
int32_t biMode;
|
int8_t biMode;
|
||||||
} SParseContext;
|
} SParseContext;
|
||||||
|
|
||||||
int32_t qParseSql(SParseContext* pCxt, SQuery** pQuery);
|
int32_t qParseSql(SParseContext* pCxt, SQuery** pQuery);
|
||||||
|
|
|
@ -33,6 +33,17 @@ int tsem_timewait(tsem_t *sim, int64_t milis);
|
||||||
int tsem_post(tsem_t *sem);
|
int tsem_post(tsem_t *sem);
|
||||||
int tsem_destroy(tsem_t *sem);
|
int tsem_destroy(tsem_t *sem);
|
||||||
|
|
||||||
|
#elif defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#define tsem_t HANDLE
|
||||||
|
|
||||||
|
int tsem_init(tsem_t *sem, int pshared, unsigned int value);
|
||||||
|
int tsem_wait(tsem_t *sem);
|
||||||
|
int tsem_timewait(tsem_t *sim, int64_t milis);
|
||||||
|
int tsem_post(tsem_t *sem);
|
||||||
|
int tsem_destroy(tsem_t *sem);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define tsem_t sem_t
|
#define tsem_t sem_t
|
||||||
|
|
|
@ -46,7 +46,7 @@ typedef HANDLE TdThreadMutexAttr; // windows api
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SRWLOCK lock;
|
SRWLOCK lock;
|
||||||
int8_t excl;
|
int8_t excl;
|
||||||
} TdThreadRwlock; // pthread api
|
} TdThreadRwlock; // windows api
|
||||||
typedef pthread_attr_t TdThreadAttr; // pthread api
|
typedef pthread_attr_t TdThreadAttr; // pthread api
|
||||||
typedef pthread_once_t TdThreadOnce; // pthread api
|
typedef pthread_once_t TdThreadOnce; // pthread api
|
||||||
typedef HANDLE TdThreadRwlockAttr; // windows api
|
typedef HANDLE TdThreadRwlockAttr; // windows api
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef _TD_SZ_H
|
||||||
|
#define _TD_SZ_H
|
||||||
|
#include "defines.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void cost_start();
|
||||||
|
double cost_end(const char* tag);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Init success return 1 else 0
|
||||||
|
//
|
||||||
|
void tdszInit(float fPrecision, double dPrecision, unsigned int maxIntervals, unsigned int intervals, int ifAdtFse, const char* compressor);
|
||||||
|
|
||||||
|
//
|
||||||
|
// compress interface to tdengine return value is count of output with bytes
|
||||||
|
//
|
||||||
|
int tdszCompress(int type, const char * input, const int nelements, const char * output);
|
||||||
|
|
||||||
|
//
|
||||||
|
// decompress interface to tdengine return value is count of output with bytes
|
||||||
|
//
|
||||||
|
int tdszDecompress(int type, const char * input, int compressedSize, const int nelements, const char * output);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Exit call
|
||||||
|
//
|
||||||
|
void tdszExit();
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* ----- #ifndef _SZ_H ----- */
|
|
@ -541,6 +541,13 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_GRANT_CPU_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080B)
|
#define TSDB_CODE_GRANT_CPU_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080B)
|
||||||
#define TSDB_CODE_GRANT_STABLE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080C)
|
#define TSDB_CODE_GRANT_STABLE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080C)
|
||||||
#define TSDB_CODE_GRANT_TABLE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080D)
|
#define TSDB_CODE_GRANT_TABLE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080D)
|
||||||
|
#define TSDB_CODE_GRANT_PAR_IVLD_ACTIVE TAOS_DEF_ERROR_CODE(0, 0x080E)
|
||||||
|
#define TSDB_CODE_GRANT_PAR_IVLD_KEY TAOS_DEF_ERROR_CODE(0, 0x080F)
|
||||||
|
#define TSDB_CODE_GRANT_PAR_DEC_IVLD_KEY TAOS_DEF_ERROR_CODE(0, 0x0810)
|
||||||
|
#define TSDB_CODE_GRANT_PAR_DEC_IVLD_KLEN TAOS_DEF_ERROR_CODE(0, 0x0811)
|
||||||
|
#define TSDB_CODE_GRANT_GEN_IVLD_KEY TAOS_DEF_ERROR_CODE(0, 0x0812)
|
||||||
|
#define TSDB_CODE_GRANT_GEN_APP_LIMIT TAOS_DEF_ERROR_CODE(0, 0x0813)
|
||||||
|
#define TSDB_CODE_GRANT_GEN_ENC_IVLD_KLEN TAOS_DEF_ERROR_CODE(0, 0x0814)
|
||||||
|
|
||||||
// sync
|
// sync
|
||||||
// #define TSDB_CODE_SYN_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0900) // 2.x
|
// #define TSDB_CODE_SYN_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0900) // 2.x
|
||||||
|
|
|
@ -54,8 +54,15 @@ extern "C" {
|
||||||
#ifdef TD_TSZ
|
#ifdef TD_TSZ
|
||||||
extern bool lossyFloat;
|
extern bool lossyFloat;
|
||||||
extern bool lossyDouble;
|
extern bool lossyDouble;
|
||||||
int32_t tsCompressInit();
|
int32_t tsCompressInit(char* lossyColumns, float fPrecision, double dPrecision, uint32_t maxIntervals, uint32_t intervals,
|
||||||
void tsCompressExit();
|
int32_t ifAdtFse, const char* compressor);
|
||||||
|
|
||||||
|
void tsCompressExit();
|
||||||
|
|
||||||
|
int32_t tsCompressFloatLossyImp(const char *const input, const int32_t nelements, char *const output);
|
||||||
|
int32_t tsDecompressFloatLossyImp(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output);
|
||||||
|
int32_t tsCompressDoubleLossyImp(const char *const input, const int32_t nelements, char *const output);
|
||||||
|
int32_t tsDecompressDoubleLossyImp(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output);
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tsCompressFloatLossy(const char *const input, int32_t inputSize, const int32_t nelements,
|
static FORCE_INLINE int32_t tsCompressFloatLossy(const char *const input, int32_t inputSize, const int32_t nelements,
|
||||||
char *const output, int32_t outputSize, char algorithm,
|
char *const output, int32_t outputSize, char algorithm,
|
||||||
|
|
|
@ -43,6 +43,7 @@ typedef enum {
|
||||||
CFG_DTYPE_INT32,
|
CFG_DTYPE_INT32,
|
||||||
CFG_DTYPE_INT64,
|
CFG_DTYPE_INT64,
|
||||||
CFG_DTYPE_FLOAT,
|
CFG_DTYPE_FLOAT,
|
||||||
|
CFG_DTYPE_DOUBLE,
|
||||||
CFG_DTYPE_STRING,
|
CFG_DTYPE_STRING,
|
||||||
CFG_DTYPE_DIR,
|
CFG_DTYPE_DIR,
|
||||||
CFG_DTYPE_LOCALE,
|
CFG_DTYPE_LOCALE,
|
||||||
|
@ -64,6 +65,7 @@ typedef struct SConfigItem {
|
||||||
union {
|
union {
|
||||||
bool bval;
|
bool bval;
|
||||||
float fval;
|
float fval;
|
||||||
|
double dval;
|
||||||
int32_t i32;
|
int32_t i32;
|
||||||
int64_t i64;
|
int64_t i64;
|
||||||
char *str;
|
char *str;
|
||||||
|
@ -101,7 +103,8 @@ int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfg
|
||||||
int32_t cfgAddBool(SConfig *pCfg, const char *name, bool defaultVal, int8_t scope);
|
int32_t cfgAddBool(SConfig *pCfg, const char *name, bool defaultVal, int8_t scope);
|
||||||
int32_t cfgAddInt32(SConfig *pCfg, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval, int8_t scope);
|
int32_t cfgAddInt32(SConfig *pCfg, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval, int8_t scope);
|
||||||
int32_t cfgAddInt64(SConfig *pCfg, const char *name, int64_t defaultVal, int64_t minval, int64_t maxval, int8_t scope);
|
int32_t cfgAddInt64(SConfig *pCfg, const char *name, int64_t defaultVal, int64_t minval, int64_t maxval, int8_t scope);
|
||||||
int32_t cfgAddFloat(SConfig *pCfg, const char *name, float defaultVal, double minval, double maxval, int8_t scope);
|
int32_t cfgAddFloat(SConfig *pCfg, const char *name, float defaultVal, float minval, float maxval, int8_t scope);
|
||||||
|
int32_t cfgAddDouble(SConfig *pCfg, const char *name, double defaultVal, double minval, double maxval, int8_t scope);
|
||||||
int32_t cfgAddString(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope);
|
int32_t cfgAddString(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope);
|
||||||
int32_t cfgAddDir(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope);
|
int32_t cfgAddDir(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope);
|
||||||
int32_t cfgAddLocale(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope);
|
int32_t cfgAddLocale(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope);
|
||||||
|
|
|
@ -322,6 +322,9 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved.
|
#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved.
|
||||||
#define TSDB_MAX_KEEP_NS (365 * 292 * 1440) // data in db to be reserved.
|
#define TSDB_MAX_KEEP_NS (365 * 292 * 1440) // data in db to be reserved.
|
||||||
#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years
|
#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years
|
||||||
|
#define TSDB_MIN_KEEP_TIME_OFFSET 0
|
||||||
|
#define TSDB_MAX_KEEP_TIME_OFFSET 23
|
||||||
|
#define TSDB_DEFAULT_KEEP_TIME_OFFSET 0
|
||||||
#define TSDB_MIN_MINROWS_FBLOCK 10
|
#define TSDB_MIN_MINROWS_FBLOCK 10
|
||||||
#define TSDB_MAX_MINROWS_FBLOCK 1000000
|
#define TSDB_MAX_MINROWS_FBLOCK 1000000
|
||||||
#define TSDB_DEFAULT_MINROWS_FBLOCK 100
|
#define TSDB_DEFAULT_MINROWS_FBLOCK 100
|
||||||
|
|
|
@ -108,9 +108,6 @@
|
||||||
# time period of keeping log files, in days
|
# time period of keeping log files, in days
|
||||||
# logKeepDays 0
|
# logKeepDays 0
|
||||||
|
|
||||||
# unit Hour. Latency of data migration
|
|
||||||
# keepTimeOffset 0
|
|
||||||
|
|
||||||
|
|
||||||
############ 3. Debug Flag and levels #############################################
|
############ 3. Debug Flag and levels #############################################
|
||||||
|
|
||||||
|
|
|
@ -33,14 +33,17 @@ adapterName="taosadapter"
|
||||||
benchmarkName="taosBenchmark"
|
benchmarkName="taosBenchmark"
|
||||||
dumpName="taosdump"
|
dumpName="taosdump"
|
||||||
demoName="taosdemo"
|
demoName="taosdemo"
|
||||||
|
xname="taosx"
|
||||||
|
|
||||||
clientName2="taos"
|
clientName2="taos"
|
||||||
serverName2="${clientName2}d"
|
serverName2="${clientName2}d"
|
||||||
configFile2="${clientName2}.cfg"
|
configFile2="${clientName2}.cfg"
|
||||||
productName2="TDengine"
|
productName2="TDengine"
|
||||||
emailName2="taosdata.com"
|
emailName2="taosdata.com"
|
||||||
|
xname2="${clientName2}x"
|
||||||
adapterName2="${clientName2}adapter"
|
adapterName2="${clientName2}adapter"
|
||||||
|
|
||||||
|
explorerName="${clientName2}-explorer"
|
||||||
benchmarkName2="${clientName2}Benchmark"
|
benchmarkName2="${clientName2}Benchmark"
|
||||||
demoName2="${clientName2}demo"
|
demoName2="${clientName2}demo"
|
||||||
dumpName2="${clientName2}dump"
|
dumpName2="${clientName2}dump"
|
||||||
|
@ -235,6 +238,12 @@ function install_bin() {
|
||||||
[ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || :
|
[ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || :
|
||||||
|
|
||||||
if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
|
if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
|
||||||
|
${csudo}rm -f ${bin_link_dir}/${xname2} || :
|
||||||
|
${csudo}rm -f ${bin_link_dir}/${explorerName} || :
|
||||||
|
|
||||||
|
#Make link
|
||||||
|
[ -x ${install_main_dir}/bin/${xname2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${xname2} ${bin_link_dir}/${xname2} || :
|
||||||
|
[ -x ${install_main_dir}/bin/${explorerName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${explorerName} ${bin_link_dir}/${explorerName} || :
|
||||||
[ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript2} || :
|
[ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript2} || :
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -693,9 +702,29 @@ function clean_service_on_systemd() {
|
||||||
fi
|
fi
|
||||||
${csudo}systemctl disable tarbitratord &>/dev/null || echo &>/dev/null
|
${csudo}systemctl disable tarbitratord &>/dev/null || echo &>/dev/null
|
||||||
${csudo}rm -f ${tarbitratord_service_config}
|
${csudo}rm -f ${tarbitratord_service_config}
|
||||||
# if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
|
|
||||||
# ${csudo}rm -f ${service_config_dir}/${serverName2}.service
|
if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
|
||||||
# fi
|
x_service_config="${service_config_dir}/${xName2}.service"
|
||||||
|
if [ -e "$x_service_config" ]; then
|
||||||
|
if systemctl is-active --quiet ${xName2}; then
|
||||||
|
echo "${productName2} ${xName2} is running, stopping it..."
|
||||||
|
${csudo}systemctl stop ${xName2} &>/dev/null || echo &>/dev/null
|
||||||
|
fi
|
||||||
|
${csudo}systemctl disable ${xName2} &>/dev/null || echo &>/dev/null
|
||||||
|
${csudo}rm -f ${x_service_config}
|
||||||
|
fi
|
||||||
|
|
||||||
|
explorer_service_config="${service_config_dir}/${explorerName2}.service"
|
||||||
|
if [ -e "$explorer_service_config" ]; then
|
||||||
|
if systemctl is-active --quiet ${explorerName2}; then
|
||||||
|
echo "${productName2} ${explorerName2} is running, stopping it..."
|
||||||
|
${csudo}systemctl stop ${explorerName2} &>/dev/null || echo &>/dev/null
|
||||||
|
fi
|
||||||
|
${csudo}systemctl disable ${explorerName2} &>/dev/null || echo &>/dev/null
|
||||||
|
${csudo}rm -f ${explorer_service_config}
|
||||||
|
${csudo}rm -f /etc/${clientName2}/explorer.toml
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_service_on_systemd() {
|
function install_service_on_systemd() {
|
||||||
|
|
|
@ -123,10 +123,11 @@ function clean_bin() {
|
||||||
${csudo}rm -f ${bin_link_dir}/set_core || :
|
${csudo}rm -f ${bin_link_dir}/set_core || :
|
||||||
${csudo}rm -f ${bin_link_dir}/TDinsight.sh || :
|
${csudo}rm -f ${bin_link_dir}/TDinsight.sh || :
|
||||||
${csudo}rm -f ${bin_link_dir}/${keeperName2} || :
|
${csudo}rm -f ${bin_link_dir}/${keeperName2} || :
|
||||||
# ${csudo}rm -f ${bin_link_dir}/${xName2} || :
|
|
||||||
# ${csudo}rm -f ${bin_link_dir}/${explorerName2} || :
|
|
||||||
|
|
||||||
if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
|
if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
|
||||||
|
${csudo}rm -f ${bin_link_dir}/${xName2} || :
|
||||||
|
${csudo}rm -f ${bin_link_dir}/${explorerName2} || :
|
||||||
${csudo}rm -f ${bin_link_dir}/${clientName2} || :
|
${csudo}rm -f ${bin_link_dir}/${clientName2} || :
|
||||||
${csudo}rm -f ${bin_link_dir}/${benchmarkName2} || :
|
${csudo}rm -f ${bin_link_dir}/${benchmarkName2} || :
|
||||||
${csudo}rm -f ${bin_link_dir}/${dumpName2} || :
|
${csudo}rm -f ${bin_link_dir}/${dumpName2} || :
|
||||||
|
@ -195,26 +196,28 @@ function clean_service_on_systemd() {
|
||||||
fi
|
fi
|
||||||
${csudo}systemctl disable ${tarbitrator_service_name} &>/dev/null || echo &>/dev/null
|
${csudo}systemctl disable ${tarbitrator_service_name} &>/dev/null || echo &>/dev/null
|
||||||
|
|
||||||
# x_service_config="${service_config_dir}/${xName2}.service"
|
if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
|
||||||
# if [ -e "$x_service_config" ]; then
|
x_service_config="${service_config_dir}/${xName2}.service"
|
||||||
# if systemctl is-active --quiet ${xName2}; then
|
if [ -e "$x_service_config" ]; then
|
||||||
# echo "${productName2} ${xName2} is running, stopping it..."
|
if systemctl is-active --quiet ${xName2}; then
|
||||||
# ${csudo}systemctl stop ${xName2} &>/dev/null || echo &>/dev/null
|
echo "${productName2} ${xName2} is running, stopping it..."
|
||||||
# fi
|
${csudo}systemctl stop ${xName2} &>/dev/null || echo &>/dev/null
|
||||||
# ${csudo}systemctl disable ${xName2} &>/dev/null || echo &>/dev/null
|
fi
|
||||||
# ${csudo}rm -f ${x_service_config}
|
${csudo}systemctl disable ${xName2} &>/dev/null || echo &>/dev/null
|
||||||
# fi
|
${csudo}rm -f ${x_service_config}
|
||||||
|
fi
|
||||||
|
|
||||||
# explorer_service_config="${service_config_dir}/${explorerName2}.service"
|
explorer_service_config="${service_config_dir}/${explorerName2}.service"
|
||||||
# if [ -e "$explorer_service_config" ]; then
|
if [ -e "$explorer_service_config" ]; then
|
||||||
# if systemctl is-active --quiet ${explorerName2}; then
|
if systemctl is-active --quiet ${explorerName2}; then
|
||||||
# echo "${productName2} ${explorerName2} is running, stopping it..."
|
echo "${productName2} ${explorerName2} is running, stopping it..."
|
||||||
# ${csudo}systemctl stop ${explorerName2} &>/dev/null || echo &>/dev/null
|
${csudo}systemctl stop ${explorerName2} &>/dev/null || echo &>/dev/null
|
||||||
# fi
|
fi
|
||||||
# ${csudo}systemctl disable ${explorerName2} &>/dev/null || echo &>/dev/null
|
${csudo}systemctl disable ${explorerName2} &>/dev/null || echo &>/dev/null
|
||||||
# ${csudo}rm -f ${explorer_service_config}
|
${csudo}rm -f ${explorer_service_config}
|
||||||
# ${csudo}rm -f /etc/${clientName2}/explorer.toml
|
${csudo}rm -f /etc/${clientName2}/explorer.toml
|
||||||
# fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean_service_on_sysvinit() {
|
function clean_service_on_sysvinit() {
|
||||||
|
|
|
@ -106,6 +106,7 @@ static const SSysDbTableSchema userDBSchema[] = {
|
||||||
{.name = "table_prefix", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
{.name = "table_prefix", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
||||||
{.name = "table_suffix", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
{.name = "table_suffix", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
||||||
{.name = "tsdb_pagesize", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
{.name = "tsdb_pagesize", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||||
|
{.name = "keep_time_offset", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema userFuncSchema[] = {
|
static const SSysDbTableSchema userFuncSchema[] = {
|
||||||
|
|
|
@ -1557,11 +1557,13 @@ STSchema *tBuildTSchema(SSchema *aSchema, int32_t numOfCols, int32_t version) {
|
||||||
|
|
||||||
// SColData ========================================
|
// SColData ========================================
|
||||||
void tColDataDestroy(void *ph) {
|
void tColDataDestroy(void *ph) {
|
||||||
SColData *pColData = (SColData *)ph;
|
if (ph) {
|
||||||
|
SColData *pColData = (SColData *)ph;
|
||||||
|
|
||||||
tFree(pColData->pBitMap);
|
tFree(pColData->pBitMap);
|
||||||
tFree(pColData->aOffset);
|
tFree(pColData->aOffset);
|
||||||
tFree(pColData->pData);
|
tFree(pColData->pData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t smaOn) {
|
void tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t smaOn) {
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "tgrant.h"
|
#include "tgrant.h"
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "tmisce.h"
|
#include "tmisce.h"
|
||||||
|
#include "defines.h"
|
||||||
|
|
||||||
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
|
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
|
||||||
#include "cus_name.h"
|
#include "cus_name.h"
|
||||||
|
@ -144,6 +145,7 @@ bool tsUseAdapter = false;
|
||||||
int32_t tsMetaCacheMaxSize = -1; // MB
|
int32_t tsMetaCacheMaxSize = -1; // MB
|
||||||
int32_t tsSlowLogThreshold = 3; // seconds
|
int32_t tsSlowLogThreshold = 3; // seconds
|
||||||
int32_t tsSlowLogScope = SLOW_LOG_TYPE_ALL;
|
int32_t tsSlowLogScope = SLOW_LOG_TYPE_ALL;
|
||||||
|
int32_t tsTimeSeriesThreshold = 50;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* denote if the server needs to compress response message at the application layer to client, including query rsp,
|
* denote if the server needs to compress response message at the application layer to client, including query rsp,
|
||||||
|
@ -211,14 +213,15 @@ int64_t tsTickPerMin[] = {60000L, 60000000L, 60000000000L};
|
||||||
*/
|
*/
|
||||||
int64_t tsTickPerHour[] = {3600000L, 3600000000L, 3600000000000L};
|
int64_t tsTickPerHour[] = {3600000L, 3600000000L, 3600000000000L};
|
||||||
|
|
||||||
// lossy compress 6
|
// lossy compress 7
|
||||||
char tsLossyColumns[32] = ""; // "float|double" means all float and double columns can be lossy compressed. set empty
|
char tsLossyColumns[32] = ""; // "float|double" means all float and double columns can be lossy compressed. set empty
|
||||||
// can close lossy compress.
|
// can close lossy compress.
|
||||||
// below option can take effect when tsLossyColumns not empty
|
// below option can take effect when tsLossyColumns not empty
|
||||||
double tsFPrecision = 1E-8; // float column precision
|
float tsFPrecision = 1E-8; // float column precision
|
||||||
double tsDPrecision = 1E-16; // double column precision
|
double tsDPrecision = 1E-16; // double column precision
|
||||||
uint32_t tsMaxRange = 500; // max range
|
uint32_t tsMaxRange = 500; // max quantization intervals
|
||||||
uint32_t tsCurRange = 100; // range
|
uint32_t tsCurRange = 100; // current quantization intervals
|
||||||
|
bool tsIfAdtFse = false; // ADT-FSE algorithom or original huffman algorithom
|
||||||
char tsCompressor[32] = "ZSTD_COMPRESSOR"; // ZSTD_COMPRESSOR or GZIP_COMPRESSOR
|
char tsCompressor[32] = "ZSTD_COMPRESSOR"; // ZSTD_COMPRESSOR or GZIP_COMPRESSOR
|
||||||
|
|
||||||
// udf
|
// udf
|
||||||
|
@ -253,7 +256,6 @@ char tsUdfdLdLibPath[512] = "";
|
||||||
bool tsDisableStream = false;
|
bool tsDisableStream = false;
|
||||||
int64_t tsStreamBufferSize = 128 * 1024 * 1024;
|
int64_t tsStreamBufferSize = 128 * 1024 * 1024;
|
||||||
bool tsFilterScalarMode = false;
|
bool tsFilterScalarMode = false;
|
||||||
int32_t tsKeepTimeOffset = 0; // latency of data migration
|
|
||||||
int tsResolveFQDNRetryTime = 100; // seconds
|
int tsResolveFQDNRetryTime = 100; // seconds
|
||||||
|
|
||||||
char tsS3Endpoint[TSDB_FQDN_LEN] = "<endpoint>";
|
char tsS3Endpoint[TSDB_FQDN_LEN] = "<endpoint>";
|
||||||
|
@ -635,6 +637,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
if (cfgAddInt32(pCfg, "trimVDbIntervalSec", tsTrimVDbIntervalSec, 1, 100000, CFG_SCOPE_SERVER) != 0) return -1;
|
if (cfgAddInt32(pCfg, "trimVDbIntervalSec", tsTrimVDbIntervalSec, 1, 100000, CFG_SCOPE_SERVER) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "uptimeInterval", tsUptimeInterval, 1, 100000, CFG_SCOPE_SERVER) != 0) return -1;
|
if (cfgAddInt32(pCfg, "uptimeInterval", tsUptimeInterval, 1, 100000, CFG_SCOPE_SERVER) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "queryRsmaTolerance", tsQueryRsmaTolerance, 0, 900000, CFG_SCOPE_SERVER) != 0) return -1;
|
if (cfgAddInt32(pCfg, "queryRsmaTolerance", tsQueryRsmaTolerance, 0, 900000, CFG_SCOPE_SERVER) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "timeseriesThreshold", tsTimeSeriesThreshold, 0, 2000, CFG_SCOPE_SERVER) != 0) return -1;
|
||||||
|
|
||||||
if (cfgAddInt64(pCfg, "walFsyncDataSizeLimit", tsWalFsyncDataSizeLimit, 100 * 1024 * 1024, INT64_MAX,
|
if (cfgAddInt64(pCfg, "walFsyncDataSizeLimit", tsWalFsyncDataSizeLimit, 100 * 1024 * 1024, INT64_MAX,
|
||||||
CFG_SCOPE_SERVER) != 0)
|
CFG_SCOPE_SERVER) != 0)
|
||||||
|
@ -651,8 +654,15 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
if (cfgAddInt32(pCfg, "cacheLazyLoadThreshold", tsCacheLazyLoadThreshold, 0, 100000, CFG_SCOPE_SERVER) != 0)
|
if (cfgAddInt32(pCfg, "cacheLazyLoadThreshold", tsCacheLazyLoadThreshold, 0, 100000, CFG_SCOPE_SERVER) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (cfgAddString(pCfg, "LossyColumns", tsLossyColumns, CFG_SCOPE_SERVER) != 0) return -1;
|
||||||
|
if (cfgAddFloat(pCfg, "FPrecision", tsFPrecision, 0.0f, 100000.0f, CFG_SCOPE_SERVER) != 0) return -1;
|
||||||
|
if (cfgAddDouble(pCfg, "DPrecision", tsDPrecision, 0.0f, 1000000.0f, CFG_SCOPE_SERVER) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "MaxRange", tsMaxRange, 0, 65536, CFG_SCOPE_SERVER) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "CurRange", tsCurRange, 0, 65536, CFG_SCOPE_SERVER) != 0) return -1;
|
||||||
|
if (cfgAddBool(pCfg, "IfAdtFse", tsIfAdtFse, CFG_SCOPE_SERVER) != 0) return -1;
|
||||||
|
if (cfgAddString(pCfg, "Compressor", tsCompressor, CFG_SCOPE_SERVER) != 0) return -1;
|
||||||
|
|
||||||
if (cfgAddBool(pCfg, "filterScalarMode", tsFilterScalarMode, CFG_SCOPE_SERVER) != 0) return -1;
|
if (cfgAddBool(pCfg, "filterScalarMode", tsFilterScalarMode, CFG_SCOPE_SERVER) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "keepTimeOffset", tsKeepTimeOffset, 0, 23, CFG_SCOPE_SERVER) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "maxStreamBackendCache", tsMaxStreamBackendCache, 16, 1024, CFG_SCOPE_SERVER) != 0) return -1;
|
if (cfgAddInt32(pCfg, "maxStreamBackendCache", tsMaxStreamBackendCache, 16, 1024, CFG_SCOPE_SERVER) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "pqSortMemThreshold", tsPQSortMemThreshold, 1, 10240, CFG_SCOPE_SERVER) != 0) return -1;
|
if (cfgAddInt32(pCfg, "pqSortMemThreshold", tsPQSortMemThreshold, 1, 10240, CFG_SCOPE_SERVER) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "resolveFQDNRetryTime", tsResolveFQDNRetryTime, 1, 10240, 0) != 0) return -1;
|
if (cfgAddInt32(pCfg, "resolveFQDNRetryTime", tsResolveFQDNRetryTime, 1, 10240, 0) != 0) return -1;
|
||||||
|
@ -1043,6 +1053,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
tsTrimVDbIntervalSec = cfgGetItem(pCfg, "trimVDbIntervalSec")->i32;
|
tsTrimVDbIntervalSec = cfgGetItem(pCfg, "trimVDbIntervalSec")->i32;
|
||||||
tsUptimeInterval = cfgGetItem(pCfg, "uptimeInterval")->i32;
|
tsUptimeInterval = cfgGetItem(pCfg, "uptimeInterval")->i32;
|
||||||
tsQueryRsmaTolerance = cfgGetItem(pCfg, "queryRsmaTolerance")->i32;
|
tsQueryRsmaTolerance = cfgGetItem(pCfg, "queryRsmaTolerance")->i32;
|
||||||
|
tsTimeSeriesThreshold = cfgGetItem(pCfg, "timeseriesThreshold")->i32;
|
||||||
|
|
||||||
tsWalFsyncDataSizeLimit = cfgGetItem(pCfg, "walFsyncDataSizeLimit")->i64;
|
tsWalFsyncDataSizeLimit = cfgGetItem(pCfg, "walFsyncDataSizeLimit")->i64;
|
||||||
|
|
||||||
|
@ -1067,11 +1078,19 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
|
|
||||||
tsCacheLazyLoadThreshold = cfgGetItem(pCfg, "cacheLazyLoadThreshold")->i32;
|
tsCacheLazyLoadThreshold = cfgGetItem(pCfg, "cacheLazyLoadThreshold")->i32;
|
||||||
|
|
||||||
|
tstrncpy(tsLossyColumns, cfgGetItem(pCfg, "LossyColumns")->str, sizeof(tsLossyColumns));
|
||||||
|
tsFPrecision = cfgGetItem(pCfg, "FPrecision")->fval;
|
||||||
|
tsDPrecision = cfgGetItem(pCfg, "DPrecision")->dval;
|
||||||
|
tsMaxRange = cfgGetItem(pCfg, "MaxRange")->i32;
|
||||||
|
tsCurRange = cfgGetItem(pCfg, "CurRange")->i32;
|
||||||
|
tsIfAdtFse = cfgGetItem(pCfg, "IfAdtFse")->bval;
|
||||||
|
tstrncpy(tsCompressor, cfgGetItem(pCfg, "Compressor")->str, sizeof(tsCompressor));
|
||||||
|
|
||||||
|
|
||||||
tsDisableStream = cfgGetItem(pCfg, "disableStream")->bval;
|
tsDisableStream = cfgGetItem(pCfg, "disableStream")->bval;
|
||||||
tsStreamBufferSize = cfgGetItem(pCfg, "streamBufferSize")->i64;
|
tsStreamBufferSize = cfgGetItem(pCfg, "streamBufferSize")->i64;
|
||||||
|
|
||||||
tsFilterScalarMode = cfgGetItem(pCfg, "filterScalarMode")->bval;
|
tsFilterScalarMode = cfgGetItem(pCfg, "filterScalarMode")->bval;
|
||||||
tsKeepTimeOffset = cfgGetItem(pCfg, "keepTimeOffset")->i32;
|
|
||||||
tsMaxStreamBackendCache = cfgGetItem(pCfg, "maxStreamBackendCache")->i32;
|
tsMaxStreamBackendCache = cfgGetItem(pCfg, "maxStreamBackendCache")->i32;
|
||||||
tsPQSortMemThreshold = cfgGetItem(pCfg, "pqSortMemThreshold")->i32;
|
tsPQSortMemThreshold = cfgGetItem(pCfg, "pqSortMemThreshold")->i32;
|
||||||
tsResolveFQDNRetryTime = cfgGetItem(pCfg, "resolveFQDNRetryTime")->i32;
|
tsResolveFQDNRetryTime = cfgGetItem(pCfg, "resolveFQDNRetryTime")->i32;
|
||||||
|
@ -1458,6 +1477,8 @@ int32_t taosApplyLocalCfg(SConfig *pCfg, char *name) {
|
||||||
tqDebugFlag = cfgGetItem(pCfg, "tqDebugFlag")->i32;
|
tqDebugFlag = cfgGetItem(pCfg, "tqDebugFlag")->i32;
|
||||||
} else if (strcasecmp("ttlFlushThreshold", name) == 0) {
|
} else if (strcasecmp("ttlFlushThreshold", name) == 0) {
|
||||||
tsTtlFlushThreshold = cfgGetItem(pCfg, "ttlFlushThreshold")->i32;
|
tsTtlFlushThreshold = cfgGetItem(pCfg, "ttlFlushThreshold")->i32;
|
||||||
|
} else if (strcasecmp("timeseriesThreshold", name) == 0) {
|
||||||
|
tsTimeSeriesThreshold = cfgGetItem(pCfg, "timeseriesThreshold")->i32;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1667,13 +1688,6 @@ void taosCfgDynamicOptions(const char *option, const char *value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcasecmp(option, "keepTimeOffset") == 0) {
|
|
||||||
int32_t newKeepTimeOffset = atoi(value);
|
|
||||||
uInfo("keepTimeOffset set from %d to %d", tsKeepTimeOffset, newKeepTimeOffset);
|
|
||||||
tsKeepTimeOffset = newKeepTimeOffset;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcasecmp(option, "ttlPushInterval") == 0) {
|
if (strcasecmp(option, "ttlPushInterval") == 0) {
|
||||||
int32_t newTtlPushInterval = atoi(value);
|
int32_t newTtlPushInterval = atoi(value);
|
||||||
uInfo("ttlPushInterval set from %d to %d", tsTtlPushIntervalSec, newTtlPushInterval);
|
uInfo("ttlPushInterval set from %d to %d", tsTtlPushIntervalSec, newTtlPushInterval);
|
||||||
|
|
|
@ -1035,6 +1035,68 @@ int32_t tDeserializeSMDropFullTextReq(void *buf, int32_t bufLen, SMDropFullTextR
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSNotifyReq(void *buf, int32_t bufLen, SNotifyReq *pReq) {
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
|
||||||
|
if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1;
|
||||||
|
if (tEncodeI64(&encoder, pReq->clusterId) < 0) return -1;
|
||||||
|
|
||||||
|
int32_t nVgroup = taosArrayGetSize(pReq->pVloads);
|
||||||
|
if (tEncodeI32(&encoder, nVgroup) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < nVgroup; ++i) {
|
||||||
|
SVnodeLoadLite *vload = TARRAY_GET_ELEM(pReq->pVloads, i);
|
||||||
|
if (tEncodeI32(&encoder, vload->vgId) < 0) return -1;
|
||||||
|
if (tEncodeI64(&encoder, vload->nTimeSeries) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSNotifyReq(void *buf, int32_t bufLen, SNotifyReq *pReq) {
|
||||||
|
int32_t code = TSDB_CODE_INVALID_MSG;
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) goto _exit;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) goto _exit;
|
||||||
|
if (tDecodeI64(&decoder, &pReq->clusterId) < 0) goto _exit;
|
||||||
|
int32_t nVgroup = 0;
|
||||||
|
if (tDecodeI32(&decoder, &nVgroup) < 0) goto _exit;
|
||||||
|
if (nVgroup > 0) {
|
||||||
|
pReq->pVloads = taosArrayInit(nVgroup, sizeof(SVnodeLoadLite));
|
||||||
|
if (!pReq->pVloads) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
for (int32_t i = 0; i < nVgroup; ++i) {
|
||||||
|
SVnodeLoadLite vload;
|
||||||
|
if (tDecodeI32(&decoder, &(vload.vgId)) < 0) goto _exit;
|
||||||
|
if (tDecodeI64(&decoder, &(vload.nTimeSeries)) < 0) goto _exit;
|
||||||
|
taosArrayPush(pReq->pVloads, &vload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
code = 0;
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tFreeSNotifyReq(SNotifyReq *pReq) {
|
||||||
|
if (pReq) {
|
||||||
|
taosArrayDestroy(pReq->pVloads);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
@ -2632,6 +2694,7 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) {
|
||||||
if (tEncodeI8(&encoder, pRetension->keepUnit) < 0) return -1;
|
if (tEncodeI8(&encoder, pRetension->keepUnit) < 0) return -1;
|
||||||
}
|
}
|
||||||
if (tEncodeI32(&encoder, pReq->tsdbPageSize) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->tsdbPageSize) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->keepTimeOffset) < 0) return -1;
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -2694,6 +2757,11 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq)
|
||||||
|
|
||||||
if (tDecodeI32(&decoder, &pReq->tsdbPageSize) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->tsdbPageSize) < 0) return -1;
|
||||||
|
|
||||||
|
pReq->keepTimeOffset = TSDB_DEFAULT_KEEP_TIME_OFFSET;
|
||||||
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
|
if (tDecodeI32(&decoder, &pReq->keepTimeOffset) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -2731,6 +2799,7 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
|
||||||
// 2nd modification
|
// 2nd modification
|
||||||
if (tEncodeI32(&encoder, pReq->walRetentionPeriod) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->walRetentionPeriod) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->walRetentionSize) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->walRetentionSize) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->keepTimeOffset) < 0) return -1;
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -2774,6 +2843,10 @@ int32_t tDeserializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
|
||||||
pReq->walRetentionPeriod = -1;
|
pReq->walRetentionPeriod = -1;
|
||||||
pReq->walRetentionSize = -1;
|
pReq->walRetentionSize = -1;
|
||||||
}
|
}
|
||||||
|
pReq->keepTimeOffset = TSDB_DEFAULT_KEEP_TIME_OFFSET;
|
||||||
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
|
if (tDecodeI32(&decoder, &pReq->keepTimeOffset) < 0) return -1;
|
||||||
|
}
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -3400,6 +3473,7 @@ int32_t tDeserializeSVTrimDbReq(void *buf, int32_t bufLen, SVTrimDbReq *pReq) {
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->timestamp) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->timestamp) < 0) return -1;
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -3501,6 +3575,7 @@ int32_t tSerializeSDbCfgRspImpl(SEncoder *encoder, const SDbCfgRsp *pRsp) {
|
||||||
}
|
}
|
||||||
if (tEncodeI8(encoder, pRsp->schemaless) < 0) return -1;
|
if (tEncodeI8(encoder, pRsp->schemaless) < 0) return -1;
|
||||||
if (tEncodeI16(encoder, pRsp->sstTrigger) < 0) return -1;
|
if (tEncodeI16(encoder, pRsp->sstTrigger) < 0) return -1;
|
||||||
|
if (tEncodeI32(encoder, pRsp->keepTimeOffset) < 0) return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3569,6 +3644,10 @@ int32_t tDeserializeSDbCfgRspImpl(SDecoder *decoder, SDbCfgRsp *pRsp) {
|
||||||
}
|
}
|
||||||
if (tDecodeI8(decoder, &pRsp->schemaless) < 0) return -1;
|
if (tDecodeI8(decoder, &pRsp->schemaless) < 0) return -1;
|
||||||
if (tDecodeI16(decoder, &pRsp->sstTrigger) < 0) return -1;
|
if (tDecodeI16(decoder, &pRsp->sstTrigger) < 0) return -1;
|
||||||
|
pRsp->keepTimeOffset = TSDB_DEFAULT_KEEP_TIME_OFFSET;
|
||||||
|
if (!tDecodeIsEnd(decoder)) {
|
||||||
|
if (tDecodeI32(decoder, &pRsp->keepTimeOffset) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -4593,6 +4672,7 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
|
||||||
if (tEncodeSReplica(&encoder, pReplica) < 0) return -1;
|
if (tEncodeSReplica(&encoder, pReplica) < 0) return -1;
|
||||||
}
|
}
|
||||||
if (tEncodeI32(&encoder, pReq->changeVersion) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->changeVersion) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->keepTimeOffset) < 0) return -1;
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
@ -4682,6 +4762,10 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
|
||||||
if (!tDecodeIsEnd(&decoder)) {
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
if (tDecodeI32(&decoder, &pReq->changeVersion) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->changeVersion) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
pReq->keepTimeOffset = TSDB_DEFAULT_KEEP_TIME_OFFSET;
|
||||||
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
|
if (tDecodeI32(&decoder, &pReq->keepTimeOffset) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -4841,6 +4925,7 @@ int32_t tSerializeSAlterVnodeConfigReq(void *buf, int32_t bufLen, SAlterVnodeCon
|
||||||
// 2nd modification
|
// 2nd modification
|
||||||
if (tEncodeI32(&encoder, pReq->walRetentionPeriod) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->walRetentionPeriod) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->walRetentionSize) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->walRetentionSize) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->keepTimeOffset) < 0) return -1;
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -4887,6 +4972,11 @@ int32_t tDeserializeSAlterVnodeConfigReq(void *buf, int32_t bufLen, SAlterVnodeC
|
||||||
if (tDecodeI32(&decoder, &pReq->walRetentionPeriod) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->walRetentionPeriod) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->walRetentionSize) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->walRetentionSize) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
pReq->keepTimeOffset = TSDB_DEFAULT_KEEP_TIME_OFFSET;
|
||||||
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
|
if (tDecodeI32(&decoder, &pReq->keepTimeOffset) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -3,11 +3,22 @@ add_library(mgmt_dnode STATIC ${MGMT_DNODE})
|
||||||
if (DEFINED GRANT_CFG_INCLUDE_DIR)
|
if (DEFINED GRANT_CFG_INCLUDE_DIR)
|
||||||
add_definitions(-DGRANTS_CFG)
|
add_definitions(-DGRANTS_CFG)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
IF (NOT BUILD_DM_MODULE)
|
||||||
|
MESSAGE(STATUS "NOT BUILD_DM_MODULE")
|
||||||
|
target_link_directories(
|
||||||
|
mgmt_dnode
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/deps/${TD_DEPS_DIR}/dm_static"
|
||||||
|
)
|
||||||
|
ELSE()
|
||||||
|
MESSAGE(STATUS "BUILD_DM_MODULE")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
mgmt_dnode
|
mgmt_dnode
|
||||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
PUBLIC "${GRANT_CFG_INCLUDE_DIR}"
|
PUBLIC "${GRANT_CFG_INCLUDE_DIR}"
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
mgmt_dnode node_util
|
mgmt_dnode node_util dmodule
|
||||||
)
|
)
|
|
@ -28,6 +28,7 @@ typedef struct SDnodeMgmt {
|
||||||
const char *path;
|
const char *path;
|
||||||
const char *name;
|
const char *name;
|
||||||
TdThread statusThread;
|
TdThread statusThread;
|
||||||
|
TdThread notifyThread;
|
||||||
TdThread monitorThread;
|
TdThread monitorThread;
|
||||||
TdThread crashReportThread;
|
TdThread crashReportThread;
|
||||||
SSingleWorker mgmtWorker;
|
SSingleWorker mgmtWorker;
|
||||||
|
@ -36,6 +37,7 @@ typedef struct SDnodeMgmt {
|
||||||
ProcessDropNodeFp processDropNodeFp;
|
ProcessDropNodeFp processDropNodeFp;
|
||||||
SendMonitorReportFp sendMonitorReportFp;
|
SendMonitorReportFp sendMonitorReportFp;
|
||||||
GetVnodeLoadsFp getVnodeLoadsFp;
|
GetVnodeLoadsFp getVnodeLoadsFp;
|
||||||
|
GetVnodeLoadsFp getVnodeLoadsLiteFp;
|
||||||
GetMnodeLoadsFp getMnodeLoadsFp;
|
GetMnodeLoadsFp getMnodeLoadsFp;
|
||||||
GetQnodeLoadsFp getQnodeLoadsFp;
|
GetQnodeLoadsFp getQnodeLoadsFp;
|
||||||
int32_t statusSeq;
|
int32_t statusSeq;
|
||||||
|
@ -44,17 +46,21 @@ typedef struct SDnodeMgmt {
|
||||||
// dmHandle.c
|
// dmHandle.c
|
||||||
SArray *dmGetMsgHandles();
|
SArray *dmGetMsgHandles();
|
||||||
void dmSendStatusReq(SDnodeMgmt *pMgmt);
|
void dmSendStatusReq(SDnodeMgmt *pMgmt);
|
||||||
|
void dmSendNotifyReq(SDnodeMgmt *pMgmt);
|
||||||
int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t dmProcessAuthRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t dmProcessAuthRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t dmProcessGrantRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t dmProcessGrantRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t dmProcessServerRunStatus(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t dmProcessServerRunStatus(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t dmProcessRetrieve(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t dmProcessRetrieve(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t dmProcessGrantReq(void *pInfo, SRpcMsg *pMsg);
|
int32_t dmProcessGrantReq(void *pInfo, SRpcMsg *pMsg);
|
||||||
|
int32_t dmProcessGrantNotify(void *pInfo, SRpcMsg *pMsg);
|
||||||
|
|
||||||
// dmWorker.c
|
// dmWorker.c
|
||||||
int32_t dmPutNodeMsgToMgmtQueue(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t dmPutNodeMsgToMgmtQueue(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t dmStartStatusThread(SDnodeMgmt *pMgmt);
|
int32_t dmStartStatusThread(SDnodeMgmt *pMgmt);
|
||||||
void dmStopStatusThread(SDnodeMgmt *pMgmt);
|
void dmStopStatusThread(SDnodeMgmt *pMgmt);
|
||||||
|
int32_t dmStartNotifyThread(SDnodeMgmt *pMgmt);
|
||||||
|
void dmStopNotifyThread(SDnodeMgmt *pMgmt);
|
||||||
int32_t dmStartMonitorThread(SDnodeMgmt *pMgmt);
|
int32_t dmStartMonitorThread(SDnodeMgmt *pMgmt);
|
||||||
void dmStopMonitorThread(SDnodeMgmt *pMgmt);
|
void dmStopMonitorThread(SDnodeMgmt *pMgmt);
|
||||||
int32_t dmStartCrashReportThread(SDnodeMgmt *pMgmt);
|
int32_t dmStartCrashReportThread(SDnodeMgmt *pMgmt);
|
||||||
|
|
|
@ -170,6 +170,36 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
dmProcessStatusRsp(pMgmt, &rpcRsp);
|
dmProcessStatusRsp(pMgmt, &rpcRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dmSendNotifyReq(SDnodeMgmt *pMgmt) {
|
||||||
|
SNotifyReq req = {0};
|
||||||
|
|
||||||
|
taosThreadRwlockRdlock(&pMgmt->pData->lock);
|
||||||
|
req.dnodeId = pMgmt->pData->dnodeId;
|
||||||
|
taosThreadRwlockUnlock(&pMgmt->pData->lock);
|
||||||
|
|
||||||
|
req.clusterId = pMgmt->pData->clusterId;
|
||||||
|
|
||||||
|
SMonVloadInfo vinfo = {0};
|
||||||
|
(*pMgmt->getVnodeLoadsLiteFp)(&vinfo);
|
||||||
|
req.pVloads = vinfo.pVloads;
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSNotifyReq(NULL, 0, &req);
|
||||||
|
void *pHead = rpcMallocCont(contLen);
|
||||||
|
tSerializeSNotifyReq(pHead, contLen, &req);
|
||||||
|
tFreeSNotifyReq(&req);
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {.pCont = pHead,
|
||||||
|
.contLen = contLen,
|
||||||
|
.msgType = TDMT_MND_NOTIFY,
|
||||||
|
.info.ahandle = (void *)0x9527,
|
||||||
|
.info.refId = 0,
|
||||||
|
.info.noResp = 1};
|
||||||
|
|
||||||
|
SEpSet epSet = {0};
|
||||||
|
dmGetMnodeEpSet(pMgmt->pData, &epSet);
|
||||||
|
rpcSendRequest(pMgmt->msgCb.clientRpc, &epSet, &rpcMsg, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t dmProcessAuthRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
int32_t dmProcessAuthRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
dError("auth rsp is received, but not supported yet");
|
dError("auth rsp is received, but not supported yet");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -395,6 +425,7 @@ SArray *dmGetMsgHandles() {
|
||||||
|
|
||||||
// Requests handled by MNODE
|
// Requests handled by MNODE
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT_NOTIFY, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH_RSP, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH_RSP, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
|
@ -15,11 +15,17 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmInt.h"
|
#include "dmInt.h"
|
||||||
|
#include "libs/function/tudf.h"
|
||||||
|
|
||||||
static int32_t dmStartMgmt(SDnodeMgmt *pMgmt) {
|
static int32_t dmStartMgmt(SDnodeMgmt *pMgmt) {
|
||||||
if (dmStartStatusThread(pMgmt) != 0) {
|
if (dmStartStatusThread(pMgmt) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#if defined(TD_ENTERPRISE) && !defined(_TD_DARWIN_64)
|
||||||
|
if (dmStartNotifyThread(pMgmt) != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (dmStartMonitorThread(pMgmt) != 0) {
|
if (dmStartMonitorThread(pMgmt) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +39,7 @@ static void dmStopMgmt(SDnodeMgmt *pMgmt) {
|
||||||
pMgmt->pData->stopped = true;
|
pMgmt->pData->stopped = true;
|
||||||
dmStopMonitorThread(pMgmt);
|
dmStopMonitorThread(pMgmt);
|
||||||
dmStopStatusThread(pMgmt);
|
dmStopStatusThread(pMgmt);
|
||||||
|
dmStopNotifyThread(pMgmt);
|
||||||
dmStopCrashReportThread(pMgmt);
|
dmStopCrashReportThread(pMgmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +59,7 @@ static int32_t dmOpenMgmt(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
||||||
pMgmt->processDropNodeFp = pInput->processDropNodeFp;
|
pMgmt->processDropNodeFp = pInput->processDropNodeFp;
|
||||||
pMgmt->sendMonitorReportFp = pInput->sendMonitorReportFp;
|
pMgmt->sendMonitorReportFp = pInput->sendMonitorReportFp;
|
||||||
pMgmt->getVnodeLoadsFp = pInput->getVnodeLoadsFp;
|
pMgmt->getVnodeLoadsFp = pInput->getVnodeLoadsFp;
|
||||||
|
pMgmt->getVnodeLoadsLiteFp = pInput->getVnodeLoadsLiteFp;
|
||||||
pMgmt->getMnodeLoadsFp = pInput->getMnodeLoadsFp;
|
pMgmt->getMnodeLoadsFp = pInput->getMnodeLoadsFp;
|
||||||
pMgmt->getQnodeLoadsFp = pInput->getQnodeLoadsFp;
|
pMgmt->getQnodeLoadsFp = pInput->getQnodeLoadsFp;
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,31 @@ static void *dmStatusThreadFp(void *param) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDmNotifyHandle dmNotifyHdl = {.state = 0};
|
||||||
|
static void *dmNotifyThreadFp(void *param) {
|
||||||
|
SDnodeMgmt *pMgmt = param;
|
||||||
|
setThreadName("dnode-notify");
|
||||||
|
|
||||||
|
if (tsem_init(&dmNotifyHdl.sem, 0, 0) != 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wait = true;
|
||||||
|
while (1) {
|
||||||
|
if (pMgmt->pData->dropped || pMgmt->pData->stopped) break;
|
||||||
|
if (wait) tsem_wait(&dmNotifyHdl.sem);
|
||||||
|
atomic_store_8(&dmNotifyHdl.state, 1);
|
||||||
|
dmSendNotifyReq(pMgmt);
|
||||||
|
if (1 == atomic_val_compare_exchange_8(&dmNotifyHdl.state, 1, 0)) {
|
||||||
|
wait = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
wait = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void *dmMonitorThreadFp(void *param) {
|
static void *dmMonitorThreadFp(void *param) {
|
||||||
SDnodeMgmt *pMgmt = param;
|
SDnodeMgmt *pMgmt = param;
|
||||||
int64_t lastTime = taosGetTimestampMs();
|
int64_t lastTime = taosGetTimestampMs();
|
||||||
|
@ -132,7 +157,6 @@ static void *dmCrashReportThreadFp(void *param) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t dmStartStatusThread(SDnodeMgmt *pMgmt) {
|
int32_t dmStartStatusThread(SDnodeMgmt *pMgmt) {
|
||||||
TdThreadAttr thAttr;
|
TdThreadAttr thAttr;
|
||||||
taosThreadAttrInit(&thAttr);
|
taosThreadAttrInit(&thAttr);
|
||||||
|
@ -154,6 +178,29 @@ void dmStopStatusThread(SDnodeMgmt *pMgmt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t dmStartNotifyThread(SDnodeMgmt *pMgmt) {
|
||||||
|
TdThreadAttr thAttr;
|
||||||
|
taosThreadAttrInit(&thAttr);
|
||||||
|
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||||
|
if (taosThreadCreate(&pMgmt->notifyThread, &thAttr, dmNotifyThreadFp, pMgmt) != 0) {
|
||||||
|
dError("failed to create notify thread since %s", strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosThreadAttrDestroy(&thAttr);
|
||||||
|
tmsgReportStartup("dnode-notify", "initialized");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dmStopNotifyThread(SDnodeMgmt *pMgmt) {
|
||||||
|
if (taosCheckPthreadValid(pMgmt->notifyThread)) {
|
||||||
|
tsem_post(&dmNotifyHdl.sem);
|
||||||
|
taosThreadJoin(pMgmt->notifyThread, NULL);
|
||||||
|
taosThreadClear(&pMgmt->notifyThread);
|
||||||
|
}
|
||||||
|
tsem_destroy(&dmNotifyHdl.sem);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t dmStartMonitorThread(SDnodeMgmt *pMgmt) {
|
int32_t dmStartMonitorThread(SDnodeMgmt *pMgmt) {
|
||||||
TdThreadAttr thAttr;
|
TdThreadAttr thAttr;
|
||||||
taosThreadAttrInit(&thAttr);
|
taosThreadAttrInit(&thAttr);
|
||||||
|
@ -204,7 +251,6 @@ void dmStopCrashReportThread(SDnodeMgmt *pMgmt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||||
SDnodeMgmt *pMgmt = pInfo->ahandle;
|
SDnodeMgmt *pMgmt = pInfo->ahandle;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
@ -251,6 +297,9 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||||
case TDMT_MND_GRANT:
|
case TDMT_MND_GRANT:
|
||||||
code = dmProcessGrantReq(&pMgmt->pData->clusterId, pMsg);
|
code = dmProcessGrantReq(&pMgmt->pData->clusterId, pMsg);
|
||||||
break;
|
break;
|
||||||
|
case TDMT_MND_GRANT_NOTIFY:
|
||||||
|
code = dmProcessGrantNotify(NULL, pMsg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||||
dGError("msg:%p, not processed in mgmt queue", pMsg);
|
dGError("msg:%p, not processed in mgmt queue", pMsg);
|
||||||
|
|
|
@ -178,6 +178,7 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_CONN, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_CONN, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_HEARTBEAT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_HEARTBEAT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STATUS, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_STATUS, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_MND_NOTIFY, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SYSTABLE_RETRIEVE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_SYSTABLE_RETRIEVE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SHOW_VARIABLES, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_SHOW_VARIABLES, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "qmInt.h"
|
#include "qmInt.h"
|
||||||
|
#include "libs/function/tudf.h"
|
||||||
|
|
||||||
static int32_t qmRequire(const SMgmtInputOpt *pInput, bool *required) {
|
static int32_t qmRequire(const SMgmtInputOpt *pInput, bool *required) {
|
||||||
return dmReadFile(pInput->path, pInput->name, required);
|
return dmReadFile(pInput->path, pInput->name, required);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "smInt.h"
|
#include "smInt.h"
|
||||||
#include "libs/function/function.h"
|
#include "libs/function/function.h"
|
||||||
|
#include "libs/function/tudf.h"
|
||||||
|
|
||||||
static int32_t smRequire(const SMgmtInputOpt *pInput, bool *required) {
|
static int32_t smRequire(const SMgmtInputOpt *pInput, bool *required) {
|
||||||
return dmReadFile(pInput->path, pInput->name, required);
|
return dmReadFile(pInput->path, pInput->name, required);
|
||||||
|
|
|
@ -40,6 +40,28 @@ void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo, bool isReset) {
|
||||||
taosThreadRwlockUnlock(&pMgmt->lock);
|
taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vmGetVnodeLoadsLite(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo) {
|
||||||
|
pInfo->pVloads = taosArrayInit(pMgmt->state.totalVnodes, sizeof(SVnodeLoadLite));
|
||||||
|
if (!pInfo->pVloads) return;
|
||||||
|
|
||||||
|
taosThreadRwlockRdlock(&pMgmt->lock);
|
||||||
|
|
||||||
|
void *pIter = taosHashIterate(pMgmt->hash, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
SVnodeObj **ppVnode = pIter;
|
||||||
|
if (ppVnode == NULL || *ppVnode == NULL) continue;
|
||||||
|
|
||||||
|
SVnodeObj *pVnode = *ppVnode;
|
||||||
|
SVnodeLoadLite vload = {0};
|
||||||
|
if (vnodeGetLoadLite(pVnode->pImpl, &vload) == 0) {
|
||||||
|
taosArrayPush(pInfo->pVloads, &vload);
|
||||||
|
}
|
||||||
|
pIter = taosHashIterate(pMgmt->hash, pIter);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
|
}
|
||||||
|
|
||||||
void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) {
|
void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) {
|
||||||
SMonVloadInfo vloads = {0};
|
SMonVloadInfo vloads = {0};
|
||||||
vmGetVnodeLoads(pMgmt, &vloads, true);
|
vmGetVnodeLoads(pMgmt, &vloads, true);
|
||||||
|
@ -104,6 +126,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
||||||
pCfg->tsdbCfg.keep0 = pCreate->daysToKeep0;
|
pCfg->tsdbCfg.keep0 = pCreate->daysToKeep0;
|
||||||
pCfg->tsdbCfg.keep1 = pCreate->daysToKeep1;
|
pCfg->tsdbCfg.keep1 = pCreate->daysToKeep1;
|
||||||
pCfg->tsdbCfg.keep2 = pCreate->daysToKeep2;
|
pCfg->tsdbCfg.keep2 = pCreate->daysToKeep2;
|
||||||
|
pCfg->tsdbCfg.keepTimeOffset = pCreate->keepTimeOffset;
|
||||||
pCfg->tsdbCfg.minRows = pCreate->minRows;
|
pCfg->tsdbCfg.minRows = pCreate->minRows;
|
||||||
pCfg->tsdbCfg.maxRows = pCreate->maxRows;
|
pCfg->tsdbCfg.maxRows = pCreate->maxRows;
|
||||||
for (size_t i = 0; i < taosArrayGetSize(pCreate->pRetensions); ++i) {
|
for (size_t i = 0; i < taosArrayGetSize(pCreate->pRetensions); ++i) {
|
||||||
|
@ -209,15 +232,15 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
dInfo(
|
dInfo(
|
||||||
"vgId:%d, vnode management handle msgType:%s, start to create vnode, page:%d pageSize:%d buffer:%d szPage:%d "
|
"vgId:%d, vnode management handle msgType:%s, start to create vnode, page:%d pageSize:%d buffer:%d szPage:%d "
|
||||||
"szBuf:%" PRIu64 ", cacheLast:%d cacheLastSize:%d sstTrigger:%d tsdbPageSize:%d %d dbname:%s dbId:%" PRId64
|
"szBuf:%" PRIu64 ", cacheLast:%d cacheLastSize:%d sstTrigger:%d tsdbPageSize:%d %d dbname:%s dbId:%" PRId64
|
||||||
", days:%d keep0:%d keep1:%d keep2:%d tsma:%d precision:%d compression:%d minRows:%d maxRows:%d"
|
", days:%d keep0:%d keep1:%d keep2:%d keepTimeOffset%d tsma:%d precision:%d compression:%d minRows:%d maxRows:%d"
|
||||||
", wal fsync:%d level:%d retentionPeriod:%d retentionSize:%" PRId64 " rollPeriod:%d segSize:%" PRId64
|
", wal fsync:%d level:%d retentionPeriod:%d retentionSize:%" PRId64 " rollPeriod:%d segSize:%" PRId64
|
||||||
", hash method:%d begin:%u end:%u prefix:%d surfix:%d replica:%d selfIndex:%d "
|
", hash method:%d begin:%u end:%u prefix:%d surfix:%d replica:%d selfIndex:%d "
|
||||||
"learnerReplica:%d learnerSelfIndex:%d strict:%d changeVersion:%d",
|
"learnerReplica:%d learnerSelfIndex:%d strict:%d changeVersion:%d",
|
||||||
req.vgId, TMSG_INFO(pMsg->msgType), req.pages, req.pageSize, req.buffer, req.pageSize * 1024,
|
req.vgId, TMSG_INFO(pMsg->msgType), req.pages, req.pageSize, req.buffer, req.pageSize * 1024,
|
||||||
(uint64_t)req.buffer * 1024 * 1024, req.cacheLast, req.cacheLastSize, req.sstTrigger, req.tsdbPageSize,
|
(uint64_t)req.buffer * 1024 * 1024, req.cacheLast, req.cacheLastSize, req.sstTrigger, req.tsdbPageSize,
|
||||||
req.tsdbPageSize * 1024, req.db, req.dbUid, req.daysPerFile, req.daysToKeep0, req.daysToKeep1, req.daysToKeep2,
|
req.tsdbPageSize * 1024, req.db, req.dbUid, req.daysPerFile, req.daysToKeep0, req.daysToKeep1, req.daysToKeep2,
|
||||||
req.isTsma, req.precision, req.compression, req.minRows, req.maxRows, req.walFsyncPeriod, req.walLevel,
|
req.keepTimeOffset, req.isTsma, req.precision, req.compression, req.minRows, req.maxRows, req.walFsyncPeriod,
|
||||||
req.walRetentionPeriod, req.walRetentionSize, req.walRollPeriod, req.walSegmentSize, req.hashMethod,
|
req.walLevel, req.walRetentionPeriod, req.walRetentionSize, req.walRollPeriod, req.walSegmentSize, req.hashMethod,
|
||||||
req.hashBegin, req.hashEnd, req.hashPrefix, req.hashSuffix, req.replica, req.selfIndex, req.learnerReplica,
|
req.hashBegin, req.hashEnd, req.hashPrefix, req.hashSuffix, req.replica, req.selfIndex, req.learnerReplica,
|
||||||
req.learnerSelfIndex, req.strict, req.changeVersion);
|
req.learnerSelfIndex, req.strict, req.changeVersion);
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "vmInt.h"
|
#include "vmInt.h"
|
||||||
#include "tfs.h"
|
#include "tfs.h"
|
||||||
#include "vnd.h"
|
#include "vnd.h"
|
||||||
|
#include "libs/function/tudf.h"
|
||||||
|
|
||||||
int32_t vmAllocPrimaryDisk(SVnodeMgmt *pMgmt, int32_t vgId) {
|
int32_t vmAllocPrimaryDisk(SVnodeMgmt *pMgmt, int32_t vgId) {
|
||||||
STfs *pTfs = pMgmt->pTfs;
|
STfs *pTfs = pMgmt->pTfs;
|
||||||
|
|
|
@ -95,6 +95,10 @@ void dmCleanupDnode(SDnode *pDnode);
|
||||||
SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType nType);
|
SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType nType);
|
||||||
int32_t dmMarkWrapper(SMgmtWrapper *pWrapper);
|
int32_t dmMarkWrapper(SMgmtWrapper *pWrapper);
|
||||||
void dmReleaseWrapper(SMgmtWrapper *pWrapper);
|
void dmReleaseWrapper(SMgmtWrapper *pWrapper);
|
||||||
|
int32_t dmInitVars(SDnode *pDnode);
|
||||||
|
void dmClearVars(SDnode *pDnode);
|
||||||
|
int32_t dmInitModule(SDnode *pDnode);
|
||||||
|
bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper);
|
||||||
SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper);
|
SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper);
|
||||||
void dmSetStatus(SDnode *pDnode, EDndRunStatus stype);
|
void dmSetStatus(SDnode *pDnode, EDndRunStatus stype);
|
||||||
void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg);
|
void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg);
|
||||||
|
@ -119,6 +123,7 @@ int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
||||||
// dmMonitor.c
|
// dmMonitor.c
|
||||||
void dmSendMonitorReport();
|
void dmSendMonitorReport();
|
||||||
void dmGetVnodeLoads(SMonVloadInfo *pInfo);
|
void dmGetVnodeLoads(SMonVloadInfo *pInfo);
|
||||||
|
void dmGetVnodeLoadsLite(SMonVloadInfo *pInfo);
|
||||||
void dmGetMnodeLoads(SMonMloadInfo *pInfo);
|
void dmGetMnodeLoads(SMonMloadInfo *pInfo);
|
||||||
void dmGetQnodeLoads(SQnodeLoad *pInfo);
|
void dmGetQnodeLoads(SQnodeLoad *pInfo);
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ void smGetMonitorInfo(void *pMgmt, SMonSmInfo *pInfo);
|
||||||
void bmGetMonitorInfo(void *pMgmt, SMonBmInfo *pInfo);
|
void bmGetMonitorInfo(void *pMgmt, SMonBmInfo *pInfo);
|
||||||
|
|
||||||
void vmGetVnodeLoads(void *pMgmt, SMonVloadInfo *pInfo, bool isReset);
|
void vmGetVnodeLoads(void *pMgmt, SMonVloadInfo *pInfo, bool isReset);
|
||||||
|
void vmGetVnodeLoadsLite(void *pMgmt, SMonVloadInfo *pInfo);
|
||||||
void mmGetMnodeLoads(void *pMgmt, SMonMloadInfo *pInfo);
|
void mmGetMnodeLoads(void *pMgmt, SMonMloadInfo *pInfo);
|
||||||
void qmGetQnodeLoads(void *pMgmt, SQnodeLoad *pInfo);
|
void qmGetQnodeLoads(void *pMgmt, SQnodeLoad *pInfo);
|
||||||
|
|
||||||
|
|
|
@ -16,24 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmMgmt.h"
|
#include "dmMgmt.h"
|
||||||
#include "audit.h"
|
#include "audit.h"
|
||||||
|
#include "libs/function/tudf.h"
|
||||||
#define STR_CASE_CMP(s, d) (0 == strcasecmp((s), (d)))
|
|
||||||
#define STR_STR_CMP(s, d) (strstr((s), (d)))
|
|
||||||
#define STR_INT_CMP(s, d, c) (taosStr2Int32(s, 0, 10) c(d))
|
|
||||||
#define STR_STR_SIGN ("ia")
|
|
||||||
#define DM_INIT_MON() \
|
|
||||||
do { \
|
|
||||||
code = (int32_t)(2147483648 | 298); \
|
|
||||||
strncpy(stName, tsVersionName, 64); \
|
|
||||||
monCfg.maxLogs = tsMonitorMaxLogs; \
|
|
||||||
monCfg.port = tsMonitorPort; \
|
|
||||||
monCfg.server = tsMonitorFqdn; \
|
|
||||||
monCfg.comp = tsMonitorComp; \
|
|
||||||
if (monInit(&monCfg) != 0) { \
|
|
||||||
if (terrno != 0) code = terrno; \
|
|
||||||
goto _exit; \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define DM_INIT_AUDIT() \
|
#define DM_INIT_AUDIT() \
|
||||||
do { \
|
do { \
|
||||||
|
@ -45,15 +28,7 @@
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define DM_ERR_RTN(c) \
|
|
||||||
do { \
|
|
||||||
code = (c); \
|
|
||||||
goto _exit; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
static SDnode globalDnode = {0};
|
static SDnode globalDnode = {0};
|
||||||
static const char *dmOS[10] = {"Ubuntu", "CentOS Linux", "Red Hat", "Debian GNU", "CoreOS",
|
|
||||||
"FreeBSD", "openSUSE", "SLES", "Fedora", "macOS"};
|
|
||||||
|
|
||||||
SDnode *dmInstance() { return &globalDnode; }
|
SDnode *dmInstance() { return &globalDnode; }
|
||||||
|
|
||||||
|
@ -76,30 +51,14 @@ static int32_t dmInitSystem() {
|
||||||
static int32_t dmInitMonitor() {
|
static int32_t dmInitMonitor() {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SMonCfg monCfg = {0};
|
SMonCfg monCfg = {0};
|
||||||
char reName[64] = {0};
|
|
||||||
char stName[64] = {0};
|
|
||||||
char ver[64] = {0};
|
|
||||||
|
|
||||||
DM_INIT_MON();
|
monCfg.maxLogs = tsMonitorMaxLogs;
|
||||||
|
monCfg.port = tsMonitorPort;
|
||||||
if (STR_STR_CMP(stName, STR_STR_SIGN)) {
|
monCfg.server = tsMonitorFqdn;
|
||||||
DM_ERR_RTN(0);
|
monCfg.comp = tsMonitorComp;
|
||||||
}
|
if (monInit(&monCfg) != 0) {
|
||||||
if (taosGetOsReleaseName(reName, stName, ver, 64) != 0) {
|
if (terrno != 0) code = terrno;
|
||||||
DM_ERR_RTN(code);
|
goto _exit;
|
||||||
}
|
|
||||||
if (STR_CASE_CMP(stName, dmOS[0])) {
|
|
||||||
if (STR_INT_CMP(ver, 17, >)) {
|
|
||||||
DM_ERR_RTN(0);
|
|
||||||
}
|
|
||||||
} else if (STR_CASE_CMP(stName, dmOS[1])) {
|
|
||||||
if (STR_INT_CMP(ver, 6, >)) {
|
|
||||||
DM_ERR_RTN(0);
|
|
||||||
}
|
|
||||||
} else if (STR_STR_CMP(stName, dmOS[2]) || STR_STR_CMP(stName, dmOS[3]) || STR_STR_CMP(stName, dmOS[4]) ||
|
|
||||||
STR_STR_CMP(stName, dmOS[5]) || STR_STR_CMP(stName, dmOS[6]) || STR_STR_CMP(stName, dmOS[7]) ||
|
|
||||||
STR_STR_CMP(stName, dmOS[8]) || STR_STR_CMP(stName, dmOS[9])) {
|
|
||||||
DM_ERR_RTN(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -419,6 +378,7 @@ SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper) {
|
||||||
.processDropNodeFp = dmProcessDropNodeReq,
|
.processDropNodeFp = dmProcessDropNodeReq,
|
||||||
.sendMonitorReportFp = dmSendMonitorReport,
|
.sendMonitorReportFp = dmSendMonitorReport,
|
||||||
.getVnodeLoadsFp = dmGetVnodeLoads,
|
.getVnodeLoadsFp = dmGetVnodeLoads,
|
||||||
|
.getVnodeLoadsLiteFp = dmGetVnodeLoadsLite,
|
||||||
.getMnodeLoadsFp = dmGetMnodeLoads,
|
.getMnodeLoadsFp = dmGetMnodeLoads,
|
||||||
.getQnodeLoadsFp = dmGetQnodeLoads,
|
.getQnodeLoadsFp = dmGetQnodeLoads,
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,88 +19,10 @@
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
#include "qworker.h"
|
#include "qworker.h"
|
||||||
#include "tstream.h"
|
#include "tstream.h"
|
||||||
|
#ifdef TD_TSZ
|
||||||
static bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper) {
|
#include "tglobal.h"
|
||||||
SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper);
|
#include "tcompression.h"
|
||||||
|
#endif
|
||||||
bool required = false;
|
|
||||||
int32_t code = (*pWrapper->func.requiredFp)(&input, &required);
|
|
||||||
if (!required) {
|
|
||||||
dDebug("node:%s, does not require startup", pWrapper->name);
|
|
||||||
} else {
|
|
||||||
dDebug("node:%s, required to startup", pWrapper->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return required;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t dmInitVars(SDnode *pDnode) {
|
|
||||||
SDnodeData *pData = &pDnode->data;
|
|
||||||
pData->dnodeId = 0;
|
|
||||||
pData->clusterId = 0;
|
|
||||||
pData->dnodeVer = 0;
|
|
||||||
pData->updateTime = 0;
|
|
||||||
pData->rebootTime = taosGetTimestampMs();
|
|
||||||
pData->dropped = 0;
|
|
||||||
pData->stopped = 0;
|
|
||||||
|
|
||||||
pData->dnodeHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
|
||||||
if (pData->dnodeHash == NULL) {
|
|
||||||
dError("failed to init dnode hash");
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dmReadEps(pData) != 0) {
|
|
||||||
dError("failed to read file since %s", terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pData->dropped) {
|
|
||||||
dError("dnode will not start since its already dropped");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosThreadRwlockInit(&pData->lock, NULL);
|
|
||||||
taosThreadMutexInit(&pDnode->mutex, NULL);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void dmClearVars(SDnode *pDnode) {
|
|
||||||
for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) {
|
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
|
||||||
taosMemoryFreeClear(pWrapper->path);
|
|
||||||
taosThreadRwlockDestroy(&pWrapper->lock);
|
|
||||||
}
|
|
||||||
if (pDnode->lockfile != NULL) {
|
|
||||||
taosUnLockFile(pDnode->lockfile);
|
|
||||||
taosCloseFile(&pDnode->lockfile);
|
|
||||||
pDnode->lockfile = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDnodeData *pData = &pDnode->data;
|
|
||||||
taosThreadRwlockWrlock(&pData->lock);
|
|
||||||
if (pData->oldDnodeEps != NULL) {
|
|
||||||
if (dmWriteEps(pData) == 0) {
|
|
||||||
dmRemoveDnodePairs(pData);
|
|
||||||
}
|
|
||||||
taosArrayDestroy(pData->oldDnodeEps);
|
|
||||||
pData->oldDnodeEps = NULL;
|
|
||||||
}
|
|
||||||
if (pData->dnodeEps != NULL) {
|
|
||||||
taosArrayDestroy(pData->dnodeEps);
|
|
||||||
pData->dnodeEps = NULL;
|
|
||||||
}
|
|
||||||
if (pData->dnodeHash != NULL) {
|
|
||||||
taosHashCleanup(pData->dnodeHash);
|
|
||||||
pData->dnodeHash = NULL;
|
|
||||||
}
|
|
||||||
taosThreadRwlockUnlock(&pData->lock);
|
|
||||||
|
|
||||||
taosThreadRwlockDestroy(&pData->lock);
|
|
||||||
taosThreadMutexDestroy(&pDnode->mutex);
|
|
||||||
memset(&pDnode->mutex, 0, sizeof(pDnode->mutex));
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t dmInitDnode(SDnode *pDnode) {
|
int32_t dmInitDnode(SDnode *pDnode) {
|
||||||
dDebug("start to create dnode");
|
dDebug("start to create dnode");
|
||||||
|
@ -111,6 +33,11 @@ int32_t dmInitDnode(SDnode *pDnode) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TD_TSZ
|
||||||
|
// compress module init
|
||||||
|
tsCompressInit(tsLossyColumns, tsFPrecision, tsDPrecision, tsMaxRange, tsCurRange, (int)tsIfAdtFse, tsCompressor);
|
||||||
|
#endif
|
||||||
|
|
||||||
pDnode->wrappers[DNODE].func = dmGetMgmtFunc();
|
pDnode->wrappers[DNODE].func = dmGetMgmtFunc();
|
||||||
pDnode->wrappers[MNODE].func = mmGetMgmtFunc();
|
pDnode->wrappers[MNODE].func = mmGetMgmtFunc();
|
||||||
pDnode->wrappers[VNODE].func = vmGetMgmtFunc();
|
pDnode->wrappers[VNODE].func = vmGetMgmtFunc();
|
||||||
|
@ -134,22 +61,12 @@ int32_t dmInitDnode(SDnode *pDnode) {
|
||||||
pWrapper->required = dmRequireNode(pDnode, pWrapper);
|
pWrapper->required = dmRequireNode(pDnode, pWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dmInitMsgHandle(pDnode) != 0) {
|
|
||||||
dError("failed to init msg handles since %s", terrstr());
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
pDnode->lockfile = dmCheckRunning(tsDataDir);
|
pDnode->lockfile = dmCheckRunning(tsDataDir);
|
||||||
if (pDnode->lockfile == NULL) {
|
if (pDnode->lockfile == NULL) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dmInitServer(pDnode) != 0) {
|
if(dmInitModule(pDnode) != 0) {
|
||||||
dError("failed to init transport since %s", terrstr());
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dmInitClient(pDnode) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,6 +97,12 @@ void dmCleanupDnode(SDnode *pDnode) {
|
||||||
streamMetaCleanup();
|
streamMetaCleanup();
|
||||||
indexCleanup();
|
indexCleanup();
|
||||||
taosConvDestroy();
|
taosConvDestroy();
|
||||||
|
|
||||||
|
#ifdef TD_TSZ
|
||||||
|
// compress destroy
|
||||||
|
tsCompressExit();
|
||||||
|
#endif
|
||||||
|
|
||||||
dDebug("dnode is closed, ptr:%p", pDnode);
|
dDebug("dnode is closed, ptr:%p", pDnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,17 @@ void dmGetVnodeLoads(SMonVloadInfo *pInfo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dmGetVnodeLoadsLite(SMonVloadInfo *pInfo) {
|
||||||
|
SDnode *pDnode = dmInstance();
|
||||||
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[VNODE];
|
||||||
|
if (dmMarkWrapper(pWrapper) == 0) {
|
||||||
|
if (pWrapper->pMgmt != NULL) {
|
||||||
|
vmGetVnodeLoadsLite(pWrapper->pMgmt, pInfo);
|
||||||
|
}
|
||||||
|
dmReleaseWrapper(pWrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void dmGetMnodeLoads(SMonMloadInfo *pInfo) {
|
void dmGetMnodeLoads(SMonMloadInfo *pInfo) {
|
||||||
SDnode *pDnode = dmInstance();
|
SDnode *pDnode = dmInstance();
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[MNODE];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[MNODE];
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
#include "tfs.h"
|
#include "tfs.h"
|
||||||
#include "wal.h"
|
#include "wal.h"
|
||||||
|
|
||||||
#include "libs/function/tudf.h"
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -94,6 +93,7 @@ typedef int32_t (*ProcessAlterNodeTypeFp)(EDndNodeType ntype, SRpcMsg *pMsg);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
|
int32_t engineVer;
|
||||||
int64_t clusterId;
|
int64_t clusterId;
|
||||||
int64_t dnodeVer;
|
int64_t dnodeVer;
|
||||||
int64_t updateTime;
|
int64_t updateTime;
|
||||||
|
@ -121,6 +121,7 @@ typedef struct {
|
||||||
ProcessDropNodeFp processDropNodeFp;
|
ProcessDropNodeFp processDropNodeFp;
|
||||||
SendMonitorReportFp sendMonitorReportFp;
|
SendMonitorReportFp sendMonitorReportFp;
|
||||||
GetVnodeLoadsFp getVnodeLoadsFp;
|
GetVnodeLoadsFp getVnodeLoadsFp;
|
||||||
|
GetVnodeLoadsFp getVnodeLoadsLiteFp;
|
||||||
GetMnodeLoadsFp getMnodeLoadsFp;
|
GetMnodeLoadsFp getMnodeLoadsFp;
|
||||||
GetQnodeLoadsFp getQnodeLoadsFp;
|
GetQnodeLoadsFp getQnodeLoadsFp;
|
||||||
} SMgmtInputOpt;
|
} SMgmtInputOpt;
|
||||||
|
@ -171,6 +172,9 @@ int32_t dmReadFile(const char *path, const char *name, bool *pDeployed);
|
||||||
int32_t dmWriteFile(const char *path, const char *name, bool deployed);
|
int32_t dmWriteFile(const char *path, const char *name, bool deployed);
|
||||||
TdFilePtr dmCheckRunning(const char *dataDir);
|
TdFilePtr dmCheckRunning(const char *dataDir);
|
||||||
|
|
||||||
|
// dmodule.c
|
||||||
|
int32_t dmInitDndInfo(SDnodeData *pData);
|
||||||
|
|
||||||
// dmEps.c
|
// dmEps.c
|
||||||
int32_t dmReadEps(SDnodeData *pData);
|
int32_t dmReadEps(SDnodeData *pData);
|
||||||
int32_t dmWriteEps(SDnodeData *pData);
|
int32_t dmWriteEps(SDnodeData *pData);
|
||||||
|
|
|
@ -57,6 +57,8 @@ static int32_t dmDecodeEps(SJson *pJson, SDnodeData *pData) {
|
||||||
if (code < 0) return -1;
|
if (code < 0) return -1;
|
||||||
tjsonGetNumberValue(pJson, "dnodeVer", pData->dnodeVer, code);
|
tjsonGetNumberValue(pJson, "dnodeVer", pData->dnodeVer, code);
|
||||||
if (code < 0) return -1;
|
if (code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "engineVer", pData->engineVer, code);
|
||||||
|
if (code < 0) return -1;
|
||||||
tjsonGetNumberValue(pJson, "clusterId", pData->clusterId, code);
|
tjsonGetNumberValue(pJson, "clusterId", pData->clusterId, code);
|
||||||
if (code < 0) return -1;
|
if (code < 0) return -1;
|
||||||
tjsonGetInt32ValueFromDouble(pJson, "dropped", pData->dropped, code);
|
tjsonGetInt32ValueFromDouble(pJson, "dropped", pData->dropped, code);
|
||||||
|
@ -96,7 +98,8 @@ int32_t dmReadEps(SDnodeData *pData) {
|
||||||
|
|
||||||
pData->dnodeEps = taosArrayInit(1, sizeof(SDnodeEp));
|
pData->dnodeEps = taosArrayInit(1, sizeof(SDnodeEp));
|
||||||
if (pData->dnodeEps == NULL) {
|
if (pData->dnodeEps == NULL) {
|
||||||
dError("failed to calloc dnodeEp array since %s", strerror(errno));
|
code = terrno;
|
||||||
|
dError("failed to calloc dnodeEp array since %s", terrstr());
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,6 +187,7 @@ _OVER:
|
||||||
static int32_t dmEncodeEps(SJson *pJson, SDnodeData *pData) {
|
static int32_t dmEncodeEps(SJson *pJson, SDnodeData *pData) {
|
||||||
if (tjsonAddDoubleToObject(pJson, "dnodeId", pData->dnodeId) < 0) return -1;
|
if (tjsonAddDoubleToObject(pJson, "dnodeId", pData->dnodeId) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "dnodeVer", pData->dnodeVer) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "dnodeVer", pData->dnodeVer) < 0) return -1;
|
||||||
|
if (tjsonAddIntegerToObject(pJson, "engineVer", pData->engineVer) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "clusterId", pData->clusterId) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "clusterId", pData->clusterId) < 0) return -1;
|
||||||
if (tjsonAddDoubleToObject(pJson, "dropped", pData->dropped) < 0) return -1;
|
if (tjsonAddDoubleToObject(pJson, "dropped", pData->dropped) < 0) return -1;
|
||||||
|
|
||||||
|
@ -218,8 +222,11 @@ int32_t dmWriteEps(SDnodeData *pData) {
|
||||||
snprintf(realfile, sizeof(realfile), "%s%sdnode%sdnode.json", tsDataDir, TD_DIRSEP, TD_DIRSEP);
|
snprintf(realfile, sizeof(realfile), "%s%sdnode%sdnode.json", tsDataDir, TD_DIRSEP, TD_DIRSEP);
|
||||||
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
if((code == dmInitDndInfo(pData)) != 0) goto _OVER;
|
||||||
pJson = tjsonCreateObject();
|
pJson = tjsonCreateObject();
|
||||||
if (pJson == NULL) goto _OVER;
|
if (pJson == NULL) goto _OVER;
|
||||||
|
pData->engineVer = tsVersion;
|
||||||
if (dmEncodeEps(pJson, pData) != 0) goto _OVER;
|
if (dmEncodeEps(pJson, pData) != 0) goto _OVER;
|
||||||
buffer = tjsonToString(pJson);
|
buffer = tjsonToString(pJson);
|
||||||
if (buffer == NULL) goto _OVER;
|
if (buffer == NULL) goto _OVER;
|
||||||
|
|
|
@ -312,6 +312,7 @@ typedef struct {
|
||||||
int32_t daysToKeep0;
|
int32_t daysToKeep0;
|
||||||
int32_t daysToKeep1;
|
int32_t daysToKeep1;
|
||||||
int32_t daysToKeep2;
|
int32_t daysToKeep2;
|
||||||
|
int32_t keepTimeOffset;
|
||||||
int32_t minRows;
|
int32_t minRows;
|
||||||
int32_t maxRows;
|
int32_t maxRows;
|
||||||
int32_t walFsyncPeriod;
|
int32_t walFsyncPeriod;
|
||||||
|
|
|
@ -47,7 +47,7 @@ void mndUserFreeObj(SUserObj *pUser);
|
||||||
|
|
||||||
int64_t mndGetIpWhiteVer(SMnode *pMnode);
|
int64_t mndGetIpWhiteVer(SMnode *pMnode);
|
||||||
|
|
||||||
void mndUpdateIpWhite(SMnode *pMnode, char *user, char *fqdn, int8_t type, int8_t lock);
|
void mndUpdateIpWhiteForAllUser(SMnode *pMnode, char *user, char *fqdn, int8_t type, int8_t lock);
|
||||||
|
|
||||||
int32_t mndRefreshUserIpWhiteList(SMnode *pMnode);
|
int32_t mndRefreshUserIpWhiteList(SMnode *pMnode);
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
#include "audit.h"
|
#include "audit.h"
|
||||||
|
|
||||||
#define DB_VER_NUMBER 1
|
#define DB_VER_NUMBER 1
|
||||||
#define DB_RESERVE_SIZE 46
|
#define DB_RESERVE_SIZE 42
|
||||||
|
|
||||||
static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw);
|
static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw);
|
||||||
static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb);
|
static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb);
|
||||||
|
@ -137,6 +137,7 @@ SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
|
||||||
SDB_SET_INT16(pRaw, dataPos, pDb->cfg.hashSuffix, _OVER)
|
SDB_SET_INT16(pRaw, dataPos, pDb->cfg.hashSuffix, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.tsdbPageSize, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.tsdbPageSize, _OVER)
|
||||||
SDB_SET_INT64(pRaw, dataPos, pDb->compactStartTime, _OVER)
|
SDB_SET_INT64(pRaw, dataPos, pDb->compactStartTime, _OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.keepTimeOffset, _OVER)
|
||||||
|
|
||||||
SDB_SET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
|
SDB_SET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
|
||||||
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
|
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
|
||||||
|
@ -227,6 +228,7 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT16(pRaw, dataPos, &pDb->cfg.hashSuffix, _OVER)
|
SDB_GET_INT16(pRaw, dataPos, &pDb->cfg.hashSuffix, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.tsdbPageSize, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.tsdbPageSize, _OVER)
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pDb->compactStartTime, _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pDb->compactStartTime, _OVER)
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.keepTimeOffset, _OVER)
|
||||||
|
|
||||||
SDB_GET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
|
SDB_GET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
|
||||||
taosInitRWLatch(&pDb->lock);
|
taosInitRWLatch(&pDb->lock);
|
||||||
|
@ -292,6 +294,7 @@ static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOld, SDbObj *pNew) {
|
||||||
pOld->cfg.daysToKeep0 = pNew->cfg.daysToKeep0;
|
pOld->cfg.daysToKeep0 = pNew->cfg.daysToKeep0;
|
||||||
pOld->cfg.daysToKeep1 = pNew->cfg.daysToKeep1;
|
pOld->cfg.daysToKeep1 = pNew->cfg.daysToKeep1;
|
||||||
pOld->cfg.daysToKeep2 = pNew->cfg.daysToKeep2;
|
pOld->cfg.daysToKeep2 = pNew->cfg.daysToKeep2;
|
||||||
|
pOld->cfg.keepTimeOffset = pNew->cfg.keepTimeOffset;
|
||||||
pOld->cfg.walFsyncPeriod = pNew->cfg.walFsyncPeriod;
|
pOld->cfg.walFsyncPeriod = pNew->cfg.walFsyncPeriod;
|
||||||
pOld->cfg.walLevel = pNew->cfg.walLevel;
|
pOld->cfg.walLevel = pNew->cfg.walLevel;
|
||||||
pOld->cfg.walRetentionPeriod = pNew->cfg.walRetentionPeriod;
|
pOld->cfg.walRetentionPeriod = pNew->cfg.walRetentionPeriod;
|
||||||
|
@ -368,6 +371,7 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
|
||||||
if (pCfg->daysToKeep0 < pCfg->daysPerFile) return -1;
|
if (pCfg->daysToKeep0 < pCfg->daysPerFile) return -1;
|
||||||
if (pCfg->daysToKeep0 > pCfg->daysToKeep1) return -1;
|
if (pCfg->daysToKeep0 > pCfg->daysToKeep1) return -1;
|
||||||
if (pCfg->daysToKeep1 > pCfg->daysToKeep2) return -1;
|
if (pCfg->daysToKeep1 > pCfg->daysToKeep2) return -1;
|
||||||
|
if (pCfg->keepTimeOffset < TSDB_MIN_KEEP_TIME_OFFSET || pCfg->keepTimeOffset > TSDB_MAX_KEEP_TIME_OFFSET) return -1;
|
||||||
if (pCfg->minRows < TSDB_MIN_MINROWS_FBLOCK || pCfg->minRows > TSDB_MAX_MINROWS_FBLOCK) return -1;
|
if (pCfg->minRows < TSDB_MIN_MINROWS_FBLOCK || pCfg->minRows > TSDB_MAX_MINROWS_FBLOCK) return -1;
|
||||||
if (pCfg->maxRows < TSDB_MIN_MAXROWS_FBLOCK || pCfg->maxRows > TSDB_MAX_MAXROWS_FBLOCK) return -1;
|
if (pCfg->maxRows < TSDB_MIN_MAXROWS_FBLOCK || pCfg->maxRows > TSDB_MAX_MAXROWS_FBLOCK) return -1;
|
||||||
if (pCfg->minRows > pCfg->maxRows) return -1;
|
if (pCfg->minRows > pCfg->maxRows) return -1;
|
||||||
|
@ -413,6 +417,7 @@ static int32_t mndCheckInChangeDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
|
||||||
if (pCfg->daysToKeep0 < pCfg->daysPerFile) return -1;
|
if (pCfg->daysToKeep0 < pCfg->daysPerFile) return -1;
|
||||||
if (pCfg->daysToKeep0 > pCfg->daysToKeep1) return -1;
|
if (pCfg->daysToKeep0 > pCfg->daysToKeep1) return -1;
|
||||||
if (pCfg->daysToKeep1 > pCfg->daysToKeep2) return -1;
|
if (pCfg->daysToKeep1 > pCfg->daysToKeep2) return -1;
|
||||||
|
if (pCfg->keepTimeOffset < TSDB_MIN_KEEP_TIME_OFFSET || pCfg->keepTimeOffset > TSDB_MAX_KEEP_TIME_OFFSET) return -1;
|
||||||
if (pCfg->walFsyncPeriod < TSDB_MIN_FSYNC_PERIOD || pCfg->walFsyncPeriod > TSDB_MAX_FSYNC_PERIOD) return -1;
|
if (pCfg->walFsyncPeriod < TSDB_MIN_FSYNC_PERIOD || pCfg->walFsyncPeriod > TSDB_MAX_FSYNC_PERIOD) return -1;
|
||||||
if (pCfg->walLevel < TSDB_MIN_WAL_LEVEL || pCfg->walLevel > TSDB_MAX_WAL_LEVEL) return -1;
|
if (pCfg->walLevel < TSDB_MIN_WAL_LEVEL || pCfg->walLevel > TSDB_MAX_WAL_LEVEL) return -1;
|
||||||
if (pCfg->cacheLast < TSDB_CACHE_MODEL_NONE || pCfg->cacheLast > TSDB_CACHE_MODEL_BOTH) return -1;
|
if (pCfg->cacheLast < TSDB_CACHE_MODEL_NONE || pCfg->cacheLast > TSDB_CACHE_MODEL_BOTH) return -1;
|
||||||
|
@ -445,6 +450,7 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
|
||||||
if (pCfg->daysToKeep0 < 0) pCfg->daysToKeep0 = TSDB_DEFAULT_KEEP;
|
if (pCfg->daysToKeep0 < 0) pCfg->daysToKeep0 = TSDB_DEFAULT_KEEP;
|
||||||
if (pCfg->daysToKeep1 < 0) pCfg->daysToKeep1 = pCfg->daysToKeep0;
|
if (pCfg->daysToKeep1 < 0) pCfg->daysToKeep1 = pCfg->daysToKeep0;
|
||||||
if (pCfg->daysToKeep2 < 0) pCfg->daysToKeep2 = pCfg->daysToKeep1;
|
if (pCfg->daysToKeep2 < 0) pCfg->daysToKeep2 = pCfg->daysToKeep1;
|
||||||
|
if (pCfg->keepTimeOffset < 0) pCfg->keepTimeOffset = TSDB_DEFAULT_KEEP_TIME_OFFSET;
|
||||||
if (pCfg->minRows < 0) pCfg->minRows = TSDB_DEFAULT_MINROWS_FBLOCK;
|
if (pCfg->minRows < 0) pCfg->minRows = TSDB_DEFAULT_MINROWS_FBLOCK;
|
||||||
if (pCfg->maxRows < 0) pCfg->maxRows = TSDB_DEFAULT_MAXROWS_FBLOCK;
|
if (pCfg->maxRows < 0) pCfg->maxRows = TSDB_DEFAULT_MAXROWS_FBLOCK;
|
||||||
if (pCfg->walFsyncPeriod < 0) pCfg->walFsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD;
|
if (pCfg->walFsyncPeriod < 0) pCfg->walFsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD;
|
||||||
|
@ -590,6 +596,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
|
||||||
.daysToKeep0 = pCreate->daysToKeep0,
|
.daysToKeep0 = pCreate->daysToKeep0,
|
||||||
.daysToKeep1 = pCreate->daysToKeep1,
|
.daysToKeep1 = pCreate->daysToKeep1,
|
||||||
.daysToKeep2 = pCreate->daysToKeep2,
|
.daysToKeep2 = pCreate->daysToKeep2,
|
||||||
|
.keepTimeOffset = pCreate->keepTimeOffset,
|
||||||
.minRows = pCreate->minRows,
|
.minRows = pCreate->minRows,
|
||||||
.maxRows = pCreate->maxRows,
|
.maxRows = pCreate->maxRows,
|
||||||
.walFsyncPeriod = pCreate->walFsyncPeriod,
|
.walFsyncPeriod = pCreate->walFsyncPeriod,
|
||||||
|
@ -763,6 +770,7 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
|
||||||
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep0:%d", createReq.daysToKeep0);
|
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep0:%d", createReq.daysToKeep0);
|
||||||
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep1:%d", createReq.daysToKeep1);
|
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep1:%d", createReq.daysToKeep1);
|
||||||
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep2:%d", createReq.daysToKeep2);
|
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep2:%d", createReq.daysToKeep2);
|
||||||
|
mndBuildAuditDetailInt32(detail, tmp, "keepTimeOffset:%d", createReq.keepTimeOffset);
|
||||||
mndBuildAuditDetailInt32(detail, tmp, "hashPrefix:%d", createReq.hashPrefix);
|
mndBuildAuditDetailInt32(detail, tmp, "hashPrefix:%d", createReq.hashPrefix);
|
||||||
mndBuildAuditDetailInt32(detail, tmp, "hashSuffix:%d", createReq.hashSuffix);
|
mndBuildAuditDetailInt32(detail, tmp, "hashSuffix:%d", createReq.hashSuffix);
|
||||||
mndBuildAuditDetailInt32(detail, tmp, "ignoreExist:%d", createReq.ignoreExist);
|
mndBuildAuditDetailInt32(detail, tmp, "ignoreExist:%d", createReq.ignoreExist);
|
||||||
|
@ -841,6 +849,11 @@ static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) {
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pAlter->keepTimeOffset >= 0 && pAlter->keepTimeOffset != pDb->cfg.keepTimeOffset) {
|
||||||
|
pDb->cfg.keepTimeOffset = pAlter->keepTimeOffset;
|
||||||
|
terrno = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (pAlter->walFsyncPeriod >= 0 && pAlter->walFsyncPeriod != pDb->cfg.walFsyncPeriod) {
|
if (pAlter->walFsyncPeriod >= 0 && pAlter->walFsyncPeriod != pDb->cfg.walFsyncPeriod) {
|
||||||
pDb->cfg.walFsyncPeriod = pAlter->walFsyncPeriod;
|
pDb->cfg.walFsyncPeriod = pAlter->walFsyncPeriod;
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
@ -1046,6 +1059,7 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
|
||||||
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep0:%d", alterReq.daysToKeep0);
|
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep0:%d", alterReq.daysToKeep0);
|
||||||
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep1:%d", alterReq.daysToKeep1);
|
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep1:%d", alterReq.daysToKeep1);
|
||||||
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep2:%d", alterReq.daysToKeep2);
|
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep2:%d", alterReq.daysToKeep2);
|
||||||
|
mndBuildAuditDetailInt32(detail, tmp, "keepTimeOffset:%d", alterReq.keepTimeOffset);
|
||||||
mndBuildAuditDetailInt32(detail, tmp, "minRows:%d", alterReq.minRows);
|
mndBuildAuditDetailInt32(detail, tmp, "minRows:%d", alterReq.minRows);
|
||||||
mndBuildAuditDetailInt32(detail, tmp, "pages:%d", alterReq.pages);
|
mndBuildAuditDetailInt32(detail, tmp, "pages:%d", alterReq.pages);
|
||||||
mndBuildAuditDetailInt32(detail, tmp, "pageSize:%d", alterReq.pageSize);
|
mndBuildAuditDetailInt32(detail, tmp, "pageSize:%d", alterReq.pageSize);
|
||||||
|
@ -1087,6 +1101,7 @@ static void mndDumpDbCfgInfo(SDbCfgRsp *cfgRsp, SDbObj *pDb) {
|
||||||
cfgRsp->daysToKeep0 = pDb->cfg.daysToKeep0;
|
cfgRsp->daysToKeep0 = pDb->cfg.daysToKeep0;
|
||||||
cfgRsp->daysToKeep1 = pDb->cfg.daysToKeep1;
|
cfgRsp->daysToKeep1 = pDb->cfg.daysToKeep1;
|
||||||
cfgRsp->daysToKeep2 = pDb->cfg.daysToKeep2;
|
cfgRsp->daysToKeep2 = pDb->cfg.daysToKeep2;
|
||||||
|
cfgRsp->keepTimeOffset = pDb->cfg.keepTimeOffset;
|
||||||
cfgRsp->minRows = pDb->cfg.minRows;
|
cfgRsp->minRows = pDb->cfg.minRows;
|
||||||
cfgRsp->maxRows = pDb->cfg.maxRows;
|
cfgRsp->maxRows = pDb->cfg.maxRows;
|
||||||
cfgRsp->walFsyncPeriod = pDb->cfg.walFsyncPeriod;
|
cfgRsp->walFsyncPeriod = pDb->cfg.walFsyncPeriod;
|
||||||
|
@ -2013,6 +2028,9 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.tsdbPageSize, false);
|
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.tsdbPageSize, false);
|
||||||
|
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.keepTimeOffset, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
|
|
|
@ -71,6 +71,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq);
|
static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp);
|
static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp);
|
||||||
static int32_t mndProcessStatusReq(SRpcMsg *pReq);
|
static int32_t mndProcessStatusReq(SRpcMsg *pReq);
|
||||||
|
static int32_t mndProcessNotifyReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessRestoreDnodeReq(SRpcMsg *pReq);
|
static int32_t mndProcessRestoreDnodeReq(SRpcMsg *pReq);
|
||||||
|
|
||||||
static int32_t mndRetrieveConfigs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveConfigs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
|
@ -80,6 +81,12 @@ static void mndCancelGetNextDnode(SMnode *pMnode, void *pIter);
|
||||||
|
|
||||||
static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pInMCfgReq, int32_t opLen, int32_t *pOutValue);
|
static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pInMCfgReq, int32_t opLen, int32_t *pOutValue);
|
||||||
|
|
||||||
|
#ifdef _GRANT
|
||||||
|
int32_t mndUpdClusterInfo(SRpcMsg *pReq);
|
||||||
|
#else
|
||||||
|
static int32_t mndUpdClusterInfo(SRpcMsg *pReq) { return 0; }
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t mndInitDnode(SMnode *pMnode) {
|
int32_t mndInitDnode(SMnode *pMnode) {
|
||||||
SSdbTable table = {
|
SSdbTable table = {
|
||||||
.sdbType = SDB_DNODE,
|
.sdbType = SDB_DNODE,
|
||||||
|
@ -97,6 +104,7 @@ int32_t mndInitDnode(SMnode *pMnode) {
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_CONFIG_DNODE, mndProcessConfigDnodeReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_CONFIG_DNODE, mndProcessConfigDnodeReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_DND_CONFIG_DNODE_RSP, mndProcessConfigDnodeRsp);
|
mndSetMsgHandle(pMnode, TDMT_DND_CONFIG_DNODE_RSP, mndProcessConfigDnodeRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_STATUS, mndProcessStatusReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_STATUS, mndProcessStatusReq);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_NOTIFY, mndProcessNotifyReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_DNODE_LIST, mndProcessDnodeListReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_DNODE_LIST, mndProcessDnodeListReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_SHOW_VARIABLES, mndProcessShowVariablesReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_SHOW_VARIABLES, mndProcessShowVariablesReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_RESTORE_DNODE, mndProcessRestoreDnodeReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_RESTORE_DNODE, mndProcessRestoreDnodeReq);
|
||||||
|
@ -139,7 +147,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
|
||||||
|
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
code = 0;
|
code = 0;
|
||||||
mndUpdateIpWhite(pMnode, TSDB_DEFAULT_USER, dnodeObj.fqdn, IP_WHITE_ADD, 1);
|
mndUpdateIpWhiteForAllUser(pMnode, TSDB_DEFAULT_USER, dnodeObj.fqdn, IP_WHITE_ADD, 1);
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
|
@ -543,6 +551,10 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
||||||
pDnode->accessTimes, needCheck, online, reboot, dnodeChanged, statusReq.statusSeq);
|
pDnode->accessTimes, needCheck, online, reboot, dnodeChanged, statusReq.statusSeq);
|
||||||
|
|
||||||
|
if (reboot) {
|
||||||
|
tsGrantHBInterval = GRANT_HEART_BEAT_MIN;
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t v = 0; v < taosArrayGetSize(statusReq.pVloads); ++v) {
|
for (int32_t v = 0; v < taosArrayGetSize(statusReq.pVloads); ++v) {
|
||||||
SVnodeLoad *pVload = taosArrayGet(statusReq.pVloads, v);
|
SVnodeLoad *pVload = taosArrayGet(statusReq.pVloads, v);
|
||||||
|
|
||||||
|
@ -676,6 +688,41 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
_OVER:
|
_OVER:
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
taosArrayDestroy(statusReq.pVloads);
|
taosArrayDestroy(statusReq.pVloads);
|
||||||
|
mndUpdClusterInfo(pReq);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndProcessNotifyReq(SRpcMsg *pReq) {
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
SNotifyReq notifyReq = {0};
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
if ((code = tDeserializeSNotifyReq(pReq->pCont, pReq->contLen, ¬ifyReq)) != 0) {
|
||||||
|
terrno = code;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t clusterid = mndGetClusterId(pMnode);
|
||||||
|
if (notifyReq.clusterId != 0 && notifyReq.clusterId != clusterid) {
|
||||||
|
code = TSDB_CODE_MND_DNODE_DIFF_CLUSTER;
|
||||||
|
mWarn("dnode:%d, its clusterid:%" PRId64 " differ from current cluster:%" PRId64 " since %s", notifyReq.dnodeId,
|
||||||
|
notifyReq.clusterId, clusterid, tstrerror(code));
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t nVgroup = taosArrayGetSize(notifyReq.pVloads);
|
||||||
|
for (int32_t v = 0; v < nVgroup; ++v) {
|
||||||
|
SVnodeLoadLite *pVload = taosArrayGet(notifyReq.pVloads, v);
|
||||||
|
|
||||||
|
SVgObj *pVgroup = mndAcquireVgroup(pMnode, pVload->vgId);
|
||||||
|
if (pVgroup != NULL) {
|
||||||
|
pVgroup->numOfTimeSeries = pVload->nTimeSeries;
|
||||||
|
mndReleaseVgroup(pMnode, pVgroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_OVER:
|
||||||
|
mndUpdClusterInfo(pReq);
|
||||||
|
tFreeSNotifyReq(¬ifyReq);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -705,7 +752,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
mndUpdateIpWhite(pMnode, TSDB_DEFAULT_USER, dnodeObj.fqdn, IP_WHITE_ADD, 1);
|
mndUpdateIpWhiteForAllUser(pMnode, TSDB_DEFAULT_USER, dnodeObj.fqdn, IP_WHITE_ADD, 1);
|
||||||
_OVER:
|
_OVER:
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
sdbFreeRaw(pRaw);
|
sdbFreeRaw(pRaw);
|
||||||
|
@ -716,7 +763,9 @@ static int32_t mndConfigDnode(SMnode *pMnode, SRpcMsg *pReq, SMCfgDnodeReq *pCfg
|
||||||
SSdbRaw *pRaw = NULL;
|
SSdbRaw *pRaw = NULL;
|
||||||
STrans *pTrans = NULL;
|
STrans *pTrans = NULL;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
|
SArray *failRecord = NULL;
|
||||||
bool cfgAll = pCfgReq->dnodeId == -1;
|
bool cfgAll = pCfgReq->dnodeId == -1;
|
||||||
|
int32_t cfgAllErr = 0;
|
||||||
int32_t iter = 0;
|
int32_t iter = 0;
|
||||||
|
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
@ -730,28 +779,64 @@ static int32_t mndConfigDnode(SMnode *pMnode, SRpcMsg *pReq, SMCfgDnodeReq *pCfg
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDnodeObj tmpDnode = *pDnode;
|
||||||
|
if (action == DND_ACTIVE_CODE) {
|
||||||
|
#ifndef TD_CHECK_ACTIVE
|
||||||
|
strncpy(tmpDnode.active, pCfgReq->value, TSDB_ACTIVE_KEY_LEN);
|
||||||
|
#else
|
||||||
|
if (grantAlterActiveCode(pDnode->active, pCfgReq->value, tmpDnode.active, 0) != 0) {
|
||||||
|
if (TSDB_CODE_DUP_KEY != terrno) {
|
||||||
|
mError("dnode:%d, config dnode:%d, app:%p config:%s value:%s failed since %s", pDnode->id, pCfgReq->dnodeId,
|
||||||
|
pReq->info.ahandle, pCfgReq->config, pCfgReq->value, terrstr());
|
||||||
|
if (cfgAll) { // alter all dnodes:
|
||||||
|
if (!failRecord) failRecord = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
if (failRecord) taosArrayPush(failRecord, &pDnode->id);
|
||||||
|
if (0 == cfgAllErr) cfgAllErr = terrno; // output 1st terrno.
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
terrno = 0; // no action for dup active code
|
||||||
|
}
|
||||||
|
if (cfgAll) continue;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} else if (action == DND_CONN_ACTIVE_CODE) {
|
||||||
|
#ifndef TD_CHECK_ACTIVE
|
||||||
|
strncpy(tmpDnode.connActive, pCfgReq->value, TSDB_CONN_ACTIVE_KEY_LEN);
|
||||||
|
#else
|
||||||
|
if (grantAlterActiveCode(pDnode->connActive, pCfgReq->value, tmpDnode.connActive, 1) != 0) {
|
||||||
|
if (TSDB_CODE_DUP_KEY != terrno) {
|
||||||
|
mError("dnode:%d, config dnode:%d, app:%p config:%s value:%s failed since %s", pDnode->id, pCfgReq->dnodeId,
|
||||||
|
pReq->info.ahandle, pCfgReq->config, pCfgReq->value, terrstr());
|
||||||
|
if (cfgAll) {
|
||||||
|
if (!failRecord) failRecord = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
if (failRecord) taosArrayPush(failRecord, &pDnode->id);
|
||||||
|
if (0 == cfgAllErr) cfgAllErr = terrno;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
terrno = 0;
|
||||||
|
}
|
||||||
|
if (cfgAll) continue;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_INVALID_CFG;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
if (!pTrans) {
|
if (!pTrans) {
|
||||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "config-dnode");
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "config-dnode");
|
||||||
if (!pTrans) goto _OVER;
|
if (!pTrans) goto _OVER;
|
||||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeObj tmpDnode = *pDnode;
|
|
||||||
if (action == DND_ACTIVE_CODE) {
|
|
||||||
strncpy(tmpDnode.active, pCfgReq->value, TSDB_ACTIVE_KEY_LEN);
|
|
||||||
} else if (action == DND_CONN_ACTIVE_CODE) {
|
|
||||||
strncpy(tmpDnode.connActive, pCfgReq->value, TSDB_CONN_ACTIVE_KEY_LEN);
|
|
||||||
} else {
|
|
||||||
terrno = TSDB_CODE_INVALID_CFG;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
pRaw = mndDnodeActionEncode(&tmpDnode);
|
pRaw = mndDnodeActionEncode(&tmpDnode);
|
||||||
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
|
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
|
||||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||||
pRaw = NULL;
|
pRaw = NULL;
|
||||||
|
|
||||||
mInfo("dnode:%d, config dnode, cfg:%d, app:%p config:%s value:%s", pDnode->id, pCfgReq->dnodeId, pReq->info.ahandle,
|
mInfo("dnode:%d, config dnode:%d, app:%p config:%s value:%s", pDnode->id, pCfgReq->dnodeId, pReq->info.ahandle,
|
||||||
pCfgReq->config, pCfgReq->value);
|
pCfgReq->config, pCfgReq->value);
|
||||||
|
|
||||||
if (cfgAll) {
|
if (cfgAll) {
|
||||||
|
@ -769,12 +854,19 @@ static int32_t mndConfigDnode(SMnode *pMnode, SRpcMsg *pReq, SMCfgDnodeReq *pCfg
|
||||||
_OVER:
|
_OVER:
|
||||||
if (cfgAll) {
|
if (cfgAll) {
|
||||||
sdbRelease(pSdb, pDnode);
|
sdbRelease(pSdb, pDnode);
|
||||||
|
if (cfgAllErr != 0) terrno = cfgAllErr;
|
||||||
|
int32_t nFail = taosArrayGetSize(failRecord);
|
||||||
|
if (nFail > 0) {
|
||||||
|
mError("config dnode, cfg:%d, app:%p config:%s value:%s. total:%d, fail:%d", pCfgReq->dnodeId, pReq->info.ahandle,
|
||||||
|
pCfgReq->config, pCfgReq->value, iter, nFail);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
}
|
}
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
sdbFreeRaw(pRaw);
|
sdbFreeRaw(pRaw);
|
||||||
|
taosArrayDestroy(failRecord);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -998,7 +1090,7 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
|
||||||
|
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
mndUpdateIpWhite(pMnode, TSDB_DEFAULT_USER, pDnode->fqdn, IP_WHITE_DROP, 1);
|
mndUpdateIpWhiteForAllUser(pMnode, TSDB_DEFAULT_USER, pDnode->fqdn, IP_WHITE_DROP, 1);
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
|
@ -1144,20 +1236,6 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
strcpy(dcfgReq.config, "monitor");
|
strcpy(dcfgReq.config, "monitor");
|
||||||
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
||||||
} else if (strncasecmp(cfgReq.config, "keeptimeoffset", 14) == 0) {
|
|
||||||
int32_t optLen = strlen("keeptimeoffset");
|
|
||||||
int32_t flag = -1;
|
|
||||||
int32_t code = mndMCfgGetValInt32(&cfgReq, optLen, &flag);
|
|
||||||
if (code < 0) return code;
|
|
||||||
|
|
||||||
if (flag < 0 || flag > 23) {
|
|
||||||
mError("dnode:%d, failed to config keepTimeOffset since value:%d. Valid range: [0, 23]", cfgReq.dnodeId, flag);
|
|
||||||
terrno = TSDB_CODE_INVALID_CFG;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(dcfgReq.config, "keeptimeoffset");
|
|
||||||
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
|
||||||
} else if (strncasecmp(cfgReq.config, "ttlpushinterval", 14) == 0) {
|
} else if (strncasecmp(cfgReq.config, "ttlpushinterval", 14) == 0) {
|
||||||
int32_t optLen = strlen("ttlpushinterval");
|
int32_t optLen = strlen("ttlpushinterval");
|
||||||
int32_t flag = -1;
|
int32_t flag = -1;
|
||||||
|
@ -1229,7 +1307,8 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
||||||
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%s", cfgReq.value);
|
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%s", cfgReq.value);
|
||||||
|
|
||||||
if (mndConfigDnode(pMnode, pReq, &cfgReq, opt) != 0) {
|
if (mndConfigDnode(pMnode, pReq, &cfgReq, opt) != 0) {
|
||||||
mError("dnode:%d, failed to config activeCode since %s", cfgReq.dnodeId, terrstr());
|
mError("dnode:%d, failed to config activeCode since %s. conf:%s, val:%s", cfgReq.dnodeId, terrstr(),
|
||||||
|
cfgReq.config, cfgReq.value);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -129,7 +129,9 @@ void grantParseParameter() { mError("can't parsed parameter k"); }
|
||||||
void grantReset(SMnode *pMnode, EGrantType grant, uint64_t value) {}
|
void grantReset(SMnode *pMnode, EGrantType grant, uint64_t value) {}
|
||||||
void grantAdd(EGrantType grant, uint64_t value) {}
|
void grantAdd(EGrantType grant, uint64_t value) {}
|
||||||
void grantRestore(EGrantType grant, uint64_t value) {}
|
void grantRestore(EGrantType grant, uint64_t value) {}
|
||||||
int32_t dmProcessGrantReq(void* pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
|
int32_t dmProcessGrantReq(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
|
||||||
|
int32_t dmProcessGrantNotify(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
|
||||||
|
int32_t grantAlterActiveCode(const char *old, const char *new, char *out, int8_t type) { return TSDB_CODE_SUCCESS; }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ int32_t mndSetUserAuthRsp(SMnode *pMnode, SUserObj *pUser, SGetUserAuthRsp *pRsp
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndEnableIpWhiteList(SMnode *pMnode) { return 1; }
|
int32_t mndEnableIpWhiteList(SMnode *pMnode) { return 0; }
|
||||||
|
|
||||||
int32_t mndFetchIpWhiteList(SIpWhiteList *ipList, char **buf) {
|
int32_t mndFetchIpWhiteList(SIpWhiteList *ipList, char **buf) {
|
||||||
*buf = NULL;
|
*buf = NULL;
|
||||||
|
|
|
@ -1678,6 +1678,10 @@ static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, SArray
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((terrno = grantCheck(TSDB_GRANT_TIMESERIES)) != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
pNew->numOfColumns = pNew->numOfColumns + ncols;
|
pNew->numOfColumns = pNew->numOfColumns + ncols;
|
||||||
if (mndAllocStbSchemas(pOld, pNew) != 0) {
|
if (mndAllocStbSchemas(pOld, pNew) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -543,6 +543,8 @@ STrans *mndAcquireTrans(SMnode *pMnode, int32_t transId) {
|
||||||
STrans *pTrans = sdbAcquire(pMnode->pSdb, SDB_TRANS, &transId);
|
STrans *pTrans = sdbAcquire(pMnode->pSdb, SDB_TRANS, &transId);
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
terrno = TSDB_CODE_MND_TRANS_NOT_EXIST;
|
terrno = TSDB_CODE_MND_TRANS_NOT_EXIST;
|
||||||
|
} else {
|
||||||
|
taosThreadMutexInit(&pTrans->mutex, NULL);
|
||||||
}
|
}
|
||||||
return pTrans;
|
return pTrans;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBloc
|
||||||
static void mndCancelGetNextPrivileges(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextPrivileges(SMnode *pMnode, void *pIter);
|
||||||
SHashObj *mndFetchAllIpWhite(SMnode *pMnode);
|
SHashObj *mndFetchAllIpWhite(SMnode *pMnode);
|
||||||
static int32_t mndProcesSRetrieveIpWhiteReq(SRpcMsg *pReq);
|
static int32_t mndProcesSRetrieveIpWhiteReq(SRpcMsg *pReq);
|
||||||
|
bool mndUpdateIpWhiteImpl(SHashObj *pIpWhiteTab, char *user, char *fqdn, int8_t type);
|
||||||
|
|
||||||
void ipWhiteMgtUpdateAll(SMnode *pMnode);
|
void ipWhiteMgtUpdateAll(SMnode *pMnode);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -80,7 +81,7 @@ void ipWhiteMgtCleanup() {
|
||||||
taosThreadRwlockDestroy(&ipWhiteMgt.rw);
|
taosThreadRwlockDestroy(&ipWhiteMgt.rw);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ipWhiteMgtUpdate(char *user, SIpWhiteList *pNew) {
|
int32_t ipWhiteMgtUpdate(SMnode *pMnode, char *user, SIpWhiteList *pNew) {
|
||||||
bool update = true;
|
bool update = true;
|
||||||
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||||
SIpWhiteList **ppList = taosHashGet(ipWhiteMgt.pIpWhiteTab, user, strlen(user));
|
SIpWhiteList **ppList = taosHashGet(ipWhiteMgt.pIpWhiteTab, user, strlen(user));
|
||||||
|
@ -98,6 +99,25 @@ int32_t ipWhiteMgtUpdate(char *user, SIpWhiteList *pNew) {
|
||||||
taosHashPut(ipWhiteMgt.pIpWhiteTab, user, strlen(user), &p, sizeof(void *));
|
taosHashPut(ipWhiteMgt.pIpWhiteTab, user, strlen(user), &p, sizeof(void *));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SArray *fqdns = mndGetAllDnodeFqdns(pMnode);
|
||||||
|
|
||||||
|
for (int i = 0; i < taosArrayGetSize(fqdns); i++) {
|
||||||
|
char *fqdn = taosArrayGetP(fqdns, i);
|
||||||
|
update |= mndUpdateIpWhiteImpl(ipWhiteMgt.pIpWhiteTab, TSDB_DEFAULT_USER, fqdn, IP_WHITE_ADD);
|
||||||
|
update |= mndUpdateIpWhiteImpl(ipWhiteMgt.pIpWhiteTab, user, fqdn, IP_WHITE_ADD);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < taosArrayGetSize(fqdns); i++) {
|
||||||
|
char *fqdn = taosArrayGetP(fqdns, i);
|
||||||
|
taosMemoryFree(fqdn);
|
||||||
|
}
|
||||||
|
taosArrayDestroy(fqdns);
|
||||||
|
|
||||||
|
// for (int i = 0; i < taosArrayGetSize(pUserNames); i++) {
|
||||||
|
// taosMemoryFree(taosArrayGetP(pUserNames, i));
|
||||||
|
// }
|
||||||
|
// taosArrayDestroy(pUserNames);
|
||||||
|
|
||||||
if (update) ipWhiteMgt.ver++;
|
if (update) ipWhiteMgt.ver++;
|
||||||
|
|
||||||
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||||
|
@ -193,17 +213,17 @@ int64_t mndGetIpWhiteVer(SMnode *pMnode) {
|
||||||
int64_t ver = 0;
|
int64_t ver = 0;
|
||||||
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||||
if (ipWhiteMgt.ver == 0) {
|
if (ipWhiteMgt.ver == 0) {
|
||||||
// user and dnode r
|
// get user and dnode ip white list
|
||||||
ipWhiteMgtUpdateAll(pMnode);
|
ipWhiteMgtUpdateAll(pMnode);
|
||||||
ipWhiteMgt.ver = taosGetTimestampMs();
|
ipWhiteMgt.ver = taosGetTimestampMs();
|
||||||
}
|
}
|
||||||
ver = ipWhiteMgt.ver;
|
ver = ipWhiteMgt.ver;
|
||||||
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||||
mDebug("ip-white-list on mnode ver: %" PRId64 "", ver);
|
|
||||||
|
|
||||||
if (mndEnableIpWhiteList(pMnode) == 0 || tsEnableWhiteList == false) {
|
if (mndEnableIpWhiteList(pMnode) == 0 || tsEnableWhiteList == false) {
|
||||||
return 0;
|
ver = 0;
|
||||||
}
|
}
|
||||||
|
mDebug("ip-white-list on mnode ver: %" PRId64 "", ver);
|
||||||
return ver;
|
return ver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +302,7 @@ int32_t mndRefreshUserIpWhiteList(SMnode *pMnode) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void mndUpdateIpWhite(SMnode *pMnode, char *user, char *fqdn, int8_t type, int8_t lock) {
|
void mndUpdateIpWhiteForAllUser(SMnode *pMnode, char *user, char *fqdn, int8_t type, int8_t lock) {
|
||||||
if (lock) {
|
if (lock) {
|
||||||
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||||
if (ipWhiteMgt.ver == 0) {
|
if (ipWhiteMgt.ver == 0) {
|
||||||
|
@ -293,6 +313,20 @@ void mndUpdateIpWhite(SMnode *pMnode, char *user, char *fqdn, int8_t type, int8_
|
||||||
}
|
}
|
||||||
|
|
||||||
bool update = mndUpdateIpWhiteImpl(ipWhiteMgt.pIpWhiteTab, user, fqdn, type);
|
bool update = mndUpdateIpWhiteImpl(ipWhiteMgt.pIpWhiteTab, user, fqdn, type);
|
||||||
|
|
||||||
|
void *pIter = taosHashIterate(ipWhiteMgt.pIpWhiteTab, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
size_t klen = 0;
|
||||||
|
char *key = taosHashGetKey(pIter, &klen);
|
||||||
|
|
||||||
|
char *keyDup = taosMemoryCalloc(1, klen + 1);
|
||||||
|
memcpy(keyDup, key, klen);
|
||||||
|
update |= mndUpdateIpWhiteImpl(ipWhiteMgt.pIpWhiteTab, keyDup, fqdn, type);
|
||||||
|
taosMemoryFree(keyDup);
|
||||||
|
|
||||||
|
pIter = taosHashIterate(ipWhiteMgt.pIpWhiteTab, pIter);
|
||||||
|
}
|
||||||
|
|
||||||
if (update) ipWhiteMgt.ver++;
|
if (update) ipWhiteMgt.ver++;
|
||||||
|
|
||||||
if (lock) taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
if (lock) taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||||
|
@ -1178,7 +1212,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
ipWhiteMgtUpdate(userObj.user, userObj.pIpWhiteList);
|
ipWhiteMgtUpdate(pMnode, userObj.user, userObj.pIpWhiteList);
|
||||||
taosMemoryFree(userObj.pIpWhiteList);
|
taosMemoryFree(userObj.pIpWhiteList);
|
||||||
|
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
|
@ -1346,7 +1380,7 @@ static int32_t mndAlterUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SRpc
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ipWhiteMgtUpdate(pNew->user, pNew->pIpWhiteList);
|
ipWhiteMgtUpdate(pMnode, pNew->user, pNew->pIpWhiteList);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,6 +261,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
|
||||||
createReq.daysToKeep0 = pDb->cfg.daysToKeep0;
|
createReq.daysToKeep0 = pDb->cfg.daysToKeep0;
|
||||||
createReq.daysToKeep1 = pDb->cfg.daysToKeep1;
|
createReq.daysToKeep1 = pDb->cfg.daysToKeep1;
|
||||||
createReq.daysToKeep2 = pDb->cfg.daysToKeep2;
|
createReq.daysToKeep2 = pDb->cfg.daysToKeep2;
|
||||||
|
createReq.keepTimeOffset = pDb->cfg.keepTimeOffset;
|
||||||
createReq.minRows = pDb->cfg.minRows;
|
createReq.minRows = pDb->cfg.minRows;
|
||||||
createReq.maxRows = pDb->cfg.maxRows;
|
createReq.maxRows = pDb->cfg.maxRows;
|
||||||
createReq.walFsyncPeriod = pDb->cfg.walFsyncPeriod;
|
createReq.walFsyncPeriod = pDb->cfg.walFsyncPeriod;
|
||||||
|
@ -377,6 +378,7 @@ static void *mndBuildAlterVnodeConfigReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pV
|
||||||
alterReq.daysToKeep0 = pDb->cfg.daysToKeep0;
|
alterReq.daysToKeep0 = pDb->cfg.daysToKeep0;
|
||||||
alterReq.daysToKeep1 = pDb->cfg.daysToKeep1;
|
alterReq.daysToKeep1 = pDb->cfg.daysToKeep1;
|
||||||
alterReq.daysToKeep2 = pDb->cfg.daysToKeep2;
|
alterReq.daysToKeep2 = pDb->cfg.daysToKeep2;
|
||||||
|
alterReq.keepTimeOffset = pDb->cfg.keepTimeOffset;
|
||||||
alterReq.walFsyncPeriod = pDb->cfg.walFsyncPeriod;
|
alterReq.walFsyncPeriod = pDb->cfg.walFsyncPeriod;
|
||||||
alterReq.walLevel = pDb->cfg.walLevel;
|
alterReq.walLevel = pDb->cfg.walLevel;
|
||||||
alterReq.strict = pDb->cfg.strict;
|
alterReq.strict = pDb->cfg.strict;
|
||||||
|
|
|
@ -86,11 +86,13 @@ void *vnodeGetIdx(void *pVnode);
|
||||||
void *vnodeGetIvtIdx(void *pVnode);
|
void *vnodeGetIvtIdx(void *pVnode);
|
||||||
|
|
||||||
int32_t vnodeGetCtbNum(SVnode *pVnode, int64_t suid, int64_t *num);
|
int32_t vnodeGetCtbNum(SVnode *pVnode, int64_t suid, int64_t *num);
|
||||||
|
int32_t vnodeGetStbColumnNum(SVnode *pVnode, tb_uid_t suid, int *num);
|
||||||
int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num);
|
int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num);
|
||||||
int32_t vnodeGetAllCtbNum(SVnode *pVnode, int64_t *num);
|
int32_t vnodeGetAllCtbNum(SVnode *pVnode, int64_t *num);
|
||||||
|
|
||||||
void vnodeResetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
void vnodeResetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
||||||
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
||||||
|
int32_t vnodeGetLoadLite(SVnode *pVnode, SVnodeLoadLite *pLoad);
|
||||||
int32_t vnodeValidateTableHash(SVnode *pVnode, char *tableFName);
|
int32_t vnodeValidateTableHash(SVnode *pVnode, char *tableFName);
|
||||||
|
|
||||||
int32_t vnodePreProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
int32_t vnodePreProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
||||||
|
@ -130,11 +132,12 @@ tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name);
|
||||||
int32_t metaGetCachedTbGroup(void *pVnode, tb_uid_t suid, const uint8_t *pKey, int32_t keyLen, SArray **pList);
|
int32_t metaGetCachedTbGroup(void *pVnode, tb_uid_t suid, const uint8_t *pKey, int32_t keyLen, SArray **pList);
|
||||||
int32_t metaPutTbGroupToCache(void *pVnode, uint64_t suid, const void *pKey, int32_t keyLen, void *pPayload,
|
int32_t metaPutTbGroupToCache(void *pVnode, uint64_t suid, const void *pKey, int32_t keyLen, void *pPayload,
|
||||||
int32_t payloadLen);
|
int32_t payloadLen);
|
||||||
bool metaTbInFilterCache(void *pVnode, tb_uid_t suid, int8_t type);
|
bool metaTbInFilterCache(SMeta *pMeta, const void* key, int8_t type);
|
||||||
int32_t metaPutTbToFilterCache(void *pVnode, tb_uid_t suid, int8_t type);
|
int32_t metaPutTbToFilterCache(SMeta *pMeta, const void* key, int8_t type);
|
||||||
int32_t metaSizeOfTbFilterCache(void *pVnode, int8_t type);
|
int32_t metaSizeOfTbFilterCache(SMeta *pMeta, int8_t type);
|
||||||
|
int32_t metaInitTbFilterCache(SMeta *pMeta);
|
||||||
|
|
||||||
int32_t metaGetStbStats(void *pVnode, int64_t uid, int64_t *numOfTables);
|
int32_t metaGetStbStats(void *pVnode, int64_t uid, int64_t *numOfTables, int32_t *numOfCols);
|
||||||
|
|
||||||
// tsdb
|
// tsdb
|
||||||
typedef struct STsdbReader STsdbReader;
|
typedef struct STsdbReader STsdbReader;
|
||||||
|
@ -282,6 +285,7 @@ struct STsdbCfg {
|
||||||
int32_t keep0; // just for save config, don't use in tsdbRead/tsdbCommit/..., and use STsdbKeepCfg in STsdb instead
|
int32_t keep0; // just for save config, don't use in tsdbRead/tsdbCommit/..., and use STsdbKeepCfg in STsdb instead
|
||||||
int32_t keep1; // just for save config, don't use in tsdbRead/tsdbCommit/..., and use STsdbKeepCfg in STsdb instead
|
int32_t keep1; // just for save config, don't use in tsdbRead/tsdbCommit/..., and use STsdbKeepCfg in STsdb instead
|
||||||
int32_t keep2; // just for save config, don't use in tsdbRead/tsdbCommit/..., and use STsdbKeepCfg in STsdb instead
|
int32_t keep2; // just for save config, don't use in tsdbRead/tsdbCommit/..., and use STsdbKeepCfg in STsdb instead
|
||||||
|
int32_t keepTimeOffset; // just for save config, use STsdbKeepCfg in STsdb instead
|
||||||
SRetention retentions[TSDB_RETENTION_MAX];
|
SRetention retentions[TSDB_RETENTION_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -289,10 +293,10 @@ typedef struct {
|
||||||
int64_t numOfSTables;
|
int64_t numOfSTables;
|
||||||
int64_t numOfCTables;
|
int64_t numOfCTables;
|
||||||
int64_t numOfNTables;
|
int64_t numOfNTables;
|
||||||
int64_t numOfCmprTables;
|
int64_t numOfReportedTimeSeries;
|
||||||
int64_t numOfNTimeSeries;
|
int64_t numOfNTimeSeries;
|
||||||
int64_t numOfTimeSeries;
|
int64_t numOfTimeSeries;
|
||||||
int64_t itvTimeSeries;
|
// int64_t itvTimeSeries;
|
||||||
int64_t pointsWritten;
|
int64_t pointsWritten;
|
||||||
int64_t totalStorage;
|
int64_t totalStorage;
|
||||||
int64_t compStorage;
|
int64_t compStorage;
|
||||||
|
|
|
@ -71,7 +71,7 @@ int32_t metaCacheDrop(SMeta* pMeta, int64_t uid);
|
||||||
int32_t metaStatsCacheUpsert(SMeta* pMeta, SMetaStbStats* pInfo);
|
int32_t metaStatsCacheUpsert(SMeta* pMeta, SMetaStbStats* pInfo);
|
||||||
int32_t metaStatsCacheDrop(SMeta* pMeta, int64_t uid);
|
int32_t metaStatsCacheDrop(SMeta* pMeta, int64_t uid);
|
||||||
int32_t metaStatsCacheGet(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo);
|
int32_t metaStatsCacheGet(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo);
|
||||||
void metaUpdateStbStats(SMeta* pMeta, int64_t uid, int64_t delta);
|
void metaUpdateStbStats(SMeta* pMeta, int64_t uid, int64_t deltaCtb, int32_t deltaCol);
|
||||||
int32_t metaUidFilterCacheGet(SMeta* pMeta, uint64_t suid, const void* pKey, int32_t keyLen, LRUHandle** pHandle);
|
int32_t metaUidFilterCacheGet(SMeta* pMeta, uint64_t suid, const void* pKey, int32_t keyLen, LRUHandle** pHandle);
|
||||||
|
|
||||||
struct SMeta {
|
struct SMeta {
|
||||||
|
|
|
@ -170,7 +170,8 @@ int32_t metaTbGroupCacheClear(SMeta* pMeta, uint64_t suid);
|
||||||
int metaAddIndexToSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
int metaAddIndexToSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
||||||
int metaDropIndexFromSTable(SMeta* pMeta, int64_t version, SDropIndexReq* pReq);
|
int metaDropIndexFromSTable(SMeta* pMeta, int64_t version, SDropIndexReq* pReq);
|
||||||
|
|
||||||
int64_t metaGetTimeSeriesNum(SMeta* pMeta);
|
int64_t metaGetTimeSeriesNum(SMeta* pMeta, int type);
|
||||||
|
void metaUpdTimeSeriesNum(SMeta* pMeta);
|
||||||
SMCtbCursor* metaOpenCtbCursor(void* pVnode, tb_uid_t uid, int lock);
|
SMCtbCursor* metaOpenCtbCursor(void* pVnode, tb_uid_t uid, int lock);
|
||||||
int32_t metaResumeCtbCursor(SMCtbCursor* pCtbCur, int8_t first);
|
int32_t metaResumeCtbCursor(SMCtbCursor* pCtbCur, int8_t first);
|
||||||
void metaPauseCtbCursor(SMCtbCursor* pCtbCur);
|
void metaPauseCtbCursor(SMCtbCursor* pCtbCur);
|
||||||
|
@ -410,6 +411,7 @@ struct STsdbKeepCfg {
|
||||||
int32_t keep0;
|
int32_t keep0;
|
||||||
int32_t keep1;
|
int32_t keep1;
|
||||||
int32_t keep2;
|
int32_t keep2;
|
||||||
|
int32_t keepTimeOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct SVCommitSched {
|
typedef struct SVCommitSched {
|
||||||
|
|
|
@ -14,6 +14,13 @@
|
||||||
*/
|
*/
|
||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
|
|
||||||
|
#ifdef TD_ENTERPRISE
|
||||||
|
extern const char* tkLogStb[];
|
||||||
|
extern const char* tkAuditStb[];
|
||||||
|
extern const int tkLogStbNum;
|
||||||
|
extern const int tkAuditStbNum;
|
||||||
|
#endif
|
||||||
|
|
||||||
#define TAG_FILTER_RES_KEY_LEN 32
|
#define TAG_FILTER_RES_KEY_LEN 32
|
||||||
#define META_CACHE_BASE_BUCKET 1024
|
#define META_CACHE_BASE_BUCKET 1024
|
||||||
#define META_CACHE_STATS_BUCKET 16
|
#define META_CACHE_STATS_BUCKET 16
|
||||||
|
@ -69,6 +76,7 @@ struct SMetaCache {
|
||||||
|
|
||||||
struct STbFilterCache {
|
struct STbFilterCache {
|
||||||
SHashObj* pStb;
|
SHashObj* pStb;
|
||||||
|
SHashObj* pStbName;
|
||||||
} STbFilterCache;
|
} STbFilterCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -178,6 +186,13 @@ int32_t metaCacheOpen(SMeta* pMeta) {
|
||||||
goto _err2;
|
goto _err2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pCache->STbFilterCache.pStbName =
|
||||||
|
taosHashInit(0, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), false, HASH_NO_LOCK);
|
||||||
|
if (pCache->STbFilterCache.pStbName == NULL) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _err2;
|
||||||
|
}
|
||||||
|
|
||||||
pMeta->pCache = pCache;
|
pMeta->pCache = pCache;
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
|
@ -204,6 +219,7 @@ void metaCacheClose(SMeta* pMeta) {
|
||||||
taosHashCleanup(pMeta->pCache->STbGroupResCache.pTableEntry);
|
taosHashCleanup(pMeta->pCache->STbGroupResCache.pTableEntry);
|
||||||
|
|
||||||
taosHashCleanup(pMeta->pCache->STbFilterCache.pStb);
|
taosHashCleanup(pMeta->pCache->STbFilterCache.pStb);
|
||||||
|
taosHashCleanup(pMeta->pCache->STbFilterCache.pStbName);
|
||||||
|
|
||||||
taosMemoryFree(pMeta->pCache);
|
taosMemoryFree(pMeta->pCache);
|
||||||
pMeta->pCache = NULL;
|
pMeta->pCache = NULL;
|
||||||
|
@ -893,30 +909,59 @@ int32_t metaTbGroupCacheClear(SMeta* pMeta, uint64_t suid) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool metaTbInFilterCache(void* pVnode, tb_uid_t suid, int8_t type) {
|
bool metaTbInFilterCache(SMeta *pMeta, const void* key, int8_t type) {
|
||||||
SMeta* pMeta = ((SVnode*)pVnode)->pMeta;
|
if (type == 0 && taosHashGet(pMeta->pCache->STbFilterCache.pStb, key, sizeof(tb_uid_t))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (type == 0 && taosHashGet(pMeta->pCache->STbFilterCache.pStb, &suid, sizeof(suid))) {
|
if (type == 1 && taosHashGet(pMeta->pCache->STbFilterCache.pStbName, key, strlen(key))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t metaPutTbToFilterCache(void* pVnode, tb_uid_t suid, int8_t type) {
|
int32_t metaPutTbToFilterCache(SMeta *pMeta, const void* key, int8_t type) {
|
||||||
SMeta* pMeta = ((SVnode*)pVnode)->pMeta;
|
|
||||||
|
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
return taosHashPut(pMeta->pCache->STbFilterCache.pStb, &suid, sizeof(suid), NULL, 0);
|
return taosHashPut(pMeta->pCache->STbFilterCache.pStb, key, sizeof(tb_uid_t), NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == 1) {
|
||||||
|
return taosHashPut(pMeta->pCache->STbFilterCache.pStbName, key, strlen(key), NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t metaSizeOfTbFilterCache(void* pVnode, int8_t type) {
|
int32_t metaSizeOfTbFilterCache(SMeta *pMeta, int8_t type) {
|
||||||
SMeta* pMeta = ((SVnode*)pVnode)->pMeta;
|
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
return taosHashGetSize(pMeta->pCache->STbFilterCache.pStb);
|
return taosHashGetSize(pMeta->pCache->STbFilterCache.pStb);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t metaInitTbFilterCache(SMeta* pMeta) {
|
||||||
|
#ifdef TD_ENTERPRISE
|
||||||
|
int32_t tbNum = 0;
|
||||||
|
const char** pTbArr = NULL;
|
||||||
|
const char* dbName = NULL;
|
||||||
|
|
||||||
|
if (!(dbName = strchr(pMeta->pVnode->config.dbname, '.'))) return 0;
|
||||||
|
if (0 == strncmp(++dbName, "log", TSDB_DB_NAME_LEN)) {
|
||||||
|
tbNum = tkLogStbNum;
|
||||||
|
pTbArr = (const char**)&tkLogStb;
|
||||||
|
} else if (0 == strncmp(dbName, "audit", TSDB_DB_NAME_LEN)) {
|
||||||
|
tbNum = tkAuditStbNum;
|
||||||
|
pTbArr = (const char**)&tkAuditStb;
|
||||||
|
}
|
||||||
|
if (tbNum && pTbArr) {
|
||||||
|
for (int32_t i = 0; i < tbNum; ++i) {
|
||||||
|
if (metaPutTbToFilterCache(pMeta, pTbArr[i], 1) != 0) {
|
||||||
|
return terrno ? terrno : -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -176,6 +176,10 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (metaInitTbFilterCache(pMeta) != 0) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
metaDebug("vgId:%d, meta is opened", TD_VID(pVnode));
|
metaDebug("vgId:%d, meta is opened", TD_VID(pVnode));
|
||||||
|
|
||||||
*ppMeta = pMeta;
|
*ppMeta = pMeta;
|
||||||
|
|
|
@ -696,22 +696,30 @@ int64_t metaGetTbNum(SMeta *pMeta) {
|
||||||
return pMeta->pVnode->config.vndStats.numOfCTables + pMeta->pVnode->config.vndStats.numOfNTables;
|
return pMeta->pVnode->config.vndStats.numOfCTables + pMeta->pVnode->config.vndStats.numOfNTables;
|
||||||
}
|
}
|
||||||
|
|
||||||
// N.B. Called by statusReq per second
|
void metaUpdTimeSeriesNum(SMeta *pMeta) {
|
||||||
int64_t metaGetTimeSeriesNum(SMeta *pMeta) {
|
int64_t nCtbTimeSeries = 0;
|
||||||
// sum of (number of columns of stable - 1) * number of ctables (excluding timestamp column)
|
if (vnodeGetTimeSeriesNum(pMeta->pVnode, &nCtbTimeSeries) == 0) {
|
||||||
int64_t nTables = metaGetTbNum(pMeta);
|
atomic_store_64(&pMeta->pVnode->config.vndStats.numOfTimeSeries, nCtbTimeSeries);
|
||||||
if (nTables - pMeta->pVnode->config.vndStats.numOfCmprTables > 100 ||
|
}
|
||||||
pMeta->pVnode->config.vndStats.numOfTimeSeries <= 0 ||
|
}
|
||||||
++pMeta->pVnode->config.vndStats.itvTimeSeries % (60 * 5) == 0) {
|
|
||||||
int64_t num = 0;
|
|
||||||
vnodeGetTimeSeriesNum(pMeta->pVnode, &num);
|
|
||||||
pMeta->pVnode->config.vndStats.numOfTimeSeries = num;
|
|
||||||
|
|
||||||
pMeta->pVnode->config.vndStats.itvTimeSeries = (TD_VID(pMeta->pVnode) % 100) * 2;
|
static FORCE_INLINE int64_t metaGetTimeSeriesNumImpl(SMeta *pMeta, bool forceUpd) {
|
||||||
pMeta->pVnode->config.vndStats.numOfCmprTables = nTables;
|
// sum of (number of columns of stable - 1) * number of ctables (excluding timestamp column)
|
||||||
|
SVnodeStats *pStats = &pMeta->pVnode->config.vndStats;
|
||||||
|
if (forceUpd || pStats->numOfTimeSeries <= 0) {
|
||||||
|
metaUpdTimeSeriesNum(pMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pMeta->pVnode->config.vndStats.numOfTimeSeries + pMeta->pVnode->config.vndStats.numOfNTimeSeries;
|
return pStats->numOfTimeSeries + pStats->numOfNTimeSeries;
|
||||||
|
}
|
||||||
|
|
||||||
|
// type: 1 reported timeseries
|
||||||
|
int64_t metaGetTimeSeriesNum(SMeta *pMeta, int type) {
|
||||||
|
int64_t nTimeSeries = metaGetTimeSeriesNumImpl(pMeta, false);
|
||||||
|
if (type == 1) {
|
||||||
|
atomic_store_64(&pMeta->pVnode->config.vndStats.numOfReportedTimeSeries, nTimeSeries);
|
||||||
|
}
|
||||||
|
return nTimeSeries;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -1509,9 +1517,10 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t metaGetStbStats(void *pVnode, int64_t uid, int64_t *numOfTables) {
|
int32_t metaGetStbStats(void *pVnode, int64_t uid, int64_t *numOfTables, int32_t *numOfCols) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
*numOfTables = 0;
|
|
||||||
|
if (!numOfTables && !numOfCols) goto _exit;
|
||||||
|
|
||||||
SVnode *pVnodeObj = pVnode;
|
SVnode *pVnodeObj = pVnode;
|
||||||
metaRLock(pVnodeObj->pMeta);
|
metaRLock(pVnodeObj->pMeta);
|
||||||
|
@ -1520,19 +1529,26 @@ int32_t metaGetStbStats(void *pVnode, int64_t uid, int64_t *numOfTables) {
|
||||||
SMetaStbStats state = {0};
|
SMetaStbStats state = {0};
|
||||||
if (metaStatsCacheGet(pVnodeObj->pMeta, uid, &state) == TSDB_CODE_SUCCESS) {
|
if (metaStatsCacheGet(pVnodeObj->pMeta, uid, &state) == TSDB_CODE_SUCCESS) {
|
||||||
metaULock(pVnodeObj->pMeta);
|
metaULock(pVnodeObj->pMeta);
|
||||||
*numOfTables = state.ctbNum;
|
if (numOfTables) *numOfTables = state.ctbNum;
|
||||||
|
if (numOfCols) *numOfCols = state.colNum;
|
||||||
|
ASSERTS(state.colNum > 0, "vgId:%d, suid:%" PRIi64 " nCols:%d <= 0 in metaCache", TD_VID(pVnodeObj), uid,
|
||||||
|
state.colNum);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// slow path: search TDB
|
// slow path: search TDB
|
||||||
int64_t ctbNum = 0;
|
int64_t ctbNum = 0;
|
||||||
|
int32_t colNum = 0;
|
||||||
vnodeGetCtbNum(pVnode, uid, &ctbNum);
|
vnodeGetCtbNum(pVnode, uid, &ctbNum);
|
||||||
|
vnodeGetStbColumnNum(pVnode, uid, &colNum);
|
||||||
metaULock(pVnodeObj->pMeta);
|
metaULock(pVnodeObj->pMeta);
|
||||||
*numOfTables = ctbNum;
|
|
||||||
|
if (numOfTables) *numOfTables = ctbNum;
|
||||||
|
if (numOfCols) *numOfCols = colNum;
|
||||||
|
|
||||||
state.uid = uid;
|
state.uid = uid;
|
||||||
state.ctbNum = ctbNum;
|
state.ctbNum = ctbNum;
|
||||||
|
state.colNum = colNum;
|
||||||
|
|
||||||
// upsert the cache
|
// upsert the cache
|
||||||
metaWLock(pVnodeObj->pMeta);
|
metaWLock(pVnodeObj->pMeta);
|
||||||
|
@ -1543,12 +1559,12 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void metaUpdateStbStats(SMeta *pMeta, int64_t uid, int64_t delta) {
|
void metaUpdateStbStats(SMeta *pMeta, int64_t uid, int64_t deltaCtb, int32_t deltaCol) {
|
||||||
SMetaStbStats stats = {0};
|
SMetaStbStats stats = {0};
|
||||||
|
|
||||||
if (metaStatsCacheGet(pMeta, uid, &stats) == TSDB_CODE_SUCCESS) {
|
if (metaStatsCacheGet(pMeta, uid, &stats) == TSDB_CODE_SUCCESS) {
|
||||||
stats.ctbNum += delta;
|
stats.ctbNum += deltaCtb;
|
||||||
|
stats.colNum += deltaCol;
|
||||||
metaStatsCacheUpsert(pMeta, &stats);
|
metaStatsCacheUpsert(pMeta, &stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
|
|
||||||
|
extern SDmNotifyHandle dmNotifyHdl;
|
||||||
|
|
||||||
static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema);
|
static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema);
|
||||||
static int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema);
|
static int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema);
|
||||||
static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME);
|
static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME);
|
||||||
|
@ -26,7 +28,7 @@ static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME);
|
||||||
static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME);
|
static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME);
|
||||||
static int metaUpdateSuidIdx(SMeta *pMeta, const SMetaEntry *pME);
|
static int metaUpdateSuidIdx(SMeta *pMeta, const SMetaEntry *pME);
|
||||||
static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry);
|
static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry);
|
||||||
static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type);
|
static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *pSuid, int8_t *pSysTbl);
|
||||||
static void metaDestroyTagIdxKey(STagIdxKey *pTagIdxKey);
|
static void metaDestroyTagIdxKey(STagIdxKey *pTagIdxKey);
|
||||||
// opt ins_tables query
|
// opt ins_tables query
|
||||||
static int metaUpdateBtimeIdx(SMeta *pMeta, const SMetaEntry *pME);
|
static int metaUpdateBtimeIdx(SMeta *pMeta, const SMetaEntry *pME);
|
||||||
|
@ -34,6 +36,7 @@ static int metaDeleteBtimeIdx(SMeta *pMeta, const SMetaEntry *pME);
|
||||||
static int metaUpdateNcolIdx(SMeta *pMeta, const SMetaEntry *pME);
|
static int metaUpdateNcolIdx(SMeta *pMeta, const SMetaEntry *pME);
|
||||||
static int metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME);
|
static int metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME);
|
||||||
|
|
||||||
|
|
||||||
static void metaGetEntryInfo(const SMetaEntry *pEntry, SMetaInfo *pInfo) {
|
static void metaGetEntryInfo(const SMetaEntry *pEntry, SMetaInfo *pInfo) {
|
||||||
pInfo->uid = pEntry->uid;
|
pInfo->uid = pEntry->uid;
|
||||||
pInfo->version = pEntry->version;
|
pInfo->version = pEntry->version;
|
||||||
|
@ -191,6 +194,18 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void metaTimeSeriesNotifyCheck(SMeta *pMeta) {
|
||||||
|
#if defined(TD_ENTERPRISE) && !defined(_TD_DARWIN_64)
|
||||||
|
int64_t nTimeSeries = metaGetTimeSeriesNum(pMeta, 0);
|
||||||
|
int64_t deltaTS = nTimeSeries - pMeta->pVnode->config.vndStats.numOfReportedTimeSeries;
|
||||||
|
if (deltaTS > tsTimeSeriesThreshold) {
|
||||||
|
if (0 == atomic_val_compare_exchange_8(&dmNotifyHdl.state, 1, 2)) {
|
||||||
|
tsem_post(&dmNotifyHdl.sem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
SMetaEntry me = {0};
|
SMetaEntry me = {0};
|
||||||
int kLen = 0;
|
int kLen = 0;
|
||||||
|
@ -292,7 +307,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb
|
||||||
|
|
||||||
for (int32_t iChild = 0; iChild < taosArrayGetSize(tbUidList); iChild++) {
|
for (int32_t iChild = 0; iChild < taosArrayGetSize(tbUidList); iChild++) {
|
||||||
tb_uid_t uid = *(tb_uid_t *)taosArrayGet(tbUidList, iChild);
|
tb_uid_t uid = *(tb_uid_t *)taosArrayGet(tbUidList, iChild);
|
||||||
metaDropTableByUid(pMeta, uid, NULL);
|
metaDropTableByUid(pMeta, uid, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// drop super table
|
// drop super table
|
||||||
|
@ -304,8 +319,12 @@ _drop_super_table:
|
||||||
tdbTbDelete(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn);
|
tdbTbDelete(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn);
|
||||||
tdbTbDelete(pMeta->pSuidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn);
|
tdbTbDelete(pMeta->pSuidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn);
|
||||||
|
|
||||||
|
metaStatsCacheDrop(pMeta, pReq->suid);
|
||||||
|
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
|
|
||||||
|
metaUpdTimeSeriesNum(pMeta);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pData);
|
tdbFree(pData);
|
||||||
|
@ -376,6 +395,9 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
nStbEntry.stbEntry.schemaRow = pReq->schemaRow;
|
nStbEntry.stbEntry.schemaRow = pReq->schemaRow;
|
||||||
nStbEntry.stbEntry.schemaTag = pReq->schemaTag;
|
nStbEntry.stbEntry.schemaTag = pReq->schemaTag;
|
||||||
|
|
||||||
|
int32_t deltaCol = pReq->schemaRow.nCols - oStbEntry.stbEntry.schemaRow.nCols;
|
||||||
|
bool updStat = deltaCol != 0 && !metaTbInFilterCache(pMeta, pReq->name, 1);
|
||||||
|
|
||||||
metaWLock(pMeta);
|
metaWLock(pMeta);
|
||||||
// compare two entry
|
// compare two entry
|
||||||
if (oStbEntry.stbEntry.schemaRow.version != pReq->schemaRow.version) {
|
if (oStbEntry.stbEntry.schemaRow.version != pReq->schemaRow.version) {
|
||||||
|
@ -390,8 +412,19 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
|
|
||||||
// metaStatsCacheDrop(pMeta, nStbEntry.uid);
|
// metaStatsCacheDrop(pMeta, nStbEntry.uid);
|
||||||
|
|
||||||
|
if (updStat) {
|
||||||
|
metaUpdateStbStats(pMeta, pReq->suid, 0, deltaCol);
|
||||||
|
}
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
|
|
||||||
|
if (updStat) {
|
||||||
|
int64_t ctbNum;
|
||||||
|
metaGetStbStats(pMeta->pVnode, pReq->suid, &ctbNum, NULL);
|
||||||
|
pMeta->pVnode->config.vndStats.numOfTimeSeries += (ctbNum * deltaCol);
|
||||||
|
metaTimeSeriesNotifyCheck(pMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
|
@ -733,7 +766,10 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs
|
||||||
}
|
}
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
|
|
||||||
|
bool sysTbl = (pReq->type == TSDB_CHILD_TABLE) && metaTbInFilterCache(pMeta, pReq->ctb.stbName, 1);
|
||||||
|
|
||||||
// build SMetaEntry
|
// build SMetaEntry
|
||||||
|
SVnodeStats *pStats = &pMeta->pVnode->config.vndStats;
|
||||||
me.version = ver;
|
me.version = ver;
|
||||||
me.type = pReq->type;
|
me.type = pReq->type;
|
||||||
me.uid = pReq->uid;
|
me.uid = pReq->uid;
|
||||||
|
@ -767,10 +803,16 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
++pMeta->pVnode->config.vndStats.numOfCTables;
|
++pStats->numOfCTables;
|
||||||
|
|
||||||
|
if (!sysTbl) {
|
||||||
|
int32_t nCols = 0;
|
||||||
|
metaGetStbStats(pMeta->pVnode, me.ctbEntry.suid, 0, &nCols);
|
||||||
|
pStats->numOfTimeSeries += nCols - 1;
|
||||||
|
}
|
||||||
|
|
||||||
metaWLock(pMeta);
|
metaWLock(pMeta);
|
||||||
metaUpdateStbStats(pMeta, me.ctbEntry.suid, 1);
|
metaUpdateStbStats(pMeta, me.ctbEntry.suid, 1, 0);
|
||||||
metaUidCacheClear(pMeta, me.ctbEntry.suid);
|
metaUidCacheClear(pMeta, me.ctbEntry.suid);
|
||||||
metaTbGroupCacheClear(pMeta, me.ctbEntry.suid);
|
metaTbGroupCacheClear(pMeta, me.ctbEntry.suid);
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
|
@ -782,12 +824,14 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs
|
||||||
me.ntbEntry.schemaRow = pReq->ntb.schemaRow;
|
me.ntbEntry.schemaRow = pReq->ntb.schemaRow;
|
||||||
me.ntbEntry.ncid = me.ntbEntry.schemaRow.pSchema[me.ntbEntry.schemaRow.nCols - 1].colId + 1;
|
me.ntbEntry.ncid = me.ntbEntry.schemaRow.pSchema[me.ntbEntry.schemaRow.nCols - 1].colId + 1;
|
||||||
|
|
||||||
++pMeta->pVnode->config.vndStats.numOfNTables;
|
++pStats->numOfNTables;
|
||||||
pMeta->pVnode->config.vndStats.numOfNTimeSeries += me.ntbEntry.schemaRow.nCols - 1;
|
pStats->numOfNTimeSeries += me.ntbEntry.schemaRow.nCols - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metaHandleEntry(pMeta, &me) < 0) goto _err;
|
if (metaHandleEntry(pMeta, &me) < 0) goto _err;
|
||||||
|
|
||||||
|
metaTimeSeriesNotifyCheck(pMeta);
|
||||||
|
|
||||||
if (pMetaRsp) {
|
if (pMetaRsp) {
|
||||||
*pMetaRsp = taosMemoryCalloc(1, sizeof(STableMetaRsp));
|
*pMetaRsp = taosMemoryCalloc(1, sizeof(STableMetaRsp));
|
||||||
|
|
||||||
|
@ -817,7 +861,9 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
|
||||||
void *pData = NULL;
|
void *pData = NULL;
|
||||||
int nData = 0;
|
int nData = 0;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
tb_uid_t uid;
|
tb_uid_t uid = 0;
|
||||||
|
tb_uid_t suid = 0;
|
||||||
|
int8_t sysTbl = 0;
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
rc = tdbTbGet(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pData, &nData);
|
rc = tdbTbGet(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pData, &nData);
|
||||||
|
@ -828,9 +874,19 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
|
||||||
uid = *(tb_uid_t *)pData;
|
uid = *(tb_uid_t *)pData;
|
||||||
|
|
||||||
metaWLock(pMeta);
|
metaWLock(pMeta);
|
||||||
metaDropTableByUid(pMeta, uid, &type);
|
rc = metaDropTableByUid(pMeta, uid, &type, &suid, &sysTbl);
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
|
|
||||||
|
if (rc < 0) goto _exit;
|
||||||
|
|
||||||
|
if (!sysTbl && type == TSDB_CHILD_TABLE) {
|
||||||
|
int32_t nCols = 0;
|
||||||
|
SVnodeStats *pStats = &pMeta->pVnode->config.vndStats;
|
||||||
|
if (metaGetStbStats(pMeta->pVnode, suid, NULL, &nCols) == 0) {
|
||||||
|
pStats->numOfTimeSeries -= nCols - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((type == TSDB_CHILD_TABLE || type == TSDB_NORMAL_TABLE) && tbUids) {
|
if ((type == TSDB_CHILD_TABLE || type == TSDB_NORMAL_TABLE) && tbUids) {
|
||||||
taosArrayPush(tbUids, &uid);
|
taosArrayPush(tbUids, &uid);
|
||||||
}
|
}
|
||||||
|
@ -839,20 +895,49 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
|
||||||
*tbUid = uid;
|
*tbUid = uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
tdbFree(pData);
|
tdbFree(pData);
|
||||||
return 0;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void metaDropTables(SMeta *pMeta, SArray *tbUids) {
|
void metaDropTables(SMeta *pMeta, SArray *tbUids) {
|
||||||
if (taosArrayGetSize(tbUids) == 0) return;
|
if (taosArrayGetSize(tbUids) == 0) return;
|
||||||
|
|
||||||
|
int64_t nCtbDropped = 0;
|
||||||
|
SSHashObj *suidHash = tSimpleHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT));
|
||||||
|
|
||||||
metaWLock(pMeta);
|
metaWLock(pMeta);
|
||||||
for (int i = 0; i < taosArrayGetSize(tbUids); ++i) {
|
for (int i = 0; i < taosArrayGetSize(tbUids); ++i) {
|
||||||
tb_uid_t uid = *(tb_uid_t *)taosArrayGet(tbUids, i);
|
tb_uid_t uid = *(tb_uid_t *)taosArrayGet(tbUids, i);
|
||||||
metaDropTableByUid(pMeta, uid, NULL);
|
tb_uid_t suid = 0;
|
||||||
|
int8_t sysTbl = 0;
|
||||||
|
int type;
|
||||||
|
metaDropTableByUid(pMeta, uid, &type, &suid, &sysTbl);
|
||||||
|
if (!sysTbl && type == TSDB_CHILD_TABLE && suid != 0 && suidHash) {
|
||||||
|
int64_t *pVal = tSimpleHashGet(suidHash, &suid, sizeof(tb_uid_t));
|
||||||
|
if (pVal) {
|
||||||
|
nCtbDropped = *pVal + 1;
|
||||||
|
} else {
|
||||||
|
nCtbDropped = 1;
|
||||||
|
}
|
||||||
|
tSimpleHashPut(suidHash, &suid, sizeof(tb_uid_t), &nCtbDropped, sizeof(int64_t));
|
||||||
|
}
|
||||||
metaDebug("batch drop table:%" PRId64, uid);
|
metaDebug("batch drop table:%" PRId64, uid);
|
||||||
}
|
}
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
|
|
||||||
|
// update timeseries
|
||||||
|
void *pCtbDropped = NULL;
|
||||||
|
int32_t iter = 0;
|
||||||
|
while ((pCtbDropped = tSimpleHashIterate(suidHash, pCtbDropped, &iter))) {
|
||||||
|
tb_uid_t *pSuid = tSimpleHashGetKey(pCtbDropped, NULL);
|
||||||
|
int32_t nCols = 0;
|
||||||
|
SVnodeStats *pStats = &pMeta->pVnode->config.vndStats;
|
||||||
|
if (metaGetStbStats(pMeta->pVnode, *pSuid, NULL, &nCols) == 0) {
|
||||||
|
pStats->numOfTimeSeries -= *(int64_t *)pCtbDropped * (nCols - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tSimpleHashCleanup(suidHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) {
|
static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) {
|
||||||
|
@ -987,7 +1072,7 @@ static int metaDeleteTtl(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
return ttlMgrDeleteTtl(pMeta->pTtlMgr, &ctx);
|
return ttlMgrDeleteTtl(pMeta->pTtlMgr, &ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *pSuid, int8_t* pSysTbl) {
|
||||||
void *pData = NULL;
|
void *pData = NULL;
|
||||||
int nData = 0;
|
int nData = 0;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
@ -1012,6 +1097,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
||||||
if (type) *type = e.type;
|
if (type) *type = e.type;
|
||||||
|
|
||||||
if (e.type == TSDB_CHILD_TABLE) {
|
if (e.type == TSDB_CHILD_TABLE) {
|
||||||
|
if (pSuid) *pSuid = e.ctbEntry.suid;
|
||||||
void *tData = NULL;
|
void *tData = NULL;
|
||||||
int tLen = 0;
|
int tLen = 0;
|
||||||
|
|
||||||
|
@ -1024,6 +1110,8 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
||||||
tDecoderInit(&tdc, tData, tLen);
|
tDecoderInit(&tdc, tData, tLen);
|
||||||
metaDecodeEntry(&tdc, &stbEntry);
|
metaDecodeEntry(&tdc, &stbEntry);
|
||||||
|
|
||||||
|
if (pSysTbl) *pSysTbl = metaTbInFilterCache(pMeta, stbEntry.name, 1) ? 1 : 0;
|
||||||
|
|
||||||
SSchema *pTagColumn = NULL;
|
SSchema *pTagColumn = NULL;
|
||||||
SSchemaWrapper *pTagSchema = &stbEntry.stbEntry.schemaTag;
|
SSchemaWrapper *pTagSchema = &stbEntry.stbEntry.schemaTag;
|
||||||
if (pTagSchema->nCols == 1 && pTagSchema->pSchema[0].type == TSDB_DATA_TYPE_JSON) {
|
if (pTagSchema->nCols == 1 && pTagSchema->pSchema[0].type == TSDB_DATA_TYPE_JSON) {
|
||||||
|
@ -1075,8 +1163,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
||||||
tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), pMeta->txn);
|
tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), pMeta->txn);
|
||||||
|
|
||||||
--pMeta->pVnode->config.vndStats.numOfCTables;
|
--pMeta->pVnode->config.vndStats.numOfCTables;
|
||||||
|
metaUpdateStbStats(pMeta, e.ctbEntry.suid, -1, 0);
|
||||||
metaUpdateStbStats(pMeta, e.ctbEntry.suid, -1);
|
|
||||||
metaUidCacheClear(pMeta, e.ctbEntry.suid);
|
metaUidCacheClear(pMeta, e.ctbEntry.suid);
|
||||||
metaTbGroupCacheClear(pMeta, e.ctbEntry.suid);
|
metaTbGroupCacheClear(pMeta, e.ctbEntry.suid);
|
||||||
} else if (e.type == TSDB_NORMAL_TABLE) {
|
} else if (e.type == TSDB_NORMAL_TABLE) {
|
||||||
|
@ -1243,6 +1330,9 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
terrno = TSDB_CODE_VND_COL_ALREADY_EXISTS;
|
terrno = TSDB_CODE_VND_COL_ALREADY_EXISTS;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
if ((terrno = grantCheck(TSDB_GRANT_TIMESERIES)) < 0) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
pSchema->version++;
|
pSchema->version++;
|
||||||
pSchema->nCols++;
|
pSchema->nCols++;
|
||||||
pNewSchema = taosMemoryMalloc(sizeof(SSchema) * pSchema->nCols);
|
pNewSchema = taosMemoryMalloc(sizeof(SSchema) * pSchema->nCols);
|
||||||
|
@ -1255,6 +1345,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
strcpy(pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1].name, pAlterTbReq->colName);
|
strcpy(pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1].name, pAlterTbReq->colName);
|
||||||
|
|
||||||
++pMeta->pVnode->config.vndStats.numOfNTimeSeries;
|
++pMeta->pVnode->config.vndStats.numOfNTimeSeries;
|
||||||
|
metaTimeSeriesNotifyCheck(pMeta);
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_DROP_COLUMN:
|
case TSDB_ALTER_TABLE_DROP_COLUMN:
|
||||||
if (pColumn == NULL) {
|
if (pColumn == NULL) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ static int32_t rsmaRestore(SSma *pSma);
|
||||||
pKeepCfg->keep0 = pKeepCfg->keep2; \
|
pKeepCfg->keep0 = pKeepCfg->keep2; \
|
||||||
pKeepCfg->keep1 = pKeepCfg->keep2; \
|
pKeepCfg->keep1 = pKeepCfg->keep2; \
|
||||||
pKeepCfg->days = smaEvalDays(v, pCfg->retentions, l, pCfg->precision, pCfg->days); \
|
pKeepCfg->days = smaEvalDays(v, pCfg->retentions, l, pCfg->precision, pCfg->days); \
|
||||||
|
pKeepCfg->keepTimeOffset = 0; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define SMA_OPEN_RSMA_IMPL(v, l) \
|
#define SMA_OPEN_RSMA_IMPL(v, l) \
|
||||||
|
|
|
@ -57,7 +57,7 @@ static int32_t tsdbOpenBCache(STsdb *pTsdb) {
|
||||||
// SLRUCache *pCache = taosLRUCacheInit(10 * 1024 * 1024, 0, .5);
|
// SLRUCache *pCache = taosLRUCacheInit(10 * 1024 * 1024, 0, .5);
|
||||||
int32_t szPage = pTsdb->pVnode->config.tsdbPageSize;
|
int32_t szPage = pTsdb->pVnode->config.tsdbPageSize;
|
||||||
|
|
||||||
SLRUCache *pCache = taosLRUCacheInit(tsS3BlockCacheSize * tsS3BlockSize * szPage, 0, .5);
|
SLRUCache *pCache = taosLRUCacheInit((int64_t)tsS3BlockCacheSize * tsS3BlockSize * szPage, 0, .5);
|
||||||
if (pCache == NULL) {
|
if (pCache == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
|
@ -3061,7 +3061,7 @@ static int32_t tsdbCacheLoadBlockS3(STsdbFD *pFD, uint8_t **ppBlock) {
|
||||||
code = s3GetObjectBlock(pFD->objName, block_offset, tsS3BlockSize * pFD->szPage, ppBlock);
|
code = s3GetObjectBlock(pFD->objName, block_offset, tsS3BlockSize * pFD->szPage, ppBlock);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
// taosMemoryFree(pBlock);
|
// taosMemoryFree(pBlock);
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
// code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3100,7 +3100,10 @@ int32_t tsdbCacheGetBlockS3(SLRUCache *pCache, STsdbFD *pFD, LRUHandle **handle)
|
||||||
taosThreadMutexUnlock(&pTsdb->bMutex);
|
taosThreadMutexUnlock(&pTsdb->bMutex);
|
||||||
|
|
||||||
*handle = NULL;
|
*handle = NULL;
|
||||||
return 0;
|
if (code == TSDB_CODE_SUCCESS && !pBlock) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t charge = tsS3BlockSize * pFD->szPage;
|
size_t charge = tsS3BlockSize * pFD->szPage;
|
||||||
|
|
|
@ -501,7 +501,6 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
STsdb *pTsdb = pCommitter->pTsdb;
|
STsdb *pTsdb = pCommitter->pTsdb;
|
||||||
SDFileSet *pRSet = NULL;
|
SDFileSet *pRSet = NULL;
|
||||||
|
|
||||||
// memory
|
// memory
|
||||||
pCommitter->commitFid = tsdbKeyFid(pCommitter->nextKey, pCommitter->minutes, pCommitter->precision);
|
pCommitter->commitFid = tsdbKeyFid(pCommitter->nextKey, pCommitter->minutes, pCommitter->precision);
|
||||||
pCommitter->expLevel = tsdbFidLevel(pCommitter->commitFid, &pCommitter->pTsdb->keepCfg, taosGetTimestampSec());
|
pCommitter->expLevel = tsdbFidLevel(pCommitter->commitFid, &pCommitter->pTsdb->keepCfg, taosGetTimestampSec());
|
||||||
|
@ -799,7 +798,6 @@ static int32_t tsdbCommitFileData(SCommitter *pCommitter) {
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
STsdb *pTsdb = pCommitter->pTsdb;
|
STsdb *pTsdb = pCommitter->pTsdb;
|
||||||
SMemTable *pMemTable = pTsdb->imem;
|
SMemTable *pMemTable = pTsdb->imem;
|
||||||
|
|
||||||
// commit file data start
|
// commit file data start
|
||||||
code = tsdbCommitFileDataStart(pCommitter);
|
code = tsdbCommitFileDataStart(pCommitter);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
|
@ -23,6 +23,7 @@ int32_t tsdbSetKeepCfg(STsdb *pTsdb, STsdbCfg *pCfg) {
|
||||||
pKeepCfg->keep0 = pCfg->keep0;
|
pKeepCfg->keep0 = pCfg->keep0;
|
||||||
pKeepCfg->keep1 = pCfg->keep1;
|
pKeepCfg->keep1 = pCfg->keep1;
|
||||||
pKeepCfg->keep2 = pCfg->keep2;
|
pKeepCfg->keep2 = pCfg->keep2;
|
||||||
|
pKeepCfg->keepTimeOffset = pCfg->keepTimeOffset;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,8 +76,9 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbDebug("vgId:%d, tsdb is opened at %s, days:%d, keep:%d,%d,%d", TD_VID(pVnode), pTsdb->path, pTsdb->keepCfg.days,
|
tsdbDebug("vgId:%d, tsdb is opened at %s, days:%d, keep:%d,%d,%d, keepTimeoffset:%d", TD_VID(pVnode), pTsdb->path,
|
||||||
pTsdb->keepCfg.keep0, pTsdb->keepCfg.keep1, pTsdb->keepCfg.keep2);
|
pTsdb->keepCfg.days, pTsdb->keepCfg.keep0, pTsdb->keepCfg.keep1, pTsdb->keepCfg.keep2,
|
||||||
|
pTsdb->keepCfg.keepTimeOffset);
|
||||||
|
|
||||||
*ppTsdb = pTsdb;
|
*ppTsdb = pTsdb;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -89,8 +91,9 @@ _err:
|
||||||
int tsdbClose(STsdb **pTsdb) {
|
int tsdbClose(STsdb **pTsdb) {
|
||||||
if (*pTsdb) {
|
if (*pTsdb) {
|
||||||
STsdb *pdb = *pTsdb;
|
STsdb *pdb = *pTsdb;
|
||||||
tsdbDebug("vgId:%d, tsdb is close at %s, days:%d, keep:%d,%d,%d", TD_VID(pdb->pVnode), pdb->path, pdb->keepCfg.days,
|
tsdbDebug("vgId:%d, tsdb is close at %s, days:%d, keep:%d,%d,%d, keepTimeOffset:%d", TD_VID(pdb->pVnode), pdb->path,
|
||||||
pdb->keepCfg.keep0, pdb->keepCfg.keep1, pdb->keepCfg.keep2);
|
pdb->keepCfg.days, pdb->keepCfg.keep0, pdb->keepCfg.keep1, pdb->keepCfg.keep2,
|
||||||
|
pdb->keepCfg.keepTimeOffset);
|
||||||
taosThreadRwlockWrlock(&(*pTsdb)->rwLock);
|
taosThreadRwlockWrlock(&(*pTsdb)->rwLock);
|
||||||
tsdbMemTableDestroy((*pTsdb)->mem, true);
|
tsdbMemTableDestroy((*pTsdb)->mem, true);
|
||||||
(*pTsdb)->mem = NULL;
|
(*pTsdb)->mem = NULL;
|
||||||
|
|
|
@ -4882,6 +4882,7 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs
|
||||||
// alloc
|
// alloc
|
||||||
STsdbReadSnap* pSnap = (STsdbReadSnap*)taosMemoryCalloc(1, sizeof(STsdbReadSnap));
|
STsdbReadSnap* pSnap = (STsdbReadSnap*)taosMemoryCalloc(1, sizeof(STsdbReadSnap));
|
||||||
if (pSnap == NULL) {
|
if (pSnap == NULL) {
|
||||||
|
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
@ -4891,6 +4892,7 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs
|
||||||
pSnap->pMem = pTsdb->mem;
|
pSnap->pMem = pTsdb->mem;
|
||||||
pSnap->pNode = taosMemoryMalloc(sizeof(*pSnap->pNode));
|
pSnap->pNode = taosMemoryMalloc(sizeof(*pSnap->pNode));
|
||||||
if (pSnap->pNode == NULL) {
|
if (pSnap->pNode == NULL) {
|
||||||
|
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
@ -4905,6 +4907,7 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs
|
||||||
pSnap->pIMem = pTsdb->imem;
|
pSnap->pIMem = pTsdb->imem;
|
||||||
pSnap->pINode = taosMemoryMalloc(sizeof(*pSnap->pINode));
|
pSnap->pINode = taosMemoryMalloc(sizeof(*pSnap->pINode));
|
||||||
if (pSnap->pINode == NULL) {
|
if (pSnap->pINode == NULL) {
|
||||||
|
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
@ -4915,6 +4918,9 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs
|
||||||
tsdbRefMemTable(pTsdb->imem, pSnap->pINode);
|
tsdbRefMemTable(pTsdb->imem, pSnap->pINode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unlock
|
||||||
|
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||||
|
|
||||||
// fs
|
// fs
|
||||||
code = tsdbFSCreateRefSnapshot(pTsdb->pFS, &pSnap->pfSetArray);
|
code = tsdbFSCreateRefSnapshot(pTsdb->pFS, &pSnap->pfSetArray);
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
@ -4922,8 +4928,6 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("vgId:%d take read snapshot failed, code:%s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
tsdbError("vgId:%d take read snapshot failed, code:%s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ static int32_t tsdbOpenFileImpl(STsdbFD *pFD) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// not check file size when reading data files.
|
// not check file size when reading data files.
|
||||||
if (flag != TD_FILE_READ) {
|
if (flag != TD_FILE_READ && !pFD->s3File) {
|
||||||
if (taosStatFile(path, &pFD->szFile, NULL, NULL) < 0) {
|
if (taosStatFile(path, &pFD->szFile, NULL, NULL) < 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
// taosMemoryFree(pFD->pBuf);
|
// taosMemoryFree(pFD->pBuf);
|
||||||
|
@ -130,6 +130,9 @@ static int32_t tsdbWriteFilePage(STsdbFD *pFD) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pFD->s3File) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
if (pFD->pgno > 0) {
|
if (pFD->pgno > 0) {
|
||||||
int64_t n = taosLSeekFile(pFD->pFD, PAGE_OFFSET(pFD->pgno, pFD->szPage), SEEK_SET);
|
int64_t n = taosLSeekFile(pFD->pFD, PAGE_OFFSET(pFD->pgno, pFD->szPage), SEEK_SET);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
|
@ -172,9 +175,12 @@ static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno) {
|
||||||
LRUHandle *handle = NULL;
|
LRUHandle *handle = NULL;
|
||||||
|
|
||||||
pFD->blkno = (pgno + tsS3BlockSize - 1) / tsS3BlockSize;
|
pFD->blkno = (pgno + tsS3BlockSize - 1) / tsS3BlockSize;
|
||||||
int32_t code = tsdbCacheGetBlockS3(pFD->pTsdb->bCache, pFD, &handle);
|
code = tsdbCacheGetBlockS3(pFD->pTsdb->bCache, pFD, &handle);
|
||||||
if (code != TSDB_CODE_SUCCESS || handle == NULL) {
|
if (code != TSDB_CODE_SUCCESS || handle == NULL) {
|
||||||
tsdbBCacheRelease(pFD->pTsdb->bCache, handle);
|
tsdbBCacheRelease(pFD->pTsdb->bCache, handle);
|
||||||
|
if (code == TSDB_CODE_SUCCESS && !handle) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,6 +285,9 @@ _exit:
|
||||||
int32_t tsdbFsyncFile(STsdbFD *pFD) {
|
int32_t tsdbFsyncFile(STsdbFD *pFD) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
if (pFD->s3File) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
code = tsdbWriteFilePage(pFD);
|
code = tsdbWriteFilePage(pFD);
|
||||||
if (code) goto _exit;
|
if (code) goto _exit;
|
||||||
|
|
||||||
|
|
|
@ -542,7 +542,7 @@ int32_t tsdbFidLevel(int32_t fid, STsdbKeepCfg *pKeepCfg, int64_t nowSec) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
nowSec = nowSec - tsKeepTimeOffset * tsTickPerHour[pKeepCfg->precision];
|
nowSec = nowSec - pKeepCfg->keepTimeOffset * tsTickPerHour[pKeepCfg->precision];
|
||||||
|
|
||||||
key = nowSec - pKeepCfg->keep0 * tsTickPerMin[pKeepCfg->precision];
|
key = nowSec - pKeepCfg->keep0 * tsTickPerMin[pKeepCfg->precision];
|
||||||
aFid[0] = tsdbKeyFid(key, pKeepCfg->days, pKeepCfg->precision);
|
aFid[0] = tsdbKeyFid(key, pKeepCfg->days, pKeepCfg->precision);
|
||||||
|
|
|
@ -35,7 +35,8 @@ const SVnodeCfg vnodeCfgDefault = {.vgId = -1,
|
||||||
.maxRows = 4096,
|
.maxRows = 4096,
|
||||||
.keep2 = 5256000,
|
.keep2 = 5256000,
|
||||||
.keep0 = 5256000,
|
.keep0 = 5256000,
|
||||||
.keep1 = 5256000},
|
.keep1 = 5256000,
|
||||||
|
.keepTimeOffset = TSDB_DEFAULT_KEEP_TIME_OFFSET},
|
||||||
.walCfg =
|
.walCfg =
|
||||||
{
|
{
|
||||||
.vgId = -1,
|
.vgId = -1,
|
||||||
|
@ -104,6 +105,7 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
|
||||||
if (tjsonAddIntegerToObject(pJson, "keep0", pCfg->tsdbCfg.keep0) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "keep0", pCfg->tsdbCfg.keep0) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1;
|
||||||
|
if (tjsonAddIntegerToObject(pJson, "keepTimeOffset", pCfg->tsdbCfg.keepTimeOffset) < 0) return -1;
|
||||||
if (pCfg->tsdbCfg.retentions[0].freq > 0) {
|
if (pCfg->tsdbCfg.retentions[0].freq > 0) {
|
||||||
int32_t nRetention = 1;
|
int32_t nRetention = 1;
|
||||||
if (pCfg->tsdbCfg.retentions[1].freq > 0) {
|
if (pCfg->tsdbCfg.retentions[1].freq > 0) {
|
||||||
|
@ -219,6 +221,8 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
||||||
if (code < 0) return -1;
|
if (code < 0) return -1;
|
||||||
tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep2, code);
|
tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep2, code);
|
||||||
if (code < 0) return -1;
|
if (code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "keepTimeOffset", pCfg->tsdbCfg.keepTimeOffset, code);
|
||||||
|
if (code < 0) return -1;
|
||||||
SJson *pNodeRetentions = tjsonGetObjectItem(pJson, "retentions");
|
SJson *pNodeRetentions = tjsonGetObjectItem(pJson, "retentions");
|
||||||
int32_t nRetention = tjsonGetArraySize(pNodeRetentions);
|
int32_t nRetention = tjsonGetArraySize(pNodeRetentions);
|
||||||
if (nRetention > TSDB_RETENTION_MAX) {
|
if (nRetention > TSDB_RETENTION_MAX) {
|
||||||
|
|
|
@ -111,15 +111,14 @@ int32_t s3PutObjectFromFile2(const char *file_str, const char *object_str) {
|
||||||
clt_params = cos_create_resumable_clt_params_content(p, 1024 * 1024, 8, COS_FALSE, NULL);
|
clt_params = cos_create_resumable_clt_params_content(p, 1024 * 1024, 8, COS_FALSE, NULL);
|
||||||
s = cos_resumable_upload_file(options, &bucket, &object, &file, headers, NULL, clt_params, NULL, &resp_headers, NULL);
|
s = cos_resumable_upload_file(options, &bucket, &object, &file, headers, NULL, clt_params, NULL, &resp_headers, NULL);
|
||||||
|
|
||||||
|
log_status(s);
|
||||||
if (!cos_status_is_ok(s)) {
|
if (!cos_status_is_ok(s)) {
|
||||||
vError("s3: %s", s->error_msg);
|
vError("s3: %d(%s)", s->code, s->error_msg);
|
||||||
vError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
|
vError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
|
||||||
code = terrno;
|
code = TAOS_SYSTEM_ERROR(EIO);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_status(s);
|
|
||||||
|
|
||||||
cos_pool_destroy(p);
|
cos_pool_destroy(p);
|
||||||
|
|
||||||
if (s->code != 200) {
|
if (s->code != 200) {
|
||||||
|
@ -301,14 +300,14 @@ int32_t s3GetObjectBlock(const char *object_name, int64_t offset, int64_t block_
|
||||||
apr_table_add(headers, COS_RANGE, range_buf);
|
apr_table_add(headers, COS_RANGE, range_buf);
|
||||||
|
|
||||||
s = cos_get_object_to_buffer(options, &bucket, &object, headers, NULL, &download_buffer, &resp_headers);
|
s = cos_get_object_to_buffer(options, &bucket, &object, headers, NULL, &download_buffer, &resp_headers);
|
||||||
|
log_status(s);
|
||||||
if (!cos_status_is_ok(s)) {
|
if (!cos_status_is_ok(s)) {
|
||||||
vError("s3: %s", s->error_msg);
|
vError("s3: %d(%s)", s->code, s->error_msg);
|
||||||
vError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
|
vError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
|
||||||
code = terrno;
|
code = TAOS_SYSTEM_ERROR(EIO);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_status(s);
|
|
||||||
// print_headers(resp_headers);
|
// print_headers(resp_headers);
|
||||||
int64_t len = 0;
|
int64_t len = 0;
|
||||||
int64_t size = 0;
|
int64_t size = 0;
|
||||||
|
|
|
@ -388,7 +388,7 @@ int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
|
||||||
pLoad->cacheUsage = tsdbCacheGetUsage(pVnode);
|
pLoad->cacheUsage = tsdbCacheGetUsage(pVnode);
|
||||||
pLoad->numOfCachedTables = tsdbCacheGetElems(pVnode);
|
pLoad->numOfCachedTables = tsdbCacheGetElems(pVnode);
|
||||||
pLoad->numOfTables = metaGetTbNum(pVnode->pMeta);
|
pLoad->numOfTables = metaGetTbNum(pVnode->pMeta);
|
||||||
pLoad->numOfTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta);
|
pLoad->numOfTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta, 1);
|
||||||
pLoad->totalStorage = (int64_t)3 * 1073741824;
|
pLoad->totalStorage = (int64_t)3 * 1073741824;
|
||||||
pLoad->compStorage = (int64_t)2 * 1073741824;
|
pLoad->compStorage = (int64_t)2 * 1073741824;
|
||||||
pLoad->pointsWritten = 100;
|
pLoad->pointsWritten = 100;
|
||||||
|
@ -400,6 +400,15 @@ int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t vnodeGetLoadLite(SVnode *pVnode, SVnodeLoadLite *pLoad) {
|
||||||
|
SSyncState syncState = syncGetState(pVnode->sync);
|
||||||
|
if (syncState.state == TAOS_SYNC_STATE_LEADER) {
|
||||||
|
pLoad->vgId = TD_VID(pVnode);
|
||||||
|
pLoad->nTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta, 1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Reset the statistics value by monitor interval
|
* @brief Reset the statistics value by monitor interval
|
||||||
*
|
*
|
||||||
|
@ -544,8 +553,8 @@ int32_t vnodeGetCtbNum(SVnode *pVnode, int64_t suid, int64_t *num) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vnodeGetStbColumnNum(SVnode *pVnode, tb_uid_t suid, int *num) {
|
int32_t vnodeGetStbColumnNum(SVnode *pVnode, tb_uid_t suid, int *num) {
|
||||||
SSchemaWrapper *pSW = metaGetTableSchema(pVnode->pMeta, suid, -1, 1);
|
SSchemaWrapper *pSW = metaGetTableSchema(pVnode->pMeta, suid, -1, 0);
|
||||||
if (pSW) {
|
if (pSW) {
|
||||||
*num = pSW->nCols;
|
*num = pSW->nCols;
|
||||||
tDeleteSchemaWrapper(pSW);
|
tDeleteSchemaWrapper(pSW);
|
||||||
|
@ -557,42 +566,55 @@ static int32_t vnodeGetStbColumnNum(SVnode *pVnode, tb_uid_t suid, int *num) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
#define TK_LOG_STB_NUM 19
|
const char *tkLogStb[] = {"cluster_info",
|
||||||
static const char *tkLogStb[TK_LOG_STB_NUM] = {"cluster_info",
|
"data_dir",
|
||||||
"data_dir",
|
"dnodes_info",
|
||||||
"dnodes_info",
|
"d_info",
|
||||||
"d_info",
|
"grants_info",
|
||||||
"grants_info",
|
"keeper_monitor",
|
||||||
"keeper_monitor",
|
"logs",
|
||||||
"logs",
|
"log_dir",
|
||||||
"log_dir",
|
"log_summary",
|
||||||
"log_summary",
|
"m_info",
|
||||||
"m_info",
|
"taosadapter_restful_http_request_fail",
|
||||||
"taosadapter_restful_http_request_fail",
|
"taosadapter_restful_http_request_in_flight",
|
||||||
"taosadapter_restful_http_request_in_flight",
|
"taosadapter_restful_http_request_summary_milliseconds",
|
||||||
"taosadapter_restful_http_request_summary_milliseconds",
|
"taosadapter_restful_http_request_total",
|
||||||
"taosadapter_restful_http_request_total",
|
"taosadapter_system_cpu_percent",
|
||||||
"taosadapter_system_cpu_percent",
|
"taosadapter_system_mem_percent",
|
||||||
"taosadapter_system_mem_percent",
|
"temp_dir",
|
||||||
"temp_dir",
|
"vgroups_info",
|
||||||
"vgroups_info",
|
"vnodes_role"};
|
||||||
"vnodes_role"};
|
const char *tkAuditStb[] = {"operations"};
|
||||||
|
const int tkLogStbNum = ARRAY_SIZE(tkLogStb);
|
||||||
|
const int tkAuditStbNum = ARRAY_SIZE(tkAuditStb);
|
||||||
|
|
||||||
// exclude stbs of taoskeeper log
|
// exclude stbs of taoskeeper log
|
||||||
static int32_t vnodeGetTimeSeriesBlackList(SVnode *pVnode) {
|
static int32_t vnodeGetTimeSeriesBlackList(SVnode *pVnode) {
|
||||||
char *dbName = strchr(pVnode->config.dbname, '.');
|
int32_t tbSize = 0;
|
||||||
if (!dbName || 0 != strncmp(++dbName, "log", TSDB_DB_NAME_LEN)) {
|
int32_t tbNum = 0;
|
||||||
return 0;
|
const char **pTbArr = NULL;
|
||||||
|
const char *dbName = NULL;
|
||||||
|
|
||||||
|
if (!(dbName = strchr(pVnode->config.dbname, '.'))) return 0;
|
||||||
|
if (0 == strncmp(++dbName, "log", TSDB_DB_NAME_LEN)) {
|
||||||
|
tbNum = tkLogStbNum;
|
||||||
|
pTbArr = (const char **)&tkLogStb;
|
||||||
|
} else if (0 == strncmp(dbName, "audit", TSDB_DB_NAME_LEN)) {
|
||||||
|
tbNum = tkAuditStbNum;
|
||||||
|
pTbArr = (const char **)&tkAuditStb;
|
||||||
}
|
}
|
||||||
int32_t tbSize = metaSizeOfTbFilterCache(pVnode, 0);
|
if (tbNum && pTbArr) {
|
||||||
if (tbSize < TK_LOG_STB_NUM) {
|
tbSize = metaSizeOfTbFilterCache(pVnode->pMeta, 0);
|
||||||
for (int32_t i = 0; i < TK_LOG_STB_NUM; ++i) {
|
if (tbSize < tbNum) {
|
||||||
tb_uid_t suid = metaGetTableEntryUidByName(pVnode->pMeta, tkLogStb[i]);
|
for (int32_t i = 0; i < tbNum; ++i) {
|
||||||
if (suid != 0) {
|
tb_uid_t suid = metaGetTableEntryUidByName(pVnode->pMeta, pTbArr[i]);
|
||||||
metaPutTbToFilterCache(pVnode, suid, 0);
|
if (suid != 0) {
|
||||||
|
metaPutTbToFilterCache(pVnode->pMeta, &suid, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
tbSize = metaSizeOfTbFilterCache(pVnode->pMeta, 0);
|
||||||
}
|
}
|
||||||
tbSize = metaSizeOfTbFilterCache(pVnode, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tbSize;
|
return tbSize;
|
||||||
|
@ -602,7 +624,7 @@ static int32_t vnodeGetTimeSeriesBlackList(SVnode *pVnode) {
|
||||||
static bool vnodeTimeSeriesFilter(void *arg1, void *arg2) {
|
static bool vnodeTimeSeriesFilter(void *arg1, void *arg2) {
|
||||||
SVnode *pVnode = (SVnode *)arg1;
|
SVnode *pVnode = (SVnode *)arg1;
|
||||||
|
|
||||||
if (metaTbInFilterCache(pVnode, *(tb_uid_t *)(arg2), 0)) {
|
if (metaTbInFilterCache(pVnode->pMeta, arg2, 0)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -617,9 +639,9 @@ int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tbFilterSize = 0;
|
int32_t tbFilterSize = 0;
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
tbFilterSize = vnodeGetTimeSeriesBlackList(pVnode);
|
tbFilterSize = vnodeGetTimeSeriesBlackList(pVnode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((!tbFilterSize && vnodeGetStbIdList(pVnode, 0, suidList) < 0) ||
|
if ((!tbFilterSize && vnodeGetStbIdList(pVnode, 0, suidList) < 0) ||
|
||||||
(tbFilterSize && vnodeGetStbIdListByFilter(pVnode, 0, suidList, vnodeTimeSeriesFilter, pVnode) < 0)) {
|
(tbFilterSize && vnodeGetStbIdListByFilter(pVnode, 0, suidList, vnodeTimeSeriesFilter, pVnode) < 0)) {
|
||||||
|
@ -634,10 +656,8 @@ int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num) {
|
||||||
tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i);
|
tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i);
|
||||||
|
|
||||||
int64_t ctbNum = 0;
|
int64_t ctbNum = 0;
|
||||||
metaGetStbStats(pVnode, suid, &ctbNum);
|
int32_t numOfCols = 0;
|
||||||
|
metaGetStbStats(pVnode, suid, &ctbNum, &numOfCols);
|
||||||
int numOfCols = 0;
|
|
||||||
vnodeGetStbColumnNum(pVnode, suid, &numOfCols);
|
|
||||||
|
|
||||||
*num += ctbNum * (numOfCols - 1);
|
*num += ctbNum * (numOfCols - 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1722,11 +1722,11 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t ver, void *pRe
|
||||||
}
|
}
|
||||||
|
|
||||||
vInfo("vgId:%d, start to alter vnode config, page:%d pageSize:%d buffer:%d szPage:%d szBuf:%" PRIu64
|
vInfo("vgId:%d, start to alter vnode config, page:%d pageSize:%d buffer:%d szPage:%d szBuf:%" PRIu64
|
||||||
" cacheLast:%d cacheLastSize:%d days:%d keep0:%d keep1:%d keep2:%d fsync:%d level:%d walRetentionPeriod:%d "
|
" cacheLast:%d cacheLastSize:%d days:%d keep0:%d keep1:%d keep2:%d keepTimeOffset:%d fsync:%d level:%d "
|
||||||
"walRetentionSize:%d",
|
"walRetentionPeriod:%d walRetentionSize:%d",
|
||||||
TD_VID(pVnode), req.pages, req.pageSize, req.buffer, req.pageSize * 1024, (uint64_t)req.buffer * 1024 * 1024,
|
TD_VID(pVnode), req.pages, req.pageSize, req.buffer, req.pageSize * 1024, (uint64_t)req.buffer * 1024 * 1024,
|
||||||
req.cacheLast, req.cacheLastSize, req.daysPerFile, req.daysToKeep0, req.daysToKeep1, req.daysToKeep2,
|
req.cacheLast, req.cacheLastSize, req.daysPerFile, req.daysToKeep0, req.daysToKeep1, req.daysToKeep2,
|
||||||
req.walFsyncPeriod, req.walLevel, req.walRetentionPeriod, req.walRetentionSize);
|
req.keepTimeOffset, req.walFsyncPeriod, req.walLevel, req.walRetentionPeriod, req.walRetentionSize);
|
||||||
|
|
||||||
if (pVnode->config.cacheLastSize != req.cacheLastSize) {
|
if (pVnode->config.cacheLastSize != req.cacheLastSize) {
|
||||||
pVnode->config.cacheLastSize = req.cacheLastSize;
|
pVnode->config.cacheLastSize = req.cacheLastSize;
|
||||||
|
@ -1795,6 +1795,13 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t ver, void *pRe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pVnode->config.tsdbCfg.keepTimeOffset != req.keepTimeOffset) {
|
||||||
|
pVnode->config.tsdbCfg.keepTimeOffset = req.keepTimeOffset;
|
||||||
|
if (!VND_IS_RSMA(pVnode)) {
|
||||||
|
tsdbChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (req.sttTrigger != -1 && req.sttTrigger != pVnode->config.sttTrigger) {
|
if (req.sttTrigger != -1 && req.sttTrigger != pVnode->config.sttTrigger) {
|
||||||
pVnode->config.sttTrigger = req.sttTrigger;
|
pVnode->config.sttTrigger = req.sttTrigger;
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,11 +312,12 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, ch
|
||||||
"CREATE DATABASE `%s` BUFFER %d CACHESIZE %d CACHEMODEL '%s' COMP %d DURATION %dm "
|
"CREATE DATABASE `%s` BUFFER %d CACHESIZE %d CACHEMODEL '%s' COMP %d DURATION %dm "
|
||||||
"WAL_FSYNC_PERIOD %d MAXROWS %d MINROWS %d STT_TRIGGER %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d "
|
"WAL_FSYNC_PERIOD %d MAXROWS %d MINROWS %d STT_TRIGGER %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d "
|
||||||
"WAL_LEVEL %d VGROUPS %d SINGLE_STABLE %d TABLE_PREFIX %d TABLE_SUFFIX %d TSDB_PAGESIZE %d "
|
"WAL_LEVEL %d VGROUPS %d SINGLE_STABLE %d TABLE_PREFIX %d TABLE_SUFFIX %d TSDB_PAGESIZE %d "
|
||||||
"WAL_RETENTION_PERIOD %d WAL_RETENTION_SIZE %" PRId64,
|
"WAL_RETENTION_PERIOD %d WAL_RETENTION_SIZE %" PRId64 " KEEP_TIME_OFFSET %d",
|
||||||
dbName, pCfg->buffer, pCfg->cacheSize, cacheModelStr(pCfg->cacheLast), pCfg->compression, pCfg->daysPerFile,
|
dbName, pCfg->buffer, pCfg->cacheSize, cacheModelStr(pCfg->cacheLast), pCfg->compression, pCfg->daysPerFile,
|
||||||
pCfg->walFsyncPeriod, pCfg->maxRows, pCfg->minRows, pCfg->sstTrigger, pCfg->daysToKeep0, pCfg->daysToKeep1, pCfg->daysToKeep2,
|
pCfg->walFsyncPeriod, pCfg->maxRows, pCfg->minRows, pCfg->sstTrigger, pCfg->daysToKeep0, pCfg->daysToKeep1, pCfg->daysToKeep2,
|
||||||
pCfg->pages, pCfg->pageSize, prec, pCfg->replications, pCfg->walLevel, pCfg->numOfVgroups,
|
pCfg->pages, pCfg->pageSize, prec, pCfg->replications, pCfg->walLevel, pCfg->numOfVgroups,
|
||||||
1 == pCfg->numOfStables, hashPrefix, pCfg->hashSuffix, pCfg->tsdbPageSize, pCfg->walRetentionPeriod, pCfg->walRetentionSize);
|
1 == pCfg->numOfStables, hashPrefix, pCfg->hashSuffix, pCfg->tsdbPageSize, pCfg->walRetentionPeriod, pCfg->walRetentionSize,
|
||||||
|
pCfg->keepTimeOffset);
|
||||||
|
|
||||||
if (retentions) {
|
if (retentions) {
|
||||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, " RETENTIONS %s", retentions);
|
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, " RETENTIONS %s", retentions);
|
||||||
|
|
|
@ -3931,7 +3931,7 @@ static void buildVnodeFilteredTbCount(SOperatorInfo* pOperator, STableCountScanO
|
||||||
pAPI->metaFn.getTableUidByName(pInfo->readHandle.vnode, pSupp->stbNameFilter, &uid);
|
pAPI->metaFn.getTableUidByName(pInfo->readHandle.vnode, pSupp->stbNameFilter, &uid);
|
||||||
|
|
||||||
int64_t numOfChildTables = 0;
|
int64_t numOfChildTables = 0;
|
||||||
pAPI->metaFn.getNumOfChildTables(pInfo->readHandle.vnode, uid, &numOfChildTables);
|
pAPI->metaFn.getNumOfChildTables(pInfo->readHandle.vnode, uid, &numOfChildTables, NULL);
|
||||||
|
|
||||||
fillTableCountScanDataBlock(pSupp, dbName, pSupp->stbNameFilter, numOfChildTables, pRes);
|
fillTableCountScanDataBlock(pSupp, dbName, pSupp->stbNameFilter, numOfChildTables, pRes);
|
||||||
} else {
|
} else {
|
||||||
|
@ -3982,7 +3982,7 @@ static void buildVnodeGroupedStbTableCount(STableCountScanOperatorInfo* pInfo, S
|
||||||
pRes->info.id.groupId = groupId;
|
pRes->info.id.groupId = groupId;
|
||||||
|
|
||||||
int64_t ctbNum = 0;
|
int64_t ctbNum = 0;
|
||||||
int32_t code = pAPI->metaFn.getNumOfChildTables(pInfo->readHandle.vnode, stbUid, &ctbNum);
|
int32_t code = pAPI->metaFn.getNumOfChildTables(pInfo->readHandle.vnode, stbUid, &ctbNum, NULL);
|
||||||
fillTableCountScanDataBlock(pSupp, dbName, varDataVal(stbName), ctbNum, pRes);
|
fillTableCountScanDataBlock(pSupp, dbName, varDataVal(stbName), ctbNum, pRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1595,6 +1595,26 @@ void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc) {
|
||||||
nodesFree(pSrc);
|
nodesFree(pSrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nodesListInsertListAfterPos(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc) {
|
||||||
|
if (NULL == pTarget || NULL == pPos || NULL == pSrc || NULL == pSrc->pHead) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL == pPos->pNext) {
|
||||||
|
pTarget->pTail = pSrc->pHead;
|
||||||
|
} else {
|
||||||
|
pPos->pNext->pPrev = pSrc->pHead;
|
||||||
|
}
|
||||||
|
|
||||||
|
pSrc->pHead->pPrev = pPos;
|
||||||
|
pSrc->pTail->pNext = pPos->pNext;
|
||||||
|
|
||||||
|
pPos->pNext = pSrc->pHead;
|
||||||
|
|
||||||
|
pTarget->length += pSrc->length;
|
||||||
|
nodesFree(pSrc);
|
||||||
|
}
|
||||||
|
|
||||||
SNode* nodesListGetNode(SNodeList* pList, int32_t index) {
|
SNode* nodesListGetNode(SNodeList* pList, int32_t index) {
|
||||||
SNode* node;
|
SNode* node;
|
||||||
FOREACH(node, pList) {
|
FOREACH(node, pList) {
|
||||||
|
@ -2318,3 +2338,13 @@ SValueNode* nodesMakeValueNodeFromBool(bool b) {
|
||||||
}
|
}
|
||||||
return pValNode;
|
return pValNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool nodesIsStar(SNode* pNode) {
|
||||||
|
return (QUERY_NODE_COLUMN == nodeType(pNode)) && ('\0' == ((SColumnNode*)pNode)->tableAlias[0]) &&
|
||||||
|
(0 == strcmp(((SColumnNode*)pNode)->colName, "*"));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool nodesIsTableStar(SNode* pNode) {
|
||||||
|
return (QUERY_NODE_COLUMN == nodeType(pNode)) && ('\0' != ((SColumnNode*)pNode)->tableAlias[0]) &&
|
||||||
|
(0 == strcmp(((SColumnNode*)pNode)->colName, "*"));
|
||||||
|
}
|
|
@ -1,4 +1,7 @@
|
||||||
aux_source_directory(src PARSER_SRC)
|
aux_source_directory(src PARSER_SRC)
|
||||||
|
IF (TD_BI_SUPPORT)
|
||||||
|
LIST(APPEND PARSER_SRC ${TD_ENTERPRISE_DIR}/src/plugins/bi/src/biRewriteQuery.c)
|
||||||
|
ENDIF ()
|
||||||
add_library(parser STATIC ${PARSER_SRC})
|
add_library(parser STATIC ${PARSER_SRC})
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
parser
|
parser
|
||||||
|
|
|
@ -63,7 +63,8 @@ typedef enum EDatabaseOptionType {
|
||||||
DB_OPTION_WAL_SEGMENT_SIZE,
|
DB_OPTION_WAL_SEGMENT_SIZE,
|
||||||
DB_OPTION_STT_TRIGGER,
|
DB_OPTION_STT_TRIGGER,
|
||||||
DB_OPTION_TABLE_PREFIX,
|
DB_OPTION_TABLE_PREFIX,
|
||||||
DB_OPTION_TABLE_SUFFIX
|
DB_OPTION_TABLE_SUFFIX,
|
||||||
|
DB_OPTION_KEEP_TIME_OFFSET
|
||||||
} EDatabaseOptionType;
|
} EDatabaseOptionType;
|
||||||
|
|
||||||
typedef enum ETableOptionType {
|
typedef enum ETableOptionType {
|
||||||
|
|
|
@ -36,7 +36,6 @@ int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pS
|
||||||
int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery);
|
int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery);
|
||||||
int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, void** pResRow);
|
int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, void** pResRow);
|
||||||
int32_t translatePostCreateSmaIndex(SParseContext* pParseCxt, SQuery* pQuery, void** pResRow);
|
int32_t translatePostCreateSmaIndex(SParseContext* pParseCxt, SQuery* pQuery, void** pResRow);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TD_PARSER_TRANS_H_
|
||||||
|
#define _TD_PARSER_TRANS_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "parToken.h"
|
||||||
|
#include "parUtil.h"
|
||||||
|
#include "parser.h"
|
||||||
|
|
||||||
|
typedef struct STranslateContext {
|
||||||
|
SParseContext* pParseCxt;
|
||||||
|
int32_t errCode;
|
||||||
|
SMsgBuf msgBuf;
|
||||||
|
SArray* pNsLevel; // element is SArray*, the element of this subarray is STableNode*
|
||||||
|
int32_t currLevel;
|
||||||
|
int32_t levelNo;
|
||||||
|
ESqlClause currClause;
|
||||||
|
SNode* pCurrStmt;
|
||||||
|
SCmdMsgInfo* pCmdMsg;
|
||||||
|
SHashObj* pDbs;
|
||||||
|
SHashObj* pTables;
|
||||||
|
SHashObj* pTargetTables;
|
||||||
|
SExplainOptions* pExplainOpt;
|
||||||
|
SParseMetaCache* pMetaCache;
|
||||||
|
bool createStream;
|
||||||
|
bool stableQuery;
|
||||||
|
bool showRewrite;
|
||||||
|
SNode* pPrevRoot;
|
||||||
|
SNode* pPostRoot;
|
||||||
|
} STranslateContext;
|
||||||
|
|
||||||
|
int32_t biRewriteSelectStar(STranslateContext* pCxt, SSelectStmt* pSelect);
|
||||||
|
int32_t findTable(STranslateContext* pCxt, const char* pTableAlias, STableNode** pOutput);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*_TD_PARSER_TRANS_H_*/
|
|
@ -255,6 +255,7 @@ db_options(A) ::= db_options(B) WAL_SEGMENT_SIZE NK_INTEGER(C).
|
||||||
db_options(A) ::= db_options(B) STT_TRIGGER NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_STT_TRIGGER, &C); }
|
db_options(A) ::= db_options(B) STT_TRIGGER NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_STT_TRIGGER, &C); }
|
||||||
db_options(A) ::= db_options(B) TABLE_PREFIX signed(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TABLE_PREFIX, C); }
|
db_options(A) ::= db_options(B) TABLE_PREFIX signed(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TABLE_PREFIX, C); }
|
||||||
db_options(A) ::= db_options(B) TABLE_SUFFIX signed(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TABLE_SUFFIX, C); }
|
db_options(A) ::= db_options(B) TABLE_SUFFIX signed(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TABLE_SUFFIX, C); }
|
||||||
|
db_options(A) ::= db_options(B) KEEP_TIME_OFFSET NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_KEEP_TIME_OFFSET, &C); }
|
||||||
|
|
||||||
alter_db_options(A) ::= alter_db_option(B). { A = createAlterDatabaseOptions(pCxt); A = setAlterDatabaseOption(pCxt, A, &B); }
|
alter_db_options(A) ::= alter_db_option(B). { A = createAlterDatabaseOptions(pCxt); A = setAlterDatabaseOption(pCxt, A, &B); }
|
||||||
alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setAlterDatabaseOption(pCxt, B, &C); }
|
alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setAlterDatabaseOption(pCxt, B, &C); }
|
||||||
|
@ -285,6 +286,7 @@ alter_db_option(A) ::= WAL_RETENTION_SIZE NK_MINUS(B) NK_INTEGER(C).
|
||||||
t.n = (C.z + C.n) - B.z;
|
t.n = (C.z + C.n) - B.z;
|
||||||
A.type = DB_OPTION_WAL_RETENTION_SIZE; A.val = t;
|
A.type = DB_OPTION_WAL_RETENTION_SIZE; A.val = t;
|
||||||
}
|
}
|
||||||
|
alter_db_option(A) ::= KEEP_TIME_OFFSET NK_INTEGER(B). { A.type = DB_OPTION_KEEP_TIME_OFFSET; A.val = B; }
|
||||||
|
|
||||||
%type integer_list { SNodeList* }
|
%type integer_list { SNodeList* }
|
||||||
%destructor integer_list { nodesDestroyList($$); }
|
%destructor integer_list { nodesDestroyList($$); }
|
||||||
|
|
|
@ -1201,6 +1201,10 @@ static SNode* setDatabaseOptionImpl(SAstCreateContext* pCxt, SNode* pOptions, ED
|
||||||
nodesDestroyNode((SNode*)pNode);
|
nodesDestroyNode((SNode*)pNode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case DB_OPTION_KEEP_TIME_OFFSET: {
|
||||||
|
pDbOptions->keepTimeOffset = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,6 +293,7 @@ static SKeyword keywordTable[] = {
|
||||||
{"_WSTART", TK_WSTART},
|
{"_WSTART", TK_WSTART},
|
||||||
{"ALIVE", TK_ALIVE},
|
{"ALIVE", TK_ALIVE},
|
||||||
{"VARBINARY", TK_VARBINARY},
|
{"VARBINARY", TK_VARBINARY},
|
||||||
|
{"KEEP_TIME_OFFSET", TK_KEEP_TIME_OFFSET},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "parTranslater.h"
|
||||||
#include "parInt.h"
|
#include "parInt.h"
|
||||||
|
|
||||||
#include "catalog.h"
|
#include "catalog.h"
|
||||||
|
@ -35,28 +36,6 @@ typedef struct SRewriteTbNameContext {
|
||||||
char* pTbName;
|
char* pTbName;
|
||||||
} SRewriteTbNameContext;
|
} SRewriteTbNameContext;
|
||||||
|
|
||||||
typedef struct STranslateContext {
|
|
||||||
SParseContext* pParseCxt;
|
|
||||||
int32_t errCode;
|
|
||||||
SMsgBuf msgBuf;
|
|
||||||
SArray* pNsLevel; // element is SArray*, the element of this subarray is STableNode*
|
|
||||||
int32_t currLevel;
|
|
||||||
int32_t levelNo;
|
|
||||||
ESqlClause currClause;
|
|
||||||
SNode* pCurrStmt;
|
|
||||||
SCmdMsgInfo* pCmdMsg;
|
|
||||||
SHashObj* pDbs;
|
|
||||||
SHashObj* pTables;
|
|
||||||
SHashObj* pTargetTables;
|
|
||||||
SExplainOptions* pExplainOpt;
|
|
||||||
SParseMetaCache* pMetaCache;
|
|
||||||
bool createStream;
|
|
||||||
bool stableQuery;
|
|
||||||
bool showRewrite;
|
|
||||||
SNode* pPrevRoot;
|
|
||||||
SNode* pPostRoot;
|
|
||||||
} STranslateContext;
|
|
||||||
|
|
||||||
typedef struct SBuildTopicContext {
|
typedef struct SBuildTopicContext {
|
||||||
bool colExists;
|
bool colExists;
|
||||||
bool colNotFound;
|
bool colNotFound;
|
||||||
|
@ -1230,37 +1209,37 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_VARBINARY: {
|
case TSDB_DATA_TYPE_VARBINARY: {
|
||||||
if (pVal->node.resType.type != TSDB_DATA_TYPE_BINARY){
|
if (pVal->node.resType.type != TSDB_DATA_TYPE_BINARY) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* data = NULL;
|
void* data = NULL;
|
||||||
uint32_t size = 0;
|
uint32_t size = 0;
|
||||||
bool isHexChar = isHex(pVal->literal, strlen(pVal->literal));
|
bool isHexChar = isHex(pVal->literal, strlen(pVal->literal));
|
||||||
if(isHexChar){
|
if (isHexChar) {
|
||||||
if(!isValidateHex(pVal->literal, strlen(pVal->literal))){
|
if (!isValidateHex(pVal->literal, strlen(pVal->literal))) {
|
||||||
return TSDB_CODE_PAR_INVALID_VARBINARY;
|
return TSDB_CODE_PAR_INVALID_VARBINARY;
|
||||||
}
|
}
|
||||||
if(taosHex2Ascii(pVal->literal, strlen(pVal->literal), &data, &size) < 0){
|
if (taosHex2Ascii(pVal->literal, strlen(pVal->literal), &data, &size) < 0) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
size = pVal->node.resType.bytes;
|
size = pVal->node.resType.bytes;
|
||||||
data = pVal->literal;
|
data = pVal->literal;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size + VARSTR_HEADER_SIZE > targetDt.bytes) {
|
if (size + VARSTR_HEADER_SIZE > targetDt.bytes) {
|
||||||
if(isHexChar) taosMemoryFree(data);
|
if (isHexChar) taosMemoryFree(data);
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_VALUE_TOO_LONG, pVal->literal);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_VALUE_TOO_LONG, pVal->literal);
|
||||||
}
|
}
|
||||||
pVal->datum.p = taosMemoryCalloc(1, size + VARSTR_HEADER_SIZE);
|
pVal->datum.p = taosMemoryCalloc(1, size + VARSTR_HEADER_SIZE);
|
||||||
if (NULL == pVal->datum.p) {
|
if (NULL == pVal->datum.p) {
|
||||||
if(isHexChar) taosMemoryFree(data);
|
if (isHexChar) taosMemoryFree(data);
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
varDataSetLen(pVal->datum.p, size);
|
varDataSetLen(pVal->datum.p, size);
|
||||||
memcpy(varDataVal(pVal->datum.p), data, size);
|
memcpy(varDataVal(pVal->datum.p), data, size);
|
||||||
if(isHexChar) taosMemoryFree(data);
|
if (isHexChar) taosMemoryFree(data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_VARCHAR:
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
|
@ -1419,7 +1398,7 @@ static EDealRes haveVectorFunction(SNode* pNode, void* pContext) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t findTable(STranslateContext* pCxt, const char* pTableAlias, STableNode** pOutput) {
|
int32_t findTable(STranslateContext* pCxt, const char* pTableAlias, STableNode** pOutput) {
|
||||||
SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel);
|
SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel);
|
||||||
size_t nums = taosArrayGetSize(pTables);
|
size_t nums = taosArrayGetSize(pTables);
|
||||||
for (size_t i = 0; i < nums; ++i) {
|
for (size_t i = 0; i < nums; ++i) {
|
||||||
|
@ -1810,17 +1789,7 @@ static int32_t translateBlockDistFunc(STranslateContext* pCtx, SFunctionNode* pF
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isStar(SNode* pNode) {
|
static bool isStarParam(SNode* pNode) { return nodesIsStar(pNode) || nodesIsTableStar(pNode); }
|
||||||
return (QUERY_NODE_COLUMN == nodeType(pNode)) && ('\0' == ((SColumnNode*)pNode)->tableAlias[0]) &&
|
|
||||||
(0 == strcmp(((SColumnNode*)pNode)->colName, "*"));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool isTableStar(SNode* pNode) {
|
|
||||||
return (QUERY_NODE_COLUMN == nodeType(pNode)) && ('\0' != ((SColumnNode*)pNode)->tableAlias[0]) &&
|
|
||||||
(0 == strcmp(((SColumnNode*)pNode)->colName, "*"));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool isStarParam(SNode* pNode) { return isStar(pNode) || isTableStar(pNode); }
|
|
||||||
|
|
||||||
static int32_t translateMultiResFunc(STranslateContext* pCxt, SFunctionNode* pFunc) {
|
static int32_t translateMultiResFunc(STranslateContext* pCxt, SFunctionNode* pFunc) {
|
||||||
if (!fmIsMultiResFunc(pFunc->funcId)) {
|
if (!fmIsMultiResFunc(pFunc->funcId)) {
|
||||||
|
@ -2841,7 +2810,8 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
|
||||||
pJoinTable->table.precision = calcJoinTablePrecision(pJoinTable);
|
pJoinTable->table.precision = calcJoinTablePrecision(pJoinTable);
|
||||||
pJoinTable->table.singleTable = joinTableIsSingleTable(pJoinTable);
|
pJoinTable->table.singleTable = joinTableIsSingleTable(pJoinTable);
|
||||||
code = translateExpr(pCxt, &pJoinTable->pOnCond);
|
code = translateExpr(pCxt, &pJoinTable->pOnCond);
|
||||||
pJoinTable->hasSubQuery = (nodeType(pJoinTable->pLeft) != QUERY_NODE_REAL_TABLE) || (nodeType(pJoinTable->pRight) != QUERY_NODE_REAL_TABLE);
|
pJoinTable->hasSubQuery = (nodeType(pJoinTable->pLeft) != QUERY_NODE_REAL_TABLE) ||
|
||||||
|
(nodeType(pJoinTable->pRight) != QUERY_NODE_REAL_TABLE);
|
||||||
if (nodeType(pJoinTable->pLeft) == QUERY_NODE_JOIN_TABLE) {
|
if (nodeType(pJoinTable->pLeft) == QUERY_NODE_JOIN_TABLE) {
|
||||||
((SJoinTableNode*)pJoinTable->pLeft)->isLowLevelJoin = true;
|
((SJoinTableNode*)pJoinTable->pLeft)->isLowLevelJoin = true;
|
||||||
}
|
}
|
||||||
|
@ -2900,7 +2870,7 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) {
|
||||||
} else {
|
} else {
|
||||||
len = snprintf(buf, sizeof(buf) - 1, "%s(%s.%s)", pSrcFunc->functionName, pCol->tableAlias, pCol->colName);
|
len = snprintf(buf, sizeof(buf) - 1, "%s(%s.%s)", pSrcFunc->functionName, pCol->tableAlias, pCol->colName);
|
||||||
taosCreateMD5Hash(buf, len);
|
taosCreateMD5Hash(buf, len);
|
||||||
strncpy(pFunc->node.aliasName, buf, TSDB_COL_NAME_LEN - 1);
|
strncpy(pFunc->node.aliasName, buf, TSDB_COL_NAME_LEN - 1);
|
||||||
len = snprintf(buf, sizeof(buf) - 1, "%s(%s)", pSrcFunc->functionName, pCol->colName);
|
len = snprintf(buf, sizeof(buf) - 1, "%s(%s)", pSrcFunc->functionName, pCol->colName);
|
||||||
// note: userAlias could be truncated here
|
// note: userAlias could be truncated here
|
||||||
strncpy(pFunc->node.userAlias, buf, TSDB_COL_NAME_LEN - 1);
|
strncpy(pFunc->node.userAlias, buf, TSDB_COL_NAME_LEN - 1);
|
||||||
|
@ -2938,9 +2908,9 @@ static int32_t createMultiResFuncsParas(STranslateContext* pCxt, SNodeList* pSrc
|
||||||
SNodeList* pExprs = NULL;
|
SNodeList* pExprs = NULL;
|
||||||
SNode* pPara = NULL;
|
SNode* pPara = NULL;
|
||||||
FOREACH(pPara, pSrcParas) {
|
FOREACH(pPara, pSrcParas) {
|
||||||
if (isStar(pPara)) {
|
if (nodesIsStar(pPara)) {
|
||||||
code = createAllColumns(pCxt, true, &pExprs);
|
code = createAllColumns(pCxt, true, &pExprs);
|
||||||
} else if (isTableStar(pPara)) {
|
} else if (nodesIsTableStar(pPara)) {
|
||||||
code = createTableAllCols(pCxt, (SColumnNode*)pPara, true, &pExprs);
|
code = createTableAllCols(pCxt, (SColumnNode*)pPara, true, &pExprs);
|
||||||
} else {
|
} else {
|
||||||
code = nodesListMakeStrictAppend(&pExprs, nodesCloneNode(pPara));
|
code = nodesListMakeStrictAppend(&pExprs, nodesCloneNode(pPara));
|
||||||
|
@ -3022,11 +2992,15 @@ static int32_t createTags(STranslateContext* pCxt, SNodeList** pOutput) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TD_ENTERPRISE
|
||||||
|
int32_t biRewriteSelectStar(STranslateContext* pCxt, SSelectStmt* pSelect) { return TSDB_CODE_SUCCESS; }
|
||||||
|
#endif
|
||||||
|
|
||||||
static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
WHERE_EACH(pNode, pSelect->pProjectionList) {
|
WHERE_EACH(pNode, pSelect->pProjectionList) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (isStar(pNode)) {
|
if (nodesIsStar(pNode)) {
|
||||||
SNodeList* pCols = NULL;
|
SNodeList* pCols = NULL;
|
||||||
code = createAllColumns(pCxt, false, &pCols);
|
code = createAllColumns(pCxt, false, &pCols);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -3046,7 +3020,7 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
ERASE_NODE(pSelect->pProjectionList);
|
ERASE_NODE(pSelect->pProjectionList);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (isTableStar(pNode)) {
|
} else if (nodesIsTableStar(pNode)) {
|
||||||
SNodeList* pCols = NULL;
|
SNodeList* pCols = NULL;
|
||||||
code = createTableAllCols(pCxt, (SColumnNode*)pNode, false, &pCols);
|
code = createTableAllCols(pCxt, (SColumnNode*)pNode, false, &pCols);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -3735,7 +3709,8 @@ static int32_t removeConstantValueFromList(SNodeList** pList) {
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
WHERE_EACH(pNode, *pList) {
|
WHERE_EACH(pNode, *pList) {
|
||||||
if (nodeType(pNode) == QUERY_NODE_VALUE ||
|
if (nodeType(pNode) == QUERY_NODE_VALUE ||
|
||||||
(nodeType(pNode) == QUERY_NODE_FUNCTION && fmIsConstantResFunc((SFunctionNode*)pNode) && fmIsScalarFunc(((SFunctionNode*)pNode)->funcId))) {
|
(nodeType(pNode) == QUERY_NODE_FUNCTION && fmIsConstantResFunc((SFunctionNode*)pNode) &&
|
||||||
|
fmIsScalarFunc(((SFunctionNode*)pNode)->funcId))) {
|
||||||
ERASE_NODE(*pList);
|
ERASE_NODE(*pList);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -3935,6 +3910,9 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = translateHaving(pCxt, pSelect);
|
code = translateHaving(pCxt, pSelect);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code && pCxt->pParseCxt->biMode != 0) {
|
||||||
|
code = biRewriteSelectStar(pCxt, pSelect);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = translateSelectList(pCxt, pSelect);
|
code = translateSelectList(pCxt, pSelect);
|
||||||
}
|
}
|
||||||
|
@ -4334,6 +4312,7 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS
|
||||||
pReq->hashPrefix = pStmt->pOptions->tablePrefix;
|
pReq->hashPrefix = pStmt->pOptions->tablePrefix;
|
||||||
pReq->hashSuffix = pStmt->pOptions->tableSuffix;
|
pReq->hashSuffix = pStmt->pOptions->tableSuffix;
|
||||||
pReq->tsdbPageSize = pStmt->pOptions->tsdbPageSize;
|
pReq->tsdbPageSize = pStmt->pOptions->tsdbPageSize;
|
||||||
|
pReq->keepTimeOffset = pStmt->pOptions->keepTimeOffset;
|
||||||
pReq->ignoreExist = pStmt->ignoreExists;
|
pReq->ignoreExist = pStmt->ignoreExists;
|
||||||
return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq);
|
return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq);
|
||||||
}
|
}
|
||||||
|
@ -4434,6 +4413,17 @@ static int32_t checkDbKeepOption(STranslateContext* pCxt, SDatabaseOptions* pOpt
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t checkDbKeepTimeOffsetOption(STranslateContext* pCxt, SDatabaseOptions* pOptions) {
|
||||||
|
if (pOptions->keepTimeOffset < TSDB_MIN_KEEP_TIME_OFFSET || pOptions->keepTimeOffset > TSDB_MAX_KEEP_TIME_OFFSET) {
|
||||||
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
||||||
|
"Invalid option keep_time_offset: %d"
|
||||||
|
" valid range: [%d, %d]",
|
||||||
|
pOptions->keepTimeOffset, TSDB_MIN_KEEP_TIME_OFFSET, TSDB_MAX_KEEP_TIME_OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t checkDbCacheModelOption(STranslateContext* pCxt, SDatabaseOptions* pOptions) {
|
static int32_t checkDbCacheModelOption(STranslateContext* pCxt, SDatabaseOptions* pOptions) {
|
||||||
if ('\0' != pOptions->cacheModelStr[0]) {
|
if ('\0' != pOptions->cacheModelStr[0]) {
|
||||||
if (0 == strcasecmp(pOptions->cacheModelStr, TSDB_CACHE_MODEL_NONE_STR)) {
|
if (0 == strcasecmp(pOptions->cacheModelStr, TSDB_CACHE_MODEL_NONE_STR)) {
|
||||||
|
@ -4565,9 +4555,9 @@ static int32_t checkOptionsDependency(STranslateContext* pCxt, const char* pDbNa
|
||||||
daysPerFile = (-1 == daysPerFile ? dbCfg.daysPerFile : daysPerFile);
|
daysPerFile = (-1 == daysPerFile ? dbCfg.daysPerFile : daysPerFile);
|
||||||
daysToKeep0 = (-1 == daysToKeep0 ? dbCfg.daysToKeep0 : daysToKeep0);
|
daysToKeep0 = (-1 == daysToKeep0 ? dbCfg.daysToKeep0 : daysToKeep0);
|
||||||
}
|
}
|
||||||
if (daysPerFile > daysToKeep0) {
|
if (daysPerFile > daysToKeep0 / 3) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
||||||
"Invalid duration value, should be keep2 >= keep1 >= keep0 >= duration");
|
"Invalid duration value, should be keep2 >= keep1 >= keep0 >= 3 * duration");
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -4606,6 +4596,9 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkDbKeepOption(pCxt, pOptions); // use precision
|
code = checkDbKeepOption(pCxt, pOptions); // use precision
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = checkDbKeepTimeOffsetOption(pCxt, pOptions);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkDbRangeOption(pCxt, "pages", pOptions->pages, TSDB_MIN_PAGES_PER_VNODE, TSDB_MAX_PAGES_PER_VNODE);
|
code = checkDbRangeOption(pCxt, "pages", pOptions->pages, TSDB_MIN_PAGES_PER_VNODE, TSDB_MAX_PAGES_PER_VNODE);
|
||||||
}
|
}
|
||||||
|
@ -4727,6 +4720,7 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt,
|
||||||
pReq->daysToKeep0 = pStmt->pOptions->keep[0];
|
pReq->daysToKeep0 = pStmt->pOptions->keep[0];
|
||||||
pReq->daysToKeep1 = pStmt->pOptions->keep[1];
|
pReq->daysToKeep1 = pStmt->pOptions->keep[1];
|
||||||
pReq->daysToKeep2 = pStmt->pOptions->keep[2];
|
pReq->daysToKeep2 = pStmt->pOptions->keep[2];
|
||||||
|
pReq->keepTimeOffset = pStmt->pOptions->keepTimeOffset;
|
||||||
pReq->walFsyncPeriod = pStmt->pOptions->fsyncPeriod;
|
pReq->walFsyncPeriod = pStmt->pOptions->fsyncPeriod;
|
||||||
pReq->walLevel = pStmt->pOptions->walLevel;
|
pReq->walLevel = pStmt->pOptions->walLevel;
|
||||||
pReq->strict = pStmt->pOptions->strict;
|
pReq->strict = pStmt->pOptions->strict;
|
||||||
|
@ -8022,9 +8016,29 @@ static int32_t insertCondIntoSelectStmt(SSelectStmt* pSelect, SNode* pCond) {
|
||||||
if (pSelect->pWhere == NULL) {
|
if (pSelect->pWhere == NULL) {
|
||||||
pSelect->pWhere = pCond;
|
pSelect->pWhere = pCond;
|
||||||
} else {
|
} else {
|
||||||
SNode* pWhere = NULL;
|
SNodeList* pLogicCondListWhere = NULL;
|
||||||
createLogicCondNode(pSelect->pWhere, pCond, &pWhere, LOGIC_COND_TYPE_AND);
|
SNodeList* pLogicCondList2 = NULL;
|
||||||
pSelect->pWhere = pWhere;
|
if (nodeType(pSelect->pWhere) == QUERY_NODE_LOGIC_CONDITION &&
|
||||||
|
((SLogicConditionNode*)pSelect->pWhere)->condType == LOGIC_COND_TYPE_AND) {
|
||||||
|
pLogicCondListWhere = ((SLogicConditionNode*)pSelect->pWhere)->pParameterList;
|
||||||
|
} else {
|
||||||
|
nodesListMakeAppend(&pLogicCondListWhere, pSelect->pWhere);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nodeType(pCond) == QUERY_NODE_LOGIC_CONDITION &&
|
||||||
|
((SLogicConditionNode*)pCond)->condType == LOGIC_COND_TYPE_AND) {
|
||||||
|
pLogicCondList2 = ((SLogicConditionNode*)pCond)->pParameterList;
|
||||||
|
} else {
|
||||||
|
nodesListMakeAppend(&pLogicCondList2, pCond);
|
||||||
|
}
|
||||||
|
|
||||||
|
nodesListAppendList(pLogicCondListWhere, pLogicCondList2);
|
||||||
|
|
||||||
|
SLogicConditionNode* pWhere = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||||
|
pWhere->condType = LOGIC_COND_TYPE_AND;
|
||||||
|
pWhere->pParameterList = pLogicCondListWhere;
|
||||||
|
|
||||||
|
pSelect->pWhere = (SNode*)pWhere;
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -8098,7 +8112,6 @@ static int32_t addShowKindCond(const SShowStmt* pShow, SSelectStmt* pSelect) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int32_t createShowCondition(const SShowStmt* pShow, SSelectStmt* pSelect) {
|
static int32_t createShowCondition(const SShowStmt* pShow, SSelectStmt* pSelect) {
|
||||||
SNode* pDbCond = NULL;
|
SNode* pDbCond = NULL;
|
||||||
SNode* pTbCond = NULL;
|
SNode* pTbCond = NULL;
|
||||||
|
@ -9537,11 +9550,6 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t rewriteQueryForBI(STranslateContext* pParseCxt, SQuery* pQuery) {
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t translate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) {
|
int32_t translate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) {
|
||||||
STranslateContext cxt = {0};
|
STranslateContext cxt = {0};
|
||||||
|
|
||||||
|
@ -9549,13 +9557,9 @@ int32_t translate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMe
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = rewriteQuery(&cxt, pQuery);
|
code = rewriteQuery(&cxt, pQuery);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && pParseCxt->biMode != 0) {
|
|
||||||
code = rewriteQueryForBI(&cxt, pQuery);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = translateQuery(&cxt, pQuery->pRoot);
|
code = translateQuery(&cxt, pQuery->pRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code && (cxt.pPrevRoot || cxt.pPostRoot)) {
|
if (TSDB_CODE_SUCCESS == code && (cxt.pPrevRoot || cxt.pPostRoot)) {
|
||||||
pQuery->pPrevRoot = cxt.pPrevRoot;
|
pQuery->pPrevRoot = cxt.pPrevRoot;
|
||||||
pQuery->pPostRoot = cxt.pPostRoot;
|
pQuery->pPostRoot = cxt.pPostRoot;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1382,6 +1382,7 @@ void uvHandleUpdate(SSvrMsg* msg, SWorkThrd* thrd) {
|
||||||
tFreeSUpdateIpWhiteReq(req);
|
tFreeSUpdateIpWhiteReq(req);
|
||||||
taosMemoryFree(req);
|
taosMemoryFree(req);
|
||||||
} else {
|
} else {
|
||||||
|
tInfo("ip-white-list disable on trans");
|
||||||
thrd->enableIpWhiteList = 0;
|
thrd->enableIpWhiteList = 0;
|
||||||
}
|
}
|
||||||
taosMemoryFree(msg);
|
taosMemoryFree(msg);
|
||||||
|
|
|
@ -68,37 +68,34 @@ int32_t taosGetAppName(char* name, int32_t* len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsem_wait(tsem_t* sem) {
|
int32_t tsem_wait(tsem_t* sem) {
|
||||||
int ret = 0;
|
return WaitForSingleObject(*sem, INFINITE);
|
||||||
do {
|
|
||||||
ret = sem_wait(sem);
|
|
||||||
} while (ret != 0 && errno == EINTR);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsem_timewait(tsem_t* sem, int64_t ms) {
|
int32_t tsem_timewait(tsem_t* sem, int64_t timeout_ms) {
|
||||||
struct timespec ts;
|
DWORD result = WaitForSingleObject(*sem, timeout_ms);
|
||||||
taosClockGetTime(0, &ts);
|
if (result == WAIT_OBJECT_0) {
|
||||||
|
return 0; // Semaphore acquired
|
||||||
|
} else if (result == WAIT_TIMEOUT) {
|
||||||
|
return -1; // Timeout reached
|
||||||
|
} else {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ts.tv_nsec += ms * 1000000;
|
// Inter-process sharing is not currently supported. The pshared parameter is invalid.
|
||||||
ts.tv_sec += ts.tv_nsec / 1000000000;
|
int tsem_init(tsem_t* sem, int pshared, unsigned int value) {
|
||||||
ts.tv_nsec %= 1000000000;
|
*sem = CreateSemaphore(NULL, value, LONG_MAX, NULL);
|
||||||
int rc;
|
return (*sem != NULL) ? 0 : -1;
|
||||||
while ((rc = sem_timedwait(sem, &ts)) == -1 && errno == EINTR) continue;
|
}
|
||||||
return rc;
|
|
||||||
/* This should have timed out */
|
int tsem_post(tsem_t* sem) {
|
||||||
// ASSERT(errno == ETIMEDOUT);
|
if (ReleaseSemaphore(*sem, 1, NULL)) return 0;
|
||||||
// ASSERT(rc != 0);
|
return -1;
|
||||||
// GetSystemTimeAsFileTime(&ft_after);
|
}
|
||||||
// // We specified a non-zero wait. Time must advance.
|
|
||||||
// if (ft_before.dwLowDateTime == ft_after.dwLowDateTime && ft_before.dwHighDateTime == ft_after.dwHighDateTime)
|
int tsem_destroy(tsem_t* sem) {
|
||||||
// {
|
if (CloseHandle(*sem)) return 0;
|
||||||
// printf("nanoseconds: %d, rc: %d, code:0x%x. before filetime: %d, %d; after filetime: %d, %d\n",
|
return -1;
|
||||||
// nanosecs, rc, errno,
|
|
||||||
// (int)ft_before.dwLowDateTime, (int)ft_before.dwHighDateTime,
|
|
||||||
// (int)ft_after.dwLowDateTime, (int)ft_after.dwHighDateTime);
|
|
||||||
// printf("time must advance during sem_timedwait.");
|
|
||||||
// return 1;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
|
@ -133,8 +130,7 @@ int tsem_wait(tsem_t *psem) {
|
||||||
int tsem_timewait(tsem_t *psem, int64_t milis) {
|
int tsem_timewait(tsem_t *psem, int64_t milis) {
|
||||||
if (psem == NULL || *psem == NULL) return -1;
|
if (psem == NULL || *psem == NULL) return -1;
|
||||||
dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(milis * USEC_PER_SEC));
|
dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(milis * USEC_PER_SEC));
|
||||||
dispatch_semaphore_wait(*psem, time);
|
return dispatch_semaphore_wait(*psem, time);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosCheckPthreadValid(TdThread thread) { return thread != 0; }
|
bool taosCheckPthreadValid(TdThread thread) { return thread != 0; }
|
||||||
|
|
|
@ -78,3 +78,10 @@ add_test(
|
||||||
NAME osAtomicTests
|
NAME osAtomicTests
|
||||||
COMMAND osAtomicTests
|
COMMAND osAtomicTests
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_executable(osSemaphoreTests "osSemaphoreTests.cpp")
|
||||||
|
target_link_libraries(osSemaphoreTests os util gtest_main)
|
||||||
|
add_test(
|
||||||
|
NAME osSemaphoreTests
|
||||||
|
COMMAND osSemaphoreTests
|
||||||
|
)
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <xsren@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <thread>
|
||||||
|
#include "os.h"
|
||||||
|
#include "tlog.h"
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
|
#pragma GCC diagnostic ignored "-Wformat"
|
||||||
|
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
|
||||||
|
#pragma GCC diagnostic ignored "-Wpointer-arith"
|
||||||
|
|
||||||
|
TEST(osSemaphoreTests, InitAndDestroy) {
|
||||||
|
tsem_t sem;
|
||||||
|
int result = tsem_init(&sem, 0, 1);
|
||||||
|
EXPECT_EQ(result, 0);
|
||||||
|
|
||||||
|
result = tsem_destroy(&sem);
|
||||||
|
EXPECT_EQ(result, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(osSemaphoreTests, Destroy) {
|
||||||
|
tsem_t sem;
|
||||||
|
int result = tsem_init(&sem, 0, 1);
|
||||||
|
EXPECT_EQ(result, 0);
|
||||||
|
|
||||||
|
result = tsem_destroy(&sem);
|
||||||
|
EXPECT_EQ(result, 0);
|
||||||
|
// result = tsem_destroy(&sem);
|
||||||
|
// EXPECT_NE(result, 0); // result == 0 if on mac
|
||||||
|
}
|
||||||
|
|
||||||
|
// skip, tsem_wait can not stopped, will block test.
|
||||||
|
// TEST(osSemaphoreTests, Wait) {
|
||||||
|
// tsem_t sem;
|
||||||
|
// tsem_init(&sem, 0, 0);
|
||||||
|
// ASSERT_EQ(tsem_wait(&sem), -1);
|
||||||
|
// tsem_destroy(&sem);
|
||||||
|
// }
|
||||||
|
|
||||||
|
TEST(osSemaphoreTests, WaitTime0) {
|
||||||
|
tsem_t sem;
|
||||||
|
tsem_init(&sem, 0, 0);
|
||||||
|
EXPECT_NE(tsem_timewait(&sem, 1000), 0);
|
||||||
|
tsem_destroy(&sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(osSemaphoreTests, WaitTime1) {
|
||||||
|
tsem_t sem;
|
||||||
|
tsem_init(&sem, 0, 1);
|
||||||
|
EXPECT_EQ(tsem_timewait(&sem, 1000), 0);
|
||||||
|
EXPECT_NE(tsem_timewait(&sem, 1000), 0);
|
||||||
|
tsem_destroy(&sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST(osSemaphoreTests, WaitAndPost) {
|
||||||
|
tsem_t sem;
|
||||||
|
int result = tsem_init(&sem, 0, 0);
|
||||||
|
EXPECT_EQ(result, 0);
|
||||||
|
|
||||||
|
std::thread([&sem]() {
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
tsem_post(&sem);
|
||||||
|
}).detach();
|
||||||
|
|
||||||
|
result = tsem_wait(&sem);
|
||||||
|
EXPECT_EQ(result, 0);
|
||||||
|
|
||||||
|
result = tsem_destroy(&sem);
|
||||||
|
EXPECT_EQ(result, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST(osSemaphoreTests, TimedWait) {
|
||||||
|
tsem_t sem;
|
||||||
|
int result = tsem_init(&sem, 0, 0);
|
||||||
|
EXPECT_EQ(result, 0);
|
||||||
|
|
||||||
|
std::thread([&sem]() {
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
tsem_post(&sem);
|
||||||
|
}).detach();
|
||||||
|
|
||||||
|
result = tsem_timewait(&sem, 1000);
|
||||||
|
EXPECT_EQ(result, 0);
|
||||||
|
|
||||||
|
result = tsem_destroy(&sem);
|
||||||
|
EXPECT_EQ(result, 0);
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue