Merge branch '3.0' into enh/ctgPerf
This commit is contained in:
commit
c1c3513b08
|
@ -2,7 +2,7 @@
|
|||
# taosadapter
|
||||
ExternalProject_Add(taosadapter
|
||||
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
|
||||
GIT_TAG df8678f
|
||||
GIT_TAG 766dcc4
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taos-tools
|
||||
ExternalProject_Add(taos-tools
|
||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||
GIT_TAG 2a2def1
|
||||
GIT_TAG c9cc20f
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taosws-rs
|
||||
ExternalProject_Add(taosws-rs
|
||||
GIT_REPOSITORY https://github.com/taosdata/taosws-rs.git
|
||||
GIT_TAG 24b199e
|
||||
GIT_TAG 648cc62
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
```
|
||||
|
|
|
@ -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.
|
||||
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 | 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)
|
||||
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>
|
||||
```
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ 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()")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)`
|
||||
|
||||
- data:udfNormalFunc 的输出数据数组,如果使用了 interBuf 那么 data 就是 interBuf 的数组。
|
||||
- numOfRows:data 中数据的行数。
|
||||
- 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 系统。
|
||||
|
|
|
@ -15,21 +15,21 @@ Note: 由于 SHOW 语句已经被开发者熟悉和广泛使用,所以它们
|
|||
|
||||
本章将详细介绍 `INFORMATION_SCHEMA` 这个内置元数据库中的表和表结构。
|
||||
|
||||
## DNODES
|
||||
## INS_DNODES
|
||||
|
||||
提供 dnode 的相关信息。也可以使用 SHOW DNODES 来查询这些信息。
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
| --- | :------------: | ------------ | --------------------- |
|
||||
| 1 | vnodes | SMALLINT | dnode 中的 vnode 个数 |
|
||||
| 2 | support_vnodes | SMALLINT | 支持的 vnode 个数 |
|
||||
| --- | :------------: | ------------ | ------------------------- |
|
||||
| 1 | vnodes | SMALLINT | dnode 中的实际 vnode 个数 |
|
||||
| 2 | support_vnodes | SMALLINT | 最多支持的 vnode 个数 |
|
||||
| 3 | status | BINARY(10) | 当前状态 |
|
||||
| 4 | note | BINARY(256) | 离线原因等信息 |
|
||||
| 5 | id | SMALLINT | dnode id |
|
||||
| 6 | endpoint | BINARY(134) | dnode 的地址 |
|
||||
| 7 | create | TIMESTAMP | 创建时间 |
|
||||
|
||||
## MNODES
|
||||
## INS_MNODES
|
||||
|
||||
提供 mnode 的相关信息。也可以使用 SHOW MNODES 来查询这些信息。
|
||||
|
||||
|
@ -41,7 +41,7 @@ Note: 由于 SHOW 语句已经被开发者熟悉和广泛使用,所以它们
|
|||
| 4 | role_time | TIMESTAMP | 成为当前角色的时间 |
|
||||
| 5 | create_time | TIMESTAMP | 创建时间 |
|
||||
|
||||
## MODULES
|
||||
## INS_MODULES
|
||||
|
||||
提供组件的相关信息。也可以使用 SHOW MODULES 来查询这些信息
|
||||
|
||||
|
@ -51,46 +51,74 @@ Note: 由于 SHOW 语句已经被开发者熟悉和广泛使用,所以它们
|
|||
| 2 | endpoint | BINARY(134) | 组件的地址 |
|
||||
| 3 | module | BINARY(10) | 组件状态 |
|
||||
|
||||
## QNODES
|
||||
## INS_QNODES
|
||||
|
||||
当前系统中 QNODE 的信息。也可以使用 SHOW QNODES 来查询这些信息。
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
| --- | :---------: | ------------ | ------------ |
|
||||
| 1 | id | SMALLINT | module id |
|
||||
| 1 | id | SMALLINT | qnode id |
|
||||
| 2 | endpoint | BINARY(134) | qnode 的地址 |
|
||||
| 3 | create_time | TIMESTAMP | 创建时间 |
|
||||
|
||||
## USER_DATABASES
|
||||
## INS_CLUSTER
|
||||
|
||||
存储集群相关信息。
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
| --- | :---------: | ------------ | ---------- |
|
||||
| 1 | id | BIGINT | cluster id |
|
||||
| 2 | name | BINARY(134) | 集群名称 |
|
||||
| 3 | create_time | TIMESTAMP | 创建时间 |
|
||||
|
||||
## INS_DATABASES
|
||||
|
||||
提供用户创建的数据库对象的相关信息。也可以使用 SHOW DATABASES 来查询这些信息。
|
||||
|
||||
TODO
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
| --- | :---------: | ------------ | ------------------------------------------------ |
|
||||
| --- | :------------------: | ---------------- | ------------------------------------------------ |
|
||||
| 1 | name | BINARY(32) | 数据库名 |
|
||||
| 2 | create_time | TIMESTAMP | 创建时间 |
|
||||
| 3 | ntables | INT | 数据库中表的数量,包含子表和普通表但不包含超级表 |
|
||||
| 4 | vgroups | INT | 数据库中有多少个 vgroup |
|
||||
| 5 | replica | INT | 副本数 |
|
||||
| 6 | quorum | INT | 写成功的确认数 |
|
||||
| 7 | days | INT | 单文件存储数据的时间跨度 |
|
||||
| 8 | keep | INT | 数据保留时长 |
|
||||
| 9 | buffer | INT | 每个 vnode 写缓存的内存块大小,单位 MB |
|
||||
| 10 | minrows | INT | 文件块中记录的最大条数 |
|
||||
| 11 | maxrows | INT | 文件块中记录的最小条数 |
|
||||
| 12 | wal_level | INT | WAL 级别 |
|
||||
| 13 | walfsync_period | INT | 数据落盘周期 |
|
||||
| 14 | comp | INT | 数据压缩方式 |
|
||||
| 15 | precision | BINARY(2) | 时间分辨率 |
|
||||
| 16 | status | BINARY(10) | 数据库状态 |
|
||||
| 6 | replica | INT | 副本数 |
|
||||
| 7 | quorum | BINARY(3) | 强一致性 |
|
||||
| 8 | duration | INT | 单文件存储数据的时间跨度 |
|
||||
| 9 | keep | INT | 数据保留时长 |
|
||||
| 10 | buffer | INT | 每个 vnode 写缓存的内存块大小,单位 MB |
|
||||
| 11 | pagesize | INT | 每个 VNODE 中元数据存储引擎的页大小,单位为 KB |
|
||||
| 12 | pages | INT | 每个 vnode 元数据存储引擎的缓存页个数 |
|
||||
| 13 | minrows | INT | 文件块中记录的最大条数 |
|
||||
| 14 | maxrows | INT | 文件块中记录的最小条数 |
|
||||
| 15 | comp | INT | 数据压缩方式 |
|
||||
| 16 | precision | BINARY(2) | 时间分辨率 |
|
||||
| 17 | status | BINARY(10) | 数据库状态 |
|
||||
| 18 | retention | BINARY (60) | 数据的聚合周期和保存时长 |
|
||||
| 19 | single_stable | BOOL | 表示此数据库中是否只可以创建一个超级表 |
|
||||
| 20 | cachemodel | BINARY(60) | 表示是否在内存中缓存子表的最近数据 |
|
||||
| 21 | cachesize | INT | 表示每个 vnode 中用于缓存子表最近数据的内存大小 |
|
||||
| 22 | wal_level | INT | WAL 级别 |
|
||||
| 23 | wal_fsync_period | INT | 数据落盘周期 |
|
||||
| 24 | wal_retention_period | INT | WAL 的保存时长 |
|
||||
| 25 | wal_retention_size | INT | WAL 的保存上限 |
|
||||
| 26 | wal_roll_period | INT | wal 文件切换时长 |
|
||||
| 27 | wal_segment_size | wal 单个文件大小 |
|
||||
|
||||
## USER_FUNCTIONS
|
||||
## INS_FUNCTIONS
|
||||
|
||||
TODO
|
||||
用户创建的自定义函数的信息。
|
||||
|
||||
## USER_INDEXES
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
| --- | :---------: | ------------ | -------------- |
|
||||
| 1 | name | BINARY(64) | 函数名 |
|
||||
| 2 | comment | BINARY(255) | 补充说明 |
|
||||
| 3 | aggregate | INT | 是否为聚合函数 |
|
||||
| 4 | output_type | BINARY(31) | 输出类型 |
|
||||
| 5 | create_time | TIMESTAMP | 创建时间 |
|
||||
| 6 | code_len | INT | 代码长度 |
|
||||
| 7 | bufsize | INT | buffer 大小 |
|
||||
|
||||
## INS_INDEXES
|
||||
|
||||
提供用户创建的索引的相关信息。也可以使用 SHOW INDEX 来查询这些信息。
|
||||
|
||||
|
@ -103,7 +131,7 @@ TODO
|
|||
| 5 | index_type | BINARY(10) | 目前有 SMA 和 FULLTEXT |
|
||||
| 6 | index_extensions | BINARY(256) | 索引的额外信息。对 SMA 类型的索引,是函数名的列表。对 FULLTEXT 类型的索引为 NULL。 |
|
||||
|
||||
## USER_STABLES
|
||||
## INS_STABLES
|
||||
|
||||
提供用户创建的超级表的相关信息。
|
||||
|
||||
|
@ -120,19 +148,7 @@ TODO
|
|||
| 9 | max_delay | BINARY(64) | 推送计算结果的最大延迟 |
|
||||
| 10 | rollup | BINARY(128) | rollup 聚合函数 |
|
||||
|
||||
## USER_STREAMS
|
||||
|
||||
提供用户创建的流计算的相关信息。
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
| --- | :---------: | ------------ | --------------------------- |
|
||||
| 1 | stream_name | BINARY(192) | 流计算名称 |
|
||||
| 2 | user_name | BINARY(23) | 创建流计算的用户 |
|
||||
| 3 | dest_table | BINARY(192) | 流计算写入的目标表 |
|
||||
| 4 | create_time | TIMESTAMP | 创建时间 |
|
||||
| 5 | sql | BLOB | 创建流计算时提供的 SQL 语句 |
|
||||
|
||||
## USER_TABLES
|
||||
## INS_TABLES
|
||||
|
||||
提供用户创建的普通表和子表的相关信息
|
||||
|
||||
|
@ -149,7 +165,18 @@ TODO
|
|||
| 9 | table_comment | BINARY(1024) | 表注释 |
|
||||
| 10 | type | BINARY(20) | 表类型 |
|
||||
|
||||
## USER_USERS
|
||||
## INS_TAGS
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
| --- | :---------: | ------------- | ---------------------- |
|
||||
| 1 | table_name | BINARY(192) | 表名 |
|
||||
| 2 | db_name | BINARY(64) | 该表所在的数据库的名称 |
|
||||
| 3 | stable_name | BINARY(192) | 所属的超级表表名 |
|
||||
| 4 | tag_name | BINARY(64) | tag 的名称 |
|
||||
| 5 | tag_type | BINARY(64) | tag 的类型 |
|
||||
| 6 | tag_value | BINARY(16384) | tag 的值 |
|
||||
|
||||
## INS_USERS
|
||||
|
||||
提供系统中创建的用户的相关信息。
|
||||
|
||||
|
@ -159,21 +186,62 @@ TODO
|
|||
| 2 | privilege | BINARY(256) | 权限 |
|
||||
| 3 | create_time | TIMESTAMP | 创建时间 |
|
||||
|
||||
## VGROUPS
|
||||
## INS_GRANTS
|
||||
|
||||
提供企业版授权的相关信息。
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
| --- | :---------: | ------------ | -------------------------------------------------- |
|
||||
| 1 | version | BINARY(9) | 企业版授权说明:official(官方授权的)/trial(试用的) |
|
||||
| 2 | cpu_cores | BINARY(9) | 授权使用的 CPU 核心数量 |
|
||||
| 3 | dnodes | BINARY(10) | 授权使用的 dnode 节点数量 |
|
||||
| 4 | streams | BINARY(10) | 授权创建的流数量 |
|
||||
| 5 | users | BINARY(10) | 授权创建的用户数量 |
|
||||
| 6 | accounts | BINARY(10) | 授权创建的帐户数量 |
|
||||
| 7 | storage | BINARY(21) | 授权使用的存储空间大小 |
|
||||
| 8 | connections | BINARY(21) | 授权使用的客户端连接数量 |
|
||||
| 9 | databases | BINARY(11) | 授权使用的数据库数量 |
|
||||
| 10 | speed | BINARY(9) | 授权使用的数据点每秒写入数量 |
|
||||
| 11 | querytime | BINARY(9) | 授权使用的查询总时长 |
|
||||
| 12 | timeseries | BINARY(21) | 授权使用的测点数量 |
|
||||
| 13 | expired | BINARY(5) | 是否到期,true:到期,false:未到期 |
|
||||
| 14 | expire_time | BINARY(19) | 试用期到期时间 |
|
||||
|
||||
## INS_VGROUPS
|
||||
|
||||
系统中所有 vgroups 的信息。
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
| --- | :--------: | ------------ | ---------------------------- |
|
||||
| 1 | vg_id | INT | vgroup id |
|
||||
| --- | :-------: | ------------ | ------------------------------------------------------ |
|
||||
| 1 | vgroup_id | INT | vgroup id |
|
||||
| 2 | db_name | BINARY(32) | 数据库名 |
|
||||
| 3 | tables | INT | 此 vgroup 内有多少表 |
|
||||
| 4 | status | BINARY(10) | 此 vgroup 的状态 |
|
||||
| 5 | onlines | INT | 在线的成员数目 |
|
||||
| 6 | v1_dnode | INT | 第一个成员所在的 dnode 的 id |
|
||||
| 7 | v1_status | BINARY(10) | 第一个成员的状态 |
|
||||
| 8 | v2_dnode | INT | 第二个成员所在的 dnode 的 id |
|
||||
| 9 | v2_status | BINARY(10) | 第二个成员的状态 |
|
||||
| 10 | v3_dnode | INT | 第三个成员所在的 dnode 的 id |
|
||||
| 11 | v3_status | BINARY(10) | 第三个成员的状态 |
|
||||
| 12 | compacting | INT | compact 状态 |
|
||||
| 5 | v1_dnode | INT | 第一个成员所在的 dnode 的 id |
|
||||
| 6 | v1_status | BINARY(10) | 第一个成员的状态 |
|
||||
| 7 | v2_dnode | INT | 第二个成员所在的 dnode 的 id |
|
||||
| 8 | v2_status | BINARY(10) | 第二个成员的状态 |
|
||||
| 9 | v3_dnode | INT | 第三个成员所在的 dnode 的 id |
|
||||
| 10 | v3_status | BINARY(10) | 第三个成员的状态 |
|
||||
| 11 | nfiles | INT | 此 vgroup 中数据/元数据文件的数量 |
|
||||
| 12 | file_size | INT | 此 vgroup 中数据/元数据文件的大小 |
|
||||
| 13 | tsma | TINYINT | 此 vgroup 是否专用于 Time-range-wise SMA,1: 是, 0: 否 |
|
||||
|
||||
## INS_CONFIGS
|
||||
|
||||
系统配置参数。
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
| --- | :------: | ------------ | ------------ |
|
||||
| 1 | name | BINARY(32) | 配置项名称 |
|
||||
| 2 | value | BINARY(64) | 该配置项的值 |
|
||||
|
||||
## INS_DNODE_VARIABLES
|
||||
|
||||
系统中每个 dnode 的配置参数。
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
| --- | :------: | ------------ | ------------ |
|
||||
| 1 | dnode_id | INT | dnode 的 ID |
|
||||
| 2 | name | BINARY(32) | 配置项名称 |
|
||||
| 3 | value | BINARY(64) | 该配置项的值 |
|
||||
|
|
|
@ -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 |
|
|
@ -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>
|
||||
```
|
||||
|
|
|
@ -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.
|
||||
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 | 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)
|
||||
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>
|
||||
```
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -49,9 +49,9 @@ int32_t grantCheck(EGrantType grant);
|
|||
#ifndef GRANTS_CFG
|
||||
#define GRANTS_SCHEMA static const SSysDbTableSchema grantsSchema[] = { \
|
||||
{.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
{.name = "expire time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
{.name = "storage(GB)", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
{.name = "storage", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
{.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
{.name = "databases", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
{.name = "users", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
|
@ -59,8 +59,8 @@ int32_t grantCheck(EGrantType grant);
|
|||
{.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
{.name = "connections", .bytes = 11 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
{.name = "streams", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
{.name = "cpu cores", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
{.name = "speed(PPS)", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
{.name = "cpu_cores", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
{.name = "speed", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
{.name = "querytime", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
}
|
||||
#define GRANT_CFG_ADD
|
||||
|
|
|
@ -227,8 +227,7 @@ typedef struct SSubmitBlk {
|
|||
int32_t sversion; // data schema version
|
||||
int32_t dataLen; // data part length, not including the SSubmitBlk head
|
||||
int32_t schemaLen; // schema length, if length is 0, no schema exists
|
||||
int16_t numOfRows; // total number of rows in current submit block
|
||||
int16_t padding; // TODO just for padding here
|
||||
int32_t numOfRows; // total number of rows in current submit block
|
||||
char data[];
|
||||
} SSubmitBlk;
|
||||
|
||||
|
@ -256,7 +255,7 @@ typedef struct {
|
|||
int32_t sversion; // data schema version
|
||||
int32_t dataLen; // data part length, not including the SSubmitBlk head
|
||||
int32_t schemaLen; // schema length, if length is 0, no schema exists
|
||||
int16_t numOfRows; // total number of rows in current submit block
|
||||
int32_t numOfRows; // total number of rows in current submit block
|
||||
// head of SSubmitBlk
|
||||
int32_t numOfBlocks;
|
||||
const void* pMsg;
|
||||
|
@ -337,9 +336,11 @@ static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* p
|
|||
}
|
||||
|
||||
static FORCE_INLINE void tDeleteSSchemaWrapper(SSchemaWrapper* pSchemaWrapper) {
|
||||
if (pSchemaWrapper) {
|
||||
taosMemoryFree(pSchemaWrapper->pSchema);
|
||||
taosMemoryFree(pSchemaWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema) {
|
||||
int32_t tlen = 0;
|
||||
|
|
|
@ -76,6 +76,13 @@ qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* n
|
|||
*/
|
||||
int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type);
|
||||
|
||||
/**
|
||||
* @brief Cleanup SSDataBlock for StreamScanInfo
|
||||
*
|
||||
* @param tinfo
|
||||
*/
|
||||
void tdCleanupStreamInputDataBlock(qTaskInfo_t tinfo);
|
||||
|
||||
/**
|
||||
* Update the table id list, add or remove.
|
||||
*
|
||||
|
|
|
@ -253,7 +253,8 @@ typedef struct SShowCreateTableStmt {
|
|||
ENodeType type;
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
char tableName[TSDB_TABLE_NAME_LEN];
|
||||
void* pCfg; // STableCfg
|
||||
void* pDbCfg; // SDbCfgInfo
|
||||
void* pTableCfg; // STableCfg
|
||||
} SShowCreateTableStmt;
|
||||
|
||||
typedef struct SShowTableDistributedStmt {
|
||||
|
@ -282,6 +283,7 @@ typedef struct SCreateIndexStmt {
|
|||
ENodeType type;
|
||||
EIndexType indexType;
|
||||
bool ignoreExists;
|
||||
char indexDbName[TSDB_DB_NAME_LEN];
|
||||
char indexName[TSDB_INDEX_NAME_LEN];
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
char tableName[TSDB_TABLE_NAME_LEN];
|
||||
|
@ -292,6 +294,7 @@ typedef struct SCreateIndexStmt {
|
|||
typedef struct SDropIndexStmt {
|
||||
ENodeType type;
|
||||
bool ignoreNotExists;
|
||||
char indexDbName[TSDB_DB_NAME_LEN];
|
||||
char indexName[TSDB_INDEX_NAME_LEN];
|
||||
} SDropIndexStmt;
|
||||
|
||||
|
|
|
@ -114,6 +114,7 @@ typedef struct SAggLogicNode {
|
|||
SNodeList* pAggFuncs;
|
||||
bool hasLastRow;
|
||||
bool hasTimeLineFunc;
|
||||
bool onlyHasKeepOrderFunc;
|
||||
} SAggLogicNode;
|
||||
|
||||
typedef struct SProjectLogicNode {
|
||||
|
@ -552,6 +553,8 @@ typedef struct SQueryPlan {
|
|||
|
||||
void nodesWalkPhysiPlan(SNode* pNode, FNodeWalker walker, void* pContext);
|
||||
|
||||
const char* dataOrderStr(EDataOrderLevel order);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -269,6 +269,7 @@ typedef struct SSelectStmt {
|
|||
bool hasInterpFunc;
|
||||
bool hasLastRowFunc;
|
||||
bool hasTimeLineFunc;
|
||||
bool onlyHasKeepOrderFunc;
|
||||
bool groupSort;
|
||||
} SSelectStmt;
|
||||
|
||||
|
|
|
@ -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,11 +474,10 @@ 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 streamSetupTrigger(SStreamTask* pTask);
|
||||
|
||||
int32_t streamProcessRunReq(SStreamTask* pTask);
|
||||
int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, SRpcMsg* pMsg);
|
||||
int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, SRpcMsg* pMsg, bool exec);
|
||||
int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp);
|
||||
int32_t streamProcessRecoverReq(SStreamTask* pTask, SStreamTaskRecoverReq* pReq, SRpcMsg* pMsg);
|
||||
int32_t streamProcessRecoverRsp(SStreamTask* pTask, SStreamTaskRecoverRsp* pRsp);
|
||||
|
@ -487,6 +485,21 @@ 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();
|
||||
void streamMetaClose(SStreamMeta* streamMeta);
|
||||
|
||||
int32_t streamMetaAddTask(SStreamMeta* pMeta, SStreamTask* pTask);
|
||||
int32_t streamMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId);
|
||||
|
||||
int32_t streamMetaBegin(SStreamMeta* pMeta);
|
||||
int32_t streamMetaCommit(SStreamMeta* pMeta);
|
||||
int32_t streamMetaRollBack(SStreamMeta* pMeta);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ typedef struct TdFile *TdFilePtr;
|
|||
#define TD_FILE_EXCL 0x0080
|
||||
#define TD_FILE_STREAM 0x0100 // Only support taosFprintfFile, taosGetLineFile, taosEOFFile
|
||||
TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions);
|
||||
TdFilePtr taosCreateFile(const char *path, int32_t tdFileOptions);
|
||||
|
||||
#define TD_FILE_ACCESS_EXIST_OK 0x1
|
||||
#define TD_FILE_ACCESS_READ_OK 0x2
|
||||
|
|
|
@ -608,6 +608,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_RSMA_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3151)
|
||||
#define TSDB_CODE_RSMA_QTASKINFO_CREATE TAOS_DEF_ERROR_CODE(0, 0x3152)
|
||||
#define TSDB_CODE_RSMA_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x3153)
|
||||
#define TSDB_CODE_RSMA_REMOVE_EXISTS TAOS_DEF_ERROR_CODE(0, 0x3154)
|
||||
|
||||
//index
|
||||
#define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200)
|
||||
|
|
|
@ -809,6 +809,7 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
|
|||
|
||||
code = catalogAsyncGetAllMeta(pCxt->pCatalog, &conn, &catalogReq, retrieveMetaCallback, pWrapper,
|
||||
&pRequest->body.queryJob);
|
||||
pCxt = NULL;
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
|
@ -816,6 +817,8 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
|
|||
_error:
|
||||
tscError("0x%" PRIx64 " error happens, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code, tstrerror(code),
|
||||
pRequest->requestId);
|
||||
taosMemoryFree(pCxt);
|
||||
|
||||
terrno = code;
|
||||
pRequest->code = code;
|
||||
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -189,20 +189,6 @@ typedef struct {
|
|||
tsem_t rspSem;
|
||||
} SMqPollCbParam;
|
||||
|
||||
#if 0
|
||||
typedef struct {
|
||||
tmq_t* tmq;
|
||||
int8_t async;
|
||||
int8_t automatic;
|
||||
int8_t freeOffsets;
|
||||
tmq_commit_cb* userCb;
|
||||
tsem_t rspSem;
|
||||
int32_t rspErr;
|
||||
SArray* offsets;
|
||||
void* userParam;
|
||||
} SMqCommitCbParam;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
tmq_t* tmq;
|
||||
int8_t automatic;
|
||||
|
@ -385,29 +371,6 @@ static int32_t tmqMakeTopicVgKey(char* dst, const char* topicName, int32_t vg) {
|
|||
return sprintf(dst, "%s:%d", topicName, vg);
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t tmqCommitCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||
SMqCommitCbParam* pParam = (SMqCommitCbParam*)param;
|
||||
pParam->rspErr = code;
|
||||
if (pParam->async) {
|
||||
if (pParam->automatic && pParam->tmq->commitCb) {
|
||||
pParam->tmq->commitCb(pParam->tmq, pParam->rspErr, pParam->tmq->commitCbUserParam);
|
||||
} else if (!pParam->automatic && pParam->userCb) {
|
||||
pParam->userCb(pParam->tmq, pParam->rspErr, pParam->userParam);
|
||||
}
|
||||
|
||||
if (pParam->freeOffsets) {
|
||||
taosArrayDestroy(pParam->offsets);
|
||||
}
|
||||
|
||||
taosMemoryFree(pParam);
|
||||
} else {
|
||||
tsem_post(&pParam->rspSem);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t tmqCommitCb2(void* param, SDataBuf* pBuf, int32_t code) {
|
||||
SMqCommitCbParam2* pParam = (SMqCommitCbParam2*)param;
|
||||
SMqCommitCbParamSet* pParamSet = (SMqCommitCbParamSet*)pParam->params;
|
||||
|
@ -509,10 +472,11 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT
|
|||
pMsgSendInfo->msgType = TDMT_VND_MQ_COMMIT_OFFSET;
|
||||
// send msg
|
||||
|
||||
atomic_add_fetch_32(&pParamSet->waitingRspNum, 1);
|
||||
atomic_add_fetch_32(&pParamSet->totalRspNum, 1);
|
||||
|
||||
int64_t transporterId = 0;
|
||||
asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, pMsgSendInfo);
|
||||
pParamSet->waitingRspNum++;
|
||||
pParamSet->totalRspNum++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -659,123 +623,6 @@ int32_t tmqCommitInner2(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t tmqCommitInner(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_t async,
|
||||
tmq_commit_cb* userCb, void* userParam) {
|
||||
SMqCMCommitOffsetReq req;
|
||||
SArray* pOffsets = NULL;
|
||||
void* buf = NULL;
|
||||
SMqCommitCbParam* pParam = NULL;
|
||||
SMsgSendInfo* sendInfo = NULL;
|
||||
int8_t freeOffsets;
|
||||
int32_t code = -1;
|
||||
|
||||
if (msg == NULL) {
|
||||
freeOffsets = 1;
|
||||
pOffsets = taosArrayInit(0, sizeof(SMqOffset));
|
||||
for (int32_t i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) {
|
||||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
||||
for (int32_t j = 0; j < taosArrayGetSize(pTopic->vgs); j++) {
|
||||
SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j);
|
||||
SMqOffset offset;
|
||||
tstrncpy(offset.topicName, pTopic->topicName, TSDB_TOPIC_FNAME_LEN);
|
||||
tstrncpy(offset.cgroup, tmq->groupId, TSDB_CGROUP_LEN);
|
||||
offset.vgId = pVg->vgId;
|
||||
offset.offset = pVg->currentOffset;
|
||||
taosArrayPush(pOffsets, &offset);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
freeOffsets = 0;
|
||||
pOffsets = (SArray*)&msg->container;
|
||||
}
|
||||
|
||||
req.num = (int32_t)pOffsets->size;
|
||||
req.offsets = pOffsets->pData;
|
||||
|
||||
SEncoder encoder;
|
||||
|
||||
tEncoderInit(&encoder, NULL, 0);
|
||||
code = tEncodeSMqCMCommitOffsetReq(&encoder, &req);
|
||||
if (code < 0) {
|
||||
goto END;
|
||||
}
|
||||
int32_t tlen = encoder.pos;
|
||||
buf = taosMemoryMalloc(tlen);
|
||||
if (buf == NULL) {
|
||||
tEncoderClear(&encoder);
|
||||
goto END;
|
||||
}
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
tEncoderInit(&encoder, buf, tlen);
|
||||
tEncodeSMqCMCommitOffsetReq(&encoder, &req);
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
pParam = taosMemoryCalloc(1, sizeof(SMqCommitCbParam));
|
||||
if (pParam == NULL) {
|
||||
goto END;
|
||||
}
|
||||
pParam->tmq = tmq;
|
||||
pParam->automatic = automatic;
|
||||
pParam->async = async;
|
||||
pParam->offsets = pOffsets;
|
||||
pParam->freeOffsets = freeOffsets;
|
||||
pParam->userCb = userCb;
|
||||
pParam->userParam = userParam;
|
||||
if (!async) tsem_init(&pParam->rspSem, 0, 0);
|
||||
|
||||
sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (sendInfo == NULL) goto END;
|
||||
sendInfo->msgInfo = (SDataBuf){
|
||||
.pData = buf,
|
||||
.len = tlen,
|
||||
.handle = NULL,
|
||||
};
|
||||
|
||||
sendInfo->requestId = generateRequestId();
|
||||
sendInfo->requestObjRefId = 0;
|
||||
sendInfo->param = pParam;
|
||||
sendInfo->fp = tmqCommitCb;
|
||||
sendInfo->msgType = TDMT_MND_MQ_COMMIT_OFFSET;
|
||||
|
||||
SEpSet epSet = getEpSet_s(&tmq->pTscObj->pAppInfo->mgmtEp);
|
||||
|
||||
int64_t transporterId = 0;
|
||||
asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo);
|
||||
|
||||
if (!async) {
|
||||
tsem_wait(&pParam->rspSem);
|
||||
code = pParam->rspErr;
|
||||
tsem_destroy(&pParam->rspSem);
|
||||
taosMemoryFree(pParam);
|
||||
} else {
|
||||
code = 0;
|
||||
}
|
||||
|
||||
// avoid double free if msg is sent
|
||||
buf = NULL;
|
||||
|
||||
END:
|
||||
if (buf) taosMemoryFree(buf);
|
||||
/*if (pParam) taosMemoryFree(pParam);*/
|
||||
/*if (sendInfo) taosMemoryFree(sendInfo);*/
|
||||
|
||||
if (code != 0 && async) {
|
||||
if (automatic) {
|
||||
tmq->commitCb(tmq, code, (tmq_topic_vgroup_list_t*)pOffsets, tmq->commitCbUserParam);
|
||||
} else {
|
||||
userCb(tmq, code, (tmq_topic_vgroup_list_t*)pOffsets, userParam);
|
||||
}
|
||||
}
|
||||
|
||||
if (!async && freeOffsets) {
|
||||
taosArrayDestroy(pOffsets);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
#endif
|
||||
|
||||
void tmqAssignAskEpTask(void* param, void* tmrId) {
|
||||
tmq_t* tmq = (tmq_t*)param;
|
||||
int8_t* pTaskType = taosAllocateQitem(sizeof(int8_t), DEF_QITEM);
|
||||
|
@ -961,7 +808,8 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
|||
tmq_t* pTmq = taosMemoryCalloc(1, sizeof(tmq_t));
|
||||
if (pTmq == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tscError("consumer %ld setup failed since %s, consumer group %s", pTmq->consumerId, terrstr(), pTmq->groupId);
|
||||
tscError("consumer %" PRId64 " setup failed since %s, consumer group %s", pTmq->consumerId, terrstr(),
|
||||
pTmq->groupId);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -979,7 +827,8 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
|||
|
||||
if (pTmq->clientTopics == NULL || pTmq->mqueue == NULL || pTmq->qall == NULL || pTmq->delayedTask == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tscError("consumer %ld setup failed since %s, consumer group %s", pTmq->consumerId, terrstr(), pTmq->groupId);
|
||||
tscError("consumer %" PRId64 " setup failed since %s, consumer group %s", pTmq->consumerId, terrstr(),
|
||||
pTmq->groupId);
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
|
@ -1008,14 +857,16 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
|||
|
||||
// init semaphore
|
||||
if (tsem_init(&pTmq->rspSem, 0, 0) != 0) {
|
||||
tscError("consumer %ld setup failed since %s, consumer group %s", pTmq->consumerId, terrstr(), pTmq->groupId);
|
||||
tscError("consumer %" PRId64 " setup failed since %s, consumer group %s", pTmq->consumerId, terrstr(),
|
||||
pTmq->groupId);
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
// init connection
|
||||
pTmq->pTscObj = taos_connect_internal(conf->ip, user, pass, NULL, NULL, conf->port, CONN_TYPE__TMQ);
|
||||
if (pTmq->pTscObj == NULL) {
|
||||
tscError("consumer %ld setup failed since %s, consumer group %s", pTmq->consumerId, terrstr(), pTmq->groupId);
|
||||
tscError("consumer %" PRId64 " setup failed since %s, consumer group %s", pTmq->consumerId, terrstr(),
|
||||
pTmq->groupId);
|
||||
tsem_destroy(&pTmq->rspSem);
|
||||
goto FAIL;
|
||||
}
|
||||
|
@ -1024,7 +875,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
|||
pTmq->hbLiveTimer = taosTmrStart(tmqSendHbReq, 1000, pTmq, tmqMgmt.timer);
|
||||
}
|
||||
|
||||
tscInfo("consumer %ld is setup, consumer group %s", pTmq->consumerId, pTmq->groupId);
|
||||
tscInfo("consumer %" PRId64 " is setup, consumer group %s", pTmq->consumerId, pTmq->groupId);
|
||||
|
||||
return pTmq;
|
||||
|
||||
|
@ -1834,14 +1685,22 @@ int32_t tmq_consumer_close(tmq_t* tmq) {
|
|||
return rsp;
|
||||
}
|
||||
|
||||
int32_t retryCnt = 0;
|
||||
tmq_list_t* lst = tmq_list_new();
|
||||
while (1) {
|
||||
rsp = tmq_subscribe(tmq, lst);
|
||||
if (rsp != TSDB_CODE_MND_CONSUMER_NOT_READY || retryCnt > 5) {
|
||||
break;
|
||||
} else {
|
||||
retryCnt++;
|
||||
taosMsleep(500);
|
||||
}
|
||||
}
|
||||
|
||||
tmq_list_destroy(lst);
|
||||
|
||||
if (rsp != 0) {
|
||||
return rsp;
|
||||
}
|
||||
}
|
||||
// TODO: free resources
|
||||
return 0;
|
||||
}
|
||||
|
@ -2869,7 +2728,8 @@ static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
|
||||
// getTbName(req.tableFName);
|
||||
char sql[256] = {0};
|
||||
sprintf(sql, "delete from `%s` where `%s` >= %" PRId64" and `%s` <= %" PRId64, req.tableFName, req.tsColName, req.skey, req.tsColName, req.ekey);
|
||||
sprintf(sql, "delete from `%s` where `%s` >= %" PRId64 " and `%s` <= %" PRId64, req.tableFName, req.tsColName,
|
||||
req.skey, req.tsColName, req.ekey);
|
||||
printf("delete sql:%s\n", sql);
|
||||
|
||||
TAOS_RES* res = taos_query(taos, sql);
|
||||
|
@ -3138,10 +2998,9 @@ int taos_write_raw_block(TAOS *taos, int rows, char *pData, const char* tbname){
|
|||
|
||||
blk->uid = htobe64(uid);
|
||||
blk->suid = htobe64(suid);
|
||||
blk->padding = htonl(blk->padding);
|
||||
blk->sversion = htonl(pTableMeta->sversion);
|
||||
blk->schemaLen = htonl(schemaLen);
|
||||
blk->numOfRows = htons(rows);
|
||||
blk->numOfRows = htonl(rows);
|
||||
blk->dataLen = htonl(dataLen);
|
||||
subReq->length = sizeof(SSubmitReq) + sizeof(SSubmitBlk) + schemaLen + dataLen;
|
||||
subReq->numOfBlocks = 1;
|
||||
|
@ -3367,10 +3226,9 @@ static int32_t tmqWriteRaw(TAOS *taos, void* data, int32_t dataLen){
|
|||
|
||||
blk->uid = htobe64(uid);
|
||||
blk->suid = htobe64(suid);
|
||||
blk->padding = htonl(blk->padding);
|
||||
blk->sversion = htonl(pSW->version);
|
||||
blk->schemaLen = htonl(schemaLen);
|
||||
blk->numOfRows = htons(rows);
|
||||
blk->numOfRows = htonl(rows);
|
||||
blk->dataLen = htonl(dataLen);
|
||||
subReq->length += sizeof(SSubmitBlk) + schemaLen + dataLen;
|
||||
subReq->numOfBlocks++;
|
||||
|
|
|
@ -1739,6 +1739,9 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) {
|
|||
formatTimestamp(pBuf, *(uint64_t*)var, TSDB_TIME_PRECISION_MILLI);
|
||||
printf(" %25s |", pBuf);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
printf(" %15d |", *(int32_t*)var);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
printf(" %15d |", *(int32_t*)var);
|
||||
break;
|
||||
|
@ -1757,6 +1760,22 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) {
|
|||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
printf(" %15lf |", *(double*)var);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_VARCHAR: {
|
||||
char* pData = colDataGetVarData(pColInfoData, j);
|
||||
int32_t dataSize = TMIN(sizeof(pBuf) - 1, varDataLen(pData));
|
||||
memset(pBuf, 0, dataSize + 1);
|
||||
strncpy(pBuf, varDataVal(pData), dataSize);
|
||||
printf(" %15s |", pBuf);
|
||||
} break;
|
||||
case TSDB_DATA_TYPE_NCHAR: {
|
||||
char* pData = colDataGetVarData(pColInfoData, j);
|
||||
int32_t dataSize = TMIN(sizeof(pBuf), varDataLen(pData));
|
||||
memset(pBuf, 0, dataSize);
|
||||
taosUcs4ToMbs((TdUcs4*)varDataVal(pData), dataSize, pBuf);
|
||||
printf(" %15s |", pBuf);
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
|
@ -1773,8 +1792,10 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
|
|||
int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||
int32_t rows = pDataBlock->info.rows;
|
||||
int32_t len = 0;
|
||||
len += snprintf(dumpBuf + len, size - len, "===stream===%s|block type %d|child id %d|group id:%" PRIu64 "|uid:%ld|rows:%d|version:%" PRIu64 "\n", flag,
|
||||
(int32_t)pDataBlock->info.type, pDataBlock->info.childId, pDataBlock->info.groupId,
|
||||
len += snprintf(dumpBuf + len, size - len,
|
||||
"===stream===%s|block type %d|child id %d|group id:%" PRIu64 "|uid:%" PRId64
|
||||
"|rows:%d|version:%" PRIu64 "\n",
|
||||
flag, (int32_t)pDataBlock->info.type, pDataBlock->info.childId, pDataBlock->info.groupId,
|
||||
pDataBlock->info.uid, pDataBlock->info.rows, pDataBlock->info.version);
|
||||
if (len >= size - 1) return dumpBuf;
|
||||
|
||||
|
@ -1929,12 +1950,14 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
|
|||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_NCHAR: {
|
||||
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_NCHAR, TD_VTYPE_NORM, var, true,
|
||||
void* data = colDataGetData(pColInfoData, j);
|
||||
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_NCHAR, TD_VTYPE_NORM, data, true,
|
||||
offset, k);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_VARCHAR: { // TSDB_DATA_TYPE_BINARY
|
||||
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_VARCHAR, TD_VTYPE_NORM, var, true,
|
||||
void* data = colDataGetData(pColInfoData, j);
|
||||
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_VARCHAR, TD_VTYPE_NORM, data, true,
|
||||
offset, k);
|
||||
break;
|
||||
}
|
||||
|
@ -2005,11 +2028,10 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
|
|||
int32_t dataLen = blk->dataLen;
|
||||
blk->uid = htobe64(blk->uid);
|
||||
blk->suid = htobe64(blk->suid);
|
||||
blk->padding = htonl(blk->padding);
|
||||
blk->sversion = htonl(blk->sversion);
|
||||
blk->dataLen = htonl(blk->dataLen);
|
||||
blk->schemaLen = htonl(blk->schemaLen);
|
||||
blk->numOfRows = htons(blk->numOfRows);
|
||||
blk->numOfRows = htonl(blk->numOfRows);
|
||||
blk = (SSubmitBlk*)(blk->data + dataLen);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
#include "tcompare.h"
|
||||
#include "tconfig.h"
|
||||
#include "tdatablock.h"
|
||||
#include "tlog.h"
|
||||
#include "tgrant.h"
|
||||
#include "tlog.h"
|
||||
|
||||
GRANT_CFG_DECLARE;
|
||||
|
||||
|
@ -389,7 +389,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
tsNumOfVnodeQueryThreads = TMAX(tsNumOfVnodeQueryThreads, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 4, 1024, 0) != 0) return -1;
|
||||
|
||||
tsNumOfVnodeStreamThreads = tsNumOfCores / 4;
|
||||
tsNumOfVnodeStreamThreads = tsNumOfCores;
|
||||
tsNumOfVnodeStreamThreads = TMAX(tsNumOfVnodeStreamThreads, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfVnodeStreamThreads", tsNumOfVnodeStreamThreads, 4, 1024, 0) != 0) return -1;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -612,7 +612,6 @@ void taosLocalCfgForbiddenToChange(char* name, bool* forbidden) {
|
|||
*forbidden = false;
|
||||
}
|
||||
|
||||
|
||||
int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
||||
int32_t len = strlen(name);
|
||||
char lowcaseName[CFG_NAME_MAX_LEN + 1] = {0};
|
||||
|
@ -740,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;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ int32_t tGetSubmitMsgNext(SSubmitMsgIter *pIter, SSubmitBlk **pPBlock) {
|
|||
pIter->sversion = htonl((*pPBlock)->sversion);
|
||||
pIter->dataLen = htonl((*pPBlock)->dataLen);
|
||||
pIter->schemaLen = htonl((*pPBlock)->schemaLen);
|
||||
pIter->numOfRows = htons((*pPBlock)->numOfRows);
|
||||
pIter->numOfRows = htonl((*pPBlock)->numOfRows);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -146,8 +146,8 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
|
|||
|
||||
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, pHead->vgId);
|
||||
if (pVnode == NULL) {
|
||||
dGError("vgId:%d, msg:%p failed to put into vnode queue since %s, msgtype:%s qtype:%d", pHead->vgId, pMsg,
|
||||
terrstr(), TMSG_INFO(pMsg->msgType), qtype);
|
||||
dGError("vgId:%d, msg:%p failed to put into vnode queue since %s, type:%s qtype:%d", pHead->vgId, pMsg, terrstr(),
|
||||
TMSG_INFO(pMsg->msgType), qtype);
|
||||
return terrno != 0 ? terrno : -1;
|
||||
}
|
||||
|
||||
|
@ -165,14 +165,22 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
|
|||
break;
|
||||
case STREAM_QUEUE:
|
||||
dGTrace("vgId:%d, msg:%p put into vnode-stream queue", pVnode->vgId, pMsg);
|
||||
if (pMsg->msgType == TDMT_STREAM_TASK_DISPATCH) {
|
||||
vnodeEnqueueStreamMsg(pVnode->pImpl, pMsg);
|
||||
} else {
|
||||
taosWriteQitem(pVnode->pStreamQ, pMsg);
|
||||
}
|
||||
break;
|
||||
case FETCH_QUEUE:
|
||||
dGTrace("vgId:%d, msg:%p put into vnode-fetch queue", pVnode->vgId, pMsg);
|
||||
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());
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -878,14 +878,14 @@ static int32_t mndRetrieveConsumer(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *
|
|||
pShow->pIter = sdbFetch(pSdb, SDB_CONSUMER, pShow->pIter, (void **)&pConsumer);
|
||||
if (pShow->pIter == NULL) break;
|
||||
if (taosArrayGetSize(pConsumer->assignedTopics) == 0) {
|
||||
mDebug("showing consumer %ld no assigned topic, skip", pConsumer->consumerId);
|
||||
mDebug("showing consumer %" PRId64 " no assigned topic, skip", pConsumer->consumerId);
|
||||
sdbRelease(pSdb, pConsumer);
|
||||
continue;
|
||||
}
|
||||
|
||||
taosRLockLatch(&pConsumer->lock);
|
||||
|
||||
mDebug("showing consumer %ld", pConsumer->consumerId);
|
||||
mDebug("showing consumer %" PRId64, pConsumer->consumerId);
|
||||
|
||||
int32_t topicSz = taosArrayGetSize(pConsumer->assignedTopics);
|
||||
bool hasTopic = true;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1011,6 +1011,11 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
if ((terrno = grantCheck(TSDB_GRANT_STABLE)) < 0) {
|
||||
code = -1;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (isAlter) {
|
||||
bool needRsp = false;
|
||||
SStbObj pDst = {0};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ int32_t mndSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void **ppWrit
|
|||
|
||||
int32_t mndSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply, SSnapshot *pSnapshot) {
|
||||
mInfo("stop to apply snapshot to sdb, apply:%d, index:%" PRId64 " term:%" PRIu64 " config:%" PRId64, isApply,
|
||||
pSnapshot->lastApplyIndex, pSnapshot->lastApplyTerm, pSnapshot->lastApplyIndex);
|
||||
pSnapshot->lastApplyIndex, pSnapshot->lastApplyTerm, pSnapshot->lastConfigIndex);
|
||||
SMnode *pMnode = pFsm->data;
|
||||
return sdbStopWrite(pMnode->pSdb, pWriter, isApply, pSnapshot->lastApplyIndex, pSnapshot->lastApplyTerm,
|
||||
pSnapshot->lastConfigIndex);
|
||||
|
|
|
@ -30,15 +30,15 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SSnode {
|
||||
SMsgCb msgCb;
|
||||
} SSnode;
|
||||
|
||||
#if 0
|
||||
typedef struct {
|
||||
SHashObj* pHash; // taskId -> SStreamTask
|
||||
} SStreamMeta;
|
||||
|
||||
typedef struct SSnode {
|
||||
SStreamMeta* pMeta;
|
||||
SMsgCb msgCb;
|
||||
} SSnode;
|
||||
|
||||
SStreamMeta* sndMetaNew();
|
||||
void sndMetaDelete(SStreamMeta* pMeta);
|
||||
|
||||
|
@ -49,6 +49,7 @@ int32_t sndMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId);
|
|||
int32_t sndDropTaskOfStream(SStreamMeta* pMeta, int64_t streamId);
|
||||
int32_t sndStopTaskOfStream(SStreamMeta* pMeta, int64_t streamId);
|
||||
int32_t sndResumeTaskOfStream(SStreamMeta* pMeta, int64_t streamId);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
#include "executor.h"
|
||||
#include "sndInt.h"
|
||||
#include "tuuid.h"
|
||||
/*SSnode *sndOpen(const char *path, const SSnodeOpt *pOption) { return NULL; }*/
|
||||
/*void sndClose(SSnode *pSnode) {}*/
|
||||
int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) { return 0; }
|
||||
int32_t sndProcessSMsg(SSnode *pSnode, SRpcMsg *pMsg) { return 0; }
|
||||
|
||||
SSnode *sndOpen(const char *path, const SSnodeOpt *pOption) {
|
||||
SSnode *pSnode = taosMemoryCalloc(1, sizeof(SSnode));
|
||||
|
@ -23,21 +27,24 @@ SSnode *sndOpen(const char *path, const SSnodeOpt *pOption) {
|
|||
return NULL;
|
||||
}
|
||||
pSnode->msgCb = pOption->msgCb;
|
||||
#if 0
|
||||
pSnode->pMeta = sndMetaNew();
|
||||
if (pSnode->pMeta == NULL) {
|
||||
taosMemoryFree(pSnode);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
return pSnode;
|
||||
}
|
||||
|
||||
void sndClose(SSnode *pSnode) {
|
||||
sndMetaDelete(pSnode->pMeta);
|
||||
/*sndMetaDelete(pSnode->pMeta);*/
|
||||
taosMemoryFree(pSnode);
|
||||
}
|
||||
|
||||
int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad) { return 0; }
|
||||
|
||||
#if 0
|
||||
SStreamMeta *sndMetaNew() {
|
||||
SStreamMeta *pMeta = taosMemoryCalloc(1, sizeof(SStreamMeta));
|
||||
if (pMeta == NULL) {
|
||||
|
@ -151,7 +158,7 @@ static int32_t sndProcessTaskDispatchReq(SSnode *pNode, SRpcMsg *pMsg) {
|
|||
.info = pMsg->info,
|
||||
.code = 0,
|
||||
};
|
||||
streamProcessDispatchReq(pTask, &req, &rsp);
|
||||
streamProcessDispatchReq(pTask, &req, &rsp, true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -263,3 +270,4 @@ int32_t sndProcessSMsg(SSnode *pSnode, SRpcMsg *pMsg) {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -188,6 +188,8 @@ bool tqNextDataBlock(STqReader *pReader);
|
|||
bool tqNextDataBlockFilterOut(STqReader *pReader, SHashObj *filterOutUids);
|
||||
int32_t tqRetrieveDataBlock(SSDataBlock *pBlock, STqReader *pReader);
|
||||
|
||||
void vnodeEnqueueStreamMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
||||
|
||||
// sma
|
||||
int32_t smaGetTSmaDays(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days);
|
||||
|
||||
|
|
|
@ -41,6 +41,9 @@ typedef struct SRSmaStat SRSmaStat;
|
|||
typedef struct SSmaKey SSmaKey;
|
||||
typedef struct SRSmaInfo SRSmaInfo;
|
||||
typedef struct SRSmaInfoItem SRSmaInfoItem;
|
||||
typedef struct SQTaskFile SQTaskFile;
|
||||
typedef struct SQTaskFReader SQTaskFReader;
|
||||
typedef struct SQTaskFWriter SQTaskFWriter;
|
||||
|
||||
struct SSmaEnv {
|
||||
SRWLatch lock;
|
||||
|
@ -64,12 +67,32 @@ struct STSmaStat {
|
|||
STSchema *pTSchema;
|
||||
};
|
||||
|
||||
struct SQTaskFile {
|
||||
volatile int32_t nRef;
|
||||
int64_t commitID;
|
||||
int64_t size;
|
||||
};
|
||||
|
||||
struct SQTaskFReader {
|
||||
SSma *pSma;
|
||||
SQTaskFile fTask;
|
||||
TdFilePtr pReadH;
|
||||
};
|
||||
struct SQTaskFWriter {
|
||||
SSma *pSma;
|
||||
SQTaskFile fTask;
|
||||
TdFilePtr pWriteH;
|
||||
char *fname;
|
||||
};
|
||||
|
||||
struct SRSmaStat {
|
||||
SSma *pSma;
|
||||
int64_t commitAppliedVer; // vnode applied version for async commit
|
||||
int64_t refId; // shared by fetch tasks
|
||||
SRWLatch lock; // r/w lock for rsma fs(e.g. qtaskinfo)
|
||||
int8_t triggerStat; // shared by fetch tasks
|
||||
int8_t commitStat; // 0 not in committing, 1 in committing
|
||||
SArray *aTaskFile; // qTaskFiles committed recently(for recovery/snapshot r/w)
|
||||
SHashObj *rsmaInfoHash; // key: stbUid, value: SRSmaInfo;
|
||||
SHashObj *iRsmaInfoHash; // key: stbUid, value: SRSmaInfo; immutable rsmaInfoHash
|
||||
};
|
||||
|
@ -89,6 +112,7 @@ struct SSmaStat {
|
|||
#define RSMA_TRIGGER_STAT(r) (&(r)->triggerStat)
|
||||
#define RSMA_COMMIT_STAT(r) (&(r)->commitStat)
|
||||
#define RSMA_REF_ID(r) ((r)->refId)
|
||||
#define RSMA_FS_LOCK(r) (&(r)->lock)
|
||||
|
||||
struct SRSmaInfoItem {
|
||||
void *taskInfo; // qTaskInfo_t
|
||||
|
@ -127,6 +151,11 @@ enum {
|
|||
RSMA_ROLE_ITERATE = 4,
|
||||
};
|
||||
|
||||
enum {
|
||||
RSMA_RESTORE_REBOOT = 1,
|
||||
RSMA_RESTORE_SYNC = 2,
|
||||
};
|
||||
|
||||
void tdDestroySmaEnv(SSmaEnv *pSmaEnv);
|
||||
void *tdFreeSmaEnv(SSmaEnv *pSmaEnv);
|
||||
|
||||
|
@ -192,6 +221,8 @@ static FORCE_INLINE void tdSmaStatSetDropped(STSmaStat *pTStat) {
|
|||
}
|
||||
}
|
||||
|
||||
void tdRSmaQTaskInfoGetFileName(int32_t vid, int64_t version, char *outputName);
|
||||
void tdRSmaQTaskInfoGetFullName(int32_t vid, int64_t version, const char *path, char *outputName);
|
||||
int32_t tdCloneRSmaInfo(SSma *pSma, SRSmaInfo *pDest, SRSmaInfo *pSrc);
|
||||
void tdFreeQTaskInfo(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level);
|
||||
static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType);
|
||||
|
@ -201,7 +232,8 @@ void tdRemoveRSmaInfoBySuid(SSma *pSma, int64_t suid);
|
|||
int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash);
|
||||
|
||||
int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName);
|
||||
int32_t tdProcessRSmaRestoreImpl(SSma *pSma);
|
||||
int32_t tdProcessRSmaRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer);
|
||||
int32_t tdRsmaRestore(SSma *pSma, int8_t type, int64_t committedVer);
|
||||
|
||||
int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg);
|
||||
int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg);
|
||||
|
@ -209,9 +241,6 @@ int32_t tdProcessTSmaGetDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen,
|
|||
|
||||
// smaFileUtil ================
|
||||
|
||||
typedef struct SQTaskFReader SQTaskFReader;
|
||||
typedef struct SQTaskFWriter SQTaskFWriter;
|
||||
|
||||
#define TD_FILE_HEAD_SIZE 512
|
||||
|
||||
typedef struct STFInfo STFInfo;
|
||||
|
|
|
@ -115,15 +115,23 @@ typedef struct {
|
|||
} STqHandle;
|
||||
|
||||
struct STQ {
|
||||
SVnode* pVnode;
|
||||
char* path;
|
||||
SHashObj* pushMgr; // consumerId -> STqHandle*
|
||||
SHashObj* handles; // subKey -> STqHandle
|
||||
SHashObj* pStreamTasks; // taksId -> SStreamTask
|
||||
SHashObj* pAlterInfo; // topic -> SAlterCheckInfo
|
||||
|
||||
STqOffsetStore* pOffsetStore;
|
||||
SVnode* pVnode;
|
||||
|
||||
TDB* pMetaStore;
|
||||
TTB* pExecStore;
|
||||
|
||||
TTB* pAlterInfoStore;
|
||||
|
||||
TDB* pStreamStore;
|
||||
TTB* pTaskDb;
|
||||
TTB* pTaskState;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -163,7 +163,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen);
|
|||
int32_t tqProcessTaskDropReq(STQ* pTq, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* data, int64_t ver);
|
||||
int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg, bool exec);
|
||||
int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg);
|
||||
|
@ -186,6 +186,7 @@ int32_t smaSyncPostCommit(SSma* pSma);
|
|||
int32_t smaAsyncPreCommit(SSma* pSma);
|
||||
int32_t smaAsyncCommit(SSma* pSma);
|
||||
int32_t smaAsyncPostCommit(SSma* pSma);
|
||||
int32_t smaDoRetention(SSma* pSma, int64_t now);
|
||||
|
||||
int32_t tdProcessTSmaCreate(SSma* pSma, int64_t version, const char* msg);
|
||||
int32_t tdProcessTSmaInsert(SSma* pSma, int64_t indexUid, const char* msg);
|
||||
|
@ -354,16 +355,16 @@ struct SSma {
|
|||
void smaHandleRes(void* pVnode, int64_t smaId, const SArray* data);
|
||||
|
||||
enum {
|
||||
SNAP_DATA_META = 0,
|
||||
SNAP_DATA_TSDB = 1,
|
||||
SNAP_DATA_DEL = 2,
|
||||
SNAP_DATA_RSMA1 = 3,
|
||||
SNAP_DATA_RSMA2 = 4,
|
||||
SNAP_DATA_QTASK = 5,
|
||||
SNAP_DATA_TQ_HANDLE = 6,
|
||||
SNAP_DATA_TQ_OFFSET = 7,
|
||||
SNAP_DATA_STREAM_TASK = 8,
|
||||
SNAP_DATA_STREAM_STATE = 9,
|
||||
SNAP_DATA_META = 1,
|
||||
SNAP_DATA_TSDB = 2,
|
||||
SNAP_DATA_DEL = 3,
|
||||
SNAP_DATA_RSMA1 = 4,
|
||||
SNAP_DATA_RSMA2 = 5,
|
||||
SNAP_DATA_QTASK = 6,
|
||||
SNAP_DATA_TQ_HANDLE = 7,
|
||||
SNAP_DATA_TQ_OFFSET = 8,
|
||||
SNAP_DATA_STREAM_TASK = 9,
|
||||
SNAP_DATA_STREAM_STATE = 10,
|
||||
};
|
||||
|
||||
struct SSnapDataHdr {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
static FORCE_INLINE void *metaMalloc(void *pPool, size_t size) { return vnodeBufPoolMalloc((SVBufPool *)pPool, size); }
|
||||
static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVBufPool *)pPool, p); }
|
||||
|
||||
// begin a meta txn
|
||||
int metaBegin(SMeta *pMeta) {
|
||||
tdbTxnOpen(&pMeta->txn, 0, metaMalloc, metaFree, pMeta->pVnode->inUse, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
|
||||
|
||||
|
@ -28,4 +29,8 @@ int metaBegin(SMeta *pMeta) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
// commit the meta txn
|
||||
int metaCommit(SMeta *pMeta) { return tdbCommit(pMeta->pEnv, &pMeta->txn); }
|
||||
|
||||
// abort the meta txn
|
||||
int metaAbort(SMeta *pMeta) { return tdbAbort(pMeta->pEnv, &pMeta->txn); }
|
||||
|
|
|
@ -204,12 +204,12 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
|
||||
++pMeta->pVnode->config.vndStats.numOfSTables;
|
||||
|
||||
metaDebug("vgId:%d, super table is created, name:%s uid: %" PRId64, TD_VID(pMeta->pVnode), pReq->name, pReq->suid);
|
||||
metaDebug("vgId:%d, stb:%s is created, suid:%" PRId64, TD_VID(pMeta->pVnode), pReq->name, pReq->suid);
|
||||
|
||||
return 0;
|
||||
|
||||
_err:
|
||||
metaError("vgId:%d, failed to create super table: %s uid: %" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name,
|
||||
metaError("vgId:%d, failed to create stb:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name,
|
||||
pReq->suid, tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq) {
|
|||
|
||||
if (metaHandleEntry(pMeta, &me) < 0) goto _err;
|
||||
|
||||
metaDebug("vgId:%d, table %s uid %" PRId64 " is created, type:%" PRId8, TD_VID(pMeta->pVnode), pReq->name, pReq->uid,
|
||||
metaDebug("vgId:%d, table:%s uid %" PRId64 " is created, type:%" PRId8, TD_VID(pMeta->pVnode), pReq->name, pReq->uid,
|
||||
pReq->type);
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -241,6 +241,41 @@ static int32_t tdCleanupQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// SQTaskFile ======================================================
|
||||
// int32_t tCmprQTaskFile(void const *lhs, void const *rhs) {
|
||||
// int64_t *lCommitted = *(int64_t *)lhs;
|
||||
// SQTaskFile *rQTaskF = (SQTaskFile *)rhs;
|
||||
|
||||
// if (lCommitted < rQTaskF->commitID) {
|
||||
// return -1;
|
||||
// } else if (lCommitted > rQTaskF->commitID) {
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* @brief At most time, there is only one qtaskinfo file committed latest in aTaskFile. Sometimes, there would be
|
||||
* multiple qtaskinfo files supporting snapshot replication.
|
||||
*
|
||||
* @param pSma
|
||||
* @param pRSmaStat
|
||||
* @return int32_t
|
||||
*/
|
||||
static int32_t tdCleanupQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat) {
|
||||
SVnode *pVnode = pSma->pVnode;
|
||||
int64_t committed = pRSmaStat->commitAppliedVer;
|
||||
SArray *aTaskFile = pRSmaStat->aTaskFile;
|
||||
|
||||
void *qTaskFile = taosArraySearch(aTaskFile, committed, tCmprQTaskFile, TD_LE);
|
||||
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief post-commit for rollup sma
|
||||
* 1) clean up the outdated qtaskinfo files
|
||||
|
|
|
@ -295,6 +295,9 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
|
|||
nLoops = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// step 4: free pStat
|
||||
taosMemoryFreeClear(pStat);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -321,12 +324,13 @@ int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) {
|
|||
tdDestroyTSmaStat(SMA_TSMA_STAT(pSmaStat));
|
||||
} else if (smaType == TSDB_SMA_TYPE_ROLLUP) {
|
||||
SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pSmaStat);
|
||||
int32_t vid = SMA_VID(pRSmaStat->pSma);
|
||||
int64_t refId = RSMA_REF_ID(pRSmaStat);
|
||||
if (taosRemoveRef(smaMgmt.rsetId, RSMA_REF_ID(pRSmaStat)) < 0) {
|
||||
smaError("vgId:%d, remove refId:%" PRIi64 " from rsmaRef:%" PRIi32 " failed since %s", SMA_VID(pRSmaStat->pSma),
|
||||
RSMA_REF_ID(pRSmaStat), smaMgmt.rsetId, terrstr());
|
||||
smaError("vgId:%d, remove refId:%" PRIi64 " from rsmaRef:%" PRIi32 " failed since %s", vid, refId,
|
||||
smaMgmt.rsetId, terrstr());
|
||||
} else {
|
||||
smaDebug("vgId:%d, remove refId:%" PRIi64 " from rsmaRef:%" PRIi32 " succeed", SMA_VID(pRSmaStat->pSma),
|
||||
RSMA_REF_ID(pRSmaStat), smaMgmt.rsetId);
|
||||
smaDebug("vgId:%d, remove refId:%" PRIi64 " from rsmaRef:%" PRIi32 " succeed", vid, refId, smaMgmt.rsetId);
|
||||
}
|
||||
} else {
|
||||
ASSERT(0);
|
||||
|
|
|
@ -123,7 +123,7 @@ int32_t smaOpen(SVnode *pVnode) {
|
|||
}
|
||||
|
||||
// restore the rsma
|
||||
if (rsmaRestore(pSma) < 0) {
|
||||
if (tdRsmaRestore(pSma, RSMA_RESTORE_REBOOT, pVnode->state.committed) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
|
@ -150,10 +150,12 @@ int32_t smaClose(SSma *pSma) {
|
|||
* @brief rsma env restore
|
||||
*
|
||||
* @param pSma
|
||||
* @param type
|
||||
* @param committedVer
|
||||
* @return int32_t
|
||||
*/
|
||||
static int32_t rsmaRestore(SSma *pSma) {
|
||||
int32_t tdRsmaRestore(SSma *pSma, int8_t type, int64_t committedVer) {
|
||||
ASSERT(VND_IS_RSMA(pSma->pVnode));
|
||||
|
||||
return tdProcessRSmaRestoreImpl(pSma);
|
||||
return tdProcessRSmaRestoreImpl(pSma, type, committedVer);
|
||||
}
|
|
@ -38,16 +38,15 @@ static SRSmaInfo *tdGetRSmaInfoBySuid(SSma *pSma, int64_t suid);
|
|||
static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSchema, int64_t suid, SRSmaStat *pStat,
|
||||
int8_t blkType);
|
||||
static void tdRSmaFetchTrigger(void *param, void *tmrId);
|
||||
static void tdRSmaQTaskInfoGetFName(int32_t vid, int64_t version, char *outputName);
|
||||
|
||||
static int32_t tdRSmaQTaskInfoIterInit(SRSmaQTaskInfoIter *pIter, STFile *pTFile);
|
||||
static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isFinish);
|
||||
static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter);
|
||||
static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, int8_t type, SRSmaQTaskInfoIter *pIter);
|
||||
static int32_t tdRSmaQTaskInfoItemRestore(SSma *pSma, const SRSmaQTaskInfoItem *infoItem);
|
||||
|
||||
static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables);
|
||||
static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int64_t *committed);
|
||||
static int32_t tdRSmaRestoreTSDataReload(SSma *pSma, int64_t committed);
|
||||
static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int8_t type, int64_t qTaskFileVer);
|
||||
static int32_t tdRSmaRestoreTSDataReload(SSma *pSma);
|
||||
|
||||
static SRSmaInfo *tdGetRSmaInfoByItem(SRSmaInfoItem *pItem) {
|
||||
// adapt accordingly if definition of SRSmaInfo update
|
||||
|
@ -77,10 +76,14 @@ struct SRSmaQTaskInfoIter {
|
|||
int32_t nBufPos;
|
||||
};
|
||||
|
||||
static void tdRSmaQTaskInfoGetFName(int32_t vgId, int64_t version, char *outputName) {
|
||||
void tdRSmaQTaskInfoGetFileName(int32_t vgId, int64_t version, char *outputName) {
|
||||
tdGetVndFileName(vgId, NULL, VNODE_RSMA_DIR, TD_QTASKINFO_FNAME_PREFIX, version, outputName);
|
||||
}
|
||||
|
||||
void tdRSmaQTaskInfoGetFullName(int32_t vgId, int64_t version, const char *path, char *outputName) {
|
||||
tdGetVndFileName(vgId, path, VNODE_RSMA_DIR, TD_QTASKINFO_FNAME_PREFIX, version, outputName);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tdRSmaQTaskInfoContLen(int32_t lenWithHead) {
|
||||
return lenWithHead - RSMA_QTASKINFO_HEAD_LEN;
|
||||
}
|
||||
|
@ -89,7 +92,7 @@ static FORCE_INLINE void tdRSmaQTaskInfoIterDestroy(SRSmaQTaskInfoIter *pIter) {
|
|||
|
||||
void tdFreeQTaskInfo(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level) {
|
||||
// Note: free/kill may in RC
|
||||
if (!taskHandle) return;
|
||||
if (!taskHandle || !(*taskHandle)) return;
|
||||
qTaskInfo_t otaskHandle = atomic_load_ptr(taskHandle);
|
||||
if (otaskHandle && atomic_val_compare_exchange_ptr(taskHandle, otaskHandle, NULL)) {
|
||||
smaDebug("vgId:%d, free qTaskInfo_t %p of level %d", vgId, otaskHandle, level);
|
||||
|
@ -125,7 +128,7 @@ void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree) {
|
|||
}
|
||||
}
|
||||
if (isDeepFree) {
|
||||
taosMemoryFree(pInfo->pTSchema);
|
||||
taosMemoryFreeClear(pInfo->pTSchema);
|
||||
}
|
||||
taosMemoryFree(pInfo);
|
||||
}
|
||||
|
@ -316,9 +319,13 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con
|
|||
|
||||
pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t));
|
||||
if (pRSmaInfo) {
|
||||
ASSERT(0); // TODO: free original pRSmaInfo if exists abnormally
|
||||
smaDebug("vgId:%d, rsma info already exists for table %s, %" PRIi64, SMA_VID(pSma), tbName, suid);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
// TODO: free original pRSmaInfo if exists abnormally
|
||||
tdFreeRSmaInfo(pSma, *(SRSmaInfo **)pRSmaInfo, true);
|
||||
if (taosHashRemove(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t)) < 0) {
|
||||
terrno = TSDB_CODE_RSMA_REMOVE_EXISTS;
|
||||
goto _err;
|
||||
}
|
||||
smaWarn("vgId:%d, remove the rsma info already exists for table %s, %" PRIi64, SMA_VID(pSma), tbName, suid);
|
||||
}
|
||||
|
||||
// from write queue: single thead
|
||||
|
@ -597,10 +604,10 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche
|
|||
#endif
|
||||
STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb[0] : pSma->pRSmaTsdb[1]);
|
||||
SSubmitReq *pReq = NULL;
|
||||
// TODO: the schema update should be handled
|
||||
// TODO: the schema update should be handled later(TD-17965)
|
||||
if (buildSubmitReqFromDataBlock(&pReq, pResult, pTSchema, SMA_VID(pSma), suid) < 0) {
|
||||
smaError("vgId:%d, build submit req for rsma stable %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma),
|
||||
suid, pItem->level, terrstr());
|
||||
smaError("vgId:%d, build submit req for rsma stable %" PRIi64 " level %" PRIi8 " failed since %s",
|
||||
SMA_VID(pSma), suid, pItem->level, terrstr());
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -619,7 +626,7 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche
|
|||
} else if (terrno == 0) {
|
||||
smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched yet", SMA_VID(pSma), pItem->level);
|
||||
} else {
|
||||
smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched since %s", SMA_VID(pSma), pItem->level, tstrerror(terrno));
|
||||
smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched since %s", SMA_VID(pSma), pItem->level, terrstr());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -869,24 +876,23 @@ _err:
|
|||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int64_t *committed) {
|
||||
static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int8_t type, int64_t qTaskFileVer) {
|
||||
SVnode *pVnode = pSma->pVnode;
|
||||
STFile tFile = {0};
|
||||
char qTaskInfoFName[TSDB_FILENAME_LEN] = {0};
|
||||
|
||||
tdRSmaQTaskInfoGetFName(TD_VID(pVnode), pVnode->state.committed, qTaskInfoFName);
|
||||
tdRSmaQTaskInfoGetFileName(TD_VID(pVnode), qTaskFileVer, qTaskInfoFName);
|
||||
if (tdInitTFile(&tFile, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFName) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
if (!taosCheckExistFile(TD_TFILE_FULL_NAME(&tFile))) {
|
||||
*committed = 0;
|
||||
if (pVnode->state.committed > 0) {
|
||||
smaWarn("vgId:%d, rsma restore for version %" PRIi64 ", not start as %s not exist", TD_VID(pVnode),
|
||||
pVnode->state.committed, TD_TFILE_FULL_NAME(&tFile));
|
||||
if (qTaskFileVer > 0) {
|
||||
smaWarn("vgId:%d, restore rsma task %" PRIi8 " for version %" PRIi64 ", not start as %s not exist",
|
||||
TD_VID(pVnode), type, qTaskFileVer, TD_TFILE_FULL_NAME(&tFile));
|
||||
} else {
|
||||
smaDebug("vgId:%d, rsma restore for version %" PRIi64 ", no need as %s not exist", TD_VID(pVnode),
|
||||
pVnode->state.committed, TD_TFILE_FULL_NAME(&tFile));
|
||||
smaDebug("vgId:%d, restore rsma task %" PRIi8 " for version %" PRIi64 ", no need as %s not exist", TD_VID(pVnode),
|
||||
type, qTaskFileVer, TD_TFILE_FULL_NAME(&tFile));
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -911,7 +917,7 @@ static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int64_t *committed) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
if (tdRSmaQTaskInfoRestore(pSma, &fIter) < 0) {
|
||||
if (tdRSmaQTaskInfoRestore(pSma, type, &fIter) < 0) {
|
||||
tdRSmaQTaskInfoIterDestroy(&fIter);
|
||||
tdCloseTFile(&tFile);
|
||||
tdDestroyTFile(&tFile);
|
||||
|
@ -922,13 +928,13 @@ static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int64_t *committed) {
|
|||
tdCloseTFile(&tFile);
|
||||
tdDestroyTFile(&tFile);
|
||||
|
||||
// restored successfully from committed
|
||||
*committed = pVnode->state.committed;
|
||||
|
||||
// restored successfully from committed or sync
|
||||
smaInfo("vgId:%d, restore rsma task %" PRIi8 " for version %" PRIi64 ", qtaskinfo reload succeed", TD_VID(pVnode),
|
||||
type, qTaskFileVer);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
_err:
|
||||
smaError("vgId:%d, rsma restore for version %" PRIi64 ", qtaskinfo reload failed since %s", TD_VID(pVnode),
|
||||
pVnode->state.committed, terrstr());
|
||||
smaError("vgId:%d, restore rsma task %" PRIi8 " for version %" PRIi64 ", qtaskinfo reload failed since %s",
|
||||
TD_VID(pVnode), type, qTaskFileVer, terrstr());
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
|
@ -936,15 +942,14 @@ _err:
|
|||
* @brief reload ts data from checkpoint
|
||||
*
|
||||
* @param pSma
|
||||
* @param committed restore from committed version
|
||||
* @return int32_t
|
||||
*/
|
||||
static int32_t tdRSmaRestoreTSDataReload(SSma *pSma, int64_t committed) {
|
||||
static int32_t tdRSmaRestoreTSDataReload(SSma *pSma) {
|
||||
// NOTHING TODO: the data would be restored from the unified WAL replay procedure
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t tdProcessRSmaRestoreImpl(SSma *pSma) {
|
||||
int32_t tdProcessRSmaRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer) {
|
||||
// step 1: iterate all stables to restore the rsma env
|
||||
int64_t nTables = 0;
|
||||
if (tdRSmaRestoreQTaskInfoInit(pSma, &nTables) < 0) {
|
||||
|
@ -952,24 +957,24 @@ int32_t tdProcessRSmaRestoreImpl(SSma *pSma) {
|
|||
}
|
||||
|
||||
if (nTables <= 0) {
|
||||
smaDebug("vgId:%d, no need to restore rsma task since no tables", SMA_VID(pSma));
|
||||
smaDebug("vgId:%d, no need to restore rsma task %" PRIi8 " since no tables", SMA_VID(pSma), type);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// step 2: retrieve qtaskinfo items from the persistence file(rsma/qtaskinfo) and restore
|
||||
int64_t committed = -1;
|
||||
if (tdRSmaRestoreQTaskInfoReload(pSma, &committed) < 0) {
|
||||
if (tdRSmaRestoreQTaskInfoReload(pSma, type, qtaskFileVer) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// step 3: reload ts data from checkpoint
|
||||
if (tdRSmaRestoreTSDataReload(pSma, committed) < 0) {
|
||||
if (tdRSmaRestoreTSDataReload(pSma) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
smaInfo("vgId:%d, restore rsma task %" PRIi8 " from qtaskf %" PRIi64 " succeed", SMA_VID(pSma), type, qtaskFileVer);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
_err:
|
||||
smaError("vgId:%d, failed to restore rsma task since %s", SMA_VID(pSma), terrstr());
|
||||
smaError("vgId:%d, restore rsma task %" PRIi8 "from qtaskf %" PRIi64 " failed since %s", SMA_VID(pSma), type,
|
||||
qtaskFileVer, terrstr());
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
|
@ -1098,7 +1103,7 @@ static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isF
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) {
|
||||
static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, int8_t type, SRSmaQTaskInfoIter *pIter) {
|
||||
while (1) {
|
||||
// block iter
|
||||
bool isFinish = false;
|
||||
|
@ -1114,7 +1119,7 @@ static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) {
|
|||
pIter->qBuf = taosDecodeFixedI32(pIter->qBuf, &qTaskInfoLenWithHead);
|
||||
if (qTaskInfoLenWithHead < RSMA_QTASKINFO_HEAD_LEN) {
|
||||
terrno = TSDB_CODE_TDB_FILE_CORRUPTED;
|
||||
smaError("vgId:%d, restore rsma qtaskinfo file %s failed since %s", SMA_VID(pSma),
|
||||
smaError("vgId:%d, restore rsma task %" PRIi8 " from qtaskinfo file %s failed since %s", SMA_VID(pSma), type,
|
||||
TD_TFILE_FULL_NAME(pIter->pTFile), terrstr());
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
@ -1127,8 +1132,8 @@ static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) {
|
|||
infoItem.qTaskInfo = pIter->qBuf;
|
||||
infoItem.len = tdRSmaQTaskInfoContLen(qTaskInfoLenWithHead);
|
||||
// do the restore job
|
||||
smaDebug("vgId:%d, restore the qtask info %s offset:%" PRIi64 "\n", SMA_VID(pSma),
|
||||
TD_TFILE_FULL_NAME(pIter->pTFile), pIter->offset - pIter->nBytes + pIter->nBufPos);
|
||||
smaDebug("vgId:%d, restore rsma task %" PRIi8 " from qtaskinfo file %s offset:%" PRIi64 "\n", SMA_VID(pSma),
|
||||
type, TD_TFILE_FULL_NAME(pIter->pTFile), pIter->offset - pIter->nBytes + pIter->nBufPos);
|
||||
tdRSmaQTaskInfoItemRestore(pSma, &infoItem);
|
||||
|
||||
pIter->qBuf = POINTER_SHIFT(pIter->qBuf, infoItem.len);
|
||||
|
@ -1172,7 +1177,7 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) {
|
|||
#if 0
|
||||
if (pRSmaStat->commitAppliedVer > 0) {
|
||||
char qTaskInfoFName[TSDB_FILENAME_LEN];
|
||||
tdRSmaQTaskInfoGetFName(vid, pRSmaStat->commitAppliedVer, qTaskInfoFName);
|
||||
tdRSmaQTaskInfoGetFileName(vid, pRSmaStat->commitAppliedVer, qTaskInfoFName);
|
||||
if (tdInitTFile(&tFile, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFName) < 0) {
|
||||
smaError("vgId:%d, rsma persit, init %s failed since %s", vid, qTaskInfoFName, terrstr());
|
||||
goto _err;
|
||||
|
@ -1217,7 +1222,7 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) {
|
|||
|
||||
if (!isFileCreated) {
|
||||
char qTaskInfoFName[TSDB_FILENAME_LEN];
|
||||
tdRSmaQTaskInfoGetFName(vid, pRSmaStat->commitAppliedVer, qTaskInfoFName);
|
||||
tdRSmaQTaskInfoGetFileName(vid, pRSmaStat->commitAppliedVer, qTaskInfoFName);
|
||||
if (tdInitTFile(&tFile, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFName) < 0) {
|
||||
smaError("vgId:%d, rsma persit, init %s failed since %s", vid, qTaskInfoFName, terrstr());
|
||||
goto _err;
|
||||
|
@ -1331,6 +1336,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
|||
SSDataBlock dataBlock = {.info.type = STREAM_GET_ALL};
|
||||
qSetMultiStreamInput(pItem->taskInfo, &dataBlock, 1, STREAM_INPUT__DATA_BLOCK);
|
||||
tdRSmaFetchAndSubmitResult(pItem, pRSmaInfo->pTSchema, pRSmaInfo->suid, pStat, STREAM_INPUT__DATA_BLOCK);
|
||||
tdCleanupStreamInputDataBlock(pItem->taskInfo);
|
||||
|
||||
tdUnRefRSmaInfo(pSma, pRSmaInfo);
|
||||
// atomic_store_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE);
|
||||
|
@ -1357,3 +1363,20 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
|||
_end:
|
||||
tdReleaseSmaRef(smaMgmt.rsetId, pItem->refId, __func__, __LINE__);
|
||||
}
|
||||
|
||||
int32_t smaDoRetention(SSma *pSma, int64_t now) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (VND_IS_RSMA(pSma->pVnode)) {
|
||||
return code;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
|
||||
if (pSma->pRSmaTsdb[i]) {
|
||||
code = tsdbDoRetention(pSma->pRSmaTsdb[i], now);
|
||||
if (code) goto _end;
|
||||
}
|
||||
}
|
||||
|
||||
_end:
|
||||
return code;
|
||||
}
|
|
@ -35,6 +35,7 @@ struct SRsmaSnapReader {
|
|||
|
||||
int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapReader** ppReader) {
|
||||
int32_t code = 0;
|
||||
SVnode* pVnode = pSma->pVnode;
|
||||
SRsmaSnapReader* pReader = NULL;
|
||||
|
||||
// alloc
|
||||
|
@ -47,6 +48,7 @@ int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapRead
|
|||
pReader->sver = sver;
|
||||
pReader->ever = ever;
|
||||
|
||||
// rsma1/rsma2
|
||||
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
|
||||
if (pSma->pRSmaTsdb[i]) {
|
||||
code = tsdbSnapReaderOpen(pSma->pRSmaTsdb[i], sver, ever, i == 0 ? SNAP_DATA_RSMA1 : SNAP_DATA_RSMA2,
|
||||
|
@ -56,23 +58,98 @@ int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapRead
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// qtaskinfo
|
||||
// 1. add ref to qtaskinfo.v${ever} if exists and then start to replicate
|
||||
char qTaskInfoFullName[TSDB_FILENAME_LEN];
|
||||
tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), ever, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName);
|
||||
|
||||
if (!taosCheckExistFile(qTaskInfoFullName)) {
|
||||
smaInfo("vgId:%d, vnode snapshot rsma reader for qtaskinfo not need as %s not exists", TD_VID(pVnode),
|
||||
qTaskInfoFullName);
|
||||
} else {
|
||||
pReader->pQTaskFReader = taosMemoryCalloc(1, sizeof(SQTaskFReader));
|
||||
if (!pReader->pQTaskFReader) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
TdFilePtr qTaskF = taosOpenFile(qTaskInfoFullName, TD_FILE_READ);
|
||||
if (!qTaskF) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
pReader->pQTaskFReader->pReadH = qTaskF;
|
||||
#if 0
|
||||
SQTaskFile* pQTaskF = &pReader->pQTaskFReader->fTask;
|
||||
pQTaskF->nRef = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
*ppReader = pReader;
|
||||
smaInfo("vgId:%d, vnode snapshot rsma reader opened succeed", SMA_VID(pSma));
|
||||
smaInfo("vgId:%d, vnode snapshot rsma reader opened %s succeed", TD_VID(pVnode), qTaskInfoFullName);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
_err:
|
||||
smaError("vgId:%d, vnode snapshot rsma reader opened failed since %s", SMA_VID(pSma), tstrerror(code));
|
||||
smaError("vgId:%d, vnode snapshot rsma reader opened failed since %s", TD_VID(pVnode), tstrerror(code));
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
static int32_t rsmaSnapReadQTaskInfo(SRsmaSnapReader* pReader, uint8_t** ppData) {
|
||||
static int32_t rsmaSnapReadQTaskInfo(SRsmaSnapReader* pReader, uint8_t** ppBuf) {
|
||||
int32_t code = 0;
|
||||
SSma* pSma = pReader->pSma;
|
||||
int64_t n = 0;
|
||||
uint8_t* pBuf = NULL;
|
||||
SQTaskFReader* qReader = pReader->pQTaskFReader;
|
||||
|
||||
if (!qReader->pReadH) {
|
||||
*ppBuf = NULL;
|
||||
smaInfo("vgId:%d, vnode snapshot rsma reader qtaskinfo, readh is empty", SMA_VID(pSma));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t size = 0;
|
||||
if (taosFStatFile(qReader->pReadH, &size, NULL) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// seek
|
||||
if (taosLSeekFile(qReader->pReadH, 0, SEEK_SET) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
ASSERT(!(*ppBuf));
|
||||
// alloc
|
||||
*ppBuf = taosMemoryCalloc(1, sizeof(SSnapDataHdr) + size);
|
||||
if (!(*ppBuf)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// read
|
||||
n = taosReadFile(qReader->pReadH, POINTER_SHIFT(*ppBuf, sizeof(SSnapDataHdr)), size);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
} else if (n != size) {
|
||||
code = TSDB_CODE_FILE_CORRUPTED;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
smaInfo("vgId:%d, vnode snapshot rsma read qtaskinfo, size:%" PRIi64, SMA_VID(pSma), size);
|
||||
|
||||
|
||||
SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppBuf);
|
||||
pHdr->type = SNAP_DATA_QTASK;
|
||||
pHdr->size = size;
|
||||
|
||||
_exit:
|
||||
smaInfo("vgId:%d, vnode snapshot rsma read qtaskinfo succeed", SMA_VID(pSma));
|
||||
return code;
|
||||
|
||||
_err:
|
||||
*ppBuf = NULL;
|
||||
smaError("vgId:%d, vnode snapshot rsma read qtaskinfo failed since %s", SMA_VID(pSma), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
@ -108,14 +185,14 @@ int32_t rsmaSnapRead(SRsmaSnapReader* pReader, uint8_t** ppData) {
|
|||
|
||||
// read qtaskinfo file
|
||||
if (!pReader->qTaskDone) {
|
||||
smaInfo("vgId:%d, vnode snapshot rsma qtaskinfo not done", SMA_VID(pReader->pSma));
|
||||
code = rsmaSnapReadQTaskInfo(pReader, ppData);
|
||||
if (code) {
|
||||
goto _err;
|
||||
} else {
|
||||
pReader->qTaskDone = 1;
|
||||
if (*ppData) {
|
||||
goto _exit;
|
||||
} else {
|
||||
pReader->qTaskDone = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,11 +217,11 @@ int32_t rsmaSnapReaderClose(SRsmaSnapReader** ppReader) {
|
|||
}
|
||||
|
||||
if (pReader->pQTaskFReader) {
|
||||
// TODO: close for qtaskinfo
|
||||
taosCloseFile(&pReader->pQTaskFReader->pReadH);
|
||||
taosMemoryFreeClear(pReader->pQTaskFReader);
|
||||
smaInfo("vgId:%d, vnode snapshot rsma reader closed for qTaskInfo", SMA_VID(pReader->pSma));
|
||||
}
|
||||
|
||||
|
||||
smaInfo("vgId:%d, vnode snapshot rsma reader closed", SMA_VID(pReader->pSma));
|
||||
|
||||
taosMemoryFreeClear(*ppReader);
|
||||
|
@ -171,6 +248,7 @@ struct SRsmaSnapWriter {
|
|||
int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapWriter** ppWriter) {
|
||||
int32_t code = 0;
|
||||
SRsmaSnapWriter* pWriter = NULL;
|
||||
SVnode* pVnode = pSma->pVnode;
|
||||
|
||||
// alloc
|
||||
pWriter = (SRsmaSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
|
||||
|
@ -182,6 +260,7 @@ int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapWrit
|
|||
pWriter->sver = sver;
|
||||
pWriter->ever = ever;
|
||||
|
||||
// rsma1/rsma2
|
||||
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
|
||||
if (pSma->pRSmaTsdb[i]) {
|
||||
code = tsdbSnapWriterOpen(pSma->pRSmaTsdb[i], sver, ever, &pWriter->pDataWriter[i]);
|
||||
|
@ -192,8 +271,25 @@ int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapWrit
|
|||
}
|
||||
|
||||
// qtaskinfo
|
||||
// TODO
|
||||
SQTaskFWriter* qWriter = (SQTaskFWriter*)taosMemoryCalloc(1, sizeof(SQTaskFWriter));
|
||||
qWriter->pSma = pSma;
|
||||
|
||||
char qTaskInfoFullName[TSDB_FILENAME_LEN];
|
||||
tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), 0, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName);
|
||||
TdFilePtr qTaskF = taosCreateFile(qTaskInfoFullName, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (!qTaskF) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
smaError("vgId:%d, rsma snapshot writer open %s failed since %s", TD_VID(pSma->pVnode), qTaskInfoFullName, tstrerror(code));
|
||||
goto _err;
|
||||
}
|
||||
qWriter->pWriteH = qTaskF;
|
||||
int32_t fnameLen = strlen(qTaskInfoFullName) + 1;
|
||||
qWriter->fname = taosMemoryCalloc(1, fnameLen);
|
||||
strncpy(qWriter->fname, qTaskInfoFullName, fnameLen);
|
||||
pWriter->pQTaskFWriter = qWriter;
|
||||
smaDebug("vgId:%d, rsma snapshot writer open succeed for %s", TD_VID(pSma->pVnode), qTaskInfoFullName);
|
||||
|
||||
// snapWriter
|
||||
*ppWriter = pWriter;
|
||||
|
||||
smaInfo("vgId:%d, rsma snapshot writer open succeed", TD_VID(pSma->pVnode));
|
||||
|
@ -208,18 +304,39 @@ _err:
|
|||
int32_t rsmaSnapWriterClose(SRsmaSnapWriter** ppWriter, int8_t rollback) {
|
||||
int32_t code = 0;
|
||||
SRsmaSnapWriter* pWriter = *ppWriter;
|
||||
SVnode* pVnode = pWriter->pSma->pVnode;
|
||||
|
||||
if (rollback) {
|
||||
ASSERT(0);
|
||||
// code = tsdbFSRollback(pWriter->pTsdb->pFS);
|
||||
// if (code) goto _err;
|
||||
// TODO: rsma1/rsma2
|
||||
// qtaskinfo
|
||||
if(pWriter->pQTaskFWriter) {
|
||||
taosRemoveFile(pWriter->pQTaskFWriter->fname);
|
||||
}
|
||||
} else {
|
||||
// rsma1/rsma2
|
||||
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
|
||||
if (pWriter->pDataWriter[i]) {
|
||||
code = tsdbSnapWriterClose(&pWriter->pDataWriter[i], rollback);
|
||||
if (code) goto _err;
|
||||
}
|
||||
}
|
||||
// qtaskinfo
|
||||
if (pWriter->pQTaskFWriter) {
|
||||
char qTaskInfoFullName[TSDB_FILENAME_LEN];
|
||||
tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), pWriter->ever, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName);
|
||||
if (taosRenameFile(pWriter->pQTaskFWriter->fname, qTaskInfoFullName) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
smaInfo("vgId:%d, vnode snapshot rsma writer rename %s to %s", SMA_VID(pWriter->pSma),
|
||||
pWriter->pQTaskFWriter->fname, qTaskInfoFullName);
|
||||
|
||||
// rsma restore
|
||||
if ((code = tdRsmaRestore(pWriter->pSma, RSMA_RESTORE_SYNC, pWriter->ever)) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
smaInfo("vgId:%d, vnode snapshot rsma writer restore from %s succeed", SMA_VID(pWriter->pSma), qTaskInfoFullName);
|
||||
}
|
||||
}
|
||||
|
||||
smaInfo("vgId:%d, vnode snapshot rsma writer close succeed", SMA_VID(pWriter->pSma));
|
||||
|
@ -262,25 +379,22 @@ _err:
|
|||
|
||||
static int32_t rsmaSnapWriteQTaskInfo(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||
int32_t code = 0;
|
||||
SQTaskFWriter* qWriter = pWriter->pQTaskFWriter;
|
||||
|
||||
if (pWriter->pQTaskFWriter == NULL) {
|
||||
// SDelFile* pDelFile = pWriter->fs.pDelFile;
|
||||
|
||||
// // reader
|
||||
// if (pDelFile) {
|
||||
// code = tsdbDelFReaderOpen(&pWriter->pDelFReader, pDelFile, pTsdb, NULL);
|
||||
// if (code) goto _err;
|
||||
|
||||
// code = tsdbReadDelIdx(pWriter->pDelFReader, pWriter->aDelIdxR, NULL);
|
||||
// if (code) goto _err;
|
||||
// }
|
||||
|
||||
// // writer
|
||||
// SDelFile delFile = {.commitID = pWriter->commitID, .offset = 0, .size = 0};
|
||||
// code = tsdbDelFWriterOpen(&pWriter->pDelFWriter, &delFile, pTsdb);
|
||||
// if (code) goto _err;
|
||||
if (qWriter && qWriter->pWriteH) {
|
||||
SSnapDataHdr* pHdr = (SSnapDataHdr*)pData;
|
||||
int64_t size = pHdr->size;
|
||||
ASSERT(size == (nData - sizeof(SSnapDataHdr)));
|
||||
int64_t contLen = taosWriteFile(qWriter->pWriteH, pHdr->data, size);
|
||||
if (contLen != size) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
smaInfo("vgId:%d, vnode snapshot rsma write qtaskinfo succeed", SMA_VID(pWriter->pSma));
|
||||
} else {
|
||||
smaInfo("vgId:%d, vnode snapshot rsma write qtaskinfo is not needed", SMA_VID(pWriter->pSma));
|
||||
}
|
||||
|
||||
smaInfo("vgId:%d, vnode snapshot rsma write qtaskinfo %s succeed", SMA_VID(pWriter->pSma), qWriter->fname);
|
||||
_exit:
|
||||
return code;
|
||||
|
||||
|
|
|
@ -216,11 +216,13 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
|
||||
if (offset.val.type == TMQ_OFFSET__LOG) {
|
||||
STqHandle* pHandle = taosHashGet(pTq->handles, offset.subKey, strlen(offset.subKey));
|
||||
if (pHandle) {
|
||||
if (walRefVer(pHandle->pRef, offset.val.version) < 0) {
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*}*/
|
||||
/*}*/
|
||||
|
@ -280,8 +282,6 @@ static int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq, int8_t su
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tqInitMetaRsp(SMqMetaRsp* pRsp, const SMqPollReq* pReq) { return 0; }
|
||||
|
||||
int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||
SMqPollReq* pReq = pMsg->pCont;
|
||||
int64_t consumerId = pReq->consumerId;
|
||||
|
@ -317,7 +317,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
|
||||
char buf[80];
|
||||
tFormatOffset(buf, 80, &reqOffset);
|
||||
tqDebug("tmq poll: consumer %ld (epoch %d), subkey %s, recv poll req in vg %d, req offset %s", consumerId,
|
||||
tqDebug("tmq poll: consumer %" PRId64 " (epoch %d), subkey %s, recv poll req in vg %d, req offset %s", consumerId,
|
||||
pReq->epoch, pHandle->subKey, TD_VID(pTq->pVnode), buf);
|
||||
|
||||
SMqDataRsp dataRsp = {0};
|
||||
|
@ -348,8 +348,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
}
|
||||
} else if (reqOffset.type == TMQ_OFFSET__RESET_LATEST) {
|
||||
tqOffsetResetToLog(&dataRsp.rspOffset, walGetLastVer(pTq->pVnode->pWal));
|
||||
tqDebug("tmq poll: consumer %ld, subkey %s, vg %d, offset reset to %ld", consumerId, pHandle->subKey,
|
||||
TD_VID(pTq->pVnode), dataRsp.rspOffset.version);
|
||||
tqDebug("tmq poll: consumer %" PRId64 ", subkey %s, vg %d, offset reset to %" PRId64, consumerId,
|
||||
pHandle->subKey, TD_VID(pTq->pVnode), dataRsp.rspOffset.version);
|
||||
if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) {
|
||||
code = -1;
|
||||
}
|
||||
|
@ -386,6 +386,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
}
|
||||
|
||||
if (pHandle->execHandle.subType != TOPIC_SUB_TYPE__COLUMN) {
|
||||
ASSERT(fetchOffsetNew.type == TMQ_OFFSET__LOG);
|
||||
int64_t fetchVer = fetchOffsetNew.version + 1;
|
||||
pCkHead = taosMemoryMalloc(sizeof(SWalCkHead) + 2048);
|
||||
if (pCkHead == NULL) {
|
||||
|
@ -398,7 +399,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
while (1) {
|
||||
consumerEpoch = atomic_load_32(&pHandle->epoch);
|
||||
if (consumerEpoch > reqEpoch) {
|
||||
tqWarn("tmq poll: consumer %ld (epoch %d), subkey %s, vg %d offset %" PRId64
|
||||
tqWarn("tmq poll: consumer %" PRId64 " (epoch %d), subkey %s, vg %d offset %" PRId64
|
||||
", found new consumer epoch %d, discard req epoch %d",
|
||||
consumerId, pReq->epoch, pHandle->subKey, TD_VID(pTq->pVnode), fetchVer, consumerEpoch, reqEpoch);
|
||||
break;
|
||||
|
@ -461,22 +462,6 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
goto OVER;
|
||||
}
|
||||
}
|
||||
|
||||
taosMemoryFree(pCkHead);
|
||||
#if 0
|
||||
} else if (fetchOffsetNew.type == TMQ_OFFSET__SNAPSHOT_DATA) {
|
||||
tqInfo("retrieve using snapshot actual offset: uid %" PRId64 " ts %" PRId64, fetchOffsetNew.uid, fetchOffsetNew.ts);
|
||||
if (tqScanSnapshot(pTq, &pHandle->execHandle, &dataRsp, fetchOffsetNew, workerId) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
// 4. send rsp
|
||||
if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) {
|
||||
code = -1;
|
||||
}
|
||||
#endif
|
||||
} else if (fetchOffsetNew.type == TMQ_OFFSET__SNAPSHOT_META) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
OVER:
|
||||
|
@ -532,7 +517,10 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
// todo lock
|
||||
STqHandle* pHandle = taosHashGet(pTq->handles, req.subKey, strlen(req.subKey));
|
||||
if (pHandle == NULL) {
|
||||
ASSERT(req.oldConsumerId == -1);
|
||||
if (req.oldConsumerId != -1) {
|
||||
tqError("vgId:%d, build new consumer handle %s for consumer %d, but old consumerId is %ld", req.vgId, req.subKey,
|
||||
req.newConsumerId, req.oldConsumerId);
|
||||
}
|
||||
ASSERT(req.newConsumerId != -1);
|
||||
STqHandle tqHandle = {0};
|
||||
pHandle = &tqHandle;
|
||||
|
@ -595,7 +583,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
taosArrayDestroy(tbUidList);
|
||||
}
|
||||
taosHashPut(pTq->handles, req.subKey, strlen(req.subKey), pHandle, sizeof(STqHandle));
|
||||
tqDebug("try to persist handle %s consumer %ld", req.subKey, pHandle->consumerId);
|
||||
tqDebug("try to persist handle %s consumer %" PRId64, req.subKey, pHandle->consumerId);
|
||||
if (tqMetaSaveHandle(pTq, req.subKey, pHandle) < 0) {
|
||||
// TODO
|
||||
ASSERT(0);
|
||||
|
@ -614,31 +602,26 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||
SStreamTask* pTask = taosMemoryCalloc(1, sizeof(SStreamTask));
|
||||
if (pTask == NULL) {
|
||||
return -1;
|
||||
}
|
||||
SDecoder decoder;
|
||||
tDecoderInit(&decoder, (uint8_t*)msg, msgLen);
|
||||
if (tDecodeSStreamTask(&decoder, pTask) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
tDecoderClear(&decoder);
|
||||
int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask) {
|
||||
int32_t code = 0;
|
||||
ASSERT(pTask->isDataScan == 0 || pTask->isDataScan == 1);
|
||||
if (pTask->isDataScan == 0 && pTask->sinkType == TASK_SINK__NONE) {
|
||||
ASSERT(taosArrayGetSize(pTask->childEpInfo) != 0);
|
||||
}
|
||||
|
||||
pTask->execStatus = TASK_EXEC_STATUS__IDLE;
|
||||
pTask->schedStatus = TASK_SCHED_STATUS__INACTIVE;
|
||||
|
||||
pTask->inputQueue = streamQueueOpen();
|
||||
pTask->outputQueue = streamQueueOpen();
|
||||
|
||||
if (pTask->inputQueue == NULL || pTask->outputQueue == NULL) {
|
||||
code = -1;
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
pTask->inputStatus = TASK_INPUT_STATUS__NORMAL;
|
||||
pTask->outputStatus = TASK_OUTPUT_STATUS__NORMAL;
|
||||
|
||||
if (pTask->inputQueue == NULL || pTask->outputQueue == NULL) goto FAIL;
|
||||
|
||||
pTask->pMsgCb = &pTq->pVnode->msgCb;
|
||||
|
||||
// exec
|
||||
|
@ -683,15 +666,35 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
tqInfo("deploy stream task on vg %d, task id %d, child id %d", TD_VID(pTq->pVnode), pTask->taskId,
|
||||
pTask->selfChildId);
|
||||
|
||||
taosHashPut(pTq->pStreamTasks, &pTask->taskId, sizeof(int32_t), &pTask, sizeof(void*));
|
||||
|
||||
/*SMeta* pMeta = pTq->pVnode->pMeta;*/
|
||||
/*tdbTbUpsert(pMeta->pTaskIdx, &pTask->taskId, sizeof(int32_t), msg, msgLen, &pMeta->txn);*/
|
||||
|
||||
return 0;
|
||||
FAIL:
|
||||
if (pTask->inputQueue) streamQueueClose(pTask->inputQueue);
|
||||
if (pTask->outputQueue) streamQueueClose(pTask->outputQueue);
|
||||
// TODO free executor
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||
SStreamTask* pTask = taosMemoryCalloc(1, sizeof(SStreamTask));
|
||||
if (pTask == NULL) {
|
||||
return -1;
|
||||
}
|
||||
SDecoder decoder;
|
||||
tDecoderInit(&decoder, (uint8_t*)msg, msgLen);
|
||||
if (tDecodeSStreamTask(&decoder, pTask) < 0) {
|
||||
ASSERT(0);
|
||||
goto FAIL;
|
||||
}
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
if (tqExpandTask(pTq, pTask) < 0) {
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
taosHashPut(pTq->pStreamTasks, &pTask->taskId, sizeof(int32_t), &pTask, sizeof(void*));
|
||||
|
||||
return 0;
|
||||
|
||||
FAIL:
|
||||
if (pTask) taosMemoryFree(pTask);
|
||||
return -1;
|
||||
}
|
||||
|
@ -714,7 +717,7 @@ int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq, int64_t ver) {
|
|||
SStreamTask* pTask = *(SStreamTask**)pIter;
|
||||
if (!pTask->isDataScan) continue;
|
||||
|
||||
qDebug("data submit enqueue stream task: %d, ver: %ld", pTask->taskId, ver);
|
||||
qDebug("data submit enqueue stream task: %d, ver: %" PRId64, pTask->taskId, ver);
|
||||
|
||||
if (!failed) {
|
||||
if (streamTaskInput(pTask, (SStreamQueueItem*)pSubmit) < 0) {
|
||||
|
@ -722,7 +725,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;
|
||||
}
|
||||
|
@ -752,13 +755,14 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
}
|
||||
}
|
||||
|
||||
int32_t tqProcessTaskDispatchReq(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));
|
||||
|
@ -767,7 +771,7 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
.info = pMsg->info,
|
||||
.code = 0,
|
||||
};
|
||||
streamProcessDispatchReq(*ppTask, &req, &rsp);
|
||||
streamProcessDispatchReq(*ppTask, &req, &rsp, exec);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -825,16 +829,6 @@ int32_t tqProcessTaskDropReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
// launch exec to free memory
|
||||
// remove from hash
|
||||
return 0;
|
||||
|
||||
#if 0
|
||||
int32_t code = taosHashRemove(pTq->pStreamTasks, &pReq->taskId, sizeof(int32_t));
|
||||
// set status dropping
|
||||
ASSERT(code == 0);
|
||||
if (code == 0) {
|
||||
// sendrsp
|
||||
}
|
||||
return code;
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t tqProcessTaskRetrieveReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||
|
@ -863,3 +857,37 @@ int32_t tqProcessTaskRetrieveRsp(STQ* pTq, SRpcMsg* pMsg) {
|
|||
//
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vnodeEnqueueStreamMsg(SVnode* pVnode, SRpcMsg* pMsg) {
|
||||
STQ* pTq = pVnode->pTq;
|
||||
char* msgStr = pMsg->pCont;
|
||||
char* msgBody = POINTER_SHIFT(msgStr, sizeof(SMsgHead));
|
||||
int32_t msgLen = pMsg->contLen - sizeof(SMsgHead);
|
||||
int32_t code = 0;
|
||||
|
||||
SStreamDispatchReq req;
|
||||
SDecoder decoder;
|
||||
tDecoderInit(&decoder, msgBody, msgLen);
|
||||
if (tDecodeStreamDispatchReq(&decoder, &req) < 0) {
|
||||
code = TSDB_CODE_MSG_DECODE_ERROR;
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
int32_t taskId = req.taskId;
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (ppTask) {
|
||||
SRpcMsg rsp = {
|
||||
.info = pMsg->info,
|
||||
.code = 0,
|
||||
};
|
||||
streamProcessDispatchReq(*ppTask, &req, &rsp, false);
|
||||
return;
|
||||
}
|
||||
FAIL:
|
||||
if (pMsg->info.handle == NULL) return;
|
||||
SRpcMsg rsp = {
|
||||
.code = code,
|
||||
.info = pMsg->info,
|
||||
};
|
||||
tmsgSendRsp(&rsp);
|
||||
}
|
||||
|
|
|
@ -111,7 +111,8 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVa
|
|||
}
|
||||
|
||||
if (pRsp->blockNum == 0 && pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) {
|
||||
tqDebug("vgId: %d, tsdb consume over, switch to wal, ver %ld", TD_VID(pTq->pVnode), pHandle->snapshotVer + 1);
|
||||
tqDebug("vgId: %d, tsdb consume over, switch to wal, ver %" PRId64, TD_VID(pTq->pVnode),
|
||||
pHandle->snapshotVer + 1);
|
||||
tqOffsetResetToLog(pOffset, pHandle->snapshotVer);
|
||||
qStreamPrepareScan(task, pOffset);
|
||||
continue;
|
||||
|
|
|
@ -92,7 +92,7 @@ int32_t tqMetaRestoreHandle(STQ* pTq) {
|
|||
handle.execHandle.execDb.pFilterOutTbUid =
|
||||
taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
}
|
||||
tqDebug("tq restore %s consumer %ld vgId:%d", handle.subKey, handle.consumerId, TD_VID(pTq->pVnode));
|
||||
tqDebug("tq restore %s consumer %" PRId64 " vgId:%d", handle.subKey, handle.consumerId, TD_VID(pTq->pVnode));
|
||||
taosHashPut(pTq->handles, pKey, kLen, &handle, sizeof(STqHandle));
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) {
|
|||
tEncodeSize(tEncodeSTqHandle, pHandle, vlen, code);
|
||||
ASSERT(code == 0);
|
||||
|
||||
tqDebug("tq save %s(%d) consumer %ld vgId:%d", pHandle->subKey, strlen(pHandle->subKey), pHandle->consumerId,
|
||||
tqDebug("tq save %s(%d) consumer %" PRId64 " vgId:%d", pHandle->subKey, strlen(pHandle->subKey), pHandle->consumerId,
|
||||
TD_VID(pTq->pVnode));
|
||||
|
||||
void* buf = taosMemoryCalloc(1, vlen);
|
||||
|
|
|
@ -37,7 +37,7 @@ int32_t tqOffsetReaderOpen(STQ* pTq, int64_t sver, int64_t ever, STqOffsetReader
|
|||
pReader->sver = sver;
|
||||
pReader->ever = ever;
|
||||
|
||||
tqInfo("vgId:%d vnode snapshot tq offset reader opened", TD_VID(pTq->pVnode));
|
||||
tqInfo("vgId:%d, vnode snapshot tq offset reader opened", TD_VID(pTq->pVnode));
|
||||
|
||||
*ppReader = pReader;
|
||||
return 0;
|
||||
|
@ -109,7 +109,7 @@ int32_t tqOffsetWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqOffsetWriter
|
|||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d tq snapshot writer open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
tqError("vgId:%d, tq snapshot writer open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
*ppWriter = NULL;
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -137,7 +137,7 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) {
|
|||
ret->offset.type = TMQ_OFFSET__LOG;
|
||||
ret->offset.version = pReader->ver;
|
||||
ret->fetchType = FETCH_TYPE__NONE;
|
||||
tqDebug("return offset %ld, no more valid", ret->offset.version);
|
||||
tqDebug("return offset %" PRId64 ", no more valid", ret->offset.version);
|
||||
ASSERT(ret->offset.version >= 0);
|
||||
return -1;
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) {
|
|||
ret->offset.version = pReader->ver;
|
||||
ASSERT(pReader->ver >= 0);
|
||||
ret->fetchType = FETCH_TYPE__NONE;
|
||||
tqDebug("return offset %ld, processed finish", ret->offset.version);
|
||||
tqDebug("return offset %" PRId64 ", processed finish", ret->offset.version);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
|
|||
for (int32_t i = 0; i < sz; i++) {
|
||||
SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i);
|
||||
|
||||
blkHead->numOfRows = htons(pDataBlock->info.rows);
|
||||
blkHead->numOfRows = htonl(pDataBlock->info.rows);
|
||||
blkHead->sversion = htonl(pTSchema->version);
|
||||
// TODO
|
||||
blkHead->suid = htobe64(suid);
|
||||
|
|
|
@ -52,13 +52,13 @@ int32_t tqSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapReader** p
|
|||
goto _err;
|
||||
}
|
||||
|
||||
tqInfo("vgId:%d vnode snapshot tq reader opened", TD_VID(pTq->pVnode));
|
||||
tqInfo("vgId:%d, vnode snapshot tq reader opened", TD_VID(pTq->pVnode));
|
||||
|
||||
*ppReader = pReader;
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d vnode snapshot tq reader open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
tqError("vgId:%d, vnode snapshot tq reader open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
*ppReader = NULL;
|
||||
return code;
|
||||
}
|
||||
|
@ -113,14 +113,14 @@ int32_t tqSnapRead(STqSnapReader* pReader, uint8_t** ppData) {
|
|||
pHdr->size = vLen;
|
||||
memcpy(pHdr->data, pVal, vLen);
|
||||
|
||||
tqInfo("vgId:%d vnode snapshot tq read data, version:%" PRId64 " subKey: %s vLen:%d", TD_VID(pReader->pTq->pVnode),
|
||||
tqInfo("vgId:%d, vnode snapshot tq read data, version:%" PRId64 " subKey: %s vLen:%d", TD_VID(pReader->pTq->pVnode),
|
||||
handle.snapshotVer, handle.subKey, vLen);
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d vnode snapshot tq read data failed since %s", TD_VID(pReader->pTq->pVnode), tstrerror(code));
|
||||
tqError("vgId:%d, vnode snapshot tq read data failed since %s", TD_VID(pReader->pTq->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** p
|
|||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d tq snapshot writer open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
tqError("vgId:%d, tq snapshot writer open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
*ppWriter = NULL;
|
||||
return code;
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) {
|
|||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d tq snapshot writer close failed since %s", TD_VID(pWriter->pTq->pVnode), tstrerror(code));
|
||||
tqError("vgId:%d, tq snapshot writer close failed since %s", TD_VID(pWriter->pTq->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -204,6 +204,6 @@ int32_t tqSnapWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
|||
|
||||
_err:
|
||||
tDecoderClear(pDecoder);
|
||||
tqError("vgId:%d vnode snapshot tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
tqError("vgId:%d, vnode snapshot tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,209 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "meta.h"
|
||||
#include "tdbInt.h"
|
||||
#include "tq.h"
|
||||
|
||||
// STqSnapReader ========================================
|
||||
struct STqSnapReader {
|
||||
STQ* pTq;
|
||||
int64_t sver;
|
||||
int64_t ever;
|
||||
TBC* pCur;
|
||||
};
|
||||
|
||||
int32_t tqSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapReader** ppReader) {
|
||||
int32_t code = 0;
|
||||
STqSnapReader* pReader = NULL;
|
||||
|
||||
// alloc
|
||||
pReader = (STqSnapReader*)taosMemoryCalloc(1, sizeof(STqSnapReader));
|
||||
if (pReader == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
pReader->pTq = pTq;
|
||||
pReader->sver = sver;
|
||||
pReader->ever = ever;
|
||||
|
||||
// impl
|
||||
code = tdbTbcOpen(pTq->pExecStore, &pReader->pCur, NULL);
|
||||
if (code) {
|
||||
taosMemoryFree(pReader);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
code = tdbTbcMoveToFirst(pReader->pCur);
|
||||
if (code) {
|
||||
taosMemoryFree(pReader);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
tqInfo("vgId:%d vnode snapshot tq reader opened", TD_VID(pTq->pVnode));
|
||||
|
||||
*ppReader = pReader;
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d vnode snapshot tq reader open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
*ppReader = NULL;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqSnapReaderClose(STqSnapReader** ppReader) {
|
||||
int32_t code = 0;
|
||||
|
||||
tdbTbcClose((*ppReader)->pCur);
|
||||
taosMemoryFree(*ppReader);
|
||||
*ppReader = NULL;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqSnapRead(STqSnapReader* pReader, uint8_t** ppData) {
|
||||
int32_t code = 0;
|
||||
const void* pKey = NULL;
|
||||
const void* pVal = NULL;
|
||||
int32_t kLen = 0;
|
||||
int32_t vLen = 0;
|
||||
SDecoder decoder;
|
||||
STqHandle handle;
|
||||
|
||||
*ppData = NULL;
|
||||
for (;;) {
|
||||
if (tdbTbcGet(pReader->pCur, &pKey, &kLen, &pVal, &vLen)) {
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
tDecoderInit(&decoder, (uint8_t*)pVal, vLen);
|
||||
tDecodeSTqHandle(&decoder, &handle);
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
if (handle.snapshotVer <= pReader->sver && handle.snapshotVer >= pReader->ever) {
|
||||
tdbTbcMoveToNext(pReader->pCur);
|
||||
break;
|
||||
} else {
|
||||
tdbTbcMoveToNext(pReader->pCur);
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT(pVal && vLen);
|
||||
|
||||
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + vLen);
|
||||
if (*ppData == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData);
|
||||
pHdr->type = SNAP_DATA_TQ_HANDLE;
|
||||
pHdr->size = vLen;
|
||||
memcpy(pHdr->data, pVal, vLen);
|
||||
|
||||
tqInfo("vgId:%d vnode snapshot tq read data, version:%" PRId64 " subKey: %s vLen:%d", TD_VID(pReader->pTq->pVnode),
|
||||
handle.snapshotVer, handle.subKey, vLen);
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d vnode snapshot tq read data failed since %s", TD_VID(pReader->pTq->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
// STqSnapWriter ========================================
|
||||
struct STqSnapWriter {
|
||||
STQ* pTq;
|
||||
int64_t sver;
|
||||
int64_t ever;
|
||||
TXN txn;
|
||||
};
|
||||
|
||||
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
||||
int32_t code = 0;
|
||||
STqSnapWriter* pWriter;
|
||||
|
||||
// alloc
|
||||
pWriter = (STqSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
|
||||
if (pWriter == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
pWriter->pTq = pTq;
|
||||
pWriter->sver = sver;
|
||||
pWriter->ever = ever;
|
||||
|
||||
if (tdbTxnOpen(&pWriter->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
*ppWriter = pWriter;
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d tq snapshot writer open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
*ppWriter = NULL;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) {
|
||||
int32_t code = 0;
|
||||
STqSnapWriter* pWriter = *ppWriter;
|
||||
STQ* pTq = pWriter->pTq;
|
||||
|
||||
if (rollback) {
|
||||
ASSERT(0);
|
||||
} else {
|
||||
code = tdbCommit(pWriter->pTq->pMetaStore, &pWriter->txn);
|
||||
if (code) goto _err;
|
||||
}
|
||||
|
||||
taosMemoryFree(pWriter);
|
||||
*ppWriter = NULL;
|
||||
|
||||
// restore from metastore
|
||||
if (tqMetaRestoreHandle(pTq) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d tq snapshot writer close failed since %s", TD_VID(pWriter->pTq->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqSnapWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||
int32_t code = 0;
|
||||
STQ* pTq = pWriter->pTq;
|
||||
SDecoder decoder = {0};
|
||||
SDecoder* pDecoder = &decoder;
|
||||
STqHandle handle;
|
||||
|
||||
tDecoderInit(pDecoder, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
||||
code = tDecodeSTqHandle(pDecoder, &handle);
|
||||
if (code) goto _err;
|
||||
code = tqMetaSaveHandle(pTq, handle.subKey, &handle);
|
||||
if (code < 0) goto _err;
|
||||
tDecoderClear(pDecoder);
|
||||
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tDecoderClear(pDecoder);
|
||||
tqError("vgId:%d vnode snapshot tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
|
@ -0,0 +1,209 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "meta.h"
|
||||
#include "tdbInt.h"
|
||||
#include "tq.h"
|
||||
|
||||
// STqSnapReader ========================================
|
||||
struct STqSnapReader {
|
||||
STQ* pTq;
|
||||
int64_t sver;
|
||||
int64_t ever;
|
||||
TBC* pCur;
|
||||
};
|
||||
|
||||
int32_t tqSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapReader** ppReader) {
|
||||
int32_t code = 0;
|
||||
STqSnapReader* pReader = NULL;
|
||||
|
||||
// alloc
|
||||
pReader = (STqSnapReader*)taosMemoryCalloc(1, sizeof(STqSnapReader));
|
||||
if (pReader == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
pReader->pTq = pTq;
|
||||
pReader->sver = sver;
|
||||
pReader->ever = ever;
|
||||
|
||||
// impl
|
||||
code = tdbTbcOpen(pTq->pExecStore, &pReader->pCur, NULL);
|
||||
if (code) {
|
||||
taosMemoryFree(pReader);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
code = tdbTbcMoveToFirst(pReader->pCur);
|
||||
if (code) {
|
||||
taosMemoryFree(pReader);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
tqInfo("vgId:%d vnode snapshot tq reader opened", TD_VID(pTq->pVnode));
|
||||
|
||||
*ppReader = pReader;
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d vnode snapshot tq reader open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
*ppReader = NULL;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqSnapReaderClose(STqSnapReader** ppReader) {
|
||||
int32_t code = 0;
|
||||
|
||||
tdbTbcClose((*ppReader)->pCur);
|
||||
taosMemoryFree(*ppReader);
|
||||
*ppReader = NULL;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqSnapRead(STqSnapReader* pReader, uint8_t** ppData) {
|
||||
int32_t code = 0;
|
||||
const void* pKey = NULL;
|
||||
const void* pVal = NULL;
|
||||
int32_t kLen = 0;
|
||||
int32_t vLen = 0;
|
||||
SDecoder decoder;
|
||||
STqHandle handle;
|
||||
|
||||
*ppData = NULL;
|
||||
for (;;) {
|
||||
if (tdbTbcGet(pReader->pCur, &pKey, &kLen, &pVal, &vLen)) {
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
tDecoderInit(&decoder, (uint8_t*)pVal, vLen);
|
||||
tDecodeSTqHandle(&decoder, &handle);
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
if (handle.snapshotVer <= pReader->sver && handle.snapshotVer >= pReader->ever) {
|
||||
tdbTbcMoveToNext(pReader->pCur);
|
||||
break;
|
||||
} else {
|
||||
tdbTbcMoveToNext(pReader->pCur);
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT(pVal && vLen);
|
||||
|
||||
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + vLen);
|
||||
if (*ppData == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData);
|
||||
pHdr->type = SNAP_DATA_TQ_HANDLE;
|
||||
pHdr->size = vLen;
|
||||
memcpy(pHdr->data, pVal, vLen);
|
||||
|
||||
tqInfo("vgId:%d vnode snapshot tq read data, version:%" PRId64 " subKey: %s vLen:%d", TD_VID(pReader->pTq->pVnode),
|
||||
handle.snapshotVer, handle.subKey, vLen);
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d vnode snapshot tq read data failed since %s", TD_VID(pReader->pTq->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
// STqSnapWriter ========================================
|
||||
struct STqSnapWriter {
|
||||
STQ* pTq;
|
||||
int64_t sver;
|
||||
int64_t ever;
|
||||
TXN txn;
|
||||
};
|
||||
|
||||
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
||||
int32_t code = 0;
|
||||
STqSnapWriter* pWriter;
|
||||
|
||||
// alloc
|
||||
pWriter = (STqSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
|
||||
if (pWriter == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
pWriter->pTq = pTq;
|
||||
pWriter->sver = sver;
|
||||
pWriter->ever = ever;
|
||||
|
||||
if (tdbTxnOpen(&pWriter->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
*ppWriter = pWriter;
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d tq snapshot writer open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
*ppWriter = NULL;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) {
|
||||
int32_t code = 0;
|
||||
STqSnapWriter* pWriter = *ppWriter;
|
||||
STQ* pTq = pWriter->pTq;
|
||||
|
||||
if (rollback) {
|
||||
ASSERT(0);
|
||||
} else {
|
||||
code = tdbCommit(pWriter->pTq->pMetaStore, &pWriter->txn);
|
||||
if (code) goto _err;
|
||||
}
|
||||
|
||||
taosMemoryFree(pWriter);
|
||||
*ppWriter = NULL;
|
||||
|
||||
// restore from metastore
|
||||
if (tqMetaRestoreHandle(pTq) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d tq snapshot writer close failed since %s", TD_VID(pWriter->pTq->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqSnapWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||
int32_t code = 0;
|
||||
STQ* pTq = pWriter->pTq;
|
||||
SDecoder decoder = {0};
|
||||
SDecoder* pDecoder = &decoder;
|
||||
STqHandle handle;
|
||||
|
||||
tDecoderInit(pDecoder, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
||||
code = tDecodeSTqHandle(pDecoder, &handle);
|
||||
if (code) goto _err;
|
||||
code = tqMetaSaveHandle(pTq, handle.subKey, &handle);
|
||||
if (code < 0) goto _err;
|
||||
tDecoderClear(pDecoder);
|
||||
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tDecoderClear(pDecoder);
|
||||
tqError("vgId:%d vnode snapshot tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
|
@ -71,7 +71,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
|
|||
goto _err;
|
||||
}
|
||||
|
||||
tsdbDebug("vgId:%d, tsdb is opened for %s, days:%d, keep:%d,%d,%d", TD_VID(pVnode), pTsdb->path, pTsdb->keepCfg.days,
|
||||
tsdbDebug("vgId:%d, tsdb is opened at %s, days:%d, keep:%d,%d,%d", TD_VID(pVnode), pTsdb->path, pTsdb->keepCfg.days,
|
||||
pTsdb->keepCfg.keep0, pTsdb->keepCfg.keep1, pTsdb->keepCfg.keep2);
|
||||
|
||||
*ppTsdb = pTsdb;
|
||||
|
|
|
@ -408,6 +408,10 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
|
|||
goto _end;
|
||||
}
|
||||
|
||||
if (VND_IS_TSMA(pVnode)) {
|
||||
tsdbDebug("vgId:%d, tsma is selected to query", TD_VID(pVnode));
|
||||
}
|
||||
|
||||
initReaderStatus(&pReader->status);
|
||||
|
||||
pReader->pTsdb = getTsdbByRetentions(pVnode, pCond->twindows.skey, pVnode->config.tsdbCfg.retentions, idstr, &level);
|
||||
|
@ -1906,20 +1910,19 @@ static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* ret
|
|||
++level;
|
||||
}
|
||||
|
||||
int32_t vgId = TD_VID(pVnode);
|
||||
const char* str = (idStr != NULL) ? idStr : "";
|
||||
|
||||
if (level == TSDB_RETENTION_L0) {
|
||||
*pLevel = TSDB_RETENTION_L0;
|
||||
tsdbDebug("vgId:%d, rsma level %d is selected to query %s", vgId, TSDB_RETENTION_L0, str);
|
||||
tsdbDebug("vgId:%d, rsma level %d is selected to query %s", TD_VID(pVnode), TSDB_RETENTION_L0, str);
|
||||
return VND_RSMA0(pVnode);
|
||||
} else if (level == TSDB_RETENTION_L1) {
|
||||
*pLevel = TSDB_RETENTION_L1;
|
||||
tsdbDebug("vgId:%d, rsma level %d is selected to query %s", vgId, TSDB_RETENTION_L1, str);
|
||||
tsdbDebug("vgId:%d, rsma level %d is selected to query %s", TD_VID(pVnode), TSDB_RETENTION_L1, str);
|
||||
return VND_RSMA1(pVnode);
|
||||
} else {
|
||||
*pLevel = TSDB_RETENTION_L2;
|
||||
tsdbDebug("vgId:%d, rsma level %d is selected to query %s", vgId, TSDB_RETENTION_L2, str);
|
||||
tsdbDebug("vgId:%d, rsma level %d is selected to query %s", TD_VID(pVnode), TSDB_RETENTION_L2, str);
|
||||
return VND_RSMA2(pVnode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1215,11 +1215,11 @@ int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData)
|
|||
}
|
||||
|
||||
_exit:
|
||||
tsdbDebug("vgId:%d, tsdb snapshow write for %s succeed", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path);
|
||||
tsdbDebug("vgId:%d, tsdb snapshot write for %s succeed", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path);
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tsdbError("vgId:%d, tsdb snapshow write for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path,
|
||||
tsdbError("vgId:%d, tsdb snapshot write for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path,
|
||||
tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg) {
|
|||
// pBlock->sversion = htonl(pBlock->sversion);
|
||||
// pBlock->dataLen = htonl(pBlock->dataLen);
|
||||
// pBlock->schemaLen = htonl(pBlock->schemaLen);
|
||||
// pBlock->numOfRows = htons(pBlock->numOfRows);
|
||||
// pBlock->numOfRows = htonl(pBlock->numOfRows);
|
||||
|
||||
#if 0
|
||||
if (pBlock->tid <= 0 || pBlock->tid >= pMeta->maxTables) {
|
||||
|
|
|
@ -40,7 +40,7 @@ int vnodeOpenBufPool(SVnode *pVnode, int64_t size) {
|
|||
pVnode->pPool = pPool;
|
||||
}
|
||||
|
||||
vDebug("vgId:%d, vnode buffer pool is opened, pool size: %" PRId64, TD_VID(pVnode), size);
|
||||
vDebug("vgId:%d, vnode buffer pool is opened, size:%" PRId64, TD_VID(pVnode), size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
|||
if (*ppData) {
|
||||
goto _exit;
|
||||
} else {
|
||||
pReader->tsdbDone = 1;
|
||||
pReader->rsmaDone = 1;
|
||||
code = rsmaSnapReaderClose(&pReader->pRsmaReader);
|
||||
if (code) goto _err;
|
||||
}
|
||||
|
@ -373,18 +373,9 @@ int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) {
|
|||
case SNAP_DATA_STREAM_STATE: {
|
||||
} break;
|
||||
case SNAP_DATA_RSMA1:
|
||||
case SNAP_DATA_RSMA2: {
|
||||
// rsma1/rsma2
|
||||
if (pWriter->pRsmaSnapWriter == NULL) {
|
||||
code = rsmaSnapWriterOpen(pVnode->pSma, pWriter->sver, pWriter->ever, &pWriter->pRsmaSnapWriter);
|
||||
if (code) goto _err;
|
||||
}
|
||||
|
||||
code = rsmaSnapWrite(pWriter->pRsmaSnapWriter, pData, nData);
|
||||
if (code) goto _err;
|
||||
} break;
|
||||
case SNAP_DATA_RSMA2:
|
||||
case SNAP_DATA_QTASK: {
|
||||
// qtask for rsma
|
||||
// rsma1/rsma2/qtask for rsma
|
||||
if (pWriter->pRsmaSnapWriter == NULL) {
|
||||
code = rsmaSnapWriterOpen(pVnode->pSma, pWriter->sver, pWriter->ever, &pWriter->pRsmaSnapWriter);
|
||||
if (code) goto _err;
|
||||
|
|
|
@ -296,7 +296,7 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
}
|
||||
|
||||
int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
||||
vTrace("message in fetch queue is processing");
|
||||
vTrace("vgId:%d, msg:%p in fetch queue is processing", pVnode->config.vgId, pMsg);
|
||||
if ((pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_VND_TABLE_META || pMsg->msgType == TDMT_VND_TABLE_CFG ||
|
||||
pMsg->msgType == TDMT_VND_BATCH_META) &&
|
||||
!vnodeIsLeader(pVnode)) {
|
||||
|
@ -330,7 +330,8 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
|||
case TDMT_STREAM_TASK_RUN:
|
||||
return tqProcessTaskRunReq(pVnode->pTq, pMsg);
|
||||
case TDMT_STREAM_TASK_DISPATCH:
|
||||
return tqProcessTaskDispatchReq(pVnode->pTq, pMsg);
|
||||
// return tqProcessTaskDispatchReq(pVnode->pTq, pMsg, pInfo->workerId != 0);
|
||||
return tqProcessTaskDispatchReq(pVnode->pTq, pMsg, true);
|
||||
case TDMT_STREAM_TASK_RECOVER:
|
||||
return tqProcessTaskRecoverReq(pVnode->pTq, pMsg);
|
||||
case TDMT_STREAM_RETRIEVE:
|
||||
|
@ -378,6 +379,9 @@ static int32_t vnodeProcessTrimReq(SVnode *pVnode, int64_t version, void *pReq,
|
|||
code = tsdbDoRetention(pVnode->pTsdb, trimReq.timestamp);
|
||||
if (code) goto _exit;
|
||||
|
||||
code = smaDoRetention(pVnode->pSma, trimReq.timestamp);
|
||||
if (code) goto _exit;
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
@ -433,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;
|
||||
}
|
||||
|
@ -487,6 +487,11 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR
|
|||
goto _exit;
|
||||
}
|
||||
|
||||
if ((terrno = grantCheck(TSDB_GRANT_TABLE)) < 0) {
|
||||
rcode = -1;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
// validate hash
|
||||
sprintf(tbName, "%s.%s", pVnode->config.dbname, pCreateReq->name);
|
||||
if (vnodeValidateTableHash(pVnode, tbName) < 0) {
|
||||
|
@ -837,6 +842,13 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
|||
goto _exit;
|
||||
}
|
||||
|
||||
if ((terrno = grantCheck(TSDB_GRANT_TABLE)) < 0) {
|
||||
pRsp->code = terrno;
|
||||
tDecoderClear(&decoder);
|
||||
taosArrayDestroy(createTbReq.ctb.tagName);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (metaCreateTable(pVnode->pMeta, version, &createTbReq) < 0) {
|
||||
if (terrno != TSDB_CODE_TDB_TABLE_ALREADY_EXIST) {
|
||||
submitBlkRsp.code = terrno;
|
||||
|
@ -901,14 +913,13 @@ _exit:
|
|||
tdProcessRSmaSubmit(pVnode->pSma, pReq, STREAM_INPUT__DATA_SUBMIT);
|
||||
}
|
||||
|
||||
vDebug("successful submit in vg %d version %ld", pVnode->config.vgId, version);
|
||||
|
||||
vDebug("vgId:%d, submit success, index:%" PRId64, pVnode->config.vgId, version);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t vnodeProcessCreateTSmaReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||
SVCreateTSmaReq req = {0};
|
||||
SDecoder coder;
|
||||
SDecoder coder = {0};
|
||||
|
||||
if (pRsp) {
|
||||
pRsp->msgType = TDMT_VND_CREATE_SMA_RSP;
|
||||
|
|
|
@ -19,9 +19,8 @@
|
|||
#define BATCH_DISABLE 1
|
||||
|
||||
static inline bool vnodeIsMsgBlock(tmsg_t type) {
|
||||
return (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_CREATE_TABLE) ||
|
||||
(type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) || (type == TDMT_VND_UPDATE_TAG_VAL) ||
|
||||
(type == TDMT_VND_ALTER_REPLICA);
|
||||
return (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) ||
|
||||
(type == TDMT_VND_UPDATE_TAG_VAL) || (type == TDMT_VND_ALTER_REPLICA);
|
||||
}
|
||||
|
||||
static inline bool vnodeIsMsgWeak(tmsg_t type) { return false; }
|
||||
|
@ -325,16 +324,7 @@ int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
#if 1
|
||||
do {
|
||||
char *syncNodeStr = sync2SimpleStr(pVnode->sync);
|
||||
static int64_t vndTick = 0;
|
||||
if (++vndTick % 10 == 1) {
|
||||
vGTrace("vgId:%d, sync trace msg:%s, %s", syncGetVgId(pVnode->sync), TMSG_INFO(pMsg->msgType), syncNodeStr);
|
||||
}
|
||||
taosMemoryFree(syncNodeStr);
|
||||
} while (0);
|
||||
#endif
|
||||
vGTrace("vgId:%d, sync msg:%p will be processed, type:%s", pVnode->config.vgId, pMsg, TMSG_INFO(pMsg->msgType));
|
||||
|
||||
if (syncNodeStrategy(pSyncNode) == SYNC_STRATEGY_NO_SNAPSHOT) {
|
||||
if (pMsg->msgType == TDMT_SYNC_TIMEOUT) {
|
||||
|
@ -458,6 +448,8 @@ int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
|||
}
|
||||
}
|
||||
|
||||
vTrace("vgId:%d, sync msg:%p is processed, type:%s code:0x%x", pVnode->config.vgId, pMsg, TMSG_INFO(pMsg->msgType),
|
||||
code);
|
||||
syncNodeRelease(pSyncNode);
|
||||
if (code != 0 && terrno == 0) {
|
||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
|
@ -518,15 +510,15 @@ static void vnodeSyncCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta c
|
|||
rpcMsg.info.conn.applyTerm = cbMeta.term;
|
||||
|
||||
vInfo("vgId:%d, commit-cb is excuted, fsm:%p, index:%" PRId64 ", term:%" PRIu64 ", msg-index:%" PRId64
|
||||
", isWeak:%d, code:%d, state:%d %s, msgtype:%d %s",
|
||||
", weak:%d, code:%d, state:%d %s, type:%s",
|
||||
syncGetVgId(pVnode->sync), pFsm, cbMeta.index, cbMeta.term, rpcMsg.info.conn.applyIndex, cbMeta.isWeak,
|
||||
cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), pMsg->msgType, TMSG_INFO(pMsg->msgType));
|
||||
cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), TMSG_INFO(pMsg->msgType));
|
||||
|
||||
tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, &rpcMsg);
|
||||
} else {
|
||||
SRpcMsg rsp = {.code = cbMeta.code, .info = pMsg->info};
|
||||
vError("vgId:%d, sync commit error, msgtype:%d,%s, index:%ld, error:0x%X, errmsg:%s", syncGetVgId(pVnode->sync),
|
||||
pMsg->msgType, TMSG_INFO(pMsg->msgType), cbMeta.index, cbMeta.code, tstrerror(cbMeta.code));
|
||||
vError("vgId:%d, commit-cb execute error, type:%s, index:%" PRId64 ", error:0x%x %s", syncGetVgId(pVnode->sync),
|
||||
TMSG_INFO(pMsg->msgType), cbMeta.index, cbMeta.code, tstrerror(cbMeta.code));
|
||||
if (rsp.info.handle != NULL) {
|
||||
tmsgSendRsp(&rsp);
|
||||
}
|
||||
|
@ -537,10 +529,9 @@ static void vnodeSyncCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta c
|
|||
static void vnodeSyncPreCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
||||
if (cbMeta.isWeak == 1) {
|
||||
SVnode *pVnode = pFsm->data;
|
||||
vTrace("vgId:%d, pre-commit-cb is excuted, fsm:%p, index:%" PRId64
|
||||
", isWeak:%d, code:%d, state:%d %s, msgtype:%d %s",
|
||||
vTrace("vgId:%d, pre-commit-cb is excuted, fsm:%p, index:%" PRId64 ", weak:%d, code:%d, state:%d %s, type:%s",
|
||||
syncGetVgId(pVnode->sync), pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state,
|
||||
syncUtilState2String(cbMeta.state), pMsg->msgType, TMSG_INFO(pMsg->msgType));
|
||||
syncUtilState2String(cbMeta.state), TMSG_INFO(pMsg->msgType));
|
||||
|
||||
if (cbMeta.code == 0) {
|
||||
SRpcMsg rpcMsg = {.msgType = pMsg->msgType, .contLen = pMsg->contLen};
|
||||
|
@ -552,8 +543,8 @@ static void vnodeSyncPreCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMet
|
|||
tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, &rpcMsg);
|
||||
} else {
|
||||
SRpcMsg rsp = {.code = cbMeta.code, .info = pMsg->info};
|
||||
vError("vgId:%d, sync pre-commit error, msgtype:%d,%s, error:0x%X, errmsg:%s", syncGetVgId(pVnode->sync),
|
||||
pMsg->msgType, TMSG_INFO(pMsg->msgType), cbMeta.code, tstrerror(cbMeta.code));
|
||||
vError("vgId:%d, pre-commit-cb execute error, type:%s, error:0x%x %s", syncGetVgId(pVnode->sync),
|
||||
TMSG_INFO(pMsg->msgType), cbMeta.code, tstrerror(cbMeta.code));
|
||||
if (rsp.info.handle != NULL) {
|
||||
tmsgSendRsp(&rsp);
|
||||
}
|
||||
|
@ -563,9 +554,9 @@ static void vnodeSyncPreCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMet
|
|||
|
||||
static void vnodeSyncRollBackMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
||||
SVnode *pVnode = pFsm->data;
|
||||
vTrace("vgId:%d, rollback-cb is excuted, fsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s, msgtype:%d %s",
|
||||
vTrace("vgId:%d, rollback-cb is excuted, fsm:%p, index:%" PRId64 ", weak:%d, code:%d, state:%d %s, type:%s",
|
||||
syncGetVgId(pVnode->sync), pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state,
|
||||
syncUtilState2String(cbMeta.state), pMsg->msgType, TMSG_INFO(pMsg->msgType));
|
||||
syncUtilState2String(cbMeta.state), TMSG_INFO(pMsg->msgType));
|
||||
}
|
||||
|
||||
#define USE_TSDB_SNAPSHOT
|
||||
|
@ -620,10 +611,10 @@ static int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void
|
|||
do {
|
||||
int32_t itemSize = tmsgGetQueueSize(&pVnode->msgCb, pVnode->config.vgId, APPLY_QUEUE);
|
||||
if (itemSize == 0) {
|
||||
vDebug("vgId:%d, apply queue is empty, start write snapshot", pVnode->config.vgId);
|
||||
vInfo("vgId:%d, start write vnode snapshot since apply queue is empty", pVnode->config.vgId);
|
||||
break;
|
||||
} else {
|
||||
vDebug("vgId:%d, %d items in apply queue, write snapshot later", pVnode->config.vgId);
|
||||
vInfo("vgId:%d, write vnode snapshot later since %d items in apply queue", pVnode->config.vgId);
|
||||
taosMsleep(10);
|
||||
}
|
||||
} while (true);
|
||||
|
@ -639,10 +630,11 @@ static int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void
|
|||
static int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply, SSnapshot *pSnapshot) {
|
||||
#ifdef USE_TSDB_SNAPSHOT
|
||||
SVnode *pVnode = pFsm->data;
|
||||
vDebug("vgId:%d, stop write snapshot, isApply:%d", pVnode->config.vgId, isApply);
|
||||
vInfo("vgId:%d, stop write vnode snapshot, apply:%d, index:%" PRId64 " term:%" PRIu64 " config:%" PRId64,
|
||||
pVnode->config.vgId, isApply, pSnapshot->lastApplyIndex, pSnapshot->lastApplyTerm, pSnapshot->lastConfigIndex);
|
||||
|
||||
int32_t code = vnodeSnapWriterClose(pWriter, !isApply, pSnapshot);
|
||||
vDebug("vgId:%d, apply snapshot to vnode, code:0x%x", pVnode->config.vgId, code);
|
||||
vInfo("vgId:%d, apply vnode snapshot finished, code:0x%x", pVnode->config.vgId, code);
|
||||
return code;
|
||||
#else
|
||||
taosMemoryFree(pWriter);
|
||||
|
@ -653,8 +645,9 @@ static int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool
|
|||
static int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) {
|
||||
#ifdef USE_TSDB_SNAPSHOT
|
||||
SVnode *pVnode = pFsm->data;
|
||||
vDebug("vgId:%d, continue write vnode snapshot, len:%d", pVnode->config.vgId, len);
|
||||
int32_t code = vnodeSnapWrite(pWriter, pBuf, len);
|
||||
vTrace("vgId:%d, write snapshot, len:%d", pVnode->config.vgId, len);
|
||||
vDebug("vgId:%d, continue write vnode snapshot finished, len:%d", pVnode->config.vgId, len);
|
||||
return code;
|
||||
#else
|
||||
return 0;
|
||||
|
@ -715,7 +708,7 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
|
|||
}
|
||||
|
||||
setPingTimerMS(pVnode->sync, 5000);
|
||||
setElectTimerMS(pVnode->sync, 1300);
|
||||
setElectTimerMS(pVnode->sync, 2800);
|
||||
setHeartbeatTimerMS(pVnode->sync, 900);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -395,9 +395,8 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
|
|||
pBlk->uid = htobe64(tbUid);
|
||||
pBlk->suid = htobe64(tbUid);
|
||||
pBlk->sversion = htonl(schemaVer);
|
||||
pBlk->padding = htonl(0);
|
||||
pBlk->schemaLen = htonl(0);
|
||||
pBlk->numOfRows = htons(mockRowNum);
|
||||
pBlk->numOfRows = htonl(mockRowNum);
|
||||
pBlk->dataLen = htonl(mockRowNum * mockRowLen);
|
||||
for (uint32_t r = 0; r < mockRowNum; ++r) {
|
||||
pRow = (STSRow *)POINTER_SHIFT(pBlk, sizeof(SSubmitBlk) + r * mockRowLen);
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "trpc.h"
|
||||
#include "query.h"
|
||||
#include "tname.h"
|
||||
#include "catalogInt.h"
|
||||
#include "query.h"
|
||||
#include "systable.h"
|
||||
#include "tname.h"
|
||||
#include "tref.h"
|
||||
#include "trpc.h"
|
||||
|
||||
int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBuf* pMsg, int32_t rspCode) {
|
||||
int32_t code = 0;
|
||||
|
@ -30,7 +30,8 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu
|
|||
int32_t msgNum = (TSDB_CODE_SUCCESS == rspCode && pMsg->pData && (pMsg->len > 0)) ? ntohl(*(int32_t*)pMsg->pData) : 0;
|
||||
ASSERT(taskNum == msgNum || 0 == msgNum);
|
||||
|
||||
ctgDebug("QID:0x%" PRIx64 " ctg got batch %d rsp %s", pJob->queryId, cbParam->batchId, TMSG_INFO(cbParam->reqType + 1));
|
||||
ctgDebug("QID:0x%" PRIx64 " ctg got batch %d rsp %s", pJob->queryId, cbParam->batchId,
|
||||
TMSG_INFO(cbParam->reqType + 1));
|
||||
|
||||
offset += sizeof(msgNum);
|
||||
SBatchRsp rsp = {0};
|
||||
|
@ -82,7 +83,6 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize, int32_t rspCode, char* target) {
|
||||
int32_t code = 0;
|
||||
|
||||
|
@ -307,7 +307,6 @@ int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize,
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgHandleMsgCallback(void* param, SDataBuf* pMsg, int32_t rspCode) {
|
||||
SCtgTaskCallbackParam* cbParam = (SCtgTaskCallbackParam*)param;
|
||||
int32_t code = 0;
|
||||
|
@ -329,10 +328,12 @@ int32_t ctgHandleMsgCallback(void *param, SDataBuf *pMsg, int32_t rspCode) {
|
|||
int32_t* taskId = taosArrayGet(cbParam->taskId, 0);
|
||||
SCtgTask* pTask = taosArrayGet(pJob->pTasks, *taskId);
|
||||
|
||||
qDebug("QID:0x%" PRIx64 " ctg task %d start to handle rsp %s", pJob->queryId, pTask->taskId, TMSG_INFO(cbParam->reqType + 1));
|
||||
qDebug("QID:0x%" PRIx64 " ctg task %d start to handle rsp %s", pJob->queryId, pTask->taskId,
|
||||
TMSG_INFO(cbParam->reqType + 1));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
SHashObj* pBatchs = taosHashInit(CTG_DEFAULT_BATCH_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||
SHashObj* pBatchs =
|
||||
taosHashInit(CTG_DEFAULT_BATCH_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||
if (NULL == pBatchs) {
|
||||
ctgError("taosHashInit %d batch failed", CTG_DEFAULT_BATCH_NUM);
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
|
@ -358,8 +359,8 @@ _return:
|
|||
CTG_API_LEAVE(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgMakeMsgSendInfo(SCtgJob* pJob, SArray* pTaskId, int32_t batchId, int32_t msgType, SMsgSendInfo **pMsgSendInfo) {
|
||||
int32_t ctgMakeMsgSendInfo(SCtgJob* pJob, SArray* pTaskId, int32_t batchId, int32_t msgType,
|
||||
SMsgSendInfo** pMsgSendInfo) {
|
||||
int32_t code = 0;
|
||||
SMsgSendInfo* msgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (NULL == msgSendInfo) {
|
||||
|
@ -395,8 +396,8 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgAsyncSendMsg(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob* pJob, SArray* pTaskId,
|
||||
int32_t batchId, char* dbFName, int32_t vgId, int32_t msgType, void *msg, uint32_t msgSize) {
|
||||
int32_t ctgAsyncSendMsg(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob* pJob, SArray* pTaskId, int32_t batchId,
|
||||
char* dbFName, int32_t vgId, int32_t msgType, void* msg, uint32_t msgSize) {
|
||||
int32_t code = 0;
|
||||
SMsgSendInfo* pMsgSendInfo = NULL;
|
||||
CTG_ERR_JRET(ctgMakeMsgSendInfo(pJob, pTaskId, batchId, msgType, &pMsgSendInfo));
|
||||
|
@ -430,7 +431,8 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo *pConn, SCtgTask* pTask, int32_t msgType, void *msg, uint32_t msgSize) {
|
||||
int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgTask* pTask, int32_t msgType, void* msg,
|
||||
uint32_t msgSize) {
|
||||
int32_t code = 0;
|
||||
SHashObj* pBatchs = pTask->pBatchs;
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
|
@ -488,7 +490,8 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo *pConn, SCtgT
|
|||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
ctgDebug("task %d %s req added to batch %d, target vgId %d", pTask->taskId, TMSG_INFO(msgType), newBatch.batchId, vgId);
|
||||
ctgDebug("task %d %s req added to batch %d, target vgId %d", pTask->taskId, TMSG_INFO(msgType), newBatch.batchId,
|
||||
vgId);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -527,7 +530,8 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo *pConn, SCtgT
|
|||
tNameGetFullDbName(pName, newBatch.dbFName);
|
||||
}
|
||||
|
||||
ctgDebug("task %d %s req added to batch %d, target vgId %d", pTask->taskId, TMSG_INFO(msgType), pBatch->batchId, vgId);
|
||||
ctgDebug("task %d %s req added to batch %d, target vgId %d", pTask->taskId, TMSG_INFO(msgType), pBatch->batchId,
|
||||
vgId);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
|
@ -584,8 +588,8 @@ int32_t ctgLaunchBatchs(SCatalog* pCtg, SCtgJob *pJob, SHashObj* pBatchs) {
|
|||
ctgDebug("QID:0x%" PRIx64 " ctg start to launch batch %d", pJob->queryId, pBatch->batchId);
|
||||
|
||||
CTG_ERR_JRET(ctgBuildBatchReqMsg(pBatch, *vgId, &msg));
|
||||
code = ctgAsyncSendMsg(pCtg, &pBatch->conn, pJob, pBatch->pTaskIds, pBatch->batchId,
|
||||
pBatch->dbFName, *vgId, pBatch->msgType, msg, pBatch->msgSize);
|
||||
code = ctgAsyncSendMsg(pCtg, &pBatch->conn, pJob, pBatch->pTaskIds, pBatch->batchId, pBatch->dbFName, *vgId,
|
||||
pBatch->msgType, msg, pBatch->msgSize);
|
||||
pBatch->pTaskIds = NULL;
|
||||
CTG_ERR_JRET(code);
|
||||
|
||||
|
@ -604,7 +608,6 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray* out, SCtgTask* pTask) {
|
||||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
|
@ -702,8 +705,8 @@ int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SBuildUseDBInput *input, SUseDbOutput *out, SCtgTask* pTask) {
|
||||
int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SBuildUseDBInput* input, SUseDbOutput* out,
|
||||
SCtgTask* pTask) {
|
||||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_USE_DB;
|
||||
|
@ -754,7 +757,8 @@ int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SBuildU
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *dbFName, SDbCfgInfo *out, SCtgTask* pTask) {
|
||||
int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbFName, SDbCfgInfo* out,
|
||||
SCtgTask* pTask) {
|
||||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_GET_DB_CFG;
|
||||
|
@ -805,7 +809,8 @@ int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *indexName, SIndexInfo *out, SCtgTask* pTask) {
|
||||
int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char* indexName, SIndexInfo* out,
|
||||
SCtgTask* pTask) {
|
||||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_GET_INDEX;
|
||||
|
@ -856,7 +861,8 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName *name, STableIndex* out, SCtgTask* pTask) {
|
||||
int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SName* name, STableIndex* out,
|
||||
SCtgTask* pTask) {
|
||||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_GET_TABLE_INDEX;
|
||||
|
@ -909,7 +915,8 @@ int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName *n
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *funcName, SFuncInfo *out, SCtgTask* pTask) {
|
||||
int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char* funcName, SFuncInfo* out,
|
||||
SCtgTask* pTask) {
|
||||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_RETRIEVE_FUNC;
|
||||
|
@ -960,7 +967,8 @@ int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const ch
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *user, SGetUserAuthRsp *out, SCtgTask* pTask) {
|
||||
int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, SGetUserAuthRsp* out,
|
||||
SCtgTask* pTask) {
|
||||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_GET_USER_AUTH;
|
||||
|
@ -1011,8 +1019,8 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo *pConn, char *dbFName, char* tbName, STableMetaOutput* out, SCtgTask* pTask) {
|
||||
int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, char* dbFName, char* tbName,
|
||||
STableMetaOutput* out, SCtgTask* pTask) {
|
||||
SBuildTableInput bInput = {.vgId = 0, .dbFName = dbFName, .tbName = tbName};
|
||||
char* msg = NULL;
|
||||
SEpSet* pVnodeEpSet = NULL;
|
||||
|
@ -1067,14 +1075,16 @@ int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo *pConn, char
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ctgGetTbMetaFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableMetaOutput* out, SCtgTask* pTask) {
|
||||
int32_t ctgGetTbMetaFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableMetaOutput* out,
|
||||
SCtgTask* pTask) {
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameGetFullDbName(pTableName, dbFName);
|
||||
|
||||
return ctgGetTbMetaFromMnodeImpl(pCtg, pConn, dbFName, (char*)pTableName->tname, out, pTask);
|
||||
}
|
||||
|
||||
int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableMetaOutput* out, SCtgTask* pTask) {
|
||||
int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SVgroupInfo* vgroupInfo,
|
||||
STableMetaOutput* out, SCtgTask* pTask) {
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameGetFullDbName(pTableName, dbFName);
|
||||
int32_t reqType = TDMT_VND_TABLE_META;
|
||||
|
@ -1083,10 +1093,11 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SNa
|
|||
void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
|
||||
SEp* pEp = &vgroupInfo->epSet.eps[vgroupInfo->epSet.inUse];
|
||||
ctgDebug("try to get table meta from vnode, vgId:%d, ep num:%d, ep %s:%d, tbFName:%s",
|
||||
vgroupInfo->vgId, vgroupInfo->epSet.numOfEps, pEp->fqdn, pEp->port, tbFName);
|
||||
ctgDebug("try to get table meta from vnode, vgId:%d, ep num:%d, ep %s:%d, tbFName:%s", vgroupInfo->vgId,
|
||||
vgroupInfo->epSet.numOfEps, pEp->fqdn, pEp->port, tbFName);
|
||||
|
||||
SBuildTableInput bInput = {.vgId = vgroupInfo->vgId, .dbFName = dbFName, .tbName = (char *)tNameGetTableName(pTableName)};
|
||||
SBuildTableInput bInput = {
|
||||
.vgId = vgroupInfo->vgId, .dbFName = dbFName, .tbName = (char*)tNameGetTableName(pTableName)};
|
||||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
|
||||
|
@ -1141,7 +1152,8 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SNa
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableCfg **out, SCtgTask* pTask) {
|
||||
int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName,
|
||||
SVgroupInfo* vgroupInfo, STableCfg** out, SCtgTask* pTask) {
|
||||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_VND_TABLE_CFG;
|
||||
|
@ -1153,8 +1165,8 @@ int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const S
|
|||
SBuildTableInput bInput = {.vgId = vgroupInfo->vgId, .dbFName = dbFName, .tbName = (char*)pTableName->tname};
|
||||
|
||||
SEp* pEp = &vgroupInfo->epSet.eps[vgroupInfo->epSet.inUse];
|
||||
ctgDebug("try to get table cfg from vnode, vgId:%d, ep num:%d, ep %s:%d, tbFName:%s",
|
||||
vgroupInfo->vgId, vgroupInfo->epSet.numOfEps, pEp->fqdn, pEp->port, tbFName);
|
||||
ctgDebug("try to get table cfg from vnode, vgId:%d, ep num:%d, ep %s:%d, tbFName:%s", vgroupInfo->vgId,
|
||||
vgroupInfo->epSet.numOfEps, pEp->fqdn, pEp->port, tbFName);
|
||||
|
||||
int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](&bInput, &msg, 0, &msgLen, mallocFp);
|
||||
if (code) {
|
||||
|
@ -1201,8 +1213,8 @@ int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const S
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg **out, SCtgTask* pTask) {
|
||||
int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableCfg** out,
|
||||
SCtgTask* pTask) {
|
||||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_TABLE_CFG;
|
||||
|
@ -1298,5 +1310,3 @@ int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, char **ou
|
|||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -192,6 +192,26 @@ char* buildRetension(SArray* pRetension) {
|
|||
return p1;
|
||||
}
|
||||
|
||||
static const char* cacheModelStr(int8_t cacheModel) {
|
||||
switch (cacheModel) {
|
||||
case TSDB_CACHE_MODEL_NONE:
|
||||
return TSDB_CACHE_MODEL_NONE_STR;
|
||||
case TSDB_CACHE_MODEL_LAST_ROW:
|
||||
return TSDB_CACHE_MODEL_LAST_ROW_STR;
|
||||
case TSDB_CACHE_MODEL_LAST_VALUE:
|
||||
return TSDB_CACHE_MODEL_LAST_VALUE_STR;
|
||||
case TSDB_CACHE_MODEL_BOTH:
|
||||
return TSDB_CACHE_MODEL_BOTH_STR;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TSDB_CACHE_MODEL_NONE_STR;
|
||||
}
|
||||
|
||||
static const char* strictStr(int8_t strict) {
|
||||
return TSDB_DB_STRICT_ON == strict ? TSDB_DB_STRICT_ON_STR : TSDB_DB_STRICT_OFF_STR;
|
||||
}
|
||||
|
||||
static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbFName, SDbCfgInfo* pCfg) {
|
||||
blockDataEnsureCapacity(pBlock, 1);
|
||||
pBlock->info.rows = 1;
|
||||
|
@ -222,13 +242,14 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbFName, S
|
|||
|
||||
char* retentions = buildRetension(pCfg->pRetensions);
|
||||
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE,
|
||||
"CREATE DATABASE `%s` BUFFER %d CACHEMODEL %d COMP %d DURATION %dm "
|
||||
"FSYNC %d MAXROWS %d MINROWS %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d "
|
||||
"STRICT %d WAL %d VGROUPS %d SINGLE_STABLE %d",
|
||||
dbFName, pCfg->buffer, pCfg->cacheLast, pCfg->compression, pCfg->daysPerFile, pCfg->walFsyncPeriod,
|
||||
len += sprintf(
|
||||
buf2 + VARSTR_HEADER_SIZE,
|
||||
"CREATE DATABASE `%s` BUFFER %d CACHEMODEL '%s' COMP %d DURATION %dm "
|
||||
"WAL_FSYNC_PERIOD %d MAXROWS %d MINROWS %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d "
|
||||
"STRICT '%s' WAL_LEVEL %d VGROUPS %d SINGLE_STABLE %d",
|
||||
dbFName, pCfg->buffer, cacheModelStr(pCfg->cacheLast), pCfg->compression, pCfg->daysPerFile, pCfg->walFsyncPeriod,
|
||||
pCfg->maxRows, pCfg->minRows, pCfg->daysToKeep0, pCfg->daysToKeep1, pCfg->daysToKeep2, pCfg->pages,
|
||||
pCfg->pageSize, prec, pCfg->replications, pCfg->strict, pCfg->walLevel, pCfg->numOfVgroups,
|
||||
pCfg->pageSize, prec, pCfg->replications, strictStr(pCfg->strict), pCfg->walLevel, pCfg->numOfVgroups,
|
||||
1 == pCfg->numOfStables);
|
||||
|
||||
if (retentions) {
|
||||
|
@ -383,21 +404,21 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void appendTableOptions(char* buf, int32_t* len, STableCfg* pCfg) {
|
||||
void appendTableOptions(char* buf, int32_t* len, SDbCfgInfo* pDbCfg, STableCfg* pCfg) {
|
||||
if (pCfg->commentLen > 0) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " COMMENT '%s'", pCfg->pComment);
|
||||
} else if (0 == pCfg->commentLen) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " COMMENT ''");
|
||||
}
|
||||
|
||||
if (pCfg->watermark1 > 0) {
|
||||
if (NULL != pDbCfg->pRetensions && pCfg->watermark1 > 0) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " WATERMARK %" PRId64 "a", pCfg->watermark1);
|
||||
if (pCfg->watermark2 > 0) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ", %" PRId64 "a", pCfg->watermark2);
|
||||
}
|
||||
}
|
||||
|
||||
if (pCfg->delay1 > 0) {
|
||||
if (NULL != pDbCfg->pRetensions && pCfg->delay1 > 0) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " MAX_DELAY %" PRId64 "a", pCfg->delay1);
|
||||
if (pCfg->delay2 > 0) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ", %" PRId64 "a", pCfg->delay2);
|
||||
|
@ -405,7 +426,7 @@ void appendTableOptions(char* buf, int32_t* len, STableCfg* pCfg) {
|
|||
}
|
||||
|
||||
int32_t funcNum = taosArrayGetSize(pCfg->pFuncs);
|
||||
if (funcNum > 0) {
|
||||
if (NULL != pDbCfg->pRetensions && funcNum > 0) {
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " ROLLUP(");
|
||||
for (int32_t i = 0; i < funcNum; ++i) {
|
||||
char* pFunc = taosArrayGet(pCfg->pFuncs, i);
|
||||
|
@ -419,7 +440,7 @@ void appendTableOptions(char* buf, int32_t* len, STableCfg* pCfg) {
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, char* tbName, STableCfg* pCfg) {
|
||||
static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* pDbCfg, char* tbName, STableCfg* pCfg) {
|
||||
int32_t code = 0;
|
||||
blockDataEnsureCapacity(pBlock, 1);
|
||||
pBlock->info.rows = 1;
|
||||
|
@ -439,7 +460,7 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, char* tbName,
|
|||
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ") TAGS (");
|
||||
appendTagFields(buf2, &len, pCfg);
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ")");
|
||||
appendTableOptions(buf2, &len, pCfg);
|
||||
appendTableOptions(buf2, &len, pDbCfg, pCfg);
|
||||
} else if (TSDB_CHILD_TABLE == pCfg->tableType) {
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE TABLE `%s` USING `%s` (", tbName, pCfg->stbName);
|
||||
appendTagNameFields(buf2, &len, pCfg);
|
||||
|
@ -449,7 +470,7 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, char* tbName,
|
|||
return code;
|
||||
}
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ")");
|
||||
appendTableOptions(buf2, &len, pCfg);
|
||||
appendTableOptions(buf2, &len, pDbCfg, pCfg);
|
||||
} else {
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE TABLE `%s` (", tbName);
|
||||
appendColumnFields(buf2, &len, pCfg);
|
||||
|
@ -465,7 +486,7 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, char* tbName,
|
|||
|
||||
static int32_t execShowCreateTable(SShowCreateTableStmt* pStmt, SRetrieveTableRsp** pRsp) {
|
||||
SSDataBlock* pBlock = buildCreateTbResultDataBlock();
|
||||
int32_t code = setCreateTBResultIntoDataBlock(pBlock, pStmt->tableName, pStmt->pCfg);
|
||||
int32_t code = setCreateTBResultIntoDataBlock(pBlock, pStmt->pDbCfg, pStmt->tableName, pStmt->pTableCfg);
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
|
@ -473,7 +494,7 @@ static int32_t execShowCreateTable(SShowCreateTableStmt* pStmt, SRetrieveTableRs
|
|||
}
|
||||
|
||||
static int32_t execShowCreateSTable(SShowCreateTableStmt* pStmt, SRetrieveTableRsp** pRsp) {
|
||||
STableCfg* pCfg = (STableCfg*)pStmt->pCfg;
|
||||
STableCfg* pCfg = (STableCfg*)pStmt->pTableCfg;
|
||||
if (TSDB_SUPER_TABLE != pCfg->tableType) {
|
||||
terrno = TSDB_CODE_TSC_NOT_STABLE_ERROR;
|
||||
return terrno;
|
||||
|
|
|
@ -88,8 +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);
|
||||
if (forUpdate) {
|
||||
setBufPageDirty(bufPage, true);
|
||||
}
|
||||
SResultRow* pRow = (SResultRow*)((char*)bufPage + pos->offset);
|
||||
return pRow;
|
||||
}
|
||||
|
|
|
@ -224,6 +224,7 @@ typedef struct SOperatorInfo {
|
|||
struct SOperatorInfo** pDownstream; // downstram pointer list
|
||||
int32_t numOfDownstream; // number of downstream. The value is always ONE expect for join operator
|
||||
SOperatorFpSet fpSet;
|
||||
int16_t resultDataBlockId;
|
||||
} SOperatorInfo;
|
||||
|
||||
typedef enum {
|
||||
|
@ -843,6 +844,7 @@ void initBasicInfo(SOptrBasicInfo* pInfo, SSDataBlock* pBlock);
|
|||
void cleanupBasicInfo(SOptrBasicInfo* pInfo);
|
||||
int32_t initExprSupp(SExprSupp* pSup, SExprInfo* pExprInfo, int32_t numOfExpr);
|
||||
void cleanupExprSupp(SExprSupp* pSup);
|
||||
void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs);
|
||||
int32_t initAggInfo(SExprSupp *pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize,
|
||||
const char* pkey);
|
||||
void initResultSizeInfo(SResultInfo * pResultInfo, int32_t numOfRows);
|
||||
|
|
|
@ -225,7 +225,7 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) {
|
|||
}
|
||||
|
||||
blkHead->dataLen = htonl(dataLen);
|
||||
blkHead->numOfRows = htons(rows);
|
||||
blkHead->numOfRows = htonl(rows);
|
||||
|
||||
ret->length += sizeof(SSubmitBlk) + dataLen;
|
||||
blkHead = POINTER_SHIFT(blkHead, sizeof(SSubmitBlk) + dataLen);
|
||||
|
|
|
@ -632,7 +632,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
|
|||
tListLen(pExp->pExpr->_function.functionName));
|
||||
#if 1
|
||||
// todo refactor: add the parameter for tbname function
|
||||
if (strcmp(pExp->pExpr->_function.functionName, "tbname") == 0) {
|
||||
if (!pFuncNode->pParameterList && (strcmp(pExp->pExpr->_function.functionName, "tbname") == 0)) {
|
||||
pFuncNode->pParameterList = nodesMakeList();
|
||||
ASSERT(LIST_LENGTH(pFuncNode->pParameterList) == 0);
|
||||
SValueNode* res = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
|
@ -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) {
|
||||
|
|
|
@ -83,6 +83,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
|||
taosArrayClear(p->pDataBlock);
|
||||
taosArrayAddAll(p->pDataBlock, pDataBlock->pDataBlock);
|
||||
taosArrayPush(pInfo->pBlockLists, &p);
|
||||
|
||||
}
|
||||
pInfo->blockType = STREAM_INPUT__DATA_BLOCK;
|
||||
} else {
|
||||
|
@ -93,6 +94,29 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
|||
}
|
||||
}
|
||||
|
||||
void tdCleanupStreamInputDataBlock(qTaskInfo_t tinfo) {
|
||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||
if (!pTaskInfo || !pTaskInfo->pRoot || pTaskInfo->pRoot->numOfDownstream <= 0) {
|
||||
return;
|
||||
}
|
||||
SOperatorInfo* pOptrInfo = pTaskInfo->pRoot->pDownstream[0];
|
||||
|
||||
if (pOptrInfo->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
||||
SStreamScanInfo* pInfo = pOptrInfo->info;
|
||||
if (pInfo->blockType == STREAM_INPUT__DATA_BLOCK) {
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pInfo->pBlockLists); ++i) {
|
||||
SSDataBlock* p = *(SSDataBlock**)taosArrayGet(pInfo->pBlockLists, i);
|
||||
taosArrayDestroy(p->pDataBlock);
|
||||
taosMemoryFreeClear(p);
|
||||
}
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type) {
|
||||
if (tinfo == NULL) {
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
|
@ -104,7 +128,7 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO
|
|||
|
||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||
|
||||
int32_t code = doSetStreamBlock(pTaskInfo->pRoot, (void**)pBlocks, numOfBlocks, type, GET_TASKID(pTaskInfo));
|
||||
int32_t code = doSetStreamBlock(pTaskInfo->pRoot, (void*)pBlocks, numOfBlocks, type, GET_TASKID(pTaskInfo));
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("%s failed to set the stream block data", GET_TASKID(pTaskInfo));
|
||||
} else {
|
||||
|
@ -605,7 +629,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, const STqOffsetVal* pOffset) {
|
|||
#if 0
|
||||
if (tOffsetEqual(pOffset, &pTaskInfo->streamInfo.lastStatus) &&
|
||||
pInfo->tqReader->pWalReader->curVersion != pOffset->version) {
|
||||
qError("prepare scan ver %ld actual ver %ld, last %ld", pOffset->version,
|
||||
qError("prepare scan ver %" PRId64 " actual ver %" PRId64 ", last %" PRId64, pOffset->version,
|
||||
pInfo->tqReader->pWalReader->curVersion, pTaskInfo->streamInfo.lastStatus.version);
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -636,8 +660,8 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, const STqOffsetVal* pOffset) {
|
|||
|
||||
#ifndef NDEBUG
|
||||
|
||||
qDebug("switch to next table %ld (cursor %d), %ld rows returned", uid, pTableScanInfo->currentTable,
|
||||
pInfo->pTableScanOp->resultInfo.totalRows);
|
||||
qDebug("switch to next table %" PRId64 " (cursor %d), %" PRId64 " rows returned", uid,
|
||||
pTableScanInfo->currentTable, pInfo->pTableScanOp->resultInfo.totalRows);
|
||||
pInfo->pTableScanOp->resultInfo.totalRows = 0;
|
||||
#endif
|
||||
|
||||
|
@ -669,8 +693,8 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, const STqOffsetVal* pOffset) {
|
|||
pTableScanInfo->cond.twindows.skey = oldSkey;
|
||||
pTableScanInfo->scanTimes = 0;
|
||||
|
||||
qDebug("tsdb reader offset seek to uid %ld ts %ld, table cur set to %d , all table num %d", uid, ts,
|
||||
pTableScanInfo->currentTable, tableSz);
|
||||
qDebug("tsdb reader offset seek to uid %" PRId64 " ts %" PRId64 ", table cur set to %d , all table num %d", uid,
|
||||
ts, pTableScanInfo->currentTable, tableSz);
|
||||
/*}*/
|
||||
|
||||
} else {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -301,7 +301,8 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
|
|||
pResultRowInfo->cur = (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset};
|
||||
|
||||
// too many time window in query
|
||||
if (taosHashGetSize(pSup->pResultRowHashTable) > MAX_INTERVAL_TIME_WINDOW) {
|
||||
if (pTaskInfo->execModel == OPTR_EXEC_MODEL_BATCH &&
|
||||
taosHashGetSize(pSup->pResultRowHashTable) > MAX_INTERVAL_TIME_WINDOW) {
|
||||
longjmp(pTaskInfo->env, TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW);
|
||||
}
|
||||
|
||||
|
@ -3328,7 +3329,7 @@ static SSDataBlock* doFill(SOperatorInfo* pOperator) {
|
|||
return fillResult;
|
||||
}
|
||||
|
||||
static void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs) {
|
||||
void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs) {
|
||||
for (int32_t i = 0; i < numOfExprs; ++i) {
|
||||
SExprInfo* pExprInfo = &pExpr[i];
|
||||
for (int32_t j = 0; j < pExprInfo->base.numOfParams; ++j) {
|
||||
|
@ -3395,7 +3396,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;
|
||||
}
|
||||
|
@ -3475,9 +3481,8 @@ void cleanupExprSupp(SExprSupp* pSupp) {
|
|||
destroySqlFunctionCtx(pSupp->pCtx, pSupp->numOfExprs);
|
||||
if (pSupp->pExprInfo != NULL) {
|
||||
destroyExprInfo(pSupp->pExprInfo, pSupp->numOfExprs);
|
||||
}
|
||||
|
||||
taosMemoryFreeClear(pSupp->pExprInfo);
|
||||
}
|
||||
taosMemoryFree(pSupp->rowEntryInfoOffset);
|
||||
}
|
||||
|
||||
|
@ -3596,7 +3601,8 @@ void doDestroyExchangeOperatorInfo(void* param) {
|
|||
}
|
||||
|
||||
static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t numOfCols, SNodeListNode* pValNode,
|
||||
STimeWindow win, int32_t capacity, const char* id, SInterval* pInterval, int32_t fillType, int32_t order) {
|
||||
STimeWindow win, int32_t capacity, const char* id, SInterval* pInterval, int32_t fillType,
|
||||
int32_t order) {
|
||||
SFillColInfo* pColInfo = createFillColInfo(pExpr, numOfCols, pValNode);
|
||||
|
||||
STimeWindow w = getAlignQueryTimeWindow(pInterval, pInterval->precision, win.skey);
|
||||
|
@ -3768,11 +3774,7 @@ SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode) {
|
|||
|
||||
static void cleanupTableSchemaInfo(SSchemaInfo* pSchemaInfo) {
|
||||
taosMemoryFreeClear(pSchemaInfo->dbname);
|
||||
if (pSchemaInfo->sw == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
taosMemoryFree(pSchemaInfo->tablename);
|
||||
taosMemoryFreeClear(pSchemaInfo->tablename);
|
||||
tDeleteSSchemaWrapper(pSchemaInfo->sw);
|
||||
tDeleteSSchemaWrapper(pSchemaInfo->qsw);
|
||||
}
|
||||
|
@ -3934,6 +3936,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
int32_t type = nodeType(pPhyNode);
|
||||
|
||||
if (pPhyNode->pChildren == NULL || LIST_LENGTH(pPhyNode->pChildren) == 0) {
|
||||
SOperatorInfo* pOperator = NULL;
|
||||
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == type) {
|
||||
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode;
|
||||
|
||||
|
@ -3951,11 +3954,9 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SOperatorInfo* pOperator = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo);
|
||||
pOperator = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo);
|
||||
STableScanInfo* pScanInfo = pOperator->info;
|
||||
pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder;
|
||||
return pOperator;
|
||||
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN == type) {
|
||||
STableMergeScanPhysiNode* pTableScanNode = (STableMergeScanPhysiNode*)pPhyNode;
|
||||
int32_t code =
|
||||
|
@ -3972,14 +3973,12 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SOperatorInfo* pOperator = createTableMergeScanOperatorInfo(pTableScanNode, pTableListInfo, pHandle, pTaskInfo);
|
||||
pOperator = createTableMergeScanOperatorInfo(pTableScanNode, pTableListInfo, pHandle, pTaskInfo);
|
||||
|
||||
STableScanInfo* pScanInfo = pOperator->info;
|
||||
pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder;
|
||||
return pOperator;
|
||||
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) {
|
||||
return createExchangeOperatorInfo(pHandle->pMsgCb->clientRpc, (SExchangePhysiNode*)pPhyNode, pTaskInfo);
|
||||
pOperator = createExchangeOperatorInfo(pHandle->pMsgCb->clientRpc, (SExchangePhysiNode*)pPhyNode, pTaskInfo);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) {
|
||||
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode;
|
||||
if (pHandle->vnode) {
|
||||
|
@ -3995,18 +3994,16 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
int32_t sz = taosArrayGetSize(pTableListInfo->pTableList);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
STableKeyInfo* pKeyInfo = taosArrayGet(pTableListInfo->pTableList, i);
|
||||
qDebug("creating stream task: add table %ld", pKeyInfo->uid);
|
||||
qDebug("creating stream task: add table %" PRId64, pKeyInfo->uid);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
pTaskInfo->schemaInfo.qsw = extractQueriedColumnSchema(&pTableScanNode->scan);
|
||||
SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle, pTableScanNode, pTagCond, pTaskInfo);
|
||||
return pOperator;
|
||||
|
||||
pOperator = createStreamScanOperatorInfo(pHandle, pTableScanNode, pTagCond, pTaskInfo);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) {
|
||||
SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode;
|
||||
return createSysTableScanOperatorInfo(pHandle, pSysScanPhyNode, pUser, pTaskInfo);
|
||||
pOperator = createSysTableScanOperatorInfo(pHandle, pSysScanPhyNode, pUser, pTaskInfo);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN == type) {
|
||||
STagScanPhysiNode* pScanPhyNode = (STagScanPhysiNode*)pPhyNode;
|
||||
int32_t code = getTableList(pHandle->meta, pHandle->vnode, pScanPhyNode, pTagCond, pTagIndexCond, pTableListInfo);
|
||||
|
@ -4015,7 +4012,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
return NULL;
|
||||
}
|
||||
|
||||
return createTagScanOperatorInfo(pHandle, pScanPhyNode, pTableListInfo, pTaskInfo);
|
||||
pOperator = createTagScanOperatorInfo(pHandle, pScanPhyNode, pTableListInfo, pTaskInfo);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN == type) {
|
||||
SBlockDistScanPhysiNode* pBlockNode = (SBlockDistScanPhysiNode*)pPhyNode;
|
||||
pTableListInfo->pTableList = taosArrayInit(4, sizeof(STableKeyInfo));
|
||||
|
@ -4041,7 +4038,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
tsdbReaderOpen(pHandle->vnode, &cond, pTableListInfo->pTableList, &pReader, "");
|
||||
cleanupQueryTableDataCond(&cond);
|
||||
|
||||
return createDataBlockInfoScanOperator(pReader, pHandle, cond.suid, pBlockNode, pTaskInfo);
|
||||
pOperator = createDataBlockInfoScanOperator(pReader, pHandle, cond.suid, pBlockNode, pTaskInfo);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN == type) {
|
||||
SLastRowScanPhysiNode* pScanNode = (SLastRowScanPhysiNode*)pPhyNode;
|
||||
|
||||
|
@ -4058,12 +4055,14 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
return NULL;
|
||||
}
|
||||
|
||||
return createLastrowScanOperator(pScanNode, pHandle, pTaskInfo);
|
||||
pOperator = createLastrowScanOperator(pScanNode, pHandle, pTaskInfo);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_PROJECT == type) {
|
||||
return createProjectOperatorInfo(NULL, (SProjectPhysiNode*)pPhyNode, pTaskInfo);
|
||||
pOperator = createProjectOperatorInfo(NULL, (SProjectPhysiNode*)pPhyNode, pTaskInfo);
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
pOperator->resultDataBlockId = pPhyNode->pOutputDataBlockDesc->dataBlockId;
|
||||
return pOperator;
|
||||
}
|
||||
|
||||
int32_t num = 0;
|
||||
|
@ -4074,7 +4073,10 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, i);
|
||||
ops[i] = createOperatorTree(pChildNode, pTaskInfo, pHandle, pTableListInfo, pTagCond, pTagIndexCond, pUser);
|
||||
if (ops[i] == NULL) {
|
||||
taosMemoryFree(ops);
|
||||
return NULL;
|
||||
} else {
|
||||
ops[i]->resultDataBlockId = pChildNode->pOutputDataBlockDesc->dataBlockId;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4208,8 +4210,9 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
taosMemoryFree(ops);
|
||||
|
||||
pOptr->resultDataBlockId = pPhyNode->pOutputDataBlockDesc->dataBlockId;
|
||||
return pOptr;
|
||||
}
|
||||
|
||||
|
@ -4512,7 +4515,7 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
|
|||
return code;
|
||||
|
||||
_complete:
|
||||
taosMemoryFreeClear(*pTaskInfo);
|
||||
doDestroyTask(*pTaskInfo);
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
|
@ -4620,7 +4623,8 @@ int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SArray* pExecInf
|
|||
pExplainInfo->verboseInfo = NULL;
|
||||
|
||||
if (operatorInfo->fpSet.getExplainFn) {
|
||||
int32_t code = operatorInfo->fpSet.getExplainFn(operatorInfo, &pExplainInfo->verboseInfo, &pExplainInfo->verboseLen);
|
||||
int32_t code =
|
||||
operatorInfo->fpSet.getExplainFn(operatorInfo, &pExplainInfo->verboseInfo, &pExplainInfo->verboseLen);
|
||||
if (code) {
|
||||
qError("%s operator getExplainFn failed, code:%s", GET_TASKID(operatorInfo->pTaskInfo), tstrerror(code));
|
||||
return code;
|
||||
|
@ -4661,7 +4665,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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,34 @@
|
|||
static void setJoinColumnInfo(SColumnInfo* pColumn, const SColumnNode* pColumnNode);
|
||||
static SSDataBlock* doMergeJoin(struct SOperatorInfo* pOperator);
|
||||
static void destroyMergeJoinOperator(void* param, int32_t numOfOutput);
|
||||
static void extractTimeCondition(SJoinOperatorInfo* Info, SLogicConditionNode* pLogicConditionNode);
|
||||
static void extractTimeCondition(SJoinOperatorInfo* pInfo, SOperatorInfo** pDownstream, int32_t numOfDownstream,
|
||||
SSortMergeJoinPhysiNode* pJoinNode);
|
||||
|
||||
static void extractTimeCondition(SJoinOperatorInfo* pInfo, SOperatorInfo** pDownstream, int32_t numOfDownstream,
|
||||
SSortMergeJoinPhysiNode* pJoinNode) {
|
||||
SNode* pMergeCondition = pJoinNode->pMergeCondition;
|
||||
if (nodeType(pMergeCondition) == QUERY_NODE_OPERATOR) {
|
||||
SOperatorNode* pNode = (SOperatorNode*)pMergeCondition;
|
||||
SColumnNode* col1 = (SColumnNode*)pNode->pLeft;
|
||||
SColumnNode* col2 = (SColumnNode*)pNode->pRight;
|
||||
SColumnNode* leftTsCol = NULL;
|
||||
SColumnNode* rightTsCol = NULL;
|
||||
if (col1->dataBlockId == pDownstream[0]->resultDataBlockId) {
|
||||
ASSERT(col2->dataBlockId == pDownstream[1]->resultDataBlockId);
|
||||
leftTsCol = col1;
|
||||
rightTsCol = col2;
|
||||
} else {
|
||||
ASSERT(col1->dataBlockId == pDownstream[1]->resultDataBlockId);
|
||||
ASSERT(col2->dataBlockId == pDownstream[0]->resultDataBlockId);
|
||||
leftTsCol = col2;
|
||||
rightTsCol = col1;
|
||||
}
|
||||
setJoinColumnInfo(&pInfo->leftCol, leftTsCol);
|
||||
setJoinColumnInfo(&pInfo->rightCol, rightTsCol);
|
||||
} else {
|
||||
ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
||||
SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream,
|
||||
SSortMergeJoinPhysiNode* pJoinNode, SExecTaskInfo* pTaskInfo) {
|
||||
|
@ -53,14 +80,7 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
|
|||
pOperator->info = pInfo;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
|
||||
SNode* pMergeCondition = pJoinNode->pMergeCondition;
|
||||
if (nodeType(pMergeCondition) == QUERY_NODE_OPERATOR) {
|
||||
SOperatorNode* pNode = (SOperatorNode*)pMergeCondition;
|
||||
setJoinColumnInfo(&pInfo->leftCol, (SColumnNode*)pNode->pLeft);
|
||||
setJoinColumnInfo(&pInfo->rightCol, (SColumnNode*)pNode->pRight);
|
||||
} else {
|
||||
ASSERT(false);
|
||||
}
|
||||
extractTimeCondition(pInfo, pDownstream, numOfDownstream, pJoinNode);
|
||||
|
||||
if (pJoinNode->pOnConditions != NULL && pJoinNode->node.pConditions != NULL) {
|
||||
pInfo->pCondAfterMerge = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
|
@ -367,17 +387,3 @@ SSDataBlock* doMergeJoin(struct SOperatorInfo* pOperator) {
|
|||
}
|
||||
return (pRes->info.rows > 0) ? pRes : NULL;
|
||||
}
|
||||
|
||||
static void extractTimeCondition(SJoinOperatorInfo* pInfo, SLogicConditionNode* pLogicConditionNode) {
|
||||
int32_t len = LIST_LENGTH(pLogicConditionNode->pParameterList);
|
||||
|
||||
for (int32_t i = 0; i < len; ++i) {
|
||||
SNode* pNode = nodesListGetNode(pLogicConditionNode->pParameterList, i);
|
||||
if (nodeType(pNode) == QUERY_NODE_OPERATOR) {
|
||||
SOperatorNode* pn1 = (SOperatorNode*)pNode;
|
||||
setJoinColumnInfo(&pInfo->leftCol, (SColumnNode*)pn1->pLeft);
|
||||
setJoinColumnInfo(&pInfo->rightCol, (SColumnNode*)pn1->pRight);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
|
|||
goto _error;
|
||||
}
|
||||
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
|
||||
int32_t numOfCols = 0;
|
||||
SExprInfo* pExprInfo = createExprInfo(pProjPhyNode->pProjections, NULL, &numOfCols);
|
||||
|
||||
|
@ -73,7 +75,6 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
|
|||
pInfo->mergeDataBlocks = false;
|
||||
}
|
||||
|
||||
|
||||
int32_t numOfRows = 4096;
|
||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||
|
||||
|
@ -94,7 +95,6 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
|
|||
pOperator->blocking = false;
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
pOperator->info = pInfo;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doProjectOperation, NULL, NULL,
|
||||
destroyProjectOperatorInfo, NULL, NULL, NULL);
|
||||
|
@ -156,7 +156,8 @@ static int32_t setInfoForNewGroup(SSDataBlock* pBlock, SLimitInfo* pLimitInfo, S
|
|||
return PROJECT_RETRIEVE_DONE;
|
||||
}
|
||||
|
||||
static int32_t doIngroupLimitOffset(SLimitInfo* pLimitInfo, uint64_t groupId, SSDataBlock* pBlock, SOperatorInfo* pOperator) {
|
||||
static int32_t doIngroupLimitOffset(SLimitInfo* pLimitInfo, uint64_t groupId, SSDataBlock* pBlock,
|
||||
SOperatorInfo* pOperator) {
|
||||
// set current group id
|
||||
pLimitInfo->currentGroupId = groupId;
|
||||
|
||||
|
@ -170,8 +171,7 @@ static int32_t doIngroupLimitOffset(SLimitInfo* pLimitInfo, uint64_t groupId, SS
|
|||
}
|
||||
|
||||
// check for the limitation in each group
|
||||
if (pLimitInfo->limit.limit >= 0 &&
|
||||
pLimitInfo->numOfOutputRows + pBlock->info.rows >= pLimitInfo->limit.limit) {
|
||||
if (pLimitInfo->limit.limit >= 0 && pLimitInfo->numOfOutputRows + pBlock->info.rows >= pLimitInfo->limit.limit) {
|
||||
int32_t keepRows = (int32_t)(pLimitInfo->limit.limit - pLimitInfo->numOfOutputRows);
|
||||
blockDataKeepFirstNRows(pBlock, keepRows);
|
||||
if (pLimitInfo->slimit.limit > 0 && pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups) {
|
||||
|
@ -330,6 +330,8 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy
|
|||
goto _error;
|
||||
}
|
||||
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
|
||||
SExprSupp* pSup = &pOperator->exprSupp;
|
||||
|
||||
SIndefRowsFuncPhysiNode* pPhyNode = (SIndefRowsFuncPhysiNode*)pNode;
|
||||
|
@ -373,7 +375,6 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy
|
|||
pOperator->blocking = false;
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
pOperator->info = pInfo;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doApplyIndefinitFunction, NULL, NULL,
|
||||
destroyIndefinitOperatorInfo, NULL, NULL, NULL);
|
||||
|
|
|
@ -1493,6 +1493,11 @@ static void destroyStreamScanOperatorInfo(void* param, int32_t numOfOutput) {
|
|||
if (pStreamScan->pColMatchInfo) {
|
||||
taosArrayDestroy(pStreamScan->pColMatchInfo);
|
||||
}
|
||||
if (pStreamScan->pPseudoExpr) {
|
||||
destroyExprInfo(pStreamScan->pPseudoExpr, pStreamScan->numOfPseudoExpr);
|
||||
taosMemoryFreeClear(pStreamScan->pPseudoExpr);
|
||||
}
|
||||
|
||||
updateInfoDestroy(pStreamScan->pUpdateInfo);
|
||||
blockDataDestroy(pStreamScan->pRes);
|
||||
blockDataDestroy(pStreamScan->pUpdateRes);
|
||||
|
|
|
@ -30,6 +30,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
|
|||
goto _error;
|
||||
}
|
||||
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
SDataBlockDescNode* pDescNode = pSortNode->node.pOutputDataBlockDesc;
|
||||
|
||||
int32_t numOfCols = 0;
|
||||
|
@ -57,7 +58,6 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
|
|||
pOperator->info = pInfo;
|
||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
|
||||
// lazy evaluation for the following parameter since the input datablock is not known till now.
|
||||
// pInfo->bufPageSize = rowSize < 1024 ? 1024 * 2 : rowSize * 2;
|
||||
|
@ -609,8 +609,7 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData
|
|||
pInfo->groupId = tsortGetGroupId(pTupleHandle);
|
||||
pInfo->prefetchedTuple = NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
pTupleHandle = tsortNextTuple(pHandle);
|
||||
pInfo->groupId = 0;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
@ -928,7 +928,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
TSKEY ts = getStartTsKey(&pBlock->info.window, tsCols);
|
||||
SResultRow* pResult = NULL;
|
||||
|
||||
STimeWindow win = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, pInfo->inputOrder);
|
||||
STimeWindow win =
|
||||
getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, pInfo->inputOrder);
|
||||
int32_t ret = TSDB_CODE_SUCCESS;
|
||||
if ((!pInfo->ignoreExpiredData || !isCloseWindow(&win, &pInfo->twAggSup)) &&
|
||||
inSlidingWindow(&pInfo->interval, &win, &pBlock->info)) {
|
||||
|
@ -1344,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);
|
||||
|
@ -1790,6 +1791,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
|||
goto _error;
|
||||
}
|
||||
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
pInfo->win = pTaskInfo->window;
|
||||
pInfo->inputOrder = (pPhyNode->window.inputTsOrder == ORDER_ASC) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||
pInfo->resultTsOrder = (pPhyNode->window.outputTsOrder == ORDER_ASC) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||
|
@ -1845,7 +1847,6 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
|||
pOperator->blocking = true;
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||
pOperator->info = pInfo;
|
||||
|
||||
|
@ -1880,6 +1881,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr
|
|||
goto _error;
|
||||
}
|
||||
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
pInfo->inputOrder = TSDB_ORDER_ASC;
|
||||
pInfo->interval = *pInterval;
|
||||
pInfo->execModel = OPTR_EXEC_MODEL_STREAM;
|
||||
|
@ -1906,7 +1908,6 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr
|
|||
pOperator->blocking = true;
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||
pOperator->info = pInfo;
|
||||
|
||||
|
@ -2180,7 +2181,6 @@ static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int32_t initPrevRowsKeeper(STimeSliceOperatorInfo* pInfo, SSDataBlock* pBlock) {
|
||||
|
@ -3028,6 +3028,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
|
|||
goto _error;
|
||||
}
|
||||
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
pInfo->order = TSDB_ORDER_ASC;
|
||||
pInfo->interval = (SInterval){.interval = pIntervalPhyNode->interval,
|
||||
.sliding = pIntervalPhyNode->sliding,
|
||||
|
@ -3114,7 +3115,6 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
|
|||
pOperator->blocking = true;
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||
pOperator->info = pInfo;
|
||||
|
||||
|
@ -3246,6 +3246,8 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh
|
|||
goto _error;
|
||||
}
|
||||
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
if (pSessionNode->window.pExprs != NULL) {
|
||||
int32_t numOfScalar = 0;
|
||||
|
@ -3308,7 +3310,6 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh
|
|||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, doStreamSessionAgg, NULL, NULL, destroyStreamSessionAggOperatorInfo,
|
||||
aggEncodeResultRow, aggDecodeResultRow, NULL);
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
if (downstream) {
|
||||
initDownStream(downstream, &pInfo->streamAggSup, pInfo->gap, pInfo->twAggSup.waterMark, pOperator->operatorType);
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
|
@ -3465,7 +3466,7 @@ static int32_t setWindowOutputBuf(SResultWindowInfo* pWinInfo, SResultRow** pRes
|
|||
assert(pWinInfo->win.skey <= pWinInfo->win.ekey);
|
||||
// too many time window in query
|
||||
int32_t size = taosArrayGetSize(pAggSup->pCurWins);
|
||||
if (size > MAX_INTERVAL_TIME_WINDOW) {
|
||||
if (pTaskInfo->execModel == OPTR_EXEC_MODEL_BATCH && size > MAX_INTERVAL_TIME_WINDOW) {
|
||||
longjmp(pTaskInfo->env, TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW);
|
||||
}
|
||||
|
||||
|
@ -3480,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;
|
||||
|
@ -3647,8 +3648,8 @@ void deleteWindow(SArray* pWinInfos, int32_t index, FDelete fp) {
|
|||
taosArrayRemove(pWinInfos, index);
|
||||
}
|
||||
|
||||
static void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, int64_t gap,
|
||||
SArray* result, FDelete fp) {
|
||||
static void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, int64_t gap, SArray* result,
|
||||
FDelete fp) {
|
||||
SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||
TSKEY* startDatas = (TSKEY*)pStartTsCol->pData;
|
||||
SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
||||
|
@ -4673,7 +4674,8 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR
|
|||
currTs = tsCols[currPos];
|
||||
currWin.skey = currTs;
|
||||
currWin.ekey = taosTimeAdd(currWin.skey, iaInfo->interval.interval, iaInfo->interval.intervalUnit,
|
||||
iaInfo->interval.precision) - 1;
|
||||
iaInfo->interval.precision) -
|
||||
1;
|
||||
|
||||
startPos = currPos;
|
||||
ret = setTimeWindowOutputBuf(pResultRowInfo, &currWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx,
|
||||
|
@ -4933,8 +4935,8 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
|
|||
TSKEY blockStartTs = getStartTsKey(&pBlock->info.window, tsCols);
|
||||
SResultRow* pResult = NULL;
|
||||
|
||||
STimeWindow win =
|
||||
getActiveTimeWindow(iaInfo->aggSup.pResultBuf, pResultRowInfo, blockStartTs, &iaInfo->interval, iaInfo->inputOrder);
|
||||
STimeWindow win = getActiveTimeWindow(iaInfo->aggSup.pResultBuf, pResultRowInfo, blockStartTs, &iaInfo->interval,
|
||||
iaInfo->inputOrder);
|
||||
|
||||
int32_t ret =
|
||||
setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pExprSup->pCtx,
|
||||
|
@ -4975,7 +4977,8 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
|
|||
STimeWindow nextWin = win;
|
||||
while (1) {
|
||||
int32_t prevEndPos = forwardRows - 1 + startPos;
|
||||
startPos = getNextQualifiedWindow(&iaInfo->interval, &nextWin, &pBlock->info, tsCols, prevEndPos, iaInfo->inputOrder);
|
||||
startPos =
|
||||
getNextQualifiedWindow(&iaInfo->interval, &nextWin, &pBlock->info, tsCols, prevEndPos, iaInfo->inputOrder);
|
||||
if (startPos < 0) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "querynodes.h"
|
||||
#include "scalar.h"
|
||||
#include "taoserror.h"
|
||||
#include "ttime.h"
|
||||
|
||||
static int32_t buildFuncErrMsg(char* pErrBuf, int32_t len, int32_t errCode, const char* pFormat, ...) {
|
||||
va_list vArgList;
|
||||
|
@ -1442,6 +1443,57 @@ static int32_t translateIrate(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateInterp(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList);
|
||||
uint8_t dbPrec = pFunc->node.resType.precision;
|
||||
|
||||
if (1 != numOfParams && 3 != numOfParams && 4 != numOfParams) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
if (3 <= numOfParams) {
|
||||
int64_t timeVal[2] = {0};
|
||||
for (int32_t i = 1; i < 3; ++i) {
|
||||
uint8_t nodeType = nodeType(nodesListGetNode(pFunc->pParameterList, i));
|
||||
uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, i))->resType.type;
|
||||
if (!IS_VAR_DATA_TYPE(paraType) || QUERY_NODE_VALUE != nodeType) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
SValueNode* pValue = (SValueNode*)nodesListGetNode(pFunc->pParameterList, i);
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
if (4 == numOfParams) {
|
||||
uint8_t nodeType = nodeType(nodesListGetNode(pFunc->pParameterList, 3));
|
||||
uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 3))->resType.type;
|
||||
if (!IS_INTEGER_TYPE(paraType) || QUERY_NODE_VALUE != nodeType) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
int32_t ret = validateTimeUnitParam(dbPrec, (SValueNode*)nodesListGetNode(pFunc->pParameterList, 3));
|
||||
if (ret == TIME_UNIT_TOO_SMALL) {
|
||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||
"INTERP function time interval parameter should be greater than db precision");
|
||||
} else if (ret == TIME_UNIT_INVALID) {
|
||||
return buildFuncErrMsg(
|
||||
pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||
"INTERP function time interval parameter should be one of the following: [1b, 1u, 1a, 1s, 1m, 1h, 1d, 1w]");
|
||||
}
|
||||
}
|
||||
|
||||
pFunc->node.resType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateFirstLast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
// forbid null as first/last input, since first(c0, null, 1) may have different number of input
|
||||
int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList);
|
||||
|
@ -2083,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,
|
||||
|
@ -2237,7 +2289,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "interp",
|
||||
.type = FUNCTION_TYPE_INTERP,
|
||||
.classification = FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_INTERVAL_INTERPO_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||
.translateFunc = translateFirstLast,
|
||||
.translateFunc = translateInterp,
|
||||
.getEnvFunc = getSelectivityFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
.processFunc = NULL,
|
||||
|
@ -2246,7 +2298,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "derivative",
|
||||
.type = FUNCTION_TYPE_DERIVATIVE,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | FUNC_MGT_CUMULATIVE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC |
|
||||
FUNC_MGT_KEEP_ORDER_FUNC | FUNC_MGT_CUMULATIVE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||
.translateFunc = translateDerivative,
|
||||
.getEnvFunc = getDerivativeFuncEnv,
|
||||
.initFunc = derivativeFuncSetup,
|
||||
|
@ -2453,7 +2506,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "diff",
|
||||
.type = FUNCTION_TYPE_DIFF,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_CUMULATIVE_FUNC,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_KEEP_ORDER_FUNC |
|
||||
FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_CUMULATIVE_FUNC,
|
||||
.translateFunc = translateDiff,
|
||||
.getEnvFunc = getDiffFuncEnv,
|
||||
.initFunc = diffFunctionSetup,
|
||||
|
@ -2487,7 +2541,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "csum",
|
||||
.type = FUNCTION_TYPE_CSUM,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_CUMULATIVE_FUNC,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC |
|
||||
FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_CUMULATIVE_FUNC | FUNC_MGT_KEEP_ORDER_FUNC,
|
||||
.translateFunc = translateCsum,
|
||||
.getEnvFunc = getCsumFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
|
@ -2856,7 +2911,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "tbname",
|
||||
.type = FUNCTION_TYPE_TBNAME,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_SCAN_PC_FUNC,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_SCAN_PC_FUNC | FUNC_MGT_KEEP_ORDER_FUNC,
|
||||
.translateFunc = translateTbnameColumn,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
|
@ -2896,7 +2951,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "_wstart",
|
||||
.type = FUNCTION_TYPE_WSTART,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC | FUNC_MGT_KEEP_ORDER_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
|
@ -2906,7 +2961,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "_wend",
|
||||
.type = FUNCTION_TYPE_WEND,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC | FUNC_MGT_KEEP_ORDER_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
|
@ -2916,7 +2971,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "_wduration",
|
||||
.type = FUNCTION_TYPE_WDURATION,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC | FUNC_MGT_KEEP_ORDER_FUNC,
|
||||
.translateFunc = translateWduration,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
|
@ -2964,7 +3019,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "_group_key",
|
||||
.type = FUNCTION_TYPE_GROUP_KEY,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_KEEP_ORDER_FUNC,
|
||||
.translateFunc = translateGroupKey,
|
||||
.getEnvFunc = getGroupKeyFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#define HISTOGRAM_MAX_BINS_NUM 1000
|
||||
#define MAVG_MAX_POINTS_NUM 1000
|
||||
#define SAMPLE_MAX_POINTS_NUM 1000
|
||||
#define TAIL_MAX_POINTS_NUM 100
|
||||
#define TAIL_MAX_OFFSET 100
|
||||
|
||||
|
@ -2494,6 +2493,8 @@ bool apercentileFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResult
|
|||
} else {
|
||||
buildHistogramInfo(pInfo);
|
||||
pInfo->pHisto = tHistogramCreateFrom(tmp, MAX_HISTOGRAM_BIN);
|
||||
qDebug("%s set up histogram, numOfElems:%" PRId64 ", numOfEntry:%d, pHisto:%p, elems:%p", __FUNCTION__,
|
||||
pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto, pInfo->pHisto->elems);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -2524,6 +2525,12 @@ int32_t apercentileFunction(SqlFunctionCtx* pCtx) {
|
|||
tdigestAdd(pInfo->pTDigest, v, w);
|
||||
}
|
||||
} else {
|
||||
qDebug("%s before add %d elements into histogram, total:%d, numOfEntry:%d, pHisto:%p, elems: %p", __FUNCTION__,
|
||||
numOfElems, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto, pInfo->pHisto->elems);
|
||||
|
||||
// might be a race condition here that pHisto can be overwritten or setup function
|
||||
// has not been called, need to relink the buffer pHisto points to.
|
||||
buildHistogramInfo(pInfo);
|
||||
for (int32_t i = start; i < pInput->numOfRows + start; ++i) {
|
||||
if (colDataIsNull_f(pCol->nullbitmap, i)) {
|
||||
continue;
|
||||
|
@ -2536,8 +2543,8 @@ int32_t apercentileFunction(SqlFunctionCtx* pCtx) {
|
|||
tHistogramAdd(&pInfo->pHisto, v);
|
||||
}
|
||||
|
||||
qDebug("add %d elements into histogram, total:%d, numOfEntry:%d, %p", numOfElems, pInfo->pHisto->numOfElems,
|
||||
pInfo->pHisto->numOfEntries, pInfo->pHisto);
|
||||
qDebug("%s after add %d elements into histogram, total:%d, numOfEntry:%d, pHisto:%p, elems: %p", __FUNCTION__,
|
||||
numOfElems, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto, pInfo->pHisto->elems);
|
||||
}
|
||||
|
||||
SET_VAL(pResInfo, numOfElems, 1);
|
||||
|
@ -2577,17 +2584,19 @@ static void apercentileTransferInfo(SAPercentileInfo* pInput, SAPercentileInfo*
|
|||
memcpy(pHisto, pInput->pHisto, sizeof(SHistogramInfo) + sizeof(SHistBin) * (MAX_HISTOGRAM_BIN + 1));
|
||||
pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo));
|
||||
|
||||
qDebug("merge histo, total:%" PRId64 ", entry:%d, %p", pHisto->numOfElems, pHisto->numOfEntries, pHisto);
|
||||
qDebug("%s merge histo, total:%" PRId64 ", entry:%d, %p", __FUNCTION__, pHisto->numOfElems,
|
||||
pHisto->numOfEntries, pHisto);
|
||||
} else {
|
||||
pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo));
|
||||
qDebug("input histogram, elem:%" PRId64 ", entry:%d, %p", pHisto->numOfElems, pHisto->numOfEntries,
|
||||
pInput->pHisto);
|
||||
qDebug("%s input histogram, elem:%" PRId64 ", entry:%d, %p", __FUNCTION__, pHisto->numOfElems,
|
||||
pHisto->numOfEntries, pInput->pHisto);
|
||||
|
||||
SHistogramInfo* pRes = tHistogramMerge(pHisto, pInput->pHisto, MAX_HISTOGRAM_BIN);
|
||||
memcpy(pHisto, pRes, sizeof(SHistogramInfo) + sizeof(SHistBin) * MAX_HISTOGRAM_BIN);
|
||||
pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo));
|
||||
|
||||
qDebug("merge histo, total:%" PRId64 ", entry:%d, %p", pHisto->numOfElems, pHisto->numOfEntries, pHisto);
|
||||
qDebug("%s merge histo, total:%" PRId64 ", entry:%d, %p", __FUNCTION__, pHisto->numOfElems,
|
||||
pHisto->numOfEntries, pHisto);
|
||||
tHistogramDestroy(&pRes);
|
||||
}
|
||||
}
|
||||
|
@ -2603,7 +2612,7 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) {
|
|||
|
||||
SAPercentileInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||
|
||||
qDebug("total %d rows will merge, %p", pInput->numOfRows, pInfo->pHisto);
|
||||
qDebug("%s total %d rows will merge, %p", __FUNCTION__, pInput->numOfRows, pInfo->pHisto);
|
||||
|
||||
int32_t start = pInput->startRowIndex;
|
||||
for (int32_t i = start; i < start + pInput->numOfRows; ++i) {
|
||||
|
@ -2614,7 +2623,7 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) {
|
|||
}
|
||||
|
||||
if (pInfo->algo != APERCT_ALGO_TDIGEST) {
|
||||
qDebug("after merge, total:%d, numOfEntry:%d, %p", pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries,
|
||||
qDebug("%s after merge, total:%d, numOfEntry:%d, %p", __FUNCTION__, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries,
|
||||
pInfo->pHisto);
|
||||
}
|
||||
|
||||
|
@ -2637,8 +2646,8 @@ int32_t apercentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
} else {
|
||||
buildHistogramInfo(pInfo);
|
||||
if (pInfo->pHisto->numOfElems > 0) {
|
||||
qDebug("get the final res:%d, elements:%" PRId64 ", entry:%d", pInfo->pHisto->numOfElems,
|
||||
pInfo->pHisto->numOfEntries);
|
||||
qDebug("%s get the final res, elements:%" PRId64 ", numOfEntry:%d, pHisto:%p, elems:%p", __FUNCTION__,
|
||||
pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto, pInfo->pHisto->elems);
|
||||
|
||||
double ratio[] = {pInfo->percent};
|
||||
double* res = tHistogramUniform(pInfo->pHisto, ratio, 1);
|
||||
|
@ -2685,7 +2694,7 @@ int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx)
|
|||
SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx);
|
||||
SAPercentileInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo);
|
||||
|
||||
qDebug("start to combine apercentile, %p", pDBuf->pHisto);
|
||||
qDebug("%s start to combine apercentile, %p", __FUNCTION__, pDBuf->pHisto);
|
||||
|
||||
apercentileTransferInfo(pSBuf, pDBuf);
|
||||
pDResInfo->numOfRes = TMAX(pDResInfo->numOfRes, pSResInfo->numOfRes);
|
||||
|
@ -4888,9 +4897,7 @@ bool sampleFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo)
|
|||
pInfo->numSampled = 0;
|
||||
pInfo->colType = pCtx->resDataInfo.type;
|
||||
pInfo->colBytes = pCtx->resDataInfo.bytes;
|
||||
if (pInfo->samples < 1 || pInfo->samples > SAMPLE_MAX_POINTS_NUM) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pInfo->data = (char*)pInfo + sizeof(SSampleInfo);
|
||||
pInfo->tuplePos = (STuplePos*)((char*)pInfo + sizeof(SSampleInfo) + pInfo->samples * pInfo->colBytes);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -976,8 +976,12 @@ int32_t cleanUpUdfs() {
|
|||
}
|
||||
|
||||
uv_mutex_lock(&gUdfdProxy.udfStubsMutex);
|
||||
int32_t i = 0;
|
||||
if (gUdfdProxy.udfStubs == NULL || taosArrayGetSize(gUdfdProxy.udfStubs) == 0) {
|
||||
uv_mutex_unlock(&gUdfdProxy.udfStubsMutex);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
SArray* udfStubs = taosArrayInit(16, sizeof(SUdfcFuncStub));
|
||||
int32_t i = 0;
|
||||
while (i < taosArrayGetSize(gUdfdProxy.udfStubs)) {
|
||||
SUdfcFuncStub *stub = taosArrayGet(gUdfdProxy.udfStubs, i);
|
||||
if (stub->refCount == 0) {
|
||||
|
|
|
@ -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));
|
||||
|
@ -686,7 +695,6 @@ void udfdAllocBuffer(uv_handle_t *handle, size_t suggestedSize, uv_buf_t *buf) {
|
|||
buf->len = 0;
|
||||
}
|
||||
}
|
||||
fnDebug("allocate buf. input buf cap - len - total : %d - %d - %d", ctx->inputCap, ctx->inputLen, ctx->inputTotal);
|
||||
}
|
||||
|
||||
bool isUdfdUvMsgComplete(SUdfdUvConn *pipe) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue