Merge branch '3.0' into cpwu/3.0

This commit is contained in:
cpwu 2022-08-04 18:49:11 +08:00
commit e10567d16b
47 changed files with 865 additions and 278 deletions

View File

@ -2,7 +2,7 @@
# taos-tools
ExternalProject_Add(taos-tools
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
GIT_TAG 8157e3b
GIT_TAG c9cc20f
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE

View File

@ -2,7 +2,7 @@
# taosws-rs
ExternalProject_Add(taosws-rs
GIT_REPOSITORY https://github.com/taosdata/taosws-rs.git
GIT_TAG 24b199e
GIT_TAG 9fa7e2f
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE

View File

@ -73,7 +73,7 @@ If `maven` is used to manage the projects, what needs to be done is only adding
<dependency>
<groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId>
<version>2.0.38</version>
<version>3.0.0</version>
</dependency>
```
@ -102,7 +102,7 @@ module goexample
go 1.17
require github.com/taosdata/driver-go/v2 develop
require github.com/taosdata/driver-go/v3 latest
```
:::note
@ -137,7 +137,7 @@ Node.js connector provides different ways of establishing connections by providi
1. Install Node.js Native Connector
```
npm i td2.0-connector
npm install @tdengine/client
```
:::note
@ -147,7 +147,7 @@ It's recommend to use Node whose version is between `node-v12.8.0` and `node-v13
2. Install Node.js REST Connector
```
npm i td2.0-rest-connector
npm install @tdengine/rest
```
</TabItem>
@ -167,7 +167,7 @@ Just need to add the reference to [TDengine.Connector](https://www.nuget.org/pac
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TDengine.Connector" Version="1.0.6" />
<PackageReference Include="TDengine.Connector" Version="3.0.0" />
</ItemGroup>
</Project>
@ -187,7 +187,7 @@ The sample code below are based on dotnet6.0, they may need to be adjusted if yo
</TabItem>
<TabItem label="R" value="r">
1. Download [taos-jdbcdriver-version-dist.jar](https://repo1.maven.org/maven2/com/taosdata/jdbc/taos-jdbcdriver/2.0.38/).
1. Download [taos-jdbcdriver-version-dist.jar](https://repo1.maven.org/maven2/com/taosdata/jdbc/taos-jdbcdriver/3.0.0/).
2. Install the dependency package `RJDBC`
```R

View File

@ -2,13 +2,18 @@ Execute TDengine CLI program `taos` directly from the Linux shell to connect to
```text
$ taos
Welcome to the TDengine shell from Linux, Client Version:2.0.5.0
Copyright (c) 2017 by TAOS Data, Inc. All rights reserved.
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
Server is Community Edition.
taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep1,keep2,keep(D) | cache(MB)| blocks | minrows | maxrows | wallevel | fsync | comp | precision | status |
=========================================================================================================================================================================================================================
test | 2020-10-14 10:35:48.617 | 10 | 1 | 1 | 1 | 2 | 3650,3650,3650 | 16| 6 | 100 | 4096 | 1 | 3000 | 2 | ms | ready |
log | 2020-10-12 09:08:21.651 | 4 | 1 | 1 | 1 | 10 | 30,30,30 | 1| 3 | 100 | 4096 | 1 | 3000 | 2 | us | ready |
Query OK, 2 row(s) in set (0.001198s)
name | create_time | vgroups | ntables | replica | strict | duration | keep | buffer | pagesize | pages | minrows | maxrows | comp | precision | status | retention | single_stable | cachemodel | cachesize | wal_level | wal_fsync_period | wal_retention_period | wal_retention_size | wal_roll_period | wal_seg_size |
=========================================================================================================================================================================================================================================================================================================================================================================================================================================================================
information_schema | NULL | NULL | 14 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
performance_schema | NULL | NULL | 3 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
db | 2022-08-04 14:14:49.385 | 2 | 4 | 1 | off | 14400m | 5254560m,5254560m,5254560m | 96 | 4 | 256 | 100 | 4096 | 2 | ms | ready | NULL | false | none | 1 | 1 | 3000 | 0 | 0 | 0 | 0 |
Query OK, 3 rows in database (0.019154s)
taos>
```

View File

@ -1,14 +1,19 @@
Go to the `C:\TDengine` directory from `cmd` and execute TDengine CLI program `taos.exe` directly to connect to the TDengine service and enter the TDengine CLI interface, for example, as follows:
```text
C:\TDengine>taos
Welcome to the TDengine shell from Linux, Client Version:2.0.5.0
Copyright (c) 2017 by TAOS Data, Inc. All rights reserved.
taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep1,keep2,keep(D) | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | precision | status |
===================================================================================================================================================================================================================================================================
test | 2020-10-14 10:35:48.617 | 10 | 1 | 1 | 1 | 2 | 3650,3650,3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | ms | ready |
log | 2020-10-12 09:08:21.651 | 4 | 1 | 1 | 1 | 10 | 30,30,30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | us | ready |
Query OK, 2 row(s) in set (0.045000s)
taos>
Welcome to the TDengine shell from Windows, Client Version:3.0.0.0
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
Server is Community Edition.
taos> show databases;
name | create_time | vgroups | ntables | replica | strict | duration | keep | buffer | pagesize | pages | minrows | maxrows | comp | precision | status | retention | single_stable | cachemodel | cachesize | wal_level | wal_fsync_period | wal_retention_period | wal_retention_size | wal_roll_period | wal_seg_size |
=========================================================================================================================================================================================================================================================================================================================================================================================================================================================================
information_schema | NULL | NULL | 14 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
performance_schema | NULL | NULL | 3 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
test | 2022-08-04 16:46:40.506 | 2 | 0 | 1 | off | 14400m | 5256000m,5256000m,5256000m | 96 | 4 | 256 |
100 | 4096 | 2 | ms | ready | NULL | false | none | 1 | 1 | 3000 | 0 | 0 | 0 | 0 |
Query OK, 3 rows in database (0.123000s)
taos>
```

View File

@ -29,7 +29,7 @@ There are two ways to install taosdump:
1. backing up all databases: specify `-A` or `-all-databases` parameter.
2. backup multiple specified databases: use `-D db1,db2,... ` parameters;
3. back up some super or normal tables in the specified database: use `-dbname stbname1 stbname2 tbname1 tbname2 ... ` parameters. Note that the first parameter of this input sequence is the database name, and only one database is supported. The second and subsequent parameters are the names of super or normal tables in that database, separated by spaces.
3. back up some super or normal tables in the specified database: use `dbname stbname1 stbname2 tbname1 tbname2 ... ` parameters. Note that the first parameter of this input sequence is the database name, and only one database is supported. The second and subsequent parameters are the names of super or normal tables in that database, separated by spaces.
4. back up the system log database: TDengine clusters usually contain a system database named `log`. The data in this database is the data that TDengine runs itself, and the taosdump will not back up the log database by default. If users need to back up the log database, users can use the `-a` or `-allow-sys` command-line parameter.
5. Loose mode backup: taosdump version 1.4.1 onwards provides `-n` and `-L` parameters for backing up data without using escape characters and "loose" mode, which can reduce the number of backups if table names, column names, tag names do not use escape characters. This can also reduce the backup data time and backup data footprint. If you are unsure about using `-n` and `-L` conditions, please use the default parameters for "strict" mode backup. See the [official documentation](/taos-sql/escape) for a description of escaped characters.
@ -104,7 +104,10 @@ Usage: taosdump [OPTION...] dbname [tbname ...]
use letter and number only. Default is NOT.
-n, --no-escape No escape char '`'. Default is using it.
-T, --thread-num=THREAD_NUM Number of thread for dump in file. Default is
5.
8.
-C, --cloud=CLOUD_DSN specify a DSN to access TDengine cloud service
-R, --restful Use RESTful interface to connect TDengine
-t, --timeout=SECONDS The timeout seconds for websocket to interact.
-g, --debug Print debug info.
-?, --help Give this help list
--usage Give a short usage message

View File

@ -16,6 +16,7 @@ The following preparations are required for EMQX to add TDengine data sources co
Depending on the current operating system, users can download the installation package from the [EMQX official website](https://www.emqx.io/downloads) and execute the installation. After installation, use `sudo emqx start` or `sudo systemctl start emqx` to start the EMQX service.
Note: this chapter is based on EMQX v4.4.5. Other version of EMQX probably change its user interface, configuration methods or functions.
## Create Database and Table
@ -31,7 +32,7 @@ Note: The table schema is based on the blog [(In Chinese) Data Transfer, Storage
## Configuring EMQX Rules
Since the configuration interface of EMQX differs from version to version, here is v4.4.3 as an example. For other versions, please refer to the corresponding official documentation.
Since the configuration interface of EMQX differs from version to version, here is v4.4.5 as an example. For other versions, please refer to the corresponding official documentation.
### Login EMQX Dashboard

View File

@ -8,9 +8,9 @@ library("rJava")
library("RJDBC")
args<- commandArgs(trailingOnly = TRUE)
driver_path = args[1] # path to jdbc-driver for example: "/root/taos-jdbcdriver-2.0.37-dist.jar"
driver_path = args[1] # path to jdbc-driver for example: "/root/taos-jdbcdriver-3.0.0-dist.jar"
driver = JDBC("com.taosdata.jdbc.TSDBDriver", driver_path)
conn = dbConnect(driver, "jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata")
dbGetQuery(conn, "SELECT server_version()")
dbDisconnect(conn)
# ANCHOR_END: demo
# ANCHOR_END: demo

View File

@ -74,7 +74,7 @@ TDengine 提供了丰富的应用程序开发接口,为了便于用户快速
<dependency>
<groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId>
<version>2.0.38</version>
<version>3.0.0</version>
</dependency>
```
@ -103,7 +103,7 @@ module goexample
go 1.17
require github.com/taosdata/driver-go/v2 develop
require github.com/taosdata/driver-go/v3 latest
```
:::note
@ -138,7 +138,7 @@ Node.js 连接器通过不同的包提供不同的连接方式。
1. 安装 Node.js 原生连接器
```
npm i td2.0-connector
npm install @tdengine/client
```
:::note
@ -148,7 +148,7 @@ Node.js 连接器通过不同的包提供不同的连接方式。
2. 安装 Node.js REST 连接器
```
npm i td2.0-rest-connector
npm install @tdengine/rest
```
</TabItem>
@ -168,7 +168,7 @@ Node.js 连接器通过不同的包提供不同的连接方式。
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TDengine.Connector" Version="1.0.6" />
<PackageReference Include="TDengine.Connector" Version="3.0.0" />
</ItemGroup>
</Project>
@ -188,7 +188,7 @@ dotnet add package TDengine.Connector
</TabItem>
<TabItem label="R" value="r">
1. 下载 [taos-jdbcdriver-version-dist.jar](https://repo1.maven.org/maven2/com/taosdata/jdbc/taos-jdbcdriver/2.0.38/)。
1. 下载 [taos-jdbcdriver-version-dist.jar](https://repo1.maven.org/maven2/com/taosdata/jdbc/taos-jdbcdriver/3.0.0/)。
2. 安装 R 的依赖包`RJDBC`
```R

View File

@ -16,72 +16,96 @@ description: "支持用户编码的聚合函数和标量函数,在查询中嵌
用户可以按照下列函数模板定义自己的标量计算函数
`void udfNormalFunc(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBuf, char* tsOutput, int* numOfOutput, short otype, short obytes, SUdfInit* buf)`
`int32_t udf(SUdfDataBlock* inputDataBlock, SUdfColumn *resultColumn)`
其中 udfNormalFunc 是函数名的占位符,以上述模板实现的函数对行数据块进行标量计算,其参数项是固定的,用于按照约束完成与引擎之间的数据交换
其中 udf 是函数名的占位符,以上述模板实现的函数对行数据块进行标量计算。
- udfNormalFunc 中各参数的具体含义是:
- data输入数据。
- itype输入数据的类型。这里采用的是短整型表示法与各种数据类型对应的值可以参见 [column_meta 中的列类型说明](/reference/rest-api/)。例如 4 用于表示 INT 型。
- iBytes输入数据中每个值会占用的字节数。
- numOfRows输入数据的总行数。
- ts主键时间戳在输入中的列数据(只读)。
- dataOutput输出数据的缓冲区缓冲区大小为用户指定的输出类型大小 \* numOfRows。
- interBuf中间计算结果的缓冲区大小为用户在创建 UDF 时指定的 BUFSIZE 大小。通常用于计算中间结果与最终结果不一致时使用,由引擎负责分配与释放。
- tsOutput主键时间戳在输出时的列数据如果非空可用于输出结果对应的时间戳。
- numOfOutput输出结果的个数行数
- oType输出数据的类型。取值含义与 itype 参数一致。
- oBytes输出数据中每个值占用的字节数。
- buf用于在 UDF 与引擎间的状态控制信息传递块。
[add_one.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/add_one.c) 是结构最简单的 UDF 实现,也即上面定义的 udfNormalFunc 函数的一个具体实现。其功能为:对传入的一个数据列(可能因 WHERE 子句进行了筛选)中的每一项,都输出 +1 之后的值,并且要求输入的列数据类型为 INT。
- scalarFunction 中各参数的具体含义是:
- inputDataBlock: 输入的数据块
- resultColumn: 输出列
### 聚合函数
用户可以按照如下函数模板定义自己的聚合函数。
`void abs_max_merge(char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput, SUdfInit* buf)`
`int32_t udf_start(SUdfInterBuf *interBuf)`
其中 udfMergeFunc 是函数名的占位符,以上述模板实现的函数用于对计算中间结果进行聚合,只有针对超级表的聚合查询才需要调用该函数。其中各参数的具体含义是:
`int32_t udf(SUdfDataBlock* inputBlock, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf)`
- dataudfNormalFunc 的输出数据数组,如果使用了 interBuf 那么 data 就是 interBuf 的数组。
- numOfRowsdata 中数据的行数。
- dataOutput输出数据的缓冲区大小等于一条最终结果的大小。如果此时输出还不是最终结果可以选择输出到 interBuf 中即 data 中。
- numOfOutput输出结果的个数行数
- buf用于在 UDF 与引擎间的状态控制信息传递块。
`int32_t udf_finish(SUdfInterBuf* interBuf, SUdfInterBuf *result)`
其中 udf 是函数名的占位符。其中各参数的具体含义是:
[abs_max.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/abs_max.c) 实现的是一个聚合函数,功能是对一组数据按绝对值取最大值。
- interBuf中间结果 buffer。
- inputBlock输入的数据块。
- newInterBuf新的中间结果buffer。
- result最终结果。
其计算过程为:与所在查询语句相关的数据会被分为多个行数据块,对每个行数据块调用 udfNormalFunc在本例的实现代码中实际函数名是 `abs_max`)来生成每个子表的中间结果,再将子表的中间结果调用 udfMergeFunc本例中其实际的函数名是 `abs_max_merge`)进行聚合,生成超级表的最终聚合结果或中间结果。聚合查询最后还会通过 udfFinalizeFunc本例中其实际的函数名是 `abs_max_finalize`)再把超级表的中间结果处理为最终结果,最终结果只能含 0 或 1 条结果数据。
他典型场景,如协方差的计算,也可通过定义聚合 UDF 的方式实现
计算过程为首先调用udf_start生成结果buffer然后相关的数据会被分为多个行数据块对每个行数据块调用 udf 用数据块更新中间结果,最后再调用 udf_finish 从中间结果产生最终结果,最终结果只能含 0 或 1 条结果数据
### 最终计算
### UDF 初始化和销毁
`int32_t udf_init()`
用户可以按下面的函数模板实现自己的函数对计算结果进行最终计算,通常用于有 interBuf 使用的场景。
`int32_t udf_destroy()`
`void abs_max_finalize(char* dataOutput, char* interBuf, int* numOfOutput, SUdfInit* buf)`
其中 udfFinalizeFunc 是函数名的占位符 ,其中各参数的具体含义是:
- dataOutput输出数据的缓冲区。
- interBuf中间结算结果缓冲区可作为输入。
- numOfOutput输出数据的个数对聚合函数来说只能是 0 或者 1。
- buf用于在 UDF 与引擎间的状态控制信息传递块。
## UDF 实现方式的规则总结
三类 UDF 函数: udfNormalFunc、udfMergeFunc、udfFinalizeFunc ,其函数名约定使用相同的前缀,此前缀即 udfNormalFunc 的实际函数名,也即 udfNormalFunc 函数不需要在实际函数名后添加后缀而udfMergeFunc 的函数名要加上后缀 `_merge`、udfFinalizeFunc 的函数名要加上后缀 `_finalize`,这是 UDF 实现规则的一部分,系统会按照这些函数名后缀来调用相应功能。
根据 UDF 函数类型的不同,用户所要实现的功能函数也不同:
- 标量函数UDF 中需实现 udfNormalFunc。
- 聚合函数UDF 中需实现 udfNormalFunc、udfMergeFunc对超级表查询、udfFinalizeFunc。
其中 udf 是函数名的占位符。udf_init 完成初始化工作。 udf_destroy 完成清理工作。
:::note
如果对应的函数不需要具体的功能,也需要实现一个空函数。
:::
### UDF 数据结构
```c
typedef struct SUdfColumnMeta {
int16_t type;
int32_t bytes;
uint8_t precision;
uint8_t scale;
} SUdfColumnMeta;
typedef struct SUdfColumnData {
int32_t numOfRows;
int32_t rowsAlloc;
union {
struct {
int32_t nullBitmapLen;
char *nullBitmap;
int32_t dataLen;
char *data;
} fixLenCol;
struct {
int32_t varOffsetsLen;
int32_t *varOffsets;
int32_t payloadLen;
char *payload;
int32_t payloadAllocLen;
} varLenCol;
};
} SUdfColumnData;
typedef struct SUdfColumn {
SUdfColumnMeta colMeta;
bool hasNull;
SUdfColumnData colData;
} SUdfColumn;
typedef struct SUdfDataBlock {
int32_t numOfRows;
int32_t numOfCols;
SUdfColumn **udfCols;
} SUdfDataBlock;
typedef struct SUdfInterBuf {
int32_t bufLen;
char* buf;
int8_t numOfResult; //zero or one
} SUdfInterBuf;
```
为了更好的操作以上数据结构,提供了一些便利函数,定义在 taosudf.h。
## 编译 UDF
用户定义函数的 C 语言源代码无法直接被 TDengine 系统使用,而是需要先编译为 动态链接库,之后才能载入 TDengine 系统。

View File

@ -0,0 +1,481 @@
---
sidebar_label: 错误码
title: TDengine C/C++ 连接器错误码
---
本文中详细列举了在使用 TDengine C/C++ 连接器时客户端可能得到的错误码以及所要采取的相应动作。其它语言的连接器在使用原生连接方式时也会所得到的返回码返回给连接器的调用者。
| **Error Code** | **说明** | 如何处理错误 |
| -------------- | ------------------ | ------------ |
| 0 | 请求处理成功 | None |
| -1 | 请求失败,未知原因 | TODO |
| 0x0003 | RPC 认证失败 | TODO |
| 0x0004 | RPC 重定向 |TODO|
| 0x000B | 无法建立连接 |TODO|
| 0x0015 | FQDN 解析失败 |检查各个dnode配置的FQDN是否正确并且能够从其它节点 ping 到 |
| 0x0017 | 端口已经被占用 | 检查所配置的端口被哪个进程占用,关闭该进程以释放端口;或者更改配置使用另一端口号 |
| 0x0018 | 连接被断开 | 检查 dnode 进程是否还在,如果无异常检查网络情况 |
| 0x0013 | 客户端和服务端的时间未同步 | 检查客户端和服务端的时间设置是否同步|
| 0x0014 | 数据库不可用 |检查数据库是否存在检查数据库的vgroups的状态 |
| 0x0100 | 该操作不支持 | 参考SQL手册使用正确的操作 |
| 0x0102 | 无法分配内存,系统内存耗尽 | 检查系统中内存被耗尽的原因,采取措施释放内存。如果内存是被 dnode 耗尽的话重启该进程 |
| 0x0104 | 文件被破坏 | TODO |
| 0x0111 | 操作在进行中 | 等待该操作完成 |
| 0x0115 | 无效的消息 | TODO |
| 0x0116 | 无效的消息长度 | TODO |
| 0x0117 | 无效指针 | TODO |
| 0x0118 | 无效参数 | |
| 0x0119 | 无效配置 | 检查配置参数的值是否在合法值域范围内 |
| 0x011A | 无效选项 | 检查配置中是否有不支持的无效配置项 |
| 0x011B | 无效的JSON 格式 | 修正插入数据中的JSON值|
| 0x011C | 无效版本号 | 检查客户端版本是否匹配,更换正确的客户端 |
| 0x011D | 无效版本信息 | 检查客户端版本是否匹配,更换正确的客户端 |
| 0x011E | 版本不匹配 | TODO |
| 0x011F | 校验和错误 | TODO |
| 0x0120 | 数据压缩失败 | TODO |
| 0x0121 | 消息未处理 | TODO |
| 0x0122 | 配置未找到 | TODO|
| 0x0123 | 重复初始化 | TODO |
| 0x0124 | 无法将重复的key加入hash| TODO |
| 0x0125 | 需要重试 | 重试 |
| 0x0126 | RPC 队列内存耗尽 | TODO |
| 0x0127 | 无效的时间戳 | 修正插入数据 |
| 0x0128 | 消息解码失败 | 检查客户端版本是否匹配和兼容 |
| 0x0129 | 磁盘耗尽 | TODO |
| 0x012A | TODO | TODO |
| 0x0200 | 无效操作 | 检查SQL命令根据SQL手册使用正确的操作|
| 0x0201 | 无效的查询句柄 | TODO |
| 0x0202 | 无效的客户端/服务端时间组合 | TODO |
| 0x0203 | 无效值 | TODO |
| 0x0204 | 无效的客户端版本 | 检查客户端版本是否匹配,更换为正确的客户端版本 |
| 0x0205 | TODO | TODO |
| 0x0206 | 无效的 FQDN | 检查服务器 fqdn 配置是否正确,是否能够从其它服务器访问到该 fqdn |
| 0x0207 | 用户名长度过长 | 检查用户名长度是否过长 |
| 0x0208 | 密码长度过长 | 检查密码长度是否过长 |
| 0x0209 | 数据库名字长度过长 | 检查数据库名是否过长 |
| 0x020A | 表名长度过长 | 检查表名是否过长 |
| 0x020B | 无效连接 | 检查该连接是否已经断开 |
| 0x020C | 系统内存耗尽 | 检查系统中内存被耗尽的原因,尝试释放出内存 |
| 0x020D | 磁盘空间耗尽 | 检查系统中磁盘耗尽的原因,尝试释放或增加磁盘空间 |
| 0x020E | 查询缓存被清除 |TODO |
| 0x020F | 查询已经被结束 | 尝试优化查询条件再重启查询 |
| 0x0210 | 结果集过大无法存储 | 尝试优化查询条件,缩小结果集,再重启查询 |
| 0x0211 | 数据库不可用 | 查看数据库是否存在,查看数据库的 vgroups 状态 |
| 0x0212 | 操作正在进行中 | 等待操作完成 |
| 0x0213 | 连接被服务端断开 | 查看服务端进程是否发生 crash 等异常终止情况 |
| 0x0214 | 没有写权限 | 只进行读操作或者尝试获取写权限 |
| 0x0215 | 连接被 kill | 重新建立连接 |
| 0x0216 | SQL 语法错误 | 参考 SQL手册纠正语法错误再重试 |
| 0x0217 | 未指定数据库或者指定的数据库不可用 | 指定数据库,或者检查指定数据库的状态 |
| 0x0218 | 所查询的表不存在 | 确认表名后纠正查询语句 |
| 0x0219 | SQL 语句超长 | 根据 maxSQLLength 缩短SQL语句或者加大maxSQLLength (如果还未配置到上限)|
| 0x021A | 空文件 | TODO |
| 0x021B | Line 协议语法错误 | 纠正插入语句 |
| 0x021C | 元数据未被缓存 | TODO |
| 0x021D | 重复的列名 | 纠正SQL语句中的相应错误 |
| 0x021E | tag 过长 | 纠正过长的 tag |
| 0x021F | 列名过长 | 纠正过长的列名 |
| 0x0220 | 重复的表名**TODO** | TODO|
| 0x0221 | JSON 格式错误 | 纠正错误的 JSON 结构 |
| 0x0222 | JSON 中使用了无效的数据类型 | 纠正 JSON 结构中的错误 |
| 0x0224 | 超出了所支持的值域 | 纠正到值域范围内 |
| 0x0229 | 无效的 tsc 输入 **TODO** | TODO |
| 0x022A | stmt API 使用错误 | 根据参考手册正确使用 |
| 0x022B | stmt 使用时未指定表名 | 指定表名 |
| 0x022C | 不支持 stmt 子名 | 根据参考手册纠正错误用法 |
| 0x022D | 查询被 kill | 优化查询语句,尽量减小计算量和结果集,然后重新启动查询 |
| 0x022E | 在当前配置的查询策略下没有可用的计算节点 | 创建新的 qnode |
| 0x022F | 所指定的表不是超级表 | 确认下该查询场景适用于超级表还是子表/普通表,如果是前者则纠正为超级表名 |
| 0x0303 | 没有权限进行所发起的操作 | 申请权限或调整操作 |
| 0x0304 | 管理节点内部错误 | TODO |
| 0x0305 | 无效连接 | TODO |
| 0x030B | 所要展示的操作其数据已经因为超时而被删除 | 更换想要展示操作或者放弃此次操作 |
| 0x030C | 无效的查询ID| 确认正确的查询ID再重新发起 |
| 0x030D | 无效的流ID| 确认正确的流ID再重新发起|
| 0x030E | 无效的连接ID| 确认正确的连接ID再重新发起|
| 0x0310 | mnode已经在运行 | 无须采取任何动作 |
| 0x0311 | 配置同步失败 | TODO |
| 0x0312 | 无法启动同步 | TODO |
| 0x0313 | 无法创建 mnode 对应的目录 | 确认磁盘上是否有可用空间以及是否有相应的写权限 |
| 0x0314 | 启动组件失败 | TODO |
| 0x0315 | 用户帐号被禁用 | 联系管理员激活该帐号 |
| 0x0320 | 元数据中已经存在所要创建的对象 | 检查所要创建的对象,比如超级表或表,是否已经存在 |
| 0x0321 | 元数据库中非预期的一般性错误 | TODO |
| 0x0322 | 无效的表类型 | TODO |
| 0x0323 | 所要查找的对象不存在 | TODO |
| 0x0325 | 无效的 key 类型 | TODO |
| 0x0326 | 无效的动作类型 | TODO |
| 0x0327 | 无效的状态类型 | TODO |
| 0x0328 | 无效的原始数据版本 | TODO |
| 0x0329 | 无效的原始数据长度 | TODO |
| 0x032A | 无效的原始数据内容 | TODO |
| 0x032B | 无效的 wal 版本 | TODO |
| 0x032C | 对象创建中 | TODO |
| 0x032D | 对象停止中 | TODO |
| 0x0330 | dnode 已经存在 | 无需任何动作放弃重复创建dnode的操作 |
| 0x0331 | dnode 不存在 | 确认所要查询或者操作的dnode ID 或者 end point 是否正确 |
| 0x0332 | vgroup 不存在 | 确认所要查询或者操作的vgroup ID 是否正确 |
| 0x0333 | 系统拒绝 drop 其角色是 leader 的 mnode | 放弃该操作 |
| 0x0334 | 没有足够的 dnode 创建所指定的 vgroups | 增加 dnode 或者修改现有dnode的配置参数 `supportVgroups` |
| 0x0335 | 集群中各个dnode的配置不一致 | 检查各个dnode的配置参数确保其一致 |
| 0x0338 | 所要查询或操作的vgroup不在所指定的dnode中| 检查vgroup ID 和 dnode ID是否正确 |
| 0x0339 | 所要查询或操作的 vgroup 已经在所指定的dnode中 | 检查 vgroup ID 和 dnode ID是否正确 |
| 0x033B | 集群 ID 不匹配 | TODO |
| 0x0340 | 该帐户已经存在 | 放弃重复创建帐户的操作 |
| 0x0342 | 无效的帐户选项 | 检查创建帐户时的参数选项是否正确 |
| 0x0343 | 帐户授权已经过期 | 联系管理员重新授权 |
| 0x0344 | 无效帐户 | 联系管理员确认帐户 |
| 0x0345 | 操作的帐户过多,无法支持 | 减少同时操作的帐户数 |
| 0x0350 | 用户已经存在 | 放弃重复创建用户的操作 |
| 0x0351 | 无效用户 | 检查并确认正确用户 |
| 0x0352 | 无效的用户名格式 | 查看参考手册修改用户名 |
| 0x0353 | 无效的密码格式 | 查看参考手册修改密码 |
| 0x0354 | 无法从连接中获取用户名 | 检查客户端环境初始化是否使用了正确的用户名 |
| 0x0355 | 一次尝试操作的用户过多 | 查看参考手册减少同时操作的用户数 |
| 0x0356 | 无效的修改操作 | 查看参考手册使用正确的操作 |
| 0x0357 | 认证失败 | 使用正确的用户名和密码 |
| 0x0360 | 要创建的超级表已经存在 | 放弃重复创建的操作或者删除该超级表再重新创建 |
| 0x0362 | 所使用或查询的超级表不存在 | 确认超级表名是否正确,如果正确则需要先创建超级表 |
| 0x0364 | 标签过多 | 查看参考手册减少标签数量 |
| 0x0365 | 列过多 | 查看参考手册减少列数量 |
| 0x0369 | 要添加的标签已经存在 | 修改标签名 |
| 0x036A | 要查询或修改的标签不存在 | 确认标签名是否正确 |
| 0x036B | 要添加的列已经存在 | 修改列名或者放弃该操作 |
| 0x036C | 要查询或修改的列不存在 | 确认列名是否正确 |
| 0x036E | 无效的超级表操作 | 查看参考手册进行正确的操作 |
| 0x036F | 错误的行字节数 | TODO |
| 0x0370 | 无效的函数名 | 确认函数名是否正确 |
| 0x0372 | 无效的函数代码 | 无效的函数编码 |
| 0x0373 | 该函数已经存在 | 修改函数名或者放弃该操作|
| 0x0374 | 所引用的函数不存在 | 确认函数名是否正确 |
| 0x0375 | 无效的 bufSize | 查看参考手册修改 bufSize |
| 0x0378 | 无效的函数注释 | 查看参考手册修改函数注释 |
| 0x0379 | 无效的函数检索消息 | TODO |
| 0x0380 | 未指定数据库或者指定的数据库不可用 | 指定数据库,或者检查所指定的数据库的状态 |
| 0x0381 | 数据库已经存在 | 放弃重复创建,或者修改数据库名 |
| 0x0382 | 无效的数据库参数 | 查看参考手册使用正确的参数 |
| 0x0383 | 无效的数据库名称 | 查看参考手册使用正确的数据库名 |
| 0x0385 | 该帐号下的数据库过多 | 删除旧的数据库再尝试创建新数据库 |
| 0x0388 | 数据库不存在 | 确认数据库名是否正确 |
| 0x0389 | 无效的数据库帐户 | 确认帐户是否正确 |
| 0x038A | 数据库参数未修改 | 查看参考手册确认修改的参数和值是否正确 |
| 0x038B | 索引不存在 |确认索引名称是否正确 |
| 0x039A | 无效的系统表名 | 查看参考手册确认表名是否正确 |
| 0x03A0 | mnode 已经存在 | 放弃该操作 |
| 0x03A1 | mnode 不存在 | 确认要查看或操作的 mnode ID |
| 0x03A2 | qnode 已经存在 | 放弃该操作 |
| 0x03A3 | qnode 不存在 | 确认要查看或操作的 qnode ID 是否正确 |
| 0x03A8 | mnode 的 replica 不能小于1 | 停止 drop mnode |
| 0x03A9 | mnode 的 replica 不能大于3 | 停止 create mnode |
| 0x03B0 | dnode 数量过多 | 停止添加新的 dnode |
| 0x03B1 | dnode 没有足够的可用内存 | 检查所在系统的内存使用情况 ,尝试释放出内存 |
| 0x03B2 | 无效的 dnode 配置 | 查看参考手册纠正配置 |
| 0x03B3 | 无效的 dnode 地址 | 确认 dnode 的 FQDN 和 serverPort参数是否正确 |
| 0x03B4 | 无效的 dnode ID | 确认正确的 dnode ID |
| 0x03B5 | vgroup 的分布未发生变化 | TODO |
| 0x03B6 | 存在状态为 offline 的 dnode | drop 这些 dnode 或者启动相应的 dnode 使其状态为 ready |
| 0x03B7 | 无效的 vgroup 副本 | TODO |
| 0x03C0 | topic 与超级表冲突 | TODO |
| 0x03C1 | 订阅了过多的超级表 | 查看参考手册减少超级表数量 |
| 0x03C2 | 无效的 超级表修改参数 | 查看参考手册进行纠正 |
| 0x03C3 | 超级表参数未被修改 | 查看参考手册确认参数是否正确 |
| 0x03C4 | 该字段被某个主题所使用 | TODO |
| 0x03C5 | 该数据库是单超级表模式 | 修改数据库为多超级表模式或者放弃创建新的超级表 |
| 0x03C6 | 修改超级表使用了无效的 schema 版本 | TODO |
| 0x03C7 | 修改超级表使用了无效的超级表 ID | 确认超级表使用是否正确 |
| 0x03C8 | 该字段被 tsma 所使用 | TODO |
| 0x03D0 | 该事务已经存在 | TODO |
| 0x03D1 | 该事务不存在 | TODO |
| 0x03D2 | 要 kill 的 stage 不存在 | TODO |
| 0x03D3 | 冲突的事务没有完成 | TODO |
| 0x03D4 | 未知的事务错误 | TODO |
| 0x03D5 | 事务提交日志已满 | TODO |
| 0x03DF | 在执行事务时无法建立连接 | 等待事务完成尝试重新建立连接 |
| 0x03E0 | Topic 已经存在 | 修改 topic 名字或者放弃创建重复的 topic |
| 0x03E1 | Topic 不存在 | 确认 Topic 名字是否正确 |
| 0x03E2 | Topic 过多 | 尝试删除不用的 topic 再建立新的,或者放弃此次操作 |
| 0x03E3 | 无效的 Topic | 确认 Topic 是否正确 |
| 0x03E4 | 建立 Topic 的查询子名无效 | 查看参考手册纠正查询子名 |
| 0x03E5 | 建立 Topic 的参数无效 | 查看参考手册使用正确的参数 |
| 0x03E6 | 消费者不存在 | 确认正确的消费者 ID |
| 0x03E7 | 消费者未修改 | TODO |
| 0x03E8 | 订阅不存在 | 确认正确的订阅 ID |
| 0x03E9 | 偏移量不存在 | 纠正偏移量 |
| 0x03EA | 消费者不可用 | TODO |
| 0x03EB | 无法删除已经被订阅的 Topic | 先取消订阅再尝试删除 |
| 0x03EC | Consumer group正在被某些消费者使用 | TODO |
| 0x03F0 | 流已经存在 | 修改流名称或者放弃创建该流 |
| 0x03F1 | 要查询或操作的流不存在 | 确认正确的流 ID |
| 0x03F2 | 无效的流参数 | 查看参考手册纠正错误的参数 |
| 0x0480 | SMA 已经存在 | 修改 SMA 名称或者放弃创建 |
| 0x0481 | SMA 不存在 | 确认正确的 SMA 名称或者 ID |
| 0x0482 | SMA 参数错误 | 查看参考手册纠正参数 |
| 0x0408 | 节点不在线 | TODO |
| 0x0409 | 节点已经部署 | TODO |
| 0x040A | 节点未部署 | TODO |
| 0x0500 | 该动作作在进行中| TODO |
| 0x0501 | 消息未被处理 | TODO |
| 0x0502 | 该动作需要被重新处理 | TODO |
| 0x0503 | 无效的 vgroup ID | 检查确认正确的 vgroups ID |
| 0x0504 | vnode 初始化失败 | TODO |
| 0x0505 | 系统磁盘空间耗尽 | 尝试释放或者增加磁盘空间 |
| 0x0506 | 对磁盘文件没有写权限 | 检查启动 TDengine 的系统帐号的写权限 |
| 0x0507 | 数据文件缺失 | TODO |
| 0x0508 | vnode 没有可用内存 | TODO |
| 0x0509 | vnode 中未预期的一般性错误 | TODO |
| 0x050C | 数据库无空闲内存 | TODO |
| 0x050D | 数据库正在删除中 | TODO |
| 0x050E | 数据库正在更新中 | TODO |
| 0x0510 | 数据库正在关闭中 | TODO |
| 0x0511 | 数据库被暂停操作 | TODO |
| 0x0512 | 数据库写操作被拒绝 | 检查用户权限,申请写操作授权 |
| 0x0513 | 数据库正在同步中 | TODO |
| 0x0514 | 无效的 tsdb 状态 | TODO |
| 0x0520 | 指定的表不存在 | 检查确认正确的表名 |
| 0x0521 | 指定的SMA 不存在 | 检查确认正确的 SMA名称 |
| 0x0522 | Hash 值不匹配 | TODO |
| 0x0523 | 指定的表不存在 | 检查确认正确的表名 |
| 0x0524 | 无效的表动作 | TODO |
| 0x0525 | 列名已经存在 | 修改列名或放弃操作 |
| 0x0526 | 列名不存在 | 确认正确的列名 |
| 0x0527 | 该列已经被订阅 | 先取消订阅再操作或者放弃操作 |
| 0x0528 | 无效的配置文件 | 检查配置文件的路径和访问权限 |
| 0x0529 | 无效的 term 文件 | TODO |
| 0x0600 | 无效的表 ID | 确认表名是否正确 |
| 0x0601 | 无效的表 类型 | TODO |
| 0x0602 | 无效的 schema 版本 | TODO |
| 0x0603 | 表已经存在 | 修改表名或放弃操作 |
| 0x0604 | 配置无效 | 查看参考手册纠正配置 |
| 0x0605 | TSDB 初始化失败 | TODO |
| 0x0606 | 磁盘空间耗尽 | 查看磁盘空间耗尽的原因,尝试释放或增加磁盘空间 |
| 0x0607 | 磁盘文件没有访问权限 | 确认启动集群的系统帐户是否有相应的写权限 |
| 0x0608 | 数据文件被破坏 | TODO |
| 0x0609 | 内存耗尽 | 检查内存被耗尽的原因,尝试释放内存 |
| 0x060A | 标签版本过老 | TODO |
| 0x060B | 时间戳不在允许范围内 | 查看参考手册了解允许写入的时间戳规则 |
| 0x060C | 提交消息被破坏 | TODO |
| 0x060D | 无效操作 | TODO |
| 0x060E | 建表消息无效 | TODO |
| 0x060F | 内存跳表中没有表的数据 | TODO |
| 0x0610 | 文件已经存在 | TODO |
| 0x0611 | 需要重新配置该表 | TODO |
| 0x0612 | 建表的信息无效 | TODO |
| 0x0613 | 磁盘空间耗尽 | 尝试释放或增加磁盘空间 |
| 0x0614 | 消息被破坏 |TODO |
| 0x0615 | 无效的标签值 | 修正标签值 |
| 0x0616 | 未缓存最后一行的原始数据 | 修改数据库的 cacheModel 参数 |
| 0x0618 | 该表不存在 | 检查表名是否正确 |
| 0x0619 | 超级表已经存在 | 修改超级表名再次尝试 |
| 0x061A | 超级表不存在 | 检查超级表名是否正确 |
| 0x061B | 表被重新创建 | TODO |
| 0x061C | TDB 环境打开错误 | N/A |
| 0x0700 | 无效的查询句柄 | N/A |
| 0x0701 | 无效的消息 | TODO |
| 0x0702 | 磁盘空间耗尽 | 尝试释放或增加磁盘空间 |
| 0x0703 | 系统内存耗尽 | 尝试释放内存 |
| 0x0704 | 未知错误 | TODO |
| 0x0705 | 重复的 Join Key | 修正查询语句中的 Join Key |
| 0x0706 | 标签过滤条件过多 | 减小查询语句中的标签过滤条件 |
| 0x0707 | 查询不可用 | TODO |
| 0x0708 | TODO | TODO |
| 0x0709 | TODO | TODO |
| 0x070A | 查询中的时间窗口过多 | 修改查询语句以减小时间窗口的数量 |
| 0x070B | 查询缓冲区达到上限 | TODO |
| 0x070C | 多副本数据不一致 | TODO |
| 0x070D | 系统错误 | TODO |
| 0x070E | 无效的时间范围 | 修正查询语句中的时间范围 |
| 0x070F | 无效输入 | 修正查询语句 |
| 0x0720 | 调度器不存在 | TODO |
| 0x0721 | 任务不存在 | TODO |
| 0x0722 | 任务已经存在 | TODO |
| 0x0723 | 任务上下文不存在 | TODO |
| 0x0724 | 任务被取消 | TODO |
| 0x0725 | 任务被停止 | TODO |
| 0x0726 | 任务正在取消中 | TODO |
| 0x0727 | 任务正在停止中 | TODO |
| 0x0728 | 重复操作 | TODO |
| 0x0729 | 任务消息错误 | TODO |
| 0x072A | 作业已经被释放 | TODO |
| 0x072B | 任务状态错误 | TODO |
| 0x072C | in 和 not in 操作符不支持 JSON 类型 | 修正查询语句 |
| 0x072D | 此处不支持 JSON |修正查询语句 |
| 0x072E | group 和 partition by 不支持 JSON 类型 |
| 0x072F | 查询作业不存在 | TODO |
| 0x0800 | License 已经过期 | 重新激活或获取 License |
| 0x0801 | 受限于 License 无法创建 dnode | 获取新的License |
| 0x0802 | 受限于 License 无法创建帐户 | 获取新的 License |
| 0x0803 | 受限于 License 无法创建表 | 获取新的 License |
| 0x0804 | 受限于 License 无法创建数据库 | 获取新的 License |
| 0x0805 | 受限于 License 无法创建用户 | 获取新的 License |
| 0x0806 | 受限于 License 无法创建连接 | 获取新的 License |
| 0x0807 | 受限于 License 无法创建流 | 获取新的 License |
| 0x0808 | 写入速度受限于 License | 获取新的 License |
| 0x0809 | 存储容量受限于 License | 获取新的 License |
| 0x080A | 查询时间受限于 License | 获取新的 License |
| 0x080B | CPU 核数受限于 License | 获取新的 License |
| 0x080C | 受限于 License 无法创建超级表 | 获取新的 License |
| 0x080D | 受限于 License 无法创建表 | 获取新的 License |
| 0x0A00 | TQ 无效配置 | TODO |
| 0x0A01 | TQ 初始化失败 | TODO |
| 0x0A02 | TQ 磁盘空间耗尽 | 尝试释放或增加磁盘空间 |
| 0x0A03 | TQ 没有写磁盘权限 | 确认启动集群的系统帐号是否具有写磁盘权限 |
| 0x0A04 | TQ 文件被破坏 | TODO |
| 0x0A05 | TQ 内存耗尽 | 尝试释放内存 |
| 0x0A06 | TQ 文件已经存在 | TODO |
| 0x0A07 | TQ 创建目录失败 | TODO |
| 0x0A08 | TQ meta 中不存在该 key | TODO |
| 0x0A09 | meta key在事务中不存在 | TODO |
| 0x0A0A | meta key在事务中重复 | TODO |
| 0x0A0B | 消费组不存在 | 指定正确的消费组 |
| 0x0A0C | 该表的 schema 不存在 | 确认表名是否正确 |
| 0x0A0D | 没有已经提交的 offset | TODO |
| 0x1000 | WAL 未知错误 | TODO |
| 0x1001 | WAL 文件被破坏 | TODO |
| 0x1002 | WAL 大小超出上限 | TODO |
| 0x1003 | WAL 使用了错误的版本号 | TODO |
| 0x1004 | 系统内存耗尽 | 尝试释放内存 |
| 0x1005 | WAL 日志不存在 | TODO |
| 0x2201 | 无效的 mount 配置 | 修正 mount 配置参数 |
| 0x2202 | mount 点过多 | TODO |
| 0x2203 | 重复的 primary mount | TODO |
| 0x2204 | primary mount 缺失 | TODO |
| 0x2205 | no mount at tier: TODO | TODO |
| 0x2206 | 文件已经存在 | 更改文件名或者删除该文件 |
| 0x2207 | 无效的级别 | TODO |
| 0x2208 | 没有可用磁盘 | TODO |
| 0x220F | 系统内存耗尽 | TODO |
| 0x2400 | catalog 内部错误 | TODO |
| 0x2401 | 无效的 catalog 输入参数 | TODO |
| 0x2402 | catalog 不可用 | TODO |
| 0x2403 | catalog 系统错误 | TODO |
| 0x2404 | 数据库被删除 | TODO |
| 0x2405 | catalog 不可用 | TODO |
| 0x2406 | 表元数据和 vgroup 不匹配 | TODO |
| 0x2407 | catalog 不存在 | TODO |
| 0x2550 | 无效的消息顺序 | TODO |
| 0x2501 | 调度器状态错误 | TODO |
| 0x2502 | 调度器内部错误 | TODO |
| 0x2504 | 任务超时 | TODO |
| 0x2505 | 作业正在停止中 | TODO |
| 0x2600 | 语法错误 | 参考 SQL 手册纠正 |
| 0x2601 | 不完整的 SQL 语句 | 参考 SQL 手册纠正 |
| 0x2602 | 无效列名 | 使用正确的列名 |
| 0x2603 | 表不存在 | 使用正确的表名 |
| 0x2604 | 表名定义有二义性 | 参考 SQL 手册纠正 |
| 0x2605 | 无效的值类型 | 参考 SQL 手册纠正 |
| 0x2608 | 此处不能使用聚合查询 | 参考 SQL 手册纠正 |
| 0x2609 | ORDER BY 只能用于查询语句中的结果列 | 参考 SQL 手册纠正 |
| 0x260A | GROUP BY 缺失表达式 (TODO) | 参考 SQL 手册纠正 |
| 0x260B | 不是 SELECT 表达式 | 参考 SQL 手册纠正 |
| 0x260C | 不是单一分组的分组函数 (TODO) | 参考 SQL 手册纠正 |
| 0x260D | 标签数量不匹配 | 参考 SQL 手册纠正 |
| 0x260E | 无效的标签名 | 改用正确的标签名 |
| 0x2610 | 名字或密码过长 | 参考 SQL 手册纠正 |
| 0x2611 | 密码不能为空 | 提供非空密码 |
| 0x2612 | 端口无效 | 端口号必须在 (0,65535) 范围内 |
| 0x2613 | 地址格式错误 | 正确格式是 "fqdn: port" |
| 0x2614 | 该语句不再支持 | 参考 SQL 手册纠正 |
| 0x2615 | 时间窗口过小 | 参考 SQL 手册纠正 |
| 0x2616 | 未指定数据库 | 在表名或超级表名前添加 "<dbname\>." 指定数据库 |
| 0x2617 | 标识符无效 | 参考 SQL 手册纠正 |
| 0x2618 | 该数据库中不存在对应的超级表 | 使用正确的数据库名或者超级表名 |
| 0x2619 | 数据库参数无效 | 参考 SQL 手册纠正 |
| 0x261A | 建表参数无效 | 参考 SQL 手册纠正 |
| 0x2624 | GROUP BY 和 窗口子句不能共用 | 参考 SQL 手册纠正 |
| 0x2627 | 聚合函数不支持嵌套 | 参考 SQL 手册纠正 |
| 0x2628 | 在 integer/bool/varchar 类型的列上只支持 状态窗口 | 参考 SQL 手册纠正 |
| 0x2629 | 标签列上不支持状态窗口 | 参考 SQL 手册纠正 |
| 0x262A | 状态窗口查询不支持超级表 | 参考 SQL 手册纠正 |
| 0x262B | 会话之间的 gap 应该是大于 0 的固定大小的窗口 | 参考 SQL 手册纠正 |
| 0x262C | 只在主键时间戳列上支持会话 | 参考 SQL 手册纠正 |
| 0x262D | 窗口偏移量不能是负值 | 参考 SQL 手册纠正 |
| 0x262E | 当 interval 的单位是 "year" 时 offset 的单位不能是 "month" | 参考 SQL 手册纠正 |
| 0x262F | offset 所指定的时间长度应该小于 interval 所指定的时间长度 | 参考 SQL 手册纠正 |
| 0x2630 | 当 interval 是自然年/月时不能使用 slidig | 参考 SQL 手册纠正 |
| 0x2631 | sliding 所指定的时间长度不能大于 interval 所指定的时间长度 | 参考 SQL 手册纠正 |
| 0x2632 | sliding 不能小于 interval 的 1%% | 参考 SQL 手册纠正 |
| 0x2633 | 当使用 JSON 类型的 tag 时只允许这一个 tag 的存在 | 去除其它 tag |
| 0x2634 | 查询块中包含的结果列的数量不正确 | TODO |
| 0x2635 | 时间戳不正确 | TODO |
| 0x2637 | offset/soffset 不能小于 0 | 纠正 offset/soffset |
| 0x2638 | offset/soffset 只能用于 partition by | 参考 SQL 手册纠正 |
| 0x2639 | 无效的 topic 查询 | TODO |
| 0x263A | 不能批量删除超级表 | 请逐个删除 |
| 0x263B | 查询时间范围未指定起止时间或者时间范围过大 | 参考 SQL 手册纠正 |
| 0x263C | 重复的列表 | 参考 SQL 手册纠正 |
| 0x263D | 标签长度超过上限 | 参考 SQL 手册纠正 |
| 0x263E | 行长度超过上限 | 参考 SQL 手册纠正 |
| 0x263F | 不合法的列数量 | 参考 SQL 手册纠正 |
| 0x2640 | 列数过多 | 参考 SQL 手册纠正 |
| 0x2641 | 首列必须是时间戳 | 参考 SQL 手册纠正 |
| 0x2642 | binary/nchar 类型的列长度无效 | 参考 SQL 手册纠正 |
| 0x2643 | 标签列数量无效 | 参考 SQL 手册纠正 |
| 0x2644 | 无权进行该操作 | 参考 SQL 手册纠正 |
| 0x2645 | 无效的流查询 | 参考 SQL 手册纠正 |
| 0x2646 | 无效的 _c0 或 _rowts 表达式 | 参考 SQL 手册纠正 |
| 0x2647 | 无效的时间线函数 | 参考 SQL 手册纠正 |
| 0x2648 | 无效的密码 | 参考 SQL 手册纠正 |
| 0x2649 | 无效的 alter table 语句 | 参考 SQL 手册纠正 |
| 0x264A | 不能删除时间戳主列 | 参考 SQL 手册纠正 |
| 0x264B | 只有 binary/nchar 类型的列能够修改长度 | 参考 SQL 手册纠正 |
| 0x264C | 无效的 tbname 伪列 | 参考 SQL 手册纠正 |
| 0x264D | 无效的函数名 | 参考 SQL 手册纠正 |
| 0x264E | 注释过长 | 参考 SQL 手册纠正 |
| 0x264F | 有些函数只能用在查询的 SELECT 列表中,且不能与其它非标量函数或列混用 | 参考 SQL 手册纠正 |
| 0x2650 | 不支持窗口查询,因为子查询的结果不包含时间戳列 | 参考 SQL 手册纠正 |
| 0x2651 | 任何列都不能被删除 | 参考 SQL 手册纠正 |
| 0x2652 | 只有 标签列可以是 JSON 类型 | 参考 SQL 手册纠正 |
| 0x2653 | 列或标签的值过长 | 参考 SQL 手册纠正 |
| 0x2655 | DELETE 语句必须有一个确定的时间范围 | 参考 SQL 手册纠正 |
| 0x2656 | REDISTRIBUTE VGROUP 语句只支持 1 到 3 个 vgroup | 参考 SQL 手册纠正 |
| 0x2657 | 不支持 Fill | 参考 SQL 手册纠正 |
| 0x2658 | 无效的窗口伪列 | 参考 SQL 手册纠正 |
| 0x2659 | 不允许做窗口查询: TODO | 参考 SQL 手册纠正 |
| 0x265A | 不允许做流计算: TODO | 参考 SQL 手册纠正 |
| 0x265B | 不允许做 Group By | 参考 SQL 手册纠正 |
| 0x265D | interp 子句错误 | 参考 SQL 手册纠正 |
| 0x265E | 窗口查询中不支持该函数 | 参考 SQL 手册纠正 |
| 0x265F | 只支持单表 | 参考 SQL 手册纠正 |
| 0x2660 | 无效的 SMA 索引 | 参考 SQL 手册纠正 |
| 0x2661 | 无效的 SELECT 表达式 | 参考 SQL 手册纠正 |
| 0x2662 | 获取表的元数据失败 | TODO |
| 0x2663 | 表名/表名不唯一 | 参考 SQL 手册纠正 |
| 0x266F | 解析器内部错误 | TODO |
| 0x2700 | 计划器内部错误 | TODO |
| 0x2701 | TODO | TODO |
| 0x2702 | 不支持 cross join | 参考 SQL 手册纠正 |
| 0x2800 | 函数内部错误 | 参考 SQL 手册纠正 |
| 0x2801 | 函数参数个数错误 | 参考 SQL 手册纠正 |
| 0x2802 | 函数参数类型错误 | 参考 SQL 手册纠正 |
| 0x2803 | 函数参数值错误 | 参考 SQL 手册纠正 |
| 0x2804 | 非内置函数 | 参考 SQL 手册纠正 |
| 0x2901 | UDF 正在停止 | TODO |
| 0x2902 | UDF 管道读取错误 | TODO |
| 0x2903 | UDF 连接错误 | TODO |
| 0x2904 | UDF 管道缺失 | TODO |
| 0x2905 | UDF 加载失败 | TODO |
| 0x2906 | UDF 无效状态 | TODO |
| 0x2907 | UDF 无效输入 | TODO |
| 0x2908 | UDF 没有函数句柄 | TODO |
| 0x2909 | UDF 无效的 bufsize | TODO |
| 0x290A | UDF 无效的输出类型 | TODO |
| 0x3000 | 无效的行协议类型 | 修正数据中的协议类型 |
| 0x3001 | 无效的时间戳精度类型 | 修正时间戳精度类型 |
| 0x3002 | 无效的数据格式 | 修正数据格式 |
| 0x3003 | 无效的无模式数据库配置 | 修改配置 |
| 0x3004 | 写入类型与之前的不同 | 修正写入类型 |
| 0x3100 | TSMA 初始化失败 | TODO |
| 0x3101 | TSMA 已经存在 | 放弃重复建立 TSMA |
| 0x3102 | 元数据中没有 TSMA 索引 | TODO |
| 0x3103 | 无效的 TSMA 环境 | TODO |
| 0x3104 | 无效的 TSMA 状态 | TODO |
| 0x3105 | 无效的 TSMA 指针 | TODO |
| 0x3106 | 无效的 TSMA 参数 | 参考 SQL 手册纠正 |
| 0x3107 | cache 中没有该 TSMA 的索引 | TODO |
| 0x3150 | 无效的 RSMA 索引 | TODO |
| 0x3151 | 无效的 RSMA 状态 | TODO |
| 0x3152 | RSMA 创建 qtaskinfo 失败 | TODO |
| 0x3153 | RSMA 文件被破坏 | TODO |
| 0x3200 | 索引正在重建中 |TODO |
| 0x3201 | 无效的索引文件 | TODO |
| 0x4000 | 无效消息 | TODO |

View File

@ -2,13 +2,18 @@
```text
$ taos
Welcome to the TDengine shell from Linux, Client Version:2.0.5.0
Copyright (c) 2017 by TAOS Data, Inc. All rights reserved.
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
Server is Community Edition.
taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep1,keep2,keep(D) | cache(MB)| blocks | minrows | maxrows | wallevel | fsync | comp | precision | status |
=========================================================================================================================================================================================================================
test | 2020-10-14 10:35:48.617 | 10 | 1 | 1 | 1 | 2 | 3650,3650,3650 | 16| 6 | 100 | 4096 | 1 | 3000 | 2 | ms | ready |
log | 2020-10-12 09:08:21.651 | 4 | 1 | 1 | 1 | 10 | 30,30,30 | 1| 3 | 100 | 4096 | 1 | 3000 | 2 | us | ready |
Query OK, 2 row(s) in set (0.001198s)
name | create_time | vgroups | ntables | replica | strict | duration | keep | buffer | pagesize | pages | minrows | maxrows | comp | precision | status | retention | single_stable | cachemodel | cachesize | wal_level | wal_fsync_period | wal_retention_period | wal_retention_size | wal_roll_period | wal_seg_size |
=========================================================================================================================================================================================================================================================================================================================================================================================================================================================================
information_schema | NULL | NULL | 14 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
performance_schema | NULL | NULL | 3 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
db | 2022-08-04 14:14:49.385 | 2 | 4 | 1 | off | 14400m | 5254560m,5254560m,5254560m | 96 | 4 | 256 | 100 | 4096 | 2 | ms | ready | NULL | false | none | 1 | 1 | 3000 | 0 | 0 | 0 | 0 |
Query OK, 3 rows in database (0.019154s)
taos>
```

View File

@ -1,14 +1,19 @@
在 cmd 下进入到 C:\TDengine 目录下直接执行 `taos.exe`,连接到 TDengine 服务,进入到 TDengine CLI 界面,示例如下:
```text
C:\TDengine>taos
Welcome to the TDengine shell from Linux, Client Version:2.0.5.0
Copyright (c) 2017 by TAOS Data, Inc. All rights reserved.
taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep1,keep2,keep(D) | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | precision | status |
===================================================================================================================================================================================================================================================================
test | 2020-10-14 10:35:48.617 | 10 | 1 | 1 | 1 | 2 | 3650,3650,3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | ms | ready |
log | 2020-10-12 09:08:21.651 | 4 | 1 | 1 | 1 | 10 | 30,30,30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | us | ready |
Query OK, 2 row(s) in set (0.045000s)
taos>
Welcome to the TDengine shell from Windows, Client Version:3.0.0.0
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
Server is Community Edition.
taos> show databases;
name | create_time | vgroups | ntables | replica | strict | duration | keep | buffer | pagesize | pages | minrows | maxrows | comp | precision | status | retention | single_stable | cachemodel | cachesize | wal_level | wal_fsync_period | wal_retention_period | wal_retention_size | wal_roll_period | wal_seg_size |
=========================================================================================================================================================================================================================================================================================================================================================================================================================================================================
information_schema | NULL | NULL | 14 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
performance_schema | NULL | NULL | 3 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
test | 2022-08-04 16:46:40.506 | 2 | 0 | 1 | off | 14400m | 5256000m,5256000m,5256000m | 96 | 4 | 256 |
100 | 4096 | 2 | ms | ready | NULL | false | none | 1 | 1 | 3000 | 0 | 0 | 0 | 0 |
Query OK, 3 rows in database (0.123000s)
taos>
```

View File

@ -107,7 +107,10 @@ Usage: taosdump [OPTION...] dbname [tbname ...]
use letter and number only. Default is NOT.
-n, --no-escape No escape char '`'. Default is using it.
-T, --thread-num=THREAD_NUM Number of thread for dump in file. Default is
5.
8.
-C, --cloud=CLOUD_DSN specify a DSN to access TDengine cloud service
-R, --restful Use RESTful interface to connect TDengine
-t, --timeout=SECONDS The timeout seconds for websocket to interact.
-g, --debug Print debug info.
-?, --help Give this help list
--usage Give a short usage message

View File

@ -17,6 +17,7 @@ MQTT 是流行的物联网数据传输协议,[EMQX](https://github.com/emqx/em
用户可以根据当前的操作系统,到 EMQX 官网下载安装包,并执行安装。下载地址如下:<https://www.emqx.io/zh/downloads>。安装后使用 `sudo emqx start``sudo systemctl start emqx` 启动 EMQX 服务。
注意:本文基于 EMQX v4.4.5 版本,其他版本由于相关配置界面、配置方法以及功能可能随着版本升级有所区别。
## 创建数据库和表
@ -32,7 +33,7 @@ CREATE TABLE sensor_data (ts TIMESTAMP, temperature FLOAT, humidity FLOAT, volum
## 配置 EMQX 规则
由于 EMQX 不同版本配置界面所有不同,这里仅以 v4.4.3 为例,其他版本请参考相应官网文档。
由于 EMQX 不同版本配置界面所有不同,这里仅以 v4.4.5 为例,其他版本请参考相应官网文档。
### 登录 EMQX Dashboard

View File

@ -46,9 +46,10 @@ enum {
};
enum {
TASK_EXEC_STATUS__IDLE = 1,
TASK_EXEC_STATUS__EXECUTING,
TASK_EXEC_STATUS__CLOSING,
TASK_SCHED_STATUS__INACTIVE = 1,
TASK_SCHED_STATUS__WAITING,
TASK_SCHED_STATUS__ACTIVE,
TASK_SCHED_STATUS__FAILED,
};
enum {
@ -204,13 +205,11 @@ typedef struct {
enum {
TASK_SOURCE__SCAN = 1,
TASK_SOURCE__PIPE,
TASK_SOURCE__MERGE,
};
enum {
TASK_EXEC__NONE = 1,
TASK_EXEC__PIPE,
TASK_EXEC__MERGE,
};
enum {
@ -256,7 +255,7 @@ typedef struct SStreamTask {
int16_t dispatchMsgType;
int8_t taskStatus;
int8_t execStatus;
int8_t schedStatus;
// node info
int32_t selfChildId;
@ -475,7 +474,7 @@ typedef struct {
int32_t tDecodeStreamDispatchReq(SDecoder* pDecoder, SStreamDispatchReq* pReq);
int32_t tDecodeStreamRetrieveReq(SDecoder* pDecoder, SStreamRetrieveReq* pReq);
int32_t streamLaunchByWrite(SStreamTask* pTask, int32_t vgId);
// int32_t streamLaunchByWrite(SStreamTask* pTask, int32_t vgId);
int32_t streamSetupTrigger(SStreamTask* pTask);
int32_t streamProcessRunReq(SStreamTask* pTask);
@ -487,6 +486,9 @@ int32_t streamProcessRecoverRsp(SStreamTask* pTask, SStreamTaskRecoverRsp* pRsp)
int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq, SRpcMsg* pMsg);
int32_t streamProcessRetrieveRsp(SStreamTask* pTask, SStreamRetrieveRsp* pRsp);
int32_t streamTryExec(SStreamTask* pTask);
int32_t streamSchedExec(SStreamTask* pTask);
typedef struct SStreamMeta SStreamMeta;
SStreamMeta* streamMetaOpen();

View File

@ -49,6 +49,8 @@ void osDefaultInit();
void osUpdate();
void osCleanup();
bool osLogSpaceAvailable();
bool osDataSpaceAvailable();
bool osTempSpaceAvailable();
void osSetTimezone(const char *timezone);
void osSetSystemLocale(const char *inLocale, const char *inCharSet);

View File

@ -30,6 +30,10 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) {
SRequestObj* pRequest = param;
setErrno(pRequest, code);
if (NEED_CLIENT_RM_TBLMETA_REQ(pRequest->type)) {
removeMeta(pRequest->pTscObj, pRequest->targetTableList);
}
taosMemoryFree(pMsg->pData);
if (pRequest->body.queryFp != NULL) {
pRequest->body.queryFp(pRequest->body.param, pRequest, code);

View File

@ -452,7 +452,7 @@ static void taosSetClientLogCfg(SConfig *pCfg) {
SConfigItem *pItem = cfgGetItem(pCfg, "logDir");
tstrncpy(tsLogDir, cfgGetItem(pCfg, "logDir")->str, PATH_MAX);
taosExpandDir(tsLogDir, tsLogDir, PATH_MAX);
tsLogSpace.reserved = cfgGetItem(pCfg, "minimalLogDirGB")->fval;
tsLogSpace.reserved = (int64_t)(((double)cfgGetItem(pCfg, "minimalLogDirGB")->fval) * 1024 * 1024 * 1024);
tsNumOfLogLines = cfgGetItem(pCfg, "numOfLogLines")->i32;
tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval;
tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32;
@ -502,7 +502,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
tstrncpy(tsTempDir, cfgGetItem(pCfg, "tempDir")->str, PATH_MAX);
taosExpandDir(tsTempDir, tsTempDir, PATH_MAX);
tsTempSpace.reserved = cfgGetItem(pCfg, "minimalTmpDirGB")->fval;
tsTempSpace.reserved = (int64_t)(((double)cfgGetItem(pCfg, "minimalTmpDirGB")->fval) * 1024 * 1024 * 1024);
if (taosMulMkDir(tsTempDir) != 0) {
uError("failed to create tempDir:%s since %s", tsTempDir, terrstr());
return -1;
@ -540,7 +540,7 @@ static void taosSetSystemCfg(SConfig *pCfg) {
}
static int32_t taosSetServerCfg(SConfig *pCfg) {
tsDataSpace.reserved = cfgGetItem(pCfg, "minimalDataDirGB")->fval;
tsDataSpace.reserved = (int64_t)(((double)cfgGetItem(pCfg, "minimalDataDirGB")->fval) * 1024 * 1024 * 1024);
tsNumOfSupportVnodes = cfgGetItem(pCfg, "supportVnodes")->i32;
tsMaxShellConns = cfgGetItem(pCfg, "maxShellConns")->i32;
tsStatusInterval = cfgGetItem(pCfg, "statusInterval")->i32;
@ -739,15 +739,15 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
}
case 'i': {
if (strcasecmp("minimalTmpDirGB", name) == 0) {
tsTempSpace.reserved = cfgGetItem(pCfg, "minimalTmpDirGB")->fval;
tsTempSpace.reserved = (int64_t)(((double)cfgGetItem(pCfg, "minimalTmpDirGB")->fval) * 1024 * 1024 * 1024);
} else if (strcasecmp("minimalDataDirGB", name) == 0) {
tsDataSpace.reserved = cfgGetItem(pCfg, "minimalDataDirGB")->fval;
tsDataSpace.reserved = (int64_t)(((double)cfgGetItem(pCfg, "minimalDataDirGB")->fval) * 1024 * 1024 * 1024);
} else if (strcasecmp("minSlidingTime", name) == 0) {
tsMinSlidingTime = cfgGetItem(pCfg, "minSlidingTime")->i32;
} else if (strcasecmp("minIntervalTime", name) == 0) {
tsMinIntervalTime = cfgGetItem(pCfg, "minIntervalTime")->i32;
} else if (strcasecmp("minimalLogDirGB", name) == 0) {
tsLogSpace.reserved = cfgGetItem(pCfg, "minimalLogDirGB")->fval;
tsLogSpace.reserved = (int64_t)(((double)cfgGetItem(pCfg, "minimalLogDirGB")->fval) * 1024 * 1024 * 1024);
}
break;
}

View File

@ -4908,7 +4908,6 @@ int32_t tDecodeSRSmaParam(SDecoder *pCoder, SRSmaParam *pRSmaParam) {
if (tDecodeI64v(pCoder, &pRSmaParam->watermark[i]) < 0) return -1;
if (tDecodeI32v(pCoder, &pRSmaParam->qmsgLen[i]) < 0) return -1;
if (pRSmaParam->qmsgLen[i] > 0) {
tDecoderMalloc(pCoder, pRSmaParam->qmsgLen[i]);
if (tDecodeBinary(pCoder, (uint8_t **)&pRSmaParam->qmsg[i], NULL) < 0) return -1; // qmsgLen contains len of '\0'
} else {
pRSmaParam->qmsg[i] = NULL;

View File

@ -30,6 +30,12 @@ static int32_t STSBufUpdateHeader(STSBuf* pTSBuf, STSBufFileHeader* pHeader);
* @return
*/
STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
if (!osTempSpaceAvailable()) {
terrno = TSDB_CODE_TSC_NO_DISKSPACE;
// tscError("tmp file created failed since %s", terrstr());
return NULL;
}
STSBuf* pTSBuf = taosMemoryCalloc(1, sizeof(STSBuf));
if (pTSBuf == NULL) {
return NULL;

View File

@ -176,7 +176,11 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
taosWriteQitem(pVnode->pFetchQ, pMsg);
break;
case WRITE_QUEUE:
if ((pMsg->msgType == TDMT_VND_SUBMIT) && (grantCheck(TSDB_GRANT_STORAGE) != TSDB_CODE_SUCCESS)) {
if (!osDataSpaceAvailable()) {
terrno = TSDB_CODE_VND_NO_DISKSPACE;
code = terrno;
dError("vgId:%d, msg:%p put into vnode-write queue failed since %s", pVnode->vgId, pMsg, terrstr());
} else if ((pMsg->msgType == TDMT_VND_SUBMIT) && (grantCheck(TSDB_GRANT_STORAGE) != TSDB_CODE_SUCCESS)) {
terrno = TSDB_CODE_VND_NO_WRITE_AUTH;
code = terrno;
dDebug("vgId:%d, msg:%p put into vnode-write queue failed since %s", pVnode->vgId, pMsg, terrstr());

View File

@ -49,8 +49,26 @@ static int32_t dmInitMonitor() {
return 0;
}
static bool dmCheckDiskSpace() {
osUpdate();
if (!osDataSpaceAvailable()) {
dError("free disk size: %f GB, too little, require %f GB at least at least , quit", (double)tsDataSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsDataSpace.reserved / 1024.0 / 1024.0 / 1024.0);
return false;
}
if (!osLogSpaceAvailable()) {
dError("free disk size: %f GB, too little, require %f GB at least at least, quit", (double)tsLogSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsLogSpace.reserved / 1024.0 / 1024.0 / 1024.0);
return false;
}
if (!osTempSpaceAvailable()) {
dError("free disk size: %f GB, too little, require %f GB at least at least, quit", (double)tsTempSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsTempSpace.reserved / 1024.0 / 1024.0 / 1024.0);
return false;
}
return true;
}
int32_t dmInit(int8_t rtype) {
dInfo("start to init dnode env");
if (!dmCheckDiskSpace()) return -1;
if (dmCheckRepeatInit(dmInstance()) != 0) return -1;
if (dmInitSystem() != 0) return -1;
if (dmInitMonitor() != 0) return -1;

View File

@ -265,6 +265,7 @@ static void dmWatchNodes(SDnode *pDnode) {
}
int32_t dmRunDnode(SDnode *pDnode) {
int count = 0;
if (dmOpenNodes(pDnode) != 0) {
dError("failed to open nodes since %s", terrstr());
return -1;
@ -274,7 +275,6 @@ int32_t dmRunDnode(SDnode *pDnode) {
dError("failed to start nodes since %s", terrstr());
return -1;
}
while (1) {
if (pDnode->stop) {
dInfo("TDengine is about to stop");
@ -285,6 +285,9 @@ int32_t dmRunDnode(SDnode *pDnode) {
}
dmWatchNodes(pDnode);
if (count == 0) osUpdate();
count %= 10;
count++;
taosMsleep(100);
}
}

View File

@ -531,7 +531,7 @@ int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate) {
}
if (pCreate->numOfColumns < TSDB_MIN_COLUMNS || pCreate->numOfColumns > TSDB_MAX_COLUMNS) {
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
terrno = TSDB_CODE_PAR_INVALID_COLUMNS_NUM;
return -1;
}
@ -542,7 +542,7 @@ int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate) {
SField *pField = taosArrayGet(pCreate->pColumns, 0);
if (pField->type != TSDB_DATA_TYPE_TIMESTAMP) {
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
terrno = TSDB_CODE_PAR_INVALID_FIRST_COLUMN;
return -1;
}

View File

@ -437,7 +437,6 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
pField->bytes = 8;
if (mndCheckCreateStbReq(&createReq) != 0) {
terrno = TSDB_CODE_INVALID_MSG;
goto _OVER;
}

View File

@ -604,7 +604,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask) {
ASSERT(taosArrayGetSize(pTask->childEpInfo) != 0);
}
pTask->execStatus = TASK_EXEC_STATUS__IDLE;
pTask->schedStatus = TASK_SCHED_STATUS__INACTIVE;
pTask->inputQueue = streamQueueOpen();
pTask->outputQueue = streamQueueOpen();
@ -720,7 +720,7 @@ int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq, int64_t ver) {
continue;
}
if (streamLaunchByWrite(pTask, TD_VID(pTq->pVnode)) < 0) {
if (streamSchedExec(pTask) < 0) {
qError("stream task launch failed, task id %d", pTask->taskId);
continue;
}
@ -751,12 +751,13 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) {
}
int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg, bool exec) {
ASSERT(0);
char* msgStr = pMsg->pCont;
char* msgBody = POINTER_SHIFT(msgStr, sizeof(SMsgHead));
int32_t msgLen = pMsg->contLen - sizeof(SMsgHead);
SStreamDispatchReq req;
SDecoder decoder;
tDecoderInit(&decoder, msgBody, msgLen);
tDecoderInit(&decoder, (uint8_t*)msgBody, msgLen);
tDecodeStreamDispatchReq(&decoder, &req);
int32_t taskId = req.taskId;
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));

View File

@ -136,31 +136,6 @@ int32_t tqSendExecReq(STQ* pTq, STqHandle* pHandle) {
return 0;
}
int32_t tqEnqueueAll(STQ* pTq, SSubmitReq* pReq) {
void* pIter = NULL;
SStreamDataSubmit* pSubmit = streamDataSubmitNew(pReq);
if (pSubmit == NULL) {
return -1;
}
while (1) {
pIter = taosHashIterate(pTq->handles, pIter);
if (pIter == NULL) break;
STqHandle* pHandle = (STqHandle*)pIter;
if (tqEnqueue(pHandle, pSubmit) < 0) {
continue;
}
int8_t execStatus = atomic_load_8(&pHandle->pushHandle.execStatus);
if (execStatus == TASK_EXEC_STATUS__IDLE || execStatus == TASK_EXEC_STATUS__CLOSING) {
tqSendExecReq(pTq, pHandle);
}
}
streamDataSubmitRefDec(pSubmit);
return 0;
}
int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver, SRpcHandleInfo handleInfo) {
if (msgType != TDMT_VND_SUBMIT) return 0;
void* pIter = NULL;

View File

@ -437,14 +437,10 @@ static int32_t vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *p
goto _err;
}
// taosMemoryFree(req.schemaRow.pSchema);
// taosMemoryFree(req.schemaTag.pSchema);
tDecoderClear(&coder);
return 0;
_err:
taosMemoryFree(req.schemaRow.pSchema);
taosMemoryFree(req.schemaTag.pSchema);
tDecoderClear(&coder);
return -1;
}

View File

@ -88,9 +88,11 @@ bool isResultRowClosed(SResultRow* pResultRow);
struct SResultRowEntryInfo* getResultEntryInfo(const SResultRow* pRow, int32_t index, const int32_t* offset);
static FORCE_INLINE SResultRow* getResultRowByPos(SDiskbasedBuf* pBuf, SResultRowPosition* pos) {
static FORCE_INLINE SResultRow* getResultRowByPos(SDiskbasedBuf* pBuf, SResultRowPosition* pos, bool forUpdate) {
SFilePage* bufPage = (SFilePage*)getBufPage(pBuf, pos->pageId);
setBufPageDirty(bufPage, true);
if (forUpdate) {
setBufPageDirty(bufPage, true);
}
SResultRow* pRow = (SResultRow*)((char*)bufPage + pos->offset);
return pRow;
}

View File

@ -953,7 +953,7 @@ STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowI
return w;
}
w = getResultRowByPos(pBuf, &pResultRowInfo->cur)->win;
w = getResultRowByPos(pBuf, &pResultRowInfo->cur, false)->win;
// in case of typical time window, we can calculate time window directly.
if (w.skey > ts || w.ekey < ts) {

View File

@ -258,7 +258,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
// in case of repeat scan/reverse scan, no new time window added.
if (isIntervalQuery) {
if (masterscan && p1 != NULL) { // the *p1 may be NULL in case of sliding+offset exists.
pResult = getResultRowByPos(pResultBuf, p1);
pResult = getResultRowByPos(pResultBuf, p1, true);
ASSERT(pResult->pageId == p1->pageId && pResult->offset == p1->offset);
}
} else {
@ -266,7 +266,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
// pResultRowInfo object.
if (p1 != NULL) {
// todo
pResult = getResultRowByPos(pResultBuf, p1);
pResult = getResultRowByPos(pResultBuf, p1, true);
ASSERT(pResult->pageId == p1->pageId && pResult->offset == p1->offset);
}
}
@ -3398,7 +3398,12 @@ int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t n
uint32_t defaultBufsz = 0;
getBufferPgSize(pAggSup->resultRowSize, &defaultPgsz, &defaultBufsz);
int32_t code = createDiskbasedBuf(&pAggSup->pResultBuf, defaultPgsz, defaultBufsz, pKey, TD_TMP_DIR_PATH);
if (!osTempSpaceAvailable()) {
terrno = TSDB_CODE_NO_AVAIL_DISK;
qError("Init stream agg supporter failed since %s", terrstr(terrno));
return terrno;
}
int32_t code = createDiskbasedBuf(&pAggSup->pResultBuf, defaultPgsz, defaultBufsz, pKey, tsTempDir);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
@ -4662,7 +4667,12 @@ int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey, SqlF
if (bufSize <= pageSize) {
bufSize = pageSize * 4;
}
int32_t code = createDiskbasedBuf(&pSup->pResultBuf, pageSize, bufSize, pKey, TD_TMP_DIR_PATH);
if (!osTempSpaceAvailable()) {
terrno = TSDB_CODE_NO_AVAIL_DISK;
qError("Init stream agg supporter failed since %s", terrstr(terrno));
return terrno;
}
int32_t code = createDiskbasedBuf(&pSup->pResultBuf, pageSize, bufSize, pKey, tsTempDir);
for (int32_t i = 0; i < numOfOutput; ++i) {
pCtx[i].pBuf = pSup->pResultBuf;
}

View File

@ -764,7 +764,13 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
uint32_t defaultBufsz = 0;
getBufferPgSize(pResBlock->info.rowSize, &defaultPgsz, &defaultBufsz);
int32_t code = createDiskbasedBuf(&pInfo->pBuf, defaultPgsz, defaultBufsz, pTaskInfo->id.str, TD_TMP_DIR_PATH);
if (!osTempSpaceAvailable()) {
terrno = TSDB_CODE_NO_AVAIL_DISK;
pTaskInfo->code = terrno;
qError("Create partition operator info failed since %s", terrstr(terrno));
goto _error;
}
int32_t code = createDiskbasedBuf(&pInfo->pBuf, defaultPgsz, defaultBufsz, pTaskInfo->id.str, tsTempDir);
if (code != TSDB_CODE_SUCCESS) {
goto _error;
}

View File

@ -611,7 +611,7 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num
break;
}
SResultRow* pr = getResultRowByPos(pInfo->aggSup.pResultBuf, p1);
SResultRow* pr = getResultRowByPos(pInfo->aggSup.pResultBuf, p1, false);
ASSERT(pr->offset == p1->offset && pr->pageId == p1->pageId);
if (pr->closed) {
@ -1345,7 +1345,7 @@ static void setInverFunction(SqlFunctionCtx* pCtx, int32_t num, EStreamType type
}
void doClearWindowImpl(SResultRowPosition* p1, SDiskbasedBuf* pResultBuf, SExprSupp* pSup, int32_t numOfOutput) {
SResultRow* pResult = getResultRowByPos(pResultBuf, p1);
SResultRow* pResult = getResultRowByPos(pResultBuf, p1, false);
SqlFunctionCtx* pCtx = pSup->pCtx;
for (int32_t i = 0; i < numOfOutput; ++i) {
pCtx[i].resultInfo = getResultEntryInfo(pResult, i, pSup->rowEntryInfoOffset);
@ -3481,7 +3481,7 @@ static int32_t setWindowOutputBuf(SResultWindowInfo* pWinInfo, SResultRow** pRes
pWinInfo->pos.pageId = (*pResult)->pageId;
pWinInfo->pos.offset = (*pResult)->offset;
} else {
*pResult = getResultRowByPos(pAggSup->pResultBuf, &pWinInfo->pos);
*pResult = getResultRowByPos(pAggSup->pResultBuf, &pWinInfo->pos, true);
if (!(*pResult)) {
qError("getResultRowByPos return NULL, TID:%s", GET_TASKID(pTaskInfo));
return TSDB_CODE_FAILED;

View File

@ -247,7 +247,12 @@ SLHashObj* tHashInit(int32_t inMemPages, int32_t pageSize, _hash_fn_t fn, int32_
return NULL;
}
int32_t code = createDiskbasedBuf(&pHashObj->pBuf, pageSize, inMemPages * pageSize, 0, TD_TMP_DIR_PATH);
if (!osTempSpaceAvailable()) {
terrno = TSDB_CODE_NO_AVAIL_DISK;
printf("tHash Init failed since %s", terrstr(terrno));
return NULL;
}
int32_t code = createDiskbasedBuf(&pHashObj->pBuf, pageSize, inMemPages * pageSize, 0, tsTempDir);
if (code != 0) {
terrno = code;
return NULL;

View File

@ -159,7 +159,12 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
int32_t start = 0;
if (pHandle->pBuf == NULL) {
int32_t code = createDiskbasedBuf(&pHandle->pBuf, pHandle->pageSize, pHandle->numOfPages * pHandle->pageSize, "doAddToBuf", TD_TMP_DIR_PATH);
if (!osTempSpaceAvailable()) {
terrno = TSDB_CODE_NO_AVAIL_DISK;
qError("Add to buf failed since %s", terrstr(terrno));
return terrno;
}
int32_t code = createDiskbasedBuf(&pHandle->pBuf, pHandle->pageSize, pHandle->numOfPages * pHandle->pageSize, "doAddToBuf", tsTempDir);
dBufSetPrintInfo(pHandle->pBuf);
if (code != TSDB_CODE_SUCCESS) {
return code;
@ -233,7 +238,13 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int
} else {
// multi-pass internal merge sort is required
if (pHandle->pBuf == NULL) {
code = createDiskbasedBuf(&pHandle->pBuf, pHandle->pageSize, pHandle->numOfPages * pHandle->pageSize, "sortComparInit", TD_TMP_DIR_PATH);
if (!osTempSpaceAvailable()) {
terrno = TSDB_CODE_NO_AVAIL_DISK;
code = terrno;
qError("Sort compare init failed since %s", terrstr(terrno));
return code;
}
code = createDiskbasedBuf(&pHandle->pBuf, pHandle->pageSize, pHandle->numOfPages * pHandle->pageSize, "sortComparInit", tsTempDir);
dBufSetPrintInfo(pHandle->pBuf);
if (code != TSDB_CODE_SUCCESS) {
return code;

View File

@ -1461,15 +1461,14 @@ static int32_t translateInterp(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
}
SValueNode* pValue = (SValueNode*)nodesListGetNode(pFunc->pParameterList, i);
int32_t ret = convertStringToTimestamp(paraType, pValue->datum.p, dbPrec, &timeVal[i - 1]);
int32_t ret = convertStringToTimestamp(paraType, pValue->datum.p, dbPrec, &timeVal[i - 1]);
if (ret != TSDB_CODE_SUCCESS) {
return invaildFuncParaValueErrMsg(pErrBuf, len, pFunc->functionName);
}
}
if (timeVal[0] > timeVal[1]) {
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
"INTERP function invalid time range");
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, "INTERP function invalid time range");
}
}
@ -2136,7 +2135,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.name = "apercentile",
.type = FUNCTION_TYPE_APERCENTILE,
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC,
.classification = FUNC_MGT_AGG_FUNC,
.translateFunc = translateApercentile,
.getEnvFunc = getApercentileFuncEnv,
.initFunc = apercentileFunctionSetup,

View File

@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "taoserror.h"
#include "tglobal.h"
#include "tcompare.h"
@ -257,7 +258,14 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval,
resetSlotInfo(pBucket);
int32_t ret = createDiskbasedBuf(&pBucket->pBuffer, pBucket->bufPageSize, pBucket->bufPageSize * 512, "1", TD_TMP_DIR_PATH);
if (!osTempSpaceAvailable()) {
terrno = TSDB_CODE_NO_AVAIL_DISK;
// qError("MemBucket create disk based Buf failed since %s", terrstr(terrno));
tMemBucketDestroy(pBucket);
return NULL;
}
int32_t ret = createDiskbasedBuf(&pBucket->pBuffer, pBucket->bufPageSize, pBucket->bufPageSize * 512, "1", tsTempDir);
if (ret != 0) {
tMemBucketDestroy(pBucket);
return NULL;

View File

@ -412,22 +412,31 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
udf->outputLen = pFuncInfo->outputLen;
udf->bufSize = pFuncInfo->bufSize;
if (!osTempSpaceAvailable()) {
terrno = TSDB_CODE_NO_AVAIL_DISK;
msgInfo->code = terrno;
fnError("udfd create shared library failed since %s", terrstr(terrno));
goto _return;
}
char path[PATH_MAX] = {0};
#ifdef WINDOWS
snprintf(path, sizeof(path), "%s%s.dll", TD_TMP_DIR_PATH, pFuncInfo->name);
snprintf(path, sizeof(path), "%s%s.dll", tsTempDir, pFuncInfo->name);
#else
snprintf(path, sizeof(path), "%s/lib%s.so", TD_TMP_DIR_PATH, pFuncInfo->name);
snprintf(path, sizeof(path), "%s/lib%s.so", tsTempDir, pFuncInfo->name);
#endif
TdFilePtr file =
taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC | TD_FILE_AUTO_DEL);
if (file == NULL) {
fnError("udfd write udf shared library: %s failed, error: %d %s", path, errno, strerror(errno));
msgInfo->code = TSDB_CODE_FILE_CORRUPTED;
goto _return;
}
int64_t count = taosWriteFile(file, pFuncInfo->pCode, pFuncInfo->codeSize);
if (count != pFuncInfo->codeSize) {
fnError("udfd write udf shared library failed");
msgInfo->code = TSDB_CODE_FILE_CORRUPTED;
goto _return;
}
taosCloseFile(&file);
strncpy(udf->path, path, strlen(path));

View File

@ -5845,11 +5845,16 @@ static int32_t createTagValFromExpr(STranslateContext* pCxt, SDataType targetDt,
}
static int32_t createTagValFromVal(STranslateContext* pCxt, SDataType targetDt, SNode* pNode, SValueNode** pVal) {
*pVal = (SValueNode*)nodesCloneNode(pNode);
if (NULL == *pVal) {
SValueNode* pTempVal = (SValueNode*)nodesCloneNode(pNode);
if (NULL == pTempVal) {
return TSDB_CODE_OUT_OF_MEMORY;
}
return DEAL_RES_ERROR == translateValueImpl(pCxt, *pVal, targetDt, true) ? pCxt->errCode : TSDB_CODE_SUCCESS;
if (DEAL_RES_ERROR == translateValueImpl(pCxt, pTempVal, targetDt, true)) {
nodesDestroyNode((SNode*)pTempVal);
return pCxt->errCode;
}
*pVal = pTempVal;
return TSDB_CODE_SUCCESS;
}
static int32_t createTagVal(STranslateContext* pCxt, uint8_t precision, SSchema* pSchema, SNode* pNode,

View File

@ -68,7 +68,7 @@ void streamTriggerByTimer(void* param, void* tmrId) {
atomic_store_8(&pTask->triggerStatus, TASK_TRIGGER_STATUS__IN_ACTIVE);
streamTaskInput(pTask, (SStreamQueueItem*)trigger);
streamLaunchByWrite(pTask, pTask->nodeId);
streamSchedExec(pTask);
}
taosTmrReset(streamTriggerByTimer, (int32_t)pTask->triggerParam, pTask, streamEnv.timer, &pTask->timer);
@ -82,9 +82,10 @@ int32_t streamSetupTrigger(SStreamTask* pTask) {
return 0;
}
#if 0
int32_t streamLaunchByWrite(SStreamTask* pTask, int32_t vgId) {
int8_t execStatus = atomic_load_8(&pTask->execStatus);
if (execStatus == TASK_EXEC_STATUS__IDLE || execStatus == TASK_EXEC_STATUS__CLOSING) {
int8_t schedStatus = atomic_load_8(&pTask->schedStatus);
if (schedStatus == TASK_SCHED_STATUS__INACTIVE) {
SStreamTaskRunReq* pRunReq = rpcMallocCont(sizeof(SStreamTaskRunReq));
if (pRunReq == NULL) return -1;
@ -101,6 +102,29 @@ int32_t streamLaunchByWrite(SStreamTask* pTask, int32_t vgId) {
}
return 0;
}
#endif
int32_t streamSchedExec(SStreamTask* pTask) {
int8_t schedStatus =
atomic_val_compare_exchange_8(&pTask->schedStatus, TASK_SCHED_STATUS__INACTIVE, TASK_SCHED_STATUS__WAITING);
if (schedStatus == TASK_SCHED_STATUS__INACTIVE) {
SStreamTaskRunReq* pRunReq = rpcMallocCont(sizeof(SStreamTaskRunReq));
if (pRunReq == NULL) {
atomic_store_8(&pTask->schedStatus, TASK_SCHED_STATUS__INACTIVE);
return -1;
}
pRunReq->head.vgId = pTask->nodeId;
pRunReq->streamId = pTask->streamId;
pRunReq->taskId = pTask->taskId;
SRpcMsg msg = {
.msgType = TDMT_STREAM_TASK_RUN,
.pCont = pRunReq,
.contLen = sizeof(SStreamTaskRunReq),
};
tmsgPutToQueue(pTask->pMsgCb, STREAM_QUEUE, &msg);
}
return 0;
}
int32_t streamTaskEnqueue(SStreamTask* pTask, SStreamDispatchReq* pReq, SRpcMsg* pRsp) {
SStreamDataBlock* pData = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM);
@ -182,14 +206,13 @@ int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, S
streamTaskEnqueue(pTask, pReq, pRsp);
if (exec) {
streamExec(pTask);
streamTryExec(pTask);
if (pTask->dispatchType != TASK_DISPATCH__NONE) {
ASSERT(pTask->sinkType == TASK_SINK__NONE);
streamDispatch(pTask);
}
} else {
streamLaunchByWrite(pTask, pTask->nodeId);
streamSchedExec(pTask);
}
return 0;
@ -219,7 +242,7 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp) {
}
int32_t streamProcessRunReq(SStreamTask* pTask) {
streamExec(pTask);
streamTryExec(pTask);
if (pTask->dispatchType != TASK_DISPATCH__NONE) {
streamDispatch(pTask);
@ -272,10 +295,11 @@ int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq, S
streamTaskEnqueueRetrieve(pTask, pReq, pRsp);
ASSERT(pTask->execType != TASK_EXEC__NONE);
streamExec(pTask);
streamSchedExec(pTask);
/*streamTryExec(pTask);*/
ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE);
streamDispatch(pTask);
/*ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE);*/
/*streamDispatch(pTask);*/
return 0;
}

View File

@ -440,13 +440,13 @@ FAIL:
int32_t streamDispatch(SStreamTask* pTask) {
ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE);
#if 1
ASSERT(pTask->sinkType == TASK_SINK__NONE);
int8_t old =
atomic_val_compare_exchange_8(&pTask->outputStatus, TASK_OUTPUT_STATUS__NORMAL, TASK_OUTPUT_STATUS__WAIT);
if (old != TASK_OUTPUT_STATUS__NORMAL) {
return 0;
}
#endif
SStreamDataBlock* pBlock = streamQueueNextItem(pTask->outputQueue);
if (pBlock == NULL) {
@ -466,22 +466,8 @@ int32_t streamDispatch(SStreamTask* pTask) {
atomic_store_8(&pTask->outputStatus, TASK_OUTPUT_STATUS__NORMAL);
goto FREE;
}
/*atomic_store_8(&pTask->outputStatus, TASK_OUTPUT_STATUS__NORMAL);*/
FREE:
taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes);
taosFreeQitem(pBlock);
#if 0
SRpcMsg dispatchMsg = {0};
SEpSet* pEpSet = NULL;
if (streamBuildDispatchMsg(pTask, pBlock, &dispatchMsg, &pEpSet) < 0) {
ASSERT(0);
atomic_store_8(&pTask->outputStatus, TASK_OUTPUT_STATUS__NORMAL);
return -1;
}
taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes);
taosFreeQitem(pBlock);
tmsgSendReq(pEpSet, &dispatchMsg);
#endif
return code;
}

View File

@ -147,24 +147,23 @@ int32_t streamPipelineExec(SStreamTask* pTask, int32_t batchNum) {
return 0;
}
static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) {
// TODO: handle version
int32_t streamExecForAll(SStreamTask* pTask) {
while (1) {
int32_t cnt = 1;
void* data = NULL;
while (1) {
SStreamQueueItem* qItem = streamQueueNextItem(pTask->inputQueue);
if (qItem == NULL) {
qDebug("stream exec over, queue empty");
qDebug("stream task exec over, queue empty, task: %d", pTask->taskId);
break;
}
if (data == NULL) {
data = qItem;
streamQueueProcessSuccess(pTask->inputQueue);
if (pTask->execType == TASK_EXEC__NONE) break;
/*if (qItem->type == STREAM_INPUT__DATA_BLOCK) {*/
/*streamUpdateVer(pTask, (SStreamDataBlock*)qItem);*/
/*}*/
if (pTask->execType == TASK_EXEC__NONE) {
break;
}
} else {
void* newRet;
if ((newRet = streamAppendQueueItem(data, qItem)) == NULL) {
@ -181,11 +180,12 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) {
if (pTask->taskStatus == TASK_STATUS__DROPPING) {
if (data) streamFreeQitem(data);
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
return NULL;
return 0;
}
if (data == NULL) break;
if (data == NULL) {
break;
}
if (pTask->execType == TASK_EXEC__NONE) {
ASSERT(((SStreamQueueItem*)data)->type == STREAM_INPUT__DATA_BLOCK);
@ -193,6 +193,8 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) {
continue;
}
SArray* pRes = taosArrayInit(0, sizeof(SSDataBlock));
qDebug("stream task %d exec begin, msg batch: %d", pTask->taskId, cnt);
streamTaskExecImpl(pTask, data, pRes);
qDebug("stream task %d exec end", pTask->taskId);
@ -203,76 +205,44 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) {
// TODO log failed ver
streamQueueProcessFail(pTask->inputQueue);
taosArrayDestroy(pRes);
return NULL;
return -1;
}
qRes->type = STREAM_INPUT__DATA_BLOCK;
qRes->blocks = pRes;
if (streamTaskOutput(pTask, qRes) < 0) {
// TODO log failed ver
/*streamQueueProcessFail(pTask->inputQueue);*/
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
taosFreeQitem(qRes);
return NULL;
}
if (((SStreamQueueItem*)data)->type == STREAM_INPUT__DATA_SUBMIT) {
SStreamDataSubmit* pSubmit = (SStreamDataSubmit*)data;
qRes->childId = pTask->selfChildId;
qRes->sourceVer = pSubmit->ver;
}
if (streamTaskOutput(pTask, qRes) < 0) {
// TODO save failed ver
/*streamQueueProcessFail(pTask->inputQueue);*/
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
taosFreeQitem(qRes);
return -1;
}
/*streamQueueProcessSuccess(pTask->inputQueue);*/
pRes = taosArrayInit(0, sizeof(SSDataBlock));
}
streamFreeQitem(data);
}
return pRes;
}
// TODO: handle version
int32_t streamExec(SStreamTask* pTask) {
SArray* pRes = taosArrayInit(0, sizeof(SSDataBlock));
if (pRes == NULL) return -1;
while (1) {
int8_t execStatus =
atomic_val_compare_exchange_8(&pTask->execStatus, TASK_EXEC_STATUS__IDLE, TASK_EXEC_STATUS__EXECUTING);
if (execStatus == TASK_EXEC_STATUS__IDLE) {
// first run
qDebug("stream exec, enter exec status");
pRes = streamExecForQall(pTask, pRes);
if (pRes == NULL) goto FAIL;
// temporarily disable status closing, since it runs out of threads
#if 0
// set status closing
atomic_store_8(&pTask->execStatus, TASK_EXEC_STATUS__CLOSING);
// second run, make sure inputQ and qall are cleared
qDebug("stream exec, enter closing status");
pRes = streamExecForQall(pTask, pRes);
if (pRes == NULL) goto FAIL;
#endif
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
atomic_store_8(&pTask->execStatus, TASK_EXEC_STATUS__IDLE);
qDebug("stream exec, return result");
return 0;
} else if (execStatus == TASK_EXEC_STATUS__CLOSING) {
continue;
} else if (execStatus == TASK_EXEC_STATUS__EXECUTING) {
ASSERT(taosArrayGetSize(pRes) == 0);
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
return 0;
} else {
ASSERT(0);
}
}
FAIL:
if (pRes) taosArrayDestroy(pRes);
if (pTask->taskStatus == TASK_STATUS__DROPPING) {
tFreeSStreamTask(pTask);
return 0;
} else {
atomic_store_8(&pTask->execStatus, TASK_EXEC_STATUS__IDLE);
return -1;
}
return 0;
}
int32_t streamTryExec(SStreamTask* pTask) {
int8_t schedStatus =
atomic_val_compare_exchange_8(&pTask->schedStatus, TASK_SCHED_STATUS__WAITING, TASK_SCHED_STATUS__ACTIVE);
if (schedStatus == TASK_SCHED_STATUS__WAITING) {
int32_t code = streamExecForAll(pTask);
if (code < 0) {
atomic_store_8(&pTask->schedStatus, TASK_SCHED_STATUS__FAILED);
return -1;
}
atomic_store_8(&pTask->schedStatus, TASK_SCHED_STATUS__INACTIVE);
if (!taosQueueEmpty(pTask->inputQueue->queue)) {
streamSchedExec(pTask);
}
}
return 0;
}

View File

@ -35,9 +35,10 @@ FAIL:
void streamQueueClose(SStreamQueue* queue) {
while (1) {
void* qItem = streamQueueNextItem(queue);
if (qItem)
if (qItem) {
taosFreeQitem(qItem);
else
} else {
return;
}
}
}

View File

@ -23,7 +23,7 @@ SStreamTask* tNewSStreamTask(int64_t streamId) {
}
pTask->taskId = tGenIdPI32();
pTask->streamId = streamId;
pTask->execStatus = TASK_EXEC_STATUS__IDLE;
pTask->schedStatus = TASK_SCHED_STATUS__INACTIVE;
pTask->inputStatus = TASK_INPUT_STATUS__NORMAL;
pTask->outputStatus = TASK_OUTPUT_STATUS__NORMAL;
@ -59,7 +59,7 @@ int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
if (tEncodeI16(pEncoder, pTask->dispatchMsgType) < 0) return -1;
if (tEncodeI8(pEncoder, pTask->taskStatus) < 0) return -1;
if (tEncodeI8(pEncoder, pTask->execStatus) < 0) return -1;
if (tEncodeI8(pEncoder, pTask->schedStatus) < 0) return -1;
if (tEncodeI32(pEncoder, pTask->selfChildId) < 0) return -1;
if (tEncodeI32(pEncoder, pTask->nodeId) < 0) return -1;
@ -114,7 +114,7 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
if (tDecodeI16(pDecoder, &pTask->dispatchMsgType) < 0) return -1;
if (tDecodeI8(pDecoder, &pTask->taskStatus) < 0) return -1;
if (tDecodeI8(pDecoder, &pTask->execStatus) < 0) return -1;
if (tDecodeI8(pDecoder, &pTask->schedStatus) < 0) return -1;
if (tDecodeI32(pDecoder, &pTask->selfChildId) < 0) return -1;
if (tDecodeI32(pDecoder, &pTask->nodeId) < 0) return -1;

View File

@ -105,6 +105,10 @@ void osCleanup() {}
bool osLogSpaceAvailable() { return tsLogSpace.reserved <= tsLogSpace.size.avail; }
bool osDataSpaceAvailable() { return tsDataSpace.reserved <= tsDataSpace.size.avail; }
bool osTempSpaceAvailable() { return tsTempSpace.reserved <= tsTempSpace.size.avail; }
void osSetTimezone(const char *timezone) { taosSetSystemTimezone(timezone, tsTimezoneStr, &tsDaylight, &tsTimezone); }
void osSetSystemLocale(const char *inLocale, const char *inCharSet) {

View File

@ -691,9 +691,14 @@ static void taosWriteLog(SLogBuff *pLogBuf) {
static void *taosAsyncOutputLog(void *param) {
SLogBuff *pLogBuf = (SLogBuff *)param;
setThreadName("log");
int32_t count = 0;
while (1) {
count += tsWriteInterval;
taosMsleep(tsWriteInterval);
if (count > 1000) {
osUpdate();
count = 0;
}
// Polling the buffer
taosWriteLog(pLogBuf);