Merge branch '3.0' into case/TD-26408-3.0
This commit is contained in:
commit
be42143362
|
@ -83,6 +83,16 @@ ELSE ()
|
|||
SET(TAOS_LIB taos)
|
||||
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)
|
||||
MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
|
||||
SET(COMMON_FLAGS "/w /D_WIN32 /DWIN32 /Zi /MTd")
|
||||
|
|
|
@ -195,6 +195,20 @@ if (TD_LINUX)
|
|||
ELSE()
|
||||
set(TD_DEPS_DIR "x86")
|
||||
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()
|
||||
MESSAGE(STATUS "DEPS_DIR: " ${TD_DEPS_DIR})
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# curl
|
||||
ExternalProject_Add(curl
|
||||
URL https://curl.se/download/curl-8.2.1.tar.gz
|
||||
URL_HASH MD5=b25588a43556068be05e1624e0e74d41
|
||||
DOWNLOAD_NO_PROGRESS 1
|
||||
DOWNLOAD_DIR "${TD_CONTRIB_DIR}/deps-download"
|
||||
#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.
|
||||
|
||||
Tips:(c interface for example)
|
||||
1. 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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
8. Consumers can tmq_position 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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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.
|
||||
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.
|
||||
- A consumption group consumes all data under the same topic, and different consumption groups are independent of each other;
|
||||
- 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;
|
||||
- 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;
|
||||
- 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;
|
||||
- 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 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;
|
||||
- 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;
|
||||
- Consumers can call position interface to obtain the offset of the current consumption, seek to the specified offset, and consume again;
|
||||
- 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;
|
||||
- Position is to obtain the current consumption position, which is the position to be taken next time, not the current consumption position
|
||||
- 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)
|
||||
- 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
|
||||
- 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
|
||||
|
||||
|
|
|
@ -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.
|
||||
- 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.
|
||||
- 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.
|
||||
- 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.
|
||||
|
|
|
@ -731,16 +731,6 @@ The charset that takes effect is UTF-8.
|
|||
| Value Range | 0: not change; 1: change by modification |
|
||||
| Default Value | 0 |
|
||||
|
||||
### keepTimeOffset
|
||||
|
||||
| Attribute | Description |
|
||||
| ------------- | ------------------------- |
|
||||
| Applicable | Server Only |
|
||||
| Meaning | Latency of data migration |
|
||||
| Unit | hour |
|
||||
| Value Range | 0-23 |
|
||||
| Default Value | 0 |
|
||||
|
||||
### tmqMaxTopicNum
|
||||
|
||||
| Attribute | Description |
|
||||
|
@ -807,4 +797,4 @@ The charset that takes effect is UTF-8.
|
|||
| 53 | udf | Yes | Yes | |
|
||||
| 54 | enableCoreFile | Yes | 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的架构有一些了解,结合各个语言链接器的接口使用。
|
||||
- 一个消费组消费同一个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. 在服务端每个vgroup仅保存一个offset,每个vgroup的offset是单调递增的,但不一定连续。各个vgroup的offset之间没有关联;
|
||||
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 等广泛使用的消息队列类产品的行为相似;
|
||||
本文档不对消息队列本身的知识做更多的介绍,如果需要了解,请自行搜索。
|
||||
|
||||
从3.2.0.0版本开始,数据订阅支持vnode迁移和分裂。
|
||||
由于数据订阅依赖wal文件,而在vnode迁移和分裂的过程中,wal并不会同步过去,所以迁移或分裂后,之前没消费完的wal数据后消费不到。所以请保证之前把数据全部消费完后,再进行vnode迁移或分裂,否则,消费会丢失数据。
|
||||
|
||||
## 主要数据结构和 API
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ database_option: {
|
|||
- WAL_FSYNC_PERIOD:当 WAL 参数设置为 2 时,落盘的周期。默认为 3000,单位毫秒。最小为 0,表示每次写入立即落盘;最大为 180000,即三分钟。
|
||||
- MAXROWS:文件块中记录的最大条数,默认为 4096 条。
|
||||
- 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 内存。
|
||||
- PAGESIZE:一个 VNODE 中元数据存储引擎的页大小,单位为 KB,默认为 4 KB。范围为 1 到 16384,即 1 KB 到 16 MB。
|
||||
- PRECISION:数据库的时间戳精度。ms 表示毫秒,us 表示微秒,ns 表示纳秒,默认 ms 毫秒。
|
||||
|
|
|
@ -716,16 +716,6 @@ charset 的有效值是 UTF-8。
|
|||
| 取值范围 | 0: 不改变;1:改变 |
|
||||
| 缺省值 | 0 |
|
||||
|
||||
### keepTimeOffset
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | -------------- |
|
||||
| 适用范围 | 仅服务端适用 |
|
||||
| 含义 | 迁移操作的延时 |
|
||||
| 单位 | 小时 |
|
||||
| 取值范围 | 0-23 |
|
||||
| 缺省值 | 0 |
|
||||
|
||||
### tmqMaxTopicNum
|
||||
|
||||
| 属性 | 说明 |
|
||||
|
@ -803,7 +793,7 @@ charset 的有效值是 UTF-8。
|
|||
| 53 | udf | 是 | 是 | |
|
||||
| 54 | enableCoreFile | 是 | 是 | |
|
||||
| 55 | ttlChangeOnWrite | 否 | 是 | |
|
||||
| 56 | keepTimeOffset | 是 | 是 | |
|
||||
| 56 | keepTimeOffset | 否 | 是(从3.2.0.0开始,该配置废弃) | |
|
||||
|
||||
## 2.x->3.0 的废弃参数
|
||||
|
||||
|
|
|
@ -319,6 +319,7 @@ DLL_EXPORT int32_t tmq_offset_seek(tmq_t *tmq, const char *pTopicName, int32_t
|
|||
DLL_EXPORT int64_t tmq_position(tmq_t *tmq, const char *pTopicName, int32_t vgId); // The current offset is the offset of the last consumed message + 1
|
||||
DLL_EXPORT int64_t tmq_committed(tmq_t *tmq, const char *pTopicName, int32_t vgId);
|
||||
|
||||
DLL_EXPORT TAOS *tmq_get_connect(tmq_t *tmq);
|
||||
DLL_EXPORT const char *tmq_get_table_name(TAOS_RES *res);
|
||||
DLL_EXPORT tmq_res_t tmq_get_res_type(TAOS_RES *res);
|
||||
DLL_EXPORT const char *tmq_get_topic_name(TAOS_RES *res);
|
||||
|
|
|
@ -145,6 +145,7 @@ extern bool tsUseAdapter;
|
|||
extern int32_t tsMetaCacheMaxSize;
|
||||
extern int32_t tsSlowLogThreshold;
|
||||
extern int32_t tsSlowLogScope;
|
||||
extern int32_t tsTimeSeriesThreshold;
|
||||
|
||||
// client
|
||||
extern int32_t tsMinSlidingTime;
|
||||
|
@ -159,10 +160,11 @@ extern char buildinfo[];
|
|||
|
||||
// lossy
|
||||
extern char tsLossyColumns[];
|
||||
extern double tsFPrecision;
|
||||
extern float tsFPrecision;
|
||||
extern double tsDPrecision;
|
||||
extern uint32_t tsMaxRange;
|
||||
extern uint32_t tsCurRange;
|
||||
extern bool tsIfAdtFse;
|
||||
extern char tsCompressor[];
|
||||
|
||||
// tfs
|
||||
|
@ -206,7 +208,6 @@ extern int32_t tsRpcRetryInterval;
|
|||
extern bool tsDisableStream;
|
||||
extern int64_t tsStreamBufferSize;
|
||||
extern bool tsFilterScalarMode;
|
||||
extern int32_t tsKeepTimeOffset;
|
||||
extern int32_t tsMaxStreamBackendCache;
|
||||
extern int32_t tsPQSortMemThreshold;
|
||||
extern int32_t tsResolveFQDNRetryTime;
|
||||
|
|
|
@ -30,6 +30,8 @@ extern "C" {
|
|||
#define GRANTS_COL_MAX_LEN 196
|
||||
#endif
|
||||
|
||||
#define GRANT_HEART_BEAT_MIN 2
|
||||
|
||||
typedef enum {
|
||||
TSDB_GRANT_ALL,
|
||||
TSDB_GRANT_TIME,
|
||||
|
@ -49,6 +51,9 @@ typedef enum {
|
|||
} EGrantType;
|
||||
|
||||
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
|
||||
#ifdef TD_ENTERPRISE
|
||||
|
|
|
@ -1096,6 +1096,7 @@ typedef struct {
|
|||
int32_t daysToKeep0;
|
||||
int32_t daysToKeep1;
|
||||
int32_t daysToKeep2;
|
||||
int32_t keepTimeOffset;
|
||||
int32_t minRows;
|
||||
int32_t maxRows;
|
||||
int32_t walFsyncPeriod;
|
||||
|
@ -1133,6 +1134,7 @@ typedef struct {
|
|||
int32_t daysToKeep0;
|
||||
int32_t daysToKeep1;
|
||||
int32_t daysToKeep2;
|
||||
int32_t keepTimeOffset;
|
||||
int32_t walFsyncPeriod;
|
||||
int8_t walLevel;
|
||||
int8_t strict;
|
||||
|
@ -1239,6 +1241,7 @@ typedef struct {
|
|||
int32_t daysToKeep0;
|
||||
int32_t daysToKeep1;
|
||||
int32_t daysToKeep2;
|
||||
int32_t keepTimeOffset;
|
||||
int32_t minRows;
|
||||
int32_t maxRows;
|
||||
int32_t walFsyncPeriod;
|
||||
|
@ -1464,6 +1467,11 @@ typedef struct {
|
|||
int32_t learnerProgress; // use one reservered
|
||||
} SVnodeLoad;
|
||||
|
||||
typedef struct {
|
||||
int32_t vgId;
|
||||
int64_t nTimeSeries;
|
||||
} SVnodeLoadLite;
|
||||
|
||||
typedef struct {
|
||||
int8_t syncState;
|
||||
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);
|
||||
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 {
|
||||
int32_t dnodeId;
|
||||
int64_t clusterId;
|
||||
|
@ -1576,6 +1594,7 @@ typedef struct {
|
|||
int32_t daysToKeep0;
|
||||
int32_t daysToKeep1;
|
||||
int32_t daysToKeep2;
|
||||
int32_t keepTimeOffset;
|
||||
int32_t minRows;
|
||||
int32_t maxRows;
|
||||
int32_t walFsyncPeriod;
|
||||
|
@ -1655,6 +1674,7 @@ typedef struct {
|
|||
int32_t daysToKeep0;
|
||||
int32_t daysToKeep1;
|
||||
int32_t daysToKeep2;
|
||||
int32_t keepTimeOffset;
|
||||
int32_t walFsyncPeriod;
|
||||
int8_t walLevel;
|
||||
int8_t strict;
|
||||
|
@ -2028,6 +2048,7 @@ int32_t tDeserializeSRedistributeVgroupReq(void* buf, int32_t bufLen, SRedistrib
|
|||
|
||||
typedef struct {
|
||||
int32_t useless;
|
||||
int32_t vgId;
|
||||
} SBalanceVgroupLeaderReq;
|
||||
|
||||
int32_t tSerializeSBalanceVgroupLeaderReq(void* buf, int32_t bufLen, SBalanceVgroupLeaderReq* pReq);
|
||||
|
|
|
@ -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_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_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_RESTORE_DNODE, "restore-dnode", 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_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_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_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp)
|
||||
|
|
|
@ -115,250 +115,252 @@
|
|||
#define TK_STT_TRIGGER 96
|
||||
#define TK_TABLE_PREFIX 97
|
||||
#define TK_TABLE_SUFFIX 98
|
||||
#define TK_NK_COLON 99
|
||||
#define TK_BWLIMIT 100
|
||||
#define TK_START 101
|
||||
#define TK_TIMESTAMP 102
|
||||
#define TK_END 103
|
||||
#define TK_TABLE 104
|
||||
#define TK_NK_LP 105
|
||||
#define TK_NK_RP 106
|
||||
#define TK_STABLE 107
|
||||
#define TK_COLUMN 108
|
||||
#define TK_MODIFY 109
|
||||
#define TK_RENAME 110
|
||||
#define TK_TAG 111
|
||||
#define TK_SET 112
|
||||
#define TK_NK_EQ 113
|
||||
#define TK_USING 114
|
||||
#define TK_TAGS 115
|
||||
#define TK_BOOL 116
|
||||
#define TK_TINYINT 117
|
||||
#define TK_SMALLINT 118
|
||||
#define TK_INT 119
|
||||
#define TK_INTEGER 120
|
||||
#define TK_BIGINT 121
|
||||
#define TK_FLOAT 122
|
||||
#define TK_DOUBLE 123
|
||||
#define TK_BINARY 124
|
||||
#define TK_NCHAR 125
|
||||
#define TK_UNSIGNED 126
|
||||
#define TK_JSON 127
|
||||
#define TK_VARCHAR 128
|
||||
#define TK_MEDIUMBLOB 129
|
||||
#define TK_BLOB 130
|
||||
#define TK_VARBINARY 131
|
||||
#define TK_GEOMETRY 132
|
||||
#define TK_DECIMAL 133
|
||||
#define TK_COMMENT 134
|
||||
#define TK_MAX_DELAY 135
|
||||
#define TK_WATERMARK 136
|
||||
#define TK_ROLLUP 137
|
||||
#define TK_TTL 138
|
||||
#define TK_SMA 139
|
||||
#define TK_DELETE_MARK 140
|
||||
#define TK_FIRST 141
|
||||
#define TK_LAST 142
|
||||
#define TK_SHOW 143
|
||||
#define TK_PRIVILEGES 144
|
||||
#define TK_DATABASES 145
|
||||
#define TK_TABLES 146
|
||||
#define TK_STABLES 147
|
||||
#define TK_MNODES 148
|
||||
#define TK_QNODES 149
|
||||
#define TK_FUNCTIONS 150
|
||||
#define TK_INDEXES 151
|
||||
#define TK_ACCOUNTS 152
|
||||
#define TK_APPS 153
|
||||
#define TK_CONNECTIONS 154
|
||||
#define TK_LICENCES 155
|
||||
#define TK_GRANTS 156
|
||||
#define TK_QUERIES 157
|
||||
#define TK_SCORES 158
|
||||
#define TK_TOPICS 159
|
||||
#define TK_VARIABLES 160
|
||||
#define TK_CLUSTER 161
|
||||
#define TK_BNODES 162
|
||||
#define TK_SNODES 163
|
||||
#define TK_TRANSACTIONS 164
|
||||
#define TK_DISTRIBUTED 165
|
||||
#define TK_CONSUMERS 166
|
||||
#define TK_SUBSCRIPTIONS 167
|
||||
#define TK_VNODES 168
|
||||
#define TK_ALIVE 169
|
||||
#define TK_NORMAL 170
|
||||
#define TK_CHILD 171
|
||||
#define TK_LIKE 172
|
||||
#define TK_TBNAME 173
|
||||
#define TK_QTAGS 174
|
||||
#define TK_AS 175
|
||||
#define TK_SYSTEM 176
|
||||
#define TK_INDEX 177
|
||||
#define TK_FUNCTION 178
|
||||
#define TK_INTERVAL 179
|
||||
#define TK_COUNT 180
|
||||
#define TK_LAST_ROW 181
|
||||
#define TK_META 182
|
||||
#define TK_ONLY 183
|
||||
#define TK_TOPIC 184
|
||||
#define TK_CONSUMER 185
|
||||
#define TK_GROUP 186
|
||||
#define TK_DESC 187
|
||||
#define TK_DESCRIBE 188
|
||||
#define TK_RESET 189
|
||||
#define TK_QUERY 190
|
||||
#define TK_CACHE 191
|
||||
#define TK_EXPLAIN 192
|
||||
#define TK_ANALYZE 193
|
||||
#define TK_VERBOSE 194
|
||||
#define TK_NK_BOOL 195
|
||||
#define TK_RATIO 196
|
||||
#define TK_NK_FLOAT 197
|
||||
#define TK_OUTPUTTYPE 198
|
||||
#define TK_AGGREGATE 199
|
||||
#define TK_BUFSIZE 200
|
||||
#define TK_LANGUAGE 201
|
||||
#define TK_REPLACE 202
|
||||
#define TK_STREAM 203
|
||||
#define TK_INTO 204
|
||||
#define TK_PAUSE 205
|
||||
#define TK_RESUME 206
|
||||
#define TK_TRIGGER 207
|
||||
#define TK_AT_ONCE 208
|
||||
#define TK_WINDOW_CLOSE 209
|
||||
#define TK_IGNORE 210
|
||||
#define TK_EXPIRED 211
|
||||
#define TK_FILL_HISTORY 212
|
||||
#define TK_UPDATE 213
|
||||
#define TK_SUBTABLE 214
|
||||
#define TK_UNTREATED 215
|
||||
#define TK_KILL 216
|
||||
#define TK_CONNECTION 217
|
||||
#define TK_TRANSACTION 218
|
||||
#define TK_BALANCE 219
|
||||
#define TK_VGROUP 220
|
||||
#define TK_LEADER 221
|
||||
#define TK_MERGE 222
|
||||
#define TK_REDISTRIBUTE 223
|
||||
#define TK_SPLIT 224
|
||||
#define TK_DELETE 225
|
||||
#define TK_INSERT 226
|
||||
#define TK_NULL 227
|
||||
#define TK_NK_QUESTION 228
|
||||
#define TK_NK_ARROW 229
|
||||
#define TK_ROWTS 230
|
||||
#define TK_QSTART 231
|
||||
#define TK_QEND 232
|
||||
#define TK_QDURATION 233
|
||||
#define TK_WSTART 234
|
||||
#define TK_WEND 235
|
||||
#define TK_WDURATION 236
|
||||
#define TK_IROWTS 237
|
||||
#define TK_ISFILLED 238
|
||||
#define TK_CAST 239
|
||||
#define TK_NOW 240
|
||||
#define TK_TODAY 241
|
||||
#define TK_TIMEZONE 242
|
||||
#define TK_CLIENT_VERSION 243
|
||||
#define TK_SERVER_VERSION 244
|
||||
#define TK_SERVER_STATUS 245
|
||||
#define TK_CURRENT_USER 246
|
||||
#define TK_CASE 247
|
||||
#define TK_WHEN 248
|
||||
#define TK_THEN 249
|
||||
#define TK_ELSE 250
|
||||
#define TK_BETWEEN 251
|
||||
#define TK_IS 252
|
||||
#define TK_NK_LT 253
|
||||
#define TK_NK_GT 254
|
||||
#define TK_NK_LE 255
|
||||
#define TK_NK_GE 256
|
||||
#define TK_NK_NE 257
|
||||
#define TK_MATCH 258
|
||||
#define TK_NMATCH 259
|
||||
#define TK_CONTAINS 260
|
||||
#define TK_IN 261
|
||||
#define TK_JOIN 262
|
||||
#define TK_INNER 263
|
||||
#define TK_SELECT 264
|
||||
#define TK_NK_HINT 265
|
||||
#define TK_DISTINCT 266
|
||||
#define TK_WHERE 267
|
||||
#define TK_PARTITION 268
|
||||
#define TK_BY 269
|
||||
#define TK_SESSION 270
|
||||
#define TK_STATE_WINDOW 271
|
||||
#define TK_EVENT_WINDOW 272
|
||||
#define TK_SLIDING 273
|
||||
#define TK_FILL 274
|
||||
#define TK_VALUE 275
|
||||
#define TK_VALUE_F 276
|
||||
#define TK_NONE 277
|
||||
#define TK_PREV 278
|
||||
#define TK_NULL_F 279
|
||||
#define TK_LINEAR 280
|
||||
#define TK_NEXT 281
|
||||
#define TK_HAVING 282
|
||||
#define TK_RANGE 283
|
||||
#define TK_EVERY 284
|
||||
#define TK_ORDER 285
|
||||
#define TK_SLIMIT 286
|
||||
#define TK_SOFFSET 287
|
||||
#define TK_LIMIT 288
|
||||
#define TK_OFFSET 289
|
||||
#define TK_ASC 290
|
||||
#define TK_NULLS 291
|
||||
#define TK_ABORT 292
|
||||
#define TK_AFTER 293
|
||||
#define TK_ATTACH 294
|
||||
#define TK_BEFORE 295
|
||||
#define TK_BEGIN 296
|
||||
#define TK_BITAND 297
|
||||
#define TK_BITNOT 298
|
||||
#define TK_BITOR 299
|
||||
#define TK_BLOCKS 300
|
||||
#define TK_CHANGE 301
|
||||
#define TK_COMMA 302
|
||||
#define TK_CONCAT 303
|
||||
#define TK_CONFLICT 304
|
||||
#define TK_COPY 305
|
||||
#define TK_DEFERRED 306
|
||||
#define TK_DELIMITERS 307
|
||||
#define TK_DETACH 308
|
||||
#define TK_DIVIDE 309
|
||||
#define TK_DOT 310
|
||||
#define TK_EACH 311
|
||||
#define TK_FAIL 312
|
||||
#define TK_FILE 313
|
||||
#define TK_FOR 314
|
||||
#define TK_GLOB 315
|
||||
#define TK_ID 316
|
||||
#define TK_IMMEDIATE 317
|
||||
#define TK_IMPORT 318
|
||||
#define TK_INITIALLY 319
|
||||
#define TK_INSTEAD 320
|
||||
#define TK_ISNULL 321
|
||||
#define TK_KEY 322
|
||||
#define TK_MODULES 323
|
||||
#define TK_NK_BITNOT 324
|
||||
#define TK_NK_SEMI 325
|
||||
#define TK_NOTNULL 326
|
||||
#define TK_OF 327
|
||||
#define TK_PLUS 328
|
||||
#define TK_PRIVILEGE 329
|
||||
#define TK_RAISE 330
|
||||
#define TK_RESTRICT 331
|
||||
#define TK_ROW 332
|
||||
#define TK_SEMI 333
|
||||
#define TK_STAR 334
|
||||
#define TK_STATEMENT 335
|
||||
#define TK_STRICT 336
|
||||
#define TK_STRING 337
|
||||
#define TK_TIMES 338
|
||||
#define TK_VALUES 339
|
||||
#define TK_VARIABLE 340
|
||||
#define TK_VIEW 341
|
||||
#define TK_WAL 342
|
||||
#define TK_KEEP_TIME_OFFSET 99
|
||||
#define TK_NK_COLON 100
|
||||
#define TK_BWLIMIT 101
|
||||
#define TK_START 102
|
||||
#define TK_TIMESTAMP 103
|
||||
#define TK_END 104
|
||||
#define TK_TABLE 105
|
||||
#define TK_NK_LP 106
|
||||
#define TK_NK_RP 107
|
||||
#define TK_STABLE 108
|
||||
#define TK_COLUMN 109
|
||||
#define TK_MODIFY 110
|
||||
#define TK_RENAME 111
|
||||
#define TK_TAG 112
|
||||
#define TK_SET 113
|
||||
#define TK_NK_EQ 114
|
||||
#define TK_USING 115
|
||||
#define TK_TAGS 116
|
||||
#define TK_BOOL 117
|
||||
#define TK_TINYINT 118
|
||||
#define TK_SMALLINT 119
|
||||
#define TK_INT 120
|
||||
#define TK_INTEGER 121
|
||||
#define TK_BIGINT 122
|
||||
#define TK_FLOAT 123
|
||||
#define TK_DOUBLE 124
|
||||
#define TK_BINARY 125
|
||||
#define TK_NCHAR 126
|
||||
#define TK_UNSIGNED 127
|
||||
#define TK_JSON 128
|
||||
#define TK_VARCHAR 129
|
||||
#define TK_MEDIUMBLOB 130
|
||||
#define TK_BLOB 131
|
||||
#define TK_VARBINARY 132
|
||||
#define TK_GEOMETRY 133
|
||||
#define TK_DECIMAL 134
|
||||
#define TK_COMMENT 135
|
||||
#define TK_MAX_DELAY 136
|
||||
#define TK_WATERMARK 137
|
||||
#define TK_ROLLUP 138
|
||||
#define TK_TTL 139
|
||||
#define TK_SMA 140
|
||||
#define TK_DELETE_MARK 141
|
||||
#define TK_FIRST 142
|
||||
#define TK_LAST 143
|
||||
#define TK_SHOW 144
|
||||
#define TK_PRIVILEGES 145
|
||||
#define TK_DATABASES 146
|
||||
#define TK_TABLES 147
|
||||
#define TK_STABLES 148
|
||||
#define TK_MNODES 149
|
||||
#define TK_QNODES 150
|
||||
#define TK_FUNCTIONS 151
|
||||
#define TK_INDEXES 152
|
||||
#define TK_ACCOUNTS 153
|
||||
#define TK_APPS 154
|
||||
#define TK_CONNECTIONS 155
|
||||
#define TK_LICENCES 156
|
||||
#define TK_GRANTS 157
|
||||
#define TK_QUERIES 158
|
||||
#define TK_SCORES 159
|
||||
#define TK_TOPICS 160
|
||||
#define TK_VARIABLES 161
|
||||
#define TK_CLUSTER 162
|
||||
#define TK_BNODES 163
|
||||
#define TK_SNODES 164
|
||||
#define TK_TRANSACTIONS 165
|
||||
#define TK_DISTRIBUTED 166
|
||||
#define TK_CONSUMERS 167
|
||||
#define TK_SUBSCRIPTIONS 168
|
||||
#define TK_VNODES 169
|
||||
#define TK_ALIVE 170
|
||||
#define TK_NORMAL 171
|
||||
#define TK_CHILD 172
|
||||
#define TK_LIKE 173
|
||||
#define TK_TBNAME 174
|
||||
#define TK_QTAGS 175
|
||||
#define TK_AS 176
|
||||
#define TK_SYSTEM 177
|
||||
#define TK_INDEX 178
|
||||
#define TK_FUNCTION 179
|
||||
#define TK_INTERVAL 180
|
||||
#define TK_COUNT 181
|
||||
#define TK_LAST_ROW 182
|
||||
#define TK_META 183
|
||||
#define TK_ONLY 184
|
||||
#define TK_TOPIC 185
|
||||
#define TK_CONSUMER 186
|
||||
#define TK_GROUP 187
|
||||
#define TK_DESC 188
|
||||
#define TK_DESCRIBE 189
|
||||
#define TK_RESET 190
|
||||
#define TK_QUERY 191
|
||||
#define TK_CACHE 192
|
||||
#define TK_EXPLAIN 193
|
||||
#define TK_ANALYZE 194
|
||||
#define TK_VERBOSE 195
|
||||
#define TK_NK_BOOL 196
|
||||
#define TK_RATIO 197
|
||||
#define TK_NK_FLOAT 198
|
||||
#define TK_OUTPUTTYPE 199
|
||||
#define TK_AGGREGATE 200
|
||||
#define TK_BUFSIZE 201
|
||||
#define TK_LANGUAGE 202
|
||||
#define TK_REPLACE 203
|
||||
#define TK_STREAM 204
|
||||
#define TK_INTO 205
|
||||
#define TK_PAUSE 206
|
||||
#define TK_RESUME 207
|
||||
#define TK_TRIGGER 208
|
||||
#define TK_AT_ONCE 209
|
||||
#define TK_WINDOW_CLOSE 210
|
||||
#define TK_IGNORE 211
|
||||
#define TK_EXPIRED 212
|
||||
#define TK_FILL_HISTORY 213
|
||||
#define TK_UPDATE 214
|
||||
#define TK_SUBTABLE 215
|
||||
#define TK_UNTREATED 216
|
||||
#define TK_KILL 217
|
||||
#define TK_CONNECTION 218
|
||||
#define TK_TRANSACTION 219
|
||||
#define TK_BALANCE 220
|
||||
#define TK_VGROUP 221
|
||||
#define TK_LEADER 222
|
||||
#define TK_MERGE 223
|
||||
#define TK_REDISTRIBUTE 224
|
||||
#define TK_SPLIT 225
|
||||
#define TK_DELETE 226
|
||||
#define TK_INSERT 227
|
||||
#define TK_NULL 228
|
||||
#define TK_NK_QUESTION 229
|
||||
#define TK_NK_ARROW 230
|
||||
#define TK_ROWTS 231
|
||||
#define TK_QSTART 232
|
||||
#define TK_QEND 233
|
||||
#define TK_QDURATION 234
|
||||
#define TK_WSTART 235
|
||||
#define TK_WEND 236
|
||||
#define TK_WDURATION 237
|
||||
#define TK_IROWTS 238
|
||||
#define TK_ISFILLED 239
|
||||
#define TK_CAST 240
|
||||
#define TK_NOW 241
|
||||
#define TK_TODAY 242
|
||||
#define TK_TIMEZONE 243
|
||||
#define TK_CLIENT_VERSION 244
|
||||
#define TK_SERVER_VERSION 245
|
||||
#define TK_SERVER_STATUS 246
|
||||
#define TK_CURRENT_USER 247
|
||||
#define TK_CASE 248
|
||||
#define TK_WHEN 249
|
||||
#define TK_THEN 250
|
||||
#define TK_ELSE 251
|
||||
#define TK_BETWEEN 252
|
||||
#define TK_IS 253
|
||||
#define TK_NK_LT 254
|
||||
#define TK_NK_GT 255
|
||||
#define TK_NK_LE 256
|
||||
#define TK_NK_GE 257
|
||||
#define TK_NK_NE 258
|
||||
#define TK_MATCH 259
|
||||
#define TK_NMATCH 260
|
||||
#define TK_CONTAINS 261
|
||||
#define TK_IN 262
|
||||
#define TK_JOIN 263
|
||||
#define TK_INNER 264
|
||||
#define TK_SELECT 265
|
||||
#define TK_NK_HINT 266
|
||||
#define TK_DISTINCT 267
|
||||
#define TK_WHERE 268
|
||||
#define TK_PARTITION 269
|
||||
#define TK_BY 270
|
||||
#define TK_SESSION 271
|
||||
#define TK_STATE_WINDOW 272
|
||||
#define TK_EVENT_WINDOW 273
|
||||
#define TK_SLIDING 274
|
||||
#define TK_FILL 275
|
||||
#define TK_VALUE 276
|
||||
#define TK_VALUE_F 277
|
||||
#define TK_NONE 278
|
||||
#define TK_PREV 279
|
||||
#define TK_NULL_F 280
|
||||
#define TK_LINEAR 281
|
||||
#define TK_NEXT 282
|
||||
#define TK_HAVING 283
|
||||
#define TK_RANGE 284
|
||||
#define TK_EVERY 285
|
||||
#define TK_ORDER 286
|
||||
#define TK_SLIMIT 287
|
||||
#define TK_SOFFSET 288
|
||||
#define TK_LIMIT 289
|
||||
#define TK_OFFSET 290
|
||||
#define TK_ASC 291
|
||||
#define TK_NULLS 292
|
||||
#define TK_ABORT 293
|
||||
#define TK_AFTER 294
|
||||
#define TK_ATTACH 295
|
||||
#define TK_BEFORE 296
|
||||
#define TK_BEGIN 297
|
||||
#define TK_BITAND 298
|
||||
#define TK_BITNOT 299
|
||||
#define TK_BITOR 300
|
||||
#define TK_BLOCKS 301
|
||||
#define TK_CHANGE 302
|
||||
#define TK_COMMA 303
|
||||
#define TK_CONCAT 304
|
||||
#define TK_CONFLICT 305
|
||||
#define TK_COPY 306
|
||||
#define TK_DEFERRED 307
|
||||
#define TK_DELIMITERS 308
|
||||
#define TK_DETACH 309
|
||||
#define TK_DIVIDE 310
|
||||
#define TK_DOT 311
|
||||
#define TK_EACH 312
|
||||
#define TK_FAIL 313
|
||||
#define TK_FILE 314
|
||||
#define TK_FOR 315
|
||||
#define TK_GLOB 316
|
||||
#define TK_ID 317
|
||||
#define TK_IMMEDIATE 318
|
||||
#define TK_IMPORT 319
|
||||
#define TK_INITIALLY 320
|
||||
#define TK_INSTEAD 321
|
||||
#define TK_ISNULL 322
|
||||
#define TK_KEY 323
|
||||
#define TK_MODULES 324
|
||||
#define TK_NK_BITNOT 325
|
||||
#define TK_NK_SEMI 326
|
||||
#define TK_NOTNULL 327
|
||||
#define TK_OF 328
|
||||
#define TK_PLUS 329
|
||||
#define TK_PRIVILEGE 330
|
||||
#define TK_RAISE 331
|
||||
#define TK_RESTRICT 332
|
||||
#define TK_ROW 333
|
||||
#define TK_SEMI 334
|
||||
#define TK_STAR 335
|
||||
#define TK_STATEMENT 336
|
||||
#define TK_STRICT 337
|
||||
#define TK_STRING 338
|
||||
#define TK_TIMES 339
|
||||
#define TK_VALUES 340
|
||||
#define TK_VARIABLE 341
|
||||
#define TK_VIEW 342
|
||||
#define TK_WAL 343
|
||||
|
||||
|
||||
#define TK_NK_SPACE 600
|
||||
#define TK_NK_COMMENT 601
|
||||
|
|
|
@ -142,6 +142,7 @@ typedef struct SSnapContext {
|
|||
typedef struct {
|
||||
int64_t uid;
|
||||
int64_t ctbNum;
|
||||
int32_t colNum;
|
||||
} SMetaStbStats;
|
||||
|
||||
// void tqReaderSetColIdList(STqReader *pReader, SArray *pColIdList);
|
||||
|
@ -285,8 +286,8 @@ typedef struct SStoreMeta {
|
|||
|
||||
// db name, vgId, numOfTables, numOfSTables
|
||||
int32_t (*getNumOfChildTables)(
|
||||
void* pVnode, int64_t uid,
|
||||
int64_t* numOfTables); // int32_t metaGetStbStats(SMeta *pMeta, int64_t uid, SMetaStbStats *pInfo);
|
||||
void* pVnode, int64_t uid, int64_t* numOfTables,
|
||||
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,
|
||||
int64_t* numOfNormalTables); // vnodeGetInfo(void *pVnode, const char **dbname, int32_t *vgId) &
|
||||
// metaGetTbNum(SMeta *pMeta) & metaGetNtbNum(SMeta *pMeta);
|
||||
|
|
|
@ -191,7 +191,7 @@ typedef struct {
|
|||
} SMonBmInfo;
|
||||
|
||||
typedef struct {
|
||||
SArray *pVloads; // SVnodeLoad
|
||||
SArray *pVloads; // SVnodeLoad/SVnodeLoadLite
|
||||
} SMonVloadInfo;
|
||||
|
||||
typedef struct {
|
||||
|
@ -206,6 +206,11 @@ typedef struct {
|
|||
bool comp;
|
||||
} SMonCfg;
|
||||
|
||||
typedef struct {
|
||||
int8_t state;
|
||||
tsem_t sem;
|
||||
} SDmNotifyHandle;
|
||||
|
||||
int32_t monInit(const SMonCfg *pCfg);
|
||||
void monCleanup();
|
||||
void monRecordLog(int64_t ts, ELogLevel level, const char *content);
|
||||
|
|
|
@ -66,6 +66,7 @@ typedef struct SDatabaseOptions {
|
|||
int32_t minRowsPerBlock;
|
||||
SNodeList* pKeep;
|
||||
int64_t keep[3];
|
||||
int32_t keepTimeOffset;
|
||||
int32_t pages;
|
||||
int32_t pagesize;
|
||||
int32_t tsdbPageSize;
|
||||
|
|
|
@ -124,6 +124,7 @@ int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
|||
int32_t nodesListPushFront(SNodeList* pList, SNode* pNode);
|
||||
SListCell* nodesListErase(SNodeList* pList, SListCell* pCell);
|
||||
void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc);
|
||||
void nodesListInsertListAfterPos(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc);
|
||||
SNode* nodesListGetNode(SNodeList* pList, int32_t index);
|
||||
SListCell* nodesListGetCell(SNodeList* pList, int32_t index);
|
||||
void nodesDestroyList(SNodeList* pList);
|
||||
|
|
|
@ -536,6 +536,9 @@ int32_t nodesMergeConds(SNode** pDst, SNodeList** pSrc);
|
|||
const char* operatorTypeStr(EOperatorType type);
|
||||
const char* logicConditionTypeStr(ELogicConditionType type);
|
||||
|
||||
bool nodesIsStar(SNode* pNode);
|
||||
bool nodesIsTableStar(SNode* pNode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -64,7 +64,7 @@ typedef struct SParseContext {
|
|||
SArray* pTableMetaPos; // sql table pos => catalog data pos
|
||||
SArray* pTableVgroupPos; // sql table pos => catalog data pos
|
||||
int64_t allocatorId;
|
||||
int32_t biMode;
|
||||
int8_t biMode;
|
||||
} SParseContext;
|
||||
|
||||
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_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
|
||||
|
||||
#define tsem_t sem_t
|
||||
|
|
|
@ -46,7 +46,7 @@ typedef HANDLE TdThreadMutexAttr; // windows api
|
|||
typedef struct {
|
||||
SRWLOCK lock;
|
||||
int8_t excl;
|
||||
} TdThreadRwlock; // pthread api
|
||||
} TdThreadRwlock; // windows api
|
||||
typedef pthread_attr_t TdThreadAttr; // pthread api
|
||||
typedef pthread_once_t TdThreadOnce; // pthread 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_STABLE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080C)
|
||||
#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
|
||||
// #define TSDB_CODE_SYN_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0900) // 2.x
|
||||
|
|
|
@ -54,9 +54,16 @@ extern "C" {
|
|||
#ifdef TD_TSZ
|
||||
extern bool lossyFloat;
|
||||
extern bool lossyDouble;
|
||||
int32_t tsCompressInit();
|
||||
int32_t tsCompressInit(char* lossyColumns, float fPrecision, double dPrecision, uint32_t maxIntervals, uint32_t intervals,
|
||||
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,
|
||||
char *const output, int32_t outputSize, char algorithm,
|
||||
char *const buffer, int32_t bufferSize) {
|
||||
|
|
|
@ -43,6 +43,7 @@ typedef enum {
|
|||
CFG_DTYPE_INT32,
|
||||
CFG_DTYPE_INT64,
|
||||
CFG_DTYPE_FLOAT,
|
||||
CFG_DTYPE_DOUBLE,
|
||||
CFG_DTYPE_STRING,
|
||||
CFG_DTYPE_DIR,
|
||||
CFG_DTYPE_LOCALE,
|
||||
|
@ -64,6 +65,7 @@ typedef struct SConfigItem {
|
|||
union {
|
||||
bool bval;
|
||||
float fval;
|
||||
double dval;
|
||||
int32_t i32;
|
||||
int64_t i64;
|
||||
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 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 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 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);
|
||||
|
|
|
@ -322,6 +322,9 @@ typedef enum ELogicConditionType {
|
|||
#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_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_MAX_MINROWS_FBLOCK 1000000
|
||||
#define TSDB_DEFAULT_MINROWS_FBLOCK 100
|
||||
|
|
|
@ -108,9 +108,6 @@
|
|||
# time period of keeping log files, in days
|
||||
# logKeepDays 0
|
||||
|
||||
# unit Hour. Latency of data migration
|
||||
# keepTimeOffset 0
|
||||
|
||||
|
||||
############ 3. Debug Flag and levels #############################################
|
||||
|
||||
|
|
|
@ -33,14 +33,17 @@ adapterName="taosadapter"
|
|||
benchmarkName="taosBenchmark"
|
||||
dumpName="taosdump"
|
||||
demoName="taosdemo"
|
||||
xname="taosx"
|
||||
|
||||
clientName2="taos"
|
||||
serverName2="${clientName2}d"
|
||||
configFile2="${clientName2}.cfg"
|
||||
productName2="TDengine"
|
||||
emailName2="taosdata.com"
|
||||
xname2="${clientName2}x"
|
||||
adapterName2="${clientName2}adapter"
|
||||
|
||||
explorerName="${clientName2}-explorer"
|
||||
benchmarkName2="${clientName2}Benchmark"
|
||||
demoName2="${clientName2}demo"
|
||||
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 || :
|
||||
|
||||
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} || :
|
||||
fi
|
||||
}
|
||||
|
@ -693,9 +702,29 @@ function clean_service_on_systemd() {
|
|||
fi
|
||||
${csudo}systemctl disable tarbitratord &>/dev/null || echo &>/dev/null
|
||||
${csudo}rm -f ${tarbitratord_service_config}
|
||||
# if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
|
||||
# ${csudo}rm -f ${service_config_dir}/${serverName2}.service
|
||||
# fi
|
||||
|
||||
if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
|
||||
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() {
|
||||
|
|
|
@ -123,10 +123,11 @@ function clean_bin() {
|
|||
${csudo}rm -f ${bin_link_dir}/set_core || :
|
||||
${csudo}rm -f ${bin_link_dir}/TDinsight.sh || :
|
||||
${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
|
||||
${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}/${benchmarkName2} || :
|
||||
${csudo}rm -f ${bin_link_dir}/${dumpName2} || :
|
||||
|
@ -195,26 +196,28 @@ function clean_service_on_systemd() {
|
|||
fi
|
||||
${csudo}systemctl disable ${tarbitrator_service_name} &>/dev/null || echo &>/dev/null
|
||||
|
||||
# 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
|
||||
if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
|
||||
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
|
||||
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 clean_service_on_sysvinit() {
|
||||
|
|
|
@ -1411,7 +1411,7 @@ int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const ch
|
|||
code = smlBuildOutput(pQuery, pVgHash);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("smlBuildOutput failed");
|
||||
return code;
|
||||
goto end;
|
||||
}
|
||||
|
||||
launchQueryImpl(pRequest, pQuery, true, NULL);
|
||||
|
@ -1496,7 +1496,7 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname)
|
|||
code = smlBuildOutput(pQuery, pVgHash);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("smlBuildOutput failed");
|
||||
return code;
|
||||
goto end;
|
||||
}
|
||||
|
||||
launchQueryImpl(pRequest, pQuery, true, NULL);
|
||||
|
|
|
@ -1768,7 +1768,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
tscError("consumer:0x%" PRIx64 " msg from vgId:%d discarded, since %s", tmq->consumerId, pollRspWrapper->vgId, tstrerror(pRspWrapper->code));
|
||||
taosWLockLatch(&tmq->lock);
|
||||
SMqClientVg* pVg = getVgInfo(tmq, pollRspWrapper->topicName, pollRspWrapper->vgId);
|
||||
pVg->emptyBlockReceiveTs = taosGetTimestampMs();
|
||||
if(pVg) pVg->emptyBlockReceiveTs = taosGetTimestampMs();
|
||||
taosWUnLockLatch(&tmq->lock);
|
||||
}
|
||||
setVgIdle(tmq, pollRspWrapper->topicName, pollRspWrapper->vgId);
|
||||
|
@ -3106,3 +3106,10 @@ int32_t tmq_offset_seek(tmq_t* tmq, const char* pTopicName, int32_t vgId, int64_
|
|||
|
||||
return code;
|
||||
}
|
||||
|
||||
TAOS *tmq_get_connect(tmq_t *tmq){
|
||||
if (tmq && tmq->pTscObj) {
|
||||
return (TAOS *)(&(tmq->pTscObj->id));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -106,6 +106,7 @@ static const SSysDbTableSchema userDBSchema[] = {
|
|||
{.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 = "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[] = {
|
||||
|
|
|
@ -1557,12 +1557,14 @@ STSchema *tBuildTSchema(SSchema *aSchema, int32_t numOfCols, int32_t version) {
|
|||
|
||||
// SColData ========================================
|
||||
void tColDataDestroy(void *ph) {
|
||||
if (ph) {
|
||||
SColData *pColData = (SColData *)ph;
|
||||
|
||||
tFree(pColData->pBitMap);
|
||||
tFree(pColData->aOffset);
|
||||
tFree(pColData->pData);
|
||||
}
|
||||
}
|
||||
|
||||
void tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t smaOn) {
|
||||
pColData->cid = cid;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "tgrant.h"
|
||||
#include "tlog.h"
|
||||
#include "tmisce.h"
|
||||
#include "defines.h"
|
||||
|
||||
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
|
||||
#include "cus_name.h"
|
||||
|
@ -144,6 +145,7 @@ bool tsUseAdapter = false;
|
|||
int32_t tsMetaCacheMaxSize = -1; // MB
|
||||
int32_t tsSlowLogThreshold = 3; // seconds
|
||||
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,
|
||||
|
@ -211,14 +213,15 @@ int64_t tsTickPerMin[] = {60000L, 60000000L, 60000000000L};
|
|||
*/
|
||||
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
|
||||
// can close lossy compress.
|
||||
// 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
|
||||
uint32_t tsMaxRange = 500; // max range
|
||||
uint32_t tsCurRange = 100; // range
|
||||
uint32_t tsMaxRange = 500; // max quantization intervals
|
||||
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
|
||||
|
||||
// udf
|
||||
|
@ -253,7 +256,6 @@ char tsUdfdLdLibPath[512] = "";
|
|||
bool tsDisableStream = false;
|
||||
int64_t tsStreamBufferSize = 128 * 1024 * 1024;
|
||||
bool tsFilterScalarMode = false;
|
||||
int32_t tsKeepTimeOffset = 0; // latency of data migration
|
||||
int tsResolveFQDNRetryTime = 100; // seconds
|
||||
|
||||
char tsS3Endpoint[TSDB_FQDN_LEN] = "<endpoint>";
|
||||
|
@ -264,6 +266,9 @@ char tsS3BucketName[TSDB_FQDN_LEN] = "<bucketname>";
|
|||
char tsS3AppId[TSDB_FQDN_LEN] = "<appid>";
|
||||
int8_t tsS3Enabled = false;
|
||||
|
||||
int32_t tsS3BlockSize = 4096; // number of tsdb pages
|
||||
int32_t tsS3BlockCacheSize = 16; // number of blocks
|
||||
|
||||
int32_t tsCheckpointInterval = 20;
|
||||
|
||||
#ifndef _STORAGE
|
||||
|
@ -321,7 +326,9 @@ int32_t taosSetS3Cfg(SConfig *pCfg) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct SConfig *taosGetCfg() { return tsCfg; }
|
||||
struct SConfig *taosGetCfg() {
|
||||
return tsCfg;
|
||||
}
|
||||
|
||||
static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *inputCfgDir, const char *envFile,
|
||||
char *apolloUrl) {
|
||||
|
@ -630,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, "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, "timeseriesThreshold", tsTimeSeriesThreshold, 0, 2000, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
|
||||
if (cfgAddInt64(pCfg, "walFsyncDataSizeLimit", tsWalFsyncDataSizeLimit, 100 * 1024 * 1024, INT64_MAX,
|
||||
CFG_SCOPE_SERVER) != 0)
|
||||
|
@ -646,8 +654,15 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
if (cfgAddInt32(pCfg, "cacheLazyLoadThreshold", tsCacheLazyLoadThreshold, 0, 100000, CFG_SCOPE_SERVER) != 0)
|
||||
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 (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, "pqSortMemThreshold", tsPQSortMemThreshold, 1, 10240, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "resolveFQDNRetryTime", tsResolveFQDNRetryTime, 1, 10240, 0) != 0) return -1;
|
||||
|
@ -655,6 +670,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
if (cfgAddString(pCfg, "s3Accesskey", tsS3AccessKey, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddString(pCfg, "s3Endpoint", tsS3Endpoint, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddString(pCfg, "s3BucketName", tsS3BucketName, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "s3BlockSize", tsS3BlockSize, 2048, 1024 * 1024, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "s3BlockCacheSize", tsS3BlockCacheSize, 4, 1024 * 1024, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
|
||||
// min free disk space used to check if the disk is full [50MB, 1GB]
|
||||
if (cfgAddInt64(pCfg, "minDiskFreeSize", tsMinDiskFreeSize, TFS_MIN_DISK_FREE_SIZE, 1024 * 1024 * 1024,
|
||||
|
@ -1036,6 +1053,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
tsTrimVDbIntervalSec = cfgGetItem(pCfg, "trimVDbIntervalSec")->i32;
|
||||
tsUptimeInterval = cfgGetItem(pCfg, "uptimeInterval")->i32;
|
||||
tsQueryRsmaTolerance = cfgGetItem(pCfg, "queryRsmaTolerance")->i32;
|
||||
tsTimeSeriesThreshold = cfgGetItem(pCfg, "timeseriesThreshold")->i32;
|
||||
|
||||
tsWalFsyncDataSizeLimit = cfgGetItem(pCfg, "walFsyncDataSizeLimit")->i64;
|
||||
|
||||
|
@ -1060,16 +1078,27 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
|
||||
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;
|
||||
tsStreamBufferSize = cfgGetItem(pCfg, "streamBufferSize")->i64;
|
||||
|
||||
tsFilterScalarMode = cfgGetItem(pCfg, "filterScalarMode")->bval;
|
||||
tsKeepTimeOffset = cfgGetItem(pCfg, "keepTimeOffset")->i32;
|
||||
tsMaxStreamBackendCache = cfgGetItem(pCfg, "maxStreamBackendCache")->i32;
|
||||
tsPQSortMemThreshold = cfgGetItem(pCfg, "pqSortMemThreshold")->i32;
|
||||
tsResolveFQDNRetryTime = cfgGetItem(pCfg, "resolveFQDNRetryTime")->i32;
|
||||
tsMinDiskFreeSize = cfgGetItem(pCfg, "minDiskFreeSize")->i64;
|
||||
|
||||
tsS3BlockSize = cfgGetItem(pCfg, "s3BlockSize")->i32;
|
||||
tsS3BlockCacheSize = cfgGetItem(pCfg, "s3BlockCacheSize")->i32;
|
||||
|
||||
GRANT_CFG_GET;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1448,6 +1477,8 @@ int32_t taosApplyLocalCfg(SConfig *pCfg, char *name) {
|
|||
tqDebugFlag = cfgGetItem(pCfg, "tqDebugFlag")->i32;
|
||||
} else if (strcasecmp("ttlFlushThreshold", name) == 0) {
|
||||
tsTtlFlushThreshold = cfgGetItem(pCfg, "ttlFlushThreshold")->i32;
|
||||
} else if (strcasecmp("timeseriesThreshold", name) == 0) {
|
||||
tsTimeSeriesThreshold = cfgGetItem(pCfg, "timeseriesThreshold")->i32;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1643,10 +1674,17 @@ void taosCfgDynamicOptions(const char *option, const char *value) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (strcasecmp(option, "keepTimeOffset") == 0) {
|
||||
int32_t newKeepTimeOffset = atoi(value);
|
||||
uInfo("keepTimeOffset set from %d to %d", tsKeepTimeOffset, newKeepTimeOffset);
|
||||
tsKeepTimeOffset = newKeepTimeOffset;
|
||||
if (strcasecmp(option, "s3BlockSize") == 0) {
|
||||
int32_t newS3BlockSize = atoi(value);
|
||||
uInfo("s3BlockSize set from %d to %d", tsS3BlockSize, newS3BlockSize);
|
||||
tsS3BlockSize = newS3BlockSize;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcasecmp(option, "s3BlockCacheSize") == 0) {
|
||||
int32_t newS3BlockCacheSize = atoi(value);
|
||||
uInfo("s3BlockCacheSize set from %d to %d", tsS3BlockCacheSize, newS3BlockCacheSize);
|
||||
tsS3BlockCacheSize = newS3BlockCacheSize;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1035,6 +1035,68 @@ int32_t tDeserializeSMDropFullTextReq(void *buf, int32_t bufLen, SMDropFullTextR
|
|||
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) {
|
||||
SEncoder encoder = {0};
|
||||
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 (tEncodeI32(&encoder, pReq->tsdbPageSize) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->keepTimeOffset) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
||||
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;
|
||||
|
||||
pReq->keepTimeOffset = TSDB_DEFAULT_KEEP_TIME_OFFSET;
|
||||
if (!tDecodeIsEnd(&decoder)) {
|
||||
if (tDecodeI32(&decoder, &pReq->keepTimeOffset) < 0) return -1;
|
||||
}
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
|
@ -2731,6 +2799,7 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
|
|||
// 2nd modification
|
||||
if (tEncodeI32(&encoder, pReq->walRetentionPeriod) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->walRetentionSize) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->keepTimeOffset) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
|
@ -2774,6 +2843,10 @@ int32_t tDeserializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
|
|||
pReq->walRetentionPeriod = -1;
|
||||
pReq->walRetentionSize = -1;
|
||||
}
|
||||
pReq->keepTimeOffset = TSDB_DEFAULT_KEEP_TIME_OFFSET;
|
||||
if (!tDecodeIsEnd(&decoder)) {
|
||||
if (tDecodeI32(&decoder, &pReq->keepTimeOffset) < 0) return -1;
|
||||
}
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
|
@ -3400,6 +3473,7 @@ int32_t tDeserializeSVTrimDbReq(void *buf, int32_t bufLen, SVTrimDbReq *pReq) {
|
|||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->timestamp) < 0) return -1;
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
|
@ -3501,6 +3575,7 @@ int32_t tSerializeSDbCfgRspImpl(SEncoder *encoder, const SDbCfgRsp *pRsp) {
|
|||
}
|
||||
if (tEncodeI8(encoder, pRsp->schemaless) < 0) return -1;
|
||||
if (tEncodeI16(encoder, pRsp->sstTrigger) < 0) return -1;
|
||||
if (tEncodeI32(encoder, pRsp->keepTimeOffset) < 0) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -3569,6 +3644,10 @@ int32_t tDeserializeSDbCfgRspImpl(SDecoder *decoder, SDbCfgRsp *pRsp) {
|
|||
}
|
||||
if (tDecodeI8(decoder, &pRsp->schemaless) < 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;
|
||||
}
|
||||
|
@ -4618,6 +4697,7 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
|
|||
if (tEncodeSReplica(&encoder, pReplica) < 0) return -1;
|
||||
}
|
||||
if (tEncodeI32(&encoder, pReq->changeVersion) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->keepTimeOffset) < 0) return -1;
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
|
@ -4707,6 +4787,10 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
|
|||
if (!tDecodeIsEnd(&decoder)) {
|
||||
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);
|
||||
tDecoderClear(&decoder);
|
||||
|
@ -4866,6 +4950,7 @@ int32_t tSerializeSAlterVnodeConfigReq(void *buf, int32_t bufLen, SAlterVnodeCon
|
|||
// 2nd modification
|
||||
if (tEncodeI32(&encoder, pReq->walRetentionPeriod) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->walRetentionSize) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->keepTimeOffset) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
|
@ -4912,6 +4997,11 @@ int32_t tDeserializeSAlterVnodeConfigReq(void *buf, int32_t bufLen, SAlterVnodeC
|
|||
if (tDecodeI32(&decoder, &pReq->walRetentionPeriod) < 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);
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
|
@ -5150,6 +5240,7 @@ int32_t tSerializeSBalanceVgroupLeaderReq(void *buf, int32_t bufLen, SBalanceVgr
|
|||
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->useless) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->vgId) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
|
@ -5163,6 +5254,9 @@ int32_t tDeserializeSBalanceVgroupLeaderReq(void *buf, int32_t bufLen, SBalanceV
|
|||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->useless) < 0) return -1;
|
||||
if(!tDecodeIsEnd(&decoder)){
|
||||
if (tDecodeI32(&decoder, &pReq->vgId) < 0) return -1;
|
||||
}
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
|
|
|
@ -3,11 +3,22 @@ add_library(mgmt_dnode STATIC ${MGMT_DNODE})
|
|||
if (DEFINED GRANT_CFG_INCLUDE_DIR)
|
||||
add_definitions(-DGRANTS_CFG)
|
||||
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(
|
||||
mgmt_dnode
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
PUBLIC "${GRANT_CFG_INCLUDE_DIR}"
|
||||
)
|
||||
target_link_libraries(
|
||||
mgmt_dnode node_util
|
||||
mgmt_dnode node_util dmodule
|
||||
)
|
|
@ -28,6 +28,7 @@ typedef struct SDnodeMgmt {
|
|||
const char *path;
|
||||
const char *name;
|
||||
TdThread statusThread;
|
||||
TdThread notifyThread;
|
||||
TdThread monitorThread;
|
||||
TdThread crashReportThread;
|
||||
SSingleWorker mgmtWorker;
|
||||
|
@ -36,6 +37,7 @@ typedef struct SDnodeMgmt {
|
|||
ProcessDropNodeFp processDropNodeFp;
|
||||
SendMonitorReportFp sendMonitorReportFp;
|
||||
GetVnodeLoadsFp getVnodeLoadsFp;
|
||||
GetVnodeLoadsFp getVnodeLoadsLiteFp;
|
||||
GetMnodeLoadsFp getMnodeLoadsFp;
|
||||
GetQnodeLoadsFp getQnodeLoadsFp;
|
||||
int32_t statusSeq;
|
||||
|
@ -44,17 +46,21 @@ typedef struct SDnodeMgmt {
|
|||
// dmHandle.c
|
||||
SArray *dmGetMsgHandles();
|
||||
void dmSendStatusReq(SDnodeMgmt *pMgmt);
|
||||
void dmSendNotifyReq(SDnodeMgmt *pMgmt);
|
||||
int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t dmProcessAuthRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t dmProcessGrantRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t dmProcessServerRunStatus(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t dmProcessRetrieve(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t dmProcessGrantReq(void *pInfo, SRpcMsg *pMsg);
|
||||
int32_t dmProcessGrantNotify(void *pInfo, SRpcMsg *pMsg);
|
||||
|
||||
// dmWorker.c
|
||||
int32_t dmPutNodeMsgToMgmtQueue(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t dmStartStatusThread(SDnodeMgmt *pMgmt);
|
||||
void dmStopStatusThread(SDnodeMgmt *pMgmt);
|
||||
int32_t dmStartNotifyThread(SDnodeMgmt *pMgmt);
|
||||
void dmStopNotifyThread(SDnodeMgmt *pMgmt);
|
||||
int32_t dmStartMonitorThread(SDnodeMgmt *pMgmt);
|
||||
void dmStopMonitorThread(SDnodeMgmt *pMgmt);
|
||||
int32_t dmStartCrashReportThread(SDnodeMgmt *pMgmt);
|
||||
|
|
|
@ -170,6 +170,36 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
|||
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) {
|
||||
dError("auth rsp is received, but not supported yet");
|
||||
return 0;
|
||||
|
@ -395,6 +425,7 @@ SArray *dmGetMsgHandles() {
|
|||
|
||||
// Requests handled by MNODE
|
||||
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;
|
||||
|
||||
code = 0;
|
||||
|
|
|
@ -15,11 +15,17 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "dmInt.h"
|
||||
#include "libs/function/tudf.h"
|
||||
|
||||
static int32_t dmStartMgmt(SDnodeMgmt *pMgmt) {
|
||||
if (dmStartStatusThread(pMgmt) != 0) {
|
||||
return -1;
|
||||
}
|
||||
#if defined(TD_ENTERPRISE) && !defined(_TD_DARWIN_64)
|
||||
if (dmStartNotifyThread(pMgmt) != 0) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
if (dmStartMonitorThread(pMgmt) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -33,6 +39,7 @@ static void dmStopMgmt(SDnodeMgmt *pMgmt) {
|
|||
pMgmt->pData->stopped = true;
|
||||
dmStopMonitorThread(pMgmt);
|
||||
dmStopStatusThread(pMgmt);
|
||||
dmStopNotifyThread(pMgmt);
|
||||
dmStopCrashReportThread(pMgmt);
|
||||
}
|
||||
|
||||
|
@ -52,6 +59,7 @@ static int32_t dmOpenMgmt(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
|||
pMgmt->processDropNodeFp = pInput->processDropNodeFp;
|
||||
pMgmt->sendMonitorReportFp = pInput->sendMonitorReportFp;
|
||||
pMgmt->getVnodeLoadsFp = pInput->getVnodeLoadsFp;
|
||||
pMgmt->getVnodeLoadsLiteFp = pInput->getVnodeLoadsLiteFp;
|
||||
pMgmt->getMnodeLoadsFp = pInput->getMnodeLoadsFp;
|
||||
pMgmt->getQnodeLoadsFp = pInput->getQnodeLoadsFp;
|
||||
|
||||
|
|
|
@ -53,6 +53,31 @@ static void *dmStatusThreadFp(void *param) {
|
|||
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) {
|
||||
SDnodeMgmt *pMgmt = param;
|
||||
int64_t lastTime = taosGetTimestampMs();
|
||||
|
@ -132,7 +157,6 @@ static void *dmCrashReportThreadFp(void *param) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int32_t dmStartStatusThread(SDnodeMgmt *pMgmt) {
|
||||
TdThreadAttr 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) {
|
||||
TdThreadAttr thAttr;
|
||||
taosThreadAttrInit(&thAttr);
|
||||
|
@ -204,7 +251,6 @@ void dmStopCrashReportThread(SDnodeMgmt *pMgmt) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||
SDnodeMgmt *pMgmt = pInfo->ahandle;
|
||||
int32_t code = -1;
|
||||
|
@ -251,6 +297,9 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
case TDMT_MND_GRANT:
|
||||
code = dmProcessGrantReq(&pMgmt->pData->clusterId, pMsg);
|
||||
break;
|
||||
case TDMT_MND_GRANT_NOTIFY:
|
||||
code = dmProcessGrantNotify(NULL, pMsg);
|
||||
break;
|
||||
default:
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
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_HEARTBEAT, 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_AUTH, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SHOW_VARIABLES, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "qmInt.h"
|
||||
#include "libs/function/tudf.h"
|
||||
|
||||
static int32_t qmRequire(const SMgmtInputOpt *pInput, bool *required) {
|
||||
return dmReadFile(pInput->path, pInput->name, required);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "smInt.h"
|
||||
#include "libs/function/function.h"
|
||||
#include "libs/function/tudf.h"
|
||||
|
||||
static int32_t smRequire(const SMgmtInputOpt *pInput, bool *required) {
|
||||
return dmReadFile(pInput->path, pInput->name, required);
|
||||
|
|
|
@ -40,6 +40,28 @@ void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo, bool isReset) {
|
|||
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) {
|
||||
SMonVloadInfo vloads = {0};
|
||||
vmGetVnodeLoads(pMgmt, &vloads, true);
|
||||
|
@ -104,6 +126,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
|||
pCfg->tsdbCfg.keep0 = pCreate->daysToKeep0;
|
||||
pCfg->tsdbCfg.keep1 = pCreate->daysToKeep1;
|
||||
pCfg->tsdbCfg.keep2 = pCreate->daysToKeep2;
|
||||
pCfg->tsdbCfg.keepTimeOffset = pCreate->keepTimeOffset;
|
||||
pCfg->tsdbCfg.minRows = pCreate->minRows;
|
||||
pCfg->tsdbCfg.maxRows = pCreate->maxRows;
|
||||
for (size_t i = 0; i < taosArrayGetSize(pCreate->pRetensions); ++i) {
|
||||
|
@ -209,15 +232,15 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
dInfo(
|
||||
"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
|
||||
", 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
|
||||
", hash method:%d begin:%u end:%u prefix:%d surfix:%d replica:%d selfIndex:%d "
|
||||
"learnerReplica:%d learnerSelfIndex:%d strict:%d changeVersion:%d",
|
||||
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,
|
||||
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.walRetentionPeriod, req.walRetentionSize, req.walRollPeriod, req.walSegmentSize, req.hashMethod,
|
||||
req.keepTimeOffset, req.isTsma, req.precision, req.compression, req.minRows, req.maxRows, req.walFsyncPeriod,
|
||||
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.learnerSelfIndex, req.strict, req.changeVersion);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "vmInt.h"
|
||||
#include "tfs.h"
|
||||
#include "vnd.h"
|
||||
#include "libs/function/tudf.h"
|
||||
|
||||
int32_t vmAllocPrimaryDisk(SVnodeMgmt *pMgmt, int32_t vgId) {
|
||||
STfs *pTfs = pMgmt->pTfs;
|
||||
|
|
|
@ -95,6 +95,10 @@ void dmCleanupDnode(SDnode *pDnode);
|
|||
SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType nType);
|
||||
int32_t dmMarkWrapper(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);
|
||||
void dmSetStatus(SDnode *pDnode, EDndRunStatus stype);
|
||||
void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg);
|
||||
|
@ -119,6 +123,7 @@ int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
|||
// dmMonitor.c
|
||||
void dmSendMonitorReport();
|
||||
void dmGetVnodeLoads(SMonVloadInfo *pInfo);
|
||||
void dmGetVnodeLoadsLite(SMonVloadInfo *pInfo);
|
||||
void dmGetMnodeLoads(SMonMloadInfo *pInfo);
|
||||
void dmGetQnodeLoads(SQnodeLoad *pInfo);
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ void smGetMonitorInfo(void *pMgmt, SMonSmInfo *pInfo);
|
|||
void bmGetMonitorInfo(void *pMgmt, SMonBmInfo *pInfo);
|
||||
|
||||
void vmGetVnodeLoads(void *pMgmt, SMonVloadInfo *pInfo, bool isReset);
|
||||
void vmGetVnodeLoadsLite(void *pMgmt, SMonVloadInfo *pInfo);
|
||||
void mmGetMnodeLoads(void *pMgmt, SMonMloadInfo *pInfo);
|
||||
void qmGetQnodeLoads(void *pMgmt, SQnodeLoad *pInfo);
|
||||
|
||||
|
|
|
@ -16,24 +16,7 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "dmMgmt.h"
|
||||
#include "audit.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)
|
||||
#include "libs/function/tudf.h"
|
||||
|
||||
#define DM_INIT_AUDIT() \
|
||||
do { \
|
||||
|
@ -45,15 +28,7 @@
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define DM_ERR_RTN(c) \
|
||||
do { \
|
||||
code = (c); \
|
||||
goto _exit; \
|
||||
} while (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; }
|
||||
|
||||
|
@ -76,30 +51,14 @@ static int32_t dmInitSystem() {
|
|||
static int32_t dmInitMonitor() {
|
||||
int32_t code = 0;
|
||||
SMonCfg monCfg = {0};
|
||||
char reName[64] = {0};
|
||||
char stName[64] = {0};
|
||||
char ver[64] = {0};
|
||||
|
||||
DM_INIT_MON();
|
||||
|
||||
if (STR_STR_CMP(stName, STR_STR_SIGN)) {
|
||||
DM_ERR_RTN(0);
|
||||
}
|
||||
if (taosGetOsReleaseName(reName, stName, ver, 64) != 0) {
|
||||
DM_ERR_RTN(code);
|
||||
}
|
||||
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);
|
||||
monCfg.maxLogs = tsMonitorMaxLogs;
|
||||
monCfg.port = tsMonitorPort;
|
||||
monCfg.server = tsMonitorFqdn;
|
||||
monCfg.comp = tsMonitorComp;
|
||||
if (monInit(&monCfg) != 0) {
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
@ -419,6 +378,7 @@ SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper) {
|
|||
.processDropNodeFp = dmProcessDropNodeReq,
|
||||
.sendMonitorReportFp = dmSendMonitorReport,
|
||||
.getVnodeLoadsFp = dmGetVnodeLoads,
|
||||
.getVnodeLoadsLiteFp = dmGetVnodeLoadsLite,
|
||||
.getMnodeLoadsFp = dmGetMnodeLoads,
|
||||
.getQnodeLoadsFp = dmGetQnodeLoads,
|
||||
};
|
||||
|
|
|
@ -19,88 +19,10 @@
|
|||
#include "index.h"
|
||||
#include "qworker.h"
|
||||
#include "tstream.h"
|
||||
|
||||
static bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper) {
|
||||
SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper);
|
||||
|
||||
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));
|
||||
}
|
||||
#ifdef TD_TSZ
|
||||
#include "tglobal.h"
|
||||
#include "tcompression.h"
|
||||
#endif
|
||||
|
||||
int32_t dmInitDnode(SDnode *pDnode) {
|
||||
dDebug("start to create dnode");
|
||||
|
@ -111,6 +33,11 @@ int32_t dmInitDnode(SDnode *pDnode) {
|
|||
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[MNODE].func = mmGetMgmtFunc();
|
||||
pDnode->wrappers[VNODE].func = vmGetMgmtFunc();
|
||||
|
@ -134,22 +61,12 @@ int32_t dmInitDnode(SDnode *pDnode) {
|
|||
pWrapper->required = dmRequireNode(pDnode, pWrapper);
|
||||
}
|
||||
|
||||
if (dmInitMsgHandle(pDnode) != 0) {
|
||||
dError("failed to init msg handles since %s", terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
pDnode->lockfile = dmCheckRunning(tsDataDir);
|
||||
if (pDnode->lockfile == NULL) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (dmInitServer(pDnode) != 0) {
|
||||
dError("failed to init transport since %s", terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (dmInitClient(pDnode) != 0) {
|
||||
if(dmInitModule(pDnode) != 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -180,6 +97,12 @@ void dmCleanupDnode(SDnode *pDnode) {
|
|||
streamMetaCleanup();
|
||||
indexCleanup();
|
||||
taosConvDestroy();
|
||||
|
||||
#ifdef TD_TSZ
|
||||
// compress destroy
|
||||
tsCompressExit();
|
||||
#endif
|
||||
|
||||
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) {
|
||||
SDnode *pDnode = dmInstance();
|
||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[MNODE];
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include "tfs.h"
|
||||
#include "wal.h"
|
||||
|
||||
#include "libs/function/tudf.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -94,6 +93,7 @@ typedef int32_t (*ProcessAlterNodeTypeFp)(EDndNodeType ntype, SRpcMsg *pMsg);
|
|||
|
||||
typedef struct {
|
||||
int32_t dnodeId;
|
||||
int32_t engineVer;
|
||||
int64_t clusterId;
|
||||
int64_t dnodeVer;
|
||||
int64_t updateTime;
|
||||
|
@ -121,6 +121,7 @@ typedef struct {
|
|||
ProcessDropNodeFp processDropNodeFp;
|
||||
SendMonitorReportFp sendMonitorReportFp;
|
||||
GetVnodeLoadsFp getVnodeLoadsFp;
|
||||
GetVnodeLoadsFp getVnodeLoadsLiteFp;
|
||||
GetMnodeLoadsFp getMnodeLoadsFp;
|
||||
GetQnodeLoadsFp getQnodeLoadsFp;
|
||||
} 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);
|
||||
TdFilePtr dmCheckRunning(const char *dataDir);
|
||||
|
||||
// dmodule.c
|
||||
int32_t dmInitDndInfo(SDnodeData *pData);
|
||||
|
||||
// dmEps.c
|
||||
int32_t dmReadEps(SDnodeData *pData);
|
||||
int32_t dmWriteEps(SDnodeData *pData);
|
||||
|
|
|
@ -57,6 +57,8 @@ static int32_t dmDecodeEps(SJson *pJson, SDnodeData *pData) {
|
|||
if (code < 0) return -1;
|
||||
tjsonGetNumberValue(pJson, "dnodeVer", pData->dnodeVer, code);
|
||||
if (code < 0) return -1;
|
||||
tjsonGetNumberValue(pJson, "engineVer", pData->engineVer, code);
|
||||
if (code < 0) return -1;
|
||||
tjsonGetNumberValue(pJson, "clusterId", pData->clusterId, code);
|
||||
if (code < 0) return -1;
|
||||
tjsonGetInt32ValueFromDouble(pJson, "dropped", pData->dropped, code);
|
||||
|
@ -96,7 +98,8 @@ int32_t dmReadEps(SDnodeData *pData) {
|
|||
|
||||
pData->dnodeEps = taosArrayInit(1, sizeof(SDnodeEp));
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -184,6 +187,7 @@ _OVER:
|
|||
static int32_t dmEncodeEps(SJson *pJson, SDnodeData *pData) {
|
||||
if (tjsonAddDoubleToObject(pJson, "dnodeId", pData->dnodeId) < 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 (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);
|
||||
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
||||
if((code == dmInitDndInfo(pData)) != 0) goto _OVER;
|
||||
pJson = tjsonCreateObject();
|
||||
if (pJson == NULL) goto _OVER;
|
||||
pData->engineVer = tsVersion;
|
||||
if (dmEncodeEps(pJson, pData) != 0) goto _OVER;
|
||||
buffer = tjsonToString(pJson);
|
||||
if (buffer == NULL) goto _OVER;
|
||||
|
|
|
@ -312,6 +312,7 @@ typedef struct {
|
|||
int32_t daysToKeep0;
|
||||
int32_t daysToKeep1;
|
||||
int32_t daysToKeep2;
|
||||
int32_t keepTimeOffset;
|
||||
int32_t minRows;
|
||||
int32_t maxRows;
|
||||
int32_t walFsyncPeriod;
|
||||
|
|
|
@ -32,11 +32,11 @@ void mndReleaseSubscribe(SMnode *pMnode, SMqSubscribeObj *pSub);
|
|||
|
||||
int32_t mndMakeSubscribeKey(char *key, const char *cgroup, const char *topicName);
|
||||
|
||||
static FORCE_INLINE int32_t mndMakePartitionKey(char *key, const char *cgroup, const char *topicName, int32_t vgId) {
|
||||
return snprintf(key, TSDB_PARTITION_KEY_LEN, "%d:%s:%s", vgId, cgroup, topicName);
|
||||
}
|
||||
//static FORCE_INLINE int32_t mndMakePartitionKey(char *key, const char *cgroup, const char *topicName, int32_t vgId) {
|
||||
// return snprintf(key, TSDB_PARTITION_KEY_LEN, "%d:%s:%s", vgId, cgroup, topicName);
|
||||
//}
|
||||
|
||||
int32_t mndDropSubByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb);
|
||||
//int32_t mndDropSubByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb);
|
||||
int32_t mndDropSubByTopic(SMnode *pMnode, STrans *pTrans, const char *topic);
|
||||
int32_t mndSetDropSubCommitLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeObj *pSub);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ void mndUserFreeObj(SUserObj *pUser);
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
@ -311,6 +311,34 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) {
|
|||
taosArrayPush(pRebSub->removedConsumers, &pConsumer->consumerId);
|
||||
}
|
||||
taosRUnLockLatch(&pConsumer->lock);
|
||||
}else{
|
||||
int32_t newTopicNum = taosArrayGetSize(pConsumer->currentTopics);
|
||||
for (int32_t i = 0; i < newTopicNum; i++) {
|
||||
char * topic = taosArrayGetP(pConsumer->currentTopics, i);
|
||||
SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, pConsumer->cgroup, topic);
|
||||
if (pSub == NULL) {
|
||||
continue;
|
||||
}
|
||||
taosRLockLatch(&pSub->lock);
|
||||
|
||||
// 2.2 iterate all vg assigned to the consumer of that topic
|
||||
SMqConsumerEp *pConsumerEp = taosHashGet(pSub->consumerHash, &pConsumer->consumerId, sizeof(int64_t));
|
||||
int32_t vgNum = taosArrayGetSize(pConsumerEp->vgs);
|
||||
|
||||
for (int32_t j = 0; j < vgNum; j++) {
|
||||
SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, j);
|
||||
SVgObj * pVgroup = mndAcquireVgroup(pMnode, pVgEp->vgId);
|
||||
if (!pVgroup) {
|
||||
char key[TSDB_SUBSCRIBE_KEY_LEN];
|
||||
mndMakeSubscribeKey(key, pConsumer->cgroup, topic);
|
||||
mndGetOrCreateRebSub(pRebMsg->rebSubHash, key);
|
||||
mInfo("vnode splitted, vgId:%d rebalance will be triggered", pVgEp->vgId);
|
||||
}
|
||||
mndReleaseVgroup(pMnode, pVgroup);
|
||||
}
|
||||
taosRUnLockLatch(&pSub->lock);
|
||||
mndReleaseSubscribe(pMnode, pSub);
|
||||
}
|
||||
}
|
||||
} else if (status == MQ_CONSUMER_STATUS_LOST) {
|
||||
if (hbStatus > MND_CONSUMER_LOST_CLEAR_THRESHOLD) { // clear consumer if lost a day
|
||||
|
@ -548,8 +576,8 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) {
|
|||
|
||||
for (int32_t j = 0; j < vgNum; j++) {
|
||||
SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, j);
|
||||
char offsetKey[TSDB_PARTITION_KEY_LEN];
|
||||
mndMakePartitionKey(offsetKey, pConsumer->cgroup, topic, pVgEp->vgId);
|
||||
// char offsetKey[TSDB_PARTITION_KEY_LEN];
|
||||
// mndMakePartitionKey(offsetKey, pConsumer->cgroup, topic, pVgEp->vgId);
|
||||
|
||||
if(epoch == -1){
|
||||
SVgObj *pVgroup = mndAcquireVgroup(pMnode, pVgEp->vgId);
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "audit.h"
|
||||
|
||||
#define DB_VER_NUMBER 1
|
||||
#define DB_RESERVE_SIZE 46
|
||||
#define DB_RESERVE_SIZE 42
|
||||
|
||||
static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw);
|
||||
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_INT32(pRaw, dataPos, pDb->cfg.tsdbPageSize, _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_DATALEN(pRaw, dataPos, _OVER)
|
||||
|
@ -227,6 +228,7 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_INT16(pRaw, dataPos, &pDb->cfg.hashSuffix, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.tsdbPageSize, _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)
|
||||
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.daysToKeep1 = pNew->cfg.daysToKeep1;
|
||||
pOld->cfg.daysToKeep2 = pNew->cfg.daysToKeep2;
|
||||
pOld->cfg.keepTimeOffset = pNew->cfg.keepTimeOffset;
|
||||
pOld->cfg.walFsyncPeriod = pNew->cfg.walFsyncPeriod;
|
||||
pOld->cfg.walLevel = pNew->cfg.walLevel;
|
||||
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->daysToKeep1) 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->maxRows < TSDB_MIN_MAXROWS_FBLOCK || pCfg->maxRows > TSDB_MAX_MAXROWS_FBLOCK) 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->daysToKeep1) 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->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;
|
||||
|
@ -445,6 +450,7 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
|
|||
if (pCfg->daysToKeep0 < 0) pCfg->daysToKeep0 = TSDB_DEFAULT_KEEP;
|
||||
if (pCfg->daysToKeep1 < 0) pCfg->daysToKeep1 = pCfg->daysToKeep0;
|
||||
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->maxRows < 0) pCfg->maxRows = TSDB_DEFAULT_MAXROWS_FBLOCK;
|
||||
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,
|
||||
.daysToKeep1 = pCreate->daysToKeep1,
|
||||
.daysToKeep2 = pCreate->daysToKeep2,
|
||||
.keepTimeOffset = pCreate->keepTimeOffset,
|
||||
.minRows = pCreate->minRows,
|
||||
.maxRows = pCreate->maxRows,
|
||||
.walFsyncPeriod = pCreate->walFsyncPeriod,
|
||||
|
@ -763,6 +770,7 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
|
|||
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep0:%d", createReq.daysToKeep0);
|
||||
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep1:%d", createReq.daysToKeep1);
|
||||
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep2:%d", createReq.daysToKeep2);
|
||||
mndBuildAuditDetailInt32(detail, tmp, "keepTimeOffset:%d", createReq.keepTimeOffset);
|
||||
mndBuildAuditDetailInt32(detail, tmp, "hashPrefix:%d", createReq.hashPrefix);
|
||||
mndBuildAuditDetailInt32(detail, tmp, "hashSuffix:%d", createReq.hashSuffix);
|
||||
mndBuildAuditDetailInt32(detail, tmp, "ignoreExist:%d", createReq.ignoreExist);
|
||||
|
@ -841,6 +849,11 @@ static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) {
|
|||
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) {
|
||||
pDb->cfg.walFsyncPeriod = pAlter->walFsyncPeriod;
|
||||
terrno = 0;
|
||||
|
@ -1046,6 +1059,7 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
|
|||
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep0:%d", alterReq.daysToKeep0);
|
||||
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep1:%d", alterReq.daysToKeep1);
|
||||
mndBuildAuditDetailInt32(detail, tmp, "daysToKeep2:%d", alterReq.daysToKeep2);
|
||||
mndBuildAuditDetailInt32(detail, tmp, "keepTimeOffset:%d", alterReq.keepTimeOffset);
|
||||
mndBuildAuditDetailInt32(detail, tmp, "minRows:%d", alterReq.minRows);
|
||||
mndBuildAuditDetailInt32(detail, tmp, "pages:%d", alterReq.pages);
|
||||
mndBuildAuditDetailInt32(detail, tmp, "pageSize:%d", alterReq.pageSize);
|
||||
|
@ -1087,6 +1101,7 @@ static void mndDumpDbCfgInfo(SDbCfgRsp *cfgRsp, SDbObj *pDb) {
|
|||
cfgRsp->daysToKeep0 = pDb->cfg.daysToKeep0;
|
||||
cfgRsp->daysToKeep1 = pDb->cfg.daysToKeep1;
|
||||
cfgRsp->daysToKeep2 = pDb->cfg.daysToKeep2;
|
||||
cfgRsp->keepTimeOffset = pDb->cfg.keepTimeOffset;
|
||||
cfgRsp->minRows = pDb->cfg.minRows;
|
||||
cfgRsp->maxRows = pDb->cfg.maxRows;
|
||||
cfgRsp->walFsyncPeriod = pDb->cfg.walFsyncPeriod;
|
||||
|
@ -2013,6 +2028,9 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
|||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
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);
|
||||
|
|
|
@ -71,6 +71,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq);
|
|||
static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq);
|
||||
static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp);
|
||||
static int32_t mndProcessStatusReq(SRpcMsg *pReq);
|
||||
static int32_t mndProcessNotifyReq(SRpcMsg *pReq);
|
||||
static int32_t mndProcessRestoreDnodeReq(SRpcMsg *pReq);
|
||||
|
||||
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);
|
||||
|
||||
#ifdef _GRANT
|
||||
int32_t mndUpdClusterInfo(SRpcMsg *pReq);
|
||||
#else
|
||||
static int32_t mndUpdClusterInfo(SRpcMsg *pReq) { return 0; }
|
||||
#endif
|
||||
|
||||
int32_t mndInitDnode(SMnode *pMnode) {
|
||||
SSdbTable table = {
|
||||
.sdbType = SDB_DNODE,
|
||||
|
@ -97,6 +104,7 @@ int32_t mndInitDnode(SMnode *pMnode) {
|
|||
mndSetMsgHandle(pMnode, TDMT_MND_CONFIG_DNODE, mndProcessConfigDnodeReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_DND_CONFIG_DNODE_RSP, mndProcessConfigDnodeRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_STATUS, mndProcessStatusReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_NOTIFY, mndProcessNotifyReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_DNODE_LIST, mndProcessDnodeListReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_SHOW_VARIABLES, mndProcessShowVariablesReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_RESTORE_DNODE, mndProcessRestoreDnodeReq);
|
||||
|
@ -139,7 +147,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
|
|||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
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:
|
||||
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,
|
||||
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) {
|
||||
SVnodeLoad *pVload = taosArrayGet(statusReq.pVloads, v);
|
||||
|
||||
|
@ -676,6 +688,41 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
_OVER:
|
||||
mndReleaseDnode(pMnode, pDnode);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -705,7 +752,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC
|
|||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
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:
|
||||
mndTransDrop(pTrans);
|
||||
sdbFreeRaw(pRaw);
|
||||
|
@ -716,7 +763,9 @@ static int32_t mndConfigDnode(SMnode *pMnode, SRpcMsg *pReq, SMCfgDnodeReq *pCfg
|
|||
SSdbRaw *pRaw = NULL;
|
||||
STrans *pTrans = NULL;
|
||||
SDnodeObj *pDnode = NULL;
|
||||
SArray *failRecord = NULL;
|
||||
bool cfgAll = pCfgReq->dnodeId == -1;
|
||||
int32_t cfgAllErr = 0;
|
||||
int32_t iter = 0;
|
||||
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
@ -730,28 +779,64 @@ static int32_t mndConfigDnode(SMnode *pMnode, SRpcMsg *pReq, SMCfgDnodeReq *pCfg
|
|||
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) {
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "config-dnode");
|
||||
if (!pTrans) 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);
|
||||
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
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);
|
||||
|
||||
if (cfgAll) {
|
||||
|
@ -769,12 +854,19 @@ static int32_t mndConfigDnode(SMnode *pMnode, SRpcMsg *pReq, SMCfgDnodeReq *pCfg
|
|||
_OVER:
|
||||
if (cfgAll) {
|
||||
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 {
|
||||
mndReleaseDnode(pMnode, pDnode);
|
||||
}
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
mndTransDrop(pTrans);
|
||||
sdbFreeRaw(pRaw);
|
||||
taosArrayDestroy(failRecord);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
|
@ -998,7 +1090,7 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
|
|||
|
||||
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;
|
||||
|
||||
_OVER:
|
||||
|
@ -1144,20 +1236,6 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
|||
|
||||
strcpy(dcfgReq.config, "monitor");
|
||||
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) {
|
||||
int32_t optLen = strlen("ttlpushinterval");
|
||||
int32_t flag = -1;
|
||||
|
@ -1229,7 +1307,8 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
|||
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%s", cfgReq.value);
|
||||
|
||||
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 0;
|
||||
|
|
|
@ -130,6 +130,8 @@ void grantReset(SMnode *pMnode, EGrantType grant, uint64_t value) {}
|
|||
void grantAdd(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 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
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ int32_t mndSetUserAuthRsp(SMnode *pMnode, SUserObj *pUser, SGetUserAuthRsp *pRsp
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndEnableIpWhiteList(SMnode *pMnode) { return 1; }
|
||||
int32_t mndEnableIpWhiteList(SMnode *pMnode) { return 0; }
|
||||
|
||||
int32_t mndFetchIpWhiteList(SIpWhiteList *ipList, char **buf) {
|
||||
*buf = NULL;
|
||||
|
|
|
@ -1678,6 +1678,10 @@ static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, SArray
|
|||
return -1;
|
||||
}
|
||||
|
||||
if ((terrno = grantCheck(TSDB_GRANT_TIMESERIES)) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pNew->numOfColumns = pNew->numOfColumns + ncols;
|
||||
if (mndAllocStbSchemas(pOld, pNew) != 0) {
|
||||
return -1;
|
||||
|
|
|
@ -361,8 +361,71 @@ static void transferVgroupsForConsumers(SMqRebOutputObj *pOutput, SHashObj *pHas
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t processRemoveAddVgs(SMnode *pMnode, SMqRebOutputObj *pOutput){
|
||||
int32_t totalVgNum = 0;
|
||||
SVgObj* pVgroup = NULL;
|
||||
void* pIter = NULL;
|
||||
SArray* newVgs = taosArrayInit(0, POINTER_BYTES);
|
||||
while (1) {
|
||||
pIter = sdbFetch(pMnode->pSdb, SDB_VGROUP, pIter, (void**)&pVgroup);
|
||||
if (pIter == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!mndVgroupInDb(pVgroup, pOutput->pSub->dbUid)) {
|
||||
sdbRelease(pMnode->pSdb, pVgroup);
|
||||
continue;
|
||||
}
|
||||
|
||||
totalVgNum++;
|
||||
SMqVgEp* pVgEp = taosMemoryMalloc(sizeof(SMqVgEp));
|
||||
pVgEp->epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||
pVgEp->vgId = pVgroup->vgId;
|
||||
taosArrayPush(newVgs, &pVgEp);
|
||||
sdbRelease(pMnode->pSdb, pVgroup);
|
||||
}
|
||||
|
||||
pIter = NULL;
|
||||
while (1) {
|
||||
pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter);
|
||||
if (pIter == NULL) break;
|
||||
SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter;
|
||||
|
||||
int32_t j = 0;
|
||||
while (j < taosArrayGetSize(pConsumerEp->vgs)) {
|
||||
SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, j);
|
||||
bool find = false;
|
||||
for(int32_t k = 0; k < taosArrayGetSize(newVgs); k++){
|
||||
SMqVgEp *pnewVgEp = taosArrayGetP(newVgs, k);
|
||||
if(pVgEp->vgId == pnewVgEp->vgId){
|
||||
tDeleteSMqVgEp(pnewVgEp);
|
||||
taosArrayRemove(newVgs, k);
|
||||
find = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!find){
|
||||
mInfo("processRemoveAddVgs old vgId:%d", pVgEp->vgId);
|
||||
tDeleteSMqVgEp(pVgEp);
|
||||
taosArrayRemove(pConsumerEp->vgs, j);
|
||||
continue;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
if(taosArrayGetSize(pOutput->pSub->unassignedVgs) == 0 && taosArrayGetSize(newVgs) != 0){
|
||||
taosArrayAddAll(pOutput->pSub->unassignedVgs, newVgs);
|
||||
mInfo("processRemoveAddVgs add new vg num:%d", (int)taosArrayGetSize(newVgs));
|
||||
taosArrayDestroy(newVgs);
|
||||
}else{
|
||||
taosArrayDestroyP(newVgs, (FDelete)tDeleteSMqVgEp);
|
||||
}
|
||||
return totalVgNum;
|
||||
}
|
||||
|
||||
static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqRebOutputObj *pOutput) {
|
||||
int32_t totalVgNum = pOutput->pSub->vgNum;
|
||||
int32_t totalVgNum = processRemoveAddVgs(pMnode, pOutput);
|
||||
const char *pSubKey = pOutput->pSub->key;
|
||||
|
||||
int32_t numOfRemoved = taosArrayGetSize(pInput->pRebInfo->removedConsumers);
|
||||
|
@ -1093,33 +1156,33 @@ int32_t mndSetDropSubCommitLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeObj
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndDropSubByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
||||
int32_t code = 0;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
||||
void *pIter = NULL;
|
||||
SMqSubscribeObj *pSub = NULL;
|
||||
while (1) {
|
||||
pIter = sdbFetch(pSdb, SDB_SUBSCRIBE, pIter, (void **)&pSub);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
if (pSub->dbUid != pDb->uid) {
|
||||
sdbRelease(pSdb, pSub);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mndSetDropSubCommitLogs(pMnode, pTrans, pSub) < 0) {
|
||||
sdbRelease(pSdb, pSub);
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
code = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
sdbRelease(pSdb, pSub);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
//int32_t mndDropSubByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
||||
// int32_t code = 0;
|
||||
// SSdb *pSdb = pMnode->pSdb;
|
||||
//
|
||||
// void *pIter = NULL;
|
||||
// SMqSubscribeObj *pSub = NULL;
|
||||
// while (1) {
|
||||
// pIter = sdbFetch(pSdb, SDB_SUBSCRIBE, pIter, (void **)&pSub);
|
||||
// if (pIter == NULL) break;
|
||||
//
|
||||
// if (pSub->dbUid != pDb->uid) {
|
||||
// sdbRelease(pSdb, pSub);
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (mndSetDropSubCommitLogs(pMnode, pTrans, pSub) < 0) {
|
||||
// sdbRelease(pSdb, pSub);
|
||||
// sdbCancelFetch(pSdb, pIter);
|
||||
// code = -1;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// sdbRelease(pSdb, pSub);
|
||||
// }
|
||||
//
|
||||
// return code;
|
||||
//}
|
||||
|
||||
int32_t mndDropSubByTopic(SMnode *pMnode, STrans *pTrans, const char *topicName) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
|
|
@ -543,6 +543,8 @@ STrans *mndAcquireTrans(SMnode *pMnode, int32_t transId) {
|
|||
STrans *pTrans = sdbAcquire(pMnode->pSdb, SDB_TRANS, &transId);
|
||||
if (pTrans == NULL) {
|
||||
terrno = TSDB_CODE_MND_TRANS_NOT_EXIST;
|
||||
} else {
|
||||
taosThreadMutexInit(&pTrans->mutex, NULL);
|
||||
}
|
||||
return pTrans;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBloc
|
|||
static void mndCancelGetNextPrivileges(SMnode *pMnode, void *pIter);
|
||||
SHashObj *mndFetchAllIpWhite(SMnode *pMnode);
|
||||
static int32_t mndProcesSRetrieveIpWhiteReq(SRpcMsg *pReq);
|
||||
bool mndUpdateIpWhiteImpl(SHashObj *pIpWhiteTab, char *user, char *fqdn, int8_t type);
|
||||
|
||||
void ipWhiteMgtUpdateAll(SMnode *pMnode);
|
||||
typedef struct {
|
||||
|
@ -80,7 +81,7 @@ void ipWhiteMgtCleanup() {
|
|||
taosThreadRwlockDestroy(&ipWhiteMgt.rw);
|
||||
}
|
||||
|
||||
int32_t ipWhiteMgtUpdate(char *user, SIpWhiteList *pNew) {
|
||||
int32_t ipWhiteMgtUpdate(SMnode *pMnode, char *user, SIpWhiteList *pNew) {
|
||||
bool update = true;
|
||||
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
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 *));
|
||||
}
|
||||
}
|
||||
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++;
|
||||
|
||||
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
|
@ -193,17 +213,17 @@ int64_t mndGetIpWhiteVer(SMnode *pMnode) {
|
|||
int64_t ver = 0;
|
||||
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
if (ipWhiteMgt.ver == 0) {
|
||||
// user and dnode r
|
||||
// get user and dnode ip white list
|
||||
ipWhiteMgtUpdateAll(pMnode);
|
||||
ipWhiteMgt.ver = taosGetTimestampMs();
|
||||
}
|
||||
ver = ipWhiteMgt.ver;
|
||||
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
mDebug("ip-white-list on mnode ver: %" PRId64 "", ver);
|
||||
|
||||
if (mndEnableIpWhiteList(pMnode) == 0 || tsEnableWhiteList == false) {
|
||||
return 0;
|
||||
ver = 0;
|
||||
}
|
||||
mDebug("ip-white-list on mnode ver: %" PRId64 "", ver);
|
||||
return ver;
|
||||
}
|
||||
|
||||
|
@ -282,7 +302,7 @@ int32_t mndRefreshUserIpWhiteList(SMnode *pMnode) {
|
|||
|
||||
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) {
|
||||
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
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);
|
||||
|
||||
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 (lock) taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
|
@ -1178,7 +1212,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
|
|||
mndTransDrop(pTrans);
|
||||
goto _OVER;
|
||||
}
|
||||
ipWhiteMgtUpdate(userObj.user, userObj.pIpWhiteList);
|
||||
ipWhiteMgtUpdate(pMnode, userObj.user, userObj.pIpWhiteList);
|
||||
taosMemoryFree(userObj.pIpWhiteList);
|
||||
|
||||
mndTransDrop(pTrans);
|
||||
|
@ -1346,7 +1380,7 @@ static int32_t mndAlterUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SRpc
|
|||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
ipWhiteMgtUpdate(pNew->user, pNew->pIpWhiteList);
|
||||
ipWhiteMgtUpdate(pMnode, pNew->user, pNew->pIpWhiteList);
|
||||
mndTransDrop(pTrans);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -261,6 +261,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
|
|||
createReq.daysToKeep0 = pDb->cfg.daysToKeep0;
|
||||
createReq.daysToKeep1 = pDb->cfg.daysToKeep1;
|
||||
createReq.daysToKeep2 = pDb->cfg.daysToKeep2;
|
||||
createReq.keepTimeOffset = pDb->cfg.keepTimeOffset;
|
||||
createReq.minRows = pDb->cfg.minRows;
|
||||
createReq.maxRows = pDb->cfg.maxRows;
|
||||
createReq.walFsyncPeriod = pDb->cfg.walFsyncPeriod;
|
||||
|
@ -377,6 +378,7 @@ static void *mndBuildAlterVnodeConfigReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pV
|
|||
alterReq.daysToKeep0 = pDb->cfg.daysToKeep0;
|
||||
alterReq.daysToKeep1 = pDb->cfg.daysToKeep1;
|
||||
alterReq.daysToKeep2 = pDb->cfg.daysToKeep2;
|
||||
alterReq.keepTimeOffset = pDb->cfg.keepTimeOffset;
|
||||
alterReq.walFsyncPeriod = pDb->cfg.walFsyncPeriod;
|
||||
alterReq.walLevel = pDb->cfg.walLevel;
|
||||
alterReq.strict = pDb->cfg.strict;
|
||||
|
@ -2672,14 +2674,14 @@ int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj *pVgro
|
|||
SDbObj dbObj = {0};
|
||||
SArray *pArray = mndBuildDnodesArray(pMnode, 0);
|
||||
|
||||
int32_t numOfTopics = 0;
|
||||
if (mndGetNumOfTopics(pMnode, pDb->name, &numOfTopics) != 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
if (numOfTopics > 0) {
|
||||
terrno = TSDB_CODE_MND_TOPIC_MUST_BE_DELETED;
|
||||
goto _OVER;
|
||||
}
|
||||
// int32_t numOfTopics = 0;
|
||||
// if (mndGetNumOfTopics(pMnode, pDb->name, &numOfTopics) != 0) {
|
||||
// goto _OVER;
|
||||
// }
|
||||
// if (numOfTopics > 0) {
|
||||
// terrno = TSDB_CODE_MND_TOPIC_MUST_BE_DELETED;
|
||||
// goto _OVER;
|
||||
// }
|
||||
|
||||
int32_t numOfStreams = 0;
|
||||
if (mndGetNumOfStreams(pMnode, pDb->name, &numOfStreams) != 0) {
|
||||
|
|
|
@ -86,11 +86,13 @@ void *vnodeGetIdx(void *pVnode);
|
|||
void *vnodeGetIvtIdx(void *pVnode);
|
||||
|
||||
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 vnodeGetAllCtbNum(SVnode *pVnode, int64_t *num);
|
||||
|
||||
void vnodeResetLoad(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 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 metaPutTbGroupToCache(void *pVnode, uint64_t suid, const void *pKey, int32_t keyLen, void *pPayload,
|
||||
int32_t payloadLen);
|
||||
bool metaTbInFilterCache(void *pVnode, tb_uid_t suid, int8_t type);
|
||||
int32_t metaPutTbToFilterCache(void *pVnode, tb_uid_t suid, int8_t type);
|
||||
int32_t metaSizeOfTbFilterCache(void *pVnode, int8_t type);
|
||||
bool metaTbInFilterCache(SMeta *pMeta, const void* key, int8_t type);
|
||||
int32_t metaPutTbToFilterCache(SMeta *pMeta, const void* key, 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
|
||||
typedef struct STsdbReader STsdbReader;
|
||||
|
@ -281,6 +284,7 @@ struct STsdbCfg {
|
|||
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 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];
|
||||
};
|
||||
|
||||
|
@ -288,10 +292,10 @@ typedef struct {
|
|||
int64_t numOfSTables;
|
||||
int64_t numOfCTables;
|
||||
int64_t numOfNTables;
|
||||
int64_t numOfCmprTables;
|
||||
int64_t numOfReportedTimeSeries;
|
||||
int64_t numOfNTimeSeries;
|
||||
int64_t numOfTimeSeries;
|
||||
int64_t itvTimeSeries;
|
||||
// int64_t itvTimeSeries;
|
||||
int64_t pointsWritten;
|
||||
int64_t totalStorage;
|
||||
int64_t compStorage;
|
||||
|
|
|
@ -71,7 +71,7 @@ int32_t metaCacheDrop(SMeta* pMeta, int64_t uid);
|
|||
int32_t metaStatsCacheUpsert(SMeta* pMeta, SMetaStbStats* pInfo);
|
||||
int32_t metaStatsCacheDrop(SMeta* pMeta, int64_t uid);
|
||||
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);
|
||||
|
||||
struct SMeta {
|
||||
|
|
|
@ -380,6 +380,8 @@ struct STsdb {
|
|||
TdThreadMutex lruMutex;
|
||||
SLRUCache *biCache;
|
||||
TdThreadMutex biMutex;
|
||||
SLRUCache *bCache;
|
||||
TdThreadMutex bMutex;
|
||||
struct STFileSystem *pFS; // new
|
||||
SRocksCache rCache;
|
||||
};
|
||||
|
@ -650,6 +652,12 @@ typedef struct {
|
|||
int64_t pgno;
|
||||
uint8_t *pBuf;
|
||||
int64_t szFile;
|
||||
STsdb *pTsdb;
|
||||
const char *objName;
|
||||
uint8_t s3File;
|
||||
int32_t fid;
|
||||
int64_t cid;
|
||||
int64_t blkno;
|
||||
} STsdbFD;
|
||||
|
||||
struct SDelFWriter {
|
||||
|
@ -861,6 +869,9 @@ int32_t tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h);
|
|||
int32_t tsdbCacheGetBlockIdx(SLRUCache *pCache, SDataFReader *pFileReader, LRUHandle **handle);
|
||||
int32_t tsdbBICacheRelease(SLRUCache *pCache, LRUHandle *h);
|
||||
|
||||
int32_t tsdbCacheGetBlockS3(SLRUCache *pCache, STsdbFD *pFD, LRUHandle **handle);
|
||||
int32_t tsdbBCacheRelease(SLRUCache *pCache, LRUHandle *h);
|
||||
|
||||
int32_t tsdbCacheDeleteLastrow(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey);
|
||||
int32_t tsdbCacheDeleteLast(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey);
|
||||
int32_t tsdbCacheDelete(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey);
|
||||
|
|
|
@ -22,15 +22,21 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define S3_BLOCK_CACHE
|
||||
|
||||
extern int8_t tsS3Enabled;
|
||||
extern int32_t tsS3BlockSize;
|
||||
extern int32_t tsS3BlockCacheSize;
|
||||
|
||||
int32_t s3Init();
|
||||
void s3CleanUp();
|
||||
int32_t s3PutObjectFromFile(const char *file, const char *object);
|
||||
int32_t s3PutObjectFromFile2(const char *file, const char *object);
|
||||
void s3DeleteObjectsByPrefix(const char *prefix);
|
||||
void s3DeleteObjects(const char *object_name[], int nobject);
|
||||
bool s3Exists(const char *object_name);
|
||||
bool s3Get(const char *object_name, const char *path);
|
||||
int32_t s3GetObjectBlock(const char *object_name, int64_t offset, int64_t size, uint8_t **ppBlock);
|
||||
void s3EvictCache(const char *path, long object_size);
|
||||
long s3Size(const char *object_name);
|
||||
|
||||
|
|
|
@ -170,7 +170,8 @@ int32_t metaTbGroupCacheClear(SMeta* pMeta, uint64_t suid);
|
|||
int metaAddIndexToSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* 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);
|
||||
int32_t metaResumeCtbCursor(SMCtbCursor* pCtbCur, int8_t first);
|
||||
void metaPauseCtbCursor(SMCtbCursor* pCtbCur);
|
||||
|
@ -410,6 +411,7 @@ struct STsdbKeepCfg {
|
|||
int32_t keep0;
|
||||
int32_t keep1;
|
||||
int32_t keep2;
|
||||
int32_t keepTimeOffset;
|
||||
};
|
||||
|
||||
typedef struct SVCommitSched {
|
||||
|
|
|
@ -14,6 +14,13 @@
|
|||
*/
|
||||
#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 META_CACHE_BASE_BUCKET 1024
|
||||
#define META_CACHE_STATS_BUCKET 16
|
||||
|
@ -69,6 +76,7 @@ struct SMetaCache {
|
|||
|
||||
struct STbFilterCache {
|
||||
SHashObj* pStb;
|
||||
SHashObj* pStbName;
|
||||
} STbFilterCache;
|
||||
};
|
||||
|
||||
|
@ -178,6 +186,13 @@ int32_t metaCacheOpen(SMeta* pMeta) {
|
|||
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;
|
||||
return code;
|
||||
|
||||
|
@ -204,6 +219,7 @@ void metaCacheClose(SMeta* pMeta) {
|
|||
taosHashCleanup(pMeta->pCache->STbGroupResCache.pTableEntry);
|
||||
|
||||
taosHashCleanup(pMeta->pCache->STbFilterCache.pStb);
|
||||
taosHashCleanup(pMeta->pCache->STbFilterCache.pStbName);
|
||||
|
||||
taosMemoryFree(pMeta->pCache);
|
||||
pMeta->pCache = NULL;
|
||||
|
@ -893,30 +909,59 @@ int32_t metaTbGroupCacheClear(SMeta* pMeta, uint64_t suid) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
bool metaTbInFilterCache(void* pVnode, tb_uid_t suid, int8_t type) {
|
||||
SMeta* pMeta = ((SVnode*)pVnode)->pMeta;
|
||||
bool metaTbInFilterCache(SMeta *pMeta, const void* key, int8_t type) {
|
||||
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 false;
|
||||
}
|
||||
|
||||
int32_t metaPutTbToFilterCache(void* pVnode, tb_uid_t suid, int8_t type) {
|
||||
SMeta* pMeta = ((SVnode*)pVnode)->pMeta;
|
||||
|
||||
int32_t metaPutTbToFilterCache(SMeta *pMeta, const void* key, int8_t type) {
|
||||
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;
|
||||
}
|
||||
|
||||
int32_t metaSizeOfTbFilterCache(void* pVnode, int8_t type) {
|
||||
SMeta* pMeta = ((SVnode*)pVnode)->pMeta;
|
||||
int32_t metaSizeOfTbFilterCache(SMeta *pMeta, int8_t type) {
|
||||
if (type == 0) {
|
||||
return taosHashGetSize(pMeta->pCache->STbFilterCache.pStb);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
if (metaInitTbFilterCache(pMeta) != 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
metaDebug("vgId:%d, meta is opened", TD_VID(pVnode));
|
||||
|
||||
*ppMeta = pMeta;
|
||||
|
|
|
@ -696,22 +696,30 @@ int64_t metaGetTbNum(SMeta *pMeta) {
|
|||
return pMeta->pVnode->config.vndStats.numOfCTables + pMeta->pVnode->config.vndStats.numOfNTables;
|
||||
}
|
||||
|
||||
// N.B. Called by statusReq per second
|
||||
int64_t metaGetTimeSeriesNum(SMeta *pMeta) {
|
||||
// sum of (number of columns of stable - 1) * number of ctables (excluding timestamp column)
|
||||
int64_t nTables = metaGetTbNum(pMeta);
|
||||
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;
|
||||
pMeta->pVnode->config.vndStats.numOfCmprTables = nTables;
|
||||
void metaUpdTimeSeriesNum(SMeta *pMeta) {
|
||||
int64_t nCtbTimeSeries = 0;
|
||||
if (vnodeGetTimeSeriesNum(pMeta->pVnode, &nCtbTimeSeries) == 0) {
|
||||
atomic_store_64(&pMeta->pVnode->config.vndStats.numOfTimeSeries, nCtbTimeSeries);
|
||||
}
|
||||
}
|
||||
|
||||
return pMeta->pVnode->config.vndStats.numOfTimeSeries + pMeta->pVnode->config.vndStats.numOfNTimeSeries;
|
||||
static FORCE_INLINE int64_t metaGetTimeSeriesNumImpl(SMeta *pMeta, bool forceUpd) {
|
||||
// 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 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 {
|
||||
|
@ -1509,9 +1517,10 @@ _exit:
|
|||
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;
|
||||
*numOfTables = 0;
|
||||
|
||||
if (!numOfTables && !numOfCols) goto _exit;
|
||||
|
||||
SVnode *pVnodeObj = pVnode;
|
||||
metaRLock(pVnodeObj->pMeta);
|
||||
|
@ -1520,19 +1529,26 @@ int32_t metaGetStbStats(void *pVnode, int64_t uid, int64_t *numOfTables) {
|
|||
SMetaStbStats state = {0};
|
||||
if (metaStatsCacheGet(pVnodeObj->pMeta, uid, &state) == TSDB_CODE_SUCCESS) {
|
||||
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;
|
||||
}
|
||||
|
||||
// slow path: search TDB
|
||||
int64_t ctbNum = 0;
|
||||
int32_t colNum = 0;
|
||||
vnodeGetCtbNum(pVnode, uid, &ctbNum);
|
||||
|
||||
vnodeGetStbColumnNum(pVnode, uid, &colNum);
|
||||
metaULock(pVnodeObj->pMeta);
|
||||
*numOfTables = ctbNum;
|
||||
|
||||
if (numOfTables) *numOfTables = ctbNum;
|
||||
if (numOfCols) *numOfCols = colNum;
|
||||
|
||||
state.uid = uid;
|
||||
state.ctbNum = ctbNum;
|
||||
state.colNum = colNum;
|
||||
|
||||
// upsert the cache
|
||||
metaWLock(pVnodeObj->pMeta);
|
||||
|
@ -1543,12 +1559,12 @@ _exit:
|
|||
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};
|
||||
|
||||
if (metaStatsCacheGet(pMeta, uid, &stats) == TSDB_CODE_SUCCESS) {
|
||||
stats.ctbNum += delta;
|
||||
|
||||
stats.ctbNum += deltaCtb;
|
||||
stats.colNum += deltaCol;
|
||||
metaStatsCacheUpsert(pMeta, &stats);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
#include "meta.h"
|
||||
|
||||
extern SDmNotifyHandle dmNotifyHdl;
|
||||
|
||||
static int metaSaveJsonVarToIdx(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);
|
||||
|
@ -26,7 +28,7 @@ static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME);
|
|||
static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME);
|
||||
static int metaUpdateSuidIdx(SMeta *pMeta, const SMetaEntry *pME);
|
||||
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);
|
||||
// opt ins_tables query
|
||||
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 metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME);
|
||||
|
||||
|
||||
static void metaGetEntryInfo(const SMetaEntry *pEntry, SMetaInfo *pInfo) {
|
||||
pInfo->uid = pEntry->uid;
|
||||
pInfo->version = pEntry->version;
|
||||
|
@ -191,6 +194,18 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche
|
|||
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) {
|
||||
SMetaEntry me = {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++) {
|
||||
tb_uid_t uid = *(tb_uid_t *)taosArrayGet(tbUidList, iChild);
|
||||
metaDropTableByUid(pMeta, uid, NULL);
|
||||
metaDropTableByUid(pMeta, uid, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
// drop super table
|
||||
|
@ -304,8 +319,12 @@ _drop_super_table:
|
|||
tdbTbDelete(pMeta->pUidIdx, &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);
|
||||
|
||||
metaUpdTimeSeriesNum(pMeta);
|
||||
|
||||
_exit:
|
||||
tdbFree(pKey);
|
||||
tdbFree(pData);
|
||||
|
@ -376,6 +395,9 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
nStbEntry.stbEntry.schemaRow = pReq->schemaRow;
|
||||
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);
|
||||
// compare two entry
|
||||
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);
|
||||
|
||||
if (updStat) {
|
||||
metaUpdateStbStats(pMeta, pReq->suid, 0, deltaCol);
|
||||
}
|
||||
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);
|
||||
tDecoderClear(&dc);
|
||||
tdbTbcClose(pTbDbc);
|
||||
|
@ -733,7 +766,10 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs
|
|||
}
|
||||
metaReaderClear(&mr);
|
||||
|
||||
bool sysTbl = (pReq->type == TSDB_CHILD_TABLE) && metaTbInFilterCache(pMeta, pReq->ctb.stbName, 1);
|
||||
|
||||
// build SMetaEntry
|
||||
SVnodeStats *pStats = &pMeta->pVnode->config.vndStats;
|
||||
me.version = ver;
|
||||
me.type = pReq->type;
|
||||
me.uid = pReq->uid;
|
||||
|
@ -767,10 +803,16 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs
|
|||
}
|
||||
#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);
|
||||
metaUpdateStbStats(pMeta, me.ctbEntry.suid, 1);
|
||||
metaUpdateStbStats(pMeta, me.ctbEntry.suid, 1, 0);
|
||||
metaUidCacheClear(pMeta, me.ctbEntry.suid);
|
||||
metaTbGroupCacheClear(pMeta, me.ctbEntry.suid);
|
||||
metaULock(pMeta);
|
||||
|
@ -782,12 +824,14 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs
|
|||
me.ntbEntry.schemaRow = pReq->ntb.schemaRow;
|
||||
me.ntbEntry.ncid = me.ntbEntry.schemaRow.pSchema[me.ntbEntry.schemaRow.nCols - 1].colId + 1;
|
||||
|
||||
++pMeta->pVnode->config.vndStats.numOfNTables;
|
||||
pMeta->pVnode->config.vndStats.numOfNTimeSeries += me.ntbEntry.schemaRow.nCols - 1;
|
||||
++pStats->numOfNTables;
|
||||
pStats->numOfNTimeSeries += me.ntbEntry.schemaRow.nCols - 1;
|
||||
}
|
||||
|
||||
if (metaHandleEntry(pMeta, &me) < 0) goto _err;
|
||||
|
||||
metaTimeSeriesNotifyCheck(pMeta);
|
||||
|
||||
if (pMetaRsp) {
|
||||
*pMetaRsp = taosMemoryCalloc(1, sizeof(STableMetaRsp));
|
||||
|
||||
|
@ -817,7 +861,9 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
|
|||
void *pData = NULL;
|
||||
int nData = 0;
|
||||
int rc = 0;
|
||||
tb_uid_t uid;
|
||||
tb_uid_t uid = 0;
|
||||
tb_uid_t suid = 0;
|
||||
int8_t sysTbl = 0;
|
||||
int type;
|
||||
|
||||
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;
|
||||
|
||||
metaWLock(pMeta);
|
||||
metaDropTableByUid(pMeta, uid, &type);
|
||||
rc = metaDropTableByUid(pMeta, uid, &type, &suid, &sysTbl);
|
||||
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) {
|
||||
taosArrayPush(tbUids, &uid);
|
||||
}
|
||||
|
@ -839,20 +895,49 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
|
|||
*tbUid = uid;
|
||||
}
|
||||
|
||||
_exit:
|
||||
tdbFree(pData);
|
||||
return 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
void metaDropTables(SMeta *pMeta, SArray *tbUids) {
|
||||
if (taosArrayGetSize(tbUids) == 0) return;
|
||||
|
||||
int64_t nCtbDropped = 0;
|
||||
SSHashObj *suidHash = tSimpleHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT));
|
||||
|
||||
metaWLock(pMeta);
|
||||
for (int i = 0; i < taosArrayGetSize(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);
|
||||
}
|
||||
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) {
|
||||
|
@ -987,7 +1072,7 @@ static int metaDeleteTtl(SMeta *pMeta, const SMetaEntry *pME) {
|
|||
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;
|
||||
int nData = 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 (e.type == TSDB_CHILD_TABLE) {
|
||||
if (pSuid) *pSuid = e.ctbEntry.suid;
|
||||
void *tData = NULL;
|
||||
int tLen = 0;
|
||||
|
||||
|
@ -1024,6 +1110,8 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
|||
tDecoderInit(&tdc, tData, tLen);
|
||||
metaDecodeEntry(&tdc, &stbEntry);
|
||||
|
||||
if (pSysTbl) *pSysTbl = metaTbInFilterCache(pMeta, stbEntry.name, 1) ? 1 : 0;
|
||||
|
||||
SSchema *pTagColumn = NULL;
|
||||
SSchemaWrapper *pTagSchema = &stbEntry.stbEntry.schemaTag;
|
||||
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);
|
||||
|
||||
--pMeta->pVnode->config.vndStats.numOfCTables;
|
||||
|
||||
metaUpdateStbStats(pMeta, e.ctbEntry.suid, -1);
|
||||
metaUpdateStbStats(pMeta, e.ctbEntry.suid, -1, 0);
|
||||
metaUidCacheClear(pMeta, e.ctbEntry.suid);
|
||||
metaTbGroupCacheClear(pMeta, e.ctbEntry.suid);
|
||||
} 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;
|
||||
goto _err;
|
||||
}
|
||||
if ((terrno = grantCheck(TSDB_GRANT_TIMESERIES)) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
pSchema->version++;
|
||||
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);
|
||||
|
||||
++pMeta->pVnode->config.vndStats.numOfNTimeSeries;
|
||||
metaTimeSeriesNotifyCheck(pMeta);
|
||||
break;
|
||||
case TSDB_ALTER_TABLE_DROP_COLUMN:
|
||||
if (pColumn == NULL) {
|
||||
|
|
|
@ -27,6 +27,7 @@ static int32_t rsmaRestore(SSma *pSma);
|
|||
pKeepCfg->keep0 = pKeepCfg->keep2; \
|
||||
pKeepCfg->keep1 = pKeepCfg->keep2; \
|
||||
pKeepCfg->days = smaEvalDays(v, pCfg->retentions, l, pCfg->precision, pCfg->days); \
|
||||
pKeepCfg->keepTimeOffset = 0; \
|
||||
} while (0)
|
||||
|
||||
#define SMA_OPEN_RSMA_IMPL(v, l) \
|
||||
|
|
|
@ -712,7 +712,7 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
|
|||
continue;
|
||||
}
|
||||
if (pHandle->consumerId == req.newConsumerId) { // do nothing
|
||||
tqInfo("vgId:%d no switch consumer:0x%" PRIx64 " remains, because redo wal log", req.vgId, req.newConsumerId);
|
||||
tqInfo("vgId:%d no switch consumer:0x%" PRIx64 " remains", req.vgId, req.newConsumerId);
|
||||
} else {
|
||||
tqInfo("vgId:%d switch consumer from Id:0x%" PRIx64 " to Id:0x%" PRIx64, req.vgId, pHandle->consumerId,
|
||||
req.newConsumerId);
|
||||
|
|
|
@ -174,21 +174,18 @@ int32_t tqSnapWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
|||
STQ* pTq = pWriter->pTq;
|
||||
SDecoder decoder = {0};
|
||||
SDecoder* pDecoder = &decoder;
|
||||
STqHandle handle;
|
||||
STqHandle handle = {0};
|
||||
|
||||
tDecoderInit(pDecoder, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
||||
code = tDecodeSTqHandle(pDecoder, &handle);
|
||||
if (code) goto _err;
|
||||
if (code) goto end;
|
||||
taosWLockLatch(&pTq->lock);
|
||||
code = tqMetaSaveHandle(pTq, handle.subKey, &handle);
|
||||
taosWUnLockLatch(&pTq->lock);
|
||||
if (code < 0) goto _err;
|
||||
tDecoderClear(pDecoder);
|
||||
|
||||
return code;
|
||||
|
||||
_err:
|
||||
end:
|
||||
tDecoderClear(pDecoder);
|
||||
tqError("vgId:%d, vnode snapshot tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
tqDestroyTqHandle(&handle);
|
||||
tqInfo("vgId:%d, vnode snapshot tq write result:%d", TD_VID(pTq->pVnode), code);
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -198,58 +198,51 @@ int32_t tqMetaRestoreCheckInfo(STQ* pTq) {
|
|||
int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) {
|
||||
int32_t code;
|
||||
int32_t vlen;
|
||||
void* buf = NULL;
|
||||
SEncoder encoder;
|
||||
tEncodeSize(tEncodeSTqHandle, pHandle, vlen, code);
|
||||
if (code < 0) {
|
||||
return -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
tqDebug("tq save %s(%d) handle consumer:0x%" PRIx64 " epoch:%d vgId:%d", pHandle->subKey,
|
||||
(int32_t)strlen(pHandle->subKey), pHandle->consumerId, pHandle->epoch, TD_VID(pTq->pVnode));
|
||||
|
||||
void* buf = taosMemoryCalloc(1, vlen);
|
||||
buf = taosMemoryCalloc(1, vlen);
|
||||
if (buf == NULL) {
|
||||
return -1;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
|
||||
SEncoder encoder;
|
||||
|
||||
tEncoderInit(&encoder, buf, vlen);
|
||||
|
||||
if (tEncodeSTqHandle(&encoder, pHandle) < 0) {
|
||||
tEncoderClear(&encoder);
|
||||
taosMemoryFree(buf);
|
||||
return -1;
|
||||
code = tEncodeSTqHandle(&encoder, pHandle);
|
||||
if (code < 0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
TXN* txn;
|
||||
|
||||
if (tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) <
|
||||
0) {
|
||||
tEncoderClear(&encoder);
|
||||
taosMemoryFree(buf);
|
||||
return -1;
|
||||
TXN* txn = NULL;
|
||||
code = tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
|
||||
if (code < 0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (tdbTbUpsert(pTq->pExecStore, key, (int)strlen(key), buf, vlen, txn) < 0) {
|
||||
tEncoderClear(&encoder);
|
||||
taosMemoryFree(buf);
|
||||
return -1;
|
||||
code = tdbTbUpsert(pTq->pExecStore, key, (int)strlen(key), buf, vlen, txn);
|
||||
if (code < 0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (tdbCommit(pTq->pMetaDB, txn) < 0) {
|
||||
tEncoderClear(&encoder);
|
||||
taosMemoryFree(buf);
|
||||
return -1;
|
||||
code = tdbCommit(pTq->pMetaDB, txn);
|
||||
if (code < 0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (tdbPostCommit(pTq->pMetaDB, txn) < 0) {
|
||||
code = tdbPostCommit(pTq->pMetaDB, txn);
|
||||
end:
|
||||
tEncoderClear(&encoder);
|
||||
taosMemoryFree(buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tEncoderClear(&encoder);
|
||||
taosMemoryFree(buf);
|
||||
return 0;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqMetaDeleteHandle(STQ* pTq, const char* key) {
|
||||
|
@ -349,15 +342,18 @@ static int buildHandle(STQ* pTq, STqHandle* handle){
|
|||
static int restoreHandle(STQ* pTq, void* pVal, int vLen, STqHandle* handle){
|
||||
int32_t vgId = TD_VID(pTq->pVnode);
|
||||
SDecoder decoder;
|
||||
int32_t code = 0;
|
||||
tDecoderInit(&decoder, (uint8_t*)pVal, vLen);
|
||||
tDecodeSTqHandle(&decoder, handle);
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
if(buildHandle(pTq, handle) < 0){
|
||||
return -1;
|
||||
}
|
||||
code = tDecodeSTqHandle(&decoder, handle);
|
||||
if (code) goto end;
|
||||
code = buildHandle(pTq, handle);
|
||||
if (code) goto end;
|
||||
tqInfo("restoreHandle %s consumer 0x%" PRIx64 " vgId:%d", handle->subKey, handle->consumerId, vgId);
|
||||
return taosHashPut(pTq->pHandle, handle->subKey, strlen(handle->subKey), handle, sizeof(STqHandle));
|
||||
code = taosHashPut(pTq->pHandle, handle->subKey, strlen(handle->subKey), handle, sizeof(STqHandle));
|
||||
|
||||
end:
|
||||
tDecoderClear(&decoder);
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqCreateHandle(STQ* pTq, SMqRebVgReq* req, STqHandle* handle){
|
||||
|
|
|
@ -85,6 +85,7 @@ int32_t tqOffsetSnapRead(STqOffsetReader* pReader, uint8_t** ppData) {
|
|||
*ppData = (uint8_t*)buf;
|
||||
|
||||
pReader->readEnd = 1;
|
||||
taosCloseFile(&pFile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ int32_t streamStateSnapRead(SStreamStateReader* pReader, uint8_t** ppData) {
|
|||
pHdr->type = SNAP_DATA_STREAM_STATE_BACKEND;
|
||||
pHdr->size = len;
|
||||
memcpy(pHdr->data, rowData, len);
|
||||
taosMemoryFree(rowData);
|
||||
tqDebug("vgId:%d, vnode stream-state snapshot read data success", TD_VID(pReader->pTq->pVnode));
|
||||
return code;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "tsdbDataFileRW.h"
|
||||
#include "tsdbReadUtil.h"
|
||||
#include "vnd.h"
|
||||
#include "vndCos.h"
|
||||
|
||||
#define ROCKS_BATCH_SIZE (4096)
|
||||
|
||||
|
@ -51,6 +52,41 @@ static void tsdbCloseBICache(STsdb *pTsdb) {
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t tsdbOpenBCache(STsdb *pTsdb) {
|
||||
int32_t code = 0;
|
||||
// SLRUCache *pCache = taosLRUCacheInit(10 * 1024 * 1024, 0, .5);
|
||||
int32_t szPage = pTsdb->pVnode->config.tsdbPageSize;
|
||||
|
||||
SLRUCache *pCache = taosLRUCacheInit((int64_t)tsS3BlockCacheSize * tsS3BlockSize * szPage, 0, .5);
|
||||
if (pCache == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
taosLRUCacheSetStrictCapacity(pCache, false);
|
||||
|
||||
taosThreadMutexInit(&pTsdb->bMutex, NULL);
|
||||
|
||||
_err:
|
||||
pTsdb->bCache = pCache;
|
||||
return code;
|
||||
}
|
||||
|
||||
static void tsdbCloseBCache(STsdb *pTsdb) {
|
||||
SLRUCache *pCache = pTsdb->bCache;
|
||||
if (pCache) {
|
||||
int32_t elems = taosLRUCacheGetElems(pCache);
|
||||
tsdbTrace("vgId:%d, elems: %d", TD_VID(pTsdb->pVnode), elems);
|
||||
taosLRUCacheEraseUnrefEntries(pCache);
|
||||
elems = taosLRUCacheGetElems(pCache);
|
||||
tsdbTrace("vgId:%d, elems: %d", TD_VID(pTsdb->pVnode), elems);
|
||||
|
||||
taosLRUCacheCleanup(pCache);
|
||||
|
||||
taosThreadMutexDestroy(&pTsdb->bMutex);
|
||||
}
|
||||
}
|
||||
|
||||
#define ROCKS_KEY_LEN (sizeof(tb_uid_t) + sizeof(int16_t) + sizeof(int8_t))
|
||||
|
||||
typedef struct {
|
||||
|
@ -1149,6 +1185,12 @@ int32_t tsdbOpenCache(STsdb *pTsdb) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
code = tsdbOpenBCache(pTsdb);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
code = tsdbOpenRocksCache(pTsdb);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -1178,6 +1220,7 @@ void tsdbCloseCache(STsdb *pTsdb) {
|
|||
}
|
||||
|
||||
tsdbCloseBICache(pTsdb);
|
||||
tsdbCloseBCache(pTsdb);
|
||||
tsdbCloseRocksCache(pTsdb);
|
||||
}
|
||||
|
||||
|
@ -2987,3 +3030,103 @@ int32_t tsdbBICacheRelease(SLRUCache *pCache, LRUHandle *h) {
|
|||
|
||||
return code;
|
||||
}
|
||||
|
||||
// block cache
|
||||
static void getBCacheKey(int32_t fid, int64_t commitID, int64_t blkno, char *key, int *len) {
|
||||
struct {
|
||||
int32_t fid;
|
||||
int64_t commitID;
|
||||
int64_t blkno;
|
||||
} bKey = {0};
|
||||
|
||||
bKey.fid = fid;
|
||||
bKey.commitID = commitID;
|
||||
bKey.blkno = blkno;
|
||||
|
||||
*len = sizeof(bKey);
|
||||
memcpy(key, &bKey, *len);
|
||||
}
|
||||
|
||||
static int32_t tsdbCacheLoadBlockS3(STsdbFD *pFD, uint8_t **ppBlock) {
|
||||
int32_t code = 0;
|
||||
/*
|
||||
uint8_t *pBlock = taosMemoryCalloc(1, tsS3BlockSize * pFD->szPage);
|
||||
if (pBlock == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
*/
|
||||
int64_t block_offset = (pFD->blkno - 1) * tsS3BlockSize * pFD->szPage;
|
||||
// int64_t size = 4096;
|
||||
code = s3GetObjectBlock(pFD->objName, block_offset, tsS3BlockSize * pFD->szPage, ppBlock);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
// taosMemoryFree(pBlock);
|
||||
// code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
|
||||
//*ppBlock = pBlock;
|
||||
|
||||
tsdbTrace("block:%p load from s3", *ppBlock);
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
||||
static void deleteBCache(const void *key, size_t keyLen, void *value, void *ud) {
|
||||
(void)ud;
|
||||
uint8_t *pBlock = (uint8_t *)value;
|
||||
|
||||
taosMemoryFree(pBlock);
|
||||
}
|
||||
|
||||
int32_t tsdbCacheGetBlockS3(SLRUCache *pCache, STsdbFD *pFD, LRUHandle **handle) {
|
||||
int32_t code = 0;
|
||||
char key[128] = {0};
|
||||
int keyLen = 0;
|
||||
|
||||
getBCacheKey(pFD->fid, pFD->cid, pFD->blkno, key, &keyLen);
|
||||
LRUHandle *h = taosLRUCacheLookup(pCache, key, keyLen);
|
||||
if (!h) {
|
||||
STsdb *pTsdb = pFD->pTsdb;
|
||||
taosThreadMutexLock(&pTsdb->bMutex);
|
||||
|
||||
h = taosLRUCacheLookup(pCache, key, keyLen);
|
||||
if (!h) {
|
||||
uint8_t *pBlock = NULL;
|
||||
code = tsdbCacheLoadBlockS3(pFD, &pBlock);
|
||||
// if table's empty or error, return code of -1
|
||||
if (code != TSDB_CODE_SUCCESS || pBlock == NULL) {
|
||||
taosThreadMutexUnlock(&pTsdb->bMutex);
|
||||
|
||||
*handle = NULL;
|
||||
if (code == TSDB_CODE_SUCCESS && !pBlock) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
size_t charge = tsS3BlockSize * pFD->szPage;
|
||||
_taos_lru_deleter_t deleter = deleteBCache;
|
||||
LRUStatus status =
|
||||
taosLRUCacheInsert(pCache, key, keyLen, pBlock, charge, deleter, &h, TAOS_LRU_PRIORITY_LOW, NULL);
|
||||
if (status != TAOS_LRU_STATUS_OK) {
|
||||
code = -1;
|
||||
}
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&pTsdb->bMutex);
|
||||
}
|
||||
|
||||
*handle = h;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbBCacheRelease(SLRUCache *pCache, LRUHandle *h) {
|
||||
int32_t code = 0;
|
||||
|
||||
taosLRUCacheRelease(pCache, h, false);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -501,7 +501,6 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
|||
int32_t lino = 0;
|
||||
STsdb *pTsdb = pCommitter->pTsdb;
|
||||
SDFileSet *pRSet = NULL;
|
||||
|
||||
// memory
|
||||
pCommitter->commitFid = tsdbKeyFid(pCommitter->nextKey, pCommitter->minutes, pCommitter->precision);
|
||||
pCommitter->expLevel = tsdbFidLevel(pCommitter->commitFid, &pCommitter->pTsdb->keepCfg, taosGetTimestampSec());
|
||||
|
@ -799,7 +798,6 @@ static int32_t tsdbCommitFileData(SCommitter *pCommitter) {
|
|||
int32_t lino = 0;
|
||||
STsdb *pTsdb = pCommitter->pTsdb;
|
||||
SMemTable *pMemTable = pTsdb->imem;
|
||||
|
||||
// commit file data start
|
||||
code = tsdbCommitFileDataStart(pCommitter);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
|
|
@ -101,7 +101,7 @@ int32_t tsdbDataFileReaderOpen(const char *fname[], const SDataFileReaderConfig
|
|||
if (fname) {
|
||||
for (int32_t i = 0; i < TSDB_FTYPE_MAX; ++i) {
|
||||
if (fname[i]) {
|
||||
code = tsdbOpenFile(fname[i], config->szPage, TD_FILE_READ, &reader[0]->fd[i]);
|
||||
code = tsdbOpenFile(fname[i], config->tsdb, TD_FILE_READ, &reader[0]->fd[i]);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ int32_t tsdbDataFileReaderOpen(const char *fname[], const SDataFileReaderConfig
|
|||
if (config->files[i].exist) {
|
||||
char fname1[TSDB_FILENAME_LEN];
|
||||
tsdbTFileName(config->tsdb, &config->files[i].file, fname1);
|
||||
code = tsdbOpenFile(fname1, config->szPage, TD_FILE_READ, &reader[0]->fd[i]);
|
||||
code = tsdbOpenFile(fname1, config->tsdb, TD_FILE_READ, &reader[0]->fd[i]);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
}
|
||||
|
@ -1466,7 +1466,7 @@ static int32_t tsdbDataFileWriterOpenDataFD(SDataFileWriter *writer) {
|
|||
}
|
||||
|
||||
tsdbTFileName(writer->config->tsdb, &writer->files[ftype], fname);
|
||||
code = tsdbOpenFile(fname, writer->config->szPage, flag, &writer->fd[ftype]);
|
||||
code = tsdbOpenFile(fname, writer->config->tsdb, flag, &writer->fd[ftype]);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
if (writer->files[ftype].size == 0) {
|
||||
|
@ -1634,7 +1634,7 @@ static int32_t tsdbDataFileWriterOpenTombFD(SDataFileWriter *writer) {
|
|||
int32_t flag = (TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
|
||||
tsdbTFileName(writer->config->tsdb, writer->files + ftype, fname);
|
||||
code = tsdbOpenFile(fname, writer->config->szPage, flag, &writer->fd[ftype]);
|
||||
code = tsdbOpenFile(fname, writer->config->tsdb, flag, &writer->fd[ftype]);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
uint8_t hdr[TSDB_FHDR_SIZE] = {0};
|
||||
|
|
|
@ -31,7 +31,7 @@ typedef struct SFDataPtr {
|
|||
int64_t size;
|
||||
} SFDataPtr;
|
||||
|
||||
extern int32_t tsdbOpenFile(const char *path, int32_t szPage, int32_t flag, STsdbFD **ppFD);
|
||||
extern int32_t tsdbOpenFile(const char *path, STsdb *pTsdb, int32_t flag, STsdbFD **ppFD);
|
||||
extern void tsdbCloseFile(STsdbFD **ppFD);
|
||||
extern int32_t tsdbWriteFile(STsdbFD *pFD, int64_t offset, const uint8_t *pBuf, int64_t size);
|
||||
extern int32_t tsdbReadFile(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size);
|
||||
|
|
|
@ -23,6 +23,7 @@ int32_t tsdbSetKeepCfg(STsdb *pTsdb, STsdbCfg *pCfg) {
|
|||
pKeepCfg->keep0 = pCfg->keep0;
|
||||
pKeepCfg->keep1 = pCfg->keep1;
|
||||
pKeepCfg->keep2 = pCfg->keep2;
|
||||
pKeepCfg->keepTimeOffset = pCfg->keepTimeOffset;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -75,8 +76,9 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
|
|||
goto _err;
|
||||
}
|
||||
|
||||
tsdbDebug("vgId:%d, tsdb is opened at %s, days:%d, keep:%d,%d,%d", TD_VID(pVnode), pTsdb->path, pTsdb->keepCfg.days,
|
||||
pTsdb->keepCfg.keep0, pTsdb->keepCfg.keep1, pTsdb->keepCfg.keep2);
|
||||
tsdbDebug("vgId:%d, tsdb is opened at %s, days:%d, keep:%d,%d,%d, keepTimeoffset:%d", TD_VID(pVnode), pTsdb->path,
|
||||
pTsdb->keepCfg.days, pTsdb->keepCfg.keep0, pTsdb->keepCfg.keep1, pTsdb->keepCfg.keep2,
|
||||
pTsdb->keepCfg.keepTimeOffset);
|
||||
|
||||
*ppTsdb = pTsdb;
|
||||
return 0;
|
||||
|
@ -89,8 +91,9 @@ _err:
|
|||
int tsdbClose(STsdb **pTsdb) {
|
||||
if (*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,
|
||||
pdb->keepCfg.keep0, pdb->keepCfg.keep1, pdb->keepCfg.keep2);
|
||||
tsdbDebug("vgId:%d, tsdb is close at %s, days:%d, keep:%d,%d,%d, keepTimeOffset:%d", TD_VID(pdb->pVnode), pdb->path,
|
||||
pdb->keepCfg.days, pdb->keepCfg.keep0, pdb->keepCfg.keep1, pdb->keepCfg.keep2,
|
||||
pdb->keepCfg.keepTimeOffset);
|
||||
taosThreadRwlockWrlock(&(*pTsdb)->rwLock);
|
||||
tsdbMemTableDestroy((*pTsdb)->mem, true);
|
||||
(*pTsdb)->mem = NULL;
|
||||
|
|
|
@ -4882,6 +4882,7 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs
|
|||
// alloc
|
||||
STsdbReadSnap* pSnap = (STsdbReadSnap*)taosMemoryCalloc(1, sizeof(STsdbReadSnap));
|
||||
if (pSnap == NULL) {
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
@ -4891,6 +4892,7 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs
|
|||
pSnap->pMem = pTsdb->mem;
|
||||
pSnap->pNode = taosMemoryMalloc(sizeof(*pSnap->pNode));
|
||||
if (pSnap->pNode == NULL) {
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
@ -4905,6 +4907,7 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs
|
|||
pSnap->pIMem = pTsdb->imem;
|
||||
pSnap->pINode = taosMemoryMalloc(sizeof(*pSnap->pINode));
|
||||
if (pSnap->pINode == NULL) {
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
@ -4915,6 +4918,9 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs
|
|||
tsdbRefMemTable(pTsdb->imem, pSnap->pINode);
|
||||
}
|
||||
|
||||
// unlock
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
|
||||
// fs
|
||||
code = tsdbFSCreateRefSnapshot(pTsdb->pFS, &pSnap->pfSetArray);
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
|
@ -4922,8 +4928,6 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs
|
|||
}
|
||||
|
||||
_exit:
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tsdbError("vgId:%d take read snapshot failed, code:%s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ static int32_t tsdbOpenFileImpl(STsdbFD *pFD) {
|
|||
const char *object_name = taosDirEntryBaseName((char *)path);
|
||||
long s3_size = tsS3Enabled ? s3Size(object_name) : 0;
|
||||
if (tsS3Enabled && !strncmp(path + strlen(path) - 5, ".data", 5) && s3_size > 0) {
|
||||
#ifndef S3_BLOCK_CACHE
|
||||
s3EvictCache(path, s3_size);
|
||||
s3Get(object_name, path);
|
||||
|
||||
|
@ -38,6 +39,14 @@ static int32_t tsdbOpenFileImpl(STsdbFD *pFD) {
|
|||
// taosMemoryFree(pFD);
|
||||
goto _exit;
|
||||
}
|
||||
#else
|
||||
pFD->s3File = 1;
|
||||
pFD->pFD = (TdFilePtr)&pFD->s3File;
|
||||
int32_t vid = 0;
|
||||
sscanf(object_name, "v%df%dver%" PRId64 ".data", &vid, &pFD->fid, &pFD->cid);
|
||||
pFD->objName = object_name;
|
||||
// pFD->szFile = s3_size;
|
||||
#endif
|
||||
} else {
|
||||
code = TAOS_SYSTEM_ERROR(errsv);
|
||||
// taosMemoryFree(pFD);
|
||||
|
@ -54,7 +63,7 @@ static int32_t tsdbOpenFileImpl(STsdbFD *pFD) {
|
|||
}
|
||||
|
||||
// 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) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
// taosMemoryFree(pFD->pBuf);
|
||||
|
@ -72,9 +81,10 @@ _exit:
|
|||
}
|
||||
|
||||
// =============== PAGE-WISE FILE ===============
|
||||
int32_t tsdbOpenFile(const char *path, int32_t szPage, int32_t flag, STsdbFD **ppFD) {
|
||||
int32_t tsdbOpenFile(const char *path, STsdb *pTsdb, int32_t flag, STsdbFD **ppFD) {
|
||||
int32_t code = 0;
|
||||
STsdbFD *pFD = NULL;
|
||||
int32_t szPage = pTsdb->pVnode->config.tsdbPageSize;
|
||||
|
||||
*ppFD = NULL;
|
||||
|
||||
|
@ -90,6 +100,7 @@ int32_t tsdbOpenFile(const char *path, int32_t szPage, int32_t flag, STsdbFD **p
|
|||
pFD->flag = flag;
|
||||
pFD->szPage = szPage;
|
||||
pFD->pgno = 0;
|
||||
pFD->pTsdb = pTsdb;
|
||||
|
||||
*ppFD = pFD;
|
||||
|
||||
|
@ -101,7 +112,9 @@ void tsdbCloseFile(STsdbFD **ppFD) {
|
|||
STsdbFD *pFD = *ppFD;
|
||||
if (pFD) {
|
||||
taosMemoryFree(pFD->pBuf);
|
||||
if (!pFD->s3File) {
|
||||
taosCloseFile(&pFD->pFD);
|
||||
}
|
||||
taosMemoryFree(pFD);
|
||||
*ppFD = NULL;
|
||||
}
|
||||
|
@ -117,6 +130,9 @@ static int32_t tsdbWriteFilePage(STsdbFD *pFD) {
|
|||
}
|
||||
}
|
||||
|
||||
if (pFD->s3File) {
|
||||
return code;
|
||||
}
|
||||
if (pFD->pgno > 0) {
|
||||
int64_t n = taosLSeekFile(pFD->pFD, PAGE_OFFSET(pFD->pgno, pFD->szPage), SEEK_SET);
|
||||
if (n < 0) {
|
||||
|
@ -153,8 +169,29 @@ static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno) {
|
|||
}
|
||||
}
|
||||
|
||||
// seek
|
||||
int64_t offset = PAGE_OFFSET(pgno, pFD->szPage);
|
||||
|
||||
if (pFD->s3File) {
|
||||
LRUHandle *handle = NULL;
|
||||
|
||||
pFD->blkno = (pgno + tsS3BlockSize - 1) / tsS3BlockSize;
|
||||
code = tsdbCacheGetBlockS3(pFD->pTsdb->bCache, pFD, &handle);
|
||||
if (code != TSDB_CODE_SUCCESS || handle == NULL) {
|
||||
tsdbBCacheRelease(pFD->pTsdb->bCache, handle);
|
||||
if (code == TSDB_CODE_SUCCESS && !handle) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
uint8_t *pBlock = (uint8_t *)taosLRUCacheValue(pFD->pTsdb->bCache, handle);
|
||||
|
||||
int64_t blk_offset = (pFD->blkno - 1) * tsS3BlockSize * pFD->szPage;
|
||||
memcpy(pFD->pBuf, pBlock + (offset - blk_offset), pFD->szPage);
|
||||
|
||||
tsdbBCacheRelease(pFD->pTsdb->bCache, handle);
|
||||
} else {
|
||||
// seek
|
||||
int64_t n = taosLSeekFile(pFD->pFD, offset, SEEK_SET);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
|
@ -170,6 +207,7 @@ static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno) {
|
|||
code = TSDB_CODE_FILE_CORRUPTED;
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
|
||||
// check
|
||||
if (pgno > 1 && !taosCheckChecksumWhole(pFD->pBuf, pFD->szPage)) {
|
||||
|
@ -247,6 +285,9 @@ _exit:
|
|||
int32_t tsdbFsyncFile(STsdbFD *pFD) {
|
||||
int32_t code = 0;
|
||||
|
||||
if (pFD->s3File) {
|
||||
return code;
|
||||
}
|
||||
code = tsdbWriteFilePage(pFD);
|
||||
if (code) goto _exit;
|
||||
|
||||
|
@ -293,7 +334,7 @@ int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pS
|
|||
// head
|
||||
flag = TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC;
|
||||
tsdbHeadFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fHead, fname);
|
||||
code = tsdbOpenFile(fname, szPage, flag, &pWriter->pHeadFD);
|
||||
code = tsdbOpenFile(fname, pTsdb, flag, &pWriter->pHeadFD);
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbWriteFile(pWriter->pHeadFD, 0, hdr, TSDB_FHDR_SIZE);
|
||||
|
@ -307,7 +348,7 @@ int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pS
|
|||
flag = TD_FILE_READ | TD_FILE_WRITE;
|
||||
}
|
||||
tsdbDataFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fData, fname);
|
||||
code = tsdbOpenFile(fname, szPage, flag, &pWriter->pDataFD);
|
||||
code = tsdbOpenFile(fname, pTsdb, flag, &pWriter->pDataFD);
|
||||
if (code) goto _err;
|
||||
if (pWriter->fData.size == 0) {
|
||||
code = tsdbWriteFile(pWriter->pDataFD, 0, hdr, TSDB_FHDR_SIZE);
|
||||
|
@ -322,7 +363,7 @@ int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pS
|
|||
flag = TD_FILE_READ | TD_FILE_WRITE;
|
||||
}
|
||||
tsdbSmaFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fSma, fname);
|
||||
code = tsdbOpenFile(fname, szPage, flag, &pWriter->pSmaFD);
|
||||
code = tsdbOpenFile(fname, pTsdb, flag, &pWriter->pSmaFD);
|
||||
if (code) goto _err;
|
||||
if (pWriter->fSma.size == 0) {
|
||||
code = tsdbWriteFile(pWriter->pSmaFD, 0, hdr, TSDB_FHDR_SIZE);
|
||||
|
@ -335,7 +376,7 @@ int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pS
|
|||
ASSERT(pWriter->fStt[pSet->nSttF - 1].size == 0);
|
||||
flag = TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC;
|
||||
tsdbSttFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fStt[pSet->nSttF - 1], fname);
|
||||
code = tsdbOpenFile(fname, szPage, flag, &pWriter->pSttFD);
|
||||
code = tsdbOpenFile(fname, pTsdb, flag, &pWriter->pSttFD);
|
||||
if (code) goto _err;
|
||||
code = tsdbWriteFile(pWriter->pSttFD, 0, hdr, TSDB_FHDR_SIZE);
|
||||
if (code) goto _err;
|
||||
|
@ -907,23 +948,23 @@ int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pS
|
|||
|
||||
// head
|
||||
tsdbHeadFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pHeadF, fname);
|
||||
code = tsdbOpenFile(fname, szPage, TD_FILE_READ, &pReader->pHeadFD);
|
||||
code = tsdbOpenFile(fname, pTsdb, TD_FILE_READ, &pReader->pHeadFD);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// data
|
||||
tsdbDataFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pDataF, fname);
|
||||
code = tsdbOpenFile(fname, szPage, TD_FILE_READ, &pReader->pDataFD);
|
||||
code = tsdbOpenFile(fname, pTsdb, TD_FILE_READ, &pReader->pDataFD);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// sma
|
||||
tsdbSmaFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pSmaF, fname);
|
||||
code = tsdbOpenFile(fname, szPage, TD_FILE_READ, &pReader->pSmaFD);
|
||||
code = tsdbOpenFile(fname, pTsdb, TD_FILE_READ, &pReader->pSmaFD);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// stt
|
||||
for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
|
||||
tsdbSttFileName(pTsdb, pSet->diskId, pSet->fid, pSet->aSttF[iStt], fname);
|
||||
code = tsdbOpenFile(fname, szPage, TD_FILE_READ, &pReader->aSttFD[iStt]);
|
||||
code = tsdbOpenFile(fname, pTsdb, TD_FILE_READ, &pReader->aSttFD[iStt]);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
|
@ -1323,8 +1364,7 @@ int32_t tsdbDelFWriterOpen(SDelFWriter **ppWriter, SDelFile *pFile, STsdb *pTsdb
|
|||
pDelFWriter->fDel = *pFile;
|
||||
|
||||
tsdbDelFileName(pTsdb, pFile, fname);
|
||||
code = tsdbOpenFile(fname, pTsdb->pVnode->config.tsdbPageSize, TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE,
|
||||
&pDelFWriter->pWriteH);
|
||||
code = tsdbOpenFile(fname, pTsdb, TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE, &pDelFWriter->pWriteH);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// update header
|
||||
|
@ -1498,7 +1538,7 @@ int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb
|
|||
pDelFReader->fDel = *pFile;
|
||||
|
||||
tsdbDelFileName(pTsdb, pFile, fname);
|
||||
code = tsdbOpenFile(fname, pTsdb->pVnode->config.tsdbPageSize, TD_FILE_READ, &pDelFReader->pReadH);
|
||||
code = tsdbOpenFile(fname, pTsdb, TD_FILE_READ, &pDelFReader->pReadH);
|
||||
if (code) {
|
||||
taosMemoryFree(pDelFReader);
|
||||
goto _exit;
|
||||
|
|
|
@ -114,7 +114,7 @@ static int32_t tsdbCopyFileS3(SRTNer *rtner, const STFileObj *from, const STFile
|
|||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
char *object_name = taosDirEntryBaseName(fname);
|
||||
code = s3PutObjectFromFile(from->fname, object_name);
|
||||
code = s3PutObjectFromFile2(from->fname, object_name);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
taosCloseFile(&fdFrom);
|
||||
|
@ -372,6 +372,14 @@ static int32_t tsdbDoRetention2(void *arg) {
|
|||
|
||||
_exit:
|
||||
if (code) {
|
||||
if (TARRAY2_DATA(rtner->fopArr)) {
|
||||
TARRAY2_DESTROY(rtner->fopArr, NULL);
|
||||
}
|
||||
TFileSetArray **fsetArr = &rtner->fsetArr;
|
||||
if (fsetArr[0]) {
|
||||
tsdbFSDestroyCopySnapshot(&rtner->fsetArr);
|
||||
}
|
||||
|
||||
TSDB_ERROR_LOG(TD_VID(rtner->tsdb->pVnode), lino, code);
|
||||
}
|
||||
return code;
|
||||
|
|
|
@ -46,12 +46,12 @@ int32_t tsdbSttFileReaderOpen(const char *fname, const SSttFileReaderConfig *con
|
|||
|
||||
// open file
|
||||
if (fname) {
|
||||
code = tsdbOpenFile(fname, config->szPage, TD_FILE_READ, &reader[0]->fd);
|
||||
code = tsdbOpenFile(fname, config->tsdb, TD_FILE_READ, &reader[0]->fd);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
} else {
|
||||
char fname1[TSDB_FILENAME_LEN];
|
||||
tsdbTFileName(config->tsdb, config->file, fname1);
|
||||
code = tsdbOpenFile(fname1, config->szPage, TD_FILE_READ, &reader[0]->fd);
|
||||
code = tsdbOpenFile(fname1, config->tsdb, TD_FILE_READ, &reader[0]->fd);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
|
@ -705,7 +705,7 @@ static int32_t tsdbSttFWriterDoOpen(SSttFileWriter *writer) {
|
|||
char fname[TSDB_FILENAME_LEN];
|
||||
|
||||
tsdbTFileName(writer->config->tsdb, writer->file, fname);
|
||||
code = tsdbOpenFile(fname, writer->config->szPage, flag, &writer->fd);
|
||||
code = tsdbOpenFile(fname, writer->config->tsdb, flag, &writer->fd);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
uint8_t hdr[TSDB_FHDR_SIZE] = {0};
|
||||
|
|
|
@ -87,7 +87,7 @@ static int32_t tsdbUpgradeHead(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReader *
|
|||
char fname[TSDB_FILENAME_LEN];
|
||||
tsdbTFileName(tsdb, &file, fname);
|
||||
|
||||
code = tsdbOpenFile(fname, ctx->szPage, TD_FILE_READ | TD_FILE_WRITE, &ctx->fd);
|
||||
code = tsdbOpenFile(fname, tsdb, TD_FILE_READ | TD_FILE_WRITE, &ctx->fd);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// convert
|
||||
|
@ -257,7 +257,7 @@ static int32_t tsdbUpgradeSttFile(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReade
|
|||
code = tsdbTFileObjInit(tsdb, &file, &fobj);
|
||||
TSDB_CHECK_CODE(code, lino, _exit1);
|
||||
|
||||
code = tsdbOpenFile(fobj->fname, ctx->szPage, TD_FILE_READ | TD_FILE_WRITE, &ctx->fd);
|
||||
code = tsdbOpenFile(fobj->fname, tsdb, TD_FILE_READ | TD_FILE_WRITE, &ctx->fd);
|
||||
TSDB_CHECK_CODE(code, lino, _exit1);
|
||||
|
||||
for (int32_t iSttBlk = 0; iSttBlk < taosArrayGetSize(aSttBlk); iSttBlk++) {
|
||||
|
@ -408,8 +408,7 @@ static int32_t tsdbUpgradeOpenTombFile(STsdb *tsdb, STFileSet *fset, STsdbFD **f
|
|||
}
|
||||
|
||||
char fname[TSDB_FILENAME_LEN] = {0};
|
||||
code = tsdbOpenFile(fobj[0]->fname, tsdb->pVnode->config.tsdbPageSize,
|
||||
TD_FILE_READ | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_CREATE, fd);
|
||||
code = tsdbOpenFile(fobj[0]->fname, tsdb, TD_FILE_READ | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_CREATE, fd);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
uint8_t hdr[TSDB_FHDR_SIZE] = {0};
|
||||
|
|
|
@ -542,7 +542,7 @@ int32_t tsdbFidLevel(int32_t fid, STsdbKeepCfg *pKeepCfg, int64_t nowSec) {
|
|||
ASSERT(0);
|
||||
}
|
||||
|
||||
nowSec = nowSec - tsKeepTimeOffset * tsTickPerHour[pKeepCfg->precision];
|
||||
nowSec = nowSec - pKeepCfg->keepTimeOffset * tsTickPerHour[pKeepCfg->precision];
|
||||
|
||||
key = nowSec - pKeepCfg->keep0 * tsTickPerMin[pKeepCfg->precision];
|
||||
aFid[0] = tsdbKeyFid(key, pKeepCfg->days, pKeepCfg->precision);
|
||||
|
|
|
@ -35,7 +35,8 @@ const SVnodeCfg vnodeCfgDefault = {.vgId = -1,
|
|||
.maxRows = 4096,
|
||||
.keep2 = 5256000,
|
||||
.keep0 = 5256000,
|
||||
.keep1 = 5256000},
|
||||
.keep1 = 5256000,
|
||||
.keepTimeOffset = TSDB_DEFAULT_KEEP_TIME_OFFSET},
|
||||
.walCfg =
|
||||
{
|
||||
.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, "keep1", pCfg->tsdbCfg.keep1) < 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) {
|
||||
int32_t nRetention = 1;
|
||||
if (pCfg->tsdbCfg.retentions[1].freq > 0) {
|
||||
|
@ -219,6 +221,8 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
|||
if (code < 0) return -1;
|
||||
tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep2, code);
|
||||
if (code < 0) return -1;
|
||||
tjsonGetNumberValue(pJson, "keepTimeOffset", pCfg->tsdbCfg.keepTimeOffset, code);
|
||||
if (code < 0) return -1;
|
||||
SJson *pNodeRetentions = tjsonGetObjectItem(pJson, "retentions");
|
||||
int32_t nRetention = tjsonGetArraySize(pNodeRetentions);
|
||||
if (nRetention > TSDB_RETENTION_MAX) {
|
||||
|
|
|
@ -59,17 +59,19 @@ int32_t s3PutObjectFromFile(const char *file_str, const char *object_str) {
|
|||
cos_request_options_t *options = NULL;
|
||||
cos_string_t bucket, object, file;
|
||||
cos_table_t *resp_headers;
|
||||
int traffic_limit = 0;
|
||||
// int traffic_limit = 0;
|
||||
|
||||
cos_pool_create(&p, NULL);
|
||||
options = cos_request_options_create(p);
|
||||
s3InitRequestOptions(options, is_cname);
|
||||
cos_table_t *headers = NULL;
|
||||
/*
|
||||
if (traffic_limit) {
|
||||
// 限速值设置范围为819200 - 838860800,即100KB/s - 100MB/s,如果超出该范围将返回400错误
|
||||
headers = cos_table_make(p, 1);
|
||||
cos_table_add_int(headers, "x-cos-traffic-limit", 819200);
|
||||
}
|
||||
*/
|
||||
cos_str_set(&bucket, tsS3BucketName);
|
||||
cos_str_set(&file, file_str);
|
||||
cos_str_set(&object, object_str);
|
||||
|
@ -85,6 +87,47 @@ int32_t s3PutObjectFromFile(const char *file_str, const char *object_str) {
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t s3PutObjectFromFile2(const char *file_str, const char *object_str) {
|
||||
int32_t code = 0;
|
||||
cos_pool_t *p = NULL;
|
||||
int is_cname = 0;
|
||||
cos_status_t *s = NULL;
|
||||
cos_request_options_t *options = NULL;
|
||||
cos_string_t bucket, object, file;
|
||||
cos_table_t *resp_headers;
|
||||
int traffic_limit = 0;
|
||||
cos_table_t *headers = NULL;
|
||||
cos_resumable_clt_params_t *clt_params = NULL;
|
||||
|
||||
cos_pool_create(&p, NULL);
|
||||
options = cos_request_options_create(p);
|
||||
s3InitRequestOptions(options, is_cname);
|
||||
headers = cos_table_make(p, 0);
|
||||
cos_str_set(&bucket, tsS3BucketName);
|
||||
cos_str_set(&file, file_str);
|
||||
cos_str_set(&object, object_str);
|
||||
|
||||
// upload
|
||||
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);
|
||||
|
||||
log_status(s);
|
||||
if (!cos_status_is_ok(s)) {
|
||||
vError("s3: %d(%s)", s->code, s->error_msg);
|
||||
vError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
|
||||
code = TAOS_SYSTEM_ERROR(EIO);
|
||||
return code;
|
||||
}
|
||||
|
||||
cos_pool_destroy(p);
|
||||
|
||||
if (s->code != 200) {
|
||||
return code = s->code;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
void s3DeleteObjectsByPrefix(const char *prefix_str) {
|
||||
cos_pool_t *p = NULL;
|
||||
cos_request_options_t *options = NULL;
|
||||
|
@ -217,6 +260,77 @@ bool s3Get(const char *object_name, const char *path) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
int32_t s3GetObjectBlock(const char *object_name, int64_t offset, int64_t block_size, uint8_t **ppBlock) {
|
||||
int32_t code = 0;
|
||||
cos_pool_t *p = NULL;
|
||||
int is_cname = 0;
|
||||
cos_status_t *s = NULL;
|
||||
cos_request_options_t *options = NULL;
|
||||
cos_string_t bucket;
|
||||
cos_string_t object;
|
||||
cos_table_t *resp_headers;
|
||||
cos_table_t *headers = NULL;
|
||||
cos_buf_t *content = NULL;
|
||||
// cos_string_t file;
|
||||
// int traffic_limit = 0;
|
||||
char range_buf[64];
|
||||
|
||||
//创建内存池
|
||||
cos_pool_create(&p, NULL);
|
||||
|
||||
//初始化请求选项
|
||||
options = cos_request_options_create(p);
|
||||
// init_test_request_options(options, is_cname);
|
||||
s3InitRequestOptions(options, is_cname);
|
||||
cos_str_set(&bucket, tsS3BucketName);
|
||||
cos_str_set(&object, object_name);
|
||||
cos_list_t download_buffer;
|
||||
cos_list_init(&download_buffer);
|
||||
/*
|
||||
if (traffic_limit) {
|
||||
// 限速值设置范围为819200 - 838860800,单位默认为 bit/s,即800Kb/s - 800Mb/s,如果超出该范围将返回400错误
|
||||
headers = cos_table_make(p, 1);
|
||||
cos_table_add_int(headers, "x-cos-traffic-limit", 819200);
|
||||
}
|
||||
*/
|
||||
|
||||
headers = cos_table_create_if_null(options, headers, 1);
|
||||
apr_snprintf(range_buf, sizeof(range_buf), "bytes=%" APR_INT64_T_FMT "-%" APR_INT64_T_FMT, offset,
|
||||
offset + block_size - 1);
|
||||
apr_table_add(headers, COS_RANGE, range_buf);
|
||||
|
||||
s = cos_get_object_to_buffer(options, &bucket, &object, headers, NULL, &download_buffer, &resp_headers);
|
||||
log_status(s);
|
||||
if (!cos_status_is_ok(s)) {
|
||||
vError("s3: %d(%s)", s->code, s->error_msg);
|
||||
vError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
|
||||
code = TAOS_SYSTEM_ERROR(EIO);
|
||||
return code;
|
||||
}
|
||||
|
||||
// print_headers(resp_headers);
|
||||
int64_t len = 0;
|
||||
int64_t size = 0;
|
||||
int64_t pos = 0;
|
||||
cos_list_for_each_entry(cos_buf_t, content, &download_buffer, node) { len += cos_buf_size(content); }
|
||||
// char *buf = cos_pcalloc(p, (apr_size_t)(len + 1));
|
||||
char *buf = taosMemoryCalloc(1, (apr_size_t)(len));
|
||||
// buf[len] = '\0';
|
||||
cos_list_for_each_entry(cos_buf_t, content, &download_buffer, node) {
|
||||
size = cos_buf_size(content);
|
||||
memcpy(buf + pos, content->pos, (size_t)size);
|
||||
pos += size;
|
||||
}
|
||||
// cos_warn_log("Download data=%s", buf);
|
||||
|
||||
//销毁内存池
|
||||
cos_pool_destroy(p);
|
||||
|
||||
*ppBlock = buf;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int64_t size;
|
||||
int32_t atime;
|
||||
|
@ -333,10 +447,12 @@ long s3Size(const char *object_name) {
|
|||
int32_t s3Init() { return 0; }
|
||||
void s3CleanUp() {}
|
||||
int32_t s3PutObjectFromFile(const char *file, const char *object) { return 0; }
|
||||
int32_t s3PutObjectFromFile2(const char *file, const char *object) { return 0; }
|
||||
void s3DeleteObjectsByPrefix(const char *prefix) {}
|
||||
void s3DeleteObjects(const char *object_name[], int nobject) {}
|
||||
bool s3Exists(const char *object_name) { return false; }
|
||||
bool s3Get(const char *object_name, const char *path) { return false; }
|
||||
int32_t s3GetObjectBlock(const char *object_name, int64_t offset, int64_t size, uint8_t **ppBlock) { return 0; }
|
||||
void s3EvictCache(const char *path, long object_size) {}
|
||||
long s3Size(const char *object_name) { return 0; }
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue