Merge remote-tracking branch 'origin/fix/TD-30837' into fix/TD-30837
# Conflicts: # source/dnode/vnode/src/tq/tq.c # source/libs/stream/inc/streamInt.h # source/libs/stream/src/streamSched.c
This commit is contained in:
commit
c5eca0486e
|
@ -5,8 +5,9 @@ ExternalProject_Add(addr2line
|
|||
GIT_TAG master
|
||||
SOURCE_DIR "${TD_CONTRIB_DIR}/addr2line"
|
||||
BINARY_DIR "${TD_CONTRIB_DIR}/addr2line"
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -11,9 +11,10 @@ ExternalProject_Add(aprutil-1
|
|||
BUILD_IN_SOURCE TRUE
|
||||
BUILD_ALWAYS 1
|
||||
#UPDATE_COMMAND ""
|
||||
CONFIGURE_COMMAND ./configure --prefix=$ENV{HOME}/.cos-local.1/ --with-apr=$ENV{HOME}/.cos-local.1
|
||||
CONFIGURE_COMMAND ./configure --prefix=$ENV{HOME}/.cos-local.1/ --with-apr=$ENV{HOME}/.cos-local.1
|
||||
#CONFIGURE_COMMAND ./configure --with-apr=/usr/local/apr
|
||||
BUILD_COMMAND make
|
||||
INSTALL_COMMAND make install
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -16,4 +16,5 @@ ExternalProject_Add(apr-1
|
|||
BUILD_COMMAND make
|
||||
INSTALL_COMMAND make install
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -9,4 +9,5 @@ ExternalProject_Add(cjson
|
|||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -9,4 +9,5 @@ ExternalProject_Add(cos
|
|||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -5,8 +5,9 @@ ExternalProject_Add(crashdump
|
|||
GIT_TAG master
|
||||
SOURCE_DIR "${TD_CONTRIB_DIR}/crashdump"
|
||||
BINARY_DIR "${TD_CONTRIB_DIR}/crashdump"
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -16,4 +16,5 @@ ExternalProject_Add(curl2
|
|||
BUILD_COMMAND make -j
|
||||
INSTALL_COMMAND make install
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -9,4 +9,5 @@ ExternalProject_Add(geos
|
|||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -10,4 +10,5 @@ ExternalProject_Add(gnuregex
|
|||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -9,4 +9,5 @@ ExternalProject_Add(googletest
|
|||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -9,4 +9,5 @@ ExternalProject_Add(iconv
|
|||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -5,8 +5,9 @@ ExternalProject_Add(libdwarf
|
|||
GIT_TAG libdwarf-0.3.1
|
||||
SOURCE_DIR "${TD_CONTRIB_DIR}/libdwarf"
|
||||
BINARY_DIR "${TD_CONTRIB_DIR}/libdwarf"
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -13,4 +13,5 @@ ExternalProject_Add(libs3
|
|||
BUILD_COMMAND make build/lib/libs3.a
|
||||
INSTALL_COMMAND make install_static
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -5,8 +5,9 @@ ExternalProject_Add(libuv
|
|||
GIT_TAG v1.48.0
|
||||
SOURCE_DIR "${TD_CONTRIB_DIR}/libuv"
|
||||
BINARY_DIR "${TD_CONTRIB_DIR}/libuv"
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -9,4 +9,5 @@ ExternalProject_Add(lz4
|
|||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
# xz
|
||||
# xz
|
||||
|
||||
if (${TD_LINUX})
|
||||
ExternalProject_Add(lzma2
|
||||
GIT_REPOSITORY https://github.com/conor42/fast-lzma2.git
|
||||
GIT_REPOSITORY https://github.com/conor42/fast-lzma2.git
|
||||
SOURCE_DIR "${TD_CONTRIB_DIR}/lzma2"
|
||||
#BINARY_DIR ""
|
||||
BUILD_IN_SOURCE TRUE
|
||||
|
@ -11,5 +11,6 @@ ExternalProject_Add(lzma2
|
|||
BUILD_COMMAND make
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -10,4 +10,5 @@ ExternalProject_Add(msvcregex
|
|||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -11,4 +11,5 @@ ExternalProject_Add(mxml
|
|||
BUILD_COMMAND make
|
||||
INSTALL_COMMAND make install
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -10,4 +10,5 @@ ExternalProject_Add(pcre2
|
|||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -10,4 +10,5 @@ ExternalProject_Add(pthread
|
|||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -11,6 +11,7 @@ if (${BUILD_CONTRIB})
|
|||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
else()
|
||||
if (NOT ${TD_LINUX})
|
||||
|
@ -24,6 +25,7 @@ else()
|
|||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -10,4 +10,5 @@ ExternalProject_Add(sqlite
|
|||
BUILD_COMMAND "$(MAKE)"
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -12,4 +12,5 @@ ExternalProject_Add(openssl
|
|||
BUILD_COMMAND make -j
|
||||
INSTALL_COMMAND make install_sw -j
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -10,4 +10,5 @@ ExternalProject_Add(stub
|
|||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -10,4 +10,5 @@ ExternalProject_Add(wcwidth
|
|||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -10,4 +10,5 @@ ExternalProject_Add(wingetopt
|
|||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -15,4 +15,5 @@ ExternalProject_Add(xml2
|
|||
BUILD_COMMAND make -j
|
||||
INSTALL_COMMAND make install && ln -sf $ENV{HOME}/.cos-local.2/include/libxml2/libxml $ENV{HOME}/.cos-local.2/include/libxml
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
|
||||
# xz
|
||||
ExternalProject_Add(xz
|
||||
GIT_REPOSITORY https://github.com/xz-mirror/xz.git
|
||||
GIT_TAG v5.4.4
|
||||
GIT_REPOSITORY https://github.com/xz-mirror/xz.git
|
||||
GIT_TAG v5.4.4
|
||||
SOURCE_DIR "${TD_CONTRIB_DIR}/xz"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
CMAKE_ARGS
|
||||
CMAKE_ARGS
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -12,4 +12,5 @@ ExternalProject_Add(zlib
|
|||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
|
||||
# zstb
|
||||
# zstb
|
||||
|
||||
#ExternalProject_Add(zstd
|
||||
#GIT_REPOSITORY https://github.com/facebook/zstd.git
|
||||
#GIT_REPOSITORY https://github.com/facebook/zstd.git
|
||||
#GIT_TAG v1.5.5
|
||||
#SOURCE_DIR "${TD_CONTRIB_DIR}/zstd"
|
||||
#DOWNLOAD_DIR "${TD_CONTRIB_DIR}/deps-download"
|
||||
#BINARY_DIR ""
|
||||
#CMAKE_COMMAND
|
||||
#CMAKE_COMMAND
|
||||
#CMAKE_ARGS ${TD_CONTRIB_DIR}/zstd/build/cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}/build/lib
|
||||
#BUILD_COMMAND make -j4
|
||||
#BUILD_COMMAND make -j4
|
||||
#INSTALL_COMMAND ""
|
||||
#TEST_COMMAND ""
|
||||
#)
|
||||
#GIT_SHALLOW true
|
||||
#)
|
||||
|
|
|
@ -169,8 +169,8 @@ CSV 文件中的每个 Row 配置一个 OPC 数据点位。Row 的规则如下
|
|||
- **采集模式**:可使用 `subscribe` 或 `observe` 模式。
|
||||
- `subscribe`:订阅模式,变更时上报数据并写入 TDengine。
|
||||
- `observe`:按照`采集间隔`时长,轮询读取点位最新值并写入 TDengine。
|
||||
- 采集间隔:默认为 10 秒,数据点位采集间隔,从上次采集数据结束后开始计时,轮询读取点位最新值并写入 TDengine。
|
||||
- **采集超时**:向 OPC 服务器读取点位数据时如果超过设定时间未返回数据,则读取失败,默认为 10 秒。
|
||||
- **采集间隔**:默认为 10 秒,数据点位采集间隔,从上次采集数据结束后开始计时,轮询读取点位最新值并写入 TDengine。仅在 **采集模式** 为 `observe` 时可配置。
|
||||
- **采集超时**:向 OPC 服务器读取点位数据时如果超过设定时间未返回数据,则读取失败,默认为 10 秒。仅在 **采集模式** 为 `observe` 时可配置。
|
||||
|
||||
当 **点位集** 中使用 **选择数据点位** 方式时,采集配置中可以配置 **点位更新模式** 和 **点位更新间隔** 来启用动态点位更新。**动态点位更新** 是指,在任务运行期间,OPC Server增加或删除了点位后,符合条件的点位会自动添加到当前任务中,不需要重启 OPC 任务。
|
||||
|
||||
|
|
|
@ -32,7 +32,11 @@ TDengine 可以高效地从 Kafka 读取数据并将其写入 TDengine,以实
|
|||
|
||||
### 3. 配置连接信息
|
||||
|
||||
在 **连接配置** 区域填写 **bootstrap-servers**,例如:`192.168.1.92:9092`。
|
||||
**bootstrap-server**,例如:`192.168.1.92`。
|
||||
|
||||
**服务端口**,例如:`9092`。
|
||||
|
||||
多个 broker 地址时,在连接配置右下增加 **新增 Broker** 按钮,成对增加 bootstrap-server 和服务端口。
|
||||
|
||||

|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 45 KiB |
|
@ -132,7 +132,7 @@ TDengine 提供了丰富的应用程序开发接口,为了便于用户快速
|
|||
pip3 install taospy[ws]
|
||||
```
|
||||
|
||||
- **安装验证**
|
||||
- **安装验证**
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="原生连接">
|
||||
对于原生连接,需要验证客户端驱动和 Python 连接器本身是否都正确安装。如果能成功导入 `taos` 模块,则说明已经正确安装了客户端驱动和 Python 连接器。可在 Python 交互式 Shell 中输入:
|
||||
|
@ -198,18 +198,18 @@ taos = { version = "*", default-features = false, features = ["ws"] }
|
|||
|
||||
- **安装**
|
||||
- 使用 npm 安装 Node.js 连接器
|
||||
```
|
||||
npm install @tdengine/websocket
|
||||
```
|
||||
```
|
||||
npm install @tdengine/websocket
|
||||
```
|
||||
:::note Node.js 目前只支持 Websocket 连接
|
||||
- **安装验证**
|
||||
- 新建安装验证目录,例如:`~/tdengine-test`,下载 GitHub 上 [nodejsChecker.js 源代码](https://github.com/taosdata/TDengine/tree/main/docs/examples/node/websocketexample/nodejsChecker.js)到本地。
|
||||
- 在命令行中执行以下命令。
|
||||
```bash
|
||||
npm init -y
|
||||
npm install @tdengine/websocket
|
||||
node nodejsChecker.js
|
||||
```
|
||||
```bash
|
||||
npm init -y
|
||||
npm install @tdengine/websocket
|
||||
node nodejsChecker.js
|
||||
```
|
||||
- 执行以上步骤后,在命令行会输出 nodeChecker.js 连接 TDengine 实例,并执行简单插入和查询的结果。
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import TabItem from "@theme/TabItem";
|
|||
|
||||
值得注意的是,通过无模式写入方式创建的超级表及其对应的子表与通过 SQL 直接创建的超级表和子表在功能上没有区别,用户仍然可以使用 SQL 直接向其中写入数据。然而,由于无模式写入方式生成的表名是基于标签值按照固定的映射规则生成的,因此这些表名可能缺乏可读性,不易于理解。
|
||||
|
||||
**采用无模式写入方式时会自动创建表,无须手动创建表。**
|
||||
**采用无模式写入方式时会自动创建表,无须手动创建表。手动建表的话可能会出现未知的错误。**
|
||||
|
||||
## 无模式写入行协议
|
||||
|
||||
|
@ -30,6 +30,7 @@ measurement,tag_set field_set timestamp
|
|||
- tag_set 格式形如 `<tag_key>=<tag_value>, <tag_key>=<tag_value>`,表示标签列数据,使用英文逗号分隔,与 field_set 之间使用一个半角空格分隔。
|
||||
- field_set 格式形如 `<field_key>=<field_value>, <field_key>=<field_value>`,表示普通列,同样使用英文逗号来分隔,与 timestamp 之间使用一个半角空格分隔。
|
||||
- timestamp 为本行数据对应的主键时间戳。
|
||||
- 无模式写入不支持含第二主键列的表的数据写入。
|
||||
|
||||
tag_set 中的所有的数据自动转化为 nchar 数据类型,并不需要使用双引号。
|
||||
在无模式写入数据行协议中,field_set 中的每个数据项都需要对自身的数据类型进行描述,具体要求如下。
|
||||
|
@ -81,7 +82,38 @@ st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4f64 1626006833639000000
|
|||
|
||||
需要注意的是,如果描述数据类型后缀时出现大小写错误,或者为数据指定的数据类型有误,均可能引发报错提示而导致数据写入失败。
|
||||
|
||||
TDengine提供数据写入的幂等性保证,即用户可以反复调用API进行出错数据的写入操作。无模式写入TDengine的主要处理逻辑请参考TDengine的官方网站,此处不赘述。
|
||||
TDengine 提供数据写入的幂等性保证,即您可以反复调用 API 进行出错数据的写入操作。但是不提供多行数据写入的原子性保证。即在多行数据一批次写入过程中,会出现部分数据写入成功,部分数据写入失败的情况。
|
||||
|
||||
## 无模式写入处理规则
|
||||
|
||||
无模式写入按照如下原则来处理行数据:
|
||||
|
||||
1. 将使用如下规则来生成子表名:首先将 measurement 的名称和标签的 key 和 value 组合成为如下的字符串
|
||||
|
||||
```json
|
||||
"measurement,tag_key1=tag_value1,tag_key2=tag_value2"
|
||||
```
|
||||
|
||||
- 需要注意的是,这里的 tag_key1, tag_key2 并不是用户输入的标签的原始顺序,而是使用了标签名称按照字符串升序排列后的结果。所以,tag_key1 并不是在行协议中输入的第一个标签。
|
||||
排列完成以后计算该字符串的 MD5 散列值 "md5_val"。然后将计算的结果与字符串组合生成表名:“t_md5_val”。其中的 “t_” 是固定的前缀,每个通过该映射关系自动生成的表都具有该前缀。
|
||||
|
||||
- 如果不想用自动生成的表名,有两种指定子表名的方式(第一种优先级更高)。
|
||||
1. 通过在taos.cfg里配置 smlAutoChildTableNameDelimiter 参数来指定(`@ # 空格 回车 换行 制表符`除外)。
|
||||
1. 举例如下:配置 smlAutoChildTableNameDelimiter=- 插入数据为 st,t0=cpu1,t1=4 c1=3 1626006833639000000 则创建的表名为 cpu1-4。
|
||||
2. 通过在taos.cfg里配置 smlChildTableName 参数来指定。
|
||||
1. 举例如下:配置 smlChildTableName=tname 插入数据为 st,tname=cpu1,t1=4 c1=3 1626006833639000000 则创建的表名为 cpu1,注意如果多行数据 tname 相同,但是后面的 tag_set 不同,则使用第一行自动建表时指定的 tag_set,其他的行会忽略。
|
||||
|
||||
2. 如果解析行协议获得的超级表不存在,则会创建这个超级表(不建议手动创建超级表,不然插入数据可能异常)。
|
||||
3. 如果解析行协议获得子表不存在,则 Schemaless 会按照步骤 1 或 2 确定的子表名来创建子表。
|
||||
4. 如果数据行中指定的标签列或普通列不存在,则在超级表中增加对应的标签列或普通列(只增不减)。
|
||||
5. 如果超级表中存在一些标签列或普通列未在一个数据行中被指定取值,那么这些列的值在这一行中会被置为 NULL。
|
||||
6. 对 BINARY 或 NCHAR 列,如果数据行中所提供值的长度超出了列类型的限制,自动增加该列允许存储的字符长度上限(只增不减),以保证数据的完整保存。
|
||||
7. 整个处理过程中遇到的错误会中断写入过程,并返回错误代码。
|
||||
8. 为了提高写入的效率,默认假设同一个超级表中 field_set 的顺序是一样的(第一条数据包含所有的 field,后面的数据按照这个顺序),如果顺序不一样,需要配置参数 smlDataFormat 为 false,否则,数据写入按照相同顺序写入,库中数据会异常,从3.0.3.0开始,自动检测顺序是否一致,该配置废弃。
|
||||
9. 由于sql建表表名不支持点号(.),所以schemaless也对点号(.)做了处理,如果schemaless自动建表的表名如果有点号(.),会自动替换为下划线(\_)。如果手动指定子表名的话,子表名里有点号(.),同样转化为下划线(\_)。
|
||||
10. taos.cfg 增加 smlTsDefaultName 配置(值为字符串),只在client端起作用,配置后,schemaless自动建表的时间列名字可以通过该配置设置。不配置的话,默认为 _ts。
|
||||
11. 无模式写入的数据超级表或子表名区分大小写。
|
||||
12. 无模式写入仍然遵循 TDengine 对数据结构的底层限制,例如每行数据的总长度不能超过 48KB(从 3.0.5.0 版本开始为 64KB),标签值的总长度不超过16KB。
|
||||
|
||||
## 时间分辨率识别
|
||||
|
||||
|
|
|
@ -154,6 +154,12 @@ charset 的有效值是 UTF-8。
|
|||
| :-----------: | :-------------------------------------------------------------------------: |
|
||||
| supportVnodes | dnode 支持的最大 vnode 数目,取值范围:0-4096,缺省值: CPU 核数的 2 倍 + 5 |
|
||||
|
||||
### 内存相关
|
||||
| 参数名称 | 参数说明 |
|
||||
| :----------------: | :---------------------------------------------: |
|
||||
| rpcQueueMemoryAllowed | 一个 dnode 允许的 rpc 消息占用的内存最大值,单位 bytes,取值范围:10485760-INT64_MAX,缺省值:服务器内存的 1/10 |
|
||||
| syncLogBufferMemoryAllowed | 一个 dnode 允许的 sync 日志缓存消息占用的内存最大值,单位 bytes,取值范围:10485760-INT64_MAX,缺省值:服务器内存的 1/10,3.1.3.2/3.3.2.13 版本开始生效 |
|
||||
|
||||
### 性能调优
|
||||
|
||||
| 参数名称 | 参数说明 |
|
||||
|
|
|
@ -33,12 +33,13 @@ TDengine 客户端驱动提供了应用编程所需要的全部 API,并且在
|
|||
|logKeepDays | 日志文件的最长保存时间; 缺省值: 0,表示无限保存; 大于 0 时,日志文件会被重命名为 taosdlog.xxx,其中 xxx 为日志文件最后修改的时间戳|
|
||||
|smlChildTableName | schemaless 自定义的子表名的 key, 无缺省值 |
|
||||
|smlAutoChildTableNameDelimiter | schemaless tag之间的连接符,连起来作为子表名,无缺省值 |
|
||||
|smlTagName | schemaless tag 为空时默认的 tag 名字, 无缺省值 |
|
||||
|smlTagName | schemaless tag 为空时默认的 tag 名字, 缺省值 "_tag_null" |
|
||||
|smlTsDefaultName | schemaless自动建表的时间列名字通过该配置设置, 缺省值 "_ts" |
|
||||
|enableCoreFile | crash 时是否生成 core 文件,0: 不生成, 1: 生成;缺省值:1 |
|
||||
|enableScience | 是否开启科学计数法显示浮点数; 0: 不开始, 1: 开启;缺省值:1 |
|
||||
|compressMsgSize | 是否对 RPC 消息进行压缩; -1: 所有消息都不压缩; 0: 所有消息都压缩; N (N>0): 只有大于 N 个字节的消息才压缩; 缺省值 -1|
|
||||
|queryTableNotExistAsEmpty | 查询表不存在时是否返回空结果集; false: 返回错误; true: 返回空结果集; 缺省值 false|
|
||||
|
||||
## API
|
||||
|
||||
请参考[连接器](../../connector)
|
||||
请参考[连接器](../../connector)
|
||||
|
|
|
@ -169,14 +169,43 @@ POW(expr1, expr2)
|
|||
|
||||
|
||||
#### ROUND
|
||||
|
||||
```sql
|
||||
ROUND(expr)
|
||||
ROUND(expr[, digits])
|
||||
```
|
||||
|
||||
**功能说明**:获得指定字段的四舍五入的结果。
|
||||
其他使用说明参见 CEIL 函数描述。
|
||||
|
||||
**返回结果类型**:与指定字段的原始数据类型一致。
|
||||
|
||||
**适用数据类型**:
|
||||
- `expr`:数值类型。
|
||||
- `digits`:数值类型。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 若 `expr` 或 `digits` 为 NULL,返回 NULL。
|
||||
- 若指定了`digits`,则会保留 `digits` 位小数,默认为 0。
|
||||
- 若输入值是 INTEGER 类型, 无论 `digits` 值为多少,都只会返回 INTEGER 类型,不会保留小数。
|
||||
- `digits` 大于零表示对小数位进行操作,四舍五入到 `digits` 位小数。若小数位数小于 `digits` 位,不进行四舍五入操作,直接返回。
|
||||
- `digits` 小于零表示丢掉小数位,并将数字四舍五入到小数点左侧 `digits` 位。若小数点左侧的位数小于 `digits`位,返回 0。
|
||||
- 由于暂未支持 DECIMAL 类型,所以该函数会用 DOUBLE 和 FLOAT 来表示包含小数的结果,但是 DOUBLE 和 FLOAT 是有精度上限的,当位数太多时使用该函数可能没有意义。
|
||||
- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select round(8888.88);
|
||||
round(8888.88) |
|
||||
============================
|
||||
8889.000000000000000 |
|
||||
|
||||
taos> select round(8888.88,-1);
|
||||
round(8888.88,-1) |
|
||||
============================
|
||||
8890.000000000000000 |
|
||||
```
|
||||
|
||||
#### SIN
|
||||
|
||||
|
@ -232,6 +261,297 @@ TAN(expr)
|
|||
|
||||
**使用说明**:只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。
|
||||
|
||||
#### PI
|
||||
```sql
|
||||
PI()
|
||||
```
|
||||
|
||||
**功能说明**:返回圆周率 π 的值。
|
||||
|
||||
**返回结果类型**:DOUBLE。
|
||||
|
||||
**适用数据类型**:无。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- π ≈ 3.141592653589793。
|
||||
- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select pi();
|
||||
pi() |
|
||||
============================
|
||||
3.141592653589793 |
|
||||
```
|
||||
|
||||
##### TRUNCATE
|
||||
```sql
|
||||
TRUNCATE(expr, digits)
|
||||
```
|
||||
|
||||
**功能说明**:获得指定字段按照指定位数截断的值。
|
||||
|
||||
**返回结果类型**:与 `expr` 字段的原始数据类型一致。
|
||||
|
||||
**适用数据类型**:
|
||||
- `expr`:数值类型。
|
||||
- `digits`:数值类型。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 若 `expr` 或 `digits` 为 NULL,返回 NULL。
|
||||
- 截取指按保留位数直接进行截取,没有四舍五入。
|
||||
- `digits` 大于零表示对小数位进行操作,截取到 `digits` 位小数,若小数位数小于 `digits` 位,不进行截取操作,直接返回。
|
||||
- `digits` 等于零表示丢掉小数位。
|
||||
- `digits` 小于零表示丢掉小数位,并将小数点左侧 `digits` 位置 `0`。若小数点左侧的位数小于 `digits`位,返回 0。
|
||||
- 由于暂未支持 DECIMAL 类型,所以该函数会用 DOUBLE 和 FLOAT 来表示包含小数的结果,但是 DOUBLE 和 FLOAT 是有精度上限的,当位数太多时使用该函数可能没有意义。
|
||||
- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select truncate(8888.88, 0);
|
||||
truncate(8888.88, 0) |
|
||||
============================
|
||||
8888.000000000000000 |
|
||||
|
||||
taos> select truncate(8888.88, -1);
|
||||
truncate(8888.88, -1) |
|
||||
============================
|
||||
8880.000000000000000 |
|
||||
```
|
||||
|
||||
#### EXP
|
||||
```sql
|
||||
EXP(expr)
|
||||
```
|
||||
**功能说明**:返回 e(自然对数的底)的指定乘方后的值。
|
||||
|
||||
**返回结果类型**:DOUBLE。
|
||||
|
||||
**适用数据类型**:数值类型。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 如果 `expr` 为 NULL,返回 NULL。
|
||||
- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select exp(2);
|
||||
exp(2) |
|
||||
============================
|
||||
7.389056098930650 |
|
||||
```
|
||||
|
||||
#### LN
|
||||
```sql
|
||||
LN(expr)
|
||||
```
|
||||
|
||||
**功能说明**:返回指定参数的自然对数。
|
||||
|
||||
**返回结果类型**:DOUBLE。
|
||||
|
||||
**适用数据类型**:数值类型。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 如果 `expr` 为 NULL,返回 NULL。
|
||||
- 如果 `epxr` 小于等于 0,返回 NULL。
|
||||
- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select ln(10);
|
||||
ln(10) |
|
||||
============================
|
||||
2.302585092994046 |
|
||||
```
|
||||
|
||||
#### MOD
|
||||
```sql
|
||||
MOD(expr1, expr2)
|
||||
```
|
||||
|
||||
**功能说明**:计算 expr1 % expr2 的结果。
|
||||
|
||||
**返回结果类型**:DOUBLE。
|
||||
|
||||
**适用数据类型**:数值类型。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 如果 `expr2` 为 0 则返回 NULL。
|
||||
- 如果 `expr1` 或 `expr2` 为 NULL,返回 NULL。
|
||||
- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。
|
||||
|
||||
**举例**:
|
||||
``` sql
|
||||
taos> select mod(10,3);
|
||||
mod(10,3) |
|
||||
============================
|
||||
1.000000000000000 |
|
||||
|
||||
taos> select mod(1,0);
|
||||
mod(1,0) |
|
||||
============================
|
||||
NULL |
|
||||
```
|
||||
|
||||
#### RAND
|
||||
```sql
|
||||
RAND([seed])
|
||||
```
|
||||
|
||||
**功能说明**:返回一个从0到1均匀分布的随机数。
|
||||
|
||||
**返回结果类型**:DOUBLE。
|
||||
|
||||
**适用数据类型**:
|
||||
- `seed`:INTEGER。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 如果指定了 `seed` 值,那么将会用指定的 `seed` 作为随机种子,确保生成的随机数序列具有确定性。
|
||||
- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。
|
||||
|
||||
**举例**:
|
||||
``` sql
|
||||
taos> select rand();
|
||||
rand() |
|
||||
============================
|
||||
0.202092426923147 |
|
||||
|
||||
taos> select rand();
|
||||
rand() |
|
||||
============================
|
||||
0.131537788143166 |
|
||||
|
||||
taos> select rand(1);
|
||||
rand(1) |
|
||||
============================
|
||||
0.000007826369259 |
|
||||
|
||||
taos> select rand(1);
|
||||
rand(1) |
|
||||
============================
|
||||
0.000007826369259 |
|
||||
```
|
||||
|
||||
#### SIGN
|
||||
```sql
|
||||
SIGN(expr)
|
||||
```
|
||||
|
||||
**功能说明**:返回指定参数的符号。
|
||||
|
||||
**返回结果类型**:与指定字段的原始数据类型一致。
|
||||
|
||||
**适用数据类型**:数值类型。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 如果 `expr` 为负,返回 -1 ,
|
||||
- 如果 `expr` 为正,返回 1 ,
|
||||
- 如果 `expr` 为 0 ,返回 0 。
|
||||
- 如果 `expr` 为 NULL ,返回 NULL 。
|
||||
- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select sign(-1);
|
||||
sign(-1) |
|
||||
========================
|
||||
-1 |
|
||||
|
||||
taos> select sign(1);
|
||||
sign(1) |
|
||||
========================
|
||||
1 |
|
||||
|
||||
taos> select sign(0);
|
||||
sign(0) |
|
||||
========================
|
||||
0 |
|
||||
```
|
||||
|
||||
#### DEGREES
|
||||
```sql
|
||||
DEGREES(expr)
|
||||
```
|
||||
|
||||
**功能说明**:计算指定参数由弧度值转为角度后的值。
|
||||
|
||||
**返回结果类型**:DOUBLE。
|
||||
|
||||
**适用数据类型**:数值类型。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 如果 `expr` 为 NULL,则返回 NULL。
|
||||
- degree = radian * 180 / π。
|
||||
- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select degrees(PI());
|
||||
degrees(pi()) |
|
||||
============================
|
||||
180.000000000000000 |
|
||||
```
|
||||
|
||||
#### RADIANS
|
||||
```sql
|
||||
RADIANS(expr)
|
||||
```
|
||||
|
||||
**功能说明**:计算指定参数由角度值转为弧度后的值。
|
||||
|
||||
**返回结果类型**:DOUBLE。
|
||||
|
||||
**适用数据类型**:数值类型。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 如果 `expr` 为 NULL,则返回 NULL。
|
||||
- radian = degree * π / 180。
|
||||
- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select radians(180);
|
||||
radians(180) |
|
||||
============================
|
||||
3.141592653589793 |
|
||||
```
|
||||
### 字符串函数
|
||||
|
||||
字符串函数的输入参数为字符串类型,返回结果为数值类型或字符串类型。
|
||||
|
@ -252,6 +572,27 @@ CHAR_LENGTH(expr)
|
|||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 与 `LENGTH()` 函数不同在于,对于多字节字符,比如中文字符, `CHAR_LENGTH()` 函数会将其算做一个字符,长度为 1,而 `LENGTH()` 会计算其字节数,长度为 3。比如 `CHAR_LENGTH('你好') = 2`, `LENGTH('你好') = 6`。
|
||||
- 如果 `expr` 为 NULL,返回 NULL。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select char_length('Hello world');
|
||||
char_length('Hello world') |
|
||||
=============================
|
||||
11 |
|
||||
|
||||
taos> select char_length('你好 世界');
|
||||
char_length('你好 世界') |
|
||||
===============================
|
||||
5 |
|
||||
```
|
||||
|
||||
#### CONCAT
|
||||
|
||||
```sql
|
||||
|
@ -353,23 +694,150 @@ RTRIM(expr)
|
|||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
|
||||
#### SUBSTR
|
||||
|
||||
#### TRIM
|
||||
```sql
|
||||
SUBSTR(expr, pos [,len])
|
||||
TRIM([{LEADING | TRAILING | BOTH} [remstr] FROM] expr)
|
||||
TRIM([remstr FROM] expr)
|
||||
```
|
||||
|
||||
**功能说明**:从源字符串 str 中的指定位置 pos 开始取一个长度为 len 的子串并返回。如果输入参数 len 被忽略,返回的子串包含从 pos 开始的整个字串。
|
||||
**功能说明**:返回去掉了所有 remstr 前缀或后缀的字符串 epxr 。
|
||||
|
||||
**返回结果类型**:与输入字段的原始类型相同。
|
||||
**返回结果类型**:与输入字段 epxr 的原始类型相同。
|
||||
|
||||
**适用数据类型**:VARCHAR, NCHAR。输入参数 pos 可以为正数,也可以为负数。如果 pos 是正数,表示开始位置从字符串开头正数计算。如果 pos 为负数,表示开始位置从字符串结尾倒数计算。
|
||||
**适用数据类型**:
|
||||
- remstr:VARCHAR,NCHAR。
|
||||
- epxr:VARCHAR,NCHAR。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 第一个可选变量[LEADING | BOTH | TRAILING]指定要剪裁字符串的哪一侧:
|
||||
- LEADING 将移除字符串开头的指定字符。
|
||||
- TRAILING 将移除字符串末尾的指定字符。
|
||||
- BOTH(默认值)将移除字符串开头和末尾的指定字符。
|
||||
- 第二个可选变量[remstr]指定要裁剪掉的字符串:
|
||||
- 如果不指定 remstr ,默认裁剪空格。
|
||||
- remstr 可以指定多个字符,如trim('ab' from 'abacd') ,此时会将 'ab' 看做一个整体来裁剪,得到裁剪结果 'acd'。
|
||||
- 若 expr 为 NULL, 返回 NULL。
|
||||
- 该函数是多字节安全的。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select trim(' a ');
|
||||
trim(' a ') |
|
||||
=============================
|
||||
a |
|
||||
|
||||
taos> select trim(leading from ' a ');
|
||||
trim(leading from ' a ') |
|
||||
==========================================
|
||||
a |
|
||||
|
||||
|
||||
taos> select trim(leading 'b' from 'bbbbbbbba ');
|
||||
trim(leading 'b' from 'bbbbbbbba ') |
|
||||
==============================================
|
||||
a |
|
||||
|
||||
taos> select trim(both 'b' from 'bbbbbabbbbbb');
|
||||
trim(both 'b' from 'bbbbbabbbbbb') |
|
||||
=====================================
|
||||
a |
|
||||
```
|
||||
|
||||
#### SUBSTRING/SUBSTR
|
||||
```sql
|
||||
SUBSTRING/SUBSTR(expr, pos [, len])
|
||||
SUBSTRING/SUBSTR(expr FROM pos [FOR len])
|
||||
```
|
||||
**功能说明**:返回字符串 `expr` 在 `pos` 位置开始的子串,若指定了 `len` ,则返回在 `pos` 位置开始,长度为 `len` 的子串。
|
||||
|
||||
**返回结果类型**:与输入字段 `expr` 的原始类型相同。
|
||||
|
||||
**适用数据类型**:
|
||||
- `expr`:VARCHAR,NCHAR。
|
||||
- `pos`:整数类型。
|
||||
- `len`:整数类型。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 若 `pos` 为正数,则返回的结果为 `expr` 从左到右开始数 `pos` 位置开始的右侧的子串。
|
||||
- 若 `pos` 为负数,则返回的结果为 `expr` 从右到左开始数 `pos` 位置开始的右侧的子串。
|
||||
- 任意参数为 NULL,返回 NULL。
|
||||
- 该函数是多字节安全的。
|
||||
- 若 `len` 小于 1,返回空串。
|
||||
- `pos` 是 1-base 的,若 `pos` 为 0,返回空串。
|
||||
- 若 `pos` + `len` 大于 `len(expr)`,返回从 `pos` 开始到字符串结尾的子串,等同于执行 `substring(expr, pos)`。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select substring('tdengine', 0);
|
||||
substring('tdengine', 0) |
|
||||
===========================
|
||||
|
|
||||
|
||||
taos> select substring('tdengine', 3);
|
||||
substring('tdengine', 3) |
|
||||
===========================
|
||||
engine |
|
||||
|
||||
taos> select substring('tdengine', 3,3);
|
||||
substring('tdengine', 3,3) |
|
||||
=============================
|
||||
eng |
|
||||
|
||||
taos> select substring('tdengine', -3,3);
|
||||
substring('tdengine', -3,3) |
|
||||
==============================
|
||||
ine |
|
||||
|
||||
taos> select substring('tdengine', -3,-3);
|
||||
substring('tdengine', -3,-3) |
|
||||
===============================
|
||||
|
|
||||
```
|
||||
|
||||
#### SUBSTRING_INDEX
|
||||
```sql
|
||||
SUBSTRING_INDEX(expr, delim, count)
|
||||
```
|
||||
|
||||
**功能说明**:返回字符串 `expr` 在出现指定次数分隔符的位置截取的子串。
|
||||
|
||||
**返回结果类型**:与输入字段 `expr` 的原始类型相同。
|
||||
|
||||
**适用数据类型**:
|
||||
- `expr`:VARCHAR,NCHAR。
|
||||
- `delim`:VARCHAR, NCHAR。
|
||||
- `count`:INTEGER。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 若 `count` 为正数,则返回的结果为 `expr` 从左到右开始数第 `count` 次 出现 `delim` 的位置左侧的字符串。
|
||||
- 若 `count` 为负数,则返回的结果为 `expr` 从右到左开始数第 `count` 的绝对值次 出现 `delim` 的位置右侧的字符串。
|
||||
- 任意参数为 NULL,返回 NULL。
|
||||
- 该函数是多字节安全的。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select substring_index('www.taosdata.com','.',2);
|
||||
substring_index('www.taosdata.com','.',2) |
|
||||
============================================
|
||||
www.taosdata |
|
||||
|
||||
taos> select substring_index('www.taosdata.com','.',-2);
|
||||
substring_index('www.taosdata.com','.',-2) |
|
||||
=============================================
|
||||
taosdata.com |
|
||||
```
|
||||
|
||||
#### UPPER
|
||||
|
||||
|
@ -387,7 +855,182 @@ UPPER(expr)
|
|||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
#### CHAR
|
||||
```sql
|
||||
CHAR(expr1 [, expr2] [, epxr3] ...)
|
||||
```
|
||||
|
||||
**功能说明**:将输入参数当作整数,并返回这些整数在 ASCII 编码中对应的字符。
|
||||
|
||||
**返回结果类型**:VARCHAR。
|
||||
|
||||
**适用数据类型**:整数类型,VARCHAR,NCHAR。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 输入的值超过 255 会被转化成多字节的结果,如 `CHAR(256)` 等同于 `CHAR(1,0)`, `CHAR(256 * 256)` 等同于 `CHAR(1,0,0)`。
|
||||
- 输入参数的 NULL 值会被跳过。
|
||||
- 输入参数若为字符串类型,会将其转换为数值类型处理。
|
||||
- 若输入的参数对应的字符为不可打印字符,返回值中仍有该参数对应的字符,但是可能无法显示出来。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select char(77);
|
||||
char(77) |
|
||||
===========
|
||||
M |
|
||||
|
||||
taos> select char(77,77);
|
||||
char(77,77) |
|
||||
==============
|
||||
MM |
|
||||
|
||||
taos> select char(77 * 256 + 77);
|
||||
char(77 * 256 + 77) |
|
||||
======================
|
||||
MM |
|
||||
|
||||
taos> select char(77,NULL,77);
|
||||
char(77,null,77) |
|
||||
===================
|
||||
MM |
|
||||
```
|
||||
|
||||
#### ASCII
|
||||
```sql
|
||||
ASCII(expr)
|
||||
```
|
||||
|
||||
**功能说明**:返回字符串第一个字符的 ASCII 码。
|
||||
|
||||
**返回结果数据类型**:BIGINT。
|
||||
|
||||
**适用数据类型**:VARCHAR, NCHAR。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 如果 `expr` 为 NULL,返回 NULL。
|
||||
- 如果 `expr` 的第一个字符为多字节字符,只会返回该字符第一个字节的值对应的 ASCII 码。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select ascii('testascii');
|
||||
ascii('testascii') |
|
||||
=====================
|
||||
116 |
|
||||
```
|
||||
|
||||
#### POSITION
|
||||
```sql
|
||||
POSITION(expr1 IN expr2)
|
||||
```
|
||||
|
||||
**功能说明**:计算字符串 `expr1` 在字符串 `expr2` 中的位置。
|
||||
|
||||
**返回结果类型**:BIGINT。
|
||||
|
||||
**适用数据类型**:
|
||||
- `expr1`:VARCHAR, NCHAR。
|
||||
- `expr2`:VARCHAR, NCHAR。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 若 `expr1` 或 `expr2` 为 NULL,返回 NULL。
|
||||
- 若 `expr1` 在 `expr2` 中不存在,返回 0。
|
||||
- 若 `expr1` 为空串,认为 `expr1` 在 `expr2` 中总能匹配成功,返回 1。
|
||||
- 返回的位置是 1-base 的。
|
||||
- 该函数是多字节安全的。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select position('a' in 'cba');
|
||||
position('a' in 'cba') |
|
||||
=========================
|
||||
3 |
|
||||
|
||||
|
||||
taos> select position('' in 'cba');
|
||||
position('' in 'cba') |
|
||||
========================
|
||||
1 |
|
||||
|
||||
taos> select position('d' in 'cba');
|
||||
position('d' in 'cba') |
|
||||
=========================
|
||||
0 |
|
||||
```
|
||||
|
||||
#### REPLACE
|
||||
```sql
|
||||
REPLACE(expr, from_str, to_str)
|
||||
```
|
||||
**功能说明**:将字符串中的 `from_str` 全部替换为 `to_str`。
|
||||
|
||||
**返回结果类型**:与输入字段 `expr` 的原始类型相同。
|
||||
|
||||
**适用数据类型**:
|
||||
- `expr`:VARCHAR, NCHAR。
|
||||
- `from_str`:VARCHAR, NCHAR。
|
||||
- `to_str`:VARCHAR, NCHAR。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 该函数是大小写敏感的。
|
||||
- 任意参数为 NULL,返回 NULL。
|
||||
- 该函数是多字节安全的。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select replace('aabbccAABBCC', 'AA', 'DD');
|
||||
replace('aabbccAABBCC', 'AA', 'DD') |
|
||||
======================================
|
||||
aabbccDDBBCC |
|
||||
```
|
||||
|
||||
#### REPEAT
|
||||
```sql
|
||||
REPEAT(expr, count)
|
||||
```
|
||||
**功能说明**:返回将字符串重复指定次数得到的字符串。
|
||||
|
||||
**返回结果类型**:与输入字段 `expr` 的原始类型相同。
|
||||
|
||||
**适用数据类型**:
|
||||
- `expr`: VARCHAR,NCHAR。
|
||||
- `count`:INTEGER。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 若 `count < 1`,返回空串。
|
||||
- 若 `expr` 或 `count` 为 NULL,返回 NULL。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select repeat('abc',5);
|
||||
repeat('abc',5) |
|
||||
============================
|
||||
abcabcabcabcabc |
|
||||
|
||||
taos> select repeat('abc',-1);
|
||||
repeat('abc',-1) |
|
||||
===================
|
||||
|
|
||||
```
|
||||
### 转换函数
|
||||
|
||||
转换函数将值从一种数据类型转换为另一种数据类型。
|
||||
|
@ -609,22 +1252,39 @@ NOW()
|
|||
TIMEDIFF(expr1, expr2 [, time_unit])
|
||||
```
|
||||
|
||||
**功能说明**:计算两个时间戳之间的差值,并近似到时间单位 time_unit 指定的精度。
|
||||
**功能说明**:返回时间戳 `expr1` - `expr2` 的结果,结果可能为负,并近似到时间单位 `time_unit` 指定的精度。
|
||||
|
||||
**返回结果数据类型**:BIGINT。
|
||||
**返回结果类型**:BIGINT。
|
||||
|
||||
**应用字段**:表示 UNIX 时间戳的 BIGINT, TIMESTAMP 类型,或符合日期时间格式的 VARCHAR, NCHAR 类型。
|
||||
|
||||
**适用于**:表和超级表。
|
||||
**适用数据类型**:
|
||||
- `expr1`:表示 UNIX 时间戳的 BIGINT, TIMESTAMP 类型,或符合日期时间格式的 VARCHAR, NCHAR 类型。
|
||||
- `expr2`:表示 UNIX 时间戳的 BIGINT, TIMESTAMP 类型,或符合日期时间格式的 VARCHAR, NCHAR 类型。
|
||||
- `time_unit`:见使用说明。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**使用说明**:
|
||||
- 支持的时间单位 time_unit 如下:
|
||||
1b(纳秒), 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天), 1w(周)。
|
||||
- 如果时间单位 time_unit 未指定, 返回的时间差值精度与当前 DATABASE 设置的时间精度一致。
|
||||
- 输入包含不符合时间日期格式的字符串则返回 NULL。
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 支持的时间单位 `time_unit` 如下: 1b(纳秒), 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天), 1w(周)。
|
||||
- 如果时间单位 `time_unit` 未指定, 返回的时间差值精度与当前 DATABASE 设置的时间精度一致。
|
||||
- 输入包含不符合时间日期格式的字符串则返回 NULL。
|
||||
- `expr1` 或 `expr2` 为 NULL,返回 NULL。
|
||||
- `time_unit` 为 NULL,等同于未指定时间单位。
|
||||
- 输入时间戳的精度由所查询表的精度确定, 若未指定表, 则精度为毫秒.
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select timediff('2022-01-01 08:00:00', '2022-01-01 08:00:01',1s);
|
||||
timediff('2022-01-01 08:00:00', '2022-01-01 08:00:01',1s) |
|
||||
============================================================
|
||||
-1 |
|
||||
|
||||
taos> select timediff('2022-01-01 08:00:01', '2022-01-01 08:00:00',1s);
|
||||
timediff('2022-01-01 08:00:01', '2022-01-01 08:00:00',1s) |
|
||||
============================================================
|
||||
1 |
|
||||
```
|
||||
|
||||
#### TIMETRUNCATE
|
||||
|
||||
|
@ -695,6 +1355,148 @@ TODAY()
|
|||
b(纳秒),u(微秒),a(毫秒),s(秒),m(分),h(小时),d(天),w(周)。
|
||||
- 返回的时间戳精度与当前 DATABASE 设置的时间精度一致。
|
||||
|
||||
#### WEEK
|
||||
```sql
|
||||
WEEK(expr [, mode])
|
||||
```
|
||||
**功能说明**:返回输入日期的周数。
|
||||
|
||||
**返回结果类型**:BIGINT。
|
||||
|
||||
**适用数据类型**:
|
||||
- `expr`:表示 UNIX 时间戳的 BIGINT, TIMESTAMP 类型,或符合日期时间格式的 VARCHAR, NCHAR 类型。
|
||||
- `mode`:0 - 7 之间的整数。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 若 `expr` 为 NULL,返回 NULL。
|
||||
- 输入时间戳的精度由所查询表的精度确定, 若未指定表, 则精度为毫秒.
|
||||
- `mode` 用来指定一周是从周日开始还是周一开始,以及指定返回值范围是 1 - 53 还是 0 - 53。下表详细描述不同的 mode 对应的计算方法:
|
||||
|
||||
| Mode | 每周的第一天 | 返回值范围 | 第 1 周的计算方法 |
|
||||
| ---- | ------ | ------ | ------------------ |
|
||||
| 0 | 周日 | 0 - 53 | 第一个包含周日的周为第 1 周 |
|
||||
| 1 | 周一 | 0 - 53 | 第一个包含四天及以上的周为第 1 周 |
|
||||
| 2 | 周日 | 1 - 53 | 第一个包含周日的周为第 1 周 |
|
||||
| 3 | 周一 | 1 - 53 | 第一个包含四天及以上的周为第 1 周 |
|
||||
| 4 | 周日 | 0 - 53 | 第一个包含四天及以上的周为第 1 周 |
|
||||
| 5 | 周一 | 0 - 53 | 第一个包含周一的周为第 1 周 |
|
||||
| 6 | 周日 | 1 - 53 | 第一个包含四天及以上的周为第 1 周 |
|
||||
| 7 | 周一 | 1 - 53 | 第一个包含周一的周为第 1 周 |
|
||||
- 当返回值范围为0 - 53时,第 1 周之前的日期为第 0 周。
|
||||
- 当返回值范围为1 - 53时,第 1 周之前的日期为上一年的最后一周。
|
||||
- 以`2000-01-01`为例,
|
||||
- 在 `mode=0`时返回值为`0`,因为该年第一个周日为`2000-01-02`,从`2000-01-02`起才是第 1 周,所以 `2000-01-01`为第 0 周,返回 0。
|
||||
- 在 `mode=1`时返回值为`0`,因为`2000-01-01`所在的周只有两天,分别是 `2000-01-01(周六)`和`2000-01-02(周日)`,所以`2000-01-03`起才是第一周,`2000-01-01`为第 0 周,返回 0。
|
||||
- 在 `mode=2`时返回值为`52`,因为从`2000-01-02`起才是第 1 周,并且返回值范围为 1-53,所以`2000-01-01`算做上一年的最后一周,即 1999 年的第 52 周,返回 52。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select week('2000-01-01',0);
|
||||
week('2000-01-01',0) |
|
||||
========================
|
||||
0 |
|
||||
|
||||
taos> select week('2000-01-01',1);
|
||||
week('2000-01-01',1) |
|
||||
========================
|
||||
0 |
|
||||
|
||||
taos> select week('2000-01-01',2);
|
||||
week('2000-01-01',2) |
|
||||
========================
|
||||
52 |
|
||||
|
||||
taos> select week('2000-01-01',3);
|
||||
week('2000-01-01',3) |
|
||||
========================
|
||||
52 |
|
||||
```
|
||||
|
||||
#### WEEKOFYEAR
|
||||
```sql
|
||||
WEEKOFYEAR(expr)
|
||||
```
|
||||
**功能说明**:返回输入日期的周数。
|
||||
|
||||
**返回结果类型**:BIGINT。
|
||||
|
||||
**适用数据类型**:表示 UNIX 时间戳的 BIGINT, TIMESTAMP 类型,或符合日期时间格式的 VARCHAR, NCHAR 类型。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 等同于`WEEK(expr, 3)`,即在每周第一天是周一,返回值范围为 1 - 53,第一个包含四天及以上的周为第 1 周的条件下判断输入日期的周数。
|
||||
- 若 `expr` 为 NULL,返回 NULL。
|
||||
- 输入时间戳的精度由所查询表的精度确定, 若未指定表, 则精度为毫秒.
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select weekofyear('2000-01-01');
|
||||
weekofyear('2000-01-01') |
|
||||
===========================
|
||||
52 |
|
||||
```
|
||||
|
||||
#### WEEKDAY
|
||||
```sql
|
||||
WEEKDAY(expr)
|
||||
```
|
||||
**功能说明**:返回输入日期是周几。
|
||||
|
||||
**返回结果类型**:BIGINT。
|
||||
|
||||
**适用数据类型**:表示 UNIX 时间戳的 BIGINT, TIMESTAMP 类型,或符合日期时间格式的 VARCHAR, NCHAR 类型。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 返回值 0 代表周日,1 代表周一 ... 6 代表周六。
|
||||
- 若 `expr` 为 NULL,返回 NULL。
|
||||
- 输入时间戳的精度由所查询表的精度确定, 若未指定表, 则精度为毫秒.
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select weekday('2000-01-01');
|
||||
weekday('2000-01-01') |
|
||||
========================
|
||||
5 |
|
||||
```
|
||||
|
||||
#### DAYOFWEEK
|
||||
```sql
|
||||
DAYOFWEEK(expr)
|
||||
```
|
||||
**功能说明**:返回输入日期是周几。
|
||||
|
||||
**返回结果类型**:BIGINT。
|
||||
|
||||
**适用数据类型**:表示 UNIX 时间戳的 BIGINT, TIMESTAMP 类型,或符合日期时间格式的 VARCHAR, NCHAR 类型。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 返回值 1 代表周日,2 代表周一 ... 7 代表周六
|
||||
- 若 `expr` 为 NULL,返回 NULL。
|
||||
- 输入时间戳的精度由所查询表的精度确定, 若未指定表, 则精度为毫秒.
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select dayofweek('2000-01-01');
|
||||
dayofweek('2000-01-01') |
|
||||
==========================
|
||||
7 |
|
||||
```
|
||||
|
||||
|
||||
## 聚合函数
|
||||
|
||||
|
@ -817,13 +1619,13 @@ SPREAD(expr)
|
|||
**适用于**:表和超级表。
|
||||
|
||||
|
||||
### STDDEV
|
||||
### STDDEV/STDDEV_POP
|
||||
|
||||
```sql
|
||||
STDDEV(expr)
|
||||
STDDEV/STDDEV_POP(expr)
|
||||
```
|
||||
|
||||
**功能说明**:统计表中某列的均方差。
|
||||
**功能说明**:统计表中某列的总体标准差。
|
||||
|
||||
**返回数据类型**:DOUBLE。
|
||||
|
||||
|
@ -831,7 +1633,51 @@ STDDEV(expr)
|
|||
|
||||
**适用于**:表和超级表。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select id from test_stddev;
|
||||
id |
|
||||
==============
|
||||
1 |
|
||||
2 |
|
||||
3 |
|
||||
4 |
|
||||
5 |
|
||||
|
||||
taos> select stddev_pop(id) from test_stddev;
|
||||
stddev_pop(id) |
|
||||
============================
|
||||
1.414213562373095 |
|
||||
```
|
||||
### VAR_POP
|
||||
```sql
|
||||
VAR_POP(expr)
|
||||
```
|
||||
|
||||
**功能说明**:统计表中某列的总体方差。
|
||||
|
||||
**返回数据类型**:DOUBLE。
|
||||
|
||||
**适用数据类型**:数值类型。
|
||||
|
||||
**适用于**:表和超级表。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select id from test_var;
|
||||
id |
|
||||
==============
|
||||
3 |
|
||||
1 |
|
||||
2 |
|
||||
4 |
|
||||
5 |
|
||||
|
||||
taos> select var_pop(id) from test_var;
|
||||
var_pop(id) |
|
||||
============================
|
||||
2.000000000000000 |
|
||||
```
|
||||
### SUM
|
||||
|
||||
```sql
|
||||
|
@ -1045,10 +1891,11 @@ MAX(expr)
|
|||
|
||||
**返回数据类型**:同应用的字段。
|
||||
|
||||
**适用数据类型**:数值类型。
|
||||
**适用数据类型**:数值类型, VARCHAR,NCHAR。
|
||||
|
||||
**适用于**:表和超级表。
|
||||
|
||||
**使用说明**:max 函数可以接受字符串作为输入参数,当输入参数为字符串类型时,返回最大的字符串值。
|
||||
|
||||
### MIN
|
||||
|
||||
|
@ -1060,10 +1907,11 @@ MIN(expr)
|
|||
|
||||
**返回数据类型**:同应用的字段。
|
||||
|
||||
**适用数据类型**:数值类型。
|
||||
**适用数据类型**:数值类型, VARCHAR,NCHAR。
|
||||
|
||||
**适用于**:表和超级表。
|
||||
|
||||
**使用说明**:min 函数可以接受字符串作为输入参数,当输入参数为字符串类型时,返回最大的字符串值。
|
||||
|
||||
### MODE
|
||||
|
||||
|
|
|
@ -93,8 +93,8 @@ TDengine 内置了一个名为 `INFORMATION_SCHEMA` 的数据库,提供对数
|
|||
| 4 | vgroups | INT | 数据库中有多少个 vgroup。需要注意,`vgroups` 为 TDengine 关键字,作为列名使用时需要使用 ` 进行转义。 |
|
||||
| 6 | replica | INT | 副本数。需要注意,`replica` 为 TDengine 关键字,作为列名使用时需要使用 ` 进行转义。 |
|
||||
| 7 | strict | VARCHAR(4) | 废弃参数 |
|
||||
| 8 | duration | VARCHAR(10) | 单文件存储数据的时间跨度。需要注意,`duration` 为 TDengine 关键字,作为列名使用时需要使用 ` 进行转义。 |
|
||||
| 9 | keep | VARCHAR(32) | 数据保留时长。需要注意,`keep` 为 TDengine 关键字,作为列名使用时需要使用 ` 进行转义。 |
|
||||
| 8 | duration | VARCHAR(10) | 单文件存储数据的时间跨度。需要注意,`duration` 为 TDengine 关键字,作为列名使用时需要使用 ` 进行转义。内部存储单位为分钟,查询时有可能转换为天或小时展示 |
|
||||
| 9 | keep | VARCHAR(32) | 数据保留时长。需要注意,`keep` 为 TDengine 关键字,作为列名使用时需要使用 ` 进行转义。 内部存储单位为分钟,查询时有可能转换为天或小时展示 |
|
||||
| 10 | buffer | INT | 每个 vnode 写缓存的内存块大小,单位 MB。需要注意,`buffer` 为 TDengine 关键字,作为列名使用时需要使用 ` 进行转义。 |
|
||||
| 11 | pagesize | INT | 每个 VNODE 中元数据存储引擎的页大小,单位为 KB。需要注意,`pagesize` 为 TDengine 关键字,作为列名使用时需要使用 ` 进行转义。 |
|
||||
| 12 | pages | INT | 每个 vnode 元数据存储引擎的缓存页个数。需要注意,`pages` 为 TDengine 关键字,作为列名使用时需要使用 ` 进行转义。 |
|
||||
|
|
|
@ -118,13 +118,14 @@ curl -L -u username:password -d "<SQL>" <ip>:<PORT>/rest/sql/[db_name][?tz=timez
|
|||
|
||||
### HTTP 响应码
|
||||
|
||||
从 `TDengine 3.0.3.0` 开始 `taosAdapter` 提供配置参数 `httpCodeServerError` 用来设置当 C 接口返回错误时是否返回非 200 的http状态码
|
||||
从 `TDengine 3.0.3.0` 开始 `taosAdapter` 提供配置参数 `httpCodeServerError` 用来设置当 C 接口返回错误时是否返回非 200 的http状态码。
|
||||
无论是否设置此参数,响应 body 里都有详细的错误码和错误信息,具体请参考 [错误](../rest-api/#错误) 。
|
||||
|
||||
| **说明** | **httpCodeServerError false** | **httpCodeServerError true** |
|
||||
|--------------------|-------------------------------|---------------------------------------|
|
||||
| taos_errno() 返回 0 | 200 | 200 |
|
||||
| taos_errno() 返回 非0 | 200(除鉴权错误) | 500 (除鉴权错误和 400/502 错误) |
|
||||
| 参数错误 | 400 (仅处理 HTTP 请求 URL 参数错误) | 400 (处理 HTTP 请求 URL 参数错误和 taosd 返回错误) |
|
||||
| taos_errno() 返回 非0 | 200(除鉴权错误) | 500 (除鉴权错误和 400/502/503 错误) |
|
||||
| 参数错误 | 400(仅处理 HTTP 请求 URL 参数错误) | 400 (处理 HTTP 请求 URL 参数错误和 taosd 返回错误) |
|
||||
| 鉴权错误 | 401 | 401 |
|
||||
| 接口不存在 | 404 | 404 |
|
||||
| 集群不可用错误 | 502 | 502 |
|
||||
|
@ -132,27 +133,29 @@ curl -L -u username:password -d "<SQL>" <ip>:<PORT>/rest/sql/[db_name][?tz=timez
|
|||
|
||||
返回 400 的 C 错误码为:
|
||||
|
||||
- TSDB_CODE_TSC_SQL_SYNTAX_ERROR ( 0x0216)
|
||||
- TSDB_CODE_TSC_LINE_SYNTAX_ERROR (0x021B)
|
||||
- TSDB_CODE_TSC_SQL_SYNTAX_ERROR (0x0216)
|
||||
- TSDB_CODE_TSC_LINE_SYNTAX_ERROR (0x021B)
|
||||
- TSDB_CODE_PAR_SYNTAX_ERROR (0x2600)
|
||||
- TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE (0x060B)
|
||||
- TSDB_CODE_TSC_VALUE_OUT_OF_RANGE (0x0224)
|
||||
- TSDB_CODE_TSC_VALUE_OUT_OF_RANGE (0x0224)
|
||||
- TSDB_CODE_PAR_INVALID_FILL_TIME_RANGE (0x263B)
|
||||
|
||||
返回 401 的错误码为:
|
||||
|
||||
- TSDB_CODE_MND_USER_ALREADY_EXIST (0x0350)
|
||||
- TSDB_CODE_MND_USER_NOT_EXIST ( 0x0351)
|
||||
- TSDB_CODE_MND_INVALID_USER_FORMAT (0x0352)
|
||||
- TSDB_CODE_MND_INVALID_PASS_FORMAT (0x0353)
|
||||
- TSDB_CODE_MND_USER_ALREADY_EXIST (0x0350)
|
||||
- TSDB_CODE_MND_USER_NOT_EXIST (0x0351)
|
||||
- TSDB_CODE_MND_INVALID_USER_FORMAT (0x0352)
|
||||
- TSDB_CODE_MND_INVALID_PASS_FORMAT (0x0353)
|
||||
- TSDB_CODE_MND_NO_USER_FROM_CONN (0x0354)
|
||||
- TSDB_CODE_MND_TOO_MANY_USERS (0x0355)
|
||||
- TSDB_CODE_MND_INVALID_ALTER_OPER (0x0356)
|
||||
- TSDB_CODE_MND_AUTH_FAILURE (0x0357)
|
||||
|
||||
返回 403 的错误码为:
|
||||
返回 502 的错误码为:
|
||||
|
||||
- TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED (0x0020)
|
||||
- TSDB_CODE_RPC_NETWORK_UNAVAIL (0x000B)
|
||||
|
||||
错误码和错误描述请参考[错误码](../../../reference/error-code)
|
||||
|
||||
### HTTP body 结构
|
||||
|
||||
|
@ -333,6 +336,8 @@ curl --location 'http://<fqdn>:<port>/rest/sql' \
|
|||
- code:(`int`)错误码。
|
||||
- desc:(`string`)错误描述。
|
||||
|
||||
错误码和错误描述请参考[错误码](../../../reference/error-code)
|
||||
|
||||
#### 返回key-value形式数据
|
||||
|
||||
当指定 url 参数 `row_with_meta=true` 时,返回的 data 中的数据会从数组的形式变成对象的形式,对象的 key 为列名,value 为数据,如下所示:
|
||||
|
|
|
@ -94,6 +94,7 @@ extern int32_t tsElectInterval;
|
|||
extern int32_t tsHeartbeatInterval;
|
||||
extern int32_t tsHeartbeatTimeout;
|
||||
extern int32_t tsSnapReplMaxWaitN;
|
||||
extern int64_t tsLogBufferMemoryAllowed; // maximum allowed log buffer size in bytes for each dnode
|
||||
|
||||
// arbitrator
|
||||
extern int32_t tsArbHeartBeatIntervalSec;
|
||||
|
|
|
@ -74,7 +74,7 @@ typedef enum {
|
|||
* @param vgId
|
||||
* @return
|
||||
*/
|
||||
qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers, int32_t vgId, int32_t taskId);
|
||||
int32_t qCreateStreamExecTaskInfo(qTaskInfo_t* pInfo, void* msg, SReadHandle* readers, int32_t vgId, int32_t taskId);
|
||||
|
||||
/**
|
||||
* Create the exec task for queue mode
|
||||
|
@ -93,7 +93,7 @@ int32_t qGetTableList(int64_t suid, void* pVnode, void* node, SArray **tableList
|
|||
* @param taskId
|
||||
* @param queryId
|
||||
*/
|
||||
void qSetTaskId(qTaskInfo_t tinfo, uint64_t taskId, uint64_t queryId);
|
||||
int32_t qSetTaskId(qTaskInfo_t tinfo, uint64_t taskId, uint64_t queryId);
|
||||
|
||||
int32_t qSetStreamOpOpen(qTaskInfo_t tinfo);
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ typedef struct TsdReader {
|
|||
int32_t (*tsdReaderOpen)(void* pVnode, SQueryTableDataCond* pCond, void* pTableList, int32_t numOfTables,
|
||||
SSDataBlock* pResBlock, void** ppReader, const char* idstr, SHashObj** pIgnoreTables);
|
||||
void (*tsdReaderClose)();
|
||||
void (*tsdSetReaderTaskId)(void *pReader, const char *pId);
|
||||
int32_t (*tsdSetReaderTaskId)(void *pReader, const char *pId);
|
||||
int32_t (*tsdSetQueryTableList)();
|
||||
int32_t (*tsdNextDataBlock)();
|
||||
|
||||
|
@ -419,9 +419,9 @@ typedef struct SStateStore {
|
|||
SStreamStateCur* (*streamStateSessionSeekKeyCurrentPrev)(SStreamState* pState, const SSessionKey* key);
|
||||
SStreamStateCur* (*streamStateSessionSeekKeyCurrentNext)(SStreamState* pState, const SSessionKey* key);
|
||||
|
||||
struct SStreamFileState* (*streamFileStateInit)(int64_t memSize, uint32_t keySize, uint32_t rowSize,
|
||||
uint32_t selectRowSize, GetTsFun fp, void* pFile, TSKEY delMark,
|
||||
const char* id, int64_t ckId, int8_t type);
|
||||
int32_t (*streamFileStateInit)(int64_t memSize, uint32_t keySize, uint32_t rowSize, uint32_t selectRowSize,
|
||||
GetTsFun fp, void* pFile, TSKEY delMark, const char* id, int64_t ckId, int8_t type,
|
||||
struct SStreamFileState** ppFileState);
|
||||
|
||||
int32_t (*streamStateGroupPut)(SStreamState* pState, int64_t groupId, void* value, int32_t vLen);
|
||||
SStreamStateCur* (*streamStateGroupGetCur)(SStreamState* pState);
|
||||
|
|
|
@ -496,6 +496,14 @@ typedef struct SScanWalInfo {
|
|||
tmr_h scanTimer;
|
||||
} SScanWalInfo;
|
||||
|
||||
typedef struct SFatalErrInfo {
|
||||
int32_t code;
|
||||
int64_t ts;
|
||||
int32_t threadId;
|
||||
int32_t line;
|
||||
char func[128];
|
||||
} SFatalErrInfo;
|
||||
|
||||
// meta
|
||||
typedef struct SStreamMeta {
|
||||
char* path;
|
||||
|
@ -525,14 +533,13 @@ typedef struct SStreamMeta {
|
|||
int32_t numOfStreamTasks; // this value should be increased when a new task is added into the meta
|
||||
int32_t numOfPausedTasks;
|
||||
int64_t rid;
|
||||
|
||||
int64_t chkpId;
|
||||
int32_t chkpCap;
|
||||
SArray* chkpSaved;
|
||||
SArray* chkpInUse;
|
||||
SRWLatch chkpDirLock;
|
||||
void* qHandle; // todo remove it
|
||||
void* bkdChkptMgt;
|
||||
SFatalErrInfo fatalInfo; // fatal error occurs, stream stop to execute
|
||||
int64_t chkpId;
|
||||
int32_t chkpCap;
|
||||
SArray* chkpSaved;
|
||||
SArray* chkpInUse;
|
||||
SRWLatch chkpDirLock;
|
||||
void* bkdChkptMgt;
|
||||
} SStreamMeta;
|
||||
|
||||
typedef struct STaskUpdateEntry {
|
||||
|
@ -676,7 +683,7 @@ int8_t streamTaskSetSchedStatusInactive(SStreamTask* pTask);
|
|||
int32_t streamTaskClearHTaskAttr(SStreamTask* pTask, int32_t clearRelHalt);
|
||||
|
||||
int32_t streamExecTask(SStreamTask* pTask);
|
||||
void streamResumeTask(SStreamTask* pTask);
|
||||
int32_t streamResumeTask(SStreamTask* pTask);
|
||||
int32_t streamTrySchedExec(SStreamTask* pTask);
|
||||
int32_t streamTaskSchedTask(SMsgCb* pMsgCb, int32_t vgId, int64_t streamId, int32_t taskId, int32_t execType);
|
||||
void streamTaskResumeInFuture(SStreamTask* pTask);
|
||||
|
@ -779,6 +786,9 @@ void streamMetaRLock(SStreamMeta* pMeta);
|
|||
void streamMetaRUnLock(SStreamMeta* pMeta);
|
||||
void streamMetaWLock(SStreamMeta* pMeta);
|
||||
void streamMetaWUnLock(SStreamMeta* pMeta);
|
||||
void streamSetFatalError(SStreamMeta* pMeta, int32_t code, const char* funcName, int32_t lino);
|
||||
int32_t streamGetFatalError(const SStreamMeta* pMeta);
|
||||
|
||||
void streamMetaResetStartInfo(STaskStartInfo* pMeta, int32_t vgId);
|
||||
int32_t streamMetaSendMsgBeforeCloseTasks(SStreamMeta* pMeta, SArray** pTaskList);
|
||||
void streamMetaUpdateStageRole(SStreamMeta* pMeta, int64_t stage, bool isLeader);
|
||||
|
@ -794,7 +804,7 @@ void streamTaskSetReqConsenChkptId(SStreamTask* pTask, int64_t ts);
|
|||
|
||||
// timer
|
||||
int32_t streamTimerGetInstance(tmr_h* pTmr);
|
||||
void streamTmrReset(TAOS_TMR_CALLBACK fp, int32_t mseconds, void* param, void* handle, tmr_h* pTmrId, int32_t vgId,
|
||||
void streamTmrStart(TAOS_TMR_CALLBACK fp, int32_t mseconds, void* pParam, void* pHandle, tmr_h* pTmrId, int32_t vgId,
|
||||
const char* pMsg);
|
||||
void streamTmrStop(tmr_h tmrId);
|
||||
|
||||
|
|
|
@ -47,9 +47,11 @@ typedef int32_t (*range_cmpr_fn)(const SSessionKey* pWin1, const SSessionKey* pW
|
|||
|
||||
typedef int (*__session_compare_fn_t)(const void* pWin, const void* pDatas, int pos);
|
||||
|
||||
SStreamFileState* streamFileStateInit(int64_t memSize, uint32_t keySize, uint32_t rowSize, uint32_t selectRowSize,
|
||||
GetTsFun fp, void* pFile, TSKEY delMark, const char* taskId, int64_t checkpointId,
|
||||
int8_t type);
|
||||
typedef int (*__session_compare_fn_t)(const void* pWin, const void* pDatas, int pos);
|
||||
|
||||
int32_t streamFileStateInit(int64_t memSize, uint32_t keySize, uint32_t rowSize, uint32_t selectRowSize, GetTsFun fp,
|
||||
void* pFile, TSKEY delMark, const char* taskId, int64_t checkpointId, int8_t type,
|
||||
struct SStreamFileState** ppFileState);
|
||||
void streamFileStateDestroy(SStreamFileState* pFileState);
|
||||
void streamFileStateClear(SStreamFileState* pFileState);
|
||||
bool needClearDiskBuff(SStreamFileState* pFileState);
|
||||
|
@ -67,7 +69,7 @@ int32_t putFreeBuff(SStreamFileState* pFileState, SRowBuffPos* pPos);
|
|||
|
||||
SStreamSnapshot* getSnapshot(SStreamFileState* pFileState);
|
||||
void flushSnapshot(SStreamFileState* pFileState, SStreamSnapshot* pSnapshot, bool flushState);
|
||||
void recoverSnapshot(SStreamFileState* pFileState, int64_t ckId);
|
||||
int32_t recoverSnapshot(SStreamFileState* pFileState, int64_t ckId);
|
||||
|
||||
int32_t getSnapshotIdList(SStreamFileState* pFileState, SArray* list);
|
||||
int32_t deleteExpiredCheckPoint(SStreamFileState* pFileState, TSKEY mark);
|
||||
|
@ -95,7 +97,7 @@ int32_t allocSessioncWinBuffByNextPosition(SStreamFileState* pFileState, SStream
|
|||
const SSessionKey* pWinKey, void** ppVal, int32_t* pVLen);
|
||||
|
||||
SRowBuffPos* createSessionWinBuff(SStreamFileState* pFileState, SSessionKey* pKey, void* p, int32_t* pVLen);
|
||||
void recoverSesssion(SStreamFileState* pFileState, int64_t ckId);
|
||||
int32_t recoverSesssion(SStreamFileState* pFileState, int64_t ckId);
|
||||
|
||||
void sessionWinStateClear(SStreamFileState* pFileState);
|
||||
void sessionWinStateCleanup(void* pBuff);
|
||||
|
|
|
@ -112,8 +112,8 @@ typedef struct SWal {
|
|||
int64_t totSize;
|
||||
int64_t lastRollSeq;
|
||||
// ctl
|
||||
int64_t refId;
|
||||
TdThreadMutex mutex;
|
||||
int64_t refId;
|
||||
TdThreadRwlock mutex;
|
||||
// ref
|
||||
SHashObj *pRefHash; // refId -> SWalRef
|
||||
// path
|
||||
|
|
|
@ -165,7 +165,6 @@ int32_t taosGetFqdn(char *);
|
|||
void tinet_ntoa(char *ipstr, uint32_t ip);
|
||||
uint32_t ip2uint(const char *const ip_addr);
|
||||
int32_t taosIgnSIGPIPE();
|
||||
uint32_t taosInetAddr(const char *ipAddr);
|
||||
const char *taosInetNtoa(struct in_addr ipInt, char *dstStr, int32_t len);
|
||||
|
||||
uint64_t taosHton64(uint64_t val);
|
||||
|
|
|
@ -80,7 +80,7 @@ typedef struct {
|
|||
|
||||
SysNameInfo taosGetSysNameInfo();
|
||||
bool taosCheckCurrentInDll();
|
||||
int taosGetlocalhostname(char *hostname, size_t maxLen);
|
||||
int32_t taosGetlocalhostname(char *hostname, size_t maxLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -81,8 +81,11 @@ int32_t taosResetTerminalMode();
|
|||
unw_get_reg(&cursor, UNW_REG_IP, &pc); \
|
||||
fname[0] = '\0'; \
|
||||
(void)unw_get_proc_name(&cursor, fname, sizeof(fname), &offset); \
|
||||
size += 1; \
|
||||
array[size] = (char *)taosMemoryMalloc(sizeof(char) * STACKSIZE + 1); \
|
||||
if(NULL == array[size]) { \
|
||||
break; \
|
||||
} \
|
||||
size += 1; \
|
||||
snprintf(array[size], STACKSIZE, "0x%lx : (%s+0x%lx) [0x%lx]\n", (long)pc, fname, (long)offset, (long)pc); \
|
||||
} \
|
||||
if (ignoreNum < size && size > 0) { \
|
||||
|
|
|
@ -54,7 +54,7 @@ enum TdTimezone {
|
|||
TdEastZone12
|
||||
};
|
||||
|
||||
void taosGetSystemTimezone(char *outTimezone, enum TdTimezone *tsTimezone);
|
||||
int32_t taosGetSystemTimezone(char *outTimezone, enum TdTimezone *tsTimezone);
|
||||
int32_t taosSetSystemTimezone(const char *inTimezone, char *outTimezone, int8_t *outDaylight, enum TdTimezone *tsTimezone);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -157,6 +157,7 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x0138)
|
||||
#define TSDB_CODE_SOCKET_ERROR TAOS_DEF_ERROR_CODE(0, 0x0139)
|
||||
#define TSDB_CODE_UNSUPPORT_OS TAOS_DEF_ERROR_CODE(0, 0x013A)
|
||||
#define TSDB_CODE_TIME_ERROR TAOS_DEF_ERROR_CODE(0, 0x013B)
|
||||
|
||||
//client
|
||||
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)
|
||||
|
@ -366,6 +367,7 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_MND_ARBGROUP_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AA)
|
||||
#define TSDB_CODE_MND_ARBGROUP_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AB)
|
||||
#define TSDB_CODE_MND_ARB_TOKEN_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x03AC)
|
||||
#define TSDB_CODE_MND_VNODE_NOT_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x03AD)
|
||||
|
||||
// mnode-dnode-part2
|
||||
#define TSDB_CODE_MND_TOO_MANY_DNODES TAOS_DEF_ERROR_CODE(0, 0x03B0)
|
||||
|
@ -966,6 +968,7 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_TMQ_REPLAY_NEED_ONE_VGROUP TAOS_DEF_ERROR_CODE(0, 0x4013)
|
||||
#define TSDB_CODE_TMQ_REPLAY_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x4014)
|
||||
#define TSDB_CODE_TMQ_NO_TABLE_QUALIFIED TAOS_DEF_ERROR_CODE(0, 0x4015)
|
||||
#define TSDB_CODE_TMQ_NO_NEED_REBALANCE TAOS_DEF_ERROR_CODE(0, 0x4016)
|
||||
|
||||
// stream
|
||||
#define TSDB_CODE_STREAM_TASK_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x4100)
|
||||
|
@ -975,6 +978,7 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_STREAM_NOT_LEADER TAOS_DEF_ERROR_CODE(0, 0x4105)
|
||||
#define TSDB_CODE_STREAM_CONFLICT_EVENT TAOS_DEF_ERROR_CODE(0, 0x4106)
|
||||
#define TSDB_CODE_STREAM_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x4107)
|
||||
#define TSDB_CODE_STREAM_INPUTQ_FULL TAOS_DEF_ERROR_CODE(0, 0x4108)
|
||||
|
||||
// TDLite
|
||||
#define TSDB_CODE_TDLITE_IVLD_OPEN_FLAGS TAOS_DEF_ERROR_CODE(0, 0x5100)
|
||||
|
|
|
@ -332,6 +332,7 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_MAX_LEARNER_REPLICA 10
|
||||
#define TSDB_SYNC_LOG_BUFFER_SIZE 4096
|
||||
#define TSDB_SYNC_LOG_BUFFER_RETENTION 256
|
||||
#define TSDB_SYNC_LOG_BUFFER_THRESHOLD (1024 * 1024 * 5)
|
||||
#define TSDB_SYNC_APPLYQ_SIZE_LIMIT 512
|
||||
#define TSDB_SYNC_NEGOTIATION_WIN 512
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ void *taosAcquireRef(int32_t rsetId, int64_t rid);
|
|||
// release ref, rid is the reference ID returned by taosAddRef
|
||||
// return 0 if success. On error, -1 is returned, and terrno is set appropriately
|
||||
int32_t taosReleaseRef(int32_t rsetId, int64_t rid);
|
||||
int32_t taosReleaseRefEx(int32_t rsetId, int64_t rid, int32_t* isReleased);
|
||||
|
||||
// return the first reference if rid is 0, otherwise return the next after current reference.
|
||||
// if return value is NULL, it means list is over(if terrno is set, it means error happens)
|
||||
|
|
|
@ -73,14 +73,14 @@ static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *tar
|
|||
char buf[TSDB_PASSWORD_LEN + 1];
|
||||
|
||||
buf[TSDB_PASSWORD_LEN] = 0;
|
||||
(void)sprintf(buf, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], context.digest[1],
|
||||
context.digest[2], context.digest[3], context.digest[4], context.digest[5], context.digest[6],
|
||||
context.digest[7], context.digest[8], context.digest[9], context.digest[10], context.digest[11],
|
||||
context.digest[12], context.digest[13], context.digest[14], context.digest[15]);
|
||||
(void)sprintf(buf, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0],
|
||||
context.digest[1], context.digest[2], context.digest[3], context.digest[4], context.digest[5],
|
||||
context.digest[6], context.digest[7], context.digest[8], context.digest[9], context.digest[10],
|
||||
context.digest[11], context.digest[12], context.digest[13], context.digest[14], context.digest[15]);
|
||||
(void)memcpy(target, buf, TSDB_PASSWORD_LEN);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t taosHashBinary(char* pBuf, int32_t len) {
|
||||
static FORCE_INLINE int32_t taosHashBinary(char *pBuf, int32_t len) {
|
||||
uint64_t hashVal = MurmurHash3_64(pBuf, len);
|
||||
return sprintf(pBuf, "%" PRIu64, hashVal);
|
||||
}
|
||||
|
@ -161,8 +161,7 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
|||
|
||||
#define TCONTAINER_OF(ptr, type, member) ((type *)((char *)(ptr)-offsetof(type, member)))
|
||||
|
||||
#define TAOS_GET_TERRNO(code) \
|
||||
(terrno == 0 ? code : terrno)
|
||||
#define TAOS_GET_TERRNO(code) (terrno == 0 ? code : terrno)
|
||||
|
||||
#define TAOS_RETURN(CODE) \
|
||||
do { \
|
||||
|
@ -177,6 +176,15 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define TAOS_CHECK_RETURN_WITH_FREE(CMD, PTR) \
|
||||
do { \
|
||||
int32_t __c = (CMD); \
|
||||
if (__c != TSDB_CODE_SUCCESS) { \
|
||||
taosMemoryFree(PTR); \
|
||||
TAOS_RETURN(__c); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define TAOS_CHECK_GOTO(CMD, LINO, LABEL) \
|
||||
do { \
|
||||
code = (CMD); \
|
||||
|
|
|
@ -1636,8 +1636,9 @@ void hbDeregisterConn(STscObj *pTscObj, SClientHbKey connKey) {
|
|||
SClientHbReq *pReq = taosHashAcquire(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
|
||||
if (pReq) {
|
||||
tFreeClientHbReq(pReq);
|
||||
if (TSDB_CODE_SUCCESS != taosHashRemove(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey))) {
|
||||
tscError("failed to remove connKey from activeInfo");
|
||||
code = taosHashRemove(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("hbDeregisterConn taosHashRemove error, code:%s", tstrerror(TAOS_SYSTEM_ERROR(code)));
|
||||
}
|
||||
taosHashRelease(pAppHbMgr->activeInfo, pReq);
|
||||
(void)atomic_sub_fetch_32(&pAppHbMgr->connKeyCnt, 1);
|
||||
|
|
|
@ -77,7 +77,10 @@ bool chkRequestKilled(void* param) {
|
|||
return killed;
|
||||
}
|
||||
|
||||
void cleanupAppInfo() { taosHashCleanup(appInfo.pInstMap); }
|
||||
void cleanupAppInfo() {
|
||||
taosHashCleanup(appInfo.pInstMap);
|
||||
taosHashCleanup(appInfo.pInstMapByClusterId);
|
||||
}
|
||||
|
||||
static int32_t taosConnectImpl(const char* user, const char* auth, const char* db, __taos_async_fn_t fp, void* param,
|
||||
SAppInstInfo* pAppInfo, int connType, STscObj** pTscObj);
|
||||
|
@ -1162,6 +1165,7 @@ void schedulerExecCb(SExecResult* pResult, void* param, int32_t code) {
|
|||
(void)atomic_add_fetch_64((int64_t*)&pActivity->numOfInsertRows, pResult->numOfRows);
|
||||
}
|
||||
}
|
||||
schedulerFreeJob(&pRequest->body.queryJob, 0);
|
||||
}
|
||||
|
||||
taosMemoryFree(pResult);
|
||||
|
@ -1276,9 +1280,9 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue
|
|||
}
|
||||
|
||||
if (NEED_CLIENT_RM_TBLMETA_REQ(pRequest->type) && NULL == pRequest->body.resInfo.execRes.res) {
|
||||
code = removeMeta(pRequest->pTscObj, pRequest->targetTableList, IS_VIEW_REQUEST(pRequest->type));
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("0x%" PRIx64 " remove meta failed,QID:0x%" PRIx64, pRequest->self, pRequest->requestId);
|
||||
int ret = removeMeta(pRequest->pTscObj, pRequest->targetTableList, IS_VIEW_REQUEST(pRequest->type));
|
||||
if (TSDB_CODE_SUCCESS != ret) {
|
||||
tscError("0x%" PRIx64 " remove meta failed,code:%d,QID:0x%" PRIx64, pRequest->self, ret, pRequest->requestId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2039,7 +2043,7 @@ static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) {
|
|||
static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int32_t numOfCols, int32_t* colLength) {
|
||||
int32_t idx = -1;
|
||||
iconv_t conv = taosAcquireConv(&idx, C2M);
|
||||
if (!conv) return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
if (conv == (iconv_t)-1) return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
int32_t type = pResultInfo->fields[i].type;
|
||||
|
@ -2236,6 +2240,10 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
|||
} else if (tTagIsJson(data)) {
|
||||
char* jsonString = NULL;
|
||||
parseTagDatatoJson(data, &jsonString);
|
||||
if(jsonString == NULL) {
|
||||
tscError("doConvertJson error: parseTagDatatoJson failed");
|
||||
return terrno;
|
||||
}
|
||||
STR_TO_VARSTR(dst, jsonString);
|
||||
taosMemoryFree(jsonString);
|
||||
} else if (jsonInnerType == TSDB_DATA_TYPE_NCHAR) { // value -> "value"
|
||||
|
|
|
@ -73,6 +73,8 @@ void taos_cleanup(void) {
|
|||
tscWarn("failed to cleanup task queue");
|
||||
}
|
||||
|
||||
tmqMgmtClose();
|
||||
|
||||
int32_t id = clientReqRefPool;
|
||||
clientReqRefPool = -1;
|
||||
taosCloseRef(id);
|
||||
|
@ -87,9 +89,6 @@ void taos_cleanup(void) {
|
|||
tscDebug("rpc cleanup");
|
||||
|
||||
taosConvDestroy();
|
||||
|
||||
tmqMgmtClose();
|
||||
|
||||
DestroyRegexCache();
|
||||
|
||||
tscInfo("all local resources released");
|
||||
|
@ -1316,9 +1315,10 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
|
|||
if (NEED_CLIENT_HANDLE_ERROR(code)) {
|
||||
tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d,QID:0x%" PRIx64,
|
||||
pRequest->self, code, tstrerror(code), pRequest->retry, pRequest->requestId);
|
||||
if (TSDB_CODE_SUCCESS != refreshMeta(pRequest->pTscObj, pRequest)) {
|
||||
tscWarn("0x%" PRIx64 " refresh meta failed, code:%d - %s,QID:0x%" PRIx64, pRequest->self, code, tstrerror(code),
|
||||
pRequest->requestId);
|
||||
code = refreshMeta(pRequest->pTscObj, pRequest);
|
||||
if (code != 0){
|
||||
tscWarn("0x%" PRIx64 " refresh meta failed, code:%d - %s,QID:0x%" PRIx64, pRequest->self, code,
|
||||
tstrerror(code), pRequest->requestId);
|
||||
}
|
||||
pRequest->prevCode = code;
|
||||
doAsyncQuery(pRequest, true);
|
||||
|
@ -1525,7 +1525,7 @@ int taos_get_table_vgId(TAOS *taos, const char *db, const char *table, int *vgId
|
|||
|
||||
conn.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
|
||||
|
||||
SName tableName;
|
||||
SName tableName = {0};
|
||||
toName(pTscObj->acctId, db, table, &tableName);
|
||||
|
||||
SVgroupInfo vgInfo;
|
||||
|
|
|
@ -68,9 +68,14 @@ static void destroyMonitorClient(void* data) {
|
|||
if (pMonitor == NULL) {
|
||||
return;
|
||||
}
|
||||
(void)taosTmrStopA(&pMonitor->timer);
|
||||
if (!taosTmrStopA(&pMonitor->timer)) {
|
||||
tscError("failed to stop timer, pMonitor:%p", pMonitor);
|
||||
}
|
||||
taosHashCleanup(pMonitor->counters);
|
||||
(void)taos_collector_registry_destroy(pMonitor->registry);
|
||||
int ret = taos_collector_registry_destroy(pMonitor->registry);
|
||||
if (ret){
|
||||
tscError("failed to destroy registry, pMonitor:%p ret:%d", pMonitor, ret);
|
||||
}
|
||||
taosMemoryFree(pMonitor);
|
||||
}
|
||||
|
||||
|
@ -186,7 +191,10 @@ static void generateClusterReport(taos_collector_registry_t* registry, void* pTr
|
|||
}
|
||||
|
||||
if (strlen(pCont) != 0 && sendReport(pTransporter, epSet, pCont, MONITOR_TYPE_COUNTER, NULL) == 0) {
|
||||
(void)taos_collector_registry_clear_batch(registry);
|
||||
int ret = taos_collector_registry_clear_batch(registry);
|
||||
if (ret){
|
||||
tscError("failed to clear registry, ret:%d", ret);
|
||||
}
|
||||
}
|
||||
taosMemoryFreeClear(pCont);
|
||||
}
|
||||
|
@ -207,7 +215,10 @@ static void reportSendProcess(void* param, void* tmrId) {
|
|||
|
||||
SEpSet ep = getEpSet_s(&pInst->mgmtEp);
|
||||
generateClusterReport(pMonitor->registry, pInst->pTransporter, &ep);
|
||||
(void)taosTmrReset(reportSendProcess, pInst->monitorParas.tsMonitorInterval * 1000, param, monitorTimer, &tmrId);
|
||||
bool reset = taosTmrReset(reportSendProcess, pInst->monitorParas.tsMonitorInterval * 1000, param, monitorTimer, &tmrId);
|
||||
if (!reset){
|
||||
tscError("failed to reset timer, pMonitor:%p", pMonitor);
|
||||
}
|
||||
taosRUnLockLatch(&monitorLock);
|
||||
}
|
||||
|
||||
|
@ -255,7 +266,11 @@ void monitorCreateClient(int64_t clusterId) {
|
|||
goto fail;
|
||||
}
|
||||
|
||||
(void)taos_collector_registry_register_collector(pMonitor->registry, pMonitor->colector);
|
||||
int r = taos_collector_registry_register_collector(pMonitor->registry, pMonitor->colector);
|
||||
if (r){
|
||||
tscError("failed to register collector, ret:%d", r);
|
||||
goto fail;
|
||||
}
|
||||
pMonitor->counters =
|
||||
(SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
||||
if (pMonitor->counters == NULL) {
|
||||
|
@ -304,12 +319,18 @@ void monitorCreateClientCounter(int64_t clusterId, const char* name, const char*
|
|||
MonitorClient* pMonitor = *ppMonitor;
|
||||
if (taos_collector_add_metric(pMonitor->colector, newCounter) != 0) {
|
||||
tscError("failed to add metric to collector");
|
||||
(void)taos_counter_destroy(newCounter);
|
||||
int r = taos_counter_destroy(newCounter);
|
||||
if (r){
|
||||
tscError("failed to destroy counter, code: %d", r);
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
if (taosHashPut(pMonitor->counters, name, strlen(name), &newCounter, POINTER_BYTES) != 0) {
|
||||
tscError("failed to put counter to monitor");
|
||||
(void)taos_counter_destroy(newCounter);
|
||||
int r = taos_counter_destroy(newCounter);
|
||||
if (r){
|
||||
tscError("failed to destroy counter, code: %d", r);
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
tscInfo("[monitor] monitorCreateClientCounter %" PRIx64 "(%p):%s : %p.", pMonitor->clusterId, pMonitor, name,
|
||||
|
@ -374,7 +395,10 @@ static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char* tmpP
|
|||
SlowLogClient* pClient = taosMemoryCalloc(1, sizeof(SlowLogClient));
|
||||
if (pClient == NULL) {
|
||||
tscError("failed to allocate memory for slow log client");
|
||||
(void)taosCloseFile(&pFile);
|
||||
int32_t ret = taosCloseFile(&pFile);
|
||||
if (ret != 0){
|
||||
tscError("failed to close file:%p ret:%d", pFile, ret);
|
||||
}
|
||||
return;
|
||||
}
|
||||
pClient->lastCheckTime = taosGetMonoTimestampMs();
|
||||
|
@ -383,7 +407,10 @@ static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char* tmpP
|
|||
pClient->pFile = pFile;
|
||||
if (taosHashPut(monitorSlowLogHash, &slowLogData->clusterId, LONG_BYTES, &pClient, POINTER_BYTES) != 0) {
|
||||
tscError("failed to put clusterId:%" PRId64 " to hash table", slowLogData->clusterId);
|
||||
(void)taosCloseFile(&pFile);
|
||||
int32_t ret = taosCloseFile(&pFile);
|
||||
if (ret != 0){
|
||||
tscError("failed to close file:%p ret:%d", pFile, ret);
|
||||
}
|
||||
taosMemoryFree(pClient);
|
||||
return;
|
||||
}
|
||||
|
@ -609,7 +636,11 @@ static void processFileRemoved(SlowLogClient* pClient) {
|
|||
tscError("failed to unlock file:%s since %d", pClient->path, terrno);
|
||||
return;
|
||||
}
|
||||
(void)taosCloseFile(&(pClient->pFile));
|
||||
int32_t ret = taosCloseFile(&(pClient->pFile));
|
||||
if (ret != 0){
|
||||
tscError("failed to close file:%p ret:%d", pClient->pFile, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
TdFilePtr pFile =
|
||||
taosOpenFile(pClient->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND | TD_FILE_READ | TD_FILE_TRUNC);
|
||||
|
@ -698,7 +729,10 @@ static void monitorSendAllSlowLogFromTempDir(int64_t clusterId) {
|
|||
}
|
||||
if (taosLockFile(pFile) < 0) {
|
||||
tscInfo("failed to lock file:%s since %s, maybe used by other process", filename, terrstr());
|
||||
(void)taosCloseFile(&pFile);
|
||||
int32_t ret = taosCloseFile(&pFile);
|
||||
if (ret != 0){
|
||||
tscError("failed to close file:%p ret:%d", pFile, ret);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
char* tmp = taosStrdup(filename);
|
||||
|
@ -706,7 +740,10 @@ static void monitorSendAllSlowLogFromTempDir(int64_t clusterId) {
|
|||
taosMemoryFree(tmp);
|
||||
}
|
||||
|
||||
(void)taosCloseDir(&pDir);
|
||||
int32_t ret = taosCloseDir(&pDir);
|
||||
if (ret != 0){
|
||||
tscError("failed to close dir, ret:%d", ret);
|
||||
}
|
||||
}
|
||||
|
||||
static void* monitorThreadFunc(void* param) {
|
||||
|
@ -852,7 +889,9 @@ void monitorClose() {
|
|||
taosHashCleanup(monitorSlowLogHash);
|
||||
taosTmrCleanUp(monitorTimer);
|
||||
taosCloseQueue(monitorQueue);
|
||||
(void)tsem2_destroy(&monitorSem);
|
||||
if(tsem2_destroy(&monitorSem) != 0) {
|
||||
tscError("failed to destroy semaphore");
|
||||
}
|
||||
taosWUnLockLatch(&monitorLock);
|
||||
}
|
||||
|
||||
|
@ -874,7 +913,9 @@ int32_t monitorPutData2MonitorQueue(MonitorSlowLogData data) {
|
|||
tscDebug("[monitor] write slow log to queue, clusterId:%" PRIx64 " type:%s, data:%s", slowLogData->clusterId,
|
||||
queueTypeStr[slowLogData->type], slowLogData->data);
|
||||
if (taosWriteQitem(monitorQueue, slowLogData) == 0) {
|
||||
(void)tsem2_post(&monitorSem);
|
||||
if(tsem2_post(&monitorSem) != 0) {
|
||||
tscError("failed to post semaphore");
|
||||
}
|
||||
} else {
|
||||
if (taosCloseFile(&(slowLogData->pFile)) != 0) {
|
||||
tscError("failed to close file:%p", slowLogData->pFile);
|
||||
|
|
|
@ -50,7 +50,9 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
if (pRequest->body.queryFp != NULL) {
|
||||
doRequestCallback(pRequest, code);
|
||||
} else {
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
if (tsem_post(&pRequest->body.rspSem) != 0){
|
||||
tscError("failed to post semaphore");
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -58,12 +60,10 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||
SRequestObj* pRequest = acquireRequest(*(int64_t*)param);
|
||||
if (NULL == pRequest) {
|
||||
goto End;
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
setErrno(pRequest, code);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
goto End;
|
||||
}
|
||||
|
||||
|
@ -71,23 +71,17 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
|
||||
if (NULL == pTscObj->pAppInfo) {
|
||||
code = TSDB_CODE_TSC_DISCONNECTED;
|
||||
setErrno(pRequest, code);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
goto End;
|
||||
}
|
||||
|
||||
SConnectRsp connectRsp = {0};
|
||||
if (tDeserializeSConnectRsp(pMsg->pData, pMsg->len, &connectRsp) != 0) {
|
||||
code = TSDB_CODE_TSC_INVALID_VERSION;
|
||||
setErrno(pRequest, code);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
goto End;
|
||||
}
|
||||
|
||||
if ((code = taosCheckVersionCompatibleFromStr(version, connectRsp.sVer, 3)) != 0) {
|
||||
tscError("version not compatible. client version: %s, server version: %s", version, connectRsp.sVer);
|
||||
setErrno(pRequest, code);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
goto End;
|
||||
}
|
||||
|
||||
|
@ -96,15 +90,11 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
if (delta > timestampDeltaLimit) {
|
||||
code = TSDB_CODE_TIME_UNSYNCED;
|
||||
tscError("time diff:%ds is too big", delta);
|
||||
setErrno(pRequest, code);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
goto End;
|
||||
}
|
||||
|
||||
if (connectRsp.epSet.numOfEps == 0) {
|
||||
code = TSDB_CODE_APP_ERROR;
|
||||
setErrno(pRequest, code);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
goto End;
|
||||
}
|
||||
|
||||
|
@ -177,8 +167,6 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
} else {
|
||||
(void)taosThreadMutexUnlock(&clientHbMgr.lock);
|
||||
code = TSDB_CODE_TSC_DISCONNECTED;
|
||||
setErrno(pRequest, code);
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
goto End;
|
||||
}
|
||||
(void)taosThreadMutexUnlock(&clientHbMgr.lock);
|
||||
|
@ -186,13 +174,19 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
tscDebug("0x%" PRIx64 " clusterId:%" PRId64 ", totalConn:%" PRId64, pRequest->requestId, connectRsp.clusterId,
|
||||
pTscObj->pAppInfo->numOfConns);
|
||||
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
End:
|
||||
if (code != 0){
|
||||
setErrno(pRequest, code);
|
||||
}
|
||||
if (tsem_post(&pRequest->body.rspSem) != 0){
|
||||
tscError("failed to post semaphore");
|
||||
}
|
||||
|
||||
if (pRequest) {
|
||||
(void)releaseRequest(pRequest->self);
|
||||
}
|
||||
|
||||
EXIT:
|
||||
taosMemoryFree(param);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
taosMemoryFree(pMsg->pData);
|
||||
|
@ -245,7 +239,9 @@ int32_t processCreateDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
if (pRequest->body.queryFp) {
|
||||
doRequestCallback(pRequest, code);
|
||||
} else {
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
if (tsem_post(&pRequest->body.rspSem) != 0){
|
||||
tscError("failed to post semaphore");
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -285,7 +281,9 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
doRequestCallback(pRequest, pRequest->code);
|
||||
|
||||
} else {
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
if (tsem_post(&pRequest->body.rspSem) != 0){
|
||||
tscError("failed to post semaphore");
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -363,7 +361,9 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
if (pRequest->body.queryFp != NULL) {
|
||||
doRequestCallback(pRequest, pRequest->code);
|
||||
} else {
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
if (tsem_post(&pRequest->body.rspSem) != 0){
|
||||
tscError("failed to post semaphore");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -386,7 +386,12 @@ int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
SMCreateStbRsp createRsp = {0};
|
||||
SDecoder coder = {0};
|
||||
tDecoderInit(&coder, pMsg->pData, pMsg->len);
|
||||
(void)tDecodeSMCreateStbRsp(&coder, &createRsp); // pMsg->len == 0
|
||||
if (pMsg->len > 0){
|
||||
code = tDecodeSMCreateStbRsp(&coder, &createRsp); // pMsg->len == 0
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
setErrno(pRequest, code);
|
||||
}
|
||||
}
|
||||
tDecoderClear(&coder);
|
||||
|
||||
pRequest->body.resInfo.execRes.msgType = TDMT_MND_CREATE_STB;
|
||||
|
@ -413,7 +418,9 @@ int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
|
||||
doRequestCallback(pRequest, code);
|
||||
} else {
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
if (tsem_post(&pRequest->body.rspSem) != 0){
|
||||
tscError("failed to post semaphore");
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -451,14 +458,15 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
}
|
||||
}
|
||||
|
||||
END:
|
||||
taosMemoryFree(pMsg->pData);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
|
||||
if (pRequest->body.queryFp != NULL) {
|
||||
doRequestCallback(pRequest, code);
|
||||
} else {
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
if (tsem_post(&pRequest->body.rspSem) != 0){
|
||||
tscError("failed to post semaphore");
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -471,7 +479,12 @@ int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
SMAlterStbRsp alterRsp = {0};
|
||||
SDecoder coder = {0};
|
||||
tDecoderInit(&coder, pMsg->pData, pMsg->len);
|
||||
(void)tDecodeSMAlterStbRsp(&coder, &alterRsp); // pMsg->len = 0
|
||||
if (pMsg->len > 0){
|
||||
code = tDecodeSMAlterStbRsp(&coder, &alterRsp); // pMsg->len == 0
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
setErrno(pRequest, code);
|
||||
}
|
||||
}
|
||||
tDecoderClear(&coder);
|
||||
|
||||
pRequest->body.resInfo.execRes.msgType = TDMT_MND_ALTER_STB;
|
||||
|
@ -498,7 +511,9 @@ int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
|
||||
doRequestCallback(pRequest, code);
|
||||
} else {
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
if (tsem_post(&pRequest->body.rspSem) != 0){
|
||||
tscError("failed to post semaphore");
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -649,7 +664,9 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
if (pRequest->body.queryFp != NULL) {
|
||||
doRequestCallback(pRequest, code);
|
||||
} else {
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
if (tsem_post(&pRequest->body.rspSem) != 0){
|
||||
tscError("failed to post semaphore");
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -801,7 +818,9 @@ int32_t processCompactDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
if (pRequest->body.queryFp != NULL) {
|
||||
pRequest->body.queryFp(((SSyncQueryParam *)pRequest->body.interParam)->userParam, pRequest, code);
|
||||
} else {
|
||||
(void)tsem_post(&pRequest->body.rspSem);
|
||||
if (tsem_post(&pRequest->body.rspSem) != 0){
|
||||
tscError("failed to post semaphore");
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -417,6 +417,10 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
|
|||
}
|
||||
char* pJson = NULL;
|
||||
parseTagDatatoJson(pTag, &pJson);
|
||||
if(pJson == NULL) {
|
||||
uError("parseTagDatatoJson failed, pJson == NULL");
|
||||
goto end;
|
||||
}
|
||||
cJSON* tag = cJSON_CreateObject();
|
||||
RAW_NULL_CHECK(tag);
|
||||
STagVal* pTagVal = taosArrayGet(pTagVals, 0);
|
||||
|
@ -727,6 +731,10 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
|||
goto end;
|
||||
}
|
||||
parseTagDatatoJson(vAlterTbReq.pTagVal, &buf);
|
||||
if(buf == NULL) {
|
||||
uError("parseTagDatatoJson failed, buf == NULL");
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
if (vAlterTbReq.tagType == TSDB_DATA_TYPE_VARBINARY) {
|
||||
buf = taosMemoryCalloc(vAlterTbReq.nTagVal * 2 + 2 + 3, 1);
|
||||
|
@ -960,6 +968,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
RAW_NULL_CHECK(pCmdMsg.pMsg);
|
||||
if (tSerializeSMCreateStbReq(pCmdMsg.pMsg, pCmdMsg.msgLen, &pReq) <= 0) {
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
taosMemoryFree(pCmdMsg.pMsg);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -971,15 +980,15 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
|
||||
(void)launchQueryImpl(pRequest, &pQuery, true, NULL); // ignore, because return value is pRequest
|
||||
|
||||
taosMemoryFree(pCmdMsg.pMsg);
|
||||
|
||||
if (pRequest->code == TSDB_CODE_SUCCESS) {
|
||||
SCatalog* pCatalog = NULL;
|
||||
// ignore the return value
|
||||
(void)catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
(void)catalogRemoveTableMeta(pCatalog, &tableName);
|
||||
RAW_RETURN_CHECK(catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog));
|
||||
RAW_RETURN_CHECK(catalogRemoveTableMeta(pCatalog, &tableName));
|
||||
}
|
||||
|
||||
code = pRequest->code;
|
||||
taosMemoryFree(pCmdMsg.pMsg);
|
||||
|
||||
end:
|
||||
uDebug(LOG_ID_TAG " create stable return, msg:%s", LOG_ID_VALUE, tstrerror(code));
|
||||
|
@ -1022,8 +1031,7 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp)};
|
||||
SName pName = {0};
|
||||
toName(pRequest->pTscObj->acctId, pRequest->pDb, req.name,
|
||||
&pName); // ignore the return value, always return pName
|
||||
toName(pRequest->pTscObj->acctId, pRequest->pDb, req.name, &pName);
|
||||
STableMeta* pTableMeta = NULL;
|
||||
code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta);
|
||||
if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) {
|
||||
|
@ -1064,6 +1072,7 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
RAW_NULL_CHECK(pCmdMsg.pMsg);
|
||||
if (tSerializeSMDropStbReq(pCmdMsg.pMsg, pCmdMsg.msgLen, &pReq) <= 0) {
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
taosMemoryFree(pCmdMsg.pMsg);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1074,15 +1083,14 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
pQuery.stableQuery = true;
|
||||
|
||||
(void)launchQueryImpl(pRequest, &pQuery, true, NULL); // ignore, because return value is pRequest
|
||||
|
||||
taosMemoryFree(pCmdMsg.pMsg);
|
||||
if (pRequest->code == TSDB_CODE_SUCCESS) {
|
||||
// ignore the error code
|
||||
(void)catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
(void)catalogRemoveTableMeta(pCatalog, &tableName);
|
||||
RAW_RETURN_CHECK(catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog));
|
||||
RAW_RETURN_CHECK(catalogRemoveTableMeta(pCatalog, &tableName));
|
||||
}
|
||||
|
||||
code = pRequest->code;
|
||||
taosMemoryFree(pCmdMsg.pMsg);
|
||||
|
||||
end:
|
||||
uDebug(LOG_ID_TAG " drop stable return, msg:%s", LOG_ID_VALUE, tstrerror(code));
|
||||
|
@ -1230,7 +1238,7 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
|
||||
(void)launchQueryImpl(pRequest, pQuery, true, NULL);
|
||||
if (pRequest->code == TSDB_CODE_SUCCESS) {
|
||||
(void)removeMeta(pTscObj, pRequest->tableList, false);
|
||||
RAW_RETURN_CHECK(removeMeta(pTscObj, pRequest->tableList, false));
|
||||
}
|
||||
|
||||
code = pRequest->code;
|
||||
|
@ -1359,7 +1367,7 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
|
||||
(void)launchQueryImpl(pRequest, pQuery, true, NULL);
|
||||
if (pRequest->code == TSDB_CODE_SUCCESS) {
|
||||
(void)removeMeta(pTscObj, pRequest->tableList, false);
|
||||
RAW_RETURN_CHECK(removeMeta(pTscObj, pRequest->tableList, false));
|
||||
}
|
||||
code = pRequest->code;
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ static int32_t smlCheckAuth(SSmlHandle *info, SRequestConnInfo *conn, const char
|
|||
return TSDB_CODE_SML_INVALID_DATA;
|
||||
}
|
||||
} else {
|
||||
toName(info->taos->acctId, info->pRequest->pDb, pTabName, &pAuth.tbName); //ignore
|
||||
toName(info->taos->acctId, info->pRequest->pDb, pTabName, &pAuth.tbName);
|
||||
}
|
||||
pAuth.type = type;
|
||||
|
||||
|
@ -2217,9 +2217,12 @@ TAOS_RES *taos_schemaless_insert_inner(TAOS *taos, char *lines[], char *rawLine,
|
|||
break;
|
||||
}
|
||||
taosMsleep(100);
|
||||
(void)refreshMeta(request->pTscObj, request); //ignore return code,try again
|
||||
uInfo("SML:%" PRIx64 " retry:%d/10,ver is old retry or object is creating code:%d, msg:%s", info->id, cnt, code,
|
||||
tstrerror(code));
|
||||
code = refreshMeta(request->pTscObj, request);
|
||||
if (code != 0){
|
||||
uInfo("SML:%" PRIx64 " refresh meta error code:%d, msg:%s", info->id, code, tstrerror(code));
|
||||
}
|
||||
smlDestroyInfo(info);
|
||||
info = NULL;
|
||||
taos_free_result(request);
|
||||
|
|
|
@ -771,7 +771,10 @@ void* stmtBindThreadFunc(void* param) {
|
|||
continue;
|
||||
}
|
||||
|
||||
(void)stmtAsyncOutput(pStmt, asyncParam);
|
||||
int ret = stmtAsyncOutput(pStmt, asyncParam);
|
||||
if (ret != 0){
|
||||
qError("stmtAsyncOutput failed, reason:%s", tstrerror(ret));
|
||||
}
|
||||
}
|
||||
|
||||
qInfo("stmt bind thread stopped");
|
||||
|
|
|
@ -194,6 +194,12 @@ static int32_t stmtUpdateBindInfo(TAOS_STMT2* stmt, STableMeta* pTableMeta, void
|
|||
pStmt->bInfo.tbSuid = pTableMeta->suid;
|
||||
pStmt->bInfo.tbVgId = pTableMeta->vgId;
|
||||
pStmt->bInfo.tbType = pTableMeta->tableType;
|
||||
|
||||
if (!pStmt->bInfo.tagsCached) {
|
||||
qDestroyBoundColInfo(pStmt->bInfo.boundTags);
|
||||
taosMemoryFreeClear(pStmt->bInfo.boundTags);
|
||||
}
|
||||
|
||||
pStmt->bInfo.boundTags = tags;
|
||||
pStmt->bInfo.tagsCached = false;
|
||||
tstrncpy(pStmt->bInfo.stbFName, sTableName, sizeof(pStmt->bInfo.stbFName));
|
||||
|
@ -985,10 +991,6 @@ int stmtSetTbTags2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* tags) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (pStmt->bInfo.inExecCache) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
STableDataCxt** pDataBlock =
|
||||
(STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||
if (NULL == pDataBlock) {
|
||||
|
@ -996,6 +998,10 @@ int stmtSetTbTags2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* tags) {
|
|||
STMT_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
if (pStmt->bInfo.inExecCache && (!pStmt->sql.autoCreateTbl || (*pDataBlock)->pData->pCreateTbReq)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
tscDebug("start to bind stmt tag values");
|
||||
STMT_ERR_RET(qBindStmtTagsValue2(*pDataBlock, pStmt->bInfo.boundTags, pStmt->bInfo.tbSuid, pStmt->bInfo.stbFName,
|
||||
pStmt->bInfo.sname.tname, tags, pStmt->exec.pRequest->msgBuf,
|
||||
|
@ -1889,7 +1895,12 @@ int stmtGetParamTbName(TAOS_STMT2* stmt, int* nums) {
|
|||
STMT_ERR_RET(stmtParseSql(pStmt));
|
||||
}
|
||||
|
||||
*nums = STMT_TYPE_MULTI_INSERT == pStmt->sql.type ? 1 : 0;
|
||||
if (TSDB_CODE_TSC_STMT_TBNAME_ERROR == pStmt->errCode) {
|
||||
*nums = 1;
|
||||
pStmt->errCode = TSDB_CODE_SUCCESS;
|
||||
} else {
|
||||
*nums = STMT_TYPE_MULTI_INSERT == pStmt->sql.type ? 1 : 0;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -807,11 +807,18 @@ static void generateTimedTask(int64_t refId, int32_t type) {
|
|||
if (code == TSDB_CODE_SUCCESS) {
|
||||
*pTaskType = type;
|
||||
if (taosWriteQitem(tmq->delayedTask, pTaskType) == 0) {
|
||||
(void)tsem2_post(&tmq->rspSem);
|
||||
if (tsem2_post(&tmq->rspSem) != 0){
|
||||
tscError("consumer:0x%" PRIx64 " failed to post sem, type:%d", tmq->consumerId, type);
|
||||
}
|
||||
}else{
|
||||
taosFreeQitem(pTaskType);
|
||||
}
|
||||
}
|
||||
|
||||
(void)taosReleaseRef(tmqMgmt.rsetId, refId);
|
||||
code = taosReleaseRef(tmqMgmt.rsetId, refId);
|
||||
if (code != 0){
|
||||
tscError("failed to release ref:%"PRId64 ", type:%d, code:%d", refId, type, code);
|
||||
}
|
||||
}
|
||||
|
||||
void tmqAssignAskEpTask(void* param, void* tmrId) {
|
||||
|
@ -824,8 +831,13 @@ void tmqReplayTask(void* param, void* tmrId) {
|
|||
tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId);
|
||||
if (tmq == NULL) return;
|
||||
|
||||
(void)tsem2_post(&tmq->rspSem);
|
||||
(void)taosReleaseRef(tmqMgmt.rsetId, refId);
|
||||
if (tsem2_post(&tmq->rspSem) != 0){
|
||||
tscError("consumer:0x%" PRIx64 " failed to post sem, replay", tmq->consumerId);
|
||||
}
|
||||
int32_t code = taosReleaseRef(tmqMgmt.rsetId, refId);
|
||||
if (code != 0){
|
||||
tscError("failed to release ref:%"PRId64 ", code:%d", refId, code);
|
||||
}
|
||||
}
|
||||
|
||||
void tmqAssignDelayedCommitTask(void* param, void* tmrId) {
|
||||
|
@ -835,17 +847,17 @@ void tmqAssignDelayedCommitTask(void* param, void* tmrId) {
|
|||
|
||||
int32_t tmqHbCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||
if (code != 0) {
|
||||
goto _return;
|
||||
goto END;
|
||||
}
|
||||
if (pMsg == NULL || param == NULL) {
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
goto _return;
|
||||
goto END;
|
||||
}
|
||||
|
||||
SMqHbRsp rsp = {0};
|
||||
code = tDeserializeSMqHbRsp(pMsg->pData, pMsg->len, &rsp);
|
||||
if (code != 0) {
|
||||
goto _return;
|
||||
goto END;
|
||||
}
|
||||
|
||||
int64_t refId = (int64_t)param;
|
||||
|
@ -866,13 +878,15 @@ int32_t tmqHbCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
}
|
||||
}
|
||||
taosWUnLockLatch(&tmq->lock);
|
||||
(void)taosReleaseRef(tmqMgmt.rsetId, refId);
|
||||
code = taosReleaseRef(tmqMgmt.rsetId, refId);
|
||||
if (code != 0){
|
||||
tscError("failed to release ref:%"PRId64 ", code:%d", refId, code);
|
||||
}
|
||||
}
|
||||
|
||||
tDestroySMqHbRsp(&rsp);
|
||||
|
||||
_return:
|
||||
|
||||
END:
|
||||
taosMemoryFree(pMsg->pData);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
return code;
|
||||
|
@ -974,9 +988,15 @@ void tmqSendHbReq(void* param, void* tmrId) {
|
|||
OVER:
|
||||
tDestroySMqHbReq(&req);
|
||||
if (tmrId != NULL) {
|
||||
(void)taosTmrReset(tmqSendHbReq, tmq->heartBeatIntervalMs, param, tmqMgmt.timer, &tmq->hbLiveTimer);
|
||||
bool ret = taosTmrReset(tmqSendHbReq, tmq->heartBeatIntervalMs, param, tmqMgmt.timer, &tmq->hbLiveTimer);
|
||||
if (!ret){
|
||||
tscError("failed to reset timer fo tmq hb");
|
||||
}
|
||||
}
|
||||
int32_t ret = taosReleaseRef(tmqMgmt.rsetId, refId);
|
||||
if (ret != 0){
|
||||
tscError("failed to release ref:%"PRId64 ", code:%d", refId, ret);
|
||||
}
|
||||
(void)taosReleaseRef(tmqMgmt.rsetId, refId);
|
||||
}
|
||||
|
||||
static void defaultCommitCbFn(tmq_t* pTmq, int32_t code, void* param) {
|
||||
|
@ -995,9 +1015,7 @@ void tmqHandleAllDelayedTask(tmq_t* pTmq) {
|
|||
return;
|
||||
}
|
||||
|
||||
(void)taosReadAllQitems(pTmq->delayedTask, qall);
|
||||
|
||||
int32_t numOfItems = taosQallItemSize(qall);
|
||||
int32_t numOfItems = taosReadAllQitems(pTmq->delayedTask, qall);
|
||||
if (numOfItems == 0) {
|
||||
taosFreeQall(qall);
|
||||
return;
|
||||
|
@ -1005,9 +1023,7 @@ void tmqHandleAllDelayedTask(tmq_t* pTmq) {
|
|||
|
||||
tscDebug("consumer:0x%" PRIx64 " handle delayed %d tasks before poll data", pTmq->consumerId, numOfItems);
|
||||
int8_t* pTaskType = NULL;
|
||||
(void)taosGetQitem(qall, (void**)&pTaskType);
|
||||
|
||||
while (pTaskType != NULL) {
|
||||
while (taosGetQitem(qall, (void**)&pTaskType) != 0) {
|
||||
if (*pTaskType == TMQ_DELAYED_TASK__ASK_EP) {
|
||||
code = askEp(pTmq, NULL, false, false);
|
||||
if (code != 0) {
|
||||
|
@ -1015,21 +1031,26 @@ void tmqHandleAllDelayedTask(tmq_t* pTmq) {
|
|||
continue;
|
||||
}
|
||||
tscDebug("consumer:0x%" PRIx64 " retrieve ep from mnode in 1s", pTmq->consumerId);
|
||||
(void)taosTmrReset(tmqAssignAskEpTask, DEFAULT_ASKEP_INTERVAL, (void*)(pTmq->refId), tmqMgmt.timer,
|
||||
bool ret = taosTmrReset(tmqAssignAskEpTask, DEFAULT_ASKEP_INTERVAL, (void*)(pTmq->refId), tmqMgmt.timer,
|
||||
&pTmq->epTimer);
|
||||
if (!ret){
|
||||
tscError("failed to reset timer fo tmq ask ep");
|
||||
}
|
||||
} else if (*pTaskType == TMQ_DELAYED_TASK__COMMIT) {
|
||||
tmq_commit_cb* pCallbackFn = pTmq->commitCb ? pTmq->commitCb : defaultCommitCbFn;
|
||||
asyncCommitAllOffsets(pTmq, pCallbackFn, pTmq->commitCbUserParam);
|
||||
tscDebug("consumer:0x%" PRIx64 " next commit to vnode(s) in %.2fs", pTmq->consumerId,
|
||||
pTmq->autoCommitInterval / 1000.0);
|
||||
(void)taosTmrReset(tmqAssignDelayedCommitTask, pTmq->autoCommitInterval, (void*)(pTmq->refId), tmqMgmt.timer,
|
||||
bool ret = taosTmrReset(tmqAssignDelayedCommitTask, pTmq->autoCommitInterval, (void*)(pTmq->refId), tmqMgmt.timer,
|
||||
&pTmq->commitTimer);
|
||||
if (!ret){
|
||||
tscError("failed to reset timer fo commit");
|
||||
}
|
||||
} else {
|
||||
tscError("consumer:0x%" PRIx64 " invalid task type:%d", pTmq->consumerId, *pTaskType);
|
||||
}
|
||||
|
||||
taosFreeQitem(pTaskType);
|
||||
(void)taosGetQitem(qall, (void**)&pTaskType);
|
||||
}
|
||||
|
||||
taosFreeQall(qall);
|
||||
|
@ -1061,26 +1082,18 @@ static void tmqFreeRspWrapper(SMqRspWrapper* rspWrapper) {
|
|||
|
||||
void tmqClearUnhandleMsg(tmq_t* tmq) {
|
||||
SMqRspWrapper* rspWrapper = NULL;
|
||||
while (1) {
|
||||
(void)taosGetQitem(tmq->qall, (void**)&rspWrapper);
|
||||
if (rspWrapper) {
|
||||
while (taosGetQitem(tmq->qall, (void**)&rspWrapper) != 0) {
|
||||
tmqFreeRspWrapper(rspWrapper);
|
||||
taosFreeQitem(rspWrapper);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rspWrapper = NULL;
|
||||
(void)taosReadAllQitems(tmq->mqueue, tmq->qall);
|
||||
while (1) {
|
||||
(void)taosGetQitem(tmq->qall, (void**)&rspWrapper);
|
||||
if (rspWrapper) {
|
||||
tmqFreeRspWrapper(rspWrapper);
|
||||
taosFreeQitem(rspWrapper);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
if (taosReadAllQitems(tmq->mqueue, tmq->qall) == 0){
|
||||
return;
|
||||
}
|
||||
while (taosGetQitem(tmq->qall, (void**)&rspWrapper) != 0) {
|
||||
tmqFreeRspWrapper(rspWrapper);
|
||||
taosFreeQitem(rspWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1095,7 +1108,9 @@ int32_t tmqSubscribeCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
if (pMsg) {
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
}
|
||||
(void)tsem2_post(&pParam->rspSem);
|
||||
if (tsem2_post(&pParam->rspSem) != 0){
|
||||
tscError("failed to post sem, subscribe cb");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1154,19 +1169,27 @@ void tmqFreeImpl(void* handle) {
|
|||
}
|
||||
|
||||
taosFreeQall(tmq->qall);
|
||||
(void)tsem2_destroy(&tmq->rspSem);
|
||||
if(tsem2_destroy(&tmq->rspSem) != 0) {
|
||||
tscError("failed to destroy sem in free tmq");
|
||||
}
|
||||
|
||||
taosArrayDestroyEx(tmq->clientTopics, freeClientTopic);
|
||||
taos_close_internal(tmq->pTscObj);
|
||||
|
||||
if (tmq->commitTimer) {
|
||||
(void)taosTmrStopA(&tmq->commitTimer);
|
||||
if (!taosTmrStopA(&tmq->commitTimer)) {
|
||||
tscError("failed to stop commit timer");
|
||||
}
|
||||
}
|
||||
if (tmq->epTimer) {
|
||||
(void)taosTmrStopA(&tmq->epTimer);
|
||||
if (!taosTmrStopA(&tmq->epTimer)) {
|
||||
tscError("failed to stop ep timer");
|
||||
}
|
||||
}
|
||||
if (tmq->hbLiveTimer) {
|
||||
(void)taosTmrStopA(&tmq->hbLiveTimer);
|
||||
if (!taosTmrStopA(&tmq->hbLiveTimer)) {
|
||||
tscError("failed to stop hb timer");
|
||||
}
|
||||
}
|
||||
taosMemoryFree(tmq);
|
||||
|
||||
|
@ -1312,7 +1335,6 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
|||
if (code) {
|
||||
terrno = code;
|
||||
tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, terrstr(), pTmq->groupId);
|
||||
(void)tsem2_destroy(&pTmq->rspSem);
|
||||
SET_ERROR_MSG_TMQ("init tscObj failed")
|
||||
goto _failed;
|
||||
}
|
||||
|
@ -1419,7 +1441,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
|||
}
|
||||
|
||||
void* abuf = buf;
|
||||
(void)tSerializeSCMSubscribeReq(&abuf, &req);
|
||||
tlen = tSerializeSCMSubscribeReq(&abuf, &req);
|
||||
|
||||
sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (sendInfo == NULL) {
|
||||
|
@ -1450,8 +1472,12 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
|||
goto FAIL;
|
||||
}
|
||||
|
||||
(void)tsem2_wait(¶m.rspSem);
|
||||
(void)tsem2_destroy(¶m.rspSem);
|
||||
if (tsem2_wait(¶m.rspSem) != 0){
|
||||
tscError("consumer:0x%" PRIx64 ", failed to wait semaphore in subscribe", tmq->consumerId);
|
||||
}
|
||||
if(tsem2_destroy(¶m.rspSem) != 0) {
|
||||
tscError("consumer:0x%" PRIx64 ", failed to destroy semaphore in subscribe", tmq->consumerId);
|
||||
}
|
||||
|
||||
if (param.rspErr != 0) {
|
||||
code = param.rspErr;
|
||||
|
@ -1656,6 +1682,8 @@ END:
|
|||
(void)strcpy(pRspWrapper->topicName, pParam->topicName);
|
||||
code = taosWriteQitem(tmq->mqueue, pRspWrapper);
|
||||
if (code != 0) {
|
||||
tmqFreeRspWrapper((SMqRspWrapper*)pRspWrapper);
|
||||
taosFreeQitem(pRspWrapper);
|
||||
tscError("consumer:0x%" PRIx64 " put poll res into mqueue failed, code:%d", tmq->consumerId, code);
|
||||
}
|
||||
}
|
||||
|
@ -1663,10 +1691,17 @@ END:
|
|||
tscDebug("consumer:0x%" PRIx64 " put poll res into mqueue, type:%d, vgId:%d, total in queue:%d,QID:0x%" PRIx64,
|
||||
tmq ? tmq->consumerId : 0, rspType, vgId, total, requestId);
|
||||
|
||||
if (tmq) (void)tsem2_post(&tmq->rspSem);
|
||||
if (tmq) {
|
||||
if (tsem2_post(&tmq->rspSem) != 0){
|
||||
tscError("failed to post rsp sem, consumer:0x%" PRIx64, tmq->consumerId);
|
||||
}
|
||||
}
|
||||
if (pMsg) taosMemoryFreeClear(pMsg->pData);
|
||||
if (pMsg) taosMemoryFreeClear(pMsg->pEpSet);
|
||||
(void)taosReleaseRef(tmqMgmt.rsetId, refId);
|
||||
ret = taosReleaseRef(tmqMgmt.rsetId, refId);
|
||||
if (ret != 0){
|
||||
tscError("failed to release ref:%"PRId64 ", code:%d", refId, ret);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -1763,7 +1798,7 @@ static bool doUpdateLocalEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp)
|
|||
|
||||
SHashObj* pVgOffsetHashMap = taosHashInit(64, MurmurHash3_32, false, HASH_NO_LOCK);
|
||||
if (pVgOffsetHashMap == NULL) {
|
||||
(void)taosArrayDestroy(newTopics);
|
||||
taosArrayDestroy(newTopics);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1848,10 +1883,10 @@ void tmqBuildConsumeReqImpl(SMqPollReq* pReq, tmq_t* tmq, int64_t timeout, SMqCl
|
|||
pReq->enableBatchMeta = tmq->enableBatchMeta;
|
||||
}
|
||||
|
||||
int32_t tmqBuildMetaRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqMetaRspObj** ppRspObj) {
|
||||
void tmqBuildMetaRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqMetaRspObj** ppRspObj) {
|
||||
SMqMetaRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqMetaRspObj));
|
||||
if (pRspObj == NULL) {
|
||||
return terrno;
|
||||
return;
|
||||
}
|
||||
pRspObj->resType = RES_TYPE__TMQ_META;
|
||||
tstrncpy(pRspObj->topic, pWrapper->topicHandle->topicName, TSDB_TOPIC_FNAME_LEN);
|
||||
|
@ -1860,13 +1895,12 @@ int32_t tmqBuildMetaRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqMetaRspObj**
|
|||
|
||||
(void)memcpy(&pRspObj->metaRsp, &pWrapper->metaRsp, sizeof(SMqMetaRsp));
|
||||
*ppRspObj = pRspObj;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tmqBuildBatchMetaRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqBatchMetaRspObj** ppRspObj) {
|
||||
void tmqBuildBatchMetaRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqBatchMetaRspObj** ppRspObj) {
|
||||
SMqBatchMetaRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqBatchMetaRspObj));
|
||||
if (pRspObj == NULL) {
|
||||
return terrno;
|
||||
return;
|
||||
}
|
||||
pRspObj->common.resType = RES_TYPE__TMQ_BATCH_META;
|
||||
tstrncpy(pRspObj->common.topic, pWrapper->topicHandle->topicName, TSDB_TOPIC_FNAME_LEN);
|
||||
|
@ -1876,7 +1910,6 @@ int32_t tmqBuildBatchMetaRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqBatchMet
|
|||
(void)memcpy(&pRspObj->rsp, &pWrapper->batchMetaRsp, sizeof(SMqBatchMetaRsp));
|
||||
tscDebug("build batchmeta Rsp from wrapper");
|
||||
*ppRspObj = pRspObj;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void changeByteEndian(char* pData) {
|
||||
|
@ -1973,31 +2006,29 @@ static void tmqBuildRspFromWrapperInner(SMqPollRspWrapper* pWrapper, SMqClientVg
|
|||
}
|
||||
}
|
||||
|
||||
int32_t tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows,
|
||||
void tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows,
|
||||
SMqRspObj** ppRspObj) {
|
||||
SMqRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqRspObj));
|
||||
if (pRspObj == NULL) {
|
||||
return terrno;
|
||||
return;
|
||||
}
|
||||
pRspObj->common.resType = RES_TYPE__TMQ;
|
||||
(void)memcpy(&pRspObj->rsp, &pWrapper->dataRsp, sizeof(SMqDataRsp));
|
||||
tmqBuildRspFromWrapperInner(pWrapper, pVg, numOfRows, &pRspObj->common, &pRspObj->rsp.common);
|
||||
*ppRspObj = pRspObj;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tmqBuildTaosxRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows,
|
||||
void tmqBuildTaosxRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows,
|
||||
SMqTaosxRspObj** ppRspObj) {
|
||||
SMqTaosxRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqTaosxRspObj));
|
||||
if (pRspObj == NULL) {
|
||||
return terrno;
|
||||
return;
|
||||
}
|
||||
pRspObj->common.resType = RES_TYPE__TMQ_METADATA;
|
||||
(void)memcpy(&pRspObj->rsp, &pWrapper->taosxRsp, sizeof(STaosxRsp));
|
||||
|
||||
tmqBuildRspFromWrapperInner(pWrapper, pVg, numOfRows, &pRspObj->common, &pRspObj->rsp.common);
|
||||
*ppRspObj = pRspObj;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t doTmqPollImpl(tmq_t* pTmq, SMqClientTopic* pTopic, SMqClientVg* pVg, int64_t timeout) {
|
||||
|
@ -2156,12 +2187,11 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
|
||||
while (1) {
|
||||
SMqRspWrapper* pRspWrapper = NULL;
|
||||
(void)taosGetQitem(tmq->qall, (void**)&pRspWrapper);
|
||||
|
||||
if (pRspWrapper == NULL) {
|
||||
(void)taosReadAllQitems(tmq->mqueue, tmq->qall);
|
||||
(void)taosGetQitem(tmq->qall, (void**)&pRspWrapper);
|
||||
if (pRspWrapper == NULL) {
|
||||
if (taosGetQitem(tmq->qall, (void**)&pRspWrapper) == 0) {
|
||||
if (taosReadAllQitems(tmq->mqueue, tmq->qall) == 0){
|
||||
return NULL;
|
||||
}
|
||||
if (taosGetQitem(tmq->qall, (void**)&pRspWrapper) == 0) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -2239,7 +2269,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
} else { // build rsp
|
||||
int64_t numOfRows = 0;
|
||||
SMqRspObj* pRsp = NULL;
|
||||
(void)tmqBuildRspFromWrapper(pollRspWrapper, pVg, &numOfRows, &pRsp);
|
||||
tmqBuildRspFromWrapper(pollRspWrapper, pVg, &numOfRows, &pRsp);
|
||||
tmq->totalRows += numOfRows;
|
||||
pVg->emptyBlockReceiveTs = 0;
|
||||
if (pRsp && tmq->replayEnable) {
|
||||
|
@ -2293,7 +2323,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
pollRspWrapper->metaRsp.head.walsver, pollRspWrapper->metaRsp.head.walever, tmq->consumerId, true);
|
||||
// build rsp
|
||||
SMqMetaRspObj* pRsp = NULL;
|
||||
(void)tmqBuildMetaRspFromWrapper(pollRspWrapper, &pRsp);
|
||||
tmqBuildMetaRspFromWrapper(pollRspWrapper, &pRsp);
|
||||
taosMemoryFreeClear(pollRspWrapper->pEpset);
|
||||
taosFreeQitem(pRspWrapper);
|
||||
taosWUnLockLatch(&tmq->lock);
|
||||
|
@ -2331,7 +2361,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
pollRspWrapper->batchMetaRsp.head.walsver, pollRspWrapper->batchMetaRsp.head.walever,
|
||||
tmq->consumerId, true);
|
||||
SMqBatchMetaRspObj* pRsp = NULL;
|
||||
(void)tmqBuildBatchMetaRspFromWrapper(pollRspWrapper, &pRsp);
|
||||
tmqBuildBatchMetaRspFromWrapper(pollRspWrapper, &pRsp);
|
||||
taosMemoryFreeClear(pollRspWrapper->pEpset);
|
||||
taosFreeQitem(pRspWrapper);
|
||||
taosWUnLockLatch(&tmq->lock);
|
||||
|
@ -2381,9 +2411,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
// build rsp
|
||||
int64_t numOfRows = 0;
|
||||
SMqTaosxRspObj* pRsp = NULL;
|
||||
if (tmqBuildTaosxRspFromWrapper(pollRspWrapper, pVg, &numOfRows, &pRsp) != 0) {
|
||||
tscError("consumer:0x%" PRIx64 " build taosx rsp failed, vgId:%d", tmq->consumerId, pVg->vgId);
|
||||
}
|
||||
tmqBuildTaosxRspFromWrapper(pollRspWrapper, pVg, &numOfRows, &pRsp);
|
||||
tmq->totalRows += numOfRows;
|
||||
|
||||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
|
@ -2551,7 +2579,10 @@ int32_t tmq_consumer_close(tmq_t* tmq) {
|
|||
}
|
||||
|
||||
if (code == 0) {
|
||||
(void)taosRemoveRef(tmqMgmt.rsetId, tmq->refId);
|
||||
code = taosRemoveRef(tmqMgmt.rsetId, tmq->refId);
|
||||
if (code != 0){
|
||||
tscError("tmq close failed to remove ref:%" PRId64 ", code:%d", tmq->refId, code);
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -2709,7 +2740,9 @@ void tmq_commit_async(tmq_t* tmq, const TAOS_RES* pRes, tmq_commit_cb* cb, void*
|
|||
static void commitCallBackFn(tmq_t* UNUSED_PARAM(tmq), int32_t code, void* param) {
|
||||
SSyncCommitInfo* pInfo = (SSyncCommitInfo*)param;
|
||||
pInfo->code = code;
|
||||
(void)tsem2_post(&pInfo->sem);
|
||||
if (tsem2_post(&pInfo->sem) != 0){
|
||||
tscError("failed to post rsp sem in commit cb");
|
||||
}
|
||||
}
|
||||
|
||||
int32_t tmq_commit_sync(tmq_t* tmq, const TAOS_RES* pRes) {
|
||||
|
@ -2738,10 +2771,14 @@ int32_t tmq_commit_sync(tmq_t* tmq, const TAOS_RES* pRes) {
|
|||
asyncCommitFromResult(tmq, pRes, commitCallBackFn, pInfo);
|
||||
}
|
||||
|
||||
(void)tsem2_wait(&pInfo->sem);
|
||||
if (tsem2_wait(&pInfo->sem) != 0){
|
||||
tscError("failed to wait sem for sync commit");
|
||||
}
|
||||
code = pInfo->code;
|
||||
|
||||
(void)tsem2_destroy(&pInfo->sem);
|
||||
if(tsem2_destroy(&pInfo->sem) != 0) {
|
||||
tscError("failed to destroy sem for sync commit");
|
||||
}
|
||||
taosMemoryFree(pInfo);
|
||||
|
||||
tscInfo("consumer:0x%" PRIx64 " sync res commit done, code:%s", tmq->consumerId, tstrerror(code));
|
||||
|
@ -2806,12 +2843,16 @@ int32_t tmq_commit_offset_sync(tmq_t* tmq, const char* pTopicName, int32_t vgId,
|
|||
|
||||
code = asyncCommitOffset(tmq, tname, vgId, &offsetVal, commitCallBackFn, pInfo);
|
||||
if (code == 0) {
|
||||
(void)tsem2_wait(&pInfo->sem);
|
||||
if (tsem2_wait(&pInfo->sem) != 0){
|
||||
tscError("failed to wait sem for sync commit offset");
|
||||
}
|
||||
code = pInfo->code;
|
||||
}
|
||||
|
||||
if (code == TSDB_CODE_TMQ_SAME_COMMITTED_VALUE) code = TSDB_CODE_SUCCESS;
|
||||
(void)tsem2_destroy(&pInfo->sem);
|
||||
if(tsem2_destroy(&pInfo->sem) != 0) {
|
||||
tscError("failed to destroy sem for sync commit offset");
|
||||
}
|
||||
taosMemoryFree(pInfo);
|
||||
|
||||
tscInfo("consumer:0x%" PRIx64 " sync send commit to vgId:%d, offset:%" PRId64 " code:%s", tmq->consumerId, vgId,
|
||||
|
@ -2864,11 +2905,11 @@ end:
|
|||
}
|
||||
|
||||
int32_t askEpCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||
if (param == NULL) {
|
||||
SMqAskEpCbParam* pParam = (SMqAskEpCbParam*)param;
|
||||
if (pParam == NULL) {
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
SMqAskEpCbParam* pParam = (SMqAskEpCbParam*)param;
|
||||
tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, pParam->refId);
|
||||
if (tmq == NULL) {
|
||||
code = TSDB_CODE_TMQ_CONSUMER_CLOSED;
|
||||
|
@ -2906,19 +2947,30 @@ int32_t askEpCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
tmqFreeRspWrapper((SMqRspWrapper*)pWrapper);
|
||||
taosFreeQitem(pWrapper);
|
||||
} else {
|
||||
(void)taosWriteQitem(tmq->mqueue, pWrapper);
|
||||
code = taosWriteQitem(tmq->mqueue, pWrapper);
|
||||
if (code != 0) {
|
||||
tmqFreeRspWrapper((SMqRspWrapper*)pWrapper);
|
||||
taosFreeQitem(pWrapper);
|
||||
tscError("consumer:0x%" PRIx64 " put ep res into mqueue failed, code:%d", tmq->consumerId, code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
END:
|
||||
(void)taosReleaseRef(tmqMgmt.rsetId, pParam->refId);
|
||||
|
||||
{
|
||||
int32_t ret = taosReleaseRef(tmqMgmt.rsetId, pParam->refId);
|
||||
if (ret != 0){
|
||||
tscError("failed to release ref:%"PRId64 ", code:%d", pParam->refId, ret);
|
||||
}
|
||||
}
|
||||
FAIL:
|
||||
if (pParam->sync) {
|
||||
if (pParam && pParam->sync) {
|
||||
SAskEpInfo* pInfo = pParam->pParam;
|
||||
if (pInfo) {
|
||||
pInfo->code = code;
|
||||
(void)tsem2_post(&pInfo->sem);
|
||||
if (tsem2_post(&pInfo->sem) != 0){
|
||||
tscError("failed to post rsp sem askep cb");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2940,11 +2992,15 @@ int32_t syncAskEp(tmq_t* pTmq) {
|
|||
|
||||
int32_t code = askEp(pTmq, pInfo, true, false);
|
||||
if (code == 0) {
|
||||
(void)tsem2_wait(&pInfo->sem);
|
||||
if (tsem2_wait(&pInfo->sem) != 0){
|
||||
tscError("consumer:0x%" PRIx64 ", failed to wait for sem", pTmq->consumerId);
|
||||
}
|
||||
code = pInfo->code;
|
||||
}
|
||||
|
||||
(void)tsem2_destroy(&pInfo->sem);
|
||||
if(tsem2_destroy(&pInfo->sem) != 0) {
|
||||
tscError("failed to destroy sem sync ask ep");
|
||||
}
|
||||
taosMemoryFree(pInfo);
|
||||
return code;
|
||||
}
|
||||
|
@ -3115,7 +3171,9 @@ static int32_t tmqGetWalInfoCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
END:
|
||||
pCommon->code = code;
|
||||
if (total == pParam->totalReq) {
|
||||
(void)tsem2_post(&pCommon->rsp);
|
||||
if (tsem2_post(&pCommon->rsp) != 0) {
|
||||
tscError("failed to post semaphore in get wal cb");
|
||||
}
|
||||
}
|
||||
|
||||
if (pMsg) {
|
||||
|
@ -3130,8 +3188,10 @@ static void destroyCommonInfo(SMqVgCommon* pCommon) {
|
|||
if (pCommon == NULL) {
|
||||
return;
|
||||
}
|
||||
(void)taosArrayDestroy(pCommon->pList);
|
||||
(void)tsem2_destroy(&pCommon->rsp);
|
||||
taosArrayDestroy(pCommon->pList);
|
||||
if(tsem2_destroy(&pCommon->rsp) != 0) {
|
||||
tscError("failed to destroy semaphore for topic:%s", pCommon->pTopicName);
|
||||
}
|
||||
(void)taosThreadMutexDestroy(&pCommon->mutex);
|
||||
taosMemoryFree(pCommon->pTopicName);
|
||||
taosMemoryFree(pCommon);
|
||||
|
@ -3167,7 +3227,9 @@ end:
|
|||
taosMemoryFree(pMsg->pEpSet);
|
||||
}
|
||||
pParam->code = code;
|
||||
(void)tsem2_post(&pParam->sem);
|
||||
if (tsem2_post(&pParam->sem) != 0){
|
||||
tscError("failed to post semaphore in tmCommittedCb");
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -3231,12 +3293,16 @@ int64_t getCommittedFromServer(tmq_t* tmq, char* tname, int32_t vgId, SEpSet* ep
|
|||
|
||||
code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, epSet, NULL, sendInfo);
|
||||
if (code != 0) {
|
||||
(void)tsem2_destroy(&pParam->sem);
|
||||
if(tsem2_destroy(&pParam->sem) != 0) {
|
||||
tscError("failed to destroy semaphore in get committed from server1");
|
||||
}
|
||||
taosMemoryFree(pParam);
|
||||
return code;
|
||||
}
|
||||
|
||||
(void)tsem2_wait(&pParam->sem);
|
||||
if (tsem2_wait(&pParam->sem) != 0){
|
||||
tscError("failed to wait semaphore in get committed from server");
|
||||
}
|
||||
code = pParam->code;
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
if (pParam->vgOffset.offset.val.type == TMQ_OFFSET__LOG) {
|
||||
|
@ -3246,7 +3312,9 @@ int64_t getCommittedFromServer(tmq_t* tmq, char* tname, int32_t vgId, SEpSet* ep
|
|||
code = TSDB_CODE_TMQ_SNAPSHOT_ERROR;
|
||||
}
|
||||
}
|
||||
(void)tsem2_destroy(&pParam->sem);
|
||||
if(tsem2_destroy(&pParam->sem) != 0) {
|
||||
tscError("failed to destroy semaphore in get committed from server2");
|
||||
}
|
||||
taosMemoryFree(pParam);
|
||||
|
||||
return code;
|
||||
|
@ -3517,7 +3585,9 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
}
|
||||
}
|
||||
|
||||
(void)tsem2_wait(&pCommon->rsp);
|
||||
if (tsem2_wait(&pCommon->rsp) != 0){
|
||||
tscError("consumer:0x%" PRIx64 " failed to wait sem in get assignment", tmq->consumerId);
|
||||
}
|
||||
code = pCommon->code;
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -3580,7 +3650,9 @@ static int32_t tmqSeekCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
}
|
||||
SMqSeekParam* pParam = param;
|
||||
pParam->code = code;
|
||||
(void)tsem2_post(&pParam->sem);
|
||||
if (tsem2_post(&pParam->sem) != 0){
|
||||
tscError("failed to post sem in tmqSeekCb");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3677,14 +3749,20 @@ int32_t tmq_offset_seek(tmq_t* tmq, const char* pTopicName, int32_t vgId, int64_
|
|||
|
||||
code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, NULL, sendInfo);
|
||||
if (code != 0) {
|
||||
(void)tsem2_destroy(&pParam->sem);
|
||||
if(tsem2_destroy(&pParam->sem) != 0) {
|
||||
tscError("consumer:0x%" PRIx64 "destroy rsp sem failed in seek offset", tmq->consumerId);
|
||||
}
|
||||
taosMemoryFree(pParam);
|
||||
return code;
|
||||
}
|
||||
|
||||
(void)tsem2_wait(&pParam->sem);
|
||||
if (tsem2_wait(&pParam->sem) != 0){
|
||||
tscError("consumer:0x%" PRIx64 "wait rsp sem failed in seek offset", tmq->consumerId);
|
||||
}
|
||||
code = pParam->code;
|
||||
(void)tsem2_destroy(&pParam->sem);
|
||||
if(tsem2_destroy(&pParam->sem) != 0) {
|
||||
tscError("consumer:0x%" PRIx64 "destroy rsp sem failed in seek offset", tmq->consumerId);
|
||||
}
|
||||
taosMemoryFree(pParam);
|
||||
|
||||
tscInfo("consumer:0x%" PRIx64 "send seek to vgId:%d, return code:%s", tmq->consumerId, vgId, tstrerror(code));
|
||||
|
|
|
@ -170,7 +170,7 @@ int32_t cos_cp_load(char const* filepath, SCheckpoint* checkpoint) {
|
|||
|
||||
cp_body = taosMemoryMalloc(size + 1);
|
||||
if (!cp_body) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
|
||||
int64_t n = taosReadFile(fd, cp_body, size);
|
||||
|
|
|
@ -124,7 +124,7 @@ int32_t colDataSetVal(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const
|
|||
|
||||
char* buf = taosMemoryRealloc(pColumnInfoData->pData, newSize);
|
||||
if (buf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pColumnInfoData->pData = buf;
|
||||
|
@ -170,7 +170,7 @@ static int32_t colDataReserve(SColumnInfoData* pColumnInfoData, size_t newSize)
|
|||
if (pColumnInfoData->varmeta.allocLen < newSize) {
|
||||
char* buf = taosMemoryRealloc(pColumnInfoData->pData, newSize);
|
||||
if (buf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pColumnInfoData->pData = buf;
|
||||
|
@ -388,7 +388,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int
|
|||
if (finalNumOfRows > (*capacity)) {
|
||||
char* p = taosMemoryRealloc(pColumnInfoData->varmeta.offset, sizeof(int32_t) * (numOfRow1 + numOfRow2));
|
||||
if (p == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
*capacity = finalNumOfRows;
|
||||
|
@ -409,7 +409,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int
|
|||
if (pColumnInfoData->varmeta.allocLen < len + oldLen) {
|
||||
char* tmp = taosMemoryRealloc(pColumnInfoData->pData, len + oldLen);
|
||||
if (tmp == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pColumnInfoData->pData = tmp;
|
||||
|
@ -425,14 +425,14 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int
|
|||
// all data may be null, when the pColumnInfoData->info.type == 0, bytes == 0;
|
||||
char* tmp = taosMemoryRealloc(pColumnInfoData->pData, finalNumOfRows * pColumnInfoData->info.bytes);
|
||||
if (tmp == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pColumnInfoData->pData = tmp;
|
||||
if (BitmapLen(numOfRow1) < BitmapLen(finalNumOfRows)) {
|
||||
char* btmp = taosMemoryRealloc(pColumnInfoData->nullbitmap, BitmapLen(finalNumOfRows));
|
||||
if (btmp == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
uint32_t extend = BitmapLen(finalNumOfRows) - BitmapLen(numOfRow1);
|
||||
memset(btmp + BitmapLen(numOfRow1), 0, extend);
|
||||
|
@ -469,7 +469,7 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p
|
|||
if (pColumnInfoData->varmeta.allocLen < newLen) {
|
||||
char* tmp = taosMemoryRealloc(pColumnInfoData->pData, newLen);
|
||||
if (tmp == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pColumnInfoData->pData = tmp;
|
||||
|
@ -545,7 +545,7 @@ int32_t colDataAssignNRows(SColumnInfoData* pDst, int32_t dstIdx, const SColumnI
|
|||
if (pDst->varmeta.allocLen < pDst->varmeta.length + allLen) {
|
||||
char* tmp = taosMemoryRealloc(pDst->pData, pDst->varmeta.length + allLen);
|
||||
if (tmp == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pDst->pData = tmp;
|
||||
|
@ -999,7 +999,7 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) {
|
|||
size_t metaSize = pBlock->info.rows * sizeof(int32_t);
|
||||
char* tmp = taosMemoryRealloc(pCol->varmeta.offset, metaSize); // preview calloc is too small
|
||||
if (tmp == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pCol->varmeta.offset = (int32_t*)tmp;
|
||||
|
@ -1017,7 +1017,7 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) {
|
|||
if (pCol->varmeta.allocLen < colLength) {
|
||||
char* tmp = taosMemoryRealloc(pCol->pData, colLength);
|
||||
if (tmp == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pCol->pData = tmp;
|
||||
|
@ -1098,7 +1098,7 @@ int32_t blockDataFromBuf1(SSDataBlock* pBlock, const char* buf, size_t capacity)
|
|||
if (pCol->varmeta.allocLen < colLength) {
|
||||
char* tmp = taosMemoryRealloc(pCol->pData, colLength);
|
||||
if (tmp == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pCol->pData = tmp;
|
||||
|
@ -1421,7 +1421,6 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) {
|
|||
|
||||
int32_t* index = createTupleIndex(rows);
|
||||
if (index == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
|
@ -1544,7 +1543,7 @@ int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo* pBlockI
|
|||
if (IS_VAR_DATA_TYPE(pColumn->info.type)) {
|
||||
char* tmp = taosMemoryRealloc(pColumn->varmeta.offset, sizeof(int32_t) * numOfRows);
|
||||
if (tmp == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pColumn->varmeta.offset = (int32_t*)tmp;
|
||||
|
@ -1553,7 +1552,7 @@ int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo* pBlockI
|
|||
// prepare for the null bitmap
|
||||
char* tmp = taosMemoryRealloc(pColumn->nullbitmap, BitmapLen(numOfRows));
|
||||
if (tmp == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
int32_t oldLen = BitmapLen(existedRows);
|
||||
|
@ -1567,7 +1566,7 @@ int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo* pBlockI
|
|||
// to MALLOC_ALIGN_BYTES
|
||||
tmp = taosMemoryMallocAlign(MALLOC_ALIGN_BYTES, numOfRows * pColumn->info.bytes);
|
||||
if (tmp == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
// memset(tmp, 0, numOfRows * pColumn->info.bytes);
|
||||
|
||||
|
@ -2517,24 +2516,25 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
|||
pDataBlock->info.id.groupId, pDataBlock->info.id.uid, pDataBlock->info.rows, pDataBlock->info.version,
|
||||
pDataBlock->info.calWin.skey, pDataBlock->info.calWin.ekey, pDataBlock->info.parTbName);
|
||||
if (len >= size - 1) {
|
||||
return code;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
for (int32_t j = 0; j < rows; j++) {
|
||||
len += snprintf(dumpBuf + len, size - len, "%s|", flag);
|
||||
if (len >= size - 1) {
|
||||
return code;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
for (int32_t k = 0; k < colNum; k++) {
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
||||
if (pColInfoData == NULL) {
|
||||
return terrno;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (colDataIsNull(pColInfoData, rows, j, NULL) || !pColInfoData->pData) {
|
||||
len += snprintf(dumpBuf + len, size - len, " %15s |", "NULL");
|
||||
if (len >= size - 1) return 0;
|
||||
if (len >= size - 1) goto _exit;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2542,53 +2542,53 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
|||
switch (pColInfoData->info.type) {
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
memset(pBuf, 0, sizeof(pBuf));
|
||||
(void) formatTimestamp(pBuf, *(uint64_t*)var, pColInfoData->info.precision);
|
||||
(void)formatTimestamp(pBuf, *(uint64_t*)var, pColInfoData->info.precision);
|
||||
len += snprintf(dumpBuf + len, size - len, " %25s |", pBuf);
|
||||
if (len >= size - 1) return 0;
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int8_t*)var);
|
||||
if (len >= size - 1) return 0;
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(uint8_t*)var);
|
||||
if (len >= size - 1) return 0;
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int16_t*)var);
|
||||
if (len >= size - 1) return 0;
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(uint16_t*)var);
|
||||
if (len >= size - 1) return 0;
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int32_t*)var);
|
||||
if (len >= size - 1) return 0;
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15u |", *(uint32_t*)var);
|
||||
if (len >= size - 1) return 0;
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15" PRId64 " |", *(int64_t*)var);
|
||||
if (len >= size - 1) return 0;
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15" PRIu64 " |", *(uint64_t*)var);
|
||||
if (len >= size - 1) return 0;
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15f |", *(float*)var);
|
||||
if (len >= size - 1) return 0;
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15f |", *(double*)var);
|
||||
if (len >= size - 1) return 0;
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(bool*)var);
|
||||
if (len >= size - 1) return 0;
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_VARCHAR:
|
||||
case TSDB_DATA_TYPE_VARBINARY:
|
||||
|
@ -2599,24 +2599,33 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
|||
dataSize = TMIN(dataSize, 50);
|
||||
memcpy(pBuf, varDataVal(pData), dataSize);
|
||||
len += snprintf(dumpBuf + len, size - len, " %15s |", pBuf);
|
||||
if (len >= size - 1) return 0;
|
||||
if (len >= size - 1) goto _exit;
|
||||
} break;
|
||||
case TSDB_DATA_TYPE_NCHAR: {
|
||||
char* pData = colDataGetVarData(pColInfoData, j);
|
||||
int32_t dataSize = TMIN(sizeof(pBuf), varDataLen(pData));
|
||||
memset(pBuf, 0, sizeof(pBuf));
|
||||
(void)taosUcs4ToMbs((TdUcs4*)varDataVal(pData), dataSize, pBuf);
|
||||
code = taosUcs4ToMbs((TdUcs4*)varDataVal(pData), dataSize, pBuf);
|
||||
if (code < 0) {
|
||||
uError("func %s failed to convert to ucs charset since %s", __func__, tstrerror(code));
|
||||
goto _exit;
|
||||
}
|
||||
len += snprintf(dumpBuf + len, size - len, " %15s |", pBuf);
|
||||
if (len >= size - 1) return 0;
|
||||
if (len >= size - 1) goto _exit;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
len += snprintf(dumpBuf + len, size - len, "%d\n", j);
|
||||
if (len >= size - 1) return code;
|
||||
if (len >= size - 1) goto _exit;
|
||||
}
|
||||
len += snprintf(dumpBuf + len, size - len, "%s |end\n", flag);
|
||||
|
||||
*pDataBuf = dumpBuf;
|
||||
dumpBuf = NULL;
|
||||
_exit:
|
||||
if (dumpBuf) {
|
||||
taosMemoryFree(dumpBuf);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -489,7 +489,7 @@ int32_t tRowBuildFromBind(SBindInfo *infos, int32_t numOfInfos, bool infoSorted,
|
|||
colVal = COL_VAL_VALUE(infos[iInfo].columnId, value);
|
||||
}
|
||||
if (taosArrayPush(colValArray, &colVal) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ int32_t tRowBuildFromBind(SBindInfo *infos, int32_t numOfInfos, bool infoSorted,
|
|||
}
|
||||
|
||||
if ((taosArrayPush(rowArray, &row)) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
|
@ -702,7 +702,7 @@ static int32_t tRowMergeImpl(SArray *aRowP, STSchema *pTSchema, int32_t iStart,
|
|||
|
||||
if (pColVal) {
|
||||
if (taosArrayPush(aColVal, pColVal) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
|
@ -1756,7 +1756,7 @@ int32_t tTagToValArray(const STag *pTag, SArray **ppArray) {
|
|||
}
|
||||
(void)tGetTagVal(p + offset, &tv, pTag->flags & TD_TAG_JSON);
|
||||
if (taosArrayPush(*ppArray, &tv) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
|
@ -3251,13 +3251,13 @@ int32_t tRowBuildFromBind2(SBindInfo2 *infos, int32_t numOfInfos, bool infoSorte
|
|||
}
|
||||
if ((bufArray = taosArrayInit(numOfInfos, sizeof(uint8_t *))) == NULL) {
|
||||
taosArrayDestroy(colValArray);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
for (int i = 0; i < numOfInfos; ++i) {
|
||||
if (!taosArrayPush(bufArray, &infos[i].bind->buffer)) {
|
||||
taosArrayDestroy(colValArray);
|
||||
taosArrayDestroy(bufArray);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3294,7 +3294,7 @@ int32_t tRowBuildFromBind2(SBindInfo2 *infos, int32_t numOfInfos, bool infoSorte
|
|||
colVal = COL_VAL_VALUE(infos[iInfo].columnId, value);
|
||||
}
|
||||
if (taosArrayPush(colValArray, &colVal) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
|
@ -3305,7 +3305,7 @@ int32_t tRowBuildFromBind2(SBindInfo2 *infos, int32_t numOfInfos, bool infoSorte
|
|||
}
|
||||
|
||||
if ((taosArrayPush(rowArray, &row)) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
|
@ -3502,7 +3502,7 @@ static int32_t tColDataMerge(SArray **colArr) {
|
|||
|
||||
dst = taosArrayInit(taosArrayGetSize(src), sizeof(SColData));
|
||||
if (dst == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < taosArrayGetSize(src); i++) {
|
||||
|
|
|
@ -81,6 +81,7 @@ int32_t tsElectInterval = 25 * 1000;
|
|||
int32_t tsHeartbeatInterval = 1000;
|
||||
int32_t tsHeartbeatTimeout = 20 * 1000;
|
||||
int32_t tsSnapReplMaxWaitN = 128;
|
||||
int64_t tsLogBufferMemoryAllowed = 0; // bytes
|
||||
|
||||
// mnode
|
||||
int64_t tsMndSdbWriteDelta = 200;
|
||||
|
@ -613,7 +614,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
|
|||
cfgAddInt32(pCfg, "timeToGetAvailableConn", tsTimeToGetAvailableConn, 20, 1000000, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
||||
|
||||
tsKeepAliveIdle = TRANGE(tsKeepAliveIdle, 1, 72000);
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "keepAliveIdle", tsKeepAliveIdle, 1, 7200000, CFG_SCOPE_BOTH, CFG_DYN_ENT_BOTH));
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "keepAliveIdle", tsKeepAliveIdle, 1, 7200000, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
||||
|
||||
tsNumOfTaskQueueThreads = tsNumOfCores * 2;
|
||||
tsNumOfTaskQueueThreads = TMAX(tsNumOfTaskQueueThreads, 16);
|
||||
|
@ -702,6 +703,9 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
tsQueueMemoryAllowed = tsTotalMemoryKB * 1024 * 0.1;
|
||||
tsQueueMemoryAllowed = TRANGE(tsQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10LL, TSDB_MAX_MSG_SIZE * 10000LL);
|
||||
|
||||
tsLogBufferMemoryAllowed = tsTotalMemoryKB * 1024 * 0.1;
|
||||
tsLogBufferMemoryAllowed = TRANGE(tsLogBufferMemoryAllowed, TSDB_MAX_MSG_SIZE * 10LL, TSDB_MAX_MSG_SIZE * 10000LL);
|
||||
|
||||
// clang-format off
|
||||
TAOS_CHECK_RETURN(cfgAddDir(pCfg, "dataDir", tsDataDir, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
TAOS_CHECK_RETURN(cfgAddFloat(pCfg, "minimalDataDirGB", 2.0f, 0.001f, 10000000, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
|
@ -736,6 +740,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "syncHeartbeatInterval", tsHeartbeatInterval, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "syncHeartbeatTimeout", tsHeartbeatTimeout, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "syncSnapReplMaxWaitN", tsSnapReplMaxWaitN, 16, (TSDB_SYNC_SNAP_BUFFER_SIZE >> 2), CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "syncLogBufferMemoryAllowed", tsLogBufferMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, INT64_MAX, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER));
|
||||
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "arbHeartBeatIntervalSec", tsArbHeartBeatIntervalSec, 1, 60 * 24 * 2, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "arbCheckSyncIntervalSec", tsArbCheckSyncIntervalSec, 1, 60 * 24 * 2, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
|
@ -970,6 +975,14 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) {
|
|||
pItem->stype = stype;
|
||||
}
|
||||
|
||||
pItem = cfgGetItem(tsCfg, "syncLogBufferMemoryAllowed");
|
||||
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
|
||||
tsLogBufferMemoryAllowed = totalMemoryKB * 1024 * 0.1;
|
||||
tsLogBufferMemoryAllowed = TRANGE(tsLogBufferMemoryAllowed, TSDB_MAX_MSG_SIZE * 10LL, TSDB_MAX_MSG_SIZE * 10000LL);
|
||||
pItem->i64 = tsLogBufferMemoryAllowed;
|
||||
pItem->stype = stype;
|
||||
}
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -1520,6 +1533,9 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "syncSnapReplMaxWaitN");
|
||||
tsSnapReplMaxWaitN = pItem->i32;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "syncLogBufferMemoryAllowed");
|
||||
tsLogBufferMemoryAllowed = pItem->i64;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "arbHeartBeatIntervalSec");
|
||||
tsArbHeartBeatIntervalSec = pItem->i32;
|
||||
|
||||
|
@ -1696,7 +1712,10 @@ int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd, const char *
|
|||
SArray *pArgs) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
if (tsCfg == NULL) osDefaultInit();
|
||||
if (tsCfg == NULL) code = osDefaultInit();
|
||||
if (code != 0) {
|
||||
(void)printf("failed to init os since %s\n", tstrerror(code));
|
||||
}
|
||||
|
||||
SConfig *pCfg = NULL;
|
||||
TAOS_CHECK_RETURN(cfgInit(&pCfg));
|
||||
|
@ -1954,6 +1973,7 @@ static int32_t taosCfgDynamicOptionsForServer(SConfig *pCfg, const char *name) {
|
|||
{"randErrorChance", &tsRandErrChance},
|
||||
{"randErrorDivisor", &tsRandErrDivisor},
|
||||
{"randErrorScope", &tsRandErrScope},
|
||||
{"syncLogBufferMemoryAllowed", &tsLogBufferMemoryAllowed},
|
||||
|
||||
{"cacheLazyLoadThreshold", &tsCacheLazyLoadThreshold},
|
||||
{"checkpointInterval", &tsStreamCheckpointInterval},
|
||||
|
|
|
@ -179,7 +179,7 @@ int32_t epsetToStr(const SEpSet* pEpSet, char* pBuf, int32_t cap) {
|
|||
int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t startTime) {
|
||||
int32_t code = 0;
|
||||
SJson* pJson = tjsonCreateObject();
|
||||
if (pJson == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (pJson == NULL) return terrno;
|
||||
|
||||
char tmp[4096] = {0};
|
||||
|
||||
|
@ -241,7 +241,7 @@ int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t
|
|||
|
||||
char* pCont = tjsonToString(pJson);
|
||||
if (pCont == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
TAOS_CHECK_GOTO(code, NULL, _exit);
|
||||
goto _exit;
|
||||
}
|
||||
|
|
|
@ -10346,7 +10346,11 @@ int32_t tDecodeSMCreateStbRsp(SDecoder *pDecoder, SMCreateStbRsp *pRsp) {
|
|||
}
|
||||
tEndDecode(pDecoder);
|
||||
|
||||
return code;
|
||||
|
||||
_exit:
|
||||
tFreeSTableMetaRsp(pRsp->pMeta);
|
||||
taosMemoryFreeClear(pRsp->pMeta);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -12026,19 +12030,19 @@ int32_t tCloneTbTSMAInfo(STableTSMAInfo *pInfo, STableTSMAInfo **pRes) {
|
|||
*pRet = *pInfo;
|
||||
if (pInfo->pFuncs) {
|
||||
pRet->pFuncs = taosArrayDup(pInfo->pFuncs, NULL);
|
||||
if (!pRet->pFuncs) code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (!pRet->pFuncs) code = terrno;
|
||||
}
|
||||
if (pInfo->pTags && code == TSDB_CODE_SUCCESS) {
|
||||
pRet->pTags = taosArrayDup(pInfo->pTags, NULL);
|
||||
if (!pRet->pTags) code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (!pRet->pTags) code = terrno;
|
||||
}
|
||||
if (pInfo->pUsedCols && code == TSDB_CODE_SUCCESS) {
|
||||
pRet->pUsedCols = taosArrayDup(pInfo->pUsedCols, NULL);
|
||||
if (!pRet->pUsedCols) code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (!pRet->pUsedCols) code = terrno;
|
||||
}
|
||||
if (pInfo->ast && code == TSDB_CODE_SUCCESS) {
|
||||
pRet->ast = taosStrdup(pInfo->ast);
|
||||
if (!pRet->ast) code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (!pRet->ast) code = terrno;
|
||||
}
|
||||
if (code) {
|
||||
tFreeAndClearTableTSMAInfo(pRet);
|
||||
|
|
|
@ -88,6 +88,9 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
|
|||
#endif
|
||||
|
||||
void toName(int32_t acctId, const char* pDbName, const char* pTableName, SName* pName) {
|
||||
if (pName == NULL){
|
||||
return;
|
||||
}
|
||||
pName->type = TSDB_TABLE_NAME_T;
|
||||
pName->acctId = acctId;
|
||||
snprintf(pName->dbname, sizeof(pName->dbname), "%s", pDbName);
|
||||
|
@ -152,7 +155,11 @@ int32_t tNameGetDbName(const SName* name, char* dst) {
|
|||
const char* tNameGetDbNameP(const SName* name) { return &name->dbname[0]; }
|
||||
|
||||
int32_t tNameGetFullDbName(const SName* name, char* dst) {
|
||||
return snprintf(dst, TSDB_DB_FNAME_LEN, "%d.%s", name->acctId, name->dbname);
|
||||
if (name == NULL || dst == NULL) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
(void)snprintf(dst, TSDB_DB_FNAME_LEN, "%d.%s", name->acctId, name->dbname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool tNameIsEmpty(const SName* name) { return name->type == 0 || name->acctId == 0; }
|
||||
|
|
|
@ -482,7 +482,7 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow, int8_t r
|
|||
if (isAlloc) {
|
||||
taosMemoryFreeClear(*ppRow);
|
||||
}
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
TAOS_RETURN(terrno);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1247,7 +1247,7 @@ static int32_t parseTsFormat(const char* formatStr, SArray* formats) {
|
|||
const TSFormatKeyWord* key = keywordSearch(formatStr);
|
||||
if (key) {
|
||||
TSFormatNode format = {.key = key, .type = TS_FORMAT_NODE_TYPE_KEYWORD};
|
||||
if (NULL == taosArrayPush(formats, &format)) TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
if (NULL == taosArrayPush(formats, &format)) TAOS_RETURN(terrno);
|
||||
formatStr += key->len;
|
||||
lastOtherFormat = NULL;
|
||||
} else {
|
||||
|
@ -1274,7 +1274,7 @@ static int32_t parseTsFormat(const char* formatStr, SArray* formats) {
|
|||
TSFormatNode format = {.type = TS_FORMAT_NODE_TYPE_CHAR, .key = NULL};
|
||||
format.c = formatStr;
|
||||
format.len = 1;
|
||||
if (NULL == taosArrayPush(formats, &format)) TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
if (NULL == taosArrayPush(formats, &format)) TAOS_RETURN(terrno);
|
||||
formatStr++;
|
||||
last = taosArrayGetLast(formats);
|
||||
}
|
||||
|
@ -1301,7 +1301,7 @@ static int32_t parseTsFormat(const char* formatStr, SArray* formats) {
|
|||
.key = NULL};
|
||||
format.c = formatStr;
|
||||
format.len = 1;
|
||||
if (NULL == taosArrayPush(formats, &format)) TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
if (NULL == taosArrayPush(formats, &format)) TAOS_RETURN(terrno);
|
||||
formatStr++;
|
||||
if (format.type == TS_FORMAT_NODE_TYPE_CHAR) lastOtherFormat = taosArrayGetLast(formats);
|
||||
}
|
||||
|
@ -1910,7 +1910,7 @@ int32_t taosTs2Char(const char* format, SArray** formats, int64_t ts, int32_t pr
|
|||
if (!*formats) {
|
||||
*formats = taosArrayInit(8, sizeof(TSFormatNode));
|
||||
if (!*formats) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
TAOS_RETURN(terrno);
|
||||
}
|
||||
TAOS_CHECK_RETURN(parseTsFormat(format, *formats));
|
||||
}
|
||||
|
@ -1926,7 +1926,7 @@ int32_t taosChar2Ts(const char* format, SArray** formats, const char* tsStr, int
|
|||
if (!*formats) {
|
||||
*formats = taosArrayInit(4, sizeof(TSFormatNode));
|
||||
if (!*formats) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
TAOS_RETURN(terrno);
|
||||
}
|
||||
TAOS_CHECK_RETURN(parseTsFormat(format, *formats));
|
||||
}
|
||||
|
@ -1951,7 +1951,7 @@ int32_t TEST_ts2char(const char* format, int64_t ts, int32_t precision, char* ou
|
|||
|
||||
SArray* formats = taosArrayInit(4, sizeof(TSFormatNode));
|
||||
if (!formats) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
TAOS_RETURN(terrno);
|
||||
}
|
||||
TAOS_CHECK_RETURN(parseTsFormat(format, formats));
|
||||
struct STm tm;
|
||||
|
|
|
@ -345,7 +345,7 @@ int32_t dmProcessServerRunStatus(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
|
||||
void *pRsp = rpcMallocCont(rspLen);
|
||||
if (pRsp == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
// rspMsg.code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
// return rspMsg.code;
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ int32_t dmBuildVariablesBlock(SSDataBlock **ppBlock) {
|
|||
|
||||
pBlock->pDataBlock = taosArrayInit(pMeta[index].colNum, sizeof(SColumnInfoData));
|
||||
if (pBlock->pDataBlock == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
|
@ -393,7 +393,7 @@ int32_t dmBuildVariablesBlock(SSDataBlock **ppBlock) {
|
|||
colInfoData.info.type = pMeta[index].schema[i].type;
|
||||
colInfoData.info.bytes = pMeta[index].schema[i].bytes;
|
||||
if (taosArrayPush(pBlock->pDataBlock, &colInfoData) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
|
@ -457,7 +457,7 @@ int32_t dmProcessRetrieve(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
|
||||
SRetrieveMetaTableRsp *pRsp = rpcMallocCont(size);
|
||||
if (pRsp == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
dError("failed to retrieve data since %s", tstrerror(code));
|
||||
blockDataDestroy(pBlock);
|
||||
return code;
|
||||
|
|
|
@ -54,7 +54,7 @@ static int32_t dmOpenMgmt(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
|||
int32_t code = 0;
|
||||
SDnodeMgmt *pMgmt = taosMemoryCalloc(1, sizeof(SDnodeMgmt));
|
||||
if (pMgmt == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pMgmt->pData = pInput->pData;
|
||||
|
|
|
@ -91,7 +91,7 @@ int32_t mmReadFile(const char *path, SMnodeOpt *pOption) {
|
|||
|
||||
pData = taosMemoryMalloc(size + 1);
|
||||
if (pData == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -134,14 +134,14 @@ static int32_t mmEncodeOption(SJson *pJson, const SMnodeOpt *pOption) {
|
|||
|
||||
SJson *replicas = tjsonCreateArray();
|
||||
if (replicas == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
if ((code = tjsonAddItemToObject(pJson, "replicas", replicas)) < 0) return code;
|
||||
|
||||
for (int32_t i = 0; i < pOption->numOfTotalReplicas; ++i) {
|
||||
SJson *replica = tjsonCreateObject();
|
||||
if (replica == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
const SReplica *pReplica = pOption->replicas + i;
|
||||
|
@ -183,7 +183,7 @@ int32_t mmWriteFile(const char *path, const SMnodeOpt *pOption) {
|
|||
// terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
pJson = tjsonCreateObject();
|
||||
if (pJson == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,14 +71,14 @@ int32_t smStartWorker(SSnodeMgmt *pMgmt) {
|
|||
int32_t code = 0;
|
||||
pMgmt->writeWroker = taosArrayInit(0, sizeof(SMultiWorker *));
|
||||
if (pMgmt->writeWroker == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
return code;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < tsNumOfSnodeWriteThreads; i++) {
|
||||
SMultiWorker *pWriteWorker = taosMemoryMalloc(sizeof(SMultiWorker));
|
||||
if (pWriteWorker == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ int32_t smStartWorker(SSnodeMgmt *pMgmt) {
|
|||
return code;
|
||||
}
|
||||
if (taosArrayPush(pMgmt->writeWroker, &pWriteWorker) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t
|
|||
|
||||
pData = taosMemoryMalloc(size + 1);
|
||||
if (pData == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ static int32_t vmEncodeVnodeList(SJson *pJson, SVnodeObj **ppVnodes, int32_t num
|
|||
int32_t code = 0;
|
||||
SJson *vnodes = tjsonCreateArray();
|
||||
if (vnodes == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
if ((code = tjsonAddItemToObject(pJson, "vnodes", vnodes)) < 0) {
|
||||
tjsonDelete(vnodes);
|
||||
|
@ -181,7 +181,7 @@ static int32_t vmEncodeVnodeList(SJson *pJson, SVnodeObj **ppVnodes, int32_t num
|
|||
if (pVnode == NULL) continue;
|
||||
|
||||
SJson *vnode = tjsonCreateObject();
|
||||
if (vnode == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (vnode == NULL) return terrno;
|
||||
if ((code = tjsonAddDoubleToObject(vnode, "vgId", pVnode->vgId)) < 0) return code;
|
||||
if ((code = tjsonAddDoubleToObject(vnode, "dropped", pVnode->dropped)) < 0) return code;
|
||||
if ((code = tjsonAddDoubleToObject(vnode, "vgVersion", pVnode->vgVersion)) < 0) return code;
|
||||
|
@ -221,7 +221,7 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
|||
// terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
pJson = tjsonCreateObject();
|
||||
if (pJson == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
if ((code = vmEncodeVnodeList(pJson, ppVnodes, numOfVnodes)) != 0) goto _OVER;
|
||||
|
|
|
@ -921,7 +921,7 @@ int32_t vmProcessArbHeartBeatReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
|
||||
void *pRsp = rpcMallocCont(rspLen);
|
||||
if (pRsp == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
terrno = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
|
|
@ -161,8 +161,7 @@ int32_t dmInitVars(SDnode *pDnode) {
|
|||
pData->dnodeHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||
if (pData->dnodeHash == NULL) {
|
||||
dError("failed to init dnode hash");
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno = code;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if ((code = dmReadEps(pData)) != 0) {
|
||||
|
|
|
@ -217,7 +217,7 @@ int32_t dmReadEps(SDnodeData *pData) {
|
|||
|
||||
content = taosMemoryMalloc(size + 1);
|
||||
if (content == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -321,7 +321,7 @@ int32_t dmWriteEps(SDnodeData *pData) {
|
|||
TAOS_CHECK_GOTO(dmInitDndInfo(pData), NULL, _OVER);
|
||||
|
||||
pJson = tjsonCreateObject();
|
||||
if (pJson == NULL) TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _OVER);
|
||||
if (pJson == NULL) TAOS_CHECK_GOTO(terrno, NULL, _OVER);
|
||||
|
||||
pData->engineVer = tsVersion;
|
||||
|
||||
|
@ -329,7 +329,7 @@ int32_t dmWriteEps(SDnodeData *pData) {
|
|||
|
||||
buffer = tjsonToString(pJson);
|
||||
if (buffer == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _OVER);
|
||||
TAOS_CHECK_GOTO(terrno, NULL, _OVER);
|
||||
}
|
||||
|
||||
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||
|
@ -574,7 +574,7 @@ static int32_t dmDecodeEpPairs(SJson *pJson, SDnodeData *pData) {
|
|||
tjsonGetUInt16ValueFromDouble(dnode, "new_port", pair.newPort, code);
|
||||
if (code < 0) return TSDB_CODE_INVALID_CFG_VALUE;
|
||||
|
||||
if (taosArrayPush(pData->oldDnodeEps, &pair) == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (taosArrayPush(pData->oldDnodeEps, &pair) == NULL) return terrno;
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -620,7 +620,7 @@ static int32_t dmReadDnodePairs(SDnodeData *pData) {
|
|||
|
||||
content = taosMemoryMalloc(size + 1);
|
||||
if (content == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -640,7 +640,7 @@ static int32_t dmReadDnodePairs(SDnodeData *pData) {
|
|||
|
||||
pData->oldDnodeEps = taosArrayInit(1, sizeof(SDnodeEpPair));
|
||||
if (pData->oldDnodeEps == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
dError("failed to calloc dnodeEp array since %s", strerror(errno));
|
||||
goto _OVER;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ int32_t dmReadFile(const char *path, const char *name, bool *pDeployed) {
|
|||
|
||||
content = taosMemoryMalloc(size + 1);
|
||||
if (content == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ int32_t dmWriteFile(const char *path, const char *name, bool deployed) {
|
|||
|
||||
pJson = tjsonCreateObject();
|
||||
if (pJson == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ static int32_t dmWriteCheckCodeFile(char *file, char *realfile, char *key, bool
|
|||
int32_t len = ENCRYPTED_LEN(sizeof(DM_KEY_INDICATOR));
|
||||
result = taosMemoryMalloc(len);
|
||||
if (result == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
SCryptOpts opts;
|
||||
|
@ -469,7 +469,7 @@ static int32_t dmReadEncryptCodeFile(char *file, char **output) {
|
|||
|
||||
content = taosMemoryMalloc(size + 1);
|
||||
if (content == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,19 @@ extern "C" {
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define RETRIEVE_CHECK_GOTO(CMD, pObj, LINO, LABEL) \
|
||||
do { \
|
||||
code = (CMD); \
|
||||
if (code != TSDB_CODE_SUCCESS) { \
|
||||
if (LINO) { \
|
||||
*((int32_t *)(LINO)) = __LINE__; \
|
||||
} \
|
||||
if (pObj) sdbRelease(pSdb, (pObj)); \
|
||||
if (pObj) sdbCancelFetch(pSdb, (pObj)); \
|
||||
goto LABEL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
int32_t mndInitShow(SMnode *pMnode);
|
||||
void mndCleanupShow(SMnode *pMnode);
|
||||
void mndAddShowRetrieveHandle(SMnode *pMnode, EShowType showType, ShowRetrieveFp fp);
|
||||
|
|
|
@ -37,9 +37,9 @@ int32_t mndAddStbToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *p
|
|||
void mndFreeStb(SStbObj *pStb);
|
||||
int32_t mndBuildSMCreateStbRsp(SMnode *pMnode, char *dbFName, char *stbFName, void **pCont, int32_t *pLen);
|
||||
|
||||
void mndExtractDbNameFromStbFullName(const char *stbFullName, char *dst);
|
||||
void mndExtractShortDbNameFromStbFullName(const char *stbFullName, char *dst);
|
||||
void mndExtractShortDbNameFromDbFullName(const char *stbFullName, char *dst);
|
||||
int32_t mndExtractDbNameFromStbFullName(const char *stbFullName, char *dst);
|
||||
int32_t mndExtractShortDbNameFromStbFullName(const char *stbFullName, char *dst);
|
||||
int32_t mndExtractShortDbNameFromDbFullName(const char *stbFullName, char *dst);
|
||||
void mndExtractTbNameFromStbFullName(const char *stbFullName, char *dst, int32_t dstSize);
|
||||
|
||||
const char *mndGetStbStr(const char *src);
|
||||
|
|
|
@ -268,7 +268,11 @@ int32_t mndAddCompactToTran(SMnode *pMnode, STrans *pTrans, SCompactObj *pCompac
|
|||
sdbFreeRaw(pVgRaw);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
|
||||
|
||||
if ((code = sdbSetRawStatus(pVgRaw, SDB_STATUS_READY)) != 0) {
|
||||
sdbFreeRaw(pVgRaw);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
rsp->compactId = pCompact->compactId;
|
||||
|
||||
|
@ -357,7 +361,10 @@ static void *mndBuildKillCompactReq(SMnode *pMnode, SVgObj *pVgroup, int32_t *pC
|
|||
pHead->contLen = htonl(contLen);
|
||||
pHead->vgId = htonl(pVgroup->vgId);
|
||||
|
||||
(void)tSerializeSVKillCompactReq((char *)pReq + sizeof(SMsgHead), contLen, &req);
|
||||
if ((contLen = tSerializeSVKillCompactReq((char *)pReq + sizeof(SMsgHead), contLen, &req)) < 0) {
|
||||
terrno = contLen;
|
||||
return NULL;
|
||||
}
|
||||
*pContLen = contLen;
|
||||
return pReq;
|
||||
}
|
||||
|
@ -421,7 +428,10 @@ static int32_t mndKillCompact(SMnode *pMnode, SRpcMsg *pReq, SCompactObj *pCompa
|
|||
mndTransDrop(pTrans);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
if ((code = sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY)) != 0) {
|
||||
mndTransDrop(pTrans);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
void *pIter = NULL;
|
||||
while (1) {
|
||||
|
@ -614,7 +624,10 @@ void mndCompactSendProgressReq(SMnode *pMnode, SCompactObj *pCompact) {
|
|||
pHead->contLen = htonl(contLen);
|
||||
pHead->vgId = htonl(pDetail->vgId);
|
||||
|
||||
(void)tSerializeSQueryCompactProgressReq((char *)pHead + sizeof(SMsgHead), contLen - sizeof(SMsgHead), &req);
|
||||
if (tSerializeSQueryCompactProgressReq((char *)pHead + sizeof(SMsgHead), contLen - sizeof(SMsgHead), &req) <= 0) {
|
||||
sdbRelease(pMnode->pSdb, pDetail);
|
||||
continue;
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_VND_QUERY_COMPACT_PROGRESS, .contLen = contLen};
|
||||
|
||||
|
@ -719,7 +732,12 @@ static int32_t mndSaveCompactProgress(SMnode *pMnode, int32_t compactId) {
|
|||
mndTransDrop(pTrans);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
if ((code = sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY)) != 0) {
|
||||
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||
sdbRelease(pMnode->pSdb, pDetail);
|
||||
mndTransDrop(pTrans);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
}
|
||||
|
||||
sdbRelease(pMnode->pSdb, pDetail);
|
||||
|
@ -782,7 +800,12 @@ static int32_t mndSaveCompactProgress(SMnode *pMnode, int32_t compactId) {
|
|||
mndTransDrop(pTrans);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED);
|
||||
if ((code = sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED)) != 0) {
|
||||
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||
sdbRelease(pMnode->pSdb, pDetail);
|
||||
mndTransDrop(pTrans);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
mInfo("compact:%d, add drop compactdetail action", pDetail->compactDetailId);
|
||||
}
|
||||
|
||||
|
@ -809,7 +832,11 @@ static int32_t mndSaveCompactProgress(SMnode *pMnode, int32_t compactId) {
|
|||
mndTransDrop(pTrans);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED);
|
||||
if ((code = sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED)) != 0) {
|
||||
mError("compact:%d, trans:%d, failed to append commit log since %s", compactId, pTrans->id, terrstr());
|
||||
mndTransDrop(pTrans);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
mInfo("compact:%d, add drop compact action", pCompact->compactId);
|
||||
}
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ static void storeOffsetRows(SMnode *pMnode, SMqHbReq *req, SMqConsumerObj *pCons
|
|||
taosWLockLatch(&pSub->lock);
|
||||
SMqConsumerEp *pConsumerEp = taosHashGet(pSub->consumerHash, &pConsumer->consumerId, sizeof(int64_t));
|
||||
if (pConsumerEp) {
|
||||
(void)taosArrayDestroy(pConsumerEp->offsetRows);
|
||||
taosArrayDestroy(pConsumerEp->offsetRows);
|
||||
pConsumerEp->offsetRows = data->offsetRows;
|
||||
data->offsetRows = NULL;
|
||||
}
|
||||
|
@ -511,6 +511,11 @@ static int32_t getTopicAddDelete(SMqConsumerObj *pExistedConsumer, SMqConsumerOb
|
|||
}
|
||||
}
|
||||
}
|
||||
// no topics need to be rebalanced
|
||||
if (taosArrayGetSize(pConsumerNew->rebNewTopics) == 0 && taosArrayGetSize(pConsumerNew->rebRemovedTopics) == 0) {
|
||||
code = TSDB_CODE_TMQ_NO_NEED_REBALANCE;
|
||||
}
|
||||
|
||||
END:
|
||||
return code;
|
||||
}
|
||||
|
@ -581,6 +586,10 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
|||
if(ubSubscribe){
|
||||
SMqConsumerObj *pConsumerTmp = NULL;
|
||||
MND_TMQ_RETURN_CHECK(mndAcquireConsumer(pMnode, subscribe.consumerId, &pConsumerTmp));
|
||||
if (taosArrayGetSize(pConsumerTmp->assignedTopics) == 0){
|
||||
mndReleaseConsumer(pMnode, pConsumerTmp);
|
||||
goto END;
|
||||
}
|
||||
mndReleaseConsumer(pMnode, pConsumerTmp);
|
||||
}
|
||||
MND_TMQ_RETURN_CHECK(checkAndSortTopic(pMnode, subscribe.topicNames));
|
||||
|
@ -599,7 +608,7 @@ END:
|
|||
mndTransDrop(pTrans);
|
||||
tDeleteSMqConsumerObj(pConsumerNew);
|
||||
taosArrayDestroyP(subscribe.topicNames, (FDelete)taosMemoryFree);
|
||||
return code;
|
||||
return (code == TSDB_CODE_TMQ_NO_NEED_REBALANCE || code == TSDB_CODE_MND_CONSUMER_NOT_EXIST) ? 0 : code;
|
||||
}
|
||||
|
||||
SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer) {
|
||||
|
|
|
@ -182,7 +182,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
|
|||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pRaw), NULL, _OVER);
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
TAOS_CHECK_GOTO(sdbSetRawStatus(pRaw, SDB_STATUS_READY), NULL, _OVER);
|
||||
pRaw = NULL;
|
||||
|
||||
TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER);
|
||||
|
@ -621,7 +621,10 @@ static int32_t mndUpdateDnodeObj(SMnode *pMnode, SDnodeObj *pDnode) {
|
|||
TAOS_RETURN(terrno);
|
||||
}
|
||||
|
||||
(void)tSerializeSDnodeInfoReq(pReq, contLen, &infoReq);
|
||||
if ((contLen = tSerializeSDnodeInfoReq(pReq, contLen, &infoReq)) <= 0) {
|
||||
code = contLen;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_UPDATE_DNODE_INFO, .pCont = pReq, .contLen = contLen};
|
||||
TAOS_CHECK_EXIT(tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg));
|
||||
|
@ -661,7 +664,7 @@ static int32_t mndProcessUpdateDnodeInfoReq(SRpcMsg *pReq) {
|
|||
mError("trans:%d, failed to append commit log since %s", pTrans->id, tstrerror(code));
|
||||
TAOS_CHECK_EXIT(code);
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
TAOS_CHECK_EXIT(sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY));
|
||||
pCommitRaw = NULL;
|
||||
|
||||
if ((code = mndTransPrepare(pMnode, pTrans)) != 0) {
|
||||
|
@ -874,8 +877,12 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
|
||||
int32_t contLen = tSerializeSStatusRsp(NULL, 0, &statusRsp);
|
||||
void *pHead = rpcMallocCont(contLen);
|
||||
(void)tSerializeSStatusRsp(pHead, contLen, &statusRsp);
|
||||
contLen = tSerializeSStatusRsp(pHead, contLen, &statusRsp);
|
||||
taosArrayDestroy(statusRsp.pDnodeEps);
|
||||
if (contLen < 0) {
|
||||
code = contLen;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
pReq->info.rspLen = contLen;
|
||||
pReq->info.rsp = pHead;
|
||||
|
@ -888,8 +895,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
_OVER:
|
||||
mndReleaseDnode(pMnode, pDnode);
|
||||
taosArrayDestroy(statusReq.pVloads);
|
||||
(void)mndUpdClusterInfo(pReq);
|
||||
return code;
|
||||
return mndUpdClusterInfo(pReq);
|
||||
}
|
||||
|
||||
static int32_t mndProcessNotifyReq(SRpcMsg *pReq) {
|
||||
|
@ -955,7 +961,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC
|
|||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pRaw), NULL, _OVER);
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
TAOS_CHECK_GOTO(sdbSetRawStatus(pRaw, SDB_STATUS_READY), NULL, _OVER);
|
||||
pRaw = NULL;
|
||||
|
||||
TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER);
|
||||
|
@ -1010,7 +1016,10 @@ static int32_t mndProcessDnodeListReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
(void)tSerializeSDnodeListRsp(pRsp, rspLen, &rsp);
|
||||
if ((rspLen = tSerializeSDnodeListRsp(pRsp, rspLen, &rsp)) <= 0) {
|
||||
code = rspLen;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
pReq->info.rspLen = rspLen;
|
||||
pReq->info.rsp = pRsp;
|
||||
|
@ -1151,7 +1160,10 @@ static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
(void)tSerializeSShowVariablesRsp(pRsp, rspLen, &rsp);
|
||||
if ((rspLen = tSerializeSShowVariablesRsp(pRsp, rspLen, &rsp)) <= 0) {
|
||||
code = rspLen;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
pReq->info.rspLen = rspLen;
|
||||
pReq->info.rsp = pRsp;
|
||||
|
@ -1247,7 +1259,7 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
|
|||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendRedolog(pTrans, pRaw), NULL, _OVER);
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_DROPPING);
|
||||
TAOS_CHECK_GOTO(sdbSetRawStatus(pRaw, SDB_STATUS_DROPPING), NULL, _OVER);
|
||||
pRaw = NULL;
|
||||
|
||||
pRaw = mndDnodeActionEncode(pDnode);
|
||||
|
@ -1257,7 +1269,7 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
|
|||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pRaw), NULL, _OVER);
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED);
|
||||
TAOS_CHECK_GOTO(sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED), NULL, _OVER);
|
||||
pRaw = NULL;
|
||||
|
||||
if (pMObj != NULL) {
|
||||
|
@ -1450,7 +1462,10 @@ static int32_t mndSendCfgDnodeReq(SMnode *pMnode, int32_t dnodeId, SDCfgDnodeReq
|
|||
void *pBuf = rpcMallocCont(bufLen);
|
||||
|
||||
if (pBuf != NULL) {
|
||||
(void)tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq);
|
||||
if ((bufLen = tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq)) <= 0) {
|
||||
code = bufLen;
|
||||
return code;
|
||||
}
|
||||
mInfo("dnode:%d, send config req to dnode, config:%s value:%s", dnodeId, pDcfgReq->config, pDcfgReq->value);
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_DND_CONFIG_DNODE, .pCont = pBuf, .contLen = bufLen};
|
||||
code = tmsgSendReq(&epSet, &rpcMsg);
|
||||
|
@ -1590,7 +1605,11 @@ static int32_t mndProcessCreateEncryptKeyReqImpl(SRpcMsg *pReq, int32_t dnodeId,
|
|||
void *pBuf = rpcMallocCont(bufLen);
|
||||
|
||||
if (pBuf != NULL) {
|
||||
(void)tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq);
|
||||
if ((bufLen = tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq)) <= 0) {
|
||||
code = bufLen;
|
||||
sdbRelease(pSdb, pDnode);
|
||||
goto _exit;
|
||||
}
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_DND_CREATE_ENCRYPT_KEY, .pCont = pBuf, .contLen = bufLen};
|
||||
if (0 == tmsgSendReq(&epSet, &rpcMsg)) {
|
||||
(void)atomic_add_fetch_16(&pMnode->encryptMgmt.nEncrypt, 1);
|
||||
|
|
|
@ -375,7 +375,7 @@ static int32_t mndDropFunc(SMnode *pMnode, SRpcMsg *pReq, SFuncObj *pFunc) {
|
|||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendRedolog(pTrans, pRedoRaw), NULL, _OVER);
|
||||
(void)sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING);
|
||||
TAOS_CHECK_GOTO(sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING), NULL, _OVER);
|
||||
|
||||
SSdbRaw *pUndoRaw = mndFuncActionEncode(pFunc);
|
||||
if (pUndoRaw == NULL) {
|
||||
|
@ -384,7 +384,7 @@ static int32_t mndDropFunc(SMnode *pMnode, SRpcMsg *pReq, SFuncObj *pFunc) {
|
|||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendUndolog(pTrans, pUndoRaw), NULL, _OVER);
|
||||
(void)sdbSetRawStatus(pUndoRaw, SDB_STATUS_READY);
|
||||
TAOS_CHECK_GOTO(sdbSetRawStatus(pUndoRaw, SDB_STATUS_READY), NULL, _OVER);
|
||||
|
||||
SSdbRaw *pCommitRaw = mndFuncActionEncode(pFunc);
|
||||
if (pCommitRaw == NULL) {
|
||||
|
@ -393,7 +393,7 @@ static int32_t mndDropFunc(SMnode *pMnode, SRpcMsg *pReq, SFuncObj *pFunc) {
|
|||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pCommitRaw), NULL, _OVER);
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED);
|
||||
TAOS_CHECK_GOTO(sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED), NULL, _OVER);
|
||||
|
||||
TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER);
|
||||
|
||||
|
@ -598,7 +598,10 @@ static int32_t mndProcessRetrieveFuncReq(SRpcMsg *pReq) {
|
|||
goto RETRIEVE_FUNC_OVER;
|
||||
}
|
||||
|
||||
(void)tSerializeSRetrieveFuncRsp(pRsp, contLen, &retrieveRsp);
|
||||
if ((contLen = tSerializeSRetrieveFuncRsp(pRsp, contLen, &retrieveRsp)) <= 0) {
|
||||
code = contLen;
|
||||
goto RETRIEVE_FUNC_OVER;
|
||||
}
|
||||
|
||||
pReq->info.rsp = pRsp;
|
||||
pReq->info.rspLen = contLen;
|
||||
|
|
|
@ -91,7 +91,7 @@ int32_t mndInitProfile(SMnode *pMnode) {
|
|||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||
|
||||
// in ms
|
||||
int32_t checkTime = tsShellActivityTimer * 2 * 1000;
|
||||
int32_t checkTime = CACHE_OBJ_KEEP_TIME * 1000;
|
||||
pMgmt->connCache = taosCacheInit(TSDB_DATA_TYPE_UINT, checkTime, false, (__cache_free_fn_t)mndFreeConn, "conn");
|
||||
if (pMgmt->connCache == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
|
|
@ -482,7 +482,7 @@ SDbObj *mndAcquireDbByStb(SMnode *pMnode, const char *stbName) {
|
|||
if ((terrno = tNameFromString(&name, stbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE)) != 0) return NULL;
|
||||
|
||||
char db[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
(void)tNameGetFullDbName(&name, db);
|
||||
if ((terrno = tNameGetFullDbName(&name, db)) != 0) return NULL;
|
||||
|
||||
return mndAcquireDb(pMnode, db);
|
||||
}
|
||||
|
@ -507,7 +507,9 @@ void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, int3
|
|||
goto _err;
|
||||
}
|
||||
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||
(void)tNameGetFullDbName(&name, dbFName);
|
||||
if ((terrno = tNameGetFullDbName(&name, dbFName)) != 0) {
|
||||
goto _err;
|
||||
};
|
||||
|
||||
req.name = (char *)tNameGetTableName(&name);
|
||||
req.suid = pStb->uid;
|
||||
|
@ -625,8 +627,9 @@ static void *mndBuildVDropStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb,
|
|||
void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead));
|
||||
|
||||
tEncoderInit(&encoder, pBuf, contLen - sizeof(SMsgHead));
|
||||
(void)tEncodeSVDropStbReq(&encoder, &req);
|
||||
terrno = tEncodeSVDropStbReq(&encoder, &req);
|
||||
tEncoderClear(&encoder);
|
||||
if (terrno != 0) return NULL;
|
||||
|
||||
*pContLen = contLen;
|
||||
return pHead;
|
||||
|
@ -1003,7 +1006,7 @@ static int32_t mndCreateStb(SMnode *pMnode, SRpcMsg *pReq, SMCreateStbReq *pCrea
|
|||
|
||||
_OVER:
|
||||
mndTransDrop(pTrans);
|
||||
(void)mndStbActionDelete(pMnode->pSdb, &stbObj);
|
||||
if (mndStbActionDelete(pMnode->pSdb, &stbObj) != 0) mError("failed to mndStbActionDelete");
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
|
@ -1032,6 +1035,7 @@ static int32_t mndProcessTtlTimer(SRpcMsg *pReq) {
|
|||
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
int32_t code = 0;
|
||||
SMsgHead *pHead = rpcMallocCont(contLen);
|
||||
if (pHead == NULL) {
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
|
@ -1039,12 +1043,16 @@ static int32_t mndProcessTtlTimer(SRpcMsg *pReq) {
|
|||
}
|
||||
pHead->contLen = htonl(contLen);
|
||||
pHead->vgId = htonl(pVgroup->vgId);
|
||||
(void)tSerializeSVDropTtlTableReq((char *)pHead + sizeof(SMsgHead), reqLen, &ttlReq);
|
||||
if ((code = tSerializeSVDropTtlTableReq((char *)pHead + sizeof(SMsgHead), reqLen, &ttlReq)) < 0) {
|
||||
mError("vgId:%d, failed to serialize drop ttl table request since %s", pVgroup->vgId, tstrerror(code));
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
continue;
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {
|
||||
.msgType = TDMT_VND_FETCH_TTL_EXPIRED_TBS, .pCont = pHead, .contLen = contLen, .info = pReq->info};
|
||||
SEpSet epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||
int32_t code = tmsgSendReq(&epSet, &rpcMsg);
|
||||
code = tmsgSendReq(&epSet, &rpcMsg);
|
||||
if (code != 0) {
|
||||
mError("vgId:%d, failed to send drop ttl table request to vnode since 0x%x", pVgroup->vgId, code);
|
||||
} else {
|
||||
|
@ -1069,6 +1077,8 @@ static int32_t mndProcessTrimDbTimer(SRpcMsg *pReq) {
|
|||
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
int32_t code = 0;
|
||||
|
||||
SMsgHead *pHead = rpcMallocCont(contLen);
|
||||
if (pHead == NULL) {
|
||||
sdbCancelFetch(pSdb, pVgroup);
|
||||
|
@ -1077,11 +1087,13 @@ static int32_t mndProcessTrimDbTimer(SRpcMsg *pReq) {
|
|||
}
|
||||
pHead->contLen = htonl(contLen);
|
||||
pHead->vgId = htonl(pVgroup->vgId);
|
||||
(void)tSerializeSVTrimDbReq((char *)pHead + sizeof(SMsgHead), reqLen, &trimReq);
|
||||
if ((code = tSerializeSVTrimDbReq((char *)pHead + sizeof(SMsgHead), reqLen, &trimReq)) < 0) {
|
||||
mError("vgId:%d, failed to serialize trim db request since %s", pVgroup->vgId, tstrerror(code));
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_VND_TRIM, .pCont = pHead, .contLen = contLen};
|
||||
SEpSet epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||
int32_t code = tmsgSendReq(&epSet, &rpcMsg);
|
||||
code = tmsgSendReq(&epSet, &rpcMsg);
|
||||
if (code != 0) {
|
||||
mError("vgId:%d, timer failed to send vnode-trim request to vnode since 0x%x", pVgroup->vgId, code);
|
||||
} else {
|
||||
|
@ -1106,19 +1118,24 @@ static int32_t mndProcessS3MigrateDbTimer(SRpcMsg *pReq) {
|
|||
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
int32_t code = 0;
|
||||
|
||||
SMsgHead *pHead = rpcMallocCont(contLen);
|
||||
if (pHead == NULL) {
|
||||
sdbCancelFetch(pSdb, pVgroup);
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
continue;
|
||||
}
|
||||
pHead->contLen = htonl(contLen);
|
||||
pHead->vgId = htonl(pVgroup->vgId);
|
||||
(void)tSerializeSVS3MigrateDbReq((char *)pHead + sizeof(SMsgHead), reqLen, &s3migrateReq);
|
||||
if ((code = tSerializeSVS3MigrateDbReq((char *)pHead + sizeof(SMsgHead), reqLen, &s3migrateReq)) < 0) {
|
||||
mError("vgId:%d, failed to serialize s3migrate db request since %s", pVgroup->vgId, tstrerror(code));
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
continue;
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_VND_S3MIGRATE, .pCont = pHead, .contLen = contLen};
|
||||
SEpSet epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||
int32_t code = tmsgSendReq(&epSet, &rpcMsg);
|
||||
code = tmsgSendReq(&epSet, &rpcMsg);
|
||||
if (code != 0) {
|
||||
mError("vgId:%d, timer failed to send vnode-s3migrate request to vnode since 0x%x", pVgroup->vgId, code);
|
||||
} else {
|
||||
|
@ -2336,11 +2353,13 @@ static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, SStbObj *pObj, void **pCont, i
|
|||
|
||||
void *cont = taosMemoryMalloc(contLen);
|
||||
tEncoderInit(&ec, cont, contLen);
|
||||
(void)tEncodeSMAlterStbRsp(&ec, &alterRsp);
|
||||
code = tEncodeSMAlterStbRsp(&ec, &alterRsp);
|
||||
tEncoderClear(&ec);
|
||||
|
||||
tFreeSMAlterStbRsp(&alterRsp);
|
||||
|
||||
if (code < 0) TAOS_RETURN(code);
|
||||
|
||||
*pCont = cont;
|
||||
*pLen = contLen;
|
||||
|
||||
|
@ -2389,7 +2408,7 @@ int32_t mndBuildSMCreateStbRsp(SMnode *pMnode, char *dbFName, char *stbFName, vo
|
|||
|
||||
void *cont = taosMemoryMalloc(contLen);
|
||||
tEncoderInit(&ec, cont, contLen);
|
||||
(void)tEncodeSMCreateStbRsp(&ec, &stbRsp);
|
||||
TAOS_CHECK_GOTO(tEncodeSMCreateStbRsp(&ec, &stbRsp), NULL, _OVER);
|
||||
tEncoderClear(&ec);
|
||||
|
||||
tFreeSMCreateStbRsp(&stbRsp);
|
||||
|
@ -2628,8 +2647,9 @@ static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) {
|
|||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
|
||||
SName name = {0};
|
||||
// TODO check return value
|
||||
(void)tNameFromString(&name, alterReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
int32_t ret = 0;
|
||||
if ((ret = tNameFromString(&name, alterReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE)) != 0)
|
||||
mError("stb:%s, failed to tNameFromString since %s", alterReq.name, tstrerror(ret));
|
||||
|
||||
auditRecord(pReq, pMnode->clusterId, "alterStb", name.dbname, name.tname, alterReq.sql, alterReq.sqlLen);
|
||||
|
||||
|
@ -2916,8 +2936,9 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq) {
|
|||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
|
||||
SName name = {0};
|
||||
// TODO check return value
|
||||
(void)tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
int32_t ret = 0;
|
||||
if ((ret = tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE)) != 0)
|
||||
mError("stb:%s, failed to tNameFromString since %s", dropReq.name, tstrerror(ret));
|
||||
|
||||
auditRecord(pReq, pMnode->clusterId, "dropStb", name.dbname, name.tname, dropReq.sql, dropReq.sqlLen);
|
||||
|
||||
|
@ -2968,7 +2989,10 @@ static int32_t mndProcessTableMetaReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
(void)tSerializeSTableMetaRsp(pRsp, rspLen, &metaRsp);
|
||||
if ((rspLen = tSerializeSTableMetaRsp(pRsp, rspLen, &metaRsp)) < 0) {
|
||||
code = rspLen;
|
||||
goto _OVER;
|
||||
}
|
||||
pReq->info.rsp = pRsp;
|
||||
pReq->info.rspLen = rspLen;
|
||||
code = 0;
|
||||
|
@ -2995,7 +3019,7 @@ static int32_t mndProcessTableCfgReq(SRpcMsg *pReq) {
|
|||
TAOS_CHECK_GOTO(tDeserializeSTableCfgReq(pReq->pCont, pReq->contLen, &cfgReq), NULL, _OVER);
|
||||
|
||||
char dbName[TSDB_DB_NAME_LEN] = {0};
|
||||
mndExtractShortDbNameFromDbFullName(cfgReq.dbFName, dbName);
|
||||
TAOS_CHECK_GOTO(mndExtractShortDbNameFromDbFullName(cfgReq.dbFName, dbName), NULL, _OVER);
|
||||
if (0 == strcmp(dbName, TSDB_INFORMATION_SCHEMA_DB)) {
|
||||
mInfo("information_schema table:%s.%s, start to retrieve cfg", cfgReq.dbFName, cfgReq.tbName);
|
||||
TAOS_CHECK_GOTO(mndBuildInsTableCfg(pMnode, cfgReq.dbFName, cfgReq.tbName, &cfgRsp), NULL, _OVER);
|
||||
|
@ -3019,7 +3043,10 @@ static int32_t mndProcessTableCfgReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
(void)tSerializeSTableCfgRsp(pRsp, rspLen, &cfgRsp);
|
||||
if ((rspLen = tSerializeSTableCfgRsp(pRsp, rspLen, &cfgRsp)) < 0) {
|
||||
code = rspLen;
|
||||
goto _OVER;
|
||||
}
|
||||
pReq->info.rsp = pRsp;
|
||||
pReq->info.rspLen = rspLen;
|
||||
code = 0;
|
||||
|
@ -3140,8 +3167,9 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
(void)tSerializeSSTbHbRsp(pRsp, rspLen, &hbRsp);
|
||||
rspLen = tSerializeSSTbHbRsp(pRsp, rspLen, &hbRsp);
|
||||
tFreeSSTbHbRsp(&hbRsp);
|
||||
if (rspLen < 0) return rspLen;
|
||||
*ppRsp = pRsp;
|
||||
*pRspLen = rspLen;
|
||||
TAOS_RETURN(code);
|
||||
|
@ -3175,25 +3203,31 @@ int32_t mndGetNumOfStbs(SMnode *pMnode, char *dbName, int32_t *pNumOfStbs) {
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
void mndExtractDbNameFromStbFullName(const char *stbFullName, char *dst) {
|
||||
int32_t mndExtractDbNameFromStbFullName(const char *stbFullName, char *dst) {
|
||||
SName name = {0};
|
||||
(void)tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
TAOS_CHECK_RETURN(tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE));
|
||||
|
||||
(void)tNameGetFullDbName(&name, dst);
|
||||
TAOS_CHECK_RETURN(tNameGetFullDbName(&name, dst));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mndExtractShortDbNameFromStbFullName(const char *stbFullName, char *dst) {
|
||||
int32_t mndExtractShortDbNameFromStbFullName(const char *stbFullName, char *dst) {
|
||||
SName name = {0};
|
||||
(void)tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
TAOS_CHECK_RETURN(tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE));
|
||||
|
||||
(void)tNameGetDbName(&name, dst);
|
||||
TAOS_CHECK_RETURN(tNameGetDbName(&name, dst));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mndExtractShortDbNameFromDbFullName(const char *stbFullName, char *dst) {
|
||||
int32_t mndExtractShortDbNameFromDbFullName(const char *stbFullName, char *dst) {
|
||||
SName name = {0};
|
||||
(void)tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB);
|
||||
TAOS_CHECK_RETURN(tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB));
|
||||
|
||||
(void)tNameGetDbName(&name, dst);
|
||||
TAOS_CHECK_RETURN(tNameGetDbName(&name, dst));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mndExtractTbNameFromStbFullName(const char *stbFullName, char *dst, int32_t dstSize) {
|
||||
|
@ -3491,6 +3525,8 @@ static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
|||
int32_t numOfRows = 0;
|
||||
SStbObj *pStb = NULL;
|
||||
int32_t cols = 0;
|
||||
int32_t lino = 0;
|
||||
int32_t code = 0;
|
||||
|
||||
SDbObj *pDb = NULL;
|
||||
if (strlen(pShow->db) > 0) {
|
||||
|
@ -3515,42 +3551,44 @@ static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
|||
cols = 0;
|
||||
|
||||
SName name = {0};
|
||||
|
||||
char stbName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
mndExtractTbNameFromStbFullName(pStb->name, &stbName[VARSTR_HEADER_SIZE], TSDB_TABLE_NAME_LEN);
|
||||
varDataSetLen(stbName, strlen(&stbName[VARSTR_HEADER_SIZE]));
|
||||
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)stbName, false);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)stbName, false), pStb, &lino, _ERROR);
|
||||
|
||||
char db[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
(void)tNameFromString(&name, pStb->db, T_NAME_ACCT | T_NAME_DB);
|
||||
(void)tNameGetDbName(&name, varDataVal(db));
|
||||
RETRIEVE_CHECK_GOTO(tNameFromString(&name, pStb->db, T_NAME_ACCT | T_NAME_DB), pStb, &lino, _ERROR);
|
||||
RETRIEVE_CHECK_GOTO(tNameGetDbName(&name, varDataVal(db)), pStb, &lino, _ERROR);
|
||||
varDataSetLen(db, strlen(varDataVal(db)));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)db, false), pStb, &lino, _ERROR);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)db, false);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->createdTime, false), pStb, &lino,
|
||||
_ERROR);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->createdTime, false);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->numOfColumns, false), pStb, &lino,
|
||||
_ERROR);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->numOfColumns, false);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->numOfTags, false), pStb, &lino, _ERROR);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->numOfTags, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->updateTime, false); // number of tables
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->updateTime, false), pStb, &lino,
|
||||
_ERROR); // number of tables
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
if (pStb->commentLen > 0) {
|
||||
char comment[TSDB_TB_COMMENT_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(comment, pStb->comment);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, comment, false);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, comment, false), pStb, &lino, _ERROR);
|
||||
} else if (pStb->commentLen == 0) {
|
||||
char comment[VARSTR_HEADER_SIZE + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(comment, "");
|
||||
(void)colDataSetVal(pColInfo, numOfRows, comment, false);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, comment, false), pStb, &lino, _ERROR);
|
||||
} else {
|
||||
colDataSetNULL(pColInfo, numOfRows);
|
||||
}
|
||||
|
@ -3560,14 +3598,14 @@ static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
|||
varDataSetLen(watermark, strlen(varDataVal(watermark)));
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)watermark, false);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)watermark, false), pStb, &lino, _ERROR);
|
||||
|
||||
char maxDelay[64 + VARSTR_HEADER_SIZE] = {0};
|
||||
sprintf(varDataVal(maxDelay), "%" PRId64 "a,%" PRId64 "a", pStb->maxdelay[0], pStb->maxdelay[1]);
|
||||
varDataSetLen(maxDelay, strlen(varDataVal(maxDelay)));
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)maxDelay, false);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)maxDelay, false), pStb, &lino, _ERROR);
|
||||
|
||||
char rollup[160 + VARSTR_HEADER_SIZE] = {0};
|
||||
int32_t rollupNum = (int32_t)taosArrayGetSize(pStb->pFuncs);
|
||||
|
@ -3586,7 +3624,7 @@ static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
|||
varDataSetLen(rollup, strlen(varDataVal(rollup)));
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)rollup, false);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)rollup, false), pStb, &lino, _ERROR);
|
||||
|
||||
numOfRows++;
|
||||
sdbRelease(pSdb, pStb);
|
||||
|
@ -3596,6 +3634,13 @@ static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
|||
mndReleaseDb(pMnode, pDb);
|
||||
}
|
||||
|
||||
goto _OVER;
|
||||
|
||||
_ERROR:
|
||||
mError("show:0x%" PRIx64 ", failed to retrieve data at %s:%d since %s", pShow->id, __FUNCTION__, lino,
|
||||
tstrerror(code));
|
||||
|
||||
_OVER:
|
||||
pShow->numOfRows += numOfRows;
|
||||
return numOfRows;
|
||||
}
|
||||
|
@ -3606,6 +3651,8 @@ static int32_t buildDbColsInfoBlock(const SSDataBlock *p, const SSysTableMeta *p
|
|||
char dName[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
char typeName[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
int32_t numOfRows = p->info.rows;
|
||||
int32_t lino = 0;
|
||||
int32_t code = 0;
|
||||
|
||||
STR_TO_VARSTR(dName, dbName);
|
||||
STR_TO_VARSTR(typeName, "SYSTEM_TABLE");
|
||||
|
@ -3624,20 +3671,20 @@ static int32_t buildDbColsInfoBlock(const SSDataBlock *p, const SSysTableMeta *p
|
|||
for (int32_t j = 0; j < pm->colNum; j++) {
|
||||
// table name
|
||||
SColumnInfoData *pColInfoData = taosArrayGet(p->pDataBlock, 0);
|
||||
(void)colDataSetVal(pColInfoData, numOfRows, tName, false);
|
||||
TAOS_CHECK_GOTO(colDataSetVal(pColInfoData, numOfRows, tName, false), &lino, _OVER);
|
||||
|
||||
// database name
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 1);
|
||||
(void)colDataSetVal(pColInfoData, numOfRows, dName, false);
|
||||
TAOS_CHECK_GOTO(colDataSetVal(pColInfoData, numOfRows, dName, false), &lino, _OVER);
|
||||
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 2);
|
||||
(void)colDataSetVal(pColInfoData, numOfRows, typeName, false);
|
||||
TAOS_CHECK_GOTO(colDataSetVal(pColInfoData, numOfRows, typeName, false), &lino, _OVER);
|
||||
|
||||
// col name
|
||||
char colName[TSDB_COL_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(colName, pm->schema[j].name);
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 3);
|
||||
(void)colDataSetVal(pColInfoData, numOfRows, colName, false);
|
||||
TAOS_CHECK_GOTO(colDataSetVal(pColInfoData, numOfRows, colName, false), &lino, _OVER);
|
||||
|
||||
// col type
|
||||
int8_t colType = pm->schema[j].type;
|
||||
|
@ -3652,10 +3699,10 @@ static int32_t buildDbColsInfoBlock(const SSDataBlock *p, const SSysTableMeta *p
|
|||
(int32_t)((pm->schema[j].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
||||
}
|
||||
varDataSetLen(colTypeStr, colTypeLen);
|
||||
(void)colDataSetVal(pColInfoData, numOfRows, (char *)colTypeStr, false);
|
||||
TAOS_CHECK_GOTO(colDataSetVal(pColInfoData, numOfRows, (char *)colTypeStr, false), &lino, _OVER);
|
||||
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 5);
|
||||
(void)colDataSetVal(pColInfoData, numOfRows, (const char *)&pm->schema[j].bytes, false);
|
||||
TAOS_CHECK_GOTO(colDataSetVal(pColInfoData, numOfRows, (const char *)&pm->schema[j].bytes, false), &lino, _OVER);
|
||||
for (int32_t k = 6; k <= 8; ++k) {
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, k);
|
||||
colDataSetNULL(pColInfoData, numOfRows);
|
||||
|
@ -3664,7 +3711,8 @@ static int32_t buildDbColsInfoBlock(const SSDataBlock *p, const SSysTableMeta *p
|
|||
numOfRows += 1;
|
||||
}
|
||||
}
|
||||
|
||||
_OVER:
|
||||
mError("failed at %s:%d since %s", __FUNCTION__, lino, tstrerror(code));
|
||||
return numOfRows;
|
||||
}
|
||||
#define BUILD_COL_FOR_INFO_DB 1
|
||||
|
@ -3712,6 +3760,8 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
SSdb *pSdb = pMnode->pSdb;
|
||||
SStbObj *pStb = NULL;
|
||||
int32_t numOfRows = 0;
|
||||
int32_t lino = 0;
|
||||
int32_t code = 0;
|
||||
|
||||
buildWhichDBs = determineBuildColForWhichDBs(pShow->db);
|
||||
|
||||
|
@ -3771,26 +3821,26 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
mDebug("mndRetrieveStbCol get stable cols, stable name:%s, db:%s", pStb->name, pStb->db);
|
||||
|
||||
char db[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
(void)tNameFromString(&name, pStb->db, T_NAME_ACCT | T_NAME_DB);
|
||||
(void)tNameGetDbName(&name, varDataVal(db));
|
||||
RETRIEVE_CHECK_GOTO(tNameFromString(&name, pStb->db, T_NAME_ACCT | T_NAME_DB), pStb, &lino, _OVER);
|
||||
RETRIEVE_CHECK_GOTO(tNameGetDbName(&name, varDataVal(db)), pStb, &lino, _OVER);
|
||||
varDataSetLen(db, strlen(varDataVal(db)));
|
||||
|
||||
for (int i = 0; i < pStb->numOfColumns; i++) {
|
||||
int32_t cols = 0;
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)stbName, false);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)stbName, false), pStb, &lino, _OVER);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)db, false);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)db, false), pStb, &lino, _OVER);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, typeName, false);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, typeName, false), pStb, &lino, _OVER);
|
||||
|
||||
// col name
|
||||
char colName[TSDB_COL_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(colName, pStb->pColumns[i].name);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, colName, false);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, colName, false), pStb, &lino, _OVER);
|
||||
|
||||
// col type
|
||||
int8_t colType = pStb->pColumns[i].type;
|
||||
|
@ -3805,10 +3855,11 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
(int32_t)((pStb->pColumns[i].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
||||
}
|
||||
varDataSetLen(colTypeStr, colTypeLen);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (char *)colTypeStr, false);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (char *)colTypeStr, false), pStb, &lino, _OVER);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->pColumns[i].bytes, false);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->pColumns[i].bytes, false), pStb,
|
||||
&lino, _OVER);
|
||||
while (cols < pShow->numOfColumns) {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetNULL(pColInfo, numOfRows);
|
||||
|
@ -3824,9 +3875,15 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
}
|
||||
}
|
||||
|
||||
pShow->numOfRows += numOfRows;
|
||||
mDebug("mndRetrieveStbCol success, rows:%d, pShow->numOfRows:%d", numOfRows, pShow->numOfRows);
|
||||
goto _OVER;
|
||||
|
||||
_ERROR:
|
||||
mError("failed to mndRetrieveStbCol, rows:%d, pShow->numOfRows:%d, at %s:%d since %s", numOfRows, pShow->numOfRows,
|
||||
__FUNCTION__, lino, tstrerror(code));
|
||||
|
||||
_OVER:
|
||||
pShow->numOfRows += numOfRows;
|
||||
return numOfRows;
|
||||
}
|
||||
|
||||
|
@ -4111,8 +4168,9 @@ static void *mndBuildVDropTbsReq(SMnode *pMnode, const SVgroupInfo *pVgInfo, con
|
|||
void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead));
|
||||
|
||||
tEncoderInit(&encoder, pBuf, contLen - sizeof(SMsgHead));
|
||||
(void)tEncodeSVDropTbBatchReq(&encoder, pReq);
|
||||
int32_t code = tEncodeSVDropTbBatchReq(&encoder, pReq);
|
||||
tEncoderClear(&encoder);
|
||||
if (code != 0) return NULL;
|
||||
|
||||
*len = contLen;
|
||||
return pHead;
|
||||
|
|
|
@ -1142,18 +1142,16 @@ int32_t extractStreamNodeList(SMnode *pMnode) {
|
|||
return taosArrayGetSize(execInfo.pNodeList);
|
||||
}
|
||||
|
||||
static bool taskNodeIsUpdated(SMnode *pMnode) {
|
||||
bool allReady = true;
|
||||
SArray *pNodeSnapshot = NULL;
|
||||
|
||||
// check if the node update happens or not
|
||||
streamMutexLock(&execInfo.lock);
|
||||
static int32_t doCheckForUpdated(SMnode *pMnode, SArray **ppNodeSnapshot) {
|
||||
bool allReady = false;
|
||||
bool nodeUpdated = false;
|
||||
SVgroupChangeInfo changeInfo = {0};
|
||||
|
||||
int32_t numOfNodes = extractStreamNodeList(pMnode);
|
||||
|
||||
if (numOfNodes == 0) {
|
||||
mDebug("stream task node change checking done, no vgroups exist, do nothing");
|
||||
execInfo.ts = taosGetTimestampSec();
|
||||
streamMutexUnlock(&execInfo.lock);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1165,43 +1163,46 @@ static bool taskNodeIsUpdated(SMnode *pMnode) {
|
|||
|
||||
if (pNodeEntry->stageUpdated) {
|
||||
mDebug("stream task not ready due to node update detected, checkpoint not issued");
|
||||
streamMutexUnlock(&execInfo.lock);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t code = mndTakeVgroupSnapshot(pMnode, &allReady, &pNodeSnapshot);
|
||||
int32_t code = mndTakeVgroupSnapshot(pMnode, &allReady, ppNodeSnapshot);
|
||||
if (code) {
|
||||
mError("failed to get the vgroup snapshot, ignore it and continue");
|
||||
}
|
||||
|
||||
if (!allReady) {
|
||||
mWarn("not all vnodes ready, quit from vnodes status check");
|
||||
taosArrayDestroy(pNodeSnapshot);
|
||||
streamMutexUnlock(&execInfo.lock);
|
||||
return true;
|
||||
}
|
||||
|
||||
SVgroupChangeInfo changeInfo = {0};
|
||||
code = mndFindChangedNodeInfo(pMnode, execInfo.pNodeList, pNodeSnapshot, &changeInfo);
|
||||
code = mndFindChangedNodeInfo(pMnode, execInfo.pNodeList, *ppNodeSnapshot, &changeInfo);
|
||||
if (code) {
|
||||
streamMutexUnlock(&execInfo.lock);
|
||||
return false;
|
||||
nodeUpdated = false;
|
||||
} else {
|
||||
nodeUpdated = (taosArrayGetSize(changeInfo.pUpdateNodeList) > 0);
|
||||
if (nodeUpdated) {
|
||||
mDebug("stream tasks not ready due to node update");
|
||||
}
|
||||
}
|
||||
|
||||
bool nodeUpdated = (taosArrayGetSize(changeInfo.pUpdateNodeList) > 0);
|
||||
|
||||
mndDestroyVgroupChangeInfo(&changeInfo);
|
||||
taosArrayDestroy(pNodeSnapshot);
|
||||
|
||||
if (nodeUpdated) {
|
||||
mDebug("stream tasks not ready due to node update");
|
||||
}
|
||||
|
||||
streamMutexUnlock(&execInfo.lock);
|
||||
return nodeUpdated;
|
||||
}
|
||||
|
||||
// check if the node update happens or not
|
||||
static bool taskNodeIsUpdated(SMnode *pMnode) {
|
||||
SArray *pNodeSnapshot = NULL;
|
||||
|
||||
streamMutexLock(&execInfo.lock);
|
||||
bool updated = doCheckForUpdated(pMnode, &pNodeSnapshot);
|
||||
streamMutexUnlock(&execInfo.lock);
|
||||
|
||||
taosArrayDestroy(pNodeSnapshot);
|
||||
return updated;
|
||||
}
|
||||
|
||||
static int32_t mndCheckTaskAndNodeStatus(SMnode *pMnode) {
|
||||
bool ready = true;
|
||||
if (taskNodeIsUpdated(pMnode)) {
|
||||
|
@ -1992,7 +1993,7 @@ static int32_t mndFindChangedNodeInfo(SMnode *pMnode, const SArray *pPrevNodeLis
|
|||
|
||||
if (pInfo->pUpdateNodeList == NULL || pInfo->pDBMap == NULL) {
|
||||
mndDestroyVgroupChangeInfo(pInfo);
|
||||
return terrno;
|
||||
TSDB_CHECK_NULL(NULL, code, lino, _err, terrno);
|
||||
}
|
||||
|
||||
int32_t numOfNodes = taosArrayGetSize(pPrevNodeList);
|
||||
|
@ -2047,6 +2048,7 @@ static int32_t mndFindChangedNodeInfo(SMnode *pMnode, const SArray *pPrevNodeLis
|
|||
return code;
|
||||
|
||||
_err:
|
||||
mError("failed to find node change info, code:%s at %s line:%d", tstrerror(code), __func__, lino);
|
||||
mndDestroyVgroupChangeInfo(pInfo);
|
||||
return code;
|
||||
}
|
||||
|
@ -2220,7 +2222,11 @@ static int32_t refreshNodeListFromExistedStreams(SMnode *pMnode, SArray *pNodeLi
|
|||
}
|
||||
|
||||
char buf[256] = {0};
|
||||
(void) epsetToStr(&pEntry->epset, buf, tListLen(buf)); // ignore this error since it is only for log file
|
||||
int32_t ret = epsetToStr(&pEntry->epset, buf, tListLen(buf)); // ignore this error since it is only for log file
|
||||
if (ret != 0) { // print error and continue
|
||||
mError("failed to convert epset to str, code:%s", tstrerror(ret));
|
||||
}
|
||||
|
||||
mDebug("extract nodeInfo from stream obj, nodeId:%d, %s", pEntry->nodeId, buf);
|
||||
}
|
||||
|
||||
|
@ -2230,7 +2236,7 @@ static int32_t refreshNodeListFromExistedStreams(SMnode *pMnode, SArray *pNodeLi
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t addAllDbsIntoHashmap(SHashObj *pDBMap, SSdb *pSdb) {
|
||||
static void addAllDbsIntoHashmap(SHashObj *pDBMap, SSdb *pSdb) {
|
||||
void *pIter = NULL;
|
||||
int32_t code = 0;
|
||||
while (1) {
|
||||
|
@ -2248,8 +2254,6 @@ static int32_t addAllDbsIntoHashmap(SHashObj *pDBMap, SSdb *pSdb) {
|
|||
mDebug("add Db:%s into Dbs list (total:%d) for kill checkpoint trans", pVgroup->dbName, size);
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
// this function runs by only one thread, so it is not multi-thread safe
|
||||
|
@ -2310,7 +2314,7 @@ static int32_t mndProcessNodeCheckReq(SRpcMsg *pMsg) {
|
|||
mInfo("rollback all stream due to mnode leader/follower switch by using nodeUpdate trans");
|
||||
updateAllVgroups = true;
|
||||
execInfo.switchFromFollower = false; // reset the flag
|
||||
(void) addAllDbsIntoHashmap(changeInfo.pDBMap, pMnode->pSdb);
|
||||
addAllDbsIntoHashmap(changeInfo.pDBMap, pMnode->pSdb);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -194,10 +194,13 @@ int32_t mndSendDropOrphanTasksMsg(SMnode *pMnode, SArray *pList) {
|
|||
return terrno;
|
||||
}
|
||||
|
||||
(void)tSerializeDropOrphanTaskMsg(pReq, contLen, &msg);
|
||||
int32_t code = tSerializeDropOrphanTaskMsg(pReq, contLen, &msg);
|
||||
if (code <= 0) {
|
||||
mError("failed to serialize the drop orphan task msg, code:%s", tstrerror(code));
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_STREAM_DROP_ORPHANTASKS, .pCont = pReq, .contLen = contLen};
|
||||
int32_t code = tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
code = tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
if (code) {
|
||||
mError("failed to put drop-orphan task msg into write queue, code:%s", tstrerror(code));
|
||||
} else {
|
||||
|
@ -216,7 +219,7 @@ int32_t mndProcessResetStatusReq(SRpcMsg *pReq) {
|
|||
mndKillTransImpl(pMnode, pMsg->transId, "");
|
||||
|
||||
streamMutexLock(&execInfo.lock);
|
||||
(void) mndResetChkptReportInfo(execInfo.pChkptStreams, pMsg->streamId);
|
||||
code = mndResetChkptReportInfo(execInfo.pChkptStreams, pMsg->streamId); // do thing if failed
|
||||
streamMutexUnlock(&execInfo.lock);
|
||||
|
||||
code = mndGetStreamObj(pMnode, pMsg->streamId, &pStream);
|
||||
|
@ -393,7 +396,7 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
|||
int32_t numOfUpdated = taosArrayGetSize(req.pUpdateNodes);
|
||||
if (numOfUpdated > 0) {
|
||||
mDebug("%d stream node(s) need updated from hbMsg(vgId:%d)", numOfUpdated, req.vgId);
|
||||
(void) setNodeEpsetExpiredFlag(req.pUpdateNodes);
|
||||
int32_t unused = setNodeEpsetExpiredFlag(req.pUpdateNodes);
|
||||
}
|
||||
|
||||
bool snodeChanged = false;
|
||||
|
|
|
@ -165,7 +165,10 @@ int32_t mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady, SArray **pList) {
|
|||
}
|
||||
|
||||
char buf[256] = {0};
|
||||
(void)epsetToStr(&entry.epset, buf, tListLen(buf));
|
||||
code = epsetToStr(&entry.epset, buf, tListLen(buf));
|
||||
if (code != 0) { // print error and continue
|
||||
mError("failed to convert epset to str, code:%s", tstrerror(code));
|
||||
}
|
||||
|
||||
void *p = taosArrayPush(pVgroupList, &entry);
|
||||
if (p == NULL) {
|
||||
|
@ -198,7 +201,10 @@ int32_t mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady, SArray **pList) {
|
|||
}
|
||||
|
||||
char buf[256] = {0};
|
||||
(void)epsetToStr(&entry.epset, buf, tListLen(buf));
|
||||
code = epsetToStr(&entry.epset, buf, tListLen(buf));
|
||||
if (code != 0) { // print error and continue
|
||||
mError("failed to convert epset to str, code:%s", tstrerror(code));
|
||||
}
|
||||
|
||||
void *p = taosArrayPush(pVgroupList, &entry);
|
||||
if (p == NULL) {
|
||||
|
@ -424,9 +430,12 @@ static int32_t doSetPauseAction(SMnode *pMnode, STrans *pTrans, SStreamTask *pTa
|
|||
}
|
||||
|
||||
char buf[256] = {0};
|
||||
(void) epsetToStr(&epset, buf, tListLen(buf));
|
||||
mDebug("pause stream task in node:%d, epset:%s", pTask->info.nodeId, buf);
|
||||
code = epsetToStr(&epset, buf, tListLen(buf));
|
||||
if (code != 0) { // print error and continue
|
||||
mError("failed to convert epset to str, code:%s", tstrerror(code));
|
||||
}
|
||||
|
||||
mDebug("pause stream task in node:%d, epset:%s", pTask->info.nodeId, buf);
|
||||
code = setTransAction(pTrans, pReq, sizeof(SVPauseStreamTaskReq), TDMT_STREAM_TASK_PAUSE, &epset, 0, TSDB_CODE_VND_INVALID_VGROUP_ID);
|
||||
if (code != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
|
@ -639,8 +648,7 @@ static int32_t doBuildStreamTaskUpdateMsg(void **pBuf, int32_t *pLen, SVgroupCha
|
|||
static int32_t doSetUpdateTaskAction(SMnode *pMnode, STrans *pTrans, SStreamTask *pTask, SVgroupChangeInfo *pInfo) {
|
||||
void *pBuf = NULL;
|
||||
int32_t len = 0;
|
||||
(void)streamTaskUpdateEpsetInfo(pTask, pInfo->pUpdateNodeList);
|
||||
|
||||
bool unusedRet = streamTaskUpdateEpsetInfo(pTask, pInfo->pUpdateNodeList);
|
||||
int32_t code = doBuildStreamTaskUpdateMsg(&pBuf, &len, pInfo, pTask->info.nodeId, &pTask->id, pTrans->id);
|
||||
if (code) {
|
||||
return code;
|
||||
|
@ -914,8 +922,15 @@ void removeStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode) {
|
|||
}
|
||||
|
||||
// 2. remove stream entry in consensus hash table and checkpoint-report hash table
|
||||
(void) mndClearConsensusCheckpointId(execInfo.pStreamConsensus, pStream->uid);
|
||||
(void) mndClearChkptReportInfo(execInfo.pChkptStreams, pStream->uid);
|
||||
code = mndClearConsensusCheckpointId(execInfo.pStreamConsensus, pStream->uid);
|
||||
if (code) {
|
||||
mError("failed to clear consensus checkpointId, code:%s", tstrerror(code));
|
||||
}
|
||||
|
||||
code = mndClearChkptReportInfo(execInfo.pChkptStreams, pStream->uid);
|
||||
if (code) {
|
||||
mError("failed to clear the checkpoint report info, code:%s", tstrerror(code));
|
||||
}
|
||||
|
||||
streamMutexUnlock(&pExecNode->lock);
|
||||
destroyStreamTaskIter(pIter);
|
||||
|
|
|
@ -248,7 +248,7 @@ static int32_t processRemovedConsumers(SMqRebOutputObj *pOutput, SHashObj *pHash
|
|||
MND_TMQ_RETURN_CHECK(pushVgDataToHash(pConsumerEp->vgs, pHash, *consumerId, pOutput->pSub->key));
|
||||
}
|
||||
|
||||
(void)taosArrayDestroy(pConsumerEp->vgs);
|
||||
taosArrayDestroy(pConsumerEp->vgs);
|
||||
MND_TMQ_RETURN_CHECK(taosHashRemove(pOutput->pSub->consumerHash, consumerId, sizeof(int64_t)));
|
||||
MND_TMQ_NULL_CHECK(taosArrayPush(pOutput->removedConsumers, consumerId));
|
||||
actualRemoved++;
|
||||
|
@ -682,8 +682,8 @@ END:
|
|||
|
||||
static void freeRebalanceItem(void *param) {
|
||||
SMqRebInfo *pInfo = param;
|
||||
(void)taosArrayDestroy(pInfo->newConsumers);
|
||||
(void)taosArrayDestroy(pInfo->removedConsumers);
|
||||
taosArrayDestroy(pInfo->newConsumers);
|
||||
taosArrayDestroy(pInfo->removedConsumers);
|
||||
}
|
||||
|
||||
// type = 0 remove type = 1 add
|
||||
|
@ -738,8 +738,12 @@ static void checkForVgroupSplit(SMnode *pMnode, SMqConsumerObj *pConsumer, SHash
|
|||
}
|
||||
SVgObj *pVgroup = mndAcquireVgroup(pMnode, pVgEp->vgId);
|
||||
if (!pVgroup) {
|
||||
(void)mndGetOrCreateRebSub(rebSubHash, key, NULL);
|
||||
mInfo("vnode splitted, vgId:%d rebalance will be triggered", pVgEp->vgId);
|
||||
code = mndGetOrCreateRebSub(rebSubHash, key, NULL);
|
||||
if (code != 0){
|
||||
mError("failed to mndGetOrCreateRebSub vgroup:%d, error:%s", pVgEp->vgId, tstrerror(code))
|
||||
}else{
|
||||
mInfo("vnode splitted, vgId:%d rebalance will be triggered", pVgEp->vgId);
|
||||
}
|
||||
}
|
||||
mndReleaseVgroup(pMnode, pVgroup);
|
||||
}
|
||||
|
@ -813,10 +817,10 @@ void mndRebCntDec() {
|
|||
}
|
||||
|
||||
static void clearRebOutput(SMqRebOutputObj *rebOutput) {
|
||||
(void)taosArrayDestroy(rebOutput->newConsumers);
|
||||
(void)taosArrayDestroy(rebOutput->modifyConsumers);
|
||||
(void)taosArrayDestroy(rebOutput->removedConsumers);
|
||||
(void)taosArrayDestroy(rebOutput->rebVgs);
|
||||
taosArrayDestroy(rebOutput->newConsumers);
|
||||
taosArrayDestroy(rebOutput->modifyConsumers);
|
||||
taosArrayDestroy(rebOutput->removedConsumers);
|
||||
taosArrayDestroy(rebOutput->rebVgs);
|
||||
tDeleteSubscribeObj(rebOutput->pSub);
|
||||
taosMemoryFree(rebOutput->pSub);
|
||||
}
|
||||
|
@ -858,7 +862,7 @@ static int32_t checkConsumer(SMnode *pMnode, SMqSubscribeObj *pSub) {
|
|||
mError("consumer:0x%" PRIx64 " not exists in sdb for exception", pConsumerEp->consumerId);
|
||||
MND_TMQ_NULL_CHECK(taosArrayAddAll(pSub->unassignedVgs, pConsumerEp->vgs));
|
||||
|
||||
(void)taosArrayDestroy(pConsumerEp->vgs);
|
||||
taosArrayDestroy(pConsumerEp->vgs);
|
||||
MND_TMQ_RETURN_CHECK(taosHashRemove(pSub->consumerHash, &pConsumerEp->consumerId, sizeof(int64_t)));
|
||||
}
|
||||
END:
|
||||
|
|
|
@ -238,7 +238,9 @@ static int32_t mndPostMgmtCode(SMnode *pMnode, int32_t code) {
|
|||
pMgmt->transSec = 0;
|
||||
pMgmt->transSeq = 0;
|
||||
pMgmt->errCode = code;
|
||||
(void)tsem_post(&pMgmt->syncSem);
|
||||
if (tsem_post(&pMgmt->syncSem) < 0) {
|
||||
mError("trans:%d, failed to post sem", transId);
|
||||
}
|
||||
|
||||
if (pMgmt->errCode != 0) {
|
||||
mError("trans:%d, failed to propose since %s, post sem", transId, tstrerror(pMgmt->errCode));
|
||||
|
@ -310,11 +312,15 @@ void mndRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx) {
|
|||
} else {
|
||||
mInfo("vgId:1, sync restore finished");
|
||||
}
|
||||
(void)mndRefreshUserIpWhiteList(pMnode);
|
||||
int32_t code = mndRefreshUserIpWhiteList(pMnode);
|
||||
if (code != 0) {
|
||||
mError("vgId:1, failed to refresh user ip white list since %s", tstrerror(code));
|
||||
mndSetRestored(pMnode, false);
|
||||
}
|
||||
|
||||
SyncIndex fsmIndex = mndSyncAppliedIndex(pFsm);
|
||||
if (commitIdx != fsmIndex) {
|
||||
mError("vgId:1, sync restore finished, but commitIdx:%" PRId64 " is not equal to appliedIdx:%" PRId64, commitIdx,
|
||||
mError("vgId:1, failed to sync restore, commitIdx:%" PRId64 " is not equal to appliedIdx:%" PRId64, commitIdx,
|
||||
fsmIndex);
|
||||
mndSetRestored(pMnode, false);
|
||||
}
|
||||
|
@ -368,7 +374,9 @@ static void mndBecomeFollower(const SSyncFSM *pFsm) {
|
|||
pMgmt->transSec = 0;
|
||||
pMgmt->transSeq = 0;
|
||||
pMgmt->errCode = TSDB_CODE_SYN_NOT_LEADER;
|
||||
(void)tsem_post(&pMgmt->syncSem);
|
||||
if (tsem_post(&pMgmt->syncSem) < 0) {
|
||||
mError("failed to post sem");
|
||||
}
|
||||
}
|
||||
(void)taosThreadMutexUnlock(&pMgmt->lock);
|
||||
|
||||
|
@ -387,7 +395,9 @@ static void mndBecomeLearner(const SSyncFSM *pFsm) {
|
|||
pMgmt->transSec = 0;
|
||||
pMgmt->transSeq = 0;
|
||||
pMgmt->errCode = TSDB_CODE_SYN_NOT_LEADER;
|
||||
(void)tsem_post(&pMgmt->syncSem);
|
||||
if (tsem_post(&pMgmt->syncSem) < 0) {
|
||||
mError("failed to post sem");
|
||||
}
|
||||
}
|
||||
(void)taosThreadMutexUnlock(&pMgmt->lock);
|
||||
}
|
||||
|
@ -487,13 +497,18 @@ int32_t mndInitSync(SMnode *pMnode) {
|
|||
pNode->nodePort = pMgmt->replicas[i].port;
|
||||
tstrncpy(pNode->nodeFqdn, pMgmt->replicas[i].fqdn, sizeof(pNode->nodeFqdn));
|
||||
pNode->nodeRole = pMgmt->nodeRoles[i];
|
||||
(void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort);
|
||||
if (tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort) != true) {
|
||||
mError("failed to open sync, tmsgUpdateDnodeInfo is false");
|
||||
}
|
||||
mInfo("vgId:1, index:%d ep:%s:%u dnode:%d cluster:%" PRId64, i, pNode->nodeFqdn, pNode->nodePort, pNode->nodeId,
|
||||
pNode->clusterId);
|
||||
}
|
||||
|
||||
int32_t code = 0;
|
||||
(void)tsem_init(&pMgmt->syncSem, 0, 0);
|
||||
if ((code = tsem_init(&pMgmt->syncSem, 0, 0)) < 0) {
|
||||
mError("failed to open sync, tsem_init, since %s", tstrerror(code));
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
pMgmt->sync = syncOpen(&syncInfo, 1); // always check
|
||||
if (pMgmt->sync <= 0) {
|
||||
if (terrno != 0) code = terrno;
|
||||
|
@ -511,7 +526,9 @@ void mndCleanupSync(SMnode *pMnode) {
|
|||
syncStop(pMgmt->sync);
|
||||
mInfo("mnode-sync is stopped, id:%" PRId64, pMgmt->sync);
|
||||
|
||||
(void)tsem_destroy(&pMgmt->syncSem);
|
||||
if (tsem_destroy(&pMgmt->syncSem) < 0) {
|
||||
mError("failed to destroy sem");
|
||||
}
|
||||
(void)taosThreadMutexDestroy(&pMgmt->lock);
|
||||
memset(pMgmt, 0, sizeof(SSyncMgmt));
|
||||
}
|
||||
|
@ -526,12 +543,14 @@ void mndSyncCheckTimeout(SMnode *pMnode) {
|
|||
if (delta > MNODE_TIMEOUT_SEC) {
|
||||
mError("trans:%d, failed to propose since timeout, start:%d cur:%d delta:%d seq:%" PRId64, pMgmt->transId,
|
||||
pMgmt->transSec, curSec, delta, pMgmt->transSeq);
|
||||
pMgmt->transId = 0;
|
||||
pMgmt->transSec = 0;
|
||||
pMgmt->transSeq = 0;
|
||||
terrno = TSDB_CODE_SYN_TIMEOUT;
|
||||
pMgmt->errCode = TSDB_CODE_SYN_TIMEOUT;
|
||||
(void)tsem_post(&pMgmt->syncSem);
|
||||
// pMgmt->transId = 0;
|
||||
// pMgmt->transSec = 0;
|
||||
// pMgmt->transSeq = 0;
|
||||
// terrno = TSDB_CODE_SYN_TIMEOUT;
|
||||
// pMgmt->errCode = TSDB_CODE_SYN_TIMEOUT;
|
||||
//if (tsem_post(&pMgmt->syncSem) < 0) {
|
||||
// mError("failed to post sem");
|
||||
//}
|
||||
} else {
|
||||
mDebug("trans:%d, waiting for sync confirm, start:%d cur:%d delta:%d seq:%" PRId64, pMgmt->transId,
|
||||
pMgmt->transSec, curSec, curSec - pMgmt->transSec, pMgmt->transSeq);
|
||||
|
@ -572,7 +591,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
|
|||
mInfo("trans:%d, is proposing and wait sem, seq:%" PRId64, transId, seq);
|
||||
pMgmt->transSeq = seq;
|
||||
(void)taosThreadMutexUnlock(&pMgmt->lock);
|
||||
(void)tsem_wait(&pMgmt->syncSem);
|
||||
code = tsem_wait(&pMgmt->syncSem);
|
||||
} else if (code > 0) {
|
||||
mInfo("trans:%d, confirm at once since replica is 1, continue execute", transId);
|
||||
pMgmt->transId = 0;
|
||||
|
@ -624,7 +643,9 @@ void mndSyncStop(SMnode *pMnode) {
|
|||
pMgmt->transId = 0;
|
||||
pMgmt->transSec = 0;
|
||||
pMgmt->errCode = TSDB_CODE_APP_IS_STOPPING;
|
||||
(void)tsem_post(&pMgmt->syncSem);
|
||||
if (tsem_post(&pMgmt->syncSem) < 0) {
|
||||
mError("failed to post sem");
|
||||
}
|
||||
}
|
||||
(void)taosThreadMutexUnlock(&pMgmt->lock);
|
||||
}
|
||||
|
|
|
@ -302,7 +302,7 @@ static int32_t mndTopicActionDelete(SSdb *pSdb, SMqTopicObj *pTopic) {
|
|||
taosMemoryFreeClear(pTopic->ast);
|
||||
taosMemoryFreeClear(pTopic->physicalPlan);
|
||||
if (pTopic->schema.nCols) taosMemoryFreeClear(pTopic->schema.pSchema);
|
||||
(void)taosArrayDestroy(pTopic->ntbColIds);
|
||||
taosArrayDestroy(pTopic->ntbColIds);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -467,7 +467,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
|
|||
MND_TMQ_NULL_CHECK(topicObj.ntbColIds);
|
||||
MND_TMQ_RETURN_CHECK(extractTopicTbInfo(pAst, &topicObj));
|
||||
if (topicObj.ntbUid == 0) {
|
||||
(void)taosArrayDestroy(topicObj.ntbColIds);
|
||||
taosArrayDestroy(topicObj.ntbColIds);
|
||||
topicObj.ntbColIds = NULL;
|
||||
}
|
||||
|
||||
|
@ -505,7 +505,7 @@ END:
|
|||
taosMemoryFreeClear(topicObj.physicalPlan);
|
||||
taosMemoryFreeClear(topicObj.sql);
|
||||
taosMemoryFreeClear(topicObj.ast);
|
||||
(void)taosArrayDestroy(topicObj.ntbColIds);
|
||||
taosArrayDestroy(topicObj.ntbColIds);
|
||||
if (topicObj.schema.nCols) {
|
||||
taosMemoryFreeClear(topicObj.schema.pSchema);
|
||||
}
|
||||
|
@ -567,9 +567,15 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) {
|
|||
|
||||
{
|
||||
SName dbname = {0};
|
||||
(void)tNameFromString(&dbname, createTopicReq.subDbName, T_NAME_ACCT | T_NAME_DB); // ignore error
|
||||
int32_t ret = tNameFromString(&dbname, createTopicReq.subDbName, T_NAME_ACCT | T_NAME_DB);
|
||||
if (ret != 0){
|
||||
mError("failed to parse db name:%s, ret:%d", createTopicReq.subDbName, ret);
|
||||
}
|
||||
SName topicName = {0};
|
||||
(void)tNameFromString(&topicName, createTopicReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); // ignore error
|
||||
ret = tNameFromString(&topicName, createTopicReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (ret != 0){
|
||||
mError("failed to parse topic name:%s, ret:%d", createTopicReq.name, ret);
|
||||
}
|
||||
auditRecord(pReq, pMnode->clusterId, "createTopic", dbname.dbname, topicName.dbname,
|
||||
createTopicReq.sql, strlen(createTopicReq.sql));
|
||||
}
|
||||
|
@ -735,7 +741,10 @@ END:
|
|||
}
|
||||
|
||||
SName name = {0};
|
||||
(void)tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); // ignore error
|
||||
int32_t ret = tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (ret != 0) {
|
||||
mError("topic:%s, failed to drop since %s", dropReq.name, tstrerror(ret));
|
||||
}
|
||||
auditRecord(pReq, pMnode->clusterId, "dropTopic", name.dbname, name.tname, dropReq.sql, dropReq.sqlLen);
|
||||
|
||||
tFreeSMDropTopicReq(&dropReq);
|
||||
|
|
|
@ -342,7 +342,8 @@ int32_t mndUpdateIpWhiteImpl(SHashObj *pIpWhiteTab, char *user, char *fqdn, int8
|
|||
SIpV4Range range = {.ip = 0, .mask = 32};
|
||||
int32_t code = taosGetIpv4FromFqdn(fqdn, &range.ip);
|
||||
if (code) {
|
||||
//TODO
|
||||
mError("failed to get ip from fqdn: %s at line %d since %s", fqdn, lino, tstrerror(code));
|
||||
TAOS_RETURN(TSDB_CODE_TSC_INVALID_FQDN);
|
||||
}
|
||||
mDebug("ip-white-list may update for user: %s, fqdn: %s", user, fqdn);
|
||||
SIpWhiteList **ppList = taosHashGet(pIpWhiteTab, user, strlen(user));
|
||||
|
@ -2800,7 +2801,7 @@ static int32_t mndLoopHash(SHashObj *hash, char *priType, SSDataBlock *pBlock, i
|
|||
void *key = taosHashGetKey(value, &keyLen);
|
||||
|
||||
char dbName[TSDB_DB_NAME_LEN] = {0};
|
||||
mndExtractShortDbNameFromStbFullName(key, dbName);
|
||||
(void)mndExtractShortDbNameFromStbFullName(key, dbName);
|
||||
char dbNameContent[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(dbNameContent, dbName, pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
|
|
@ -164,7 +164,7 @@ typedef struct STsdbReader STsdbReader;
|
|||
int32_t tsdbReaderOpen2(void *pVnode, SQueryTableDataCond *pCond, void *pTableList, int32_t numOfTables,
|
||||
SSDataBlock *pResBlock, void **ppReader, const char *idstr, SHashObj **pIgnoreTables);
|
||||
int32_t tsdbSetTableList2(STsdbReader *pReader, const void *pTableList, int32_t num);
|
||||
void tsdbReaderSetId2(STsdbReader *pReader, const char *idstr);
|
||||
int32_t tsdbReaderSetId(void *pReader, const char *idstr);
|
||||
void tsdbReaderClose2(STsdbReader *pReader);
|
||||
int32_t tsdbNextDataBlock2(STsdbReader *pReader, bool *hasNext);
|
||||
int32_t tsdbRetrieveDatablockSMA2(STsdbReader *pReader, SSDataBlock *pDataBlock, bool *allHave, bool *hasNullSMA);
|
||||
|
|
|
@ -314,8 +314,9 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
|
|||
|
||||
SReadHandle handle = {.vnode = pVnode, .initTqReader = 1, .skipRollup = 1, .pStateBackend = pStreamState};
|
||||
initStorageAPI(&handle.api);
|
||||
pRSmaInfo->taskInfo[idx] = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle, TD_VID(pVnode), 0);
|
||||
if (!pRSmaInfo->taskInfo[idx]) {
|
||||
|
||||
code = qCreateStreamExecTaskInfo(&pRSmaInfo->taskInfo[idx], param->qmsg[idx], &handle, TD_VID(pVnode), 0);
|
||||
if (!pRSmaInfo->taskInfo[idx] || (code != 0)) {
|
||||
TAOS_RETURN(TSDB_CODE_RSMA_QTASKINFO_CREATE);
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,6 @@ int32_t tqOpen(const char* path, SVnode* pVnode) {
|
|||
|
||||
int32_t tqInitialize(STQ* pTq) {
|
||||
int32_t vgId = TD_VID(pTq->pVnode);
|
||||
|
||||
int32_t code = streamMetaOpen(pTq->path, pTq, tqBuildStreamTask, tqExpandStreamTask, vgId, -1,
|
||||
tqStartTaskCompleteCallback, &pTq->pStreamMeta);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -110,7 +109,6 @@ int32_t tqInitialize(STQ* pTq) {
|
|||
}
|
||||
|
||||
streamMetaLoadAllTasks(pTq->pStreamMeta);
|
||||
|
||||
return tqMetaOpen(pTq);
|
||||
}
|
||||
|
||||
|
@ -344,7 +342,9 @@ int32_t tqProcessPollPush(STQ* pTq, SRpcMsg* pMsg) {
|
|||
.pCont = pHandle->msg->pCont,
|
||||
.contLen = pHandle->msg->contLen,
|
||||
.info = pHandle->msg->info};
|
||||
(void)tmsgPutToQueue(&pTq->pVnode->msgCb, QUERY_QUEUE, &msg);
|
||||
if (tmsgPutToQueue(&pTq->pVnode->msgCb, QUERY_QUEUE, &msg) != 0){
|
||||
tqError("vgId:%d tmsgPutToQueue failed, consumer:0x%" PRIx64, vgId, pHandle->consumerId);
|
||||
}
|
||||
taosMemoryFree(pHandle->msg);
|
||||
pHandle->msg = NULL;
|
||||
}
|
||||
|
@ -643,7 +643,6 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
|
|||
|
||||
tDecoderInit(&dc, (uint8_t*)msg, msgLen);
|
||||
ret = tDecodeSMqRebVgReq(&dc, &req);
|
||||
// decode req
|
||||
if (ret < 0) {
|
||||
goto end;
|
||||
}
|
||||
|
@ -653,7 +652,10 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
|
|||
|
||||
taosRLockLatch(&pTq->lock);
|
||||
STqHandle* pHandle = NULL;
|
||||
(void)tqMetaGetHandle(pTq, req.subKey, &pHandle); // ignore return code
|
||||
int32_t code = tqMetaGetHandle(pTq, req.subKey, &pHandle);
|
||||
if (code != 0){
|
||||
tqInfo("vgId:%d, tq process sub req:%s, no such handle, create new one", pTq->pVnode->config.vgId, req.subKey);
|
||||
}
|
||||
taosRUnLockLatch(&pTq->lock);
|
||||
if (pHandle == NULL) {
|
||||
if (req.oldConsumerId != -1) {
|
||||
|
@ -662,6 +664,7 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
|
|||
}
|
||||
if (req.newConsumerId == -1) {
|
||||
tqError("vgId:%d, tq invalid rebalance request, new consumerId %" PRId64 "", req.vgId, req.newConsumerId);
|
||||
ret = TSDB_CODE_INVALID_PARA;
|
||||
goto end;
|
||||
}
|
||||
STqHandle handle = {0};
|
||||
|
@ -740,16 +743,25 @@ int32_t tqBuildStreamTask(void* pTqObj, SStreamTask* pTask, int64_t nextProcessV
|
|||
SSchemaWrapper* pschemaWrapper = pOutputInfo->tbSink.pSchemaWrapper;
|
||||
pOutputInfo->tbSink.pTSchema = tBuildTSchema(pschemaWrapper->pSchema, pschemaWrapper->nCols, ver1);
|
||||
if (pOutputInfo->tbSink.pTSchema == NULL) {
|
||||
return -1;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pOutputInfo->tbSink.pTblInfo = tSimpleHashInit(10240, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT));
|
||||
if (pOutputInfo->tbSink.pTblInfo == NULL) {
|
||||
tqError("vgId:%d failed init sink tableInfo, code:%s", vgId, tstrerror(terrno));
|
||||
return terrno;
|
||||
}
|
||||
|
||||
tSimpleHashSetFreeFp(pOutputInfo->tbSink.pTblInfo, freePtr);
|
||||
}
|
||||
|
||||
if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) {
|
||||
SWalFilterCond cond = {.deleteMsg = 1}; // delete msg also extract from wal files
|
||||
pTask->exec.pWalReader = walOpenReader(pTq->pVnode->pWal, &cond, pTask->id.taskId);
|
||||
if (pTask->exec.pWalReader == NULL) {
|
||||
tqError("vgId:%d failed init wal reader, code:%s", vgId, tstrerror(terrno));
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
||||
streamTaskResetUpstreamStageInfo(pTask);
|
||||
|
@ -1002,9 +1014,13 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
}
|
||||
|
||||
int32_t code = tqStreamTaskProcessRunReq(pTq->pStreamMeta, pMsg, vnodeIsRoleLeader(pTq->pVnode));
|
||||
if (code) {
|
||||
tqError("vgId:%d failed to create task run req, code:%s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
// let's continue scan data in the wal files
|
||||
if (code == 0 && (pReq->reqType >= 0 || pReq->reqType == STREAM_EXEC_T_RESUME_TASK)) {
|
||||
if (pReq->reqType >= 0 || pReq->reqType == STREAM_EXEC_T_RESUME_TASK) {
|
||||
code = tqScanWalAsync(pTq, false); // it's ok to failed
|
||||
if (code) {
|
||||
tqError("vgId:%d failed to start scan wal file, code:%s", pTq->pStreamMeta->vgId, tstrerror(code));
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue