Merge remote-tracking branch 'origin/3.0' into enh/TD-32938
This commit is contained in:
commit
36cbf6e1dd
|
@ -163,4 +163,12 @@ geos_c.h
|
|||
source/libs/parser/src/sql.c
|
||||
include/common/ttokenauto.h
|
||||
!packaging/smokeTest/pytest_require.txt
|
||||
tdengine-test-dir
|
||||
tdengine-test-dir/
|
||||
localtime.c
|
||||
private.h
|
||||
strftime.c
|
||||
tzdir.h
|
||||
tzfile.h
|
||||
coverage.info
|
||||
taos
|
||||
taosd
|
||||
|
|
|
@ -131,7 +131,7 @@ IF(TD_WINDOWS)
|
|||
SET(COMMON_FLAGS "/w /D_WIN32 /DWIN32 /Zi /MTd")
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO /FORCE:MULTIPLE")
|
||||
|
||||
# IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
|
||||
# SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# libuv
|
||||
ExternalProject_Add(libuv
|
||||
GIT_REPOSITORY https://github.com/libuv/libuv.git
|
||||
GIT_TAG v1.48.0
|
||||
GIT_TAG v1.49.2
|
||||
SOURCE_DIR "${TD_CONTRIB_DIR}/libuv"
|
||||
BINARY_DIR "${TD_CONTRIB_DIR}/libuv"
|
||||
CONFIGURE_COMMAND ""
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -18,14 +18,14 @@ create user user_name pass'password' [sysinfo {1|0}] [createdb {1|0}]
|
|||
The parameters are explained as follows.
|
||||
|
||||
- user_name: Up to 23 B long.
|
||||
- password: Up to 128 B long, valid characters include letters and numbers as well as special characters other than single and double quotes, apostrophes, backslashes, and spaces, and it cannot be empty.
|
||||
- password: The password must be between 8 and 16 characters long and include at least three types of characters from the following: uppercase letters, lowercase letters, numbers, and special characters. Special characters include `! @ # $ % ^ & * ( ) - _ + = [ ] { } : ; > < ? | ~ , .`.
|
||||
- sysinfo: Whether the user can view system information. 1 means they can view it, 0 means they cannot. System information includes server configuration information, various node information such as dnode, query node (qnode), etc., as well as storage-related information, etc. The default is to view system information.
|
||||
- createdb: Whether the user can create databases. 1 means they can create databases, 0 means they cannot. The default value is 0. // Supported starting from TDengine Enterprise version 3.3.2.0
|
||||
|
||||
The following SQL can create a user named test with the password 123456 who can view system information.
|
||||
The following SQL can create a user named test with the password abc123!@# who can view system information.
|
||||
|
||||
```sql
|
||||
create user test pass '123456' sysinfo 1
|
||||
create user test pass 'abc123!@#' sysinfo 1
|
||||
```
|
||||
|
||||
### Viewing Users
|
||||
|
|
|
@ -74,6 +74,9 @@ After modifying configuration file parameters, you need to restart the *taosd* s
|
|||
|maxNumOfDistinctRes | |Maximum number of distinct results allowed to return, default value 100,000, maximum allowed value 100 million|
|
||||
|queryBufferSize | |Not effective yet|
|
||||
|queryRspPolicy | |Query response strategy|
|
||||
|queryUseMemoryPool | |Whether query will use memory pool to manage memory, default value: 1 (on); 0: off, 1: on|
|
||||
|minReservedMemorySize | |The minimum reserved system available memory size, all memory except reserved can be used for queries, unit: MB, default reserved size is 20% of system physical memory, value range 1024-1000000000|
|
||||
|singleQueryMaxMemorySize| |The memory limit that a single query can use on a single node (dnode), exceeding this limit will return an error, unit: MB, default value: 0 (no limit), value range 0-1000000000|
|
||||
|filterScalarMode | |Force scalar filter mode, 0: off; 1: on, default value 0|
|
||||
|queryPlannerTrace | |Internal parameter, whether the query plan outputs detailed logs|
|
||||
|queryNodeChunkSize | |Internal parameter, chunk size of the query plan|
|
||||
|
|
|
@ -13,16 +13,16 @@ CREATE USER user_name PASS 'password' [SYSINFO {1|0}] [CREATEDB {1|0}];
|
|||
|
||||
The username can be up to 23 bytes long.
|
||||
|
||||
The password can be up to 31 bytes long. The password can include letters, numbers, and special characters except for single quotes, double quotes, backticks, backslashes, and spaces, and it cannot be an empty string.
|
||||
The password must be between 8 and 16 characters long and include at least three types of characters from the following: uppercase letters, lowercase letters, numbers, and special characters. Special characters include `! @ # $ % ^ & * ( ) - _ + = [ ] { } : ; > < ? | ~ , .`.
|
||||
|
||||
`SYSINFO` indicates whether the user can view system information. `1` means they can view, `0` means they have no permission to view. System information includes service configuration, dnode, vnode, storage, etc. The default value is `1`.
|
||||
|
||||
`CREATEDB` indicates whether the user can create databases. `1` means they can create databases, `0` means they have no permission to create databases. The default value is `0`. // Supported starting from TDengine Enterprise version 3.3.2.0
|
||||
|
||||
In the example below, we create a user with the password `123456` who can view system information.
|
||||
In the example below, we create a user with the password `abc123!@#` who can view system information.
|
||||
|
||||
```sql
|
||||
taos> create user test pass '123456' sysinfo 1;
|
||||
taos> create user test pass 'abc123!@#' sysinfo 1;
|
||||
Query OK, 0 of 0 rows affected (0.001254s)
|
||||
```
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ This document details the server error codes that may be encountered when using
|
|||
| 0x80000350 | User already exists | Create user, duplicate creation | Confirm if the operation is correct |
|
||||
| 0x80000351 | Invalid user | User does not exist | Confirm if the operation is correct |
|
||||
| 0x80000352 | Invalid user format | Incorrect format | Confirm if the operation is correct |
|
||||
| 0x80000353 | Invalid password format | Incorrect format | Confirm if the operation is correct |
|
||||
| 0x80000353 | Invalid password format | The password must be between 8 and 16 characters long and include at least three types of characters from the following: uppercase letters, lowercase letters, numbers, and special characters. | Confirm the format of the password string |
|
||||
| 0x80000354 | Can not get user from conn | Internal error | Report issue |
|
||||
| 0x80000355 | Too many users | (Enterprise only) Exceeding user limit | Adjust configuration |
|
||||
| 0x80000357 | Authentication failure | Incorrect password | Confirm if the operation is correct |
|
||||
|
@ -251,6 +251,7 @@ This document details the server error codes that may be encountered when using
|
|||
| 0x80000529 | Vnode is stopped | Vnode is closed | Report issue |
|
||||
| 0x80000530 | Duplicate write request | Duplicate write request, internal error | Report issue |
|
||||
| 0x80000531 | Vnode query is busy | Query is busy | Report issue |
|
||||
| 0x80000540 | Vnode already exist but Dbid not match | Internal error | Report issue |
|
||||
|
||||
## tsdb
|
||||
|
||||
|
@ -283,6 +284,9 @@ This document details the server error codes that may be encountered when using
|
|||
| 0x80000729 | Task message error | Query message error | Preserve the scene and logs, report issue on GitHub |
|
||||
| 0x8000072B | Task status error | Subquery status error | Preserve the scene and logs, report issue on GitHub |
|
||||
| 0x8000072F | Job not exist | Query JOB no longer exists | Preserve the scene and logs, report issue on GitHub |
|
||||
| 0x80000739 | Query memory upper limit is reached | Single query memory upper limit is reached | Modify memory upper limit size or optimize SQL |
|
||||
| 0x8000073A | Query memory exhausted | Query memory in dnode is exhausted | Limit concurrent queries or add more physical memory |
|
||||
| 0x8000073B | Timeout for long time no fetch | Query without fetch for a long time | Correct application to fetch data asap |
|
||||
|
||||
## grant
|
||||
|
||||
|
|
|
@ -16,15 +16,15 @@ create user user_name pass'password' [sysinfo {1|0}] [createdb {1|0}]
|
|||
```
|
||||
|
||||
相关参数说明如下。
|
||||
- user_name:最长为 23 B。
|
||||
- password:最长为 128 B,合法字符包括字母和数字以及单双引号、撇号、反斜杠和空格以外的特殊字符,且不可以为空。
|
||||
- user_name:用户名最长不超过 23 个字节。
|
||||
- password:密码长度必须为 8 到 16 位,并且至少包含大写字母、小写字母、数字、特殊字符中的三类。特殊字符包括 `! @ # $ % ^ & * ( ) - _ + = [ ] { } : ; > < ? | ~ , .`。
|
||||
- sysinfo :用户是否可以查看系统信息。1 表示可以查看,0 表示不可以查看。系统信息包括服务端配置信息、服务端各种节点信息,如 dnode、查询节点(qnode)等,以及与存储相关的信息等。默认为可以查看系统信息。
|
||||
- createdb:用户是否可以创建数据库。1 表示可以创建,0 表示不可以创建。缺省值为 0。// 从 TDengine 企业版 3.3.2.0 开始支持
|
||||
|
||||
如下 SQL 可以创建密码为 123456 且可以查看系统信息的用户 test。
|
||||
如下 SQL 可以创建密码为 abc123!@# 且可以查看系统信息的用户 test。
|
||||
|
||||
```sql
|
||||
create user test pass '123456' sysinfo 1
|
||||
create user test pass 'abc123!@#' sysinfo 1
|
||||
```
|
||||
|
||||
### 查看用户
|
||||
|
|
|
@ -70,6 +70,9 @@ taosd 命令行参数如下
|
|||
|maxNumOfDistinctRes | |允许返回的 distinct 结果最大行数,默认值 10 万,最大允许值 1 亿|
|
||||
|queryBufferSize | |暂不生效|
|
||||
|queryRspPolicy | |查询响应策略|
|
||||
|queryUseMemoryPool | |查询是否使用内存池管理内存,默认值:1(打开); 0: 关闭,1: 打开|
|
||||
|minReservedMemorySize | |最小预留的系统可用内存数量,除预留外的内存都可以被用于查询,单位:MB,默认预留大小为系统物理内存的 20%,取值范围 1024 - 1000000000|
|
||||
|singleQueryMaxMemorySize| |单个查询在单个节点(dnode)上可以使用的内存上限,超过该上限将返回错误,单位:MB,默认值:0(无上限),取值范围 0 - 1000000000|
|
||||
|filterScalarMode | |强制使用标量过滤模式,0:关闭;1:开启,默认值 0|
|
||||
|queryPlannerTrace | |内部参数,查询计划是否输出详细日志|
|
||||
|queryNodeChunkSize | |内部参数,查询计划的块大小|
|
||||
|
|
|
@ -54,7 +54,7 @@ taos> SET MAX_BINARY_DISPLAY_WIDTH <nn>;
|
|||
- -h HOST: 要连接的 TDengine 服务端所在服务器的 FQDN, 默认为连接本地服务
|
||||
- -P PORT: 指定服务端所用端口号
|
||||
- -u USER: 连接时使用的用户名
|
||||
- -p PASSWORD: 连接服务端时使用的密码
|
||||
- -p PASSWORD: 连接服务端时使用的密码,特殊字符如 `! & ( ) < > ; |` 需使用字符 `\` 进行转义处理
|
||||
- -?, --help: 打印出所有命令行参数
|
||||
|
||||
还有更多其他参数:
|
||||
|
|
|
@ -64,7 +64,8 @@ database_option: {
|
|||
- DURATION:数据文件存储数据的时间跨度。可以使用加单位的表示形式,如 DURATION 100h、DURATION 10d 等,支持 m(分钟)、h(小时)和 d(天)三个单位。不加时间单位时默认单位为天,如 DURATION 50 表示 50 天。
|
||||
- MAXROWS:文件块中记录的最大条数,默认为 4096 条。
|
||||
- MINROWS:文件块中记录的最小条数,默认为 100 条。
|
||||
- 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 会取最大的保存时间)。了解更多,请点击 [关于主键时间戳](https://docs.taosdata.com/reference/taos-sql/insert/)
|
||||
- KEEP:表示数据文件保存的天数,缺省值为 3650,取值范围 [1, 365000],且必须大于或等于 3 倍的 DURATION 参数值。数据库会自动删除保存时间超过 KEEP 值的数据从而释放存储空间。KEEP 可以使用加单位的表示形式,如 KEEP 100h、KEEP 10d 等,支持 m(分钟)、h(小时)和 d(天)三个单位。也可以不写单位,如 KEEP 50,此时默认单位为天。企业版支持[多级存储](../../operation/planning/#%E5%A4%9A%E7%BA%A7%E5%AD%98%E5%82%A8)功能, 因此, 可以设置多个保存时间(多个以英文逗号分隔,最多 3 个,满足 keep 0 \<= keep 1 \<= keep 2,如 KEEP 100h,100d,3650d); 社区版不支持多级存储功能(即使配置了多个保存时间, 也不会生效, KEEP 会取最大的保存时间)。了解更多,请点击 [关于主键时间戳](https://docs.taosdata.com/reference/taos-sql/insert/)
|
||||
|
||||
- KEEP_TIME_OFFSET:自 3.2.0.0 版本生效。删除或迁移保存时间超过 KEEP 值的数据的延迟执行时间,默认值为 0 (小时)。在数据文件保存时间超过 KEEP 后,删除或迁移操作不会立即执行,而会额外等待本参数指定的时间间隔,以实现与业务高峰期错开的目的。
|
||||
- STT_TRIGGER:表示落盘文件触发文件合并的个数。开源版本固定为 1,企业版本可设置范围为 1 到 16。对于少表高频写入场景,此参数建议使用默认配置;而对于多表低频写入场景,此参数建议配置较大的值。
|
||||
- SINGLE_STABLE:表示此数据库中是否只可以创建一个超级表,用于超级表列非常多的情况。
|
||||
|
|
|
@ -14,16 +14,16 @@ CREATE USER user_name PASS 'password' [SYSINFO {1|0}] [CREATEDB {1|0}];
|
|||
|
||||
用户名最长不超过 23 个字节。
|
||||
|
||||
密码最长不超过 31 个字节。密码可以包含字母、数字以及除单引号、双引号、反引号、反斜杠和空格以外的特殊字符,密码不能为空字符串。
|
||||
密码长度必须为 8 到 16 位,并且至少包含大写字母、小写字母、数字、特殊字符中的三类。特殊字符包括 `! @ # $ % ^ & * ( ) - _ + = [ ] { } : ; > < ? | ~ , .`。
|
||||
|
||||
`SYSINFO` 表示该用户是否能够查看系统信息。`1` 表示可以查看,`0` 表示无权查看。系统信息包括服务配置、dnode、vnode、存储等信息。缺省值为 `1`。
|
||||
|
||||
`CREATEDB` 表示该用户是否能够创建数据库。`1` 表示可以创建,`0` 表示无权创建。缺省值为 `0`。// 从 TDengine 企业版 3.3.2.0 开始支持
|
||||
|
||||
在下面的示例中,我们创建一个密码为 `123456` 且可以查看系统信息的用户。
|
||||
在下面的示例中,我们创建一个密码为 `abc123!@#` 且可以查看系统信息的用户。
|
||||
|
||||
```sql
|
||||
taos> create user test pass '123456' sysinfo 1;
|
||||
taos> create user test pass 'abc123!@#' sysinfo 1;
|
||||
Query OK, 0 of 0 rows affected (0.001254s)
|
||||
```
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ WKB规范请参考[Well-Known Binary (WKB)](https://libgeos.org/specifications/w
|
|||
|
||||
**原因**:程序没有找到依赖的本地函数库 taos。
|
||||
|
||||
**解决方法**:Windows 下可以将 C:\TDengine\driver\taos.dll 拷贝到 C:\Windows\System32\ 目录下,Linux 下将建立如下软链 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可,macOS 下需要建立软链 `ln -s /usr/local/lib/libtaos.dylib`。
|
||||
**解决方法**:Windows 下可以将 C:\TDengine\driver\taos.dll 拷贝到 C:\Windows\System32\ 目录下,Linux 下将建立如下软链 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可,macOS 下需要建立软链 `ln -s /usr/local/lib/libtaos.dylib /usr/lib/libtaos.dylib`。
|
||||
|
||||
3. java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ description: TDengine 服务端的错误码列表和详细说明
|
|||
| 0x80000350 | User already exists | Create user, 重复创建 | 确认操作是否正确 |
|
||||
| 0x80000351 | Invalid user | 用户不存在 | 确认操作是否正确 |
|
||||
| 0x80000352 | Invalid user format | 格式不正确 | 确认操作是否正确 |
|
||||
| 0x80000353 | Invalid password format | 格式不正确 | 确认操作是否正确 |
|
||||
| 0x80000353 | Invalid password format | 密码长度必须为 8 到 16 位,并且至少包含大写字母、小写字母、数字、特殊字符中的三类 | 确认密码字符串的格式 |
|
||||
| 0x80000354 | Can not get user from conn | 内部错误 | 上报issue |
|
||||
| 0x80000355 | Too many users | (仅企业版)用户数量超限 | 调整配置 |
|
||||
| 0x80000357 | Authentication failure | 密码不正确 | 确认操作是否正确 |
|
||||
|
@ -261,6 +261,7 @@ description: TDengine 服务端的错误码列表和详细说明
|
|||
| 0x80000529 | Vnode is stopped | Vnode 已经关闭 | 上报问题 |
|
||||
| 0x80000530 | Duplicate write request | 重复写入请求,内部错误 | 上报问题 |
|
||||
| 0x80000531 | Vnode query is busy | 查询忙碌 | 上报问题 |
|
||||
| 0x80000540 | Vnode already exist but Dbid not match | 内部错误 | 上报问题 |
|
||||
|
||||
|
||||
## tsdb
|
||||
|
@ -294,6 +295,9 @@ description: TDengine 服务端的错误码列表和详细说明
|
|||
| 0x80000729 | Task message error | 查询消息错误 | 保留现场和日志,github上报issue |
|
||||
| 0x8000072B | Task status error | 子查询状态错误 | 保留现场和日志,github上报issue |
|
||||
| 0x8000072F | Job not exist | 查询JOB已经不存在 | 保留现场和日志,github上报issue |
|
||||
| 0x80000739 | Query memory upper limit is reached | 单个查询达到内存使用上限 | 设置合理的内存上限或调整 SQL 语句 |
|
||||
| 0x8000073A | Query memory exhausted | dnode查询内存到达使用上限 | 设置合理的内存上限或调整并发查询量或增大系统内存 |
|
||||
| 0x8000073B | Timeout for long time no fetch | 查询被长时间中断未恢复 | 调整应用实现尽快 fetch 数据 |
|
||||
|
||||
## grant
|
||||
|
||||
|
|
|
@ -280,4 +280,12 @@ TDinsight插件中展示的数据是通过taosKeeper和taosAdapter服务收集
|
|||
https://docs.taosdata.com/reference/components/taosd/#%E7%9B%91%E6%8E%A7%E7%9B%B8%E5%85%B3
|
||||
您可以随时关闭该参数,只需要在taos.cfg 中修改telemetryReporting为 0,然后重启数据库服务即可。
|
||||
代码位于:https://github.com/taosdata/TDengine/blob/62e609c558deb764a37d1a01ba84bc35115a85a4/source/dnode/mnode/impl/src/mndTelem.c
|
||||
此外,对于安全性要求极高的企业版 TDengine Enterprise 来说,此参数不会工作。
|
||||
此外,对于安全性要求极高的企业版 TDengine Enterprise 来说,此参数不会工作。
|
||||
### 31 第一次连接集群时遇到“Sync leader is unreachable”怎么办?
|
||||
报这个错,说明第一次向集群的连接是成功的,但第一次访问的IP不是mnode的leader节点,客户端试图与leader建立连接时发生错误。客户端通过EP,也就是指定的fqdn与端口号寻找leader节点,常见的报错原因有两个:
|
||||
|
||||
- 集群中其他节点的端口没有打开
|
||||
- 客户端的hosts未正确配置
|
||||
|
||||
因此用户首先要检查服务端,集群的所有端口(原生连接默认6030,http连接默认6041)有无打开;其次是客户端的hosts文件中是否配置了集群所有节点的fqdn与IP信息。
|
||||
如仍无法解决,则需要联系涛思技术人员支持。
|
||||
|
|
|
@ -70,6 +70,18 @@ extern int32_t tsTagFilterResCacheSize;
|
|||
extern int32_t tsBypassFlag;
|
||||
|
||||
// queue & threads
|
||||
extern int32_t tsQueryMinConcurrentTaskNum;
|
||||
extern int32_t tsQueryMaxConcurrentTaskNum;
|
||||
extern int32_t tsQueryConcurrentTaskNum;
|
||||
extern int32_t tsSingleQueryMaxMemorySize;
|
||||
extern int8_t tsQueryUseMemoryPool;
|
||||
extern int8_t tsMemPoolFullFunc;
|
||||
//extern int32_t tsQueryBufferPoolSize;
|
||||
extern int32_t tsMinReservedMemorySize;
|
||||
extern int64_t tsCurrentAvailMemorySize;
|
||||
extern int8_t tsNeedTrim;
|
||||
extern int32_t tsQueryNoFetchTimeoutSec;
|
||||
extern int32_t tsNumOfQueryThreads;
|
||||
extern int32_t tsNumOfRpcThreads;
|
||||
extern int32_t tsNumOfRpcSessions;
|
||||
extern int32_t tsShareConnLimit;
|
||||
|
|
|
@ -2758,7 +2758,7 @@ int32_t tDeserializeSResFetchReq(void* buf, int32_t bufLen, SResFetchReq* pReq);
|
|||
|
||||
typedef struct {
|
||||
SMsgHead header;
|
||||
uint64_t sId;
|
||||
uint64_t clientId;
|
||||
} SSchTasksStatusReq;
|
||||
|
||||
typedef struct {
|
||||
|
@ -2788,7 +2788,7 @@ typedef struct SQueryNodeEpId {
|
|||
|
||||
typedef struct {
|
||||
SMsgHead header;
|
||||
uint64_t sId;
|
||||
uint64_t clientId;
|
||||
SQueryNodeEpId epId;
|
||||
SArray* taskAction; // SArray<STaskAction>
|
||||
} SSchedulerHbReq;
|
||||
|
|
|
@ -47,7 +47,7 @@ typedef int32_t (*GetQueueSizeFp)(void* pMgmt, int32_t vgId, EQueueType qtype);
|
|||
typedef int32_t (*SendReqFp)(const SEpSet* pEpSet, SRpcMsg* pMsg);
|
||||
typedef void (*SendRspFp)(SRpcMsg* pMsg);
|
||||
typedef void (*RegisterBrokenLinkArgFp)(struct SRpcMsg* pMsg);
|
||||
typedef void (*ReleaseHandleFp)(SRpcHandleInfo* pHandle, int8_t type);
|
||||
typedef void (*ReleaseHandleFp)(SRpcHandleInfo* pHandle, int8_t type, int32_t status);
|
||||
typedef void (*ReportStartup)(const char* name, const char* desc);
|
||||
|
||||
typedef struct {
|
||||
|
@ -76,7 +76,7 @@ int32_t tmsgSendReq(const SEpSet* epSet, SRpcMsg* pMsg);
|
|||
int32_t tmsgSendSyncReq(const SEpSet* epSet, SRpcMsg* pMsg);
|
||||
void tmsgSendRsp(SRpcMsg* pMsg);
|
||||
void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg);
|
||||
void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type);
|
||||
void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type, int32_t code);
|
||||
void tmsgReportStartup(const char* name, const char* desc);
|
||||
bool tmsgUpdateDnodeInfo(int32_t* dnodeId, int64_t* clusterId, char* fqdn, uint16_t* port);
|
||||
void tmsgUpdateDnodeEpSet(SEpSet* epset);
|
||||
|
|
|
@ -29,6 +29,9 @@ extern "C" {
|
|||
#define DS_BUF_FULL 2
|
||||
#define DS_BUF_EMPTY 3
|
||||
|
||||
#define DS_FLAG_USE_MEMPOOL (1 << 0)
|
||||
|
||||
|
||||
struct SSDataBlock;
|
||||
|
||||
typedef struct SDeleterRes {
|
||||
|
@ -84,7 +87,7 @@ typedef struct SOutputData {
|
|||
* @param pHandle output
|
||||
* @return error code
|
||||
*/
|
||||
int32_t dsCreateDataSinker(void* pSinkManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, void* pParam, const char* id);
|
||||
int32_t dsCreateDataSinker(void* pSinkManager, SDataSinkNode** ppDataSink, DataSinkHandle* pHandle, void* pParam, const char* id);
|
||||
|
||||
int32_t dsDataSinkGetCacheSize(SDataSinkStat* pStat);
|
||||
|
||||
|
@ -131,6 +134,9 @@ void dsScheduleProcess(void* ahandle, void* pItem);
|
|||
*/
|
||||
void dsDestroyDataSinker(DataSinkHandle handle);
|
||||
|
||||
int32_t dsGetSinkFlags(DataSinkHandle handle, uint64_t* pFlags);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -58,6 +58,7 @@ typedef struct {
|
|||
|
||||
struct SStorageAPI api;
|
||||
void* pWorkerCb;
|
||||
bool localExec;
|
||||
} SReadHandle;
|
||||
|
||||
// in queue mode, data streams are seperated by msg
|
||||
|
@ -167,6 +168,7 @@ int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bo
|
|||
|
||||
int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pBlock, uint64_t* useconds);
|
||||
|
||||
int32_t qExecutorInit(void);
|
||||
void qResetTaskCode(qTaskInfo_t tinfo);
|
||||
|
||||
void qCleanExecTaskBlockBuf(qTaskInfo_t tinfo);
|
||||
|
|
|
@ -631,7 +631,7 @@ typedef struct SDownstreamSourceNode {
|
|||
SQueryNodeAddr addr;
|
||||
uint64_t clientId;
|
||||
uint64_t taskId;
|
||||
uint64_t schedId;
|
||||
uint64_t sId;
|
||||
int32_t execId;
|
||||
int32_t fetchMsgType;
|
||||
bool localExec;
|
||||
|
|
|
@ -113,6 +113,11 @@ int32_t qWorkerProcessLocalFetch(void *pMgmt, uint64_t sId, uint64_t qId, uint64
|
|||
|
||||
int32_t qWorkerDbgEnableDebug(char *option);
|
||||
|
||||
void qWorkerRetireJob(uint64_t jobId, uint64_t clientId, int32_t errCode);
|
||||
|
||||
void qWorkerRetireJobs(int64_t retireSize, int32_t errCode);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -171,7 +171,7 @@ void *rpcReallocCont(void *ptr, int64_t contLen);
|
|||
int32_t rpcSendRequest(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid);
|
||||
int32_t rpcSendResponse(const SRpcMsg *pMsg);
|
||||
int32_t rpcRegisterBrokenLinkArg(SRpcMsg *msg);
|
||||
int32_t rpcReleaseHandle(void *handle, int8_t type); // just release conn to rpc instance, no close sock
|
||||
int32_t rpcReleaseHandle(void *handle, int8_t type, int32_t code); // just release conn to rpc instance, no close sock
|
||||
|
||||
// These functions will not be called in the child process
|
||||
int32_t rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid, SRpcCtx *ctx);
|
||||
|
|
|
@ -110,6 +110,7 @@ extern "C" {
|
|||
#include "osLz4.h"
|
||||
#include "osMath.h"
|
||||
#include "osMemory.h"
|
||||
#include "osMemPool.h"
|
||||
#include "osRand.h"
|
||||
#include "osSemaphore.h"
|
||||
#include "osSignal.h"
|
||||
|
|
|
@ -0,0 +1,206 @@
|
|||
/*
|
||||
* 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_OS_MEMPOOL_H_
|
||||
#define _TD_OS_MEMPOOL_H_
|
||||
|
||||
#include "os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MEMPOOL_MAX_CHUNK_SIZE (1 << 30)
|
||||
#define MEMPOOL_MIN_CHUNK_SIZE (1 << 20)
|
||||
|
||||
typedef enum MemPoolEvictPolicy {
|
||||
E_EVICT_ALL = 1,
|
||||
E_EVICT_NONE,
|
||||
E_EVICT_AUTO,
|
||||
E_EVICT_MAX_VALUE, // no used
|
||||
} MemPoolEvictPolicy;
|
||||
|
||||
typedef struct SMemPoolJob {
|
||||
uint64_t jobId;
|
||||
uint64_t clientId;
|
||||
|
||||
int32_t remainSession;
|
||||
|
||||
int64_t allocMemSize;
|
||||
int64_t maxAllocMemSize;
|
||||
} SMemPoolJob;
|
||||
|
||||
typedef struct SMPStatItem {
|
||||
int64_t inErr;
|
||||
int64_t exec;
|
||||
int64_t succ;
|
||||
int64_t fail;
|
||||
} SMPStatItem;
|
||||
|
||||
typedef struct SMPStatItemExt {
|
||||
int64_t inErr;
|
||||
int64_t exec;
|
||||
int64_t succ;
|
||||
int64_t fail;
|
||||
int64_t origExec;
|
||||
int64_t origSucc;
|
||||
int64_t origFail;
|
||||
} SMPStatItemExt;
|
||||
|
||||
typedef struct SMPMemoryStat {
|
||||
SMPStatItem memMalloc;
|
||||
SMPStatItem memCalloc;
|
||||
SMPStatItemExt memRealloc;
|
||||
SMPStatItem memStrdup;
|
||||
SMPStatItem memStrndup;
|
||||
SMPStatItem memFree;
|
||||
SMPStatItem memTrim;
|
||||
|
||||
SMPStatItem chunkMalloc;
|
||||
SMPStatItem chunkRecycle;
|
||||
SMPStatItem chunkReUse;
|
||||
SMPStatItem chunkFree;
|
||||
} SMPMemoryStat;
|
||||
|
||||
typedef struct SMPStatDetail {
|
||||
SMPMemoryStat times;
|
||||
SMPMemoryStat bytes;
|
||||
} SMPStatDetail;
|
||||
|
||||
|
||||
typedef void (*mpDecConcSessionNum)(void);
|
||||
typedef void (*mpIncConcSessionNum)(void);
|
||||
typedef void (*mpSetConcSessionNum)(int32_t);
|
||||
typedef void (*mpReserveFailFp)(int64_t, int32_t);
|
||||
typedef void (*mpReserveReachFp)(uint64_t, uint64_t, int32_t);
|
||||
typedef void (*mpCfgUpdate)(void*, void*);
|
||||
|
||||
typedef struct SMemPoolCallBack {
|
||||
//mpDecConcSessionNum decSessFp;
|
||||
//mpIncConcSessionNum incSessFp;
|
||||
//mpSetConcSessionNum setSessFp;
|
||||
mpReserveFailFp failFp;
|
||||
mpReserveReachFp reachFp;
|
||||
//mpCfgUpdate cfgUpdateFp;
|
||||
} SMemPoolCallBack;
|
||||
|
||||
|
||||
typedef struct SMemPoolCfg {
|
||||
//bool reserveMode;
|
||||
int64_t reserveSize;
|
||||
//int32_t *upperLimitSize; //MB
|
||||
//int64_t retireUnitSize;
|
||||
int32_t *jobQuota; //MB
|
||||
int32_t chunkSize;
|
||||
int32_t threadNum;
|
||||
MemPoolEvictPolicy evicPolicy;
|
||||
SMemPoolCallBack cb;
|
||||
} SMemPoolCfg;
|
||||
|
||||
#define MEMPOOL_GET_ALLOC_SIZE(_dstat) ((_dstat)->bytes.memMalloc.succ + (_dstat)->bytes.memCalloc.succ + (_dstat)->bytes.memRealloc.succ + (_dstat)->bytes.memStrdup.succ + (_dstat)->bytes.memStrndup.succ)
|
||||
#define MEMPOOL_GET_FREE_SIZE(_dstat) ((_dstat)->bytes.memRealloc.origSucc + (_dstat)->bytes.memFree.succ)
|
||||
#define MEMPOOL_GET_USED_SIZE(_dstat) (MEMPOOL_GET_ALLOC_SIZE(_dstat) - MEMPOOL_GET_FREE_SIZE(_dstat))
|
||||
|
||||
|
||||
int32_t taosMemPoolOpen(char* poolName, SMemPoolCfg* cfg, void** poolHandle);
|
||||
void *taosMemPoolMalloc(void* poolHandle, void* session, int64_t size, char* fileName, int32_t lineNo);
|
||||
void *taosMemPoolCalloc(void* poolHandle, void* session, int64_t num, int64_t size, char* fileName, int32_t lineNo);
|
||||
void *taosMemPoolRealloc(void* poolHandle, void* session, void *ptr, int64_t size, char* fileName, int32_t lineNo);
|
||||
char *taosMemPoolStrdup(void* poolHandle, void* session, const char *ptr, char* fileName, int32_t lineNo);
|
||||
char *taosMemPoolStrndup(void* poolHandle, void* session, const char *ptr, int64_t size, char* fileName, int32_t lineNo);
|
||||
void taosMemPoolFree(void* poolHandle, void* session, void *ptr, char* fileName, int32_t lineNo);
|
||||
int64_t taosMemPoolGetMemorySize(void* poolHandle, void* session, void *ptr, char* fileName, int32_t lineNo);
|
||||
int32_t taosMemPoolTrim(void* poolHandle, void* session, int32_t size, char* fileName, int32_t lineNo, bool* trimed);
|
||||
void *taosMemPoolMallocAlign(void* poolHandle, void* session, uint32_t alignment, int64_t size, char* fileName, int32_t lineNo);
|
||||
void taosMemPoolClose(void* poolHandle);
|
||||
void taosMemPoolModDestroy(void);
|
||||
void taosAutoMemoryFree(void *ptr);
|
||||
int32_t taosMemPoolInitSession(void* poolHandle, void** ppSession, void* pJob, char *sessionId);
|
||||
void taosMemPoolDestroySession(void* poolHandle, void* session);
|
||||
int32_t taosMemPoolCallocJob(uint64_t jobId, uint64_t cId, void** ppJob);
|
||||
void taosMemPoolCfgUpdate(void* poolHandle, SMemPoolCfg* pCfg);
|
||||
void taosMemPoolPrintStat(void* poolHandle, void* session, char* procName);
|
||||
int32_t taosMemPoolTryLockPool(void* poolHandle, bool readLock);
|
||||
void taosMemPoolUnLockPool(void* poolHandle, bool readLock);
|
||||
void taosMemPoolGetUsedSizeBegin(void* poolHandle, int64_t* usedSize, bool* needEnd);
|
||||
void taosMemPoolGetUsedSizeEnd(void* poolHandle);
|
||||
int32_t taosMemPoolGetSessionStat(void* session, SMPStatDetail** ppStat, int64_t* allocSize, int64_t* maxAllocSize);
|
||||
void taosMemPoolSchedTrim(void);
|
||||
int32_t taosMemoryPoolInit(mpReserveFailFp, mpReserveReachFp);
|
||||
|
||||
|
||||
#define taosMemPoolFreeClear(ptr) \
|
||||
do { \
|
||||
if (ptr) { \
|
||||
taosMemPoolFree((void *)ptr); \
|
||||
(ptr) = NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#ifndef BUILD_TEST
|
||||
extern void* gMemPoolHandle;
|
||||
extern threadlocal void* threadPoolSession;
|
||||
extern threadlocal bool threadPoolEnabled;
|
||||
extern int8_t tsMemPoolFullFunc;
|
||||
|
||||
|
||||
#define taosEnableMemPoolUsage(_session) do { threadPoolSession = _session; tsEnableRandErr = true;} while (0)
|
||||
#define taosDisableMemPoolUsage() do { threadPoolSession = NULL; tsEnableRandErr = false;} while (0)
|
||||
|
||||
#define taosSaveDisableMemPoolUsage(_enable, _randErr) do { (_enable) = threadPoolEnabled; (_randErr) = tsEnableRandErr; threadPoolEnabled = false; tsEnableRandErr = false;} while (0)
|
||||
#define taosRestoreEnableMemPoolUsage(_enable, _randErr) do { threadPoolEnabled = (_enable); tsEnableRandErr = (_randErr);} while (0)
|
||||
|
||||
|
||||
#define taosMemoryMalloc(_size) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolMalloc(gMemPoolHandle, threadPoolSession, _size, (char*)__FILE__, __LINE__)) : (taosMemMalloc(_size)))
|
||||
#define taosMemoryCalloc(_num, _size) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolCalloc(gMemPoolHandle, threadPoolSession, _num, _size, (char*)__FILE__, __LINE__)) : (taosMemCalloc(_num, _size)))
|
||||
#define taosMemoryRealloc(_ptr, _size) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolRealloc(gMemPoolHandle, threadPoolSession, _ptr, _size, (char*)__FILE__, __LINE__)) : (taosMemRealloc(_ptr, _size)))
|
||||
#define taosStrdup(_ptr) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolStrdup(gMemPoolHandle, threadPoolSession, _ptr, (char*)__FILE__, __LINE__)) : (taosStrdupi(_ptr)))
|
||||
#define taosStrndup(_ptr, _size) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolStrndup(gMemPoolHandle, threadPoolSession, _ptr, _size, (char*)__FILE__, __LINE__)) : (taosStrndupi(_ptr, _size)))
|
||||
#define taosMemoryFree(_ptr) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolFree(gMemPoolHandle, threadPoolSession, _ptr, (char*)__FILE__, __LINE__)) : (taosMemFree(_ptr)))
|
||||
#define taosMemorySize(_ptr) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolGetMemorySize(gMemPoolHandle, threadPoolSession, _ptr, (char*)__FILE__, __LINE__)) : (taosMemSize(_ptr)))
|
||||
#define taosMemoryTrim(_size, _trimed) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolTrim(gMemPoolHandle, threadPoolSession, _size, (char*)__FILE__, __LINE__, _trimed)) : (taosMemTrim(_size, _trimed)))
|
||||
#define taosMemoryMallocAlign(_alignment, _size) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolMallocAlign(gMemPoolHandle, threadPoolSession, _alignment, _size, (char*)__FILE__, __LINE__)) : (taosMemMallocAlign(_alignment, _size)))
|
||||
#else
|
||||
#define taosEnableMemoryPoolUsage(_pool, _session)
|
||||
#define taosDisableMemoryPoolUsage()
|
||||
#define taosSaveDisableMemoryPoolUsage()
|
||||
#define taosRestoreEnableMemoryPoolUsage()
|
||||
|
||||
#define taosMemoryMalloc(_size) taosMemMalloc(_size)
|
||||
#define taosMemoryCalloc(_num, _size) taosMemCalloc(_num, _size)
|
||||
#define taosMemoryRealloc(_ptr, _size) taosMemRealloc(_ptr, _size)
|
||||
#define taosStrdup(_ptr) taosStrdupi(_ptr)
|
||||
#define taosStrndup(_ptr, _size) taosStrndupi(_ptr, _size)
|
||||
#define taosMemoryFree(_ptr) taosMemFree(_ptr)
|
||||
#define taosMemorySize(_ptr) taosMemSize(_ptr)
|
||||
#define taosMemoryTrim(_size, _trimed) taosMemTrim(_size, _trimed)
|
||||
#define taosMemoryMallocAlign(_alignment, _size) taosMemMallocAlign(_alignment, _size)
|
||||
|
||||
#endif
|
||||
|
||||
#define taosMemoryFreeClear(ptr) \
|
||||
do { \
|
||||
if (ptr) { \
|
||||
taosMemoryFree((void *)ptr); \
|
||||
(ptr) = NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_OS_MEMPOOL_H_*/
|
|
@ -36,35 +36,32 @@ extern "C" {
|
|||
#endif // ifndef ALLOW_FORBID_FUNC
|
||||
#endif // if !defined(WINDOWS)
|
||||
|
||||
// #define taosMemoryMalloc malloc
|
||||
// #define taosMemoryCalloc calloc
|
||||
// #define taosMemoryRealloc realloc
|
||||
// #define taosMemoryFree free
|
||||
|
||||
int32_t taosMemoryDbgInit();
|
||||
int32_t taosMemoryDbgInitRestore();
|
||||
void *taosMemoryMalloc(int64_t size);
|
||||
void *taosMemoryCalloc(int64_t num, int64_t size);
|
||||
void *taosMemoryRealloc(void *ptr, int64_t size);
|
||||
char *taosStrdup(const char *ptr);
|
||||
void taosMemoryFree(void *ptr);
|
||||
int64_t taosMemorySize(void *ptr);
|
||||
void *taosMemMalloc(int64_t size);
|
||||
void *taosMemCalloc(int64_t num, int64_t size);
|
||||
void *taosMemRealloc(void *ptr, int64_t size);
|
||||
char *taosStrdupi(const char *ptr);
|
||||
char *taosStrndupi(const char *ptr, int64_t size);
|
||||
void taosMemFree(void *ptr);
|
||||
int64_t taosMemSize(void *ptr);
|
||||
void taosPrintBackTrace();
|
||||
void taosMemoryTrim(int32_t size);
|
||||
void *taosMemoryMallocAlign(uint32_t alignment, int64_t size);
|
||||
int32_t taosMemTrim(int32_t size, bool* trimed);
|
||||
void *taosMemMallocAlign(uint32_t alignment, int64_t size);
|
||||
|
||||
#define TAOS_MEMSET(_s, _c, _n) ((void)memset(_s, _c, _n))
|
||||
#define TAOS_MEMCPY(_d, _s, _n) ((void)memcpy(_d, _s, _n))
|
||||
#define TAOS_MEMMOVE(_d, _s, _n) ((void)memmove(_d, _s, _n))
|
||||
|
||||
#define taosMemoryFreeClear(ptr) \
|
||||
#define taosMemFreeClear(ptr) \
|
||||
do { \
|
||||
if (ptr) { \
|
||||
taosMemoryFree((void *)ptr); \
|
||||
taosMemFree((void *)ptr); \
|
||||
(ptr) = NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#include "osMemPool.h"
|
||||
#define TAOS_MEMORY_REALLOC(ptr, len) \
|
||||
do { \
|
||||
void *tmp = taosMemoryRealloc(ptr, (len)); \
|
||||
|
|
|
@ -25,7 +25,7 @@ typedef int32_t TdUcs4;
|
|||
#if !defined(DISALLOW_NCHAR_WITHOUT_ICONV)// && defined(DARWIN)
|
||||
#include "iconv.h"
|
||||
#else
|
||||
typedef void *iconv_t;
|
||||
typedef void *iconv_t;
|
||||
#endif
|
||||
typedef enum { M2C = 0, C2M, CM_NUM } ConvType;
|
||||
|
||||
|
@ -67,29 +67,35 @@ typedef struct {
|
|||
#ifdef strndup
|
||||
#undef strndup
|
||||
#endif
|
||||
#define strndup STR_TO_F_FUNC_TAOS_FORBID
|
||||
#define strndup STR_TO_F_FUNC_TAOS_FORBID
|
||||
|
||||
#endif
|
||||
|
||||
#define tstrncpy(dst, src, size) \
|
||||
do { \
|
||||
(void)strncpy((dst), (src), (size)); \
|
||||
(dst)[(size) - 1] = 0; \
|
||||
(dst)[(size)-1] = 0; \
|
||||
} while (0)
|
||||
|
||||
int64_t tsnprintf(char *dst, int64_t size, const char *format, ...);
|
||||
#define TAOS_STRCPY(_dst, _src) ((void)strcpy(_dst, _src))
|
||||
#define TAOS_STRCPY(_dst, _src) ((void)strcpy(_dst, _src))
|
||||
#define TAOS_STRNCPY(_dst, _src, _size) ((void)strncpy(_dst, _src, _size))
|
||||
#define TAOS_STRCAT(_dst, _src) ((void)strcat(_dst, _src))
|
||||
#define TAOS_STRNCAT(_dst, _src, len) ((void)strncat(_dst, _src, len))
|
||||
#define TAOS_STRCAT(_dst, _src) ((void)strcat(_dst, _src))
|
||||
#define TAOS_STRNCAT(_dst, _src, len) ((void)strncat(_dst, _src, len))
|
||||
|
||||
char *tstrdup(const char *src);
|
||||
char *tstrndup(const char *str, int64_t size);
|
||||
int32_t taosUcs4len(TdUcs4 *ucs4);
|
||||
int32_t taosStr2int64(const char *str, int64_t *val);
|
||||
int32_t taosStr2int16(const char *str, int16_t *val);
|
||||
int32_t taosStr2int32(const char *str, int32_t *val);
|
||||
int32_t taosStr2int16(const char *str, int16_t *val);
|
||||
int32_t taosStr2int8(const char *str, int8_t *val);
|
||||
|
||||
int32_t taosStr2Uint64(const char *str, uint64_t *val);
|
||||
int32_t taosStr2Uint32(const char *str, uint32_t *val);
|
||||
int32_t taosStr2Uint16(const char *str, uint16_t *val);
|
||||
int32_t taosStr2Uint8(const char *str, uint8_t *val);
|
||||
|
||||
iconv_t taosAcquireConv(int32_t *idx, ConvType type, void* charsetCxt);
|
||||
void taosReleaseConv(int32_t idx, iconv_t conv, ConvType type, void* charsetCxt);
|
||||
int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs, void* charsetCxt);
|
||||
|
@ -121,10 +127,9 @@ double taosStr2Double(const char *str, char **pEnd);
|
|||
float taosStr2Float(const char *str, char **pEnd);
|
||||
int32_t taosHex2Ascii(const char *z, uint32_t n, void **data, uint32_t *size);
|
||||
int32_t taosAscii2Hex(const char *z, uint32_t n, void **data, uint32_t *size);
|
||||
char *taosStrndup(const char *s, int n);
|
||||
//int32_t taosBin2Ascii(const char *z, uint32_t n, void** data, uint32_t* size);
|
||||
bool isHex(const char* z, uint32_t n);
|
||||
bool isValidateHex(const char* z, uint32_t n);
|
||||
// int32_t taosBin2Ascii(const char *z, uint32_t n, void** data, uint32_t* size);
|
||||
bool isHex(const char *z, uint32_t n);
|
||||
bool isValidateHex(const char *z, uint32_t n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ int32_t taosGetCpuInstructions(char* sse42, char* avx, char* avx2, char* fma, ch
|
|||
int32_t taosGetTotalMemory(int64_t *totalKB);
|
||||
int32_t taosGetProcMemory(int64_t *usedKB);
|
||||
int32_t taosGetSysMemory(int64_t *usedKB);
|
||||
int32_t taosGetSysAvailMemory(int64_t *availSize);
|
||||
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize);
|
||||
int32_t taosGetProcIODelta(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, int64_t *write_bytes);
|
||||
void taosSetDefaultProcIODelta(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, int64_t *write_bytes);
|
||||
|
|
|
@ -565,6 +565,7 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_VND_ARB_NOT_SYNCED TAOS_DEF_ERROR_CODE(0, 0x0537) // internal
|
||||
#define TSDB_CODE_VND_WRITE_DISABLED TAOS_DEF_ERROR_CODE(0, 0x0538) // internal
|
||||
#define TSDB_CODE_VND_TTL_FLUSH_INCOMPLETION TAOS_DEF_ERROR_CODE(0, 0x0539) // internal
|
||||
#define TSDB_CODE_VND_ALREADY_EXIST_BUT_NOT_MATCH TAOS_DEF_ERROR_CODE(0, 0x0540)
|
||||
|
||||
// tsdb
|
||||
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
|
||||
|
@ -643,6 +644,9 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_QRY_FILTER_RANGE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0736)
|
||||
#define TSDB_CODE_QRY_FILTER_INVALID_TYPE TAOS_DEF_ERROR_CODE(0, 0x0737)
|
||||
#define TSDB_CODE_QRY_TASK_SUCC_TO_PARTSUSS TAOS_DEF_ERROR_CODE(0, 0x0738)
|
||||
#define TSDB_CODE_QRY_REACH_QMEM_THRESHOLD TAOS_DEF_ERROR_CODE(0, 0x0739)
|
||||
#define TSDB_CODE_QRY_QUERY_MEM_EXHAUSTED TAOS_DEF_ERROR_CODE(0, 0x073A)
|
||||
#define TSDB_CODE_QRY_NO_FETCH_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x073B)
|
||||
|
||||
// grant
|
||||
#define TSDB_CODE_GRANT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0800)
|
||||
|
|
|
@ -119,6 +119,7 @@ void cfgUnLock(SConfig *pCfg);
|
|||
|
||||
// clang-format off
|
||||
int32_t cfgAddBool(SConfig *pCfg, const char *name, bool defaultVal, int8_t scope, int8_t dynScope);
|
||||
int32_t cfgAddInt32Ex(SConfig *pCfg, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval, int8_t scope, int8_t dynScope);
|
||||
int32_t cfgAddInt32(SConfig *pCfg, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval, int8_t scope, int8_t dynScope);
|
||||
int32_t cfgAddInt64(SConfig *pCfg, const char *name, int64_t defaultVal, int64_t minval, int64_t maxval, int8_t scope, int8_t dynScope);
|
||||
int32_t cfgAddFloat(SConfig *pCfg, const char *name, float defaultVal, float minval, float maxval, int8_t scope, int8_t dynScope);
|
||||
|
|
|
@ -318,6 +318,8 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_MAX_JSON_KEY_LEN 256
|
||||
|
||||
#define TSDB_AUTH_LEN 16
|
||||
#define TSDB_PASSWORD_MIN_LEN 8
|
||||
#define TSDB_PASSWORD_MAX_LEN 16
|
||||
#define TSDB_PASSWORD_LEN 32
|
||||
#define TSDB_USET_PASSWORD_LEN 129
|
||||
#define TSDB_VERSION_LEN 32
|
||||
|
@ -674,6 +676,8 @@ typedef enum {
|
|||
ANAL_ALGO_TYPE_END,
|
||||
} EAnalAlgoType;
|
||||
|
||||
#define MIN_RESERVE_MEM_SIZE 1024 // MB
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -87,6 +87,8 @@ BoundedQueue* createBoundedQueue(uint32_t maxSize, pq_comp_fn fn, FDelete delete
|
|||
|
||||
void taosBQSetFn(BoundedQueue* q, pq_comp_fn fn);
|
||||
|
||||
void taosBQClear(BoundedQueue* q);
|
||||
|
||||
void destroyBoundedQueue(BoundedQueue* q);
|
||||
|
||||
/*
|
||||
|
|
|
@ -72,6 +72,7 @@ void taosInitRWLatch(SRWLatch *pLatch);
|
|||
void taosWLockLatch(SRWLatch *pLatch);
|
||||
void taosWUnLockLatch(SRWLatch *pLatch);
|
||||
void taosRLockLatch(SRWLatch *pLatch);
|
||||
int32_t taosRTryLockLatch(SRWLatch *pLatch);
|
||||
void taosRUnLockLatch(SRWLatch *pLatch);
|
||||
int32_t taosWTryLockLatch(SRWLatch *pLatch);
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ int32_t taosInitLog(const char *logName, int32_t maxFiles, bool tsc);
|
|||
void taosCloseLog();
|
||||
void taosResetLog();
|
||||
void taosDumpData(uint8_t *msg, int32_t len);
|
||||
void taosSetNoNewFile();
|
||||
|
||||
void taosPrintLog(const char *flags, int32_t level, int32_t dflag, const char *format, ...)
|
||||
#ifdef __GNUC__
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* 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_UTIL_MEMPOOL_H_
|
||||
#define _TD_UTIL_MEMPOOL_H_
|
||||
|
||||
#include "os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void *mpool_h;
|
||||
|
||||
mpool_h taosMemPoolInit(int32_t maxNum, int32_t blockSize);
|
||||
char *taosMemPoolMalloc(mpool_h handle);
|
||||
void taosMemPoolFree(mpool_h handle, char *p);
|
||||
void taosMemPoolCleanUp(mpool_h handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_UTIL_MEMPOOL_H_*/
|
|
@ -50,7 +50,7 @@ typedef struct SDiskbasedBufStatis {
|
|||
* @param handle
|
||||
* @return
|
||||
*/
|
||||
int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMemBufSize, const char* id,
|
||||
int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int64_t inMemBufSize, const char* id,
|
||||
const char* dir);
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,6 +39,8 @@ bool taosTmrStop(tmr_h tmrId);
|
|||
|
||||
bool taosTmrStopA(tmr_h *tmrId);
|
||||
|
||||
bool taosTmrIsStopped(tmr_h* timerId);
|
||||
|
||||
bool taosTmrReset(TAOS_TMR_CALLBACK fp, int32_t mseconds, void *param, void *handle, tmr_h *pTmrId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -227,6 +227,11 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
|||
|
||||
#define TAOS_UNUSED(expr) (void)(expr)
|
||||
|
||||
bool taosIsBigChar(char c);
|
||||
bool taosIsSmallChar(char c);
|
||||
bool taosIsNumberChar(char c);
|
||||
bool taosIsSpecialChar(char c);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -689,7 +689,7 @@ void doDestroyRequest(void *p) {
|
|||
SRequestObj *pRequest = (SRequestObj *)p;
|
||||
|
||||
uint64_t reqId = pRequest->requestId;
|
||||
tscTrace("begin to destroy request %" PRIx64 " p:%p", reqId, pRequest);
|
||||
tscDebug("begin to destroy request 0x%" PRIx64 " p:%p", reqId, pRequest);
|
||||
|
||||
int64_t nextReqRefId = pRequest->relation.nextRefId;
|
||||
|
||||
|
@ -731,7 +731,7 @@ void doDestroyRequest(void *p) {
|
|||
taosMemoryFreeClear(pRequest->effectiveUser);
|
||||
taosMemoryFreeClear(pRequest->sqlstr);
|
||||
taosMemoryFree(pRequest);
|
||||
tscTrace("end to destroy request %" PRIx64 " p:%p", reqId, pRequest);
|
||||
tscDebug("end to destroy request %" PRIx64 " p:%p", reqId, pRequest);
|
||||
destroyNextReq(nextReqRefId);
|
||||
}
|
||||
|
||||
|
@ -955,7 +955,7 @@ void taos_init_imp(void) {
|
|||
taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
|
||||
if (NULL == appInfo.pInstMap || NULL == appInfo.pInstMapByClusterId) {
|
||||
(void)printf("failed to allocate memory when init appInfo\n");
|
||||
tscInitRes = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tscInitRes = terrno;
|
||||
return;
|
||||
}
|
||||
taosHashSetFreeFp(appInfo.pInstMap, destroyAppInst);
|
||||
|
|
|
@ -595,6 +595,7 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
|
|||
}
|
||||
|
||||
SAppInstInfo *pInst = pAppHbMgr->pAppInstInfo;
|
||||
|
||||
if (code != 0) {
|
||||
pInst->onlineDnodes = pInst->totalDnodes ? 0 : -1;
|
||||
tscDebug("hb rsp error %s, update server status %d/%d", tstrerror(code), pInst->onlineDnodes, pInst->totalDnodes);
|
||||
|
@ -1338,7 +1339,6 @@ static void *hbThreadFunc(void *param) {
|
|||
}
|
||||
void *buf = taosMemoryMalloc(tlen);
|
||||
if (buf == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tFreeClientHbBatchReq(pReq);
|
||||
// hbClearReqInfo(pAppHbMgr);
|
||||
break;
|
||||
|
@ -1352,7 +1352,6 @@ static void *hbThreadFunc(void *param) {
|
|||
SMsgSendInfo *pInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
|
||||
if (pInfo == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tFreeClientHbBatchReq(pReq);
|
||||
// hbClearReqInfo(pAppHbMgr);
|
||||
taosMemoryFree(buf);
|
||||
|
@ -1364,7 +1363,6 @@ static void *hbThreadFunc(void *param) {
|
|||
pInfo->msgType = TDMT_MND_HEARTBEAT;
|
||||
pInfo->param = taosMemoryMalloc(sizeof(int32_t));
|
||||
if (pInfo->param == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tFreeClientHbBatchReq(pReq);
|
||||
// hbClearReqInfo(pAppHbMgr);
|
||||
taosMemoryFree(buf);
|
||||
|
@ -1372,7 +1370,7 @@ static void *hbThreadFunc(void *param) {
|
|||
break;
|
||||
}
|
||||
*(int32_t *)pInfo->param = i;
|
||||
pInfo->paramFreeFp = taosMemoryFree;
|
||||
pInfo->paramFreeFp = taosAutoMemoryFree;
|
||||
pInfo->requestId = generateRequestId();
|
||||
pInfo->requestObjRefId = 0;
|
||||
|
||||
|
@ -1458,7 +1456,7 @@ int32_t appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key, SAppHbMgr **pAppHbMg
|
|||
(*pAppHbMgr)->reportBytes = 0;
|
||||
(*pAppHbMgr)->key = taosStrdup(key);
|
||||
if ((*pAppHbMgr)->key == NULL) {
|
||||
TSC_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSC_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
// init app info
|
||||
|
|
|
@ -126,7 +126,7 @@ int32_t taos_connect_internal(const char* ip, const char* user, const char* pass
|
|||
|
||||
char* key = getClusterKey(user, secretEncrypt, ip, port);
|
||||
if (NULL == key) {
|
||||
TSC_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSC_ERR_RET(terrno);
|
||||
}
|
||||
tscInfo("connecting to server, numOfEps:%d inUse:%d user:%s db:%s key:%s", epSet.epSet.numOfEps, epSet.epSet.inUse,
|
||||
user, db, key);
|
||||
|
@ -1820,11 +1820,10 @@ int32_t doProcessMsgFromServerImpl(SRpcMsg* pMsg, SEpSet* pEpSet) {
|
|||
.handleRefId = pMsg->info.refId,
|
||||
.pEpSet = pEpSet};
|
||||
|
||||
if (pMsg->code != TSDB_CODE_OUT_OF_MEMORY && pMsg->contLen > 0) {
|
||||
if (pMsg->contLen > 0) {
|
||||
buf.pData = taosMemoryCalloc(1, pMsg->contLen);
|
||||
if (buf.pData == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
pMsg->code = terrno;
|
||||
} else {
|
||||
(void)memcpy(buf.pData, pMsg->pCont, pMsg->contLen);
|
||||
}
|
||||
|
@ -2957,7 +2956,6 @@ TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly, int8_t s
|
|||
|
||||
SSyncQueryParam* param = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
|
||||
if (NULL == param) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
int32_t code = tsem_init(¶m->sem, 0, 0);
|
||||
|
@ -2998,7 +2996,6 @@ TAOS_RES* taosQueryImplWithReqid(TAOS* taos, const char* sql, bool validateOnly,
|
|||
|
||||
SSyncQueryParam* param = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
|
||||
if (param == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
int32_t code = tsem_init(¶m->sem, 0, 0);
|
||||
|
|
|
@ -292,7 +292,6 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
|
|||
int64_t *rid = taosMemoryCalloc(1, sizeof(int64_t));
|
||||
if (NULL == rid) {
|
||||
tscError("out of memory when taos connect to %s:%u, user:%s db:%s", ip, port, user, db);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
*rid = pObj->id;
|
||||
|
@ -424,7 +423,7 @@ void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *pa
|
|||
|
||||
void *pReq = taosMemoryMalloc(msgLen);
|
||||
if (pReq == NULL) {
|
||||
fp(param, TSDB_CODE_OUT_OF_MEMORY, taos, 0, NULL);
|
||||
fp(param, terrno, taos, 0, NULL);
|
||||
releaseTscObj(connId);
|
||||
return;
|
||||
}
|
||||
|
@ -438,7 +437,7 @@ void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *pa
|
|||
|
||||
SFetchWhiteListInfo *pParam = taosMemoryMalloc(sizeof(SFetchWhiteListInfo));
|
||||
if (pParam == NULL) {
|
||||
fp(param, TSDB_CODE_OUT_OF_MEMORY, taos, 0, NULL);
|
||||
fp(param, terrno, taos, 0, NULL);
|
||||
taosMemoryFree(pReq);
|
||||
releaseTscObj(connId);
|
||||
return;
|
||||
|
@ -449,7 +448,7 @@ void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *pa
|
|||
pParam->userParam = param;
|
||||
SMsgSendInfo *pSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (pSendInfo == NULL) {
|
||||
fp(param, TSDB_CODE_OUT_OF_MEMORY, taos, 0, NULL);
|
||||
fp(param, terrno, taos, 0, NULL);
|
||||
taosMemoryFree(pParam);
|
||||
taosMemoryFree(pReq);
|
||||
releaseTscObj(connId);
|
||||
|
|
|
@ -1348,7 +1348,7 @@ end:
|
|||
destroyRequest(pRequest);
|
||||
tDecoderClear(&coder);
|
||||
qDestroyQuery(pQuery);
|
||||
taosArrayDestroyP(pTagList, taosMemoryFree);
|
||||
taosArrayDestroyP(pTagList, NULL);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -1563,7 +1563,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
req.source = TD_REQ_FROM_TAOX;
|
||||
tEncodeSize(tEncodeSVAlterTbReq, &req, tlen, code);
|
||||
if (code != 0) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
tlen += sizeof(SMsgHead);
|
||||
|
@ -1577,7 +1577,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
code = tEncodeSVAlterTbReq(&coder, &req);
|
||||
if (code != 0) {
|
||||
tEncoderClear(&coder);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
tEncoderClear(&coder);
|
||||
|
|
|
@ -444,7 +444,7 @@ int32_t smlParseEndLine(SSmlHandle *info, SSmlLineInfo *elements, SSmlKv *kvTs)
|
|||
}
|
||||
|
||||
clearColValArraySml(info->currTableDataCtx->pValues);
|
||||
taosArrayClearP(info->escapedStringList, taosMemoryFree);
|
||||
taosArrayClearP(info->escapedStringList, NULL);
|
||||
if (unlikely(ret != TSDB_CODE_SUCCESS)) {
|
||||
uError("SML:0x%" PRIx64 " %s smlBuildCol error:%d", info->id, __FUNCTION__, ret);
|
||||
return ret;
|
||||
|
@ -1270,7 +1270,7 @@ void smlDestroyInfo(SSmlHandle *info) {
|
|||
taosArrayDestroy(info->valueJsonArray);
|
||||
|
||||
taosArrayDestroyEx(info->preLineTagKV, freeSSmlKv);
|
||||
taosArrayDestroyP(info->escapedStringList, taosMemoryFree);
|
||||
taosArrayDestroyP(info->escapedStringList, NULL);
|
||||
|
||||
if (!info->dataFormat) {
|
||||
for (int i = 0; i < info->lineNum; i++) {
|
||||
|
@ -1536,7 +1536,7 @@ int32_t smlClearForRerun(SSmlHandle *info) {
|
|||
SML_CHECK_NULL(info->lines);
|
||||
}
|
||||
|
||||
taosArrayClearP(info->escapedStringList, taosMemoryFree);
|
||||
taosArrayClearP(info->escapedStringList, NULL);
|
||||
if(info->protocol == TSDB_SML_JSON_PROTOCOL) {
|
||||
taosMemoryFreeClear(info->preLine.tags);
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ int32_t smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg) {
|
|||
void* data = NULL;
|
||||
uint32_t size = 0;
|
||||
if(taosHex2Ascii(pVal->value + NCHAR_ADD_LEN - 1, pVal->length - NCHAR_ADD_LEN, &data, &size) < 0){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (size + VARSTR_HEADER_SIZE > TSDB_MAX_VARBINARY_LEN) {
|
||||
|
|
|
@ -300,7 +300,7 @@ int32_t stmtCacheBlock(STscStmt* pStmt) {
|
|||
|
||||
STableDataCxt** pSrc = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||
if (!pSrc) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
STableDataCxt* pDst = NULL;
|
||||
|
||||
|
@ -355,7 +355,7 @@ int32_t stmtParseSql(STscStmt* pStmt) {
|
|||
STableDataCxt** pSrc =
|
||||
(STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||
if (NULL == pSrc || NULL == *pSrc) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
STableDataCxt* pTableCtx = *pSrc;
|
||||
|
@ -845,13 +845,11 @@ TAOS_STMT* stmtInit(STscObj* taos, int64_t reqid, TAOS_STMT_OPTIONS* pOptions) {
|
|||
|
||||
pStmt = taosMemoryCalloc(1, sizeof(STscStmt));
|
||||
if (NULL == pStmt) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pStmt->sql.pTableCache = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
if (NULL == pStmt->sql.pTableCache) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFree(pStmt);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -876,13 +874,11 @@ TAOS_STMT* stmtInit(STscObj* taos, int64_t reqid, TAOS_STMT_OPTIONS* pOptions) {
|
|||
pStmt->sql.siInfo.mgmtEpSet = getEpSet_s(&pStmt->taos->pAppInfo->mgmtEp);
|
||||
pStmt->sql.siInfo.pTableHash = tSimpleHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY));
|
||||
if (NULL == pStmt->sql.siInfo.pTableHash) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
(void)stmtClose(pStmt);
|
||||
return NULL;
|
||||
}
|
||||
pStmt->sql.siInfo.pTableCols = taosArrayInit(STMT_TABLE_COLS_NUM, POINTER_BYTES);
|
||||
if (NULL == pStmt->sql.siInfo.pTableCols) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
(void)stmtClose(pStmt);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -948,7 +944,7 @@ int stmtPrepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
|
|||
int32_t stmtInitStbInterlaceTableInfo(STscStmt* pStmt) {
|
||||
STableDataCxt** pSrc = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||
if (!pSrc) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
STableDataCxt* pDst = NULL;
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ static int32_t stmtParseSql(STscStmt2* pStmt) {
|
|||
STableDataCxt** pSrc =
|
||||
(STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||
if (NULL == pSrc || NULL == *pSrc) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
STableDataCxt* pTableCtx = *pSrc;
|
||||
|
@ -295,7 +295,7 @@ static int32_t stmtParseSql(STscStmt2* pStmt) {
|
|||
if (NULL == pStmt->sql.pBindInfo) {
|
||||
pStmt->sql.pBindInfo = taosMemoryMalloc(pTableCtx->boundColsInfo.numOfBound * sizeof(*pStmt->sql.pBindInfo));
|
||||
if (NULL == pStmt->sql.pBindInfo) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -540,7 +540,7 @@ static int32_t stmtGetFromCache(STscStmt2* pStmt) {
|
|||
|
||||
if (taosHashPut(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName), &pNewBlock,
|
||||
POINTER_BYTES)) {
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
STMT_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
pStmt->exec.pCurrBlock = pNewBlock;
|
||||
|
@ -630,7 +630,7 @@ static int32_t stmtGetFromCache(STscStmt2* pStmt) {
|
|||
|
||||
if (taosHashPut(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName), &pNewBlock,
|
||||
POINTER_BYTES)) {
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
STMT_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
pStmt->exec.pCurrBlock = pNewBlock;
|
||||
|
@ -766,13 +766,11 @@ TAOS_STMT2* stmtInit2(STscObj* taos, TAOS_STMT2_OPTION* pOptions) {
|
|||
|
||||
pStmt = taosMemoryCalloc(1, sizeof(STscStmt2));
|
||||
if (NULL == pStmt) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pStmt->sql.pTableCache = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
if (NULL == pStmt->sql.pTableCache) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFree(pStmt);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -798,7 +796,6 @@ TAOS_STMT2* stmtInit2(STscObj* taos, TAOS_STMT2_OPTION* pOptions) {
|
|||
pStmt->sql.siInfo.mgmtEpSet = getEpSet_s(&pStmt->taos->pAppInfo->mgmtEp);
|
||||
pStmt->sql.siInfo.pTableHash = tSimpleHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY));
|
||||
if (NULL == pStmt->sql.siInfo.pTableHash) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
(void)stmtClose(pStmt);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -894,7 +891,7 @@ int stmtPrepare2(TAOS_STMT2* stmt, const char* sql, unsigned long length) {
|
|||
static int32_t stmtInitStbInterlaceTableInfo(STscStmt2* pStmt) {
|
||||
STableDataCxt** pSrc = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||
if (!pSrc) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
STableDataCxt* pDst = NULL;
|
||||
|
||||
|
@ -1199,7 +1196,7 @@ static int32_t stmtCacheBlock(STscStmt2* pStmt) {
|
|||
|
||||
STableDataCxt** pSrc = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||
if (!pSrc) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
STableDataCxt* pDst = NULL;
|
||||
|
||||
|
@ -1266,7 +1263,7 @@ static int32_t stmtBackupQueryFields(STscStmt2* pStmt) {
|
|||
pRes->fields = taosMemoryMalloc(size);
|
||||
pRes->userFields = taosMemoryMalloc(size);
|
||||
if (NULL == pRes->fields || NULL == pRes->userFields) {
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
STMT_ERR_RET(terrno);
|
||||
}
|
||||
(void)memcpy(pRes->fields, pStmt->exec.pRequest->body.resInfo.fields, size);
|
||||
(void)memcpy(pRes->userFields, pStmt->exec.pRequest->body.resInfo.userFields, size);
|
||||
|
@ -1284,7 +1281,7 @@ static int32_t stmtRestoreQueryFields(STscStmt2* pStmt) {
|
|||
if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
|
||||
pStmt->exec.pRequest->body.resInfo.fields = taosMemoryMalloc(size);
|
||||
if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
STMT_ERR_RET(terrno);
|
||||
}
|
||||
(void)memcpy(pStmt->exec.pRequest->body.resInfo.fields, pRes->fields, size);
|
||||
}
|
||||
|
@ -1292,7 +1289,7 @@ static int32_t stmtRestoreQueryFields(STscStmt2* pStmt) {
|
|||
if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
|
||||
pStmt->exec.pRequest->body.resInfo.userFields = taosMemoryMalloc(size);
|
||||
if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
STMT_ERR_RET(terrno);
|
||||
}
|
||||
(void)memcpy(pStmt->exec.pRequest->body.resInfo.userFields, pRes->userFields, size);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead)); \
|
||||
if (FUNC(&decoder, DATA) < 0) { \
|
||||
tDecoderClear(&decoder); \
|
||||
code = TSDB_CODE_OUT_OF_MEMORY; \
|
||||
code = terrno; \
|
||||
goto END;\
|
||||
}\
|
||||
tDecoderClear(&decoder);\
|
||||
|
@ -534,7 +534,7 @@ int32_t tmq_list_append(tmq_list_t* list, const char* src) {
|
|||
void tmq_list_destroy(tmq_list_t* list) {
|
||||
if (list == NULL) return;
|
||||
SArray* container = &list->container;
|
||||
taosArrayDestroyP(container, taosMemoryFree);
|
||||
taosArrayDestroyP(container, NULL);
|
||||
}
|
||||
|
||||
int32_t tmq_list_get_size(const tmq_list_t* list) {
|
||||
|
@ -659,7 +659,7 @@ static int32_t doSendCommitMsg(tmq_t* tmq, int32_t vgId, SEpSet* epSet, STqOffse
|
|||
pMsgSendInfo->requestId = generateRequestId();
|
||||
pMsgSendInfo->requestObjRefId = 0;
|
||||
pMsgSendInfo->param = pParam;
|
||||
pMsgSendInfo->paramFreeFp = taosMemoryFree;
|
||||
pMsgSendInfo->paramFreeFp = taosAutoMemoryFree;
|
||||
pMsgSendInfo->fp = tmqCommitCb;
|
||||
pMsgSendInfo->msgType = TDMT_VND_TMQ_COMMIT_OFFSET;
|
||||
|
||||
|
@ -1385,7 +1385,7 @@ static int32_t askEp(tmq_t* pTmq, void* param, bool sync, bool updateEpSet) {
|
|||
sendInfo->requestId = generateRequestId();
|
||||
sendInfo->requestObjRefId = 0;
|
||||
sendInfo->param = pParam;
|
||||
sendInfo->paramFreeFp = taosMemoryFree;
|
||||
sendInfo->paramFreeFp = taosAutoMemoryFree;
|
||||
sendInfo->fp = askEpCb;
|
||||
sendInfo->msgType = TDMT_MND_TMQ_ASK_EP;
|
||||
|
||||
|
@ -1552,7 +1552,7 @@ static void tmqMgmtInit(void) {
|
|||
tmqMgmt.timer = taosTmrInit(1000, 100, 360000, "TMQ");
|
||||
|
||||
if (tmqMgmt.timer == NULL) {
|
||||
tmqInitRes = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tmqInitRes = terrno;
|
||||
}
|
||||
|
||||
tmqMgmt.rsetId = taosOpenRef(10000, tmqFreeImpl);
|
||||
|
@ -1886,7 +1886,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
|||
}
|
||||
|
||||
END:
|
||||
taosArrayDestroyP(req.topicNames, taosMemoryFree);
|
||||
taosArrayDestroyP(req.topicNames, NULL);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -2177,7 +2177,7 @@ static int32_t doTmqPollImpl(tmq_t* pTmq, SMqClientTopic* pTopic, SMqClientVg* p
|
|||
sendInfo->requestId = req.reqId;
|
||||
sendInfo->requestObjRefId = 0;
|
||||
sendInfo->param = pParam;
|
||||
sendInfo->paramFreeFp = taosMemoryFree;
|
||||
sendInfo->paramFreeFp = taosAutoMemoryFree;
|
||||
sendInfo->fp = tmqPollCb;
|
||||
sendInfo->msgType = TDMT_VND_TMQ_CONSUME;
|
||||
|
||||
|
@ -2520,7 +2520,7 @@ int32_t tmq_unsubscribe(tmq_t* tmq) {
|
|||
|
||||
tmq_list_t* lst = tmq_list_new();
|
||||
if (lst == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto END;
|
||||
}
|
||||
code = tmq_subscribe(tmq, lst);
|
||||
|
@ -2701,10 +2701,12 @@ int32_t tmq_commit_sync(tmq_t* tmq, const TAOS_RES* pRes) {
|
|||
tqErrorC("failed to allocate memory for sync commit");
|
||||
return terrno;
|
||||
}
|
||||
if (tsem2_init(&pInfo->sem, 0, 0) != 0) {
|
||||
|
||||
code = tsem2_init(&pInfo->sem, 0, 0);
|
||||
if (code != 0) {
|
||||
tqErrorC("failed to init sem for sync commit");
|
||||
taosMemoryFree(pInfo);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
pInfo->code = 0;
|
||||
|
||||
|
@ -2778,9 +2780,10 @@ int32_t tmq_commit_offset_sync(tmq_t* tmq, const char* pTopicName, int32_t vgId,
|
|||
return terrno;
|
||||
}
|
||||
|
||||
if (tsem2_init(&pInfo->sem, 0, 0) != 0) {
|
||||
code = tsem2_init(&pInfo->sem, 0, 0);
|
||||
if (code != 0) {
|
||||
taosMemoryFree(pInfo);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
pInfo->code = 0;
|
||||
|
||||
|
@ -2847,6 +2850,7 @@ end:
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4, SReqResultInfo** pResInfo) {
|
||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
||||
SMqDataRsp* data = &pRspObj->dataRsp;
|
||||
|
@ -2966,9 +2970,10 @@ static int32_t tmCommittedCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
if (pMsg) {
|
||||
SDecoder decoder = {0};
|
||||
tDecoderInit(&decoder, (uint8_t*)pMsg->pData, pMsg->len);
|
||||
if (tDecodeMqVgOffset(&decoder, &pParam->vgOffset) < 0) {
|
||||
int32_t err = tDecodeMqVgOffset(&decoder, &pParam->vgOffset);
|
||||
if (err < 0) {
|
||||
tOffsetDestroy(&pParam->vgOffset.offset);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = err;
|
||||
goto end;
|
||||
}
|
||||
tDecoderClear(&decoder);
|
||||
|
@ -3261,8 +3266,9 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
if (tsem2_init(&pCommon->rsp, 0, 0) != 0) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
||||
code = tsem2_init(&pCommon->rsp, 0, 0);
|
||||
if (code != 0) {
|
||||
goto end;
|
||||
}
|
||||
(void)taosThreadMutexInit(&pCommon->mutex, 0);
|
||||
|
@ -3296,7 +3302,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
int32_t msgSize = tSerializeSMqPollReq(NULL, 0, &req);
|
||||
if (msgSize < 0) {
|
||||
taosMemoryFree(pParam);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = msgSize;
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -3307,10 +3313,11 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
goto end;
|
||||
}
|
||||
|
||||
if (tSerializeSMqPollReq(msg, msgSize, &req) < 0) {
|
||||
msgSize = tSerializeSMqPollReq(msg, msgSize, &req);
|
||||
if (msgSize < 0) {
|
||||
taosMemoryFree(msg);
|
||||
taosMemoryFree(pParam);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = msgSize;
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -3326,7 +3333,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
sendInfo->requestId = req.reqId;
|
||||
sendInfo->requestObjRefId = 0;
|
||||
sendInfo->param = pParam;
|
||||
sendInfo->paramFreeFp = taosMemoryFree;
|
||||
sendInfo->paramFreeFp = taosAutoMemoryFree;
|
||||
sendInfo->fp = tmqGetWalInfoCb;
|
||||
sendInfo->msgType = TDMT_VND_TMQ_VG_WALINFO;
|
||||
|
||||
|
|
|
@ -300,7 +300,13 @@ void* doConsumeData(void* param) {
|
|||
int main(int argc, char** argv) {
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
if (argc > 1) {
|
||||
numOfThreads = atoi(argv[1]);
|
||||
//numOfThreads = atoi(argv[1]);
|
||||
int32_t code = taosStr2int32(argv[1], &numOfThreads);
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
numOfThreads = TMAX(numOfThreads, 1);
|
||||
|
|
|
@ -299,8 +299,8 @@ TEST(connectionCase, setConnectionOption_Test) {
|
|||
taosMsleep(2 * HEARTBEAT_INTERVAL);
|
||||
|
||||
//test user APP and user IP
|
||||
check_sql_result(pConn, "select user_app from performance_schema.perf_connections", "aaaaaaaaaaaaaaaaaaaaaab");
|
||||
check_sql_result(pConn, "select user_ip from performance_schema.perf_connections", "192.168.0.2");
|
||||
check_sql_result_integer(pConn, "select count(*) from performance_schema.perf_connections where user_app = 'aaaaaaaaaaaaaaaaaaaaaab'", 1);
|
||||
check_sql_result_integer(pConn, "select count(*) from performance_schema.perf_connections where user_ip = '192.168.0.2'", 1);
|
||||
|
||||
code = taos_options_connection(pConn, TSDB_OPTION_CONNECTION_USER_IP, "192.168.1.2");
|
||||
ASSERT(code == 0);
|
||||
|
@ -313,9 +313,8 @@ TEST(connectionCase, setConnectionOption_Test) {
|
|||
|
||||
taosMsleep(2 * HEARTBEAT_INTERVAL);
|
||||
|
||||
check_sql_result(pConn, "select user_app from performance_schema.perf_connections", "user");
|
||||
check_sql_result(pConn, "select user_ip from performance_schema.perf_connections", "192.168.1.2");
|
||||
|
||||
check_sql_result_integer(pConn, "select count(*) from performance_schema.perf_connections where user_app = 'user'", 1);
|
||||
check_sql_result_integer(pConn, "select count(*) from performance_schema.perf_connections where user_ip = '192.168.1.2'", 1);
|
||||
|
||||
// test clear
|
||||
code = taos_options_connection(pConn, TSDB_OPTION_CONNECTION_CLEAR, "192.168.0.2");
|
||||
|
@ -944,3 +943,4 @@ TEST(timezoneCase, localtime_performance_Test) {
|
|||
#endif
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
|
|
|
@ -261,7 +261,7 @@ static void responseCompleteCallback(S3Status status, const S3ErrorDetails *erro
|
|||
for (int i = 0; i < error->extraDetailsCount; i++) {
|
||||
if (elen - len > 0) {
|
||||
len += tsnprintf(&(cbd->err_msg[len]), elen - len, " %s: %s\n", error->extraDetails[i].name,
|
||||
error->extraDetails[i].value);
|
||||
error->extraDetails[i].value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -742,9 +742,9 @@ upload:
|
|||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(EIO), &lino, _exit);
|
||||
}
|
||||
n = tsnprintf(buf, sizeof(buf),
|
||||
"<Part><PartNumber>%d</PartNumber>"
|
||||
"<ETag>%s</ETag></Part>",
|
||||
i + 1, manager.etags[i]);
|
||||
"<Part><PartNumber>%d</PartNumber>"
|
||||
"<ETag>%s</ETag></Part>",
|
||||
i + 1, manager.etags[i]);
|
||||
size += growbuffer_append(&(manager.gb), buf, n);
|
||||
}
|
||||
size += growbuffer_append(&(manager.gb), "</CompleteMultipartUpload>", strlen("</CompleteMultipartUpload>"));
|
||||
|
@ -908,10 +908,10 @@ upload:
|
|||
int n;
|
||||
for (int i = 0; i < cp.part_num; ++i) {
|
||||
n = tsnprintf(buf, sizeof(buf),
|
||||
"<Part><PartNumber>%d</PartNumber>"
|
||||
"<ETag>%s</ETag></Part>",
|
||||
// i + 1, manager.etags[i]);
|
||||
cp.parts[i].index + 1, cp.parts[i].etag);
|
||||
"<Part><PartNumber>%d</PartNumber>"
|
||||
"<ETag>%s</ETag></Part>",
|
||||
// i + 1, manager.etags[i]);
|
||||
cp.parts[i].index + 1, cp.parts[i].etag);
|
||||
size += growbuffer_append(&(manager.gb), buf, n);
|
||||
}
|
||||
size += growbuffer_append(&(manager.gb), "</CompleteMultipartUpload>", strlen("</CompleteMultipartUpload>"));
|
||||
|
@ -1916,7 +1916,8 @@ void s3EvictCache(const char *path, long object_size) {
|
|||
}
|
||||
|
||||
long s3Size(const char *object_name) {
|
||||
long size = 0;
|
||||
int32_t code = 0;
|
||||
long size = 0;
|
||||
|
||||
cos_pool_t *p = NULL;
|
||||
int is_cname = 0;
|
||||
|
@ -1941,7 +1942,10 @@ long s3Size(const char *object_name) {
|
|||
if (cos_status_is_ok(s)) {
|
||||
char *content_length_str = (char *)apr_table_get(resp_headers, COS_CONTENT_LENGTH);
|
||||
if (content_length_str != NULL) {
|
||||
size = atol(content_length_str);
|
||||
code = taosStr2Int64(content_length_str, &size);
|
||||
if (code != 0) {
|
||||
cos_warn_log("parse content length failed since %s\n", tstrerror(code));
|
||||
}
|
||||
}
|
||||
cos_warn_log("head object succeeded: %ld\n", size);
|
||||
} else {
|
||||
|
|
|
@ -403,7 +403,7 @@ _exit:
|
|||
}
|
||||
|
||||
void tCleanupStreamDispatchReq(SStreamDispatchReq* pReq) {
|
||||
taosArrayDestroyP(pReq->data, taosMemoryFree);
|
||||
taosArrayDestroyP(pReq->data, NULL);
|
||||
taosArrayDestroy(pReq->dataLen);
|
||||
}
|
||||
|
||||
|
|
|
@ -9295,7 +9295,7 @@ int32_t tSerializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *pR
|
|||
tEncoderInit(&encoder, buf, bufLen);
|
||||
|
||||
TAOS_CHECK_EXIT(tStartEncode(&encoder));
|
||||
TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->sId));
|
||||
TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->clientId));
|
||||
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->epId.nodeId));
|
||||
TAOS_CHECK_EXIT(tEncodeU16(&encoder, pReq->epId.ep.port));
|
||||
TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->epId.ep.fqdn));
|
||||
|
@ -9342,7 +9342,7 @@ int32_t tDeserializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *
|
|||
tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen);
|
||||
|
||||
TAOS_CHECK_EXIT(tStartDecode(&decoder));
|
||||
TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->sId));
|
||||
TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->clientId));
|
||||
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->epId.nodeId));
|
||||
TAOS_CHECK_EXIT(tDecodeU16(&decoder, &pReq->epId.ep.port));
|
||||
TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->epId.ep.fqdn));
|
||||
|
@ -11252,11 +11252,11 @@ int32_t tDecodeMqDataRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) {
|
|||
static void tDeleteMqDataRspCommon(SMqDataRsp *pRsp) {
|
||||
taosArrayDestroy(pRsp->blockDataLen);
|
||||
pRsp->blockDataLen = NULL;
|
||||
taosArrayDestroyP(pRsp->blockData, (FDelete)taosMemoryFree);
|
||||
taosArrayDestroyP(pRsp->blockData, NULL);
|
||||
pRsp->blockData = NULL;
|
||||
taosArrayDestroyP(pRsp->blockSchema, (FDelete)tDeleteSchemaWrapper);
|
||||
pRsp->blockSchema = NULL;
|
||||
taosArrayDestroyP(pRsp->blockTbName, (FDelete)taosMemoryFree);
|
||||
taosArrayDestroyP(pRsp->blockTbName, NULL);
|
||||
pRsp->blockTbName = NULL;
|
||||
tOffsetDestroy(&pRsp->reqOffset);
|
||||
tOffsetDestroy(&pRsp->rspOffset);
|
||||
|
@ -11318,7 +11318,7 @@ void tDeleteSTaosxRsp(SMqDataRsp *pRsp) {
|
|||
|
||||
taosArrayDestroy(pRsp->createTableLen);
|
||||
pRsp->createTableLen = NULL;
|
||||
taosArrayDestroyP(pRsp->createTableReq, (FDelete)taosMemoryFree);
|
||||
taosArrayDestroyP(pRsp->createTableReq, NULL);
|
||||
pRsp->createTableReq = NULL;
|
||||
}
|
||||
|
||||
|
@ -12877,7 +12877,7 @@ _exit:
|
|||
|
||||
void tDeleteMqBatchMetaRsp(SMqBatchMetaRsp *pRsp) {
|
||||
taosMemoryFreeClear(pRsp->pMetaBuff);
|
||||
taosArrayDestroyP(pRsp->batchMetaReq, taosMemoryFree);
|
||||
taosArrayDestroyP(pRsp->batchMetaReq, NULL);
|
||||
taosArrayDestroy(pRsp->batchMetaLen);
|
||||
pRsp->batchMetaReq = NULL;
|
||||
pRsp->batchMetaLen = NULL;
|
||||
|
|
|
@ -267,7 +267,7 @@ bool checkColumnEncode(char encode[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
|||
}
|
||||
bool checkColumnEncodeOrSetDefault(uint8_t type, char encode[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||
if (0 == strlen(encode)) {
|
||||
strncpy(encode, getDefaultEncodeStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
||||
tstrncpy(encode, getDefaultEncodeStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
||||
return true;
|
||||
}
|
||||
return checkColumnEncode(encode) && validColEncode(type, columnEncodeVal(encode));
|
||||
|
@ -284,7 +284,7 @@ bool checkColumnCompress(char compress[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
|||
}
|
||||
bool checkColumnCompressOrSetDefault(uint8_t type, char compress[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||
if (0 == strlen(compress)) {
|
||||
strncpy(compress, getDefaultCompressStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
||||
tstrncpy(compress, getDefaultCompressStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,7 @@ bool checkColumnLevel(char level[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
|||
}
|
||||
bool checkColumnLevelOrSetDefault(uint8_t type, char level[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||
if (0 == strlen(level)) {
|
||||
strncpy(level, getDefaultLevelStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
||||
tstrncpy(level, getDefaultLevelStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
||||
return true;
|
||||
}
|
||||
return checkColumnLevel(level) && validColCompressLevel(type, columnLevelVal(level));
|
||||
|
@ -330,7 +330,7 @@ void setColLevel(uint32_t* compress, uint8_t level) {
|
|||
|
||||
int32_t setColCompressByOption(uint8_t type, uint8_t encode, uint16_t compressType, uint8_t level, bool check,
|
||||
uint32_t* compress) {
|
||||
if(compress == NULL) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
if (compress == NULL) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
if (check && !validColEncode(type, encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
setColEncode(compress, encode);
|
||||
|
||||
|
|
|
@ -54,13 +54,28 @@ char tsEncryptKey[17] = {0};
|
|||
int32_t tsMaxShellConns = 50000;
|
||||
int32_t tsShellActivityTimer = 3; // second
|
||||
|
||||
// memory pool
|
||||
int8_t tsMemPoolFullFunc = 0;
|
||||
int8_t tsQueryUseMemoryPool = 1;
|
||||
int32_t tsQueryBufferPoolSize = 0; //MB
|
||||
int32_t tsSingleQueryMaxMemorySize = 0; //MB
|
||||
int32_t tsMinReservedMemorySize = 0; //MB
|
||||
int64_t tsCurrentAvailMemorySize = 0;
|
||||
int8_t tsNeedTrim = 0;
|
||||
|
||||
// queue & threads
|
||||
int32_t tsQueryMinConcurrentTaskNum = 1;
|
||||
int32_t tsQueryMaxConcurrentTaskNum = 0;
|
||||
int32_t tsQueryConcurrentTaskNum = 0;
|
||||
int32_t tsQueryNoFetchTimeoutSec = 3600 * 5;
|
||||
|
||||
int32_t tsNumOfRpcThreads = 1;
|
||||
int32_t tsNumOfRpcSessions = 30000;
|
||||
int32_t tsShareConnLimit = 10;
|
||||
int32_t tsReadTimeout = 900;
|
||||
int32_t tsTimeToGetAvailableConn = 500000;
|
||||
|
||||
int32_t tsNumOfQueryThreads = 0;
|
||||
int32_t tsNumOfCommitThreads = 2;
|
||||
int32_t tsNumOfTaskQueueThreads = 16;
|
||||
int32_t tsNumOfMnodeQueryThreads = 16;
|
||||
|
@ -735,6 +750,14 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "queryRspPolicy", tsQueryRspPolicy, 0, 1, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER));
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfCommitThreads", tsNumOfCommitThreads, 1, 1024, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "retentionSpeedLimitMB", tsRetentionSpeedLimitMB, 0, 1024, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
|
||||
|
||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "queryUseMemoryPool", tsQueryUseMemoryPool, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0);
|
||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "memPoolFullFunc", tsMemPoolFullFunc, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0);
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "singleQueryMaxMemorySize", tsSingleQueryMaxMemorySize, 0, 1000000000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0);
|
||||
//TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "queryBufferPoolSize", tsQueryBufferPoolSize, 0, 1000000000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0);
|
||||
TAOS_CHECK_RETURN(cfgAddInt32Ex(pCfg, "minReservedMemorySize", 0, 1024, 1000000000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0);
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "queryNoFetchTimeoutSec", tsQueryNoFetchTimeoutSec, 60, 1000000000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0);
|
||||
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfMnodeReadThreads", tsNumOfMnodeReadThreads, 1, 1024, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 1, 1024, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
|
@ -1692,6 +1715,21 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "experimental");
|
||||
tsExperimental = pItem->bval;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryUseMemoryPool");
|
||||
tsQueryUseMemoryPool = pItem->bval;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "memPoolFullFunc");
|
||||
tsMemPoolFullFunc = pItem->bval;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "singleQueryMaxMemorySize");
|
||||
tsSingleQueryMaxMemorySize = pItem->i32;
|
||||
|
||||
//TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryBufferPoolSize");
|
||||
//tsQueryBufferPoolSize = pItem->i32;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "minReservedMemorySize");
|
||||
tsMinReservedMemorySize = pItem->i32;
|
||||
|
||||
// GRANT_CFG_GET;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
@ -2061,7 +2099,8 @@ static int32_t taosCfgDynamicOptionsForServer(SConfig *pCfg, const char *name) {
|
|||
{"experimental", &tsExperimental},
|
||||
{"maxTsmaNum", &tsMaxTsmaNum},
|
||||
{"safetyCheckLevel", &tsSafetyCheckLevel},
|
||||
{"bypassFlag", &tsBypassFlag}};
|
||||
{"bypassFlag", &tsBypassFlag},
|
||||
{"queryNoFetchTimeoutSec", &tsQueryNoFetchTimeoutSec}};
|
||||
|
||||
if ((code = taosCfgSetOption(debugOptions, tListLen(debugOptions), pItem, true)) != TSDB_CODE_SUCCESS) {
|
||||
code = taosCfgSetOption(options, tListLen(options), pItem, false);
|
||||
|
|
|
@ -22,12 +22,15 @@
|
|||
int32_t taosGetFqdnPortFromEp(const char* ep, SEp* pEp) {
|
||||
pEp->port = 0;
|
||||
memset(pEp->fqdn, 0, TSDB_FQDN_LEN);
|
||||
strncpy(pEp->fqdn, ep, TSDB_FQDN_LEN - 1);
|
||||
tstrncpy(pEp->fqdn, ep, TSDB_FQDN_LEN);
|
||||
|
||||
char* temp = strchr(pEp->fqdn, ':');
|
||||
if (temp) {
|
||||
*temp = 0;
|
||||
pEp->port = atoi(temp + 1);
|
||||
pEp->port = taosStr2UInt16(temp + 1, NULL, 10);
|
||||
if (pEp->port < 0) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
}
|
||||
|
||||
if (pEp->port == 0) {
|
||||
|
@ -282,7 +285,7 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
|||
locked = 1;
|
||||
|
||||
while ((pItem = cfgNextIter(pIter)) != NULL) {
|
||||
_start:
|
||||
_start:
|
||||
col = startCol;
|
||||
|
||||
// GRANT_CFG_SKIP;
|
||||
|
@ -297,12 +300,11 @@ _start:
|
|||
|
||||
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, name, false), NULL, _exit);
|
||||
|
||||
char value[TSDB_CONFIG_PATH_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
int32_t valueLen = 0;
|
||||
|
||||
char value[TSDB_CONFIG_PATH_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
int32_t valueLen = 0;
|
||||
SDiskCfg* pDiskCfg = NULL;
|
||||
if (strcasecmp(pItem->name, "dataDir") == 0 && exSize > 0) {
|
||||
char* buf = &value[VARSTR_HEADER_SIZE];
|
||||
char* buf = &value[VARSTR_HEADER_SIZE];
|
||||
pDiskCfg = taosArrayGet(pItem->array, index);
|
||||
valueLen = tsnprintf(buf, TSDB_CONFIG_PATH_LEN, "%s", pDiskCfg->dir);
|
||||
index++;
|
||||
|
@ -335,7 +337,7 @@ _start:
|
|||
if (strcasecmp(pItem->name, "dataDir") == 0 && pDiskCfg) {
|
||||
char* buf = &info[VARSTR_HEADER_SIZE];
|
||||
valueLen = tsnprintf(buf, TSDB_CONFIG_INFO_LEN, "level %d primary %d disabled %" PRIi8, pDiskCfg->level,
|
||||
pDiskCfg->primary, pDiskCfg->disable);
|
||||
pDiskCfg->primary, pDiskCfg->disable);
|
||||
} else {
|
||||
valueLen = 0;
|
||||
}
|
||||
|
@ -352,7 +354,7 @@ _start:
|
|||
if (index > 0 && index <= exSize) {
|
||||
goto _start;
|
||||
}
|
||||
}
|
||||
}
|
||||
pBlock->info.rows = numOfRows;
|
||||
_exit:
|
||||
if (locked) cfgUnLock(pConf);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#endif
|
||||
#include "dmUtil.h"
|
||||
#include "tcs.h"
|
||||
#include "qworker.h"
|
||||
|
||||
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
|
||||
#include "cus_name.h"
|
||||
|
@ -279,7 +280,7 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
|
|||
printf("ERROR: Encrypt key overflow, it should be at most %d characters\n", ENCRYPT_KEY_LEN);
|
||||
return TSDB_CODE_INVALID_CFG;
|
||||
}
|
||||
tstrncpy(global.encryptKey, argv[i], ENCRYPT_KEY_LEN);
|
||||
tstrncpy(global.encryptKey, argv[i], ENCRYPT_KEY_LEN + 1);
|
||||
} else {
|
||||
printf("'-y' requires a parameter\n");
|
||||
return TSDB_CODE_INVALID_CFG;
|
||||
|
@ -477,6 +478,13 @@ int mainWindows(int argc, char **argv) {
|
|||
taosCleanupArgs();
|
||||
return code;
|
||||
}
|
||||
|
||||
if ((code = taosMemoryPoolInit(qWorkerRetireJobs, qWorkerRetireJob)) != 0) {
|
||||
dError("failed to init memPool, error:0x%x", code);
|
||||
taosCloseLog();
|
||||
taosCleanupArgs();
|
||||
return code;
|
||||
}
|
||||
|
||||
if ((tsCharsetCxt = taosConvInit(tsCharset)) == NULL) {
|
||||
dError("failed to init conv");
|
||||
|
|
|
@ -114,7 +114,7 @@ static void dmMayShouldUpdateAnalFunc(SDnodeMgmt *pMgmt, int64_t newVer) {
|
|||
.pCont = pHead,
|
||||
.contLen = contLen,
|
||||
.msgType = TDMT_MND_RETRIEVE_ANAL_ALGO,
|
||||
.info.ahandle = (void *)0x9527,
|
||||
.info.ahandle = 0,
|
||||
.info.refId = 0,
|
||||
.info.noResp = 0,
|
||||
.info.handle = 0,
|
||||
|
|
|
@ -202,9 +202,12 @@ static void *dmMonitorThreadFp(void *param) {
|
|||
|
||||
trimCount = (trimCount + 1) % TRIM_FREQ;
|
||||
if (trimCount == 0) {
|
||||
taosMemoryTrim(0);
|
||||
taosMemoryTrim(0, NULL);
|
||||
}
|
||||
}
|
||||
if (atomic_val_compare_exchange_8(&tsNeedTrim, 1, 0)) {
|
||||
taosMemoryTrim(0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -220,6 +220,8 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
|||
return code;
|
||||
}
|
||||
|
||||
tsNumOfQueryThreads += tsNumOfMnodeQueryThreads;
|
||||
|
||||
SSingleWorkerCfg fCfg = {
|
||||
.min = tsNumOfMnodeFetchThreads,
|
||||
.max = tsNumOfMnodeFetchThreads,
|
||||
|
|
|
@ -104,8 +104,8 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
|
|||
int32_t code = 0;
|
||||
|
||||
SSingleWorkerCfg queryCfg = {
|
||||
.min = tsNumOfVnodeQueryThreads,
|
||||
.max = tsNumOfVnodeQueryThreads,
|
||||
.min = tsNumOfQnodeQueryThreads,
|
||||
.max = tsNumOfQnodeQueryThreads,
|
||||
.name = "qnode-query",
|
||||
.fp = (FItem)qmProcessQueue,
|
||||
.param = pMgmt,
|
||||
|
@ -117,6 +117,8 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
|
|||
return code;
|
||||
}
|
||||
|
||||
tsNumOfQueryThreads += tsNumOfQnodeQueryThreads;
|
||||
|
||||
SSingleWorkerCfg fetchCfg = {
|
||||
.min = tsNumOfQnodeFetchThreads,
|
||||
.max = tsNumOfQnodeFetchThreads,
|
||||
|
|
|
@ -186,7 +186,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
|||
#if defined(TD_ENTERPRISE)
|
||||
pCfg->tsdbCfg.encryptAlgorithm = pCreate->encryptAlgorithm;
|
||||
if (pCfg->tsdbCfg.encryptAlgorithm == DND_CA_SM4) {
|
||||
strncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
tstrncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
}
|
||||
#else
|
||||
pCfg->tsdbCfg.encryptAlgorithm = 0;
|
||||
|
@ -202,7 +202,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
|||
#if defined(TD_ENTERPRISE)
|
||||
pCfg->walCfg.encryptAlgorithm = pCreate->encryptAlgorithm;
|
||||
if (pCfg->walCfg.encryptAlgorithm == DND_CA_SM4) {
|
||||
strncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
tstrncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
}
|
||||
#else
|
||||
pCfg->walCfg.encryptAlgorithm = 0;
|
||||
|
@ -378,12 +378,11 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
|
||||
snprintf(path, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, vnodeCfg.vgId);
|
||||
|
||||
if (vnodeCreate(path, &vnodeCfg, diskPrimary, pMgmt->pTfs) < 0) {
|
||||
dError("vgId:%d, failed to create vnode since %s", req.vgId, terrstr());
|
||||
if ((code = vnodeCreate(path, &vnodeCfg, diskPrimary, pMgmt->pTfs)) < 0) {
|
||||
dError("vgId:%d, failed to create vnode since %s", req.vgId, tstrerror(code));
|
||||
vmReleaseVnode(pMgmt, pVnode);
|
||||
vmCleanPrimaryDisk(pMgmt, req.vgId);
|
||||
(void)tFreeSCreateVnodeReq(&req);
|
||||
code = terrno != 0 ? terrno : -1;
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -884,7 +883,7 @@ int32_t vmProcessArbHeartBeatReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
size_t size = taosArrayGetSize(arbHbReq.hbMembers);
|
||||
|
||||
arbHbRsp.dnodeId = pMgmt->pData->dnodeId;
|
||||
strncpy(arbHbRsp.arbToken, arbHbReq.arbToken, TSDB_ARB_TOKEN_SIZE);
|
||||
tstrncpy(arbHbRsp.arbToken, arbHbReq.arbToken, TSDB_ARB_TOKEN_SIZE);
|
||||
arbHbRsp.hbMembers = taosArrayInit(size, sizeof(SVArbHbRspMember));
|
||||
if (arbHbRsp.hbMembers == NULL) {
|
||||
goto _OVER;
|
||||
|
|
|
@ -94,7 +94,7 @@ static void vmUnRegisterCreatingState(SVnodeMgmt *pMgmt, int32_t vgId) {
|
|||
dTrace("vgId:%d, remove from creating Hash", vgId);
|
||||
r = taosHashRemove(pMgmt->creatingHash, &vgId, sizeof(int32_t));
|
||||
if (r != 0) {
|
||||
dError("vgId:%d, failed to remove vnode from hash", vgId);
|
||||
dError("vgId:%d, failed to remove vnode from creatingHash", vgId);
|
||||
}
|
||||
(void)taosThreadRwlockUnlock(&pMgmt->lock);
|
||||
|
||||
|
|
|
@ -456,6 +456,8 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) {
|
|||
pQPool->max = tsNumOfVnodeQueryThreads;
|
||||
if ((code = tQueryAutoQWorkerInit(pQPool)) != 0) return code;
|
||||
|
||||
tsNumOfQueryThreads += tsNumOfVnodeQueryThreads;
|
||||
|
||||
SAutoQWorkerPool *pStreamPool = &pMgmt->streamPool;
|
||||
pStreamPool->name = "vnode-stream";
|
||||
pStreamPool->ratio = tsRatioOfVnodeStreamThreads;
|
||||
|
|
|
@ -220,6 +220,7 @@ void dmCleanup() {
|
|||
|
||||
dInfo("dnode env is cleaned up");
|
||||
|
||||
taosMemPoolClose(gMemPoolHandle);
|
||||
taosCleanupCfg();
|
||||
taosCloseLog();
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ int32_t dmInitVars(SDnode *pDnode) {
|
|||
|
||||
//code = taosGetCryptKey(tsAuthCode, pData->machineId, tsCryptKey);
|
||||
code = 0;
|
||||
strncpy(tsEncryptKey, tsAuthCode, 16);
|
||||
tstrncpy(tsEncryptKey, tsAuthCode, 16);
|
||||
|
||||
if (code != 0) {
|
||||
if(code == -1){
|
||||
|
@ -221,6 +221,7 @@ int32_t dmInitVars(SDnode *pDnode) {
|
|||
}
|
||||
|
||||
extern SMonVloadInfo tsVinfo;
|
||||
|
||||
void dmClearVars(SDnode *pDnode) {
|
||||
for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) {
|
||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
||||
|
|
|
@ -368,7 +368,9 @@ static inline int32_t dmSendSyncReq(const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
|||
|
||||
static inline void dmRegisterBrokenLinkArg(SRpcMsg *pMsg) { (void)rpcRegisterBrokenLinkArg(pMsg); }
|
||||
|
||||
static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) { (void)rpcReleaseHandle(pHandle, type); }
|
||||
static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type, int32_t status) {
|
||||
(void)rpcReleaseHandle(pHandle, type, status);
|
||||
}
|
||||
|
||||
static bool rpcRfp(int32_t code, tmsg_t msgType) {
|
||||
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_MNODE_NOT_FOUND ||
|
||||
|
|
|
@ -230,7 +230,7 @@ static int32_t dmWriteCheckCodeFile(char *file, char *realfile, char *key, bool
|
|||
}
|
||||
|
||||
SCryptOpts opts;
|
||||
strncpy(opts.key, key, ENCRYPT_KEY_LEN);
|
||||
tstrncpy(opts.key, key, ENCRYPT_KEY_LEN + 1);
|
||||
opts.len = len;
|
||||
opts.source = DM_KEY_INDICATOR;
|
||||
opts.result = result;
|
||||
|
@ -349,7 +349,7 @@ static int32_t dmCompareEncryptKey(char *file, char *key, bool toLogFile) {
|
|||
}
|
||||
|
||||
SCryptOpts opts = {0};
|
||||
strncpy(opts.key, key, ENCRYPT_KEY_LEN);
|
||||
tstrncpy(opts.key, key, ENCRYPT_KEY_LEN + 1);
|
||||
opts.len = len;
|
||||
opts.source = content;
|
||||
opts.result = result;
|
||||
|
@ -551,7 +551,7 @@ int32_t dmGetEncryptKey() {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
strncpy(tsEncryptKey, encryptKey, ENCRYPT_KEY_LEN);
|
||||
strncpy(tsEncryptKey, encryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
taosMemoryFreeClear(encryptKey);
|
||||
tsEncryptionKeyChksum = taosCalcChecksum(0, tsEncryptKey, strlen(tsEncryptKey));
|
||||
tsEncryptionKeyStat = ENCRYPT_KEY_STAT_LOADED;
|
||||
|
|
|
@ -1315,7 +1315,7 @@ static int32_t mndRetrieveArbGroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
|||
continue;
|
||||
}
|
||||
char dbNameInGroup[TSDB_DB_FNAME_LEN];
|
||||
strncpy(dbNameInGroup, pVgObj->dbName, TSDB_DB_FNAME_LEN);
|
||||
tstrncpy(dbNameInGroup, pVgObj->dbName, TSDB_DB_FNAME_LEN);
|
||||
sdbRelease(pSdb, pVgObj);
|
||||
|
||||
char dbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
|
|
|
@ -244,7 +244,7 @@ int32_t mndCompactGetDbName(SMnode *pMnode, int32_t compactId, char *dbname, int
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
(void)strncpy(dbname, pCompact->dbname, len);
|
||||
tstrncpy(dbname, pCompact->dbname, len);
|
||||
mndReleaseCompact(pMnode, pCompact);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ int32_t mndRetrieveCompact(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock,
|
|||
TAOS_CHECK_GOTO(tNameFromString(&name, pCompact->dbname, T_NAME_ACCT | T_NAME_DB), &lino, _OVER);
|
||||
(void)tNameGetDbName(&name, varDataVal(tmpBuf));
|
||||
} else {
|
||||
(void)strncpy(varDataVal(tmpBuf), pCompact->dbname, TSDB_SHOW_SQL_LEN);
|
||||
tstrncpy(varDataVal(tmpBuf), pCompact->dbname, TSDB_SHOW_SQL_LEN);
|
||||
}
|
||||
varDataSetLen(tmpBuf, strlen(varDataVal(tmpBuf)));
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)tmpBuf, false), pCompact, &lino, _OVER);
|
||||
|
@ -516,11 +516,14 @@ int32_t mndProcessKillCompactReq(SRpcMsg *pReq) {
|
|||
|
||||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
|
||||
char obj[TSDB_INT32_ID_LEN] = {0};
|
||||
(void)sprintf(obj, "%d", pCompact->compactId);
|
||||
|
||||
auditRecord(pReq, pMnode->clusterId, "killCompact", pCompact->dbname, obj, killCompactReq.sql, killCompactReq.sqlLen);
|
||||
|
||||
char obj[TSDB_INT32_ID_LEN] = {0};
|
||||
int32_t nBytes = snprintf(obj, sizeof(obj), "%d", pCompact->compactId);
|
||||
if ((uint32_t)nBytes < sizeof(obj)) {
|
||||
auditRecord(pReq, pMnode->clusterId, "killCompact", pCompact->dbname, obj, killCompactReq.sql,
|
||||
killCompactReq.sqlLen);
|
||||
} else {
|
||||
mError("compact:%" PRId32 " failed to audit since %s", pCompact->compactId, tstrerror(TSDB_CODE_OUT_OF_RANGE));
|
||||
}
|
||||
_OVER:
|
||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("failed to kill compact %" PRId32 " since %s", killCompactReq.compactId, terrstr());
|
||||
|
@ -641,7 +644,7 @@ void mndCompactSendProgressReq(SMnode *pMnode, SCompactObj *pCompact) {
|
|||
|
||||
char detail[1024] = {0};
|
||||
int32_t len = tsnprintf(detail, sizeof(detail), "msgType:%s numOfEps:%d inUse:%d",
|
||||
TMSG_INFO(TDMT_VND_QUERY_COMPACT_PROGRESS), epSet.numOfEps, epSet.inUse);
|
||||
TMSG_INFO(TDMT_VND_QUERY_COMPACT_PROGRESS), epSet.numOfEps, epSet.inUse);
|
||||
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
||||
len += tsnprintf(detail + len, sizeof(detail) - len, " ep:%d-%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port);
|
||||
}
|
||||
|
|
|
@ -614,7 +614,7 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
|||
END:
|
||||
mndTransDrop(pTrans);
|
||||
tDeleteSMqConsumerObj(pConsumerNew);
|
||||
taosArrayDestroyP(subscribe.topicNames, (FDelete)taosMemoryFree);
|
||||
taosArrayDestroyP(subscribe.topicNames, NULL);
|
||||
return (code == TSDB_CODE_TMQ_NO_NEED_REBALANCE || code == TSDB_CODE_MND_CONSUMER_NOT_EXIST) ? 0 : code;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "mndDb.h"
|
||||
#include "audit.h"
|
||||
#include "command.h"
|
||||
#include "mndArbGroup.h"
|
||||
#include "mndCluster.h"
|
||||
#include "mndDnode.h"
|
||||
|
@ -34,7 +35,6 @@
|
|||
#include "systable.h"
|
||||
#include "thttp.h"
|
||||
#include "tjson.h"
|
||||
#include "command.h"
|
||||
|
||||
#define DB_VER_NUMBER 1
|
||||
#define DB_RESERVE_SIZE 27
|
||||
|
@ -416,7 +416,12 @@ static int32_t mndCheckDbName(const char *dbName, SUserObj *pUser) {
|
|||
return TSDB_CODE_MND_INVALID_DB;
|
||||
}
|
||||
|
||||
int32_t acctId = atoi(dbName);
|
||||
int32_t acctId;
|
||||
int32_t code = taosStr2int32(dbName, &acctId);
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
|
||||
if (acctId != pUser->acctId) {
|
||||
return TSDB_CODE_MND_INVALID_DB_ACCT;
|
||||
}
|
||||
|
@ -1561,8 +1566,8 @@ static int32_t mndBuildDropVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *
|
|||
|
||||
static int32_t mndSetDropDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
||||
int32_t code = 0;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
void *pIter = NULL;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
void *pIter = NULL;
|
||||
|
||||
while (1) {
|
||||
SVgObj *pVgroup = NULL;
|
||||
|
@ -1942,9 +1947,9 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs,
|
|||
continue;
|
||||
} else {
|
||||
mTrace("db:%s, valid dbinfo, vgVersion:%d cfgVersion:%d stateTs:%" PRId64
|
||||
" numOfTables:%d, changed to vgVersion:%d cfgVersion:%d stateTs:%" PRId64 " numOfTables:%d",
|
||||
pDbCacheInfo->dbFName, pDbCacheInfo->vgVersion, pDbCacheInfo->cfgVersion, pDbCacheInfo->stateTs,
|
||||
pDbCacheInfo->numOfTable, pDb->vgVersion, pDb->cfgVersion, pDb->stateTs, numOfTable);
|
||||
" numOfTables:%d, changed to vgVersion:%d cfgVersion:%d stateTs:%" PRId64 " numOfTables:%d",
|
||||
pDbCacheInfo->dbFName, pDbCacheInfo->vgVersion, pDbCacheInfo->cfgVersion, pDbCacheInfo->stateTs,
|
||||
pDbCacheInfo->numOfTable, pDb->vgVersion, pDb->cfgVersion, pDb->stateTs, numOfTable);
|
||||
}
|
||||
|
||||
if (pDbCacheInfo->cfgVersion < pDb->cfgVersion) {
|
||||
|
@ -1956,7 +1961,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs,
|
|||
rsp.pTsmaRsp = taosMemoryCalloc(1, sizeof(STableTSMAInfoRsp));
|
||||
if (rsp.pTsmaRsp) rsp.pTsmaRsp->pTsmas = taosArrayInit(4, POINTER_BYTES);
|
||||
if (rsp.pTsmaRsp && rsp.pTsmaRsp->pTsmas) {
|
||||
bool exist = false;
|
||||
bool exist = false;
|
||||
int32_t code = mndGetDbTsmas(pMnode, 0, pDb->uid, rsp.pTsmaRsp, &exist);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
|
@ -2387,7 +2392,8 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
|||
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, rows, (const char *)strictVstr, false), &lino, _OVER);
|
||||
|
||||
char durationVstr[128] = {0};
|
||||
int32_t len = formatDurationOrKeep(&durationVstr[VARSTR_HEADER_SIZE], sizeof(durationVstr) - VARSTR_HEADER_SIZE, pDb->cfg.daysPerFile);
|
||||
int32_t len = formatDurationOrKeep(&durationVstr[VARSTR_HEADER_SIZE], sizeof(durationVstr) - VARSTR_HEADER_SIZE,
|
||||
pDb->cfg.daysPerFile);
|
||||
|
||||
varDataSetLen(durationVstr, len);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
@ -2403,9 +2409,9 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
|||
int32_t lenKeep2 = formatDurationOrKeep(keep2Str, sizeof(keep2Str), pDb->cfg.daysToKeep2);
|
||||
|
||||
if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) {
|
||||
len = sprintf(&keepVstr[VARSTR_HEADER_SIZE], "%s,%s,%s", keep1Str, keep2Str, keep0Str);
|
||||
len = sprintf(&keepVstr[VARSTR_HEADER_SIZE], "%s,%s,%s", keep1Str, keep2Str, keep0Str);
|
||||
} else {
|
||||
len = sprintf(&keepVstr[VARSTR_HEADER_SIZE], "%s,%s,%s", keep0Str, keep1Str, keep2Str);
|
||||
len = sprintf(&keepVstr[VARSTR_HEADER_SIZE], "%s,%s,%s", keep0Str, keep1Str, keep2Str);
|
||||
}
|
||||
varDataSetLen(keepVstr, len);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
|
|
@ -350,10 +350,10 @@ END:
|
|||
|
||||
void tClearSMqConsumerObj(SMqConsumerObj *pConsumer) {
|
||||
if (pConsumer == NULL) return;
|
||||
taosArrayDestroyP(pConsumer->currentTopics, (FDelete)taosMemoryFree);
|
||||
taosArrayDestroyP(pConsumer->rebNewTopics, (FDelete)taosMemoryFree);
|
||||
taosArrayDestroyP(pConsumer->rebRemovedTopics, (FDelete)taosMemoryFree);
|
||||
taosArrayDestroyP(pConsumer->assignedTopics, (FDelete)taosMemoryFree);
|
||||
taosArrayDestroyP(pConsumer->currentTopics, NULL);
|
||||
taosArrayDestroyP(pConsumer->rebNewTopics, NULL);
|
||||
taosArrayDestroyP(pConsumer->rebRemovedTopics, NULL);
|
||||
taosArrayDestroyP(pConsumer->assignedTopics, NULL);
|
||||
}
|
||||
|
||||
void tDeleteSMqConsumerObj(SMqConsumerObj *pConsumer) {
|
||||
|
|
|
@ -462,7 +462,7 @@ int32_t mndGetDnodeData(SMnode *pMnode, SArray *pDnodeInfo) {
|
|||
dInfo.isMnode = 0;
|
||||
}
|
||||
|
||||
if(taosArrayPush(pDnodeInfo, &dInfo) == NULL){
|
||||
if (taosArrayPush(pDnodeInfo, &dInfo) == NULL) {
|
||||
code = terrno;
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
break;
|
||||
|
@ -471,12 +471,12 @@ int32_t mndGetDnodeData(SMnode *pMnode, SArray *pDnodeInfo) {
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
#define CHECK_MONITOR_PARA(para,err) \
|
||||
if (pCfg->monitorParas.para != para) { \
|
||||
mError("dnode:%d, para:%d inconsistent with cluster:%d", pDnode->id, pCfg->monitorParas.para, para); \
|
||||
terrno = err; \
|
||||
return err;\
|
||||
}
|
||||
#define CHECK_MONITOR_PARA(para, err) \
|
||||
if (pCfg->monitorParas.para != para) { \
|
||||
mError("dnode:%d, para:%d inconsistent with cluster:%d", pDnode->id, pCfg->monitorParas.para, para); \
|
||||
terrno = err; \
|
||||
return err; \
|
||||
}
|
||||
|
||||
static int32_t mndCheckClusterCfgPara(SMnode *pMnode, SDnodeObj *pDnode, const SClusterCfg *pCfg) {
|
||||
CHECK_MONITOR_PARA(tsEnableMonitor, DND_REASON_STATUS_MONITOR_SWITCH_NOT_MATCH);
|
||||
|
@ -486,7 +486,8 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, SDnodeObj *pDnode, const S
|
|||
CHECK_MONITOR_PARA(tsSlowLogScope, DND_REASON_STATUS_MONITOR_SLOW_LOG_SCOPE_NOT_MATCH);
|
||||
|
||||
if (0 != strcasecmp(pCfg->monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb)) {
|
||||
mError("dnode:%d, tsSlowLogExceptDb:%s inconsistent with cluster:%s", pDnode->id, pCfg->monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb);
|
||||
mError("dnode:%d, tsSlowLogExceptDb:%s inconsistent with cluster:%s", pDnode->id,
|
||||
pCfg->monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb);
|
||||
terrno = TSDB_CODE_DNODE_INVALID_MONITOR_PARAS;
|
||||
return DND_REASON_STATUS_MONITOR_NOT_MATCH;
|
||||
}
|
||||
|
@ -582,8 +583,8 @@ static bool mndUpdateMnodeState(SMnodeObj *pObj, SMnodeLoad *pMload) {
|
|||
return stateChanged;
|
||||
}
|
||||
|
||||
extern char* tsMonFwUri;
|
||||
extern char* tsMonSlowLogUri;
|
||||
extern char *tsMonFwUri;
|
||||
extern char *tsMonSlowLogUri;
|
||||
static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
SStatisReq statisReq = {0};
|
||||
|
@ -595,9 +596,9 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
|||
mInfo("process statis req,\n %s", statisReq.pCont);
|
||||
}
|
||||
|
||||
if (statisReq.type == MONITOR_TYPE_COUNTER){
|
||||
if (statisReq.type == MONITOR_TYPE_COUNTER) {
|
||||
monSendContent(statisReq.pCont, tsMonFwUri);
|
||||
}else if(statisReq.type == MONITOR_TYPE_SLOW_LOG){
|
||||
} else if (statisReq.type == MONITOR_TYPE_SLOW_LOG) {
|
||||
monSendContent(statisReq.pCont, tsMonSlowLogUri);
|
||||
}
|
||||
|
||||
|
@ -1057,27 +1058,27 @@ _OVER:
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static void getSlowLogScopeString(int32_t scope, char* result){
|
||||
if(scope == SLOW_LOG_TYPE_NULL) {
|
||||
static void getSlowLogScopeString(int32_t scope, char *result) {
|
||||
if (scope == SLOW_LOG_TYPE_NULL) {
|
||||
(void)strcat(result, "NONE");
|
||||
return;
|
||||
}
|
||||
while(scope > 0){
|
||||
if(scope & SLOW_LOG_TYPE_QUERY) {
|
||||
while (scope > 0) {
|
||||
if (scope & SLOW_LOG_TYPE_QUERY) {
|
||||
(void)strcat(result, "QUERY");
|
||||
scope &= ~SLOW_LOG_TYPE_QUERY;
|
||||
} else if(scope & SLOW_LOG_TYPE_INSERT) {
|
||||
} else if (scope & SLOW_LOG_TYPE_INSERT) {
|
||||
(void)strcat(result, "INSERT");
|
||||
scope &= ~SLOW_LOG_TYPE_INSERT;
|
||||
} else if(scope & SLOW_LOG_TYPE_OTHERS) {
|
||||
} else if (scope & SLOW_LOG_TYPE_OTHERS) {
|
||||
(void)strcat(result, "OTHERS");
|
||||
scope &= ~SLOW_LOG_TYPE_OTHERS;
|
||||
} else{
|
||||
} else {
|
||||
(void)printf("invalid slow log scope:%d", scope);
|
||||
return;
|
||||
}
|
||||
|
||||
if(scope > 0) {
|
||||
if (scope > 0) {
|
||||
(void)strcat(result, "|");
|
||||
}
|
||||
}
|
||||
|
@ -1439,7 +1440,7 @@ _OVER:
|
|||
|
||||
static int32_t mndMCfg2DCfg(SMCfgDnodeReq *pMCfgReq, SDCfgDnodeReq *pDCfgReq) {
|
||||
int32_t code = 0;
|
||||
char *p = pMCfgReq->config;
|
||||
char *p = pMCfgReq->config;
|
||||
while (*p) {
|
||||
if (*p == ' ') {
|
||||
break;
|
||||
|
@ -1448,7 +1449,7 @@ static int32_t mndMCfg2DCfg(SMCfgDnodeReq *pMCfgReq, SDCfgDnodeReq *pDCfgReq) {
|
|||
}
|
||||
|
||||
size_t optLen = p - pMCfgReq->config;
|
||||
(void)strncpy(pDCfgReq->config, pMCfgReq->config, optLen);
|
||||
tstrncpy(pDCfgReq->config, pMCfgReq->config, optLen + 1);
|
||||
pDCfgReq->config[optLen] = 0;
|
||||
|
||||
if (' ' == pMCfgReq->config[optLen]) {
|
||||
|
@ -1537,7 +1538,7 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
|||
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
||||
#endif
|
||||
} else {
|
||||
TAOS_CHECK_GOTO (mndMCfg2DCfg(&cfgReq, &dcfgReq), NULL, _err_out);
|
||||
TAOS_CHECK_GOTO(mndMCfg2DCfg(&cfgReq, &dcfgReq), NULL, _err_out);
|
||||
if (strlen(dcfgReq.config) > TSDB_DNODE_CONFIG_LEN) {
|
||||
mError("dnode:%d, failed to config since config is too long", cfgReq.dnodeId);
|
||||
code = TSDB_CODE_INVALID_CFG;
|
||||
|
@ -1880,11 +1881,19 @@ static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pMCfgReq, int32_t optLen, int32
|
|||
if (' ' == pMCfgReq->config[optLen]) {
|
||||
// 'key value'
|
||||
if (strlen(pMCfgReq->value) != 0) goto _err;
|
||||
*pOutValue = atoi(pMCfgReq->config + optLen + 1);
|
||||
code = taosStr2int32(pMCfgReq->config + optLen + 1, pOutValue);
|
||||
if (code != 0) {
|
||||
mError("dnode:%d, failed to get cfg since %s", pMCfgReq->dnodeId, tstrerror(code));
|
||||
goto _err;
|
||||
}
|
||||
} else {
|
||||
// 'key' 'value'
|
||||
if (strlen(pMCfgReq->value) == 0) goto _err;
|
||||
*pOutValue = atoi(pMCfgReq->value);
|
||||
code = taosStr2int32(pMCfgReq->value, pOutValue);
|
||||
if (code != 0) {
|
||||
mError("dnode:%d, failed to get cfg since %s", pMCfgReq->dnodeId, tstrerror(code));
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
|
||||
TAOS_RETURN(code);
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndAcct.h"
|
||||
#include "mndArbGroup.h"
|
||||
#include "mndAnode.h"
|
||||
#include "mndArbGroup.h"
|
||||
#include "mndCluster.h"
|
||||
#include "mndCompact.h"
|
||||
#include "mndCompactDetail.h"
|
||||
|
@ -254,7 +254,7 @@ static void mndIncreaseUpTime(SMnode *pMnode) {
|
|||
.pCont = pReq,
|
||||
.contLen = contLen,
|
||||
.info.notFreeAhandle = 1,
|
||||
.info.ahandle = (void *)0x9527};
|
||||
.info.ahandle = 0};
|
||||
// TODO check return value
|
||||
if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
|
||||
mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
|
||||
|
@ -530,7 +530,7 @@ static int32_t mndInitWal(SMnode *pMnode) {
|
|||
code = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||
TAOS_RETURN(code);
|
||||
} else {
|
||||
(void)strncpy(cfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
tstrncpy(cfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndMnode.h"
|
||||
#include "audit.h"
|
||||
#include "mndCluster.h"
|
||||
#include "mndDnode.h"
|
||||
#include "mndMnode.h"
|
||||
#include "mndPrivilege.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndSync.h"
|
||||
|
@ -722,10 +722,13 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) {
|
|||
code = mndCreateMnode(pMnode, pReq, pDnode, &createReq);
|
||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
|
||||
char obj[40] = {0};
|
||||
sprintf(obj, "%d", createReq.dnodeId);
|
||||
|
||||
auditRecord(pReq, pMnode->clusterId, "createMnode", "", obj, createReq.sql, createReq.sqlLen);
|
||||
char obj[40] = {0};
|
||||
int32_t bytes = snprintf(obj, sizeof(obj), "%d", createReq.dnodeId);
|
||||
if ((uint32_t)bytes < sizeof(obj)) {
|
||||
auditRecord(pReq, pMnode->clusterId, "createMnode", "", obj, createReq.sql, createReq.sqlLen);
|
||||
} else {
|
||||
mError("mnode:%d, failed to audit create req since %s", createReq.dnodeId, tstrerror(TSDB_CODE_OUT_OF_RANGE));
|
||||
}
|
||||
|
||||
_OVER:
|
||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndProfile.h"
|
||||
#include "audit.h"
|
||||
#include "mndDb.h"
|
||||
#include "mndDnode.h"
|
||||
#include "mndMnode.h"
|
||||
#include "mndPrivilege.h"
|
||||
#include "mndProfile.h"
|
||||
#include "mndQnode.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndSma.h"
|
||||
|
@ -344,10 +344,13 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
|
|||
|
||||
code = 0;
|
||||
|
||||
char detail[1000] = {0};
|
||||
(void)sprintf(detail, "app:%s", connReq.app);
|
||||
|
||||
auditRecord(pReq, pMnode->clusterId, "login", "", "", detail, strlen(detail));
|
||||
char detail[1000] = {0};
|
||||
int32_t nBytes = snprintf(detail, sizeof(detail), "app:%s", connReq.app);
|
||||
if ((uint32_t)nBytes < sizeof(detail)) {
|
||||
auditRecord(pReq, pMnode->clusterId, "login", "", "", detail, strlen(detail));
|
||||
} else {
|
||||
mError("failed to audit logic since %s", tstrerror(TSDB_CODE_OUT_OF_RANGE));
|
||||
}
|
||||
|
||||
_OVER:
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndSma.h"
|
||||
#include "functionMgt.h"
|
||||
#include "mndDb.h"
|
||||
#include "mndDnode.h"
|
||||
#include "mndIndex.h"
|
||||
|
@ -31,7 +32,6 @@
|
|||
#include "mndVgroup.h"
|
||||
#include "parser.h"
|
||||
#include "tname.h"
|
||||
#include "functionMgt.h"
|
||||
|
||||
#define TSDB_SMA_VER_NUMBER 1
|
||||
#define TSDB_SMA_RESERVE_SIZE 64
|
||||
|
@ -48,8 +48,8 @@ static int32_t mndProcessGetTbSmaReq(SRpcMsg *pReq);
|
|||
static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||
static void mndDestroySmaObj(SSmaObj *pSmaObj);
|
||||
|
||||
static int32_t mndProcessCreateTSMAReq(SRpcMsg* pReq);
|
||||
static int32_t mndProcessDropTSMAReq(SRpcMsg* pReq);
|
||||
static int32_t mndProcessCreateTSMAReq(SRpcMsg *pReq);
|
||||
static int32_t mndProcessDropTSMAReq(SRpcMsg *pReq);
|
||||
|
||||
// sma and tag index comm func
|
||||
static int32_t mndProcessDropIdxReq(SRpcMsg *pReq);
|
||||
|
@ -61,11 +61,11 @@ static void mndCancelRetrieveTSMA(SMnode *pMnode, void *pIter);
|
|||
static int32_t mndProcessGetTbTSMAReq(SRpcMsg *pReq);
|
||||
|
||||
typedef struct SCreateTSMACxt {
|
||||
SMnode * pMnode;
|
||||
SMnode *pMnode;
|
||||
const SRpcMsg *pRpcReq;
|
||||
union {
|
||||
const SMCreateSmaReq *pCreateSmaReq;
|
||||
const SMDropSmaReq * pDropSmaReq;
|
||||
const SMDropSmaReq *pDropSmaReq;
|
||||
};
|
||||
SDbObj *pDb;
|
||||
SStbObj *pSrcStb;
|
||||
|
@ -298,16 +298,13 @@ void mndReleaseSma(SMnode *pMnode, SSmaObj *pSma) {
|
|||
sdbRelease(pSdb, pSma);
|
||||
}
|
||||
|
||||
SDbObj *mndAcquireDbBySma(SMnode *pMnode, const char *db) {
|
||||
|
||||
return mndAcquireDb(pMnode, db);
|
||||
}
|
||||
SDbObj *mndAcquireDbBySma(SMnode *pMnode, const char *db) { return mndAcquireDb(pMnode, db); }
|
||||
|
||||
static void *mndBuildVCreateSmaReq(SMnode *pMnode, SVgObj *pVgroup, SSmaObj *pSma, int32_t *pContLen) {
|
||||
SEncoder encoder = {0};
|
||||
int32_t contLen = 0;
|
||||
SName name = {0};
|
||||
int32_t code = tNameFromString(&name, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
int32_t code = tNameFromString(&name, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -368,7 +365,7 @@ static void *mndBuildVDropSmaReq(SMnode *pMnode, SVgObj *pVgroup, SSmaObj *pSma,
|
|||
SEncoder encoder = {0};
|
||||
int32_t contLen;
|
||||
SName name = {0};
|
||||
int32_t code = tNameFromString(&name, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
int32_t code = tNameFromString(&name, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
terrno = code;
|
||||
return NULL;
|
||||
|
@ -424,9 +421,9 @@ static int32_t mndSetCreateSmaRedoLogs(SMnode *pMnode, STrans *pTrans, SSmaObj *
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static int32_t mndSetCreateSmaUndoLogs(SMnode* pMnode, STrans* pTrans, SSmaObj* pSma) {
|
||||
int32_t code = 0;
|
||||
SSdbRaw * pUndoRaw = mndSmaActionEncode(pSma);
|
||||
static int32_t mndSetCreateSmaUndoLogs(SMnode *pMnode, STrans *pTrans, SSmaObj *pSma) {
|
||||
int32_t code = 0;
|
||||
SSdbRaw *pUndoRaw = mndSmaActionEncode(pSma);
|
||||
if (!pUndoRaw) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
|
@ -670,7 +667,8 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
|||
// check the maxDelay
|
||||
if (streamObj.conf.triggerParam < TSDB_MIN_ROLLUP_MAX_DELAY) {
|
||||
int64_t msInterval = -1;
|
||||
int32_t code = convertTimeFromPrecisionToUnit(pCreate->interval, pDb->cfg.precision, TIME_UNIT_MILLISECOND, &msInterval);
|
||||
int32_t code =
|
||||
convertTimeFromPrecisionToUnit(pCreate->interval, pDb->cfg.precision, TIME_UNIT_MILLISECOND, &msInterval);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
mError("sma:%s, failed to create since convert time failed: %s", smaObj.name, tstrerror(code));
|
||||
return code;
|
||||
|
@ -792,7 +790,7 @@ static int32_t mndCheckCreateSmaReq(SMCreateSmaReq *pCreate) {
|
|||
}
|
||||
|
||||
static int32_t mndGetStreamNameFromSmaName(char *streamName, char *smaName) {
|
||||
SName n;
|
||||
SName n;
|
||||
int32_t code = tNameFromString(&n, smaName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
|
@ -984,10 +982,10 @@ static int32_t mndSetDropSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SD
|
|||
}
|
||||
|
||||
static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *pSma) {
|
||||
int32_t code = -1;
|
||||
SVgObj *pVgroup = NULL;
|
||||
SStbObj *pStb = NULL;
|
||||
STrans *pTrans = NULL;
|
||||
int32_t code = -1;
|
||||
SVgObj *pVgroup = NULL;
|
||||
SStbObj *pStb = NULL;
|
||||
STrans *pTrans = NULL;
|
||||
SStreamObj *pStream = NULL;
|
||||
|
||||
pVgroup = mndAcquireVgroup(pMnode, pSma->dstVgId);
|
||||
|
@ -1023,7 +1021,6 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
|
||||
code = mndAcquireStream(pMnode, streamName, &pStream);
|
||||
if (pStream == NULL || pStream->smaId != pSma->uid || code != 0) {
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
|
@ -1124,8 +1121,8 @@ _OVER:
|
|||
|
||||
int32_t mndDropSmasByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
||||
int32_t code = 0;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
void *pIter = NULL;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
void *pIter = NULL;
|
||||
|
||||
while (1) {
|
||||
SSmaObj *pSma = NULL;
|
||||
|
@ -1232,7 +1229,7 @@ static int32_t mndGetSma(SMnode *pMnode, SUserIndexReq *indexReq, SUserIndexRsp
|
|||
FOREACH(node, pList) {
|
||||
SFunctionNode *pFunc = (SFunctionNode *)node;
|
||||
extOffset += tsnprintf(rsp->indexExts + extOffset, sizeof(rsp->indexExts) - extOffset - 1, "%s%s",
|
||||
(extOffset ? "," : ""), pFunc->functionName);
|
||||
(extOffset ? "," : ""), pFunc->functionName);
|
||||
}
|
||||
|
||||
*exist = true;
|
||||
|
@ -1439,8 +1436,8 @@ static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
|||
|
||||
SName smaName = {0};
|
||||
SName stbName = {0};
|
||||
char n2[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
char n3[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
char n2[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
char n3[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
code = tNameFromString(&smaName, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
char n1[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -1448,7 +1445,7 @@ static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
|||
STR_TO_VARSTR(n2, (char *)mndGetDbStr(pSma->db));
|
||||
code = tNameFromString(&stbName, pSma->stb, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
}
|
||||
SColumnInfoData* pColInfo = NULL;
|
||||
SColumnInfoData *pColInfo = NULL;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
STR_TO_VARSTR(n3, (char *)tNameGetTableName(&stbName));
|
||||
|
||||
|
@ -1540,7 +1537,7 @@ static void mndCancelRetrieveIdx(SMnode *pMnode, void *pIter) {
|
|||
taosMemoryFree(p);
|
||||
}
|
||||
|
||||
static void initSMAObj(SCreateTSMACxt* pCxt) {
|
||||
static void initSMAObj(SCreateTSMACxt *pCxt) {
|
||||
memcpy(pCxt->pSma->name, pCxt->pCreateSmaReq->name, TSDB_TABLE_FNAME_LEN);
|
||||
memcpy(pCxt->pSma->stb, pCxt->pCreateSmaReq->stb, TSDB_TABLE_FNAME_LEN);
|
||||
memcpy(pCxt->pSma->db, pCxt->pDb->name, TSDB_DB_FNAME_LEN);
|
||||
|
@ -1549,7 +1546,7 @@ static void initSMAObj(SCreateTSMACxt* pCxt) {
|
|||
pCxt->pSma->uid = mndGenerateUid(pCxt->pCreateSmaReq->name, TSDB_TABLE_FNAME_LEN);
|
||||
|
||||
memcpy(pCxt->pSma->dstTbName, pCxt->targetStbFullName, TSDB_TABLE_FNAME_LEN);
|
||||
pCxt->pSma->dstTbUid = 0; // not used
|
||||
pCxt->pSma->dstTbUid = 0; // not used
|
||||
pCxt->pSma->stbUid = pCxt->pSrcStb ? pCxt->pSrcStb->uid : pCxt->pCreateSmaReq->normSourceTbUid;
|
||||
pCxt->pSma->dbUid = pCxt->pDb->uid;
|
||||
pCxt->pSma->interval = pCxt->pCreateSmaReq->interval;
|
||||
|
@ -1598,7 +1595,7 @@ static int32_t mndCreateTSMABuildCreateStreamReq(SCreateTSMACxt *pCxt) {
|
|||
if (!pCxt->pCreateStreamReq->pTags) {
|
||||
return terrno;
|
||||
}
|
||||
SField f = {0};
|
||||
SField f = {0};
|
||||
int32_t code = 0;
|
||||
if (pCxt->pSrcStb) {
|
||||
for (int32_t idx = 0; idx < pCxt->pCreateStreamReq->numOfTags - 1; ++idx) {
|
||||
|
@ -1626,9 +1623,9 @@ static int32_t mndCreateTSMABuildCreateStreamReq(SCreateTSMACxt *pCxt) {
|
|||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
// construct output cols
|
||||
SNode* pNode;
|
||||
SNode *pNode;
|
||||
FOREACH(pNode, pCxt->pProjects) {
|
||||
SExprNode* pExprNode = (SExprNode*)pNode;
|
||||
SExprNode *pExprNode = (SExprNode *)pNode;
|
||||
f.bytes = pExprNode->resType.bytes;
|
||||
f.type = pExprNode->resType.type;
|
||||
f.flags = COL_SMA_ON;
|
||||
|
@ -1642,7 +1639,7 @@ static int32_t mndCreateTSMABuildCreateStreamReq(SCreateTSMACxt *pCxt) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndCreateTSMABuildDropStreamReq(SCreateTSMACxt* pCxt) {
|
||||
static int32_t mndCreateTSMABuildDropStreamReq(SCreateTSMACxt *pCxt) {
|
||||
tstrncpy(pCxt->pDropStreamReq->name, pCxt->streamName, TSDB_STREAM_FNAME_LEN);
|
||||
pCxt->pDropStreamReq->igNotExists = false;
|
||||
pCxt->pDropStreamReq->sql = taosStrdup(pCxt->pDropSmaReq->name);
|
||||
|
@ -1685,14 +1682,13 @@ static int32_t mndSetUpdateDbTsmaVersionCommitLogs(SMnode *pMnode, STrans *pTran
|
|||
TAOS_RETURN(sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY));
|
||||
}
|
||||
|
||||
static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt* pCxt) {
|
||||
static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt *pCxt) {
|
||||
int32_t code = -1;
|
||||
STransAction createStreamRedoAction = {0};
|
||||
STransAction createStreamUndoAction = {0};
|
||||
STransAction dropStbUndoAction = {0};
|
||||
SMDropStbReq dropStbReq = {0};
|
||||
STrans *pTrans =
|
||||
mndTransCreate(pCxt->pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_TSMA, pCxt->pRpcReq, "create-tsma");
|
||||
STrans *pTrans = mndTransCreate(pCxt->pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_TSMA, pCxt->pRpcReq, "create-tsma");
|
||||
if (!pTrans) {
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
|
@ -1713,7 +1709,9 @@ static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt* pCxt) {
|
|||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
if (createStreamRedoAction.contLen != tSerializeSCMCreateStreamReq(createStreamRedoAction.pCont, createStreamRedoAction.contLen, pCxt->pCreateStreamReq)) {
|
||||
if (createStreamRedoAction.contLen != tSerializeSCMCreateStreamReq(createStreamRedoAction.pCont,
|
||||
createStreamRedoAction.contLen,
|
||||
pCxt->pCreateStreamReq)) {
|
||||
mError("sma: %s, failed to create due to create stream req encode failure", pCxt->pCreateSmaReq->name);
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto _OVER;
|
||||
|
@ -1728,7 +1726,8 @@ static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt* pCxt) {
|
|||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
if (createStreamUndoAction.contLen != tSerializeSMDropStreamReq(createStreamUndoAction.pCont, createStreamUndoAction.contLen, pCxt->pDropStreamReq)) {
|
||||
if (createStreamUndoAction.contLen !=
|
||||
tSerializeSMDropStreamReq(createStreamUndoAction.pCont, createStreamUndoAction.contLen, pCxt->pDropStreamReq)) {
|
||||
mError("sma: %s, failed to create due to drop stream req encode failure", pCxt->pCreateSmaReq->name);
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto _OVER;
|
||||
|
@ -1746,7 +1745,8 @@ static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt* pCxt) {
|
|||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
if (dropStbUndoAction.contLen != tSerializeSMDropStbReq(dropStbUndoAction.pCont, dropStbUndoAction.contLen, &dropStbReq)) {
|
||||
if (dropStbUndoAction.contLen !=
|
||||
tSerializeSMDropStbReq(dropStbUndoAction.pCont, dropStbUndoAction.contLen, &dropStbReq)) {
|
||||
mError("sma: %s, failed to create due to drop stb req encode failure", pCxt->pCreateSmaReq->name);
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto _OVER;
|
||||
|
@ -1781,7 +1781,7 @@ static int32_t mndCreateTSMA(SCreateTSMACxt *pCxt) {
|
|||
pCxt->pSma = &sma;
|
||||
initSMAObj(pCxt);
|
||||
|
||||
SNodeList* pProjects = NULL;
|
||||
SNodeList *pProjects = NULL;
|
||||
code = nodesStringToList(pCxt->pCreateSmaReq->expr, &pProjects);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto _OVER;
|
||||
|
@ -1830,8 +1830,8 @@ _OVER:
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static int32_t mndTSMAGenerateOutputName(const char* tsmaName, char* streamName, char* targetStbName) {
|
||||
SName smaName;
|
||||
static int32_t mndTSMAGenerateOutputName(const char *tsmaName, char *streamName, char *targetStbName) {
|
||||
SName smaName;
|
||||
int32_t code = tNameFromString(&smaName, tsmaName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
|
@ -1841,17 +1841,17 @@ static int32_t mndTSMAGenerateOutputName(const char* tsmaName, char* streamName,
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateTSMAReq(SRpcMsg* pReq) {
|
||||
static int32_t mndProcessCreateTSMAReq(SRpcMsg *pReq) {
|
||||
#ifdef WINDOWS
|
||||
TAOS_RETURN(TSDB_CODE_MND_INVALID_PLATFORM);
|
||||
#endif
|
||||
SMnode * pMnode = pReq->info.node;
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
int32_t code = -1;
|
||||
SDbObj * pDb = NULL;
|
||||
SStbObj * pStb = NULL;
|
||||
SSmaObj * pSma = NULL;
|
||||
SSmaObj * pBaseTsma = NULL;
|
||||
SStreamObj * pStream = NULL;
|
||||
SDbObj *pDb = NULL;
|
||||
SStbObj *pStb = NULL;
|
||||
SSmaObj *pSma = NULL;
|
||||
SSmaObj *pBaseTsma = NULL;
|
||||
SStreamObj *pStream = NULL;
|
||||
int64_t mTraceId = TRACE_GET_ROOTID(&pReq->info.traceId);
|
||||
SMCreateSmaReq createReq = {0};
|
||||
|
||||
|
@ -1941,16 +1941,16 @@ static int32_t mndProcessCreateTSMAReq(SRpcMsg* pReq) {
|
|||
}
|
||||
|
||||
SCreateTSMACxt cxt = {
|
||||
.pMnode = pMnode,
|
||||
.pCreateSmaReq = &createReq,
|
||||
.pCreateStreamReq = NULL,
|
||||
.streamName = streamName,
|
||||
.targetStbFullName = streamTargetStbFullName,
|
||||
.pDb = pDb,
|
||||
.pRpcReq = pReq,
|
||||
.pSma = NULL,
|
||||
.pBaseSma = pBaseTsma,
|
||||
.pSrcStb = pStb,
|
||||
.pMnode = pMnode,
|
||||
.pCreateSmaReq = &createReq,
|
||||
.pCreateStreamReq = NULL,
|
||||
.streamName = streamName,
|
||||
.targetStbFullName = streamTargetStbFullName,
|
||||
.pDb = pDb,
|
||||
.pRpcReq = pReq,
|
||||
.pSma = NULL,
|
||||
.pBaseSma = pBaseTsma,
|
||||
.pSrcStb = pStb,
|
||||
};
|
||||
|
||||
code = mndCreateTSMA(&cxt);
|
||||
|
@ -1971,10 +1971,10 @@ _OVER:
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static int32_t mndDropTSMA(SCreateTSMACxt* pCxt) {
|
||||
int32_t code = -1;
|
||||
static int32_t mndDropTSMA(SCreateTSMACxt *pCxt) {
|
||||
int32_t code = -1;
|
||||
STransAction dropStreamRedoAction = {0};
|
||||
STrans *pTrans = mndTransCreate(pCxt->pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_TSMA, pCxt->pRpcReq, "drop-tsma");
|
||||
STrans *pTrans = mndTransCreate(pCxt->pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_TSMA, pCxt->pRpcReq, "drop-tsma");
|
||||
if (!pTrans) {
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
|
@ -2021,7 +2021,8 @@ static int32_t mndDropTSMA(SCreateTSMACxt* pCxt) {
|
|||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
if (dropStbRedoAction.contLen != tSerializeSMDropStbReq(dropStbRedoAction.pCont, dropStbRedoAction.contLen, &dropStbReq)) {
|
||||
if (dropStbRedoAction.contLen !=
|
||||
tSerializeSMDropStbReq(dropStbRedoAction.pCont, dropStbRedoAction.contLen, &dropStbReq)) {
|
||||
mError("tsma: %s, failedto drop due to drop stb req encode failure", pCxt->pDropSmaReq->name);
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto _OVER;
|
||||
|
@ -2044,9 +2045,9 @@ _OVER:
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static bool hasRecursiveTsmasBasedOnMe(SMnode* pMnode, const SSmaObj* pSma) {
|
||||
static bool hasRecursiveTsmasBasedOnMe(SMnode *pMnode, const SSmaObj *pSma) {
|
||||
SSmaObj *pSmaObj = NULL;
|
||||
void * pIter = NULL;
|
||||
void *pIter = NULL;
|
||||
while (1) {
|
||||
pIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter, (void **)&pSmaObj);
|
||||
if (pIter == NULL) break;
|
||||
|
@ -2060,25 +2061,25 @@ static bool hasRecursiveTsmasBasedOnMe(SMnode* pMnode, const SSmaObj* pSma) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static int32_t mndProcessDropTSMAReq(SRpcMsg* pReq) {
|
||||
static int32_t mndProcessDropTSMAReq(SRpcMsg *pReq) {
|
||||
int32_t code = -1;
|
||||
SMDropSmaReq dropReq = {0};
|
||||
SSmaObj * pSma = NULL;
|
||||
SDbObj * pDb = NULL;
|
||||
SMnode * pMnode = pReq->info.node;
|
||||
SSmaObj *pSma = NULL;
|
||||
SDbObj *pDb = NULL;
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
if (tDeserializeSMDropSmaReq(pReq->pCont, pReq->contLen, &dropReq) != TSDB_CODE_SUCCESS) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
char streamTargetStbFullName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
char streamTargetStbFullName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
code = mndTSMAGenerateOutputName(dropReq.name, streamName, streamTargetStbFullName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
SStbObj* pStb = mndAcquireStb(pMnode, streamTargetStbFullName);
|
||||
SStbObj *pStb = mndAcquireStb(pMnode, streamTargetStbFullName);
|
||||
|
||||
pSma = mndAcquireSma(pMnode, dropReq.name);
|
||||
if (!pSma && dropReq.igNotExists) {
|
||||
|
@ -2113,13 +2114,13 @@ static int32_t mndProcessDropTSMAReq(SRpcMsg* pReq) {
|
|||
}
|
||||
|
||||
SCreateTSMACxt cxt = {
|
||||
.pDb = pDb,
|
||||
.pMnode = pMnode,
|
||||
.pRpcReq = pReq,
|
||||
.pSma = pSma,
|
||||
.streamName = streamName,
|
||||
.targetStbFullName = streamTargetStbFullName,
|
||||
.pDropSmaReq = &dropReq,
|
||||
.pDb = pDb,
|
||||
.pMnode = pMnode,
|
||||
.pRpcReq = pReq,
|
||||
.pSma = pSma,
|
||||
.streamName = streamName,
|
||||
.targetStbFullName = streamTargetStbFullName,
|
||||
.pDropSmaReq = &dropReq,
|
||||
};
|
||||
|
||||
code = mndDropTSMA(&cxt);
|
||||
|
@ -2134,10 +2135,10 @@ _OVER:
|
|||
}
|
||||
|
||||
static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||
SDbObj * pDb = NULL;
|
||||
SDbObj *pDb = NULL;
|
||||
int32_t numOfRows = 0;
|
||||
SSmaObj * pSma = NULL;
|
||||
SMnode * pMnode = pReq->info.node;
|
||||
SSmaObj *pSma = NULL;
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
int32_t code = 0;
|
||||
SColumnInfoData *pColInfo;
|
||||
if (pShow->pIter == NULL) {
|
||||
|
@ -2153,7 +2154,7 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
|||
while (numOfRows < rows) {
|
||||
pIter->pSmaIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter->pSmaIter, (void **)&pSma);
|
||||
if (pIter->pSmaIter == NULL) break;
|
||||
SDbObj* pSrcDb = mndAcquireDb(pMnode, pSma->db);
|
||||
SDbObj *pSrcDb = mndAcquireDb(pMnode, pSma->db);
|
||||
|
||||
if ((pDb && pSma->dbUid != pDb->uid) || !pSrcDb) {
|
||||
sdbRelease(pMnode->pSdb, pSma);
|
||||
|
@ -2176,7 +2177,7 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
STR_TO_VARSTR(db, (char *)mndGetDbStr(pSma->db));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)db, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)db, false);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -2186,12 +2187,12 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
STR_TO_VARSTR(srcTb, (char *)tNameGetTableName(&n));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)srcTb, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)srcTb, false);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)db, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)db, false);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -2200,29 +2201,29 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
|||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
char targetTb[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(targetTb, (char*)tNameGetTableName(&n));
|
||||
STR_TO_VARSTR(targetTb, (char *)tNameGetTableName(&n));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)targetTb, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)targetTb, false);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
// stream name
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)smaName, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)smaName, false);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)(&pSma->createdTime), false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)(&pSma->createdTime), false);
|
||||
}
|
||||
|
||||
// interval
|
||||
char interval[64 + VARSTR_HEADER_SIZE] = {0};
|
||||
char interval[64 + VARSTR_HEADER_SIZE] = {0};
|
||||
int32_t len = 0;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (!IS_CALENDAR_TIME_DURATION(pSma->intervalUnit)) {
|
||||
len = tsnprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval,
|
||||
getPrecisionUnit(pSrcDb->cfg.precision));
|
||||
getPrecisionUnit(pSrcDb->cfg.precision));
|
||||
} else {
|
||||
len = tsnprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval, pSma->intervalUnit);
|
||||
}
|
||||
|
@ -2243,17 +2244,17 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
|||
// func list
|
||||
len = 0;
|
||||
SNode *pNode = NULL, *pFunc = NULL;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesStringToNode(pSma->ast, &pNode);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
char * start = buf + VARSTR_HEADER_SIZE;
|
||||
char *start = buf + VARSTR_HEADER_SIZE;
|
||||
FOREACH(pFunc, ((SSelectStmt *)pNode)->pProjectionList) {
|
||||
if (nodeType(pFunc) == QUERY_NODE_FUNCTION) {
|
||||
SFunctionNode *pFuncNode = (SFunctionNode *)pFunc;
|
||||
if (!fmIsTSMASupportedFunc(pFuncNode->funcId)) continue;
|
||||
len += tsnprintf(start, TSDB_MAX_SAVED_SQL_LEN - len, "%s%s", start != buf + VARSTR_HEADER_SIZE ? "," : "",
|
||||
((SExprNode *)pFunc)->userAlias);
|
||||
((SExprNode *)pFunc)->userAlias);
|
||||
if (len >= TSDB_MAX_SAVED_SQL_LEN) {
|
||||
len = TSDB_MAX_SAVED_SQL_LEN;
|
||||
break;
|
||||
|
@ -2297,7 +2298,8 @@ static void mndCancelRetrieveTSMA(SMnode *pMnode, void *pIter) {
|
|||
taosMemoryFree(p);
|
||||
}
|
||||
|
||||
int32_t dumpTSMAInfoFromSmaObj(const SSmaObj* pSma, const SStbObj* pDestStb, STableTSMAInfo* pInfo, const SSmaObj* pBaseTsma) {
|
||||
int32_t dumpTSMAInfoFromSmaObj(const SSmaObj *pSma, const SStbObj *pDestStb, STableTSMAInfo *pInfo,
|
||||
const SSmaObj *pBaseTsma) {
|
||||
int32_t code = 0;
|
||||
pInfo->interval = pSma->interval;
|
||||
pInfo->unit = pSma->intervalUnit;
|
||||
|
@ -2336,7 +2338,7 @@ int32_t dumpTSMAInfoFromSmaObj(const SSmaObj* pSma, const SStbObj* pDestStb, STa
|
|||
SSelectStmt *pSelect = (SSelectStmt *)pNode;
|
||||
FOREACH(pFunc, pSelect->pProjectionList) {
|
||||
STableTSMAFuncInfo funcInfo = {0};
|
||||
SFunctionNode * pFuncNode = (SFunctionNode *)pFunc;
|
||||
SFunctionNode *pFuncNode = (SFunctionNode *)pFunc;
|
||||
if (!fmIsTSMASupportedFunc(pFuncNode->funcId)) continue;
|
||||
funcInfo.funcId = pFuncNode->funcId;
|
||||
funcInfo.colId = ((SColumnNode *)pFuncNode->pParameterList->pHead->pNode)->colId;
|
||||
|
@ -2383,9 +2385,9 @@ int32_t dumpTSMAInfoFromSmaObj(const SSmaObj* pSma, const SStbObj* pDestStb, STa
|
|||
}
|
||||
|
||||
// @note remember to mndReleaseSma(*ppOut)
|
||||
static int32_t mndGetDeepestBaseForTsma(SMnode* pMnode, SSmaObj* pSma, SSmaObj** ppOut) {
|
||||
int32_t code = 0;
|
||||
SSmaObj* pRecursiveTsma = NULL;
|
||||
static int32_t mndGetDeepestBaseForTsma(SMnode *pMnode, SSmaObj *pSma, SSmaObj **ppOut) {
|
||||
int32_t code = 0;
|
||||
SSmaObj *pRecursiveTsma = NULL;
|
||||
if (pSma->baseSmaName[0]) {
|
||||
pRecursiveTsma = mndAcquireSma(pMnode, pSma->baseSmaName);
|
||||
if (!pRecursiveTsma) {
|
||||
|
@ -2393,7 +2395,7 @@ static int32_t mndGetDeepestBaseForTsma(SMnode* pMnode, SSmaObj* pSma, SSmaObj**
|
|||
return TSDB_CODE_MND_SMA_NOT_EXIST;
|
||||
}
|
||||
while (pRecursiveTsma->baseSmaName[0]) {
|
||||
SSmaObj* pTmpSma = pRecursiveTsma;
|
||||
SSmaObj *pTmpSma = pRecursiveTsma;
|
||||
pRecursiveTsma = mndAcquireSma(pMnode, pTmpSma->baseSmaName);
|
||||
if (!pRecursiveTsma) {
|
||||
mError("base tsma: %s for tsma: %s not found", pTmpSma->baseSmaName, pTmpSma->name);
|
||||
|
@ -2407,7 +2409,6 @@ static int32_t mndGetDeepestBaseForTsma(SMnode* pMnode, SSmaObj* pSma, SSmaObj**
|
|||
return code;
|
||||
}
|
||||
|
||||
|
||||
static int32_t mndGetTSMA(SMnode *pMnode, char *tsmaFName, STableTSMAInfoRsp *rsp, bool *exist) {
|
||||
int32_t code = -1;
|
||||
SSmaObj *pSma = NULL;
|
||||
|
@ -2450,17 +2451,17 @@ static int32_t mndGetTSMA(SMnode *pMnode, char *tsmaFName, STableTSMAInfoRsp *rs
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
typedef bool (*tsmaFilter)(const SSmaObj* pSma, void* param);
|
||||
typedef bool (*tsmaFilter)(const SSmaObj *pSma, void *param);
|
||||
|
||||
static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilter filtered, void* param, bool* exist) {
|
||||
int32_t code = 0;
|
||||
SSmaObj * pSma = NULL;
|
||||
SSmaObj * pBaseTsma = NULL;
|
||||
SSdb * pSdb = pMnode->pSdb;
|
||||
void * pIter = NULL;
|
||||
SStreamObj * pStream = NULL;
|
||||
SStbObj * pStb = NULL;
|
||||
bool shouldRetry = false;
|
||||
static int32_t mndGetSomeTsmas(SMnode *pMnode, STableTSMAInfoRsp *pRsp, tsmaFilter filtered, void *param, bool *exist) {
|
||||
int32_t code = 0;
|
||||
SSmaObj *pSma = NULL;
|
||||
SSmaObj *pBaseTsma = NULL;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
void *pIter = NULL;
|
||||
SStreamObj *pStream = NULL;
|
||||
SStbObj *pStb = NULL;
|
||||
bool shouldRetry = false;
|
||||
|
||||
while (1) {
|
||||
pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma);
|
||||
|
@ -2479,7 +2480,7 @@ static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilt
|
|||
}
|
||||
|
||||
SName smaName;
|
||||
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
code = tNameFromString(&smaName, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
sdbRelease(pSdb, pSma);
|
||||
|
@ -2541,8 +2542,8 @@ static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilt
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static bool tsmaTbFilter(const SSmaObj* pSma, void* param) {
|
||||
const char* tbFName = param;
|
||||
static bool tsmaTbFilter(const SSmaObj *pSma, void *param) {
|
||||
const char *tbFName = param;
|
||||
return pSma->stb[0] != tbFName[0] || strcmp(pSma->stb, tbFName) != 0;
|
||||
}
|
||||
|
||||
|
@ -2550,7 +2551,7 @@ static int32_t mndGetTableTSMA(SMnode *pMnode, char *tbFName, STableTSMAInfoRsp
|
|||
return mndGetSomeTsmas(pMnode, pRsp, tsmaTbFilter, tbFName, exist);
|
||||
}
|
||||
|
||||
static bool tsmaDbFilter(const SSmaObj* pSma, void* param) {
|
||||
static bool tsmaDbFilter(const SSmaObj *pSma, void *param) {
|
||||
uint64_t *dbUid = param;
|
||||
return pSma->dbUid != *dbUid;
|
||||
}
|
||||
|
@ -2564,7 +2565,7 @@ static int32_t mndProcessGetTbTSMAReq(SRpcMsg *pReq) {
|
|||
int32_t code = -1;
|
||||
STableTSMAInfoReq tsmaReq = {0};
|
||||
bool exist = false;
|
||||
SMnode * pMnode = pReq->info.node;
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
|
||||
TAOS_CHECK_GOTO(tDeserializeTableTSMAInfoReq(pReq->pCont, pReq->contLen, &tsmaReq), NULL, _OVER);
|
||||
|
||||
|
@ -2635,12 +2636,12 @@ static int32_t mkNonExistTSMAInfo(const STSMAVersion *pTsmaVer, STableTSMAInfo *
|
|||
|
||||
int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t numOfTsmas, void **ppRsp,
|
||||
int32_t *pRspLen) {
|
||||
int32_t code = -1;
|
||||
STSMAHbRsp hbRsp = {0};
|
||||
int32_t rspLen = 0;
|
||||
void * pRsp = NULL;
|
||||
char tsmaFName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
STableTSMAInfo * pTsmaInfo = NULL;
|
||||
int32_t code = -1;
|
||||
STSMAHbRsp hbRsp = {0};
|
||||
int32_t rspLen = 0;
|
||||
void *pRsp = NULL;
|
||||
char tsmaFName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
STableTSMAInfo *pTsmaInfo = NULL;
|
||||
|
||||
hbRsp.pTsmas = taosArrayInit(numOfTsmas, POINTER_BYTES);
|
||||
if (!hbRsp.pTsmas) {
|
||||
|
@ -2649,13 +2650,13 @@ int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < numOfTsmas; ++i) {
|
||||
STSMAVersion* pTsmaVer = &pTsmaVersions[i];
|
||||
STSMAVersion *pTsmaVer = &pTsmaVersions[i];
|
||||
pTsmaVer->dbId = be64toh(pTsmaVer->dbId);
|
||||
pTsmaVer->tsmaId = be64toh(pTsmaVer->tsmaId);
|
||||
pTsmaVer->version = ntohl(pTsmaVer->version);
|
||||
|
||||
snprintf(tsmaFName, sizeof(tsmaFName), "%s.%s", pTsmaVer->dbFName, pTsmaVer->name);
|
||||
SSmaObj* pSma = mndAcquireSma(pMnode, tsmaFName);
|
||||
SSmaObj *pSma = mndAcquireSma(pMnode, tsmaFName);
|
||||
if (!pSma) {
|
||||
code = mkNonExistTSMAInfo(pTsmaVer, &pTsmaInfo);
|
||||
if (code) goto _OVER;
|
||||
|
@ -2683,7 +2684,7 @@ int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t
|
|||
continue;
|
||||
}
|
||||
|
||||
SStbObj* pDestStb = mndAcquireStb(pMnode, pSma->dstTbName);
|
||||
SStbObj *pDestStb = mndAcquireStb(pMnode, pSma->dstTbName);
|
||||
if (!pDestStb) {
|
||||
mInfo("tsma: %s.%" PRIx64 " dest stb: %s not found, maybe dropped", tsmaFName, pTsmaVer->tsmaId, pSma->dstTbName);
|
||||
code = mkNonExistTSMAInfo(pTsmaVer, &pTsmaInfo);
|
||||
|
@ -2698,7 +2699,7 @@ int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t
|
|||
}
|
||||
|
||||
// dump smaObj into rsp
|
||||
STableTSMAInfo * pInfo = NULL;
|
||||
STableTSMAInfo *pInfo = NULL;
|
||||
pInfo = taosMemoryCalloc(1, sizeof(STableTSMAInfo));
|
||||
if (!pInfo) {
|
||||
code = terrno;
|
||||
|
@ -2707,7 +2708,7 @@ int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
SSmaObj* pBaseSma = NULL;
|
||||
SSmaObj *pBaseSma = NULL;
|
||||
code = mndGetDeepestBaseForTsma(pMnode, pSma, &pBaseSma);
|
||||
if (code == 0) code = dumpTSMAInfoFromSmaObj(pSma, pDestStb, pInfo, pBaseSma);
|
||||
|
||||
|
|
|
@ -627,9 +627,12 @@ static void *mndBuildVDropStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb,
|
|||
void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead));
|
||||
|
||||
tEncoderInit(&encoder, pBuf, contLen - sizeof(SMsgHead));
|
||||
terrno = tEncodeSVDropStbReq(&encoder, &req);
|
||||
int32_t code = tEncodeSVDropStbReq(&encoder, &req);
|
||||
tEncoderClear(&encoder);
|
||||
if (terrno != 0) return NULL;
|
||||
if (code != 0) {
|
||||
terrno = code;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*pContLen = contLen;
|
||||
return pHead;
|
||||
|
|
|
@ -213,7 +213,7 @@ int32_t ipWhiteMgtUpdate(SMnode *pMnode, char *user, SIpWhiteList *pNew) {
|
|||
|
||||
_OVER:
|
||||
(void)taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
taosArrayDestroyP(fqdns, (FDelete)taosMemoryFree);
|
||||
taosArrayDestroyP(fqdns, NULL);
|
||||
if (code < 0) {
|
||||
mError("failed to update ip white list for user: %s at line %d since %s", user, lino, tstrerror(code));
|
||||
}
|
||||
|
@ -640,8 +640,8 @@ int32_t mndFetchAllIpWhite(SMnode *pMnode, SHashObj **ppIpWhiteTab) {
|
|||
}
|
||||
|
||||
_OVER:
|
||||
taosArrayDestroyP(fqdns, taosMemoryFree);
|
||||
taosArrayDestroyP(pUserNames, taosMemoryFree);
|
||||
taosArrayDestroyP(fqdns, NULL);
|
||||
taosArrayDestroyP(pUserNames, NULL);
|
||||
|
||||
if (code < 0) {
|
||||
mError("failed to fetch all ip white list at line %d since %s", lino, tstrerror(code));
|
||||
|
@ -1706,8 +1706,8 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
|
|||
if (pCreate->isImport != 1) {
|
||||
taosEncryptPass_c((uint8_t *)pCreate->pass, strlen(pCreate->pass), userObj.pass);
|
||||
} else {
|
||||
// mInfo("pCreate->pass:%s", pCreate->pass)
|
||||
strncpy(userObj.pass, pCreate->pass, TSDB_PASSWORD_LEN);
|
||||
// mInfo("pCreate->pass:%s", pCreate->eass)
|
||||
memcpy(userObj.pass, pCreate->pass, TSDB_PASSWORD_LEN);
|
||||
}
|
||||
tstrncpy(userObj.user, pCreate->user, TSDB_USER_LEN);
|
||||
tstrncpy(userObj.acct, acct, TSDB_USER_LEN);
|
||||
|
@ -1803,6 +1803,43 @@ _OVER:
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static int32_t mndCheckPasswordFmt(const char *pwd) {
|
||||
int32_t len = strlen(pwd);
|
||||
if (len < TSDB_PASSWORD_MIN_LEN || len > TSDB_PASSWORD_MAX_LEN) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strcmp(pwd, "taosdata") == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool charTypes[4] = {0};
|
||||
for (int32_t i = 0; i < len; ++i) {
|
||||
if (taosIsBigChar(pwd[i])) {
|
||||
charTypes[0] = true;
|
||||
} else if (taosIsSmallChar(pwd[i])) {
|
||||
charTypes[1] = true;
|
||||
} else if (taosIsNumberChar(pwd[i])) {
|
||||
charTypes[2] = true;
|
||||
} else if (taosIsSpecialChar(pwd[i])) {
|
||||
charTypes[3] = true;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t numOfTypes = 0;
|
||||
for (int32_t i = 0; i < 4; ++i) {
|
||||
numOfTypes += charTypes[i];
|
||||
}
|
||||
|
||||
if (numOfTypes < 3) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) {
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
int32_t code = 0;
|
||||
|
@ -1836,7 +1873,7 @@ static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) {
|
|||
TAOS_CHECK_GOTO(TSDB_CODE_MND_INVALID_USER_FORMAT, &lino, _OVER);
|
||||
}
|
||||
|
||||
if (createReq.pass[0] == 0) {
|
||||
if (mndCheckPasswordFmt(createReq.pass) != 0) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_MND_INVALID_PASS_FORMAT, &lino, _OVER);
|
||||
}
|
||||
|
||||
|
@ -1862,13 +1899,13 @@ static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) {
|
|||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
|
||||
char detail[1000] = {0};
|
||||
(void)sprintf(detail, "enable:%d, superUser:%d, sysInfo:%d, password:xxx", createReq.enable, createReq.superUser,
|
||||
createReq.sysInfo);
|
||||
TAOS_UNUSED(snprintf(detail, sizeof(detail), "enable:%d, superUser:%d, sysInfo:%d, password:xxx", createReq.enable,
|
||||
createReq.superUser, createReq.sysInfo));
|
||||
char operation[15] = {0};
|
||||
if (createReq.isImport == 1) {
|
||||
(void)strcpy(operation, "importUser");
|
||||
tstrncpy(operation, "importUser", sizeof(operation));
|
||||
} else {
|
||||
(void)strcpy(operation, "createUser");
|
||||
tstrncpy(operation, "createUser", sizeof(operation));
|
||||
}
|
||||
|
||||
auditRecord(pReq, pMnode->clusterId, operation, "", createReq.user, detail, strlen(detail));
|
||||
|
@ -2325,8 +2362,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
|
|||
TAOS_CHECK_GOTO(TSDB_CODE_MND_INVALID_USER_FORMAT, &lino, _OVER);
|
||||
}
|
||||
|
||||
if (TSDB_ALTER_USER_PASSWD == alterReq.alterType &&
|
||||
(alterReq.pass[0] == 0 || strlen(alterReq.pass) >= TSDB_PASSWORD_LEN)) {
|
||||
if (TSDB_ALTER_USER_PASSWD == alterReq.alterType && mndCheckPasswordFmt(alterReq.pass) != 0) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_MND_INVALID_PASS_FORMAT, &lino, _OVER);
|
||||
}
|
||||
|
||||
|
@ -2466,9 +2502,10 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
|
|||
|
||||
if (alterReq.alterType == TSDB_ALTER_USER_PASSWD) {
|
||||
char detail[1000] = {0};
|
||||
(void)sprintf(detail, "alterType:%s, enable:%d, superUser:%d, sysInfo:%d, createdb:%d, tabName:%s, password:xxx",
|
||||
mndUserAuditTypeStr(alterReq.alterType), alterReq.enable, alterReq.superUser, alterReq.sysInfo,
|
||||
alterReq.createdb ? 1 : 0, alterReq.tabName);
|
||||
(void)snprintf(detail, sizeof(detail),
|
||||
"alterType:%s, enable:%d, superUser:%d, sysInfo:%d, createdb:%d, tabName:%s, password:xxx",
|
||||
mndUserAuditTypeStr(alterReq.alterType), alterReq.enable, alterReq.superUser, alterReq.sysInfo,
|
||||
alterReq.createdb ? 1 : 0, alterReq.tabName);
|
||||
auditRecord(pReq, pMnode->clusterId, "alterUser", "", alterReq.user, detail, strlen(detail));
|
||||
} else if (alterReq.alterType == TSDB_ALTER_USER_SUPERUSER || alterReq.alterType == TSDB_ALTER_USER_ENABLE ||
|
||||
alterReq.alterType == TSDB_ALTER_USER_SYSINFO || alterReq.alterType == TSDB_ALTER_USER_CREATEDB) {
|
||||
|
@ -2841,8 +2878,8 @@ static int32_t mndLoopHash(SHashObj *hash, char *priType, SSDataBlock *pBlock, i
|
|||
SNode *pAst = NULL;
|
||||
int32_t sqlLen = 0;
|
||||
size_t bufSz = strlen(value) + 1;
|
||||
if (bufSz < 5) bufSz = 5;
|
||||
TAOS_MEMORY_REALLOC(*sql, bufSz + 1);
|
||||
if (bufSz < 6) bufSz = 6;
|
||||
TAOS_MEMORY_REALLOC(*sql, bufSz);
|
||||
if (*sql == NULL) {
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
|
@ -2856,12 +2893,12 @@ static int32_t mndLoopHash(SHashObj *hash, char *priType, SSDataBlock *pBlock, i
|
|||
if (nodesStringToNode(value, &pAst) == 0) {
|
||||
if (nodesNodeToSQL(pAst, *sql, bufSz, &sqlLen) != 0) {
|
||||
sqlLen = 5;
|
||||
(void)sprintf(*sql, "error");
|
||||
(void)snprintf(*sql, bufSz, "error");
|
||||
}
|
||||
nodesDestroyNode(pAst);
|
||||
} else {
|
||||
sqlLen = 5;
|
||||
(void)sprintf(*sql, "error");
|
||||
(void)snprintf(*sql, bufSz, "error");
|
||||
}
|
||||
|
||||
STR_WITH_MAXSIZE_TO_VARSTR((*condition), (*sql), pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
|
|
@ -370,7 +370,7 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
|||
opts.source = pRaw->pData;
|
||||
opts.result = plantContent;
|
||||
opts.unitLen = 16;
|
||||
strncpy(opts.key, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
tstrncpy(opts.key, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
|
||||
count = CBC_Decrypt(&opts);
|
||||
|
||||
|
@ -515,7 +515,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
|
|||
opts.source = pRaw->pData;
|
||||
opts.result = newData;
|
||||
opts.unitLen = 16;
|
||||
strncpy(opts.key, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
tstrncpy(opts.key, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
|
||||
int32_t count = CBC_Encrypt(&opts);
|
||||
|
||||
|
|
|
@ -138,6 +138,7 @@ static int32_t metaOpenImpl(SVnode *pVnode, SMeta **ppMeta, const char *metaDir,
|
|||
int32_t code = 0;
|
||||
int32_t lino;
|
||||
int32_t offset;
|
||||
int32_t pathLen = 0;
|
||||
char path[TSDB_FILENAME_LEN] = {0};
|
||||
char indexFullPath[128] = {0};
|
||||
|
||||
|
@ -150,14 +151,15 @@ static int32_t metaOpenImpl(SVnode *pVnode, SMeta **ppMeta, const char *metaDir,
|
|||
taosRemoveDir(path);
|
||||
}
|
||||
|
||||
if ((pMeta = taosMemoryCalloc(1, sizeof(*pMeta) + strlen(path) + 1)) == NULL) {
|
||||
pathLen = strlen(path) + 1;
|
||||
if ((pMeta = taosMemoryCalloc(1, sizeof(*pMeta) + pathLen)) == NULL) {
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
metaInitLock(pMeta);
|
||||
|
||||
pMeta->path = (char *)&pMeta[1];
|
||||
strcpy(pMeta->path, path);
|
||||
tstrncpy(pMeta->path, path, pathLen);
|
||||
int32_t ret = taosRealPath(pMeta->path, NULL, strlen(path) + 1);
|
||||
|
||||
pMeta->pVnode = pVnode;
|
||||
|
|
|
@ -1189,7 +1189,7 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs
|
|||
(*pMetaRsp)->tableType = TSDB_CHILD_TABLE;
|
||||
(*pMetaRsp)->tuid = pReq->uid;
|
||||
(*pMetaRsp)->suid = pReq->ctb.suid;
|
||||
strcpy((*pMetaRsp)->tbName, pReq->name);
|
||||
tstrncpy((*pMetaRsp)->tbName, pReq->name, strlen(pReq->name) + 1);
|
||||
} else {
|
||||
ret = metaUpdateMetaRsp(pReq->uid, pReq->name, &pReq->ntb.schemaRow, *pMetaRsp);
|
||||
if (ret < 0) {
|
||||
|
@ -1834,7 +1834,8 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1].type = pAlterTbReq->type;
|
||||
pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1].flags = pAlterTbReq->flags;
|
||||
pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1].colId = entry.ntbEntry.ncid++;
|
||||
strcpy(pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1].name, pAlterTbReq->colName);
|
||||
tstrncpy(pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1].name, pAlterTbReq->colName,
|
||||
strlen(pAlterTbReq->colName) + 1);
|
||||
|
||||
++pMeta->pVnode->config.vndStats.numOfNTimeSeries;
|
||||
metaTimeSeriesNotifyCheck(pMeta);
|
||||
|
@ -1943,7 +1944,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
goto _err;
|
||||
}
|
||||
pSchema->version++;
|
||||
strcpy(pColumn->name, pAlterTbReq->colNewName);
|
||||
tstrncpy(pColumn->name, pAlterTbReq->colNewName, strlen(pAlterTbReq->colNewName) + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,18 +49,20 @@ const char *ttlV1Tbname = "ttlv1.idx";
|
|||
int32_t ttlMgrOpen(STtlManger **ppTtlMgr, TDB *pEnv, int8_t rollback, const char *logPrefix, int32_t flushThreshold) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int64_t startNs = taosGetTimestampNs();
|
||||
int32_t pathLen = 0;
|
||||
|
||||
*ppTtlMgr = NULL;
|
||||
|
||||
STtlManger *pTtlMgr = (STtlManger *)tdbOsCalloc(1, sizeof(*pTtlMgr));
|
||||
if (pTtlMgr == NULL) TAOS_RETURN(terrno);
|
||||
|
||||
char *logBuffer = (char *)tdbOsCalloc(1, strlen(logPrefix) + 1);
|
||||
pathLen = strlen(logPrefix) + 1;
|
||||
char *logBuffer = (char *)tdbOsCalloc(1, pathLen);
|
||||
if (logBuffer == NULL) {
|
||||
tdbOsFree(pTtlMgr);
|
||||
TAOS_RETURN(terrno);
|
||||
}
|
||||
(void)strcpy(logBuffer, logPrefix);
|
||||
tstrncpy(logBuffer, logPrefix, pathLen);
|
||||
pTtlMgr->logPrefix = logBuffer;
|
||||
pTtlMgr->flushThreshold = flushThreshold;
|
||||
|
||||
|
|
|
@ -308,7 +308,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
|
|||
if (!pStreamTask->exec.qmsg) {
|
||||
TAOS_RETURN(terrno);
|
||||
}
|
||||
(void)sprintf(pStreamTask->exec.qmsg, "%s", RSMA_EXEC_TASK_FLAG);
|
||||
TAOS_UNUSED(snprintf(pStreamTask->exec.qmsg, strlen(RSMA_EXEC_TASK_FLAG) + 1, "%s", RSMA_EXEC_TASK_FLAG));
|
||||
pStreamTask->chkInfo.checkpointId = streamMetaGetLatestCheckpointId(pStreamTask->pMeta);
|
||||
tdRSmaTaskInit(pStreamTask->pMeta, pItem, &pStreamTask->id);
|
||||
|
||||
|
|
|
@ -396,7 +396,7 @@ static int32_t tsdbFSAddEntryToFileObjHash(STFileHash *hash, const char *fname)
|
|||
STFileHashEntry *entry = taosMemoryMalloc(sizeof(*entry));
|
||||
if (entry == NULL) return terrno;
|
||||
|
||||
strncpy(entry->fname, fname, TSDB_FILENAME_LEN);
|
||||
tstrncpy(entry->fname, fname, TSDB_FILENAME_LEN);
|
||||
|
||||
uint32_t idx = MurmurHash3_32(fname, strlen(fname)) % hash->numBucket;
|
||||
|
||||
|
@ -946,7 +946,7 @@ int32_t tsdbFSEditCommit(STFileSystem *fs) {
|
|||
arg->tsdb = fs->tsdb;
|
||||
arg->fid = fset->fid;
|
||||
|
||||
code = vnodeAsync(&fset->channel, EVA_PRIORITY_HIGH, tsdbMerge, taosMemoryFree, arg, NULL);
|
||||
code = vnodeAsync(&fset->channel, EVA_PRIORITY_HIGH, tsdbMerge, taosAutoMemoryFree, arg, NULL);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
fset->mergeScheduled = true;
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ _end:
|
|||
void clearBlockScanInfoBuf(SBlockInfoBuf* pBuf) {
|
||||
if (pBuf == NULL) return;
|
||||
if (pBuf->pData != NULL) {
|
||||
taosArrayDestroyP(pBuf->pData, (FDelete)taosMemoryFree);
|
||||
taosArrayDestroyP(pBuf->pData, NULL);
|
||||
pBuf->pData = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ static int32_t tsdbWriteFilePage(STsdbFD *pFD, int32_t encryptAlgorithm, char *e
|
|||
opts.result = PacketData;
|
||||
opts.unitLen = 128;
|
||||
// strncpy(opts.key, tsEncryptKey, 16);
|
||||
strncpy(opts.key, encryptKey, ENCRYPT_KEY_LEN);
|
||||
tstrncpy(opts.key, encryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
|
||||
NewLen = CBC_Encrypt(&opts);
|
||||
|
||||
|
@ -249,7 +249,7 @@ static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno, int32_t encryptAlgor
|
|||
opts.result = PacketData;
|
||||
opts.unitLen = 128;
|
||||
// strncpy(opts.key, tsEncryptKey, 16);
|
||||
strncpy(opts.key, encryptKey, ENCRYPT_KEY_LEN);
|
||||
tstrncpy(opts.key, encryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
|
||||
NewLen = CBC_Decrypt(&opts);
|
||||
|
||||
|
|
|
@ -265,7 +265,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
|||
if (tsEncryptKey[0] == 0) {
|
||||
return terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||
} else {
|
||||
strncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
tstrncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -292,7 +292,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
|||
if (tsEncryptKey[0] == 0) {
|
||||
return terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||
} else {
|
||||
strncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
tstrncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -106,6 +106,8 @@ static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) {
|
|||
if (code && code != TSDB_CODE_TIMEOUT_ERROR) {
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
code = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,8 +67,17 @@ int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, int32_t diskPrimary, STfs
|
|||
SVnodeInfo oldInfo = {0};
|
||||
oldInfo.config = vnodeCfgDefault;
|
||||
if (vnodeLoadInfo(dir, &oldInfo) == 0) {
|
||||
vWarn("vgId:%d, vnode config info already exists at %s.", oldInfo.config.vgId, dir);
|
||||
return (oldInfo.config.dbId == info.config.dbId) ? 0 : -1;
|
||||
code = (oldInfo.config.dbId == info.config.dbId) ? 0 : TSDB_CODE_VND_ALREADY_EXIST_BUT_NOT_MATCH;
|
||||
if (code == 0) {
|
||||
vWarn("vgId:%d, vnode config info already exists at %s.", oldInfo.config.vgId, dir);
|
||||
} else {
|
||||
vError("vgId:%d, vnode config info already exists at %s. oldDbId:%" PRId64 "(%s) at cluster:%" PRId64
|
||||
", newDbId:%" PRId64 "(%s) at cluser:%" PRId64 ", code:%s",
|
||||
oldInfo.config.vgId, dir, oldInfo.config.dbId, oldInfo.config.dbname,
|
||||
oldInfo.config.syncCfg.nodeInfo[oldInfo.config.syncCfg.myIndex].clusterId, info.config.dbId,
|
||||
info.config.dbname, info.config.syncCfg.nodeInfo[info.config.syncCfg.myIndex].clusterId, tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
vInfo("vgId:%d, save config while create", info.config.vgId);
|
||||
|
@ -190,7 +199,14 @@ int32_t vnodeRenameVgroupId(const char *srcPath, const char *dstPath, int32_t sr
|
|||
char *tsdbFilePrefixPos = strstr(oldRname, tsdbFilePrefix);
|
||||
if (tsdbFilePrefixPos == NULL) continue;
|
||||
|
||||
int32_t tsdbFileVgId = atoi(tsdbFilePrefixPos + prefixLen);
|
||||
int32_t tsdbFileVgId = 0; // atoi(tsdbFilePrefixPos + prefixLen);
|
||||
ret = taosStr2int32(tsdbFilePrefixPos + prefixLen, &tsdbFileVgId);
|
||||
if (ret != 0) {
|
||||
vError("vgId:%d, failed to get tsdb file vgid since %s", dstVgId, tstrerror(ret));
|
||||
tfsClosedir(tsdbDir);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (tsdbFileVgId == srcVgId) {
|
||||
char *tsdbFileSurfixPos = tsdbFilePrefixPos + prefixLen + vnodeVgroupIdLen(srcVgId);
|
||||
|
||||
|
|
|
@ -1093,7 +1093,7 @@ static int32_t vnodeProcessFetchTtlExpiredTbs(SVnode *pVnode, int64_t ver, void
|
|||
expiredTb.suid = *uid;
|
||||
terrno = metaReaderGetTableEntryByUid(&mr, *uid);
|
||||
if (terrno < 0) goto _end;
|
||||
strncpy(buf, mr.me.name, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(buf, mr.me.name, TSDB_TABLE_NAME_LEN);
|
||||
void *p = taosArrayPush(pNames, buf);
|
||||
if (p == NULL) {
|
||||
goto _end;
|
||||
|
@ -1321,7 +1321,7 @@ _exit:
|
|||
taosArrayDestroy(tbUids);
|
||||
tDecoderClear(&decoder);
|
||||
tEncoderClear(&encoder);
|
||||
taosArrayDestroyP(tbNames, taosMemoryFree);
|
||||
taosArrayDestroyP(tbNames, NULL);
|
||||
return rcode;
|
||||
}
|
||||
|
||||
|
|
|
@ -519,7 +519,7 @@ int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTabl
|
|||
vgList = taosArrayInit(1, sizeof(SVgroupInfo));
|
||||
if (NULL == vgList) {
|
||||
ctgError("taosArrayInit %d failed", (int32_t)sizeof(SVgroupInfo));
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
CTG_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
if (NULL == taosArrayPush(vgList, &vgroupInfo)) {
|
||||
|
@ -877,13 +877,13 @@ int32_t catalogInit(SCatalogCfg* cfg) {
|
|||
gCtgMgmt.timer = taosTmrInit(0, 0, 0, "catalog");
|
||||
if (NULL == gCtgMgmt.timer) {
|
||||
qError("init timer failed, error:%s", tstrerror(terrno));
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
CTG_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
gCtgMgmt.cacheTimer = taosTmrStart(ctgProcessTimerEvent, CTG_DEFAULT_CACHE_MON_MSEC, NULL, gCtgMgmt.timer);
|
||||
if (NULL == gCtgMgmt.cacheTimer) {
|
||||
qError("start cache timer failed");
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
CTG_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
CTG_ERR_RET(ctgStartUpdateThread());
|
||||
|
|
|
@ -1173,12 +1173,16 @@ int32_t ctgDumpTbIndexRes(SCtgTask* pTask) {
|
|||
SCtgJob* pJob = pTask->pJob;
|
||||
if (NULL == pJob->jobRes.pTableIndex) {
|
||||
SArray* pRes = taosArrayInit(pJob->tbIndexNum, sizeof(SMetaRes));
|
||||
if (NULL == pRes) {
|
||||
CTG_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
if (atomic_val_compare_exchange_ptr(&pJob->jobRes.pTableIndex, NULL, pRes)) {
|
||||
taosArrayDestroy(pRes);
|
||||
}
|
||||
|
||||
if (NULL == pJob->jobRes.pTableIndex) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1198,12 +1202,16 @@ int32_t ctgDumpTbCfgRes(SCtgTask* pTask) {
|
|||
SCtgJob* pJob = pTask->pJob;
|
||||
if (NULL == pJob->jobRes.pTableCfg) {
|
||||
SArray* pRes = taosArrayInit(pJob->tbCfgNum, sizeof(SMetaRes));
|
||||
if (NULL == pRes) {
|
||||
CTG_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
if (atomic_val_compare_exchange_ptr(&pJob->jobRes.pTableCfg, NULL, pRes)) {
|
||||
taosArrayDestroy(pRes);
|
||||
}
|
||||
|
||||
if (NULL == pJob->jobRes.pTableCfg) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1223,12 +1231,16 @@ int32_t ctgDumpTbTagRes(SCtgTask* pTask) {
|
|||
SCtgJob* pJob = pTask->pJob;
|
||||
if (NULL == pJob->jobRes.pTableTag) {
|
||||
SArray* pRes = taosArrayInit(pJob->tbTagNum, sizeof(SMetaRes));
|
||||
if (NULL == pRes) {
|
||||
CTG_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
if (atomic_val_compare_exchange_ptr(&pJob->jobRes.pTableTag, NULL, pRes)) {
|
||||
taosArrayDestroy(pRes);
|
||||
}
|
||||
|
||||
if (NULL == pJob->jobRes.pTableTag) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue