diff --git a/.gitignore b/.gitignore
index c25f60075c..1c609d3ba3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -118,3 +118,4 @@ contrib/*
!contrib/test
sql
debug*/
+.env
\ No newline at end of file
diff --git a/cmake/taosws_CMakeLists.txt.in b/cmake/taosws_CMakeLists.txt.in
index a2b45a5bfa..de6409a8c6 100644
--- a/cmake/taosws_CMakeLists.txt.in
+++ b/cmake/taosws_CMakeLists.txt.in
@@ -2,7 +2,7 @@
# taosws-rs
ExternalProject_Add(taosws-rs
GIT_REPOSITORY https://github.com/taosdata/taosws-rs.git
- GIT_TAG 648cc62
+ GIT_TAG 29424d5
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE
diff --git a/docs/zh/07-develop/09-udf.md b/docs/zh/07-develop/09-udf.md
index 6071275b55..b8ae618105 100644
--- a/docs/zh/07-develop/09-udf.md
+++ b/docs/zh/07-develop/09-udf.md
@@ -124,52 +124,49 @@ gcc -g -O0 -fPIC -shared add_one.c -o add_one.so
用户可以通过 SQL 指令在系统中加载客户端所在主机上的 UDF 函数库(不能通过 RESTful 接口或 HTTP 管理界面来进行这一过程)。一旦创建成功,则当前 TDengine 集群的所有用户都可以在 SQL 指令中使用这些函数。UDF 存储在系统的 MNode 节点上,因此即使重启 TDengine 系统,已经创建的 UDF 也仍然可用。
-在创建 UDF 时,需要区分标量函数和聚合函数。如果创建时声明了错误的函数类别,则可能导致通过 SQL 指令调用函数时出错。此外, UDF 支持输入与输出类型不一致,用户需要保证输入数据类型与 UDF 程序匹配,UDF 输出数据类型与 OUTPUTTYPE 匹配。
+在创建 UDF 时,需要区分标量函数和聚合函数。如果创建时声明了错误的函数类别,则可能导致通过 SQL 指令调用函数时出错。此外,用户需要保证输入数据类型与 UDF 程序匹配,UDF 输出数据类型与 OUTPUTTYPE 匹配。
- 创建标量函数
```sql
-CREATE FUNCTION ids(X) AS ids(Y) OUTPUTTYPE typename(Z) [ BUFSIZE B ];
+CREATE FUNCTION function_name AS library_path OUTPUTTYPE output_type;
```
- - ids(X):标量函数未来在 SQL 指令中被调用时的函数名,必须与函数实现中 udfNormalFunc 的实际名称一致;
- - ids(Y):包含 UDF 函数实现的动态链接库的库文件绝对路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件),这个路径需要用英文单引号或英文双引号括起来;
- - typename(Z):此函数计算结果的数据类型,与上文中 udfNormalFunc 的 itype 参数不同,这里不是使用数字表示法,而是直接写类型名称即可;
- - B:中间计算结果的缓冲区大小,单位是字节,最小 0,最大 512,如果不使用可以不设置。
+ - function_name:标量函数未来在 SQL 中被调用时的函数名,必须与函数实现中 udf 的实际名称一致;
+ - library_path:包含 UDF 函数实现的动态链接库的库文件绝对路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件),这个路径需要用英文单引号或英文双引号括起来;
+ - output_type:此函数计算结果的数据类型名称;
- 例如,如下语句可以把 add_one.so 创建为系统中可用的 UDF:
+ 例如,如下语句可以把 libbitand.so 创建为系统中可用的 UDF:
```sql
- CREATE FUNCTION add_one AS "/home/taos/udf_example/add_one.so" OUTPUTTYPE INT;
+ CREATE FUNCTION bit_and AS "/home/taos/udf_example/libbitand.so" OUTPUTTYPE INT;
```
- 创建聚合函数:
```sql
-CREATE AGGREGATE FUNCTION ids(X) AS ids(Y) OUTPUTTYPE typename(Z) [ BUFSIZE B ];
+CREATE AGGREGATE FUNCTION function_name AS library_path OUTPUTTYPE output_type [ BUFSIZE buffer_size ];
```
- - ids(X):聚合函数未来在 SQL 指令中被调用时的函数名,必须与函数实现中 udfNormalFunc 的实际名称一致;
- - ids(Y):包含 UDF 函数实现的动态链接库的库文件绝对路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件),这个路径需要用英文单引号或英文双引号括起来;
- - typename(Z):此函数计算结果的数据类型,与上文中 udfNormalFunc 的 itype 参数不同,这里不是使用数字表示法,而是直接写类型名称即可;
- - B:中间计算结果的缓冲区大小,单位是字节,最小 0,最大 512,如果不使用可以不设置。
+ - function_name:聚合函数未来在 SQL 中被调用时的函数名,必须与函数实现中 udfNormalFunc 的实际名称一致;
+ - library_path:包含 UDF 函数实现的动态链接库的库文件绝对路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件),这个路径需要用英文单引号或英文双引号括起来;
+ - output_type:此函数计算结果的数据类型,与上文中 udfNormalFunc 的 itype 参数不同,这里不是使用数字表示法,而是直接写类型名称即可;
+ - buffer_size:中间计算结果的缓冲区大小,单位是字节。如果不使用可以不设置。
- 关于中间计算结果的使用,可以参考示例程序[demo.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/demo.c)
-
- 例如,如下语句可以把 demo.so 创建为系统中可用的 UDF:
+ 例如,如下语句可以把 libsqrsum.so 创建为系统中可用的 UDF:
```sql
- CREATE AGGREGATE FUNCTION demo AS "/home/taos/udf_example/demo.so" OUTPUTTYPE DOUBLE bufsize 14;
+ CREATE AGGREGATE FUNCTION sqr_sum AS "/home/taos/udf_example/libsqrsum.so" OUTPUTTYPE DOUBLE bufsize 8;
```
### 管理 UDF
- 删除指定名称的用户定义函数:
```
-DROP FUNCTION ids(X);
+DROP FUNCTION function_name;
```
-- ids(X):此参数的含义与 CREATE 指令中的 ids(X) 参数一致,也即要删除的函数的名字,例如
+- function_name:此参数的含义与 CREATE 指令中的 function_name 参数一致,也即要删除的函数的名字,例如
```sql
-DROP FUNCTION add_one;
+DROP FUNCTION bit_and;
```
- 显示系统中当前可用的所有 UDF:
```sql
@@ -180,53 +177,32 @@ SHOW FUNCTIONS;
在 SQL 指令中,可以直接以在系统中创建 UDF 时赋予的函数名来调用用户定义函数。例如:
```sql
-SELECT X(c) FROM table/stable;
+SELECT X(c1,c2) FROM table/stable;
```
-表示对名为 c 的数据列调用名为 X 的用户定义函数。SQL 指令中用户定义函数可以配合 WHERE 等查询特性来使用。
+表示对名为 c1, c2 的数据列调用名为 X 的用户定义函数。SQL 指令中用户定义函数可以配合 WHERE 等查询特性来使用。
-## UDF 的一些使用限制
-
-在当前版本下,使用 UDF 存在如下这些限制:
-
-1. 在创建和调用 UDF 时,服务端和客户端都只支持 Linux 操作系统;
-2. UDF 不能与系统内建的 SQL 函数混合使用,暂不支持在一条 SQL 语句中使用多个不同名的 UDF ;
-3. UDF 只支持以单个数据列作为输入;
-4. UDF 只要创建成功,就会被持久化存储到 MNode 节点中;
-5. 无法通过 RESTful 接口来创建 UDF;
-6. UDF 在 SQL 中定义的函数名,必须与 .so 库文件实现中的接口函数名前缀保持一致,也即必须是 udfNormalFunc 的名称,而且不可与 TDengine 中已有的内建 SQL 函数重名。
## 示例代码
-### 标量函数示例 [add_one](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/add_one.c)
+### 标量函数示例 [bit_and](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/bit_and.c)
-add_one.c
+bit_and.c
```c
-{{#include tests/script/sh/add_one.c}}
+{{#include tests/script/sh/bit_and.c}}
```
-### 向量函数示例 [abs_max](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/abs_max.c)
+### 聚合函数示例 [sqr_sum](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/sqr_sum.c)
-abs_max.c
+sqr_sum.c
```c
-{{#include tests/script/sh/abs_max.c}}
-```
-
-
-
-### 使用中间计算结果示例 [demo](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/demo.c)
-
-
-demo.c
-
-```c
-{{#include tests/script/sh/demo.c}}
+{{#include tests/script/sh/sqr_sum.c}}
```
diff --git a/docs/zh/12-taos-sql/26-udf.md b/docs/zh/12-taos-sql/26-udf.md
index bd8d61a584..1292206311 100644
--- a/docs/zh/12-taos-sql/26-udf.md
+++ b/docs/zh/12-taos-sql/26-udf.md
@@ -8,21 +8,30 @@ title: 用户自定义函数
## 创建函数
```sql
-CREATE [AGGREGATE] FUNCTION func_name AS library_path OUTPUTTYPE type_name [BUFSIZE value]
+CREATE [AGGREGATE] FUNCTION func_name AS library_path OUTPUTTYPE type_name [BUFSIZE buffer_size]
```
语法说明:
AGGREGATE:标识此函数是标量函数还是聚集函数。
-func_name:函数名,必须与函数实现中udfNormalFunc的实际名称一致。
+func_name:函数名,必须与函数实现中 udf 的实际名称一致。
library_path:包含UDF函数实现的动态链接库的绝对路径,是在客户端侧主机上的绝对路径。
-OUTPUTTYPE:标识此函数的返回类型。
-BUFSIZE:中间结果的缓冲区大小,单位是字节。不设置则默认为0。最大不可超过512字节。
+type_name:标识此函数的返回类型。
+buffer_size:中间结果的缓冲区大小,单位是字节。不设置则默认为0。
关于如何开发自定义函数,请参考 [UDF使用说明](../../develop/udf)。
## 删除自定义函数
+```
+DROP FUNCTION function_name;
+```
+
+- function_name:此参数的含义与 CREATE 指令中的 function_name 参数一致,也即要删除的函数的名字,例如
+
+
+## 显示 UDF
+
```sql
-DROP FUNCTION func_name
-```
\ No newline at end of file
+SHOW FUNCTION;
+```
diff --git a/docs/zh/14-reference/05-taosbenchmark.md b/docs/zh/14-reference/05-taosbenchmark.md
index f4aff0169d..f84ec65b4c 100644
--- a/docs/zh/14-reference/05-taosbenchmark.md
+++ b/docs/zh/14-reference/05-taosbenchmark.md
@@ -233,11 +233,28 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\)
- **drop** : 插入前是否删除数据库,默认为 true。
+#### 流式计算相关配置参数
+
+创建流式计算的相关参数在 json 配置文件中的 `stream` 中配置,具体参数如下。
+
+- **stream_name** : 流式计算的名称,必填项。
+
+- **stream_stb** : 流式计算对应的超级表名称,必填项。
+
+- **stream_sql** : 流式计算的sql语句,必填项。
+
+- **trigger_mode** : 流式计算的触发模式,可选项。
+
+- **watermark** : 流式计算的水印,可选项。
+
+- **drop** : 是否创建流式计算,可选项为 "yes" 或者 "no", 为 "no" 时不创建。
+
#### 超级表相关配置参数
-创建超级表时的相关参数在 json 配置文件中的 `super_tables` 中配置,具体参数如下表。
+创建超级表时的相关参数在 json 配置文件中的 `super_tables` 中配置,具体参数如下。
- **name**: 超级表名,必须配置,没有默认值。
+
- **child_table_exists** : 子表是否已经存在,默认值为 "no",可选值为 "yes" 或 "no"。
- **child_table_count** : 子表的数量,默认值为 10。
@@ -288,6 +305,22 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\)
- **tags_file** : 仅当 insert_mode 为 taosc, rest 的模式下生效。 最终的 tag 的数值与 childtable_count 有关,如果 csv 文件内的 tag 数据行小于给定的子表数量,那么会循环读取 csv 文件数据直到生成 childtable_count 指定的子表数量;否则则只会读取 childtable_count 行 tag 数据。也即最终生成的子表数量为二者取小。
+#### tsma配置参数
+
+指定tsma的配置参数在 `super_tables` 中的 `tsmas` 中,具体参数如下。
+
+- **name** : 指定 tsma 的名字,必选项。
+
+- **function** : 指定 tsma 的函数,必选项。
+
+- **interval** : 指定 tsma 的时间间隔,必选项。
+
+- **sliding** : 指定 tsma 的窗口时间位移,必选项。
+
+- **custom** : 指定 tsma 的创建语句结尾追加的自定义配置,可选项。
+
+- **start_when_inserted** : 指定当插入多少行时创建 tsma,可选项,默认为 0。
+
#### 标签列与数据列配置参数
指定超级表标签列与数据列的配置参数分别在 `super_tables` 中的 `columns` 和 `tag` 中。
diff --git a/docs/zh/28-releases.md b/docs/zh/28-releases.md
new file mode 100644
index 0000000000..5f30325829
--- /dev/null
+++ b/docs/zh/28-releases.md
@@ -0,0 +1,9 @@
+---
+sidebar_label: 发布历史
+title: 发布历史
+---
+
+import Release from "/components/Release";
+
+
+
diff --git a/include/common/tcommon.h b/include/common/tcommon.h
index 4eea744be1..7d78c2dc2f 100644
--- a/include/common/tcommon.h
+++ b/include/common/tcommon.h
@@ -107,6 +107,7 @@ typedef struct SDataBlockInfo {
int32_t childId; // used for stream, do not serialize
EStreamType type; // used for stream, do not serialize
STimeWindow calWin; // used for stream, do not serialize
+ TSKEY watermark;// used for stream
} SDataBlockInfo;
typedef struct SSDataBlock {
diff --git a/include/common/tmsg.h b/include/common/tmsg.h
index bfb80ec8f8..3c3071c8df 100644
--- a/include/common/tmsg.h
+++ b/include/common/tmsg.h
@@ -1369,6 +1369,7 @@ typedef struct {
int64_t skey;
int64_t ekey;
int64_t version; // for stream
+ TSKEY watermark;// for stream
char data[];
} SRetrieveTableRsp;
@@ -3054,6 +3055,7 @@ int32_t tEncodeDeleteRes(SEncoder* pCoder, const SDeleteRes* pRes);
int32_t tDecodeDeleteRes(SDecoder* pCoder, SDeleteRes* pRes);
typedef struct {
+ int32_t msgIdx;
int32_t msgType;
int32_t msgLen;
void* msg;
@@ -3067,6 +3069,7 @@ typedef struct {
typedef struct {
int32_t reqType;
+ int32_t msgIdx;
int32_t msgLen;
int32_t rspCode;
void* msg;
diff --git a/include/libs/catalog/catalog.h b/include/libs/catalog/catalog.h
index 1d1849f24a..ee566d759a 100644
--- a/include/libs/catalog/catalog.h
+++ b/include/libs/catalog/catalog.h
@@ -58,12 +58,17 @@ typedef struct SDbInfo {
int64_t dbId;
} SDbInfo;
+typedef struct STablesReq {
+ char dbFName[TSDB_DB_FNAME_LEN];
+ SArray* pTables;
+} STablesReq;
+
typedef struct SCatalogReq {
SArray* pDbVgroup; // element is db full name
SArray* pDbCfg; // element is db full name
SArray* pDbInfo; // element is db full name
- SArray* pTableMeta; // element is SNAME
- SArray* pTableHash; // element is SNAME
+ SArray* pTableMeta; // element is STablesReq
+ SArray* pTableHash; // element is STablesReq
SArray* pUdf; // element is udf name
SArray* pIndex; // element is index name
SArray* pUser; // element is SUserAuthInfo
diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c
index 0c4dc1705c..b85d2a67ac 100644
--- a/source/client/src/clientImpl.c
+++ b/source/client/src/clientImpl.c
@@ -1308,8 +1308,8 @@ int32_t doProcessMsgFromServer(void* param) {
char tbuf[40] = {0};
TRACE_TO_STR(trace, tbuf);
- tscDebug("processMsgFromServer handle %p, message: %s, code: %s, gtid: %s", pMsg->info.handle,
- TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), tbuf);
+ tscDebug("processMsgFromServer handle %p, message: %s, size:%d, code: %s, gtid: %s", pMsg->info.handle,
+ TMSG_INFO(pMsg->msgType), pMsg->contLen, tstrerror(pMsg->code), tbuf);
if (pSendInfo->requestObjRefId != 0) {
SRequestObj* pRequest = (SRequestObj*)taosAcquireRef(clientReqRefPool, pSendInfo->requestObjRefId);
@@ -1922,7 +1922,7 @@ _OVER:
return code;
}
-int32_t appendTbToReq(SArray* pList, int32_t pos1, int32_t len1, int32_t pos2, int32_t len2, const char* str,
+int32_t appendTbToReq(SHashObj* pHash, int32_t pos1, int32_t len1, int32_t pos2, int32_t len2, const char* str,
int32_t acctId, char* db) {
SName name;
@@ -1957,20 +1957,33 @@ int32_t appendTbToReq(SArray* pList, int32_t pos1, int32_t len1, int32_t pos2, i
return -1;
}
- taosArrayPush(pList, &name);
+ char dbFName[TSDB_DB_FNAME_LEN];
+ sprintf(dbFName, "%d.%.*s", acctId, dbLen, dbName);
+
+ STablesReq* pDb = taosHashGet(pHash, dbFName, strlen(dbFName));
+ if (pDb) {
+ taosArrayPush(pDb->pTables, &name);
+ } else {
+ STablesReq db;
+ db.pTables = taosArrayInit(20, sizeof(SName));
+ strcpy(db.dbFName, dbFName);
+ taosArrayPush(db.pTables, &name);
+ taosHashPut(pHash, dbFName, strlen(dbFName), &db, sizeof(db));
+ }
return TSDB_CODE_SUCCESS;
}
int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, SArray** pReq) {
- *pReq = taosArrayInit(10, sizeof(SName));
- if (NULL == *pReq) {
+ SHashObj* pHash = taosHashInit(3, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
+ if (NULL == pHash) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
bool inEscape = false;
int32_t code = 0;
+ void *pIter = NULL;
int32_t vIdx = 0;
int32_t vPos[2];
@@ -1985,7 +1998,7 @@ int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName,
vLen[vIdx] = i - vPos[vIdx];
}
- code = appendTbToReq(*pReq, vPos[0], vLen[0], vPos[1], vLen[1], tbList, acctId, dbName);
+ code = appendTbToReq(pHash, vPos[0], vLen[0], vPos[1], vLen[1], tbList, acctId, dbName);
if (code) {
goto _return;
}
@@ -2035,7 +2048,7 @@ int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName,
vLen[vIdx] = i - vPos[vIdx];
}
- code = appendTbToReq(*pReq, vPos[0], vLen[0], vPos[1], vLen[1], tbList, acctId, dbName);
+ code = appendTbToReq(pHash, vPos[0], vLen[0], vPos[1], vLen[1], tbList, acctId, dbName);
if (code) {
goto _return;
}
@@ -2067,14 +2080,31 @@ int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName,
goto _return;
}
+ int32_t dbNum = taosHashGetSize(pHash);
+ *pReq = taosArrayInit(dbNum, sizeof(STablesReq));
+ pIter = taosHashIterate(pHash, NULL);
+ while (pIter) {
+ STablesReq* pDb = (STablesReq*)pIter;
+ taosArrayPush(*pReq, pDb);
+ pIter = taosHashIterate(pHash, pIter);
+ }
+
+ taosHashCleanup(pHash);
+
return TSDB_CODE_SUCCESS;
_return:
terrno = TSDB_CODE_TSC_INVALID_OPERATION;
- taosArrayDestroy(*pReq);
- *pReq = NULL;
+ pIter = taosHashIterate(pHash, NULL);
+ while (pIter) {
+ STablesReq* pDb = (STablesReq*)pIter;
+ taosArrayDestroy(pDb->pTables);
+ pIter = taosHashIterate(pHash, pIter);
+ }
+
+ taosHashCleanup(pHash);
return terrno;
}
diff --git a/source/common/src/systable.c b/source/common/src/systable.c
index 29d7b557c8..675d3bbfdd 100644
--- a/source/common/src/systable.c
+++ b/source/common/src/systable.c
@@ -308,9 +308,9 @@ static const SSysDbTableSchema offsetSchema[] = {
};
static const SSysDbTableSchema querySchema[] = {
- {.name = "query_id", .bytes = TSDB_QUERY_ID_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
- {.name = "req_id", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT},
- {.name = "connId", .bytes = 4, .type = TSDB_DATA_TYPE_UINT},
+ {.name = "kill_id", .bytes = TSDB_QUERY_ID_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
+ {.name = "query_id", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT},
+ {.name = "conn_id", .bytes = 4, .type = TSDB_DATA_TYPE_UINT},
{.name = "app", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c
index 51c21eafa9..302874962e 100644
--- a/source/common/src/tdatablock.c
+++ b/source/common/src/tdatablock.c
@@ -1272,8 +1272,7 @@ int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src) {
colDataAssign(pDst, pSrc, src->info.rows, &src->info);
}
- dst->info.rows = src->info.rows;
- dst->info.capacity = src->info.rows;
+ dst->info = src->info;
return 0;
}
diff --git a/source/dnode/mnode/impl/src/mndQuery.c b/source/dnode/mnode/impl/src/mndQuery.c
index 2beeb10335..654f46ec85 100644
--- a/source/dnode/mnode/impl/src/mndQuery.c
+++ b/source/dnode/mnode/impl/src/mndQuery.c
@@ -84,6 +84,9 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
}
for (int32_t i = 0; i < msgNum; ++i) {
+ req.msgIdx = ntohl(*(int32_t*)((char*)pMsg->pCont + offset));
+ offset += sizeof(req.msgIdx);
+
req.msgType = ntohl(*(int32_t*)((char*)pMsg->pCont + offset));
offset += sizeof(req.msgType);
@@ -111,6 +114,7 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
} else {
rsp.rspCode = 0;
}
+ rsp.msgIdx = req.msgIdx;
rsp.reqType = reqMsg.msgType;
rsp.msgLen = reqMsg.info.rspLen;
rsp.msg = reqMsg.info.rsp;
@@ -136,6 +140,8 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
*(int32_t*)((char*)pRsp + offset) = htonl(p->reqType);
offset += sizeof(p->reqType);
+ *(int32_t*)((char*)pRsp + offset) = htonl(p->msgIdx);
+ offset += sizeof(p->msgIdx);
*(int32_t*)((char*)pRsp + offset) = htonl(p->msgLen);
offset += sizeof(p->msgLen);
*(int32_t*)((char*)pRsp + offset) = htonl(p->rspCode);
diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c
index 650c98eb88..460d0b6fbb 100644
--- a/source/dnode/vnode/src/vnd/vnodeCommit.c
+++ b/source/dnode/vnode/src/vnd/vnodeCommit.c
@@ -223,6 +223,8 @@ int vnodeCommit(SVnode *pVnode) {
vnodeBufPoolUnRef(pVnode->inUse);
pVnode->inUse = NULL;
+ pVnode->state.commitTerm = pVnode->state.applyTerm;
+
// save info
info.config = pVnode->config;
info.state.committed = pVnode->state.applied;
diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c
index d18ba88268..707c4bc471 100644
--- a/source/dnode/vnode/src/vnd/vnodeQuery.c
+++ b/source/dnode/vnode/src/vnd/vnodeQuery.c
@@ -273,6 +273,9 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
}
for (int32_t i = 0; i < msgNum; ++i) {
+ req.msgIdx = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
+ offset += sizeof(req.msgIdx);
+
req.msgType = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
offset += sizeof(req.msgType);
@@ -301,6 +304,7 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
break;
}
+ rsp.msgIdx = req.msgIdx;
rsp.reqType = reqMsg.msgType;
rsp.msgLen = reqMsg.contLen;
rsp.rspCode = reqMsg.code;
@@ -327,6 +331,8 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
*(int32_t *)((char *)pRsp + offset) = htonl(p->reqType);
offset += sizeof(p->reqType);
+ *(int32_t *)((char *)pRsp + offset) = htonl(p->msgIdx);
+ offset += sizeof(p->msgIdx);
*(int32_t *)((char *)pRsp + offset) = htonl(p->msgLen);
offset += sizeof(p->msgLen);
*(int32_t *)((char *)pRsp + offset) = htonl(p->rspCode);
diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c
index 1586143319..a269f81ddd 100644
--- a/source/dnode/vnode/src/vnd/vnodeSync.c
+++ b/source/dnode/vnode/src/vnd/vnodeSync.c
@@ -708,8 +708,8 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
}
setPingTimerMS(pVnode->sync, 5000);
- setElectTimerMS(pVnode->sync, 2800);
- setHeartbeatTimerMS(pVnode->sync, 900);
+ setElectTimerMS(pVnode->sync, 4000);
+ setHeartbeatTimerMS(pVnode->sync, 700);
return 0;
}
diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h
index 816309beb1..4ef23860cd 100644
--- a/source/libs/catalog/inc/catalogInt.h
+++ b/source/libs/catalog/inc/catalogInt.h
@@ -32,6 +32,7 @@ extern "C" {
#define CTG_DEFAULT_RENT_SLOT_SIZE 10
#define CTG_DEFAULT_MAX_RETRY_TIMES 3
#define CTG_DEFAULT_BATCH_NUM 64
+#define CTG_DEFAULT_FETCH_NUM 8
#define CTG_RENT_SLOT_SECOND 1.5
@@ -80,6 +81,8 @@ typedef enum {
CTG_TASK_GET_UDF,
CTG_TASK_GET_USER,
CTG_TASK_GET_SVR_VER,
+ CTG_TASK_GET_TB_META_BATCH,
+ CTG_TASK_GET_TB_HASH_BATCH,
} CTG_TASK_TYPE;
typedef enum {
@@ -110,6 +113,23 @@ typedef struct SCtgTbMetaCtx {
int32_t flag;
} SCtgTbMetaCtx;
+typedef struct SCtgFetch {
+ int32_t dbIdx;
+ int32_t tbIdx;
+ int32_t fetchIdx;
+ int32_t resIdx;
+ int32_t flag;
+ SCtgTbCacheInfo tbInfo;
+ int32_t vgId;
+} SCtgFetch;
+
+typedef struct SCtgTbMetasCtx {
+ int32_t fetchNum;
+ SArray* pNames;
+ SArray* pResList;
+ SArray* pFetchs;
+} SCtgTbMetasCtx;
+
typedef struct SCtgTbIndexCtx {
SName* pName;
} SCtgTbIndexCtx;
@@ -137,6 +157,14 @@ typedef struct SCtgTbHashCtx {
SName* pName;
} SCtgTbHashCtx;
+typedef struct SCtgTbHashsCtx {
+ int32_t fetchNum;
+ SArray* pNames;
+ SArray* pResList;
+ SArray* pFetchs;
+} SCtgTbHashsCtx;
+
+
typedef struct SCtgIndexCtx {
char indexFName[TSDB_INDEX_FNAME_LEN];
} SCtgIndexCtx;
@@ -211,6 +239,7 @@ typedef struct SCtgBatch {
SRequestConnInfo conn;
char dbFName[TSDB_DB_FNAME_LEN];
SArray* pTaskIds;
+ SArray* pMsgIdxs;
} SCtgBatch;
typedef struct SCtgJob {
@@ -218,6 +247,7 @@ typedef struct SCtgJob {
int32_t batchId;
SHashObj* pBatchs;
SArray* pTasks;
+ int32_t subTaskNum;
int32_t taskDone;
SMetaData jobRes;
int32_t jobResCode;
@@ -258,6 +288,7 @@ typedef struct SCtgTaskCallbackParam {
SArray* taskId;
int32_t reqType;
int32_t batchId;
+ SArray* msgIdx;
} SCtgTaskCallbackParam;
@@ -276,6 +307,7 @@ typedef struct SCtgTask {
int32_t taskId;
SCtgJob* pJob;
void* taskCtx;
+ SArray* msgCtxs;
SCtgMsgCtx msgCtx;
int32_t code;
void* res;
@@ -286,9 +318,14 @@ typedef struct SCtgTask {
SHashObj* pBatchs;
} SCtgTask;
+typedef struct SCtgTaskReq {
+ SCtgTask* pTask;
+ int32_t msgIdx;
+} SCtgTaskReq;
+
typedef int32_t (*ctgInitTaskFp)(SCtgJob*, int32_t, void*);
typedef int32_t (*ctgLanchTaskFp)(SCtgTask*);
-typedef int32_t (*ctgHandleTaskMsgRspFp)(SCtgTask*, int32_t, const SDataBuf *, int32_t);
+typedef int32_t (*ctgHandleTaskMsgRspFp)(SCtgTaskReq*, int32_t, const SDataBuf *, int32_t);
typedef int32_t (*ctgDumpTaskResFp)(SCtgTask*);
typedef int32_t (*ctgCloneTaskResFp)(SCtgTask*, void**);
typedef int32_t (*ctgCompTaskFp)(SCtgTask*, void*, bool*);
@@ -487,6 +524,8 @@ typedef struct SCtgOperation {
#define CTG_FLAG_MAKE_STB(_isStb) (((_isStb) == 1) ? CTG_FLAG_STB : ((_isStb) == 0 ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB))
#define CTG_FLAG_MATCH_STB(_flag, tbType) (CTG_FLAG_IS_UNKNOWN_STB(_flag) || (CTG_FLAG_IS_STB(_flag) && (tbType) == TSDB_SUPER_TABLE) || (CTG_FLAG_IS_NOT_STB(_flag) && (tbType) != TSDB_SUPER_TABLE))
+#define CTG_GET_TASK_MSGCTX(_task, _id) (((CTG_TASK_GET_TB_META_BATCH == (_task)->type) || (CTG_TASK_GET_TB_HASH_BATCH == (_task)->type)) ? taosArrayGet((_task)->msgCtxs, (_id)) : &(_task)->msgCtx)
+
#define CTG_META_SIZE(pMeta) (sizeof(STableMeta) + ((pMeta)->tableInfo.numOfTags + (pMeta)->tableInfo.numOfColumns) * sizeof(SSchema))
#define CTG_TABLE_NOT_EXIST(code) (code == CTG_ERR_CODE_TABLE_NOT_EXIST)
@@ -586,6 +625,7 @@ int32_t ctgdShowCacheInfo(void);
int32_t ctgRemoveTbMetaFromCache(SCatalog* pCtg, SName* pTableName, bool syncReq);
int32_t ctgGetTbMetaFromCache(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta);
+int32_t ctgGetTbMetasFromCache(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetasCtx* ctx, int32_t dbIdx, int32_t *fetchIdx, int32_t baseResIdx, SArray* pList);
int32_t ctgOpUpdateVgroup(SCtgCacheOperation *action);
int32_t ctgOpUpdateTbMeta(SCtgCacheOperation *action);
@@ -631,7 +671,7 @@ int32_t ctgGetTbHashVgroupFromCache(SCatalog *pCtg, const SName *pTableName, SVg
int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize, int32_t rspCode, char* target);
-int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SBuildUseDBInput *input, SUseDbOutput *out, SCtgTask* pTask);
+int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SBuildUseDBInput *input, SUseDbOutput *out, SCtgTaskReq* tReq);
int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray *out, SCtgTask* pTask);
int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray **out, SCtgTask* pTask);
int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *dbFName, SDbCfgInfo *out, SCtgTask* pTask);
@@ -639,9 +679,9 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const
int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName *name, STableIndex* out, SCtgTask* pTask);
int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *funcName, SFuncInfo *out, SCtgTask* pTask);
int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *user, SGetUserAuthRsp *out, SCtgTask* pTask);
-int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo *pConn, char *dbFName, char* tbName, STableMetaOutput* out, SCtgTask* pTask);
-int32_t ctgGetTbMetaFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableMetaOutput* out, SCtgTask* pTask);
-int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableMetaOutput* out, SCtgTask* pTask);
+int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo *pConn, char *dbFName, char* tbName, STableMetaOutput* out, SCtgTaskReq* tReq);
+int32_t ctgGetTbMetaFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableMetaOutput* out, SCtgTaskReq* tReq);
+int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableMetaOutput* out, SCtgTaskReq* tReq);
int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableCfg **out, SCtgTask* pTask);
int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg **out, SCtgTask* pTask);
int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, char **out, SCtgTask* pTask);
@@ -664,6 +704,7 @@ void ctgFreeJob(void* job);
void ctgFreeHandleImpl(SCatalog* pCtg);
void ctgFreeVgInfo(SDBVgInfo *vgInfo);
int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName *pTableName, SVgroupInfo *pVgroup);
+int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo *dbInfo, SCtgTbHashsCtx *pCtx, char* dbFName, SArray* pNames, bool update);
void ctgResetTbMetaTask(SCtgTask* pTask);
void ctgFreeDbCache(SCtgDBCache *dbCache);
int32_t ctgStbVersionSortCompare(const void* key1, const void* key2);
@@ -672,8 +713,11 @@ int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2);
int32_t ctgDbVgVersionSearchCompare(const void* key1, const void* key2);
void ctgFreeSTableMetaOutput(STableMetaOutput* pOutput);
int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* target);
+int32_t ctgAddMsgCtx(SArray* pCtxs, int32_t reqType, void* out, char* target);
char * ctgTaskTypeStr(CTG_TASK_TYPE type);
int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, char* dbFName, int32_t vgId);
+int32_t ctgGetTablesReqNum(SArray *pList);
+int32_t ctgAddFetch(SArray** pFetchs, int32_t dbIdx, int32_t tbIdx, int32_t *fetchIdx, int32_t resIdx, int32_t flag);
int32_t ctgCloneTableIndex(SArray* pIndex, SArray** pRes);
void ctgFreeSTableIndex(void *info);
void ctgClearSubTaskRes(SCtgSubRes *pRes);
@@ -682,6 +726,7 @@ void ctgClearHandle(SCatalog* pCtg);
void ctgFreeTbCacheImpl(SCtgTbCache *pCache);
int32_t ctgRemoveTbMeta(SCatalog* pCtg, SName* pTableName);
int32_t ctgGetTbHashVgroup(SCatalog *pCtg, SRequestConnInfo *pConn, const SName *pTableName, SVgroupInfo *pVgroup);
+SName* ctgGetFetchName(SArray* pNames, SCtgFetch* pFetch);
extern SCatalogMgmt gCtgMgmt;
diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c
index 0184ac3a60..63d99cc58b 100644
--- a/source/libs/catalog/src/ctgAsync.c
+++ b/source/libs/catalog/src/ctgAsync.c
@@ -50,6 +50,31 @@ int32_t ctgInitGetTbMetaTask(SCtgJob *pJob, int32_t taskIdx, void* param) {
return TSDB_CODE_SUCCESS;
}
+int32_t ctgInitGetTbMetasTask(SCtgJob *pJob, int32_t taskIdx, void* param) {
+ SName *name = (SName*)param;
+ SCtgTask task = {0};
+
+ task.type = CTG_TASK_GET_TB_META_BATCH;
+ task.taskId = taskIdx;
+ task.pJob = pJob;
+
+ task.taskCtx = taosMemoryCalloc(1, sizeof(SCtgTbMetasCtx));
+ if (NULL == task.taskCtx) {
+ CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
+ }
+
+ SCtgTbMetasCtx* ctx = task.taskCtx;
+ ctx->pNames = param;
+ ctx->pResList = taosArrayInit(pJob->tbMetaNum, sizeof(SMetaRes));
+
+ taosArrayPush(pJob->pTasks, &task);
+
+ qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbNum:%d, tbNum:%d",
+ pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), taosArrayGetSize(ctx->pNames), pJob->tbMetaNum);
+
+ return TSDB_CODE_SUCCESS;
+}
+
int32_t ctgInitGetDbVgTask(SCtgJob *pJob, int32_t taskIdx, void* param) {
char *dbFName = (char*)param;
SCtgTask task = {0};
@@ -153,6 +178,32 @@ int32_t ctgInitGetTbHashTask(SCtgJob *pJob, int32_t taskIdx, void* param) {
return TSDB_CODE_SUCCESS;
}
+int32_t ctgInitGetTbHashsTask(SCtgJob *pJob, int32_t taskIdx, void* param) {
+ SName *name = (SName*)param;
+ SCtgTask task = {0};
+
+ task.type = CTG_TASK_GET_TB_HASH_BATCH;
+ task.taskId = taskIdx;
+ task.pJob = pJob;
+
+ task.taskCtx = taosMemoryCalloc(1, sizeof(SCtgTbHashsCtx));
+ if (NULL == task.taskCtx) {
+ CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
+ }
+
+ SCtgTbHashsCtx* ctx = task.taskCtx;
+ ctx->pNames = param;
+ ctx->pResList = taosArrayInit(pJob->tbHashNum, sizeof(SMetaRes));
+
+ taosArrayPush(pJob->pTasks, &task);
+
+ qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbNum:%d, tbNum:%d",
+ pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), taosArrayGetSize(ctx->pNames), pJob->tbHashNum);
+
+ return TSDB_CODE_SUCCESS;
+}
+
+
int32_t ctgInitGetQnodeTask(SCtgJob *pJob, int32_t taskIdx, void* param) {
SCtgTask task = {0};
@@ -328,10 +379,12 @@ int32_t ctgInitGetTbCfgTask(SCtgJob *pJob, int32_t taskIdx, void* param) {
}
-
int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob *pJob, const SCatalogReq* pReq) {
SHashObj* pDb = taosHashInit(taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
- if (NULL == pDb) {
+ SHashObj* pTb = taosHashInit(taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
+ if (NULL == pDb || NULL == pTb) {
+ taosHashCleanup(pDb);
+ taosHashCleanup(pTb);
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
}
@@ -350,18 +403,26 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob *pJob, con
taosHashPut(pDb, dbFName, strlen(dbFName), dbFName, TSDB_DB_FNAME_LEN);
}
- for (int32_t i = 0; i < pJob->tbMetaNum; ++i) {
- SName* name = taosArrayGet(pReq->pTableMeta, i);
- char dbFName[TSDB_DB_FNAME_LEN];
- tNameGetFullDbName(name, dbFName);
- taosHashPut(pDb, dbFName, strlen(dbFName), dbFName, TSDB_DB_FNAME_LEN);
+ int32_t dbNum = taosArrayGetSize(pReq->pTableMeta);
+ for (int32_t i = 0; i < dbNum; ++i) {
+ STablesReq* p = taosArrayGet(pReq->pTableMeta, i);
+ taosHashPut(pDb, p->dbFName, strlen(p->dbFName), p->dbFName, TSDB_DB_FNAME_LEN);
+ int32_t tbNum = taosArrayGetSize(p->pTables);
+ for (int32_t m = 0; m < tbNum; ++m) {
+ SName* name = taosArrayGet(p->pTables, m);
+ taosHashPut(pTb, name, sizeof(SName), name, sizeof(SName));
+ }
}
-
- for (int32_t i = 0; i < pJob->tbHashNum; ++i) {
- SName* name = taosArrayGet(pReq->pTableHash, i);
- char dbFName[TSDB_DB_FNAME_LEN];
- tNameGetFullDbName(name, dbFName);
- taosHashPut(pDb, dbFName, strlen(dbFName), dbFName, TSDB_DB_FNAME_LEN);
+
+ dbNum = taosArrayGetSize(pReq->pTableHash);
+ for (int32_t i = 0; i < dbNum; ++i) {
+ STablesReq* p = taosArrayGet(pReq->pTableHash, i);
+ taosHashPut(pDb, p->dbFName, strlen(p->dbFName), p->dbFName, TSDB_DB_FNAME_LEN);
+ int32_t tbNum = taosArrayGetSize(p->pTables);
+ for (int32_t m = 0; m < tbNum; ++m) {
+ SName* name = taosArrayGet(p->pTables, m);
+ taosHashPut(pTb, name, sizeof(SName), name, sizeof(SName));
+ }
}
for (int32_t i = 0; i < pJob->tbCfgNum; ++i) {
@@ -380,16 +441,6 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob *pJob, con
taosHashCleanup(pDb);
// REFRESH TABLE META
- SHashObj* pTb = taosHashInit(taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
- for (int32_t i = 0; i < pJob->tbMetaNum; ++i) {
- SName* name = taosArrayGet(pReq->pTableMeta, i);
- taosHashPut(pTb, name, sizeof(SName), name, sizeof(SName));
- }
-
- for (int32_t i = 0; i < pJob->tbHashNum; ++i) {
- SName* name = taosArrayGet(pReq->pTableHash, i);
- taosHashPut(pTb, name, sizeof(SName), name, sizeof(SName));
- }
for (int32_t i = 0; i < pJob->tbCfgNum; ++i) {
SName* name = taosArrayGet(pReq->pTableCfg, i);
@@ -429,9 +480,9 @@ int32_t ctgInitTask(SCtgJob *pJob, CTG_TASK_TYPE type, void* param, int32_t *tas
int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp, void* param) {
int32_t code = 0;
- int32_t tbMetaNum = (int32_t)taosArrayGetSize(pReq->pTableMeta);
+ int32_t tbMetaNum = (int32_t)ctgGetTablesReqNum(pReq->pTableMeta);
int32_t dbVgNum = (int32_t)taosArrayGetSize(pReq->pDbVgroup);
- int32_t tbHashNum = (int32_t)taosArrayGetSize(pReq->pTableHash);
+ int32_t tbHashNum = (int32_t)ctgGetTablesReqNum(pReq->pTableHash);
int32_t udfNum = (int32_t)taosArrayGetSize(pReq->pUdf);
int32_t qnodeNum = pReq->qNodeRequired ? 1 : 0;
int32_t dnodeNum = pReq->dNodeRequired ? 1 : 0;
@@ -452,7 +503,8 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const
}
SCtgJob *pJob = *job;
-
+
+ pJob->subTaskNum = taskNum;
pJob->queryId = pConn->requestId;
pJob->userFp = fp;
pJob->pCtg = pCtg;
@@ -506,15 +558,27 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const
CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_DB_INFO, dbFName, NULL));
}
+#if 0
for (int32_t i = 0; i < tbMetaNum; ++i) {
SName* name = taosArrayGet(pReq->pTableMeta, i);
CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_TB_META, name, NULL));
}
+#else
+ if (tbMetaNum > 0) {
+ CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_TB_META_BATCH, pReq->pTableMeta, NULL));
+ }
+#endif
+#if 0
for (int32_t i = 0; i < tbHashNum; ++i) {
SName* name = taosArrayGet(pReq->pTableHash, i);
CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_TB_HASH, name, NULL));
}
+#else
+ if (tbHashNum > 0) {
+ CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_TB_HASH_BATCH, pReq->pTableHash, NULL));
+ }
+#endif
for (int32_t i = 0; i < tbIndexNum; ++i) {
SName* name = taosArrayGet(pReq->pTableIndex, i);
@@ -586,6 +650,15 @@ int32_t ctgDumpTbMetaRes(SCtgTask* pTask) {
return TSDB_CODE_SUCCESS;
}
+int32_t ctgDumpTbMetasRes(SCtgTask* pTask) {
+ SCtgJob* pJob = pTask->pJob;
+
+ pJob->jobRes.pTableMeta = pTask->res;
+
+ return TSDB_CODE_SUCCESS;
+}
+
+
int32_t ctgDumpDbVgRes(SCtgTask* pTask) {
SCtgJob* pJob = pTask->pJob;
if (NULL == pJob->jobRes.pDbVgroup) {
@@ -616,6 +689,14 @@ int32_t ctgDumpTbHashRes(SCtgTask* pTask) {
return TSDB_CODE_SUCCESS;
}
+int32_t ctgDumpTbHashsRes(SCtgTask* pTask) {
+ SCtgJob* pJob = pTask->pJob;
+
+ pJob->jobRes.pTableHash = pTask->res;
+
+ return TSDB_CODE_SUCCESS;
+}
+
int32_t ctgDumpTbIndexRes(SCtgTask* pTask) {
SCtgJob* pJob = pTask->pJob;
if (NULL == pJob->jobRes.pTableIndex) {
@@ -844,46 +925,51 @@ _return:
CTG_RET(code);
}
-int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
+int32_t ctgHandleGetTbMetaRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
int32_t code = 0;
SCtgDBCache *dbCache = NULL;
- SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
+ SCtgTask* pTask = tReq->pTask;
SCatalog* pCtg = pTask->pJob->pCtg;
SRequestConnInfo* pConn = &pTask->pJob->conn;
+ SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx);
+ SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
+ SName* pName = ctx->pName;
+ int32_t flag = ctx->flag;
+ int32_t* vgId = &ctx->vgId;
- CTG_ERR_JRET(ctgProcessRspMsg(pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target));
+ CTG_ERR_JRET(ctgProcessRspMsg(pMsgCtx->out, reqType, pMsg->pData, pMsg->len, rspCode, pMsgCtx->target));
switch (reqType) {
case TDMT_MND_USE_DB: {
- SUseDbOutput* pOut = (SUseDbOutput*)pTask->msgCtx.out;
+ SUseDbOutput* pOut = (SUseDbOutput*)pMsgCtx->out;
SVgroupInfo vgInfo = {0};
- CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, pOut->dbVgroup, ctx->pName, &vgInfo));
+ CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, pOut->dbVgroup, pName, &vgInfo));
- ctgDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(ctx->pName), ctx->flag);
+ ctgDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(pName), flag);
- ctx->vgId = vgInfo.vgId;
- CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, ctx->pName, &vgInfo, NULL, pTask));
+ *vgId = vgInfo.vgId;
+ CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, pName, &vgInfo, NULL, tReq));
return TSDB_CODE_SUCCESS;
}
case TDMT_MND_TABLE_META: {
- STableMetaOutput* pOut = (STableMetaOutput*)pTask->msgCtx.out;
+ STableMetaOutput* pOut = (STableMetaOutput*)pMsgCtx->out;
if (CTG_IS_META_NULL(pOut->metaType)) {
- if (CTG_FLAG_IS_STB(ctx->flag)) {
+ if (CTG_FLAG_IS_STB(flag)) {
char dbFName[TSDB_DB_FNAME_LEN] = {0};
- tNameGetFullDbName(ctx->pName, dbFName);
+ tNameGetFullDbName(pName, dbFName);
CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, dbFName, &dbCache));
if (NULL != dbCache) {
SVgroupInfo vgInfo = {0};
- CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, ctx->pName, &vgInfo));
+ CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, pName, &vgInfo));
- ctgDebug("will refresh tbmeta, supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(ctx->pName), ctx->flag);
+ ctgDebug("will refresh tbmeta, supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(pName), flag);
- ctx->vgId = vgInfo.vgId;
- CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, ctx->pName, &vgInfo, NULL, pTask));
+ *vgId = vgInfo.vgId;
+ CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, pName, &vgInfo, NULL, tReq));
ctgReleaseVgInfoToCache(pCtg, dbCache);
} else {
@@ -892,58 +978,64 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *
tstrncpy(input.db, dbFName, tListLen(input.db));
input.vgVersion = CTG_DEFAULT_INVALID_VERSION;
- CTG_ERR_JRET(ctgGetDBVgInfoFromMnode(pCtg, pConn, &input, NULL, pTask));
+ CTG_ERR_JRET(ctgGetDBVgInfoFromMnode(pCtg, pConn, &input, NULL, tReq));
}
return TSDB_CODE_SUCCESS;
}
- ctgError("no tbmeta got, tbName:%s", tNameGetTableName(ctx->pName));
- ctgRemoveTbMetaFromCache(pCtg, ctx->pName, false);
+ ctgError("no tbmeta got, tbName:%s", tNameGetTableName(pName));
+ ctgRemoveTbMetaFromCache(pCtg, pName, false);
CTG_ERR_JRET(CTG_ERR_CODE_TABLE_NOT_EXIST);
}
- if (pTask->msgCtx.lastOut) {
- TSWAP(pTask->msgCtx.out, pTask->msgCtx.lastOut);
- STableMetaOutput* pLastOut = (STableMetaOutput*)pTask->msgCtx.out;
+ if (pMsgCtx->lastOut) {
+ TSWAP(pMsgCtx->out, pMsgCtx->lastOut);
+ STableMetaOutput* pLastOut = (STableMetaOutput*)pMsgCtx->out;
TSWAP(pLastOut->tbMeta, pOut->tbMeta);
}
break;
}
case TDMT_VND_TABLE_META: {
- STableMetaOutput* pOut = (STableMetaOutput*)pTask->msgCtx.out;
+ STableMetaOutput* pOut = (STableMetaOutput*)pMsgCtx->out;
if (CTG_IS_META_NULL(pOut->metaType)) {
- ctgError("no tbmeta got, tbNmae:%s", tNameGetTableName(ctx->pName));
- ctgRemoveTbMetaFromCache(pCtg, ctx->pName, false);
+ ctgError("no tbmeta got, tbNmae:%s", tNameGetTableName(pName));
+ ctgRemoveTbMetaFromCache(pCtg, pName, false);
CTG_ERR_JRET(CTG_ERR_CODE_TABLE_NOT_EXIST);
}
- if (CTG_FLAG_IS_STB(ctx->flag)) {
+ if (CTG_FLAG_IS_STB(flag)) {
break;
}
if (CTG_IS_META_TABLE(pOut->metaType) && TSDB_SUPER_TABLE == pOut->tbMeta->tableType) {
- ctgDebug("will continue to refresh tbmeta since got stb, tbName:%s", tNameGetTableName(ctx->pName));
+ ctgDebug("will continue to refresh tbmeta since got stb, tbName:%s", tNameGetTableName(pName));
taosMemoryFreeClear(pOut->tbMeta);
- CTG_RET(ctgGetTbMetaFromMnode(pCtg, pConn, ctx->pName, NULL, pTask));
+ CTG_RET(ctgGetTbMetaFromMnode(pCtg, pConn, pName, NULL, tReq));
} else if (CTG_IS_META_BOTH(pOut->metaType)) {
int32_t exist = 0;
- if (!CTG_FLAG_IS_FORCE_UPDATE(ctx->flag)) {
- CTG_ERR_JRET(ctgTbMetaExistInCache(pCtg, pOut->dbFName, pOut->tbName, &exist));
+ if (!CTG_FLAG_IS_FORCE_UPDATE(flag)) {
+ SName stbName = *pName;
+ strcpy(stbName.tname, pOut->tbName);
+ SCtgTbMetaCtx stbCtx = {0};
+ stbCtx.flag = flag;
+ stbCtx.pName = &stbName;
+
+ taosMemoryFreeClear(pOut->tbMeta);
+ CTG_ERR_JRET(ctgReadTbMetaFromCache(pCtg, &stbCtx, &pOut->tbMeta));
+ if (pOut->tbMeta) {
+ exist = 1;
+ }
}
if (0 == exist) {
- TSWAP(pTask->msgCtx.lastOut, pTask->msgCtx.out);
- CTG_RET(ctgGetTbMetaFromMnodeImpl(pCtg, pConn, pOut->dbFName, pOut->tbName, NULL, pTask));
- } else {
- taosMemoryFreeClear(pOut->tbMeta);
-
- SET_META_TYPE_CTABLE(pOut->metaType);
+ TSWAP(pMsgCtx->lastOut, pMsgCtx->out);
+ CTG_RET(ctgGetTbMetaFromMnodeImpl(pCtg, pConn, pOut->dbFName, pOut->tbName, NULL, tReq));
}
}
break;
@@ -954,17 +1046,20 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *
break;
}
- STableMetaOutput* pOut = (STableMetaOutput*)pTask->msgCtx.out;
+ STableMetaOutput* pOut = (STableMetaOutput*)pMsgCtx->out;
ctgUpdateTbMetaToCache(pCtg, pOut, false);
if (CTG_IS_META_BOTH(pOut->metaType)) {
memcpy(pOut->tbMeta, &pOut->ctbMeta, sizeof(pOut->ctbMeta));
- } else if (CTG_IS_META_CTABLE(pOut->metaType)) {
- SName stbName = *ctx->pName;
+ }
+
+/*
+ else if (CTG_IS_META_CTABLE(pOut->metaType)) {
+ SName stbName = *pName;
strcpy(stbName.tname, pOut->tbName);
SCtgTbMetaCtx stbCtx = {0};
- stbCtx.flag = ctx->flag;
+ stbCtx.flag = flag;
stbCtx.pName = &stbName;
CTG_ERR_JRET(ctgReadTbMetaFromCache(pCtg, &stbCtx, &pOut->tbMeta));
@@ -977,6 +1072,7 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *
memcpy(pOut->tbMeta, &pOut->ctbMeta, sizeof(pOut->ctbMeta));
}
+*/
TSWAP(pTask->res, pOut->tbMeta);
@@ -986,13 +1082,199 @@ _return:
ctgReleaseVgInfoToCache(pCtg, dbCache);
}
- ctgHandleTaskEnd(pTask, code);
-
+ if (pTask->res) {
+ ctgHandleTaskEnd(pTask, code);
+ }
+
CTG_RET(code);
}
-int32_t ctgHandleGetDbVgRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
+
+int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
int32_t code = 0;
+ SCtgDBCache *dbCache = NULL;
+ SCtgTask* pTask = tReq->pTask;
+ SCatalog* pCtg = pTask->pJob->pCtg;
+ SRequestConnInfo* pConn = &pTask->pJob->conn;
+ SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx);
+ SCtgTbMetasCtx* ctx = (SCtgTbMetasCtx*)pTask->taskCtx;
+ SCtgFetch* pFetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx);
+ SName* pName = ctgGetFetchName(ctx->pNames, pFetch);
+ int32_t flag = pFetch->flag;
+ int32_t* vgId = &pFetch->vgId;
+
+ CTG_ERR_JRET(ctgProcessRspMsg(pMsgCtx->out, reqType, pMsg->pData, pMsg->len, rspCode, pMsgCtx->target));
+
+ switch (reqType) {
+ case TDMT_MND_USE_DB: {
+ SUseDbOutput* pOut = (SUseDbOutput*)pMsgCtx->out;
+
+ SVgroupInfo vgInfo = {0};
+ CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, pOut->dbVgroup, pName, &vgInfo));
+
+ ctgDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(pName), flag);
+
+ *vgId = vgInfo.vgId;
+ CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, pName, &vgInfo, NULL, tReq));
+
+ return TSDB_CODE_SUCCESS;
+ }
+ case TDMT_MND_TABLE_META: {
+ STableMetaOutput* pOut = (STableMetaOutput*)pMsgCtx->out;
+
+ if (CTG_IS_META_NULL(pOut->metaType)) {
+ if (CTG_FLAG_IS_STB(flag)) {
+ char dbFName[TSDB_DB_FNAME_LEN] = {0};
+ tNameGetFullDbName(pName, dbFName);
+
+ CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, dbFName, &dbCache));
+ if (NULL != dbCache) {
+ SVgroupInfo vgInfo = {0};
+ CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, pName, &vgInfo));
+
+ ctgDebug("will refresh tbmeta, supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(pName), flag);
+
+ *vgId = vgInfo.vgId;
+ CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, pName, &vgInfo, NULL, tReq));
+
+ ctgReleaseVgInfoToCache(pCtg, dbCache);
+ } else {
+ SBuildUseDBInput input = {0};
+
+ tstrncpy(input.db, dbFName, tListLen(input.db));
+ input.vgVersion = CTG_DEFAULT_INVALID_VERSION;
+
+ CTG_ERR_JRET(ctgGetDBVgInfoFromMnode(pCtg, pConn, &input, NULL, tReq));
+ }
+
+ return TSDB_CODE_SUCCESS;
+ }
+
+ ctgError("no tbmeta got, tbName:%s", tNameGetTableName(pName));
+ ctgRemoveTbMetaFromCache(pCtg, pName, false);
+
+ CTG_ERR_JRET(CTG_ERR_CODE_TABLE_NOT_EXIST);
+ }
+
+ if (pMsgCtx->lastOut) {
+ TSWAP(pMsgCtx->out, pMsgCtx->lastOut);
+ STableMetaOutput* pLastOut = (STableMetaOutput*)pMsgCtx->out;
+ TSWAP(pLastOut->tbMeta, pOut->tbMeta);
+ }
+
+ break;
+ }
+ case TDMT_VND_TABLE_META: {
+ STableMetaOutput* pOut = (STableMetaOutput*)pMsgCtx->out;
+
+ if (CTG_IS_META_NULL(pOut->metaType)) {
+ ctgError("no tbmeta got, tbNmae:%s", tNameGetTableName(pName));
+ ctgRemoveTbMetaFromCache(pCtg, pName, false);
+ CTG_ERR_JRET(CTG_ERR_CODE_TABLE_NOT_EXIST);
+ }
+
+ if (CTG_FLAG_IS_STB(flag)) {
+ break;
+ }
+
+ if (CTG_IS_META_TABLE(pOut->metaType) && TSDB_SUPER_TABLE == pOut->tbMeta->tableType) {
+ ctgDebug("will continue to refresh tbmeta since got stb, tbName:%s", tNameGetTableName(pName));
+
+ taosMemoryFreeClear(pOut->tbMeta);
+
+ CTG_RET(ctgGetTbMetaFromMnode(pCtg, pConn, pName, NULL, tReq));
+ } else if (CTG_IS_META_BOTH(pOut->metaType)) {
+ int32_t exist = 0;
+ if (!CTG_FLAG_IS_FORCE_UPDATE(flag)) {
+ SName stbName = *pName;
+ strcpy(stbName.tname, pOut->tbName);
+ SCtgTbMetaCtx stbCtx = {0};
+ stbCtx.flag = flag;
+ stbCtx.pName = &stbName;
+
+ taosMemoryFreeClear(pOut->tbMeta);
+ CTG_ERR_JRET(ctgReadTbMetaFromCache(pCtg, &stbCtx, &pOut->tbMeta));
+ if (pOut->tbMeta) {
+ ctgDebug("use cached stb meta, tbName:%s", tNameGetTableName(pName));
+ exist = 1;
+ }
+ }
+
+ if (0 == exist) {
+ TSWAP(pMsgCtx->lastOut, pMsgCtx->out);
+ CTG_RET(ctgGetTbMetaFromMnodeImpl(pCtg, pConn, pOut->dbFName, pOut->tbName, NULL, tReq));
+ }
+ }
+ break;
+ }
+ default:
+ ctgError("invalid reqType %d", reqType);
+ CTG_ERR_JRET(TSDB_CODE_INVALID_MSG);
+ break;
+ }
+
+ STableMetaOutput* pOut = (STableMetaOutput*)pMsgCtx->out;
+
+ ctgUpdateTbMetaToCache(pCtg, pOut, false);
+
+ if (CTG_IS_META_BOTH(pOut->metaType)) {
+ memcpy(pOut->tbMeta, &pOut->ctbMeta, sizeof(pOut->ctbMeta));
+ }
+
+/*
+ else if (CTG_IS_META_CTABLE(pOut->metaType)) {
+ SName stbName = *pName;
+ strcpy(stbName.tname, pOut->tbName);
+ SCtgTbMetaCtx stbCtx = {0};
+ stbCtx.flag = flag;
+ stbCtx.pName = &stbName;
+
+ CTG_ERR_JRET(ctgReadTbMetaFromCache(pCtg, &stbCtx, &pOut->tbMeta));
+ if (NULL == pOut->tbMeta) {
+ ctgDebug("stb no longer exist, stbName:%s", stbName.tname);
+ CTG_ERR_JRET(ctgRelaunchGetTbMetaTask(pTask));
+
+ return TSDB_CODE_SUCCESS;
+ }
+
+ memcpy(pOut->tbMeta, &pOut->ctbMeta, sizeof(pOut->ctbMeta));
+ }
+*/
+
+ SMetaRes* pRes = taosArrayGet(ctx->pResList, pFetch->resIdx);
+ pRes->code = 0;
+ pRes->pRes = pOut->tbMeta;
+ pOut->tbMeta = NULL;
+ if (0 == atomic_sub_fetch_32(&ctx->fetchNum, 1)) {
+ TSWAP(pTask->res, ctx->pResList);
+ }
+
+_return:
+
+ if (dbCache) {
+ ctgReleaseVgInfoToCache(pCtg, dbCache);
+ }
+
+ if (code) {
+ SMetaRes* pRes = taosArrayGet(ctx->pResList, pFetch->resIdx);
+ pRes->code = code;
+ pRes->pRes = NULL;
+ if (0 == atomic_sub_fetch_32(&ctx->fetchNum, 1)) {
+ TSWAP(pTask->res, ctx->pResList);
+ }
+ }
+
+ if (pTask->res) {
+ ctgHandleTaskEnd(pTask, code);
+ }
+
+ CTG_RET(code);
+}
+
+
+int32_t ctgHandleGetDbVgRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
+ int32_t code = 0;
+ SCtgTask* pTask = tReq->pTask;
SCtgDbVgCtx* ctx = (SCtgDbVgCtx*)pTask->taskCtx;
SCatalog* pCtg = pTask->pJob->pCtg;
@@ -1024,8 +1306,9 @@ _return:
CTG_RET(code);
}
-int32_t ctgHandleGetTbHashRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
+int32_t ctgHandleGetTbHashRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
int32_t code = 0;
+ SCtgTask* pTask = tReq->pTask;
SCtgTbHashCtx* ctx = (SCtgTbHashCtx*)pTask->taskCtx;
SCatalog* pCtg = pTask->pJob->pCtg;
@@ -1061,8 +1344,65 @@ _return:
CTG_RET(code);
}
-int32_t ctgHandleGetTbIndexRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
+int32_t ctgHandleGetTbHashsRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
int32_t code = 0;
+ SCtgTask* pTask = tReq->pTask;
+ SCtgTbHashsCtx* ctx = (SCtgTbHashsCtx*)pTask->taskCtx;
+ SCatalog* pCtg = pTask->pJob->pCtg;
+ SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx);
+ SCtgFetch* pFetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx);
+
+ CTG_ERR_JRET(ctgProcessRspMsg(pMsgCtx->out, reqType, pMsg->pData, pMsg->len, rspCode, pMsgCtx->target));
+
+ switch (reqType) {
+ case TDMT_MND_USE_DB: {
+ SUseDbOutput* pOut = (SUseDbOutput*)pMsgCtx->out;
+
+ STablesReq* pReq = taosArrayGet(ctx->pNames, pFetch->dbIdx);
+ CTG_ERR_JRET(ctgGetVgInfosFromHashValue(pCtg, tReq, pOut->dbVgroup, ctx, pMsgCtx->target, pReq->pTables, true));
+
+ CTG_ERR_JRET(ctgUpdateVgroupEnqueue(pCtg, pMsgCtx->target, pOut->dbId, pOut->dbVgroup, false));
+ pOut->dbVgroup = NULL;
+
+ break;
+ }
+ default:
+ ctgError("invalid reqType %d", reqType);
+ CTG_ERR_JRET(TSDB_CODE_INVALID_MSG);
+ break;
+ }
+
+ if (0 == atomic_sub_fetch_32(&ctx->fetchNum, 1)) {
+ TSWAP(pTask->res, ctx->pResList);
+ }
+
+_return:
+
+ if (code) {
+ STablesReq* pReq = taosArrayGet(ctx->pNames, pFetch->dbIdx);
+ int32_t num = taosArrayGetSize(pReq->pTables);
+ for (int32_t i = 0; i < num; ++i) {
+ SMetaRes *pRes = taosArrayGet(ctx->pResList, pFetch->resIdx + i);
+ pRes->code = code;
+ pRes->pRes = NULL;
+ }
+
+ if (0 == atomic_sub_fetch_32(&ctx->fetchNum, 1)) {
+ TSWAP(pTask->res, ctx->pResList);
+ }
+ }
+
+ if (pTask->res) {
+ ctgHandleTaskEnd(pTask, code);
+ }
+
+ CTG_RET(code);
+}
+
+
+int32_t ctgHandleGetTbIndexRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
+ int32_t code = 0;
+ SCtgTask* pTask = tReq->pTask;
CTG_ERR_JRET(ctgProcessRspMsg(pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target));
STableIndex* pOut = (STableIndex*)pTask->msgCtx.out;
@@ -1083,8 +1423,9 @@ _return:
CTG_RET(code);
}
-int32_t ctgHandleGetTbCfgRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
+int32_t ctgHandleGetTbCfgRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
int32_t code = 0;
+ SCtgTask* pTask = tReq->pTask;
CTG_ERR_JRET(ctgProcessRspMsg(&pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target));
TSWAP(pTask->res, pTask->msgCtx.out);
@@ -1096,8 +1437,9 @@ _return:
CTG_RET(code);
}
-int32_t ctgHandleGetDbCfgRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
+int32_t ctgHandleGetDbCfgRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
int32_t code = 0;
+ SCtgTask* pTask = tReq->pTask;
CTG_ERR_JRET(ctgProcessRspMsg(pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target));
TSWAP(pTask->res, pTask->msgCtx.out);
@@ -1109,13 +1451,14 @@ _return:
CTG_RET(code);
}
-int32_t ctgHandleGetDbInfoRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
+int32_t ctgHandleGetDbInfoRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
CTG_RET(TSDB_CODE_APP_ERROR);
}
-int32_t ctgHandleGetQnodeRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
+int32_t ctgHandleGetQnodeRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
int32_t code = 0;
+ SCtgTask* pTask = tReq->pTask;
CTG_ERR_JRET(ctgProcessRspMsg(pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target));
TSWAP(pTask->res, pTask->msgCtx.out);
@@ -1127,8 +1470,9 @@ _return:
CTG_RET(code);
}
-int32_t ctgHandleGetDnodeRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
+int32_t ctgHandleGetDnodeRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
int32_t code = 0;
+ SCtgTask* pTask = tReq->pTask;
CTG_ERR_JRET(ctgProcessRspMsg(&pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target));
TSWAP(pTask->res, pTask->msgCtx.out);
@@ -1140,8 +1484,9 @@ _return:
CTG_RET(code);
}
-int32_t ctgHandleGetIndexRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
+int32_t ctgHandleGetIndexRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
int32_t code = 0;
+ SCtgTask* pTask = tReq->pTask;
CTG_ERR_JRET(ctgProcessRspMsg(pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target));
TSWAP(pTask->res, pTask->msgCtx.out);
@@ -1153,8 +1498,9 @@ _return:
CTG_RET(code);
}
-int32_t ctgHandleGetUdfRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
+int32_t ctgHandleGetUdfRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
int32_t code = 0;
+ SCtgTask* pTask = tReq->pTask;
CTG_ERR_JRET(ctgProcessRspMsg(pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target));
TSWAP(pTask->res, pTask->msgCtx.out);
@@ -1166,8 +1512,9 @@ _return:
CTG_RET(code);
}
-int32_t ctgHandleGetUserRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
+int32_t ctgHandleGetUserRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
int32_t code = 0;
+ SCtgTask* pTask = tReq->pTask;
SCtgUserCtx* ctx = (SCtgUserCtx*)pTask->taskCtx;
SCatalog* pCtg = pTask->pJob->pCtg;
bool pass = false;
@@ -1210,8 +1557,9 @@ _return:
CTG_RET(code);
}
-int32_t ctgHandleGetSvrVerRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
+int32_t ctgHandleGetSvrVerRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
int32_t code = 0;
+ SCtgTask* pTask = tReq->pTask;
CTG_ERR_JRET(ctgProcessRspMsg(&pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target));
@@ -1224,45 +1572,45 @@ _return:
CTG_RET(code);
}
-int32_t ctgAsyncRefreshTbMeta(SCtgTask *pTask) {
+int32_t ctgAsyncRefreshTbMeta(SCtgTaskReq *tReq, int32_t flag, SName* pName, int32_t* vgId) {
+ SCtgTask* pTask = tReq->pTask;
SCatalog* pCtg = pTask->pJob->pCtg;
SRequestConnInfo* pConn = &pTask->pJob->conn;
int32_t code = 0;
- SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
- if (CTG_FLAG_IS_SYS_DB(ctx->flag)) {
- ctgDebug("will refresh sys db tbmeta, tbName:%s", tNameGetTableName(ctx->pName));
+ if (CTG_FLAG_IS_SYS_DB(flag)) {
+ ctgDebug("will refresh sys db tbmeta, tbName:%s", tNameGetTableName(pName));
- CTG_RET(ctgGetTbMetaFromMnodeImpl(pCtg, pConn, (char *)ctx->pName->dbname, (char *)ctx->pName->tname, NULL, pTask));
+ CTG_RET(ctgGetTbMetaFromMnodeImpl(pCtg, pConn, (char *)pName->dbname, (char *)pName->tname, NULL, tReq));
}
- if (CTG_FLAG_IS_STB(ctx->flag)) {
- ctgDebug("will refresh tbmeta, supposed to be stb, tbName:%s", tNameGetTableName(ctx->pName));
+ if (CTG_FLAG_IS_STB(flag)) {
+ ctgDebug("will refresh tbmeta, supposed to be stb, tbName:%s", tNameGetTableName(pName));
// if get from mnode failed, will not try vnode
- CTG_RET(ctgGetTbMetaFromMnode(pCtg, pConn, ctx->pName, NULL, pTask));
+ CTG_RET(ctgGetTbMetaFromMnode(pCtg, pConn, pName, NULL, tReq));
}
SCtgDBCache *dbCache = NULL;
char dbFName[TSDB_DB_FNAME_LEN] = {0};
- tNameGetFullDbName(ctx->pName, dbFName);
+ tNameGetFullDbName(pName, dbFName);
CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, dbFName, &dbCache));
if (dbCache) {
SVgroupInfo vgInfo = {0};
- CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, ctx->pName, &vgInfo));
+ CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, pName, &vgInfo));
- ctgDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(ctx->pName), ctx->flag);
+ ctgDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(pName), flag);
- ctx->vgId = vgInfo.vgId;
- CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, ctx->pName, &vgInfo, NULL, pTask));
+ *vgId = vgInfo.vgId;
+ CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, pName, &vgInfo, NULL, tReq));
} else {
SBuildUseDBInput input = {0};
tstrncpy(input.db, dbFName, tListLen(input.db));
input.vgVersion = CTG_DEFAULT_INVALID_VERSION;
- CTG_ERR_JRET(ctgGetDBVgInfoFromMnode(pCtg, pConn, &input, NULL, pTask));
+ CTG_ERR_JRET(ctgGetDBVgInfoFromMnode(pCtg, pConn, &input, NULL, tReq));
}
_return:
@@ -1284,11 +1632,54 @@ int32_t ctgLaunchGetTbMetaTask(SCtgTask *pTask) {
return TSDB_CODE_SUCCESS;
}
- CTG_ERR_RET(ctgAsyncRefreshTbMeta(pTask));
+ SCtgTbMetaCtx* pCtx = (SCtgTbMetaCtx*)pTask->taskCtx;
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = -1;
+ CTG_ERR_RET(ctgAsyncRefreshTbMeta(&tReq, pCtx->flag, pCtx->pName, &pCtx->vgId));
return TSDB_CODE_SUCCESS;
}
+int32_t ctgLaunchGetTbMetasTask(SCtgTask *pTask) {
+ SCatalog* pCtg = pTask->pJob->pCtg;
+ SRequestConnInfo* pConn = &pTask->pJob->conn;
+ SCtgTbMetasCtx* pCtx = (SCtgTbMetasCtx*)pTask->taskCtx;
+
+ int32_t dbNum = taosArrayGetSize(pCtx->pNames);
+ int32_t fetchIdx = 0;
+ int32_t baseResIdx = 0;
+ for (int32_t i = 0; i < dbNum; ++i) {
+ STablesReq* pReq = taosArrayGet(pCtx->pNames, i);
+ ctgDebug("start to check tb metas in db %s, tbNum %d", pReq->dbFName, taosArrayGetSize(pReq->pTables));
+ CTG_ERR_RET(ctgGetTbMetasFromCache(pCtg, pConn, pCtx, i, &fetchIdx, baseResIdx, pReq->pTables));
+ baseResIdx += taosArrayGetSize(pReq->pTables);
+ }
+
+ pCtx->fetchNum = taosArrayGetSize(pCtx->pFetchs);
+ if (pCtx->fetchNum <= 0) {
+ TSWAP(pTask->res, pCtx->pResList);
+
+ CTG_ERR_RET(ctgHandleTaskEnd(pTask, 0));
+ return TSDB_CODE_SUCCESS;
+ }
+
+ pTask->msgCtxs = taosArrayInit(pCtx->fetchNum, sizeof(SCtgMsgCtx));
+ taosArraySetSize(pTask->msgCtxs, pCtx->fetchNum);
+
+ for (int32_t i = 0; i < pCtx->fetchNum; ++i) {
+ SCtgFetch* pFetch = taosArrayGet(pCtx->pFetchs, i);
+ SName* pName = ctgGetFetchName(pCtx->pNames, pFetch);
+
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = pFetch->fetchIdx;
+ CTG_ERR_RET(ctgAsyncRefreshTbMeta(&tReq, pFetch->flag, pName, &pFetch->vgId));
+ }
+
+ return TSDB_CODE_SUCCESS;
+}
+
int32_t ctgLaunchGetDbVgTask(SCtgTask *pTask) {
int32_t code = 0;
SCatalog* pCtg = pTask->pJob->pCtg;
@@ -1309,8 +1700,11 @@ int32_t ctgLaunchGetDbVgTask(SCtgTask *pTask) {
tstrncpy(input.db, pCtx->dbFName, tListLen(input.db));
input.vgVersion = CTG_DEFAULT_INVALID_VERSION;
-
- CTG_ERR_RET(ctgGetDBVgInfoFromMnode(pCtg, pConn, &input, NULL, pTask));
+
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = -1;
+ CTG_ERR_RET(ctgGetDBVgInfoFromMnode(pCtg, pConn, &input, NULL, &tReq));
}
_return:
@@ -1346,8 +1740,11 @@ int32_t ctgLaunchGetTbHashTask(SCtgTask *pTask) {
tstrncpy(input.db, pCtx->dbFName, tListLen(input.db));
input.vgVersion = CTG_DEFAULT_INVALID_VERSION;
-
- CTG_ERR_RET(ctgGetDBVgInfoFromMnode(pCtg, pConn, &input, NULL, pTask));
+
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = -1;
+ CTG_ERR_RET(ctgGetDBVgInfoFromMnode(pCtg, pConn, &input, NULL, &tReq));
}
_return:
@@ -1359,6 +1756,75 @@ _return:
CTG_RET(code);
}
+int32_t ctgLaunchGetTbHashsTask(SCtgTask *pTask) {
+ SCatalog* pCtg = pTask->pJob->pCtg;
+ SRequestConnInfo* pConn = &pTask->pJob->conn;
+ SCtgTbHashsCtx* pCtx = (SCtgTbHashsCtx*)pTask->taskCtx;
+ SCtgDBCache *dbCache = NULL;
+ int32_t dbNum = taosArrayGetSize(pCtx->pNames);
+ int32_t fetchIdx = 0;
+ int32_t baseResIdx = 0;
+ int32_t code = 0;
+
+ for (int32_t i = 0; i < dbNum; ++i) {
+ STablesReq* pReq = taosArrayGet(pCtx->pNames, i);
+
+ CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, pReq->dbFName, &dbCache));
+
+ if (NULL != dbCache) {
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = -1;
+ CTG_ERR_JRET(ctgGetVgInfosFromHashValue(pCtg, &tReq, dbCache->vgCache.vgInfo, pCtx, pReq->dbFName, pReq->pTables, false));
+
+ ctgReleaseVgInfoToCache(pCtg, dbCache);
+ dbCache = NULL;
+
+ baseResIdx += taosArrayGetSize(pReq->pTables);
+ } else {
+ ctgAddFetch(&pCtx->pFetchs, i, -1, &fetchIdx, baseResIdx, 0);
+
+ baseResIdx += taosArrayGetSize(pReq->pTables);
+ taosArraySetSize(pCtx->pResList, baseResIdx);
+ }
+ }
+
+ pCtx->fetchNum = taosArrayGetSize(pCtx->pFetchs);
+ if (pCtx->fetchNum <= 0) {
+ TSWAP(pTask->res, pCtx->pResList);
+
+ CTG_ERR_RET(ctgHandleTaskEnd(pTask, 0));
+ return TSDB_CODE_SUCCESS;
+ }
+
+ pTask->msgCtxs = taosArrayInit(pCtx->fetchNum, sizeof(SCtgMsgCtx));
+ taosArraySetSize(pTask->msgCtxs, pCtx->fetchNum);
+
+ for (int32_t i = 0; i < pCtx->fetchNum; ++i) {
+ SCtgFetch* pFetch = taosArrayGet(pCtx->pFetchs, i);
+ STablesReq* pReq = taosArrayGet(pCtx->pNames, pFetch->dbIdx);
+
+ SBuildUseDBInput input = {0};
+ strcpy(input.db, pReq->dbFName);
+
+ input.vgVersion = CTG_DEFAULT_INVALID_VERSION;
+
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = pFetch->fetchIdx;
+ CTG_ERR_RET(ctgGetDBVgInfoFromMnode(pCtg, pConn, &input, NULL, &tReq));
+ }
+
+_return:
+
+ if (dbCache) {
+ ctgReleaseVgInfoToCache(pCtg, dbCache);
+ }
+
+ return code;
+}
+
+
int32_t ctgLaunchGetTbIndexTask(SCtgTask *pTask) {
int32_t code = 0;
SCatalog* pCtg = pTask->pJob->pCtg;
@@ -1597,19 +2063,21 @@ int32_t ctgCloneDbVg(SCtgTask* pTask, void** pRes) {
SCtgAsyncFps gCtgAsyncFps[] = {
- {ctgInitGetQnodeTask, ctgLaunchGetQnodeTask, ctgHandleGetQnodeRsp, ctgDumpQnodeRes, NULL, NULL},
- {ctgInitGetDnodeTask, ctgLaunchGetDnodeTask, ctgHandleGetDnodeRsp, ctgDumpDnodeRes, NULL, NULL},
- {ctgInitGetDbVgTask, ctgLaunchGetDbVgTask, ctgHandleGetDbVgRsp, ctgDumpDbVgRes, ctgCompDbVgTasks, ctgCloneDbVg},
- {ctgInitGetDbCfgTask, ctgLaunchGetDbCfgTask, ctgHandleGetDbCfgRsp, ctgDumpDbCfgRes, NULL, NULL},
- {ctgInitGetDbInfoTask, ctgLaunchGetDbInfoTask, ctgHandleGetDbInfoRsp, ctgDumpDbInfoRes, NULL, NULL},
- {ctgInitGetTbMetaTask, ctgLaunchGetTbMetaTask, ctgHandleGetTbMetaRsp, ctgDumpTbMetaRes, ctgCompTbMetaTasks, ctgCloneTbMeta},
- {ctgInitGetTbHashTask, ctgLaunchGetTbHashTask, ctgHandleGetTbHashRsp, ctgDumpTbHashRes, NULL, NULL},
- {ctgInitGetTbIndexTask, ctgLaunchGetTbIndexTask, ctgHandleGetTbIndexRsp, ctgDumpTbIndexRes, NULL, NULL},
- {ctgInitGetTbCfgTask, ctgLaunchGetTbCfgTask, ctgHandleGetTbCfgRsp, ctgDumpTbCfgRes, NULL, NULL},
- {ctgInitGetIndexTask, ctgLaunchGetIndexTask, ctgHandleGetIndexRsp, ctgDumpIndexRes, NULL, NULL},
- {ctgInitGetUdfTask, ctgLaunchGetUdfTask, ctgHandleGetUdfRsp, ctgDumpUdfRes, NULL, NULL},
- {ctgInitGetUserTask, ctgLaunchGetUserTask, ctgHandleGetUserRsp, ctgDumpUserRes, NULL, NULL},
- {ctgInitGetSvrVerTask, ctgLaunchGetSvrVerTask, ctgHandleGetSvrVerRsp, ctgDumpSvrVer, NULL, NULL},
+ {ctgInitGetQnodeTask, ctgLaunchGetQnodeTask, ctgHandleGetQnodeRsp, ctgDumpQnodeRes, NULL, NULL},
+ {ctgInitGetDnodeTask, ctgLaunchGetDnodeTask, ctgHandleGetDnodeRsp, ctgDumpDnodeRes, NULL, NULL},
+ {ctgInitGetDbVgTask, ctgLaunchGetDbVgTask, ctgHandleGetDbVgRsp, ctgDumpDbVgRes, ctgCompDbVgTasks, ctgCloneDbVg},
+ {ctgInitGetDbCfgTask, ctgLaunchGetDbCfgTask, ctgHandleGetDbCfgRsp, ctgDumpDbCfgRes, NULL, NULL},
+ {ctgInitGetDbInfoTask, ctgLaunchGetDbInfoTask, ctgHandleGetDbInfoRsp, ctgDumpDbInfoRes, NULL, NULL},
+ {ctgInitGetTbMetaTask, ctgLaunchGetTbMetaTask, ctgHandleGetTbMetaRsp, ctgDumpTbMetaRes, ctgCompTbMetaTasks, ctgCloneTbMeta},
+ {ctgInitGetTbHashTask, ctgLaunchGetTbHashTask, ctgHandleGetTbHashRsp, ctgDumpTbHashRes, NULL, NULL},
+ {ctgInitGetTbIndexTask, ctgLaunchGetTbIndexTask, ctgHandleGetTbIndexRsp, ctgDumpTbIndexRes, NULL, NULL},
+ {ctgInitGetTbCfgTask, ctgLaunchGetTbCfgTask, ctgHandleGetTbCfgRsp, ctgDumpTbCfgRes, NULL, NULL},
+ {ctgInitGetIndexTask, ctgLaunchGetIndexTask, ctgHandleGetIndexRsp, ctgDumpIndexRes, NULL, NULL},
+ {ctgInitGetUdfTask, ctgLaunchGetUdfTask, ctgHandleGetUdfRsp, ctgDumpUdfRes, NULL, NULL},
+ {ctgInitGetUserTask, ctgLaunchGetUserTask, ctgHandleGetUserRsp, ctgDumpUserRes, NULL, NULL},
+ {ctgInitGetSvrVerTask, ctgLaunchGetSvrVerTask, ctgHandleGetSvrVerRsp, ctgDumpSvrVer, NULL, NULL},
+ {ctgInitGetTbMetasTask, ctgLaunchGetTbMetasTask, ctgHandleGetTbMetasRsp, ctgDumpTbMetasRes, NULL, NULL},
+ {ctgInitGetTbHashsTask, ctgLaunchGetTbHashsTask, ctgHandleGetTbHashsRsp, ctgDumpTbHashsRes, NULL, NULL},
};
int32_t ctgMakeAsyncRes(SCtgJob *pJob) {
diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c
index 2e8e259151..930361419e 100644
--- a/source/libs/catalog/src/ctgCache.c
+++ b/source/libs/catalog/src/ctgCache.c
@@ -242,7 +242,6 @@ int32_t ctgAcquireTbMetaFromCache(SCatalog* pCtg, char *dbFName, char* tbName, S
goto _return;
}
- int32_t sz = 0;
pCache = taosHashAcquire(dbCache->tbCache, tbName, strlen(tbName));
if (NULL == pCache) {
ctgDebug("tb %s not in cache, dbFName:%s", tbName, dbFName);
@@ -282,7 +281,6 @@ int32_t ctgAcquireStbMetaFromCache(SCatalog* pCtg, char *dbFName, uint64_t suid,
goto _return;
}
- int32_t sz = 0;
char* stName = taosHashAcquire(dbCache->stbCache, &suid, sizeof(suid));
if (NULL == stName) {
ctgDebug("stb 0x%" PRIx64 " not in cache, dbFName:%s", suid, dbFName);
@@ -2152,6 +2150,254 @@ int32_t ctgGetTbMetaFromCache(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMet
return TSDB_CODE_SUCCESS;
}
+#if 0
+int32_t ctgGetTbMetaBFromCache(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetasCtx* ctx, SArray** pResList) {
+ int32_t tbNum = taosArrayGetSize(ctx->pNames);
+ SName* fName = taosArrayGet(ctx->pNames, 0);
+ int32_t fIdx = 0;
+
+ for (int32_t i = 0; i < tbNum; ++i) {
+ SName* pName = taosArrayGet(ctx->pNames, i);
+ SCtgTbMetaCtx nctx = {0};
+ nctx.flag = CTG_FLAG_UNKNOWN_STB;
+ nctx.pName = pName;
+
+ if (IS_SYS_DBNAME(pName->dbname)) {
+ CTG_FLAG_SET_SYS_DB(nctx.flag);
+ }
+
+ STableMeta *pTableMeta = NULL;
+ CTG_ERR_RET(ctgReadTbMetaFromCache(pCtg, &nctx, &pTableMeta));
+ SMetaRes res = {0};
+
+ if (pTableMeta) {
+ if (CTG_FLAG_MATCH_STB(nctx.flag, pTableMeta->tableType) &&
+ ((!CTG_FLAG_IS_FORCE_UPDATE(nctx.flag)) || (CTG_FLAG_IS_SYS_DB(nctx.flag)))) {
+ res.pRes = pTableMeta;
+ } else {
+ taosMemoryFreeClear(pTableMeta);
+ }
+ }
+
+ if (NULL == res.pRes) {
+ if (NULL == ctx->pFetchs) {
+ ctx->pFetchs = taosArrayInit(tbNum, sizeof(SCtgFetch));
+ }
+
+ if (CTG_FLAG_IS_UNKNOWN_STB(nctx.flag)) {
+ CTG_FLAG_SET_STB(nctx.flag, nctx.tbInfo.tbType);
+ }
+
+ SCtgFetch fetch = {0};
+ fetch.tbIdx = i;
+ fetch.fetchIdx = fIdx++;
+ fetch.flag = nctx.flag;
+
+ taosArrayPush(ctx->pFetchs, &fetch);
+ }
+
+ taosArrayPush(ctx->pResList, &res);
+ }
+
+ if (NULL == ctx->pFetchs) {
+ TSWAP(*pResList, ctx->pResList);
+ }
+
+ return TSDB_CODE_SUCCESS;
+}
+#endif
+
+int32_t ctgGetTbMetasFromCache(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetasCtx* ctx, int32_t dbIdx, int32_t *fetchIdx, int32_t baseResIdx, SArray* pList) {
+ int32_t tbNum = taosArrayGetSize(pList);
+ SName* pName = taosArrayGet(pList, 0);
+ char dbFName[TSDB_DB_FNAME_LEN] = {0};
+ int32_t flag = CTG_FLAG_UNKNOWN_STB;
+ uint64_t lastSuid = 0;
+ STableMeta* lastTableMeta = NULL;
+
+ if (IS_SYS_DBNAME(pName->dbname)) {
+ CTG_FLAG_SET_SYS_DB(flag);
+ strcpy(dbFName, pName->dbname);
+ } else {
+ tNameGetFullDbName(pName, dbFName);
+ }
+
+ SCtgDBCache *dbCache = NULL;
+ SCtgTbCache* pCache = NULL;
+ ctgAcquireDBCache(pCtg, dbFName, &dbCache);
+
+ if (NULL == dbCache) {
+ ctgDebug("db %s not in cache", dbFName);
+ for (int32_t i = 0; i < tbNum; ++i) {
+ ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag);
+ taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1);
+ }
+
+ return TSDB_CODE_SUCCESS;
+ }
+
+ for (int32_t i = 0; i < tbNum; ++i) {
+ SName* pName = taosArrayGet(pList, i);
+
+ pCache = taosHashAcquire(dbCache->tbCache, pName->tname, strlen(pName->tname));
+ if (NULL == pCache) {
+ ctgDebug("tb %s not in cache, dbFName:%s", pName->tname, dbFName);
+ ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag);
+ taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1);
+
+ continue;
+ }
+
+ CTG_LOCK(CTG_READ, &pCache->metaLock);
+ if (NULL == pCache->pMeta) {
+ ctgDebug("tb %s meta not in cache, dbFName:%s", pName->tname, dbFName);
+ ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag);
+ taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1);
+
+ continue;
+ }
+
+ STableMeta* tbMeta = pCache->pMeta;
+
+ SCtgTbMetaCtx nctx = {0};
+ nctx.flag = flag;
+ nctx.tbInfo.inCache = true;
+ nctx.tbInfo.dbId = dbCache->dbId;
+ nctx.tbInfo.suid = tbMeta->suid;
+ nctx.tbInfo.tbType = tbMeta->tableType;
+
+ SMetaRes res = {0};
+ STableMeta* pTableMeta = NULL;
+ if (tbMeta->tableType != TSDB_CHILD_TABLE) {
+ int32_t metaSize = CTG_META_SIZE(tbMeta);
+ pTableMeta = taosMemoryCalloc(1, metaSize);
+ if (NULL == pTableMeta) {
+ ctgReleaseTbMetaToCache(pCtg, dbCache, pCache);
+ CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
+ }
+
+ memcpy(pTableMeta, tbMeta, metaSize);
+
+ CTG_UNLOCK(CTG_READ, &pCache->metaLock);
+ taosHashRelease(dbCache->tbCache, pCache);
+
+ ctgDebug("Got tb %s meta from cache, type:%d, dbFName:%s", pName->tname, tbMeta->tableType, dbFName);
+
+ res.pRes = pTableMeta;
+ taosArrayPush(ctx->pResList, &res);
+
+ continue;
+ }
+
+ // PROCESS FOR CHILD TABLE
+
+ if (lastSuid && tbMeta->suid == lastSuid && lastTableMeta) {
+ cloneTableMeta(lastTableMeta, &pTableMeta);
+ memcpy(pTableMeta, tbMeta, sizeof(SCTableMeta));
+
+ CTG_UNLOCK(CTG_READ, &pCache->metaLock);
+ taosHashRelease(dbCache->tbCache, pCache);
+
+ ctgDebug("Got tb %s meta from cache, type:%d, dbFName:%s", pName->tname, tbMeta->tableType, dbFName);
+
+ res.pRes = pTableMeta;
+ taosArrayPush(ctx->pResList, &res);
+
+ continue;
+ }
+
+ int32_t metaSize = sizeof(SCTableMeta);
+ pTableMeta = taosMemoryCalloc(1, metaSize);
+ if (NULL == pTableMeta) {
+ ctgReleaseTbMetaToCache(pCtg, dbCache, pCache);
+ CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
+ }
+
+ memcpy(pTableMeta, tbMeta, metaSize);
+
+ CTG_UNLOCK(CTG_READ, &pCache->metaLock);
+ taosHashRelease(dbCache->tbCache, pCache);
+
+ ctgDebug("Got ctb %s meta from cache, will continue to get its stb meta, type:%d, dbFName:%s",
+ pName->tname, nctx.tbInfo.tbType, dbFName);
+
+ char* stName = taosHashAcquire(dbCache->stbCache, &pTableMeta->suid, sizeof(pTableMeta->suid));
+ if (NULL == stName) {
+ ctgDebug("stb 0x%" PRIx64 " not in cache, dbFName:%s", pTableMeta->suid, dbFName);
+ ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag);
+ taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1);
+
+ taosMemoryFreeClear(pTableMeta);
+ continue;
+ }
+
+ pCache = taosHashAcquire(dbCache->tbCache, stName, strlen(stName));
+ if (NULL == pCache) {
+ ctgDebug("stb 0x%" PRIx64 " name %s not in cache, dbFName:%s", pTableMeta->suid, stName, dbFName);
+ taosHashRelease(dbCache->stbCache, stName);
+
+ ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag);
+ taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1);
+
+ taosMemoryFreeClear(pTableMeta);
+ continue;
+ }
+
+ taosHashRelease(dbCache->stbCache, stName);
+
+ CTG_LOCK(CTG_READ, &pCache->metaLock);
+ if (NULL == pCache->pMeta) {
+ ctgDebug("stb 0x%" PRIx64 " meta not in cache, dbFName:%s", pTableMeta->suid, dbFName);
+ CTG_UNLOCK(CTG_READ, &pCache->metaLock);
+ taosHashRelease(dbCache->tbCache, pCache);
+
+ ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag);
+ taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1);
+
+ taosMemoryFreeClear(pTableMeta);
+
+ continue;
+ }
+
+ STableMeta* stbMeta = pCache->pMeta;
+ if (stbMeta->suid != nctx.tbInfo.suid) {
+ CTG_UNLOCK(CTG_READ, &pCache->metaLock);
+ taosHashRelease(dbCache->tbCache, pCache);
+
+ ctgError("stb suid 0x%" PRIx64 " in stbCache mis-match, expected suid 0x%"PRIx64 , stbMeta->suid, nctx.tbInfo.suid);
+
+ ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag);
+ taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1);
+
+ taosMemoryFreeClear(pTableMeta);
+
+ continue;
+ }
+
+ metaSize = CTG_META_SIZE(stbMeta);
+ pTableMeta = taosMemoryRealloc(pTableMeta, metaSize);
+ if (NULL == pTableMeta) {
+ ctgReleaseTbMetaToCache(pCtg, dbCache, pCache);
+ CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
+ }
+
+ memcpy(&pTableMeta->sversion, &stbMeta->sversion, metaSize - sizeof(SCTableMeta));
+
+ CTG_UNLOCK(CTG_READ, &pCache->metaLock);
+ taosHashRelease(dbCache->tbCache, pCache);
+
+ res.pRes = pTableMeta;
+ taosArrayPush(ctx->pResList, &res);
+
+ lastSuid = pTableMeta->suid;
+ lastTableMeta = pTableMeta;
+ }
+
+ ctgReleaseDBCache(pCtg, dbCache);
+
+ return TSDB_CODE_SUCCESS;
+}
+
int32_t ctgRemoveTbMetaFromCache(SCatalog* pCtg, SName* pTableName, bool syncReq) {
int32_t code = 0;
diff --git a/source/libs/catalog/src/ctgRemote.c b/source/libs/catalog/src/ctgRemote.c
index 4652c66ebc..a9f2d426bc 100644
--- a/source/libs/catalog/src/ctgRemote.c
+++ b/source/libs/catalog/src/ctgRemote.c
@@ -22,9 +22,8 @@
int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBuf* pMsg, int32_t rspCode) {
int32_t code = 0;
- SArray* pTaskId = cbParam->taskId;
SCatalog* pCtg = pJob->pCtg;
- int32_t taskNum = taosArrayGetSize(pTaskId);
+ int32_t taskNum = taosArrayGetSize(cbParam->taskId);
SDataBuf taskMsg = *pMsg;
int32_t offset = 0;
int32_t msgNum = (TSDB_CODE_SUCCESS == rspCode && pMsg->pData && (pMsg->len > 0)) ? ntohl(*(int32_t*)pMsg->pData) : 0;
@@ -42,11 +41,14 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu
}
for (int32_t i = 0; i < taskNum; ++i) {
- int32_t* taskId = taosArrayGet(pTaskId, i);
+ int32_t* taskId = taosArrayGet(cbParam->taskId, i);
+ int32_t* msgIdx = taosArrayGet(cbParam->msgIdx, i);
SCtgTask* pTask = taosArrayGet(pJob->pTasks, *taskId);
if (msgNum > 0) {
rsp.reqType = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
offset += sizeof(rsp.reqType);
+ rsp.msgIdx = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
+ offset += sizeof(rsp.msgIdx);
rsp.msgLen = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
offset += sizeof(rsp.msgLen);
rsp.rspCode = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
@@ -57,7 +59,10 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu
taskMsg.msgType = rsp.reqType;
taskMsg.pData = rsp.msg;
taskMsg.len = rsp.msgLen;
+
+ ASSERT(rsp.msgIdx == *msgIdx);
} else {
+ rsp.msgIdx = *msgIdx;
rsp.reqType = -1;
taskMsg.msgType = -1;
taskMsg.pData = NULL;
@@ -65,11 +70,14 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu
}
pTask->pBatchs = pBatchs;
+
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = rsp.msgIdx;
- ctgDebug("QID:0x%" PRIx64 " ctg task %d start to handle rsp %s", pJob->queryId, pTask->taskId,
- TMSG_INFO(taskMsg.msgType + 1));
+ ctgDebug("QID:0x%" PRIx64 " ctg task %d idx %d start to handle rsp %s", pJob->queryId, pTask->taskId, rsp.msgIdx, TMSG_INFO(taskMsg.msgType + 1));
- (*gCtgAsyncFps[pTask->type].handleRspFp)(pTask, rsp.reqType, &taskMsg, (rsp.rspCode ? rsp.rspCode : rspCode));
+ (*gCtgAsyncFps[pTask->type].handleRspFp)(&tReq, rsp.reqType, &taskMsg, (rsp.rspCode ? rsp.rspCode : rspCode));
}
CTG_ERR_JRET(ctgLaunchBatchs(pJob->pCtg, pJob, pBatchs));
@@ -338,7 +346,10 @@ int32_t ctgHandleMsgCallback(void* param, SDataBuf* pMsg, int32_t rspCode) {
pTask->pBatchs = pBatchs;
#endif
- CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].handleRspFp)(pTask, cbParam->reqType, pMsg, rspCode));
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = -1;
+ CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].handleRspFp)(&tReq, cbParam->reqType, pMsg, rspCode));
#if CTG_BATCH_FETCH
CTG_ERR_JRET(ctgLaunchBatchs(pJob->pCtg, pJob, pBatchs));
@@ -356,7 +367,7 @@ _return:
CTG_API_LEAVE(code);
}
-int32_t ctgMakeMsgSendInfo(SCtgJob* pJob, SArray* pTaskId, int32_t batchId, int32_t msgType,
+int32_t ctgMakeMsgSendInfo(SCtgJob* pJob, SArray* pTaskId, int32_t batchId, SArray* pMsgIdx, int32_t msgType,
SMsgSendInfo** pMsgSendInfo) {
int32_t code = 0;
SMsgSendInfo* msgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
@@ -376,6 +387,7 @@ int32_t ctgMakeMsgSendInfo(SCtgJob* pJob, SArray* pTaskId, int32_t batchId, int3
param->refId = pJob->refId;
param->taskId = pTaskId;
param->batchId = batchId;
+ param->msgIdx = pMsgIdx;
msgSendInfo->param = param;
msgSendInfo->paramFreeFp = ctgFreeMsgSendParam;
@@ -394,10 +406,10 @@ _return:
}
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) {
+ SArray* pMsgIdx, 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));
+ CTG_ERR_JRET(ctgMakeMsgSendInfo(pJob, pTaskId, batchId, pMsgIdx, msgType, &pMsgSendInfo));
ctgUpdateSendTargetInfo(pMsgSendInfo, msgType, dbFName, vgId);
@@ -428,25 +440,27 @@ _return:
CTG_RET(code);
}
-int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgTask* pTask, int32_t msgType, void* msg,
+int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgTaskReq* tReq, int32_t msgType, void* msg,
uint32_t msgSize) {
int32_t code = 0;
+ SCtgTask* pTask = tReq->pTask;
SHashObj* pBatchs = pTask->pBatchs;
SCtgJob* pJob = pTask->pJob;
SCtgBatch* pBatch = taosHashGet(pBatchs, &vgId, sizeof(vgId));
- int32_t taskNum = taosArrayGetSize(pTask->pJob->pTasks);
- SCtgBatch newBatch = {0};
- SBatchMsg req = {0};
-
+ SCtgBatch newBatch = {0};
+ SBatchMsg req = {0};
+
if (NULL == pBatch) {
- newBatch.pMsgs = taosArrayInit(taskNum, sizeof(SBatchMsg));
- newBatch.pTaskIds = taosArrayInit(taskNum, sizeof(int32_t));
- if (NULL == newBatch.pMsgs || NULL == newBatch.pTaskIds) {
+ newBatch.pMsgs = taosArrayInit(pJob->subTaskNum, sizeof(SBatchMsg));
+ newBatch.pTaskIds = taosArrayInit(pJob->subTaskNum, sizeof(int32_t));
+ newBatch.pMsgIdxs = taosArrayInit(pJob->subTaskNum, sizeof(int32_t));
+ if (NULL == newBatch.pMsgs || NULL == newBatch.pTaskIds || NULL == newBatch.pMsgIdxs) {
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
}
newBatch.conn = *pConn;
+ req.msgIdx = tReq->msgIdx;
req.msgType = msgType;
req.msgLen = msgSize;
req.msg = msg;
@@ -456,19 +470,31 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT
if (NULL == taosArrayPush(newBatch.pTaskIds, &pTask->taskId)) {
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
}
+ if (NULL == taosArrayPush(newBatch.pMsgIdxs, &req.msgIdx)) {
+ CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
+ }
newBatch.msgSize = sizeof(SBatchReq) + sizeof(req) + msgSize - POINTER_BYTES;
if (vgId > 0) {
+ SName* pName = NULL;
if (TDMT_VND_TABLE_CFG == msgType) {
SCtgTbCfgCtx* ctx = (SCtgTbCfgCtx*)pTask->taskCtx;
- tNameGetFullDbName(ctx->pName, newBatch.dbFName);
+ pName = ctx->pName;
} else if (TDMT_VND_TABLE_META == msgType) {
- SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
- tNameGetFullDbName(ctx->pName, newBatch.dbFName);
+ if (CTG_TASK_GET_TB_META_BATCH == pTask->type) {
+ SCtgTbMetasCtx* ctx = (SCtgTbMetasCtx*)pTask->taskCtx;
+ SCtgFetch* fetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx);
+ pName = ctgGetFetchName(ctx->pNames, fetch);
+ } else {
+ SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
+ pName = ctx->pName;
+ }
} else {
ctgError("invalid vnode msgType %d", msgType);
CTG_ERR_JRET(TSDB_CODE_APP_ERROR);
}
+
+ tNameGetFullDbName(pName, newBatch.dbFName);
}
newBatch.msgType = (vgId > 0) ? TDMT_VND_BATCH_META : TDMT_MND_BATCH_META;
@@ -484,6 +510,7 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT
return TSDB_CODE_SUCCESS;
}
+ req.msgIdx = tReq->msgIdx;
req.msgType = msgType;
req.msgLen = msgSize;
req.msg = msg;
@@ -493,19 +520,32 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT
if (NULL == taosArrayPush(pBatch->pTaskIds, &pTask->taskId)) {
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
}
+ if (NULL == taosArrayPush(pBatch->pMsgIdxs, &req.msgIdx)) {
+ CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
+ }
+
pBatch->msgSize += sizeof(req) + msgSize - POINTER_BYTES;
if (vgId > 0) {
+ SName* pName = NULL;
if (TDMT_VND_TABLE_CFG == msgType) {
SCtgTbCfgCtx* ctx = (SCtgTbCfgCtx*)pTask->taskCtx;
- tNameGetFullDbName(ctx->pName, newBatch.dbFName);
+ pName = ctx->pName;
} else if (TDMT_VND_TABLE_META == msgType) {
- SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
- tNameGetFullDbName(ctx->pName, newBatch.dbFName);
+ if (CTG_TASK_GET_TB_META_BATCH == pTask->type) {
+ SCtgTbMetasCtx* ctx = (SCtgTbMetasCtx*)pTask->taskCtx;
+ SCtgFetch* fetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx);
+ pName = ctgGetFetchName(ctx->pNames, fetch);
+ } else {
+ SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
+ pName = ctx->pName;
+ }
} else {
ctgError("invalid vnode msgType %d", msgType);
CTG_ERR_JRET(TSDB_CODE_APP_ERROR);
}
+
+ tNameGetFullDbName(pName, newBatch.dbFName);
}
ctgDebug("task %d %s req added to batch %d, target vgId %d", pTask->taskId, TMSG_INFO(msgType), pBatch->batchId,
@@ -537,6 +577,8 @@ int32_t ctgBuildBatchReqMsg(SCtgBatch* pBatch, int32_t vgId, void** msg) {
for (int32_t i = 0; i < num; ++i) {
SBatchMsg* pReq = taosArrayGet(pBatch->pMsgs, i);
+ *(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgIdx);
+ offset += sizeof(pReq->msgIdx);
*(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgType);
offset += sizeof(pReq->msgType);
*(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgLen);
@@ -564,8 +606,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->pMsgIdxs,
+ pBatch->dbFName, *vgId, pBatch->msgType, msg, pBatch->msgSize);
pBatch->pTaskIds = NULL;
CTG_ERR_JRET(code);
@@ -603,10 +645,14 @@ int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray
if (NULL == pOut) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
}
- CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, NULL));
+
+ CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, pOut, NULL));
#if CTG_BATCH_FETCH
- CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = -1;
+ CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
#else
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
if (NULL == pTaskId) {
@@ -614,7 +660,7 @@ int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray
}
taosArrayPush(pTaskId, &pTask->taskId);
- CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
+ CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
#endif
}
@@ -649,10 +695,13 @@ int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray
}
if (pTask) {
- CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, NULL));
+ CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, NULL, NULL));
#if CTG_BATCH_FETCH
- CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = -1;
+ CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
#else
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
if (NULL == pTaskId) {
@@ -660,7 +709,7 @@ int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray
}
taosArrayPush(pTaskId, &pTask->taskId);
- CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
+ CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
#endif
}
@@ -681,10 +730,11 @@ int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray
}
int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SBuildUseDBInput* input, SUseDbOutput* out,
- SCtgTask* pTask) {
+ SCtgTaskReq* tReq) {
char* msg = NULL;
int32_t msgLen = 0;
int32_t reqType = TDMT_MND_USE_DB;
+ SCtgTask* pTask = tReq ? tReq->pTask : NULL;
void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
ctgDebug("try to get db vgInfo from mnode, dbFName:%s", input->db);
@@ -700,10 +750,11 @@ int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SBuildU
if (NULL == pOut) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
}
- CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, input->db));
+
+ CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx), reqType, pOut, input->db));
#if CTG_BATCH_FETCH
- CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
+ CTG_RET(ctgAddBatch(pCtg, 0, pConn, tReq, reqType, msg, msgLen));
#else
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
if (NULL == pTaskId) {
@@ -711,7 +762,7 @@ int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SBuildU
}
taosArrayPush(pTaskId, &pTask->taskId);
- CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
+ CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
#endif
}
@@ -751,10 +802,14 @@ int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char
if (NULL == pOut) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
}
- CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)dbFName));
+
+ CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, pOut, (char*)dbFName));
#if CTG_BATCH_FETCH
- CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = -1;
+ CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
#else
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
if (NULL == pTaskId) {
@@ -762,7 +817,7 @@ int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char
}
taosArrayPush(pTaskId, &pTask->taskId);
- CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
+ CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
#endif
}
@@ -802,10 +857,14 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const
if (NULL == pOut) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
}
- CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)indexName));
+
+ CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, pOut, (char*)indexName));
#if CTG_BATCH_FETCH
- CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = -1;
+ CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
#else
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
if (NULL == pTaskId) {
@@ -813,7 +872,7 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const
}
taosArrayPush(pTaskId, &pTask->taskId);
- CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
+ CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
#endif
}
@@ -855,11 +914,14 @@ int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SName* n
if (NULL == pOut) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
}
-
- CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)tbFName));
+
+ CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, pOut, (char*)tbFName));
#if CTG_BATCH_FETCH
- CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = -1;
+ CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
#else
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
if (NULL == pTaskId) {
@@ -867,7 +929,7 @@ int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SName* n
}
taosArrayPush(pTaskId, &pTask->taskId);
- CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
+ CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
#endif
}
@@ -907,10 +969,14 @@ int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const ch
if (NULL == pOut) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
}
- CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)funcName));
+
+ CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, pOut, (char*)funcName));
#if CTG_BATCH_FETCH
- CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = -1;
+ CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
#else
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
if (NULL == pTaskId) {
@@ -918,7 +984,7 @@ int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const ch
}
taosArrayPush(pTaskId, &pTask->taskId);
- CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
+ CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
#endif
}
@@ -958,10 +1024,14 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const
if (NULL == pOut) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
}
- CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)user));
+
+ CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, pOut, (char*)user));
#if CTG_BATCH_FETCH
- CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = -1;
+ CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
#else
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
if (NULL == pTaskId) {
@@ -969,7 +1039,7 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const
}
taosArrayPush(pTaskId, &pTask->taskId);
- CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
+ CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
#endif
}
@@ -990,7 +1060,8 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const
}
int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, char* dbFName, char* tbName,
- STableMetaOutput* out, SCtgTask* pTask) {
+ STableMetaOutput* out, SCtgTaskReq* tReq) {
+ SCtgTask *pTask = tReq ? tReq->pTask : NULL;
SBuildTableInput bInput = {.vgId = 0, .dbFName = dbFName, .tbName = tbName};
char* msg = NULL;
SEpSet* pVnodeEpSet = NULL;
@@ -1013,9 +1084,11 @@ int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, char*
if (NULL == pOut) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
}
- CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, tbFName));
+
+ CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx), reqType, pOut, tbFName));
+
#if CTG_BATCH_FETCH
- CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
+ CTG_RET(ctgAddBatch(pCtg, 0, pConn, tReq, reqType, msg, msgLen));
#else
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
if (NULL == pTaskId) {
@@ -1023,7 +1096,7 @@ int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, char*
}
taosArrayPush(pTaskId, &pTask->taskId);
- CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
+ CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
#endif
}
@@ -1044,15 +1117,16 @@ int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, char*
}
int32_t ctgGetTbMetaFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableMetaOutput* out,
- SCtgTask* pTask) {
+ SCtgTaskReq* tReq) {
char dbFName[TSDB_DB_FNAME_LEN];
tNameGetFullDbName(pTableName, dbFName);
- return ctgGetTbMetaFromMnodeImpl(pCtg, pConn, dbFName, (char*)pTableName->tname, out, pTask);
+ return ctgGetTbMetaFromMnodeImpl(pCtg, pConn, dbFName, (char*)pTableName->tname, out, tReq);
}
int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SVgroupInfo* vgroupInfo,
- STableMetaOutput* out, SCtgTask* pTask) {
+ STableMetaOutput* out, SCtgTaskReq* tReq) {
+ SCtgTask *pTask = tReq ? tReq->pTask : NULL;
char dbFName[TSDB_DB_FNAME_LEN];
tNameGetFullDbName(pTableName, dbFName);
int32_t reqType = TDMT_VND_TABLE_META;
@@ -1080,15 +1154,16 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SNa
if (NULL == pOut) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
}
- CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, tbFName));
SRequestConnInfo vConn = {.pTrans = pConn->pTrans,
.requestId = pConn->requestId,
.requestObjRefId = pConn->requestObjRefId,
.mgmtEps = vgroupInfo->epSet};
+ CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx), reqType, pOut, tbFName));
+
#if CTG_BATCH_FETCH
- CTG_RET(ctgAddBatch(pCtg, vgroupInfo->vgId, &vConn, pTask, reqType, msg, msgLen));
+ CTG_RET(ctgAddBatch(pCtg, vgroupInfo->vgId, &vConn, tReq, reqType, msg, msgLen));
#else
SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
char dbFName[TSDB_DB_FNAME_LEN];
@@ -1099,7 +1174,7 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SNa
}
taosArrayPush(pTaskId, &pTask->taskId);
- CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, dbFName, ctx->vgId, reqType, msg, msgLen));
+ CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, NULL, dbFName, ctx->vgId, reqType, msg, msgLen));
#endif
}
@@ -1142,14 +1217,17 @@ int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S
}
if (pTask) {
- CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, (char*)tbFName));
+ CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, NULL, (char*)tbFName));
SRequestConnInfo vConn = {.pTrans = pConn->pTrans,
.requestId = pConn->requestId,
.requestObjRefId = pConn->requestObjRefId,
.mgmtEps = vgroupInfo->epSet};
#if CTG_BATCH_FETCH
- CTG_RET(ctgAddBatch(pCtg, vgroupInfo->vgId, &vConn, pTask, reqType, msg, msgLen));
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = -1;
+ CTG_RET(ctgAddBatch(pCtg, vgroupInfo->vgId, &vConn, &tReq, reqType, msg, msgLen));
#else
SCtgTbCfgCtx* ctx = (SCtgTbCfgCtx*)pTask->taskCtx;
char dbFName[TSDB_DB_FNAME_LEN];
@@ -1160,7 +1238,7 @@ int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S
}
taosArrayPush(pTaskId, &pTask->taskId);
- CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, dbFName, ctx->pVgInfo->vgId, reqType, msg, msgLen));
+ CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, NULL, dbFName, ctx->pVgInfo->vgId, reqType, msg, msgLen));
#endif
}
@@ -1201,9 +1279,13 @@ int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S
}
if (pTask) {
- CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, (char*)tbFName));
+ CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, NULL, (char*)tbFName));
+
#if CTG_BATCH_FETCH
- CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = -1;
+ CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
#else
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
if (NULL == pTaskId) {
@@ -1211,7 +1293,7 @@ int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S
}
taosArrayPush(pTaskId, &pTask->taskId);
- CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
+ CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
#endif
}
@@ -1246,10 +1328,13 @@ int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, char** ou
}
if (pTask) {
- CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, NULL));
+ CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, NULL, NULL));
#if CTG_BATCH_FETCH
- CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
+ SCtgTaskReq tReq;
+ tReq.pTask = pTask;
+ tReq.msgIdx = -1;
+ CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen));
#else
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
if (NULL == pTaskId) {
@@ -1257,7 +1342,7 @@ int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, char** ou
}
taosArrayPush(pTaskId, &pTask->taskId);
- CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
+ CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen));
#endif
}
diff --git a/source/libs/catalog/src/ctgUtil.c b/source/libs/catalog/src/ctgUtil.c
index bdf60b110b..8e5fb90f1a 100644
--- a/source/libs/catalog/src/ctgUtil.c
+++ b/source/libs/catalog/src/ctgUtil.c
@@ -26,6 +26,7 @@ void ctgFreeMsgSendParam(void* param) {
SCtgTaskCallbackParam* pParam = (SCtgTaskCallbackParam*)param;
taosArrayDestroy(pParam->taskId);
+ taosArrayDestroy(pParam->msgIdx);
taosMemoryFree(param);
}
@@ -88,6 +89,10 @@ char *ctgTaskTypeStr(CTG_TASK_TYPE type) {
return "[get user]";
case CTG_TASK_GET_SVR_VER:
return "[get svr ver]";
+ case CTG_TASK_GET_TB_META_BATCH:
+ return "[bget table meta]";
+ case CTG_TASK_GET_TB_HASH_BATCH:
+ return "[bget table hash]";
default:
return "unknown";
}
@@ -460,6 +465,25 @@ void ctgResetTbMetaTask(SCtgTask* pTask) {
taosMemoryFreeClear(pTask->res);
}
+void ctgFreeBatchMeta(void* meta) {
+ if (NULL == meta) {
+ return;
+ }
+
+ SMetaRes* pRes = (SMetaRes*)meta;
+ taosMemoryFreeClear(pRes->pRes);
+}
+
+void ctgFreeBatchHash(void* hash) {
+ if (NULL == hash) {
+ return;
+ }
+
+ SMetaRes* pRes = (SMetaRes*)hash;
+ taosMemoryFreeClear(pRes->pRes);
+}
+
+
void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) {
switch (type) {
case CTG_TASK_GET_QNODE:
@@ -500,6 +524,24 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) {
taosMemoryFreeClear(*pRes);
break;
}
+ case CTG_TASK_GET_TB_META_BATCH: {
+ SArray* pArray = (SArray*)*pRes;
+ int32_t num = taosArrayGetSize(pArray);
+ for (int32_t i = 0; i < num; ++i) {
+ ctgFreeBatchMeta(taosArrayGet(pArray, i));
+ }
+ *pRes = NULL; // no need to free it
+ break;
+ }
+ case CTG_TASK_GET_TB_HASH_BATCH: {
+ SArray* pArray = (SArray*)*pRes;
+ int32_t num = taosArrayGetSize(pArray);
+ for (int32_t i = 0; i < num; ++i) {
+ ctgFreeBatchHash(taosArrayGet(pArray, i));
+ }
+ *pRes = NULL; // no need to free it
+ break;
+ }
default:
qError("invalid task type %d", type);
break;
@@ -554,6 +596,16 @@ void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void **pRes) {
taosMemoryFreeClear(*pRes);
break;
}
+ case CTG_TASK_GET_TB_META_BATCH: {
+ taosArrayDestroyEx(*pRes, ctgFreeBatchMeta);
+ *pRes = NULL;
+ break;
+ }
+ case CTG_TASK_GET_TB_HASH_BATCH: {
+ taosArrayDestroyEx(*pRes, ctgFreeBatchHash);
+ *pRes = NULL;
+ break;
+ }
default:
qError("invalid task type %d", type);
break;
@@ -583,12 +635,38 @@ void ctgFreeTaskCtx(SCtgTask* pTask) {
taosMemoryFreeClear(pTask->taskCtx);
break;
}
+ case CTG_TASK_GET_TB_META_BATCH: {
+ SCtgTbMetasCtx* taskCtx = (SCtgTbMetasCtx*)pTask->taskCtx;
+ taosArrayDestroyEx(taskCtx->pResList, ctgFreeBatchMeta);
+ taosArrayDestroy(taskCtx->pFetchs);
+ // NO NEED TO FREE pNames
+
+ taosArrayDestroyEx(pTask->msgCtxs, (FDelete)ctgFreeMsgCtx);
+
+ if (pTask->msgCtx.lastOut) {
+ ctgFreeSTableMetaOutput((STableMetaOutput*)pTask->msgCtx.lastOut);
+ pTask->msgCtx.lastOut = NULL;
+ }
+ taosMemoryFreeClear(pTask->taskCtx);
+ break;
+ }
case CTG_TASK_GET_TB_HASH: {
SCtgTbHashCtx* taskCtx = (SCtgTbHashCtx*)pTask->taskCtx;
taosMemoryFreeClear(taskCtx->pName);
taosMemoryFreeClear(pTask->taskCtx);
break;
}
+ case CTG_TASK_GET_TB_HASH_BATCH: {
+ SCtgTbHashsCtx* taskCtx = (SCtgTbHashsCtx*)pTask->taskCtx;
+ taosArrayDestroyEx(taskCtx->pResList, ctgFreeBatchHash);
+ taosArrayDestroy(taskCtx->pFetchs);
+ // NO NEED TO FREE pNames
+
+ taosArrayDestroyEx(pTask->msgCtxs, (FDelete)ctgFreeMsgCtx);
+
+ taosMemoryFreeClear(pTask->taskCtx);
+ break;
+ }
case CTG_TASK_GET_TB_INDEX: {
SCtgTbIndexCtx* taskCtx = (SCtgTbIndexCtx*)pTask->taskCtx;
taosMemoryFreeClear(taskCtx->pName);
@@ -679,6 +757,23 @@ int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* targ
return TSDB_CODE_SUCCESS;
}
+int32_t ctgAddMsgCtx(SArray* pCtxs, int32_t reqType, void* out, char* target) {
+ SCtgMsgCtx ctx = {0};
+
+ ctx.reqType = reqType;
+ ctx.out = out;
+ if (target) {
+ ctx.target = strdup(target);
+ if (NULL == ctx.target) {
+ CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
+ }
+ }
+
+ taosArrayPush(pCtxs, &ctx);
+
+ return TSDB_CODE_SUCCESS;
+}
+
int32_t ctgGetHashFunction(int8_t hashMethod, tableNameHashFp *fp) {
switch (hashMethod) {
@@ -780,6 +875,104 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName
CTG_RET(code);
}
+int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo *dbInfo, SCtgTbHashsCtx *pCtx, char* dbFName, SArray* pNames, bool update) {
+ int32_t code = 0;
+ SCtgTask* pTask = tReq->pTask;
+ SMetaRes res = {0};
+ int32_t vgNum = taosHashGetSize(dbInfo->vgHash);
+ if (vgNum <= 0) {
+ ctgError("db vgroup cache invalid, db:%s, vgroup number:%d", dbFName, vgNum);
+ CTG_ERR_RET(TSDB_CODE_TSC_DB_NOT_SELECTED);
+ }
+
+ tableNameHashFp fp = NULL;
+ SVgroupInfo *vgInfo = NULL;
+
+ CTG_ERR_RET(ctgGetHashFunction(dbInfo->hashMethod, &fp));
+
+ int32_t tbNum = taosArrayGetSize(pNames);
+
+ if (1 == vgNum) {
+ void *pIter = taosHashIterate(dbInfo->vgHash, NULL);
+ for (int32_t i = 0; i < tbNum; ++i) {
+ vgInfo = taosMemoryMalloc(sizeof(SVgroupInfo));
+ if (NULL == vgInfo) {
+ CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
+ }
+
+ *vgInfo = *(SVgroupInfo*)pIter;
+
+ ctgDebug("Got tb hash vgroup, vgId:%d, epNum %d, current %s port %d", vgInfo->vgId, vgInfo->epSet.numOfEps,
+ vgInfo->epSet.eps[vgInfo->epSet.inUse].fqdn, vgInfo->epSet.eps[vgInfo->epSet.inUse].port);
+
+ if (update) {
+ SCtgFetch* pFetch = taosArrayGet(pCtx->pFetchs, tReq->msgIdx);
+ SMetaRes *pRes = taosArrayGet(pCtx->pResList, pFetch->resIdx + i);
+ pRes->pRes = vgInfo;
+ } else {
+ res.pRes = vgInfo;
+ taosArrayPush(pCtx->pResList, &res);
+ }
+ }
+
+ return TSDB_CODE_SUCCESS;
+ }
+
+ char tbFullName[TSDB_TABLE_FNAME_LEN];
+ sprintf(tbFullName, "%s.", dbFName);
+ int32_t offset = strlen(tbFullName);
+ SName* pName = NULL;
+ int32_t tbNameLen = 0;
+
+ for (int32_t i = 0; i < tbNum; ++i) {
+ pName = taosArrayGet(pNames, i);
+
+ tbNameLen = offset + strlen(pName->tname);
+ strcpy(tbFullName + offset, pName->tname);
+
+ uint32_t hashValue = (*fp)(tbFullName, (uint32_t)tbNameLen);
+
+ void *pIter = taosHashIterate(dbInfo->vgHash, NULL);
+ while (pIter) {
+ vgInfo = pIter;
+ if (hashValue >= vgInfo->hashBegin && hashValue <= vgInfo->hashEnd) {
+ taosHashCancelIterate(dbInfo->vgHash, pIter);
+ break;
+ }
+
+ pIter = taosHashIterate(dbInfo->vgHash, pIter);
+ vgInfo = NULL;
+ }
+
+ if (NULL == vgInfo) {
+ ctgError("no hash range found for hash value [%u], db:%s, numOfVgId:%d", hashValue, dbFName, taosHashGetSize(dbInfo->vgHash));
+ CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
+ }
+
+ SVgroupInfo* pNewVg = taosMemoryMalloc(sizeof(SVgroupInfo));
+ if (NULL == pNewVg) {
+ CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
+ }
+
+ *pNewVg = *vgInfo;
+
+ ctgDebug("Got tb %s hash vgroup, vgId:%d, epNum %d, current %s port %d", tbFullName, vgInfo->vgId, vgInfo->epSet.numOfEps,
+ vgInfo->epSet.eps[vgInfo->epSet.inUse].fqdn, vgInfo->epSet.eps[vgInfo->epSet.inUse].port);
+
+ if (update) {
+ SCtgFetch* pFetch = taosArrayGet(pCtx->pFetchs, tReq->msgIdx);
+ SMetaRes *pRes = taosArrayGet(pCtx->pResList, pFetch->resIdx + i);
+ pRes->pRes = pNewVg;
+ } else {
+ res.pRes = pNewVg;
+ taosArrayPush(pCtx->pResList, &res);
+ }
+ }
+
+ CTG_RET(code);
+}
+
+
int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2) {
if (*(uint64_t *)key1 < ((SSTableVersion*)key2)->suid) {
return -1;
@@ -921,4 +1114,41 @@ int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, cha
return TSDB_CODE_SUCCESS;
}
+int32_t ctgGetTablesReqNum(SArray *pList) {
+ if (NULL == pList) {
+ return 0;
+ }
+
+ int32_t total = 0;
+ int32_t n = taosArrayGetSize(pList);
+ for (int32_t i = 0; i < n; ++i) {
+ STablesReq *pReq = taosArrayGet(pList, i);
+ total += taosArrayGetSize(pReq->pTables);
+ }
+
+ return total;
+}
+
+int32_t ctgAddFetch(SArray** pFetchs, int32_t dbIdx, int32_t tbIdx, int32_t *fetchIdx, int32_t resIdx, int32_t flag) {
+ if (NULL == (*pFetchs)) {
+ *pFetchs = taosArrayInit(CTG_DEFAULT_FETCH_NUM, sizeof(SCtgFetch));
+ }
+
+ SCtgFetch fetch = {0};
+ fetch.dbIdx = dbIdx;
+ fetch.tbIdx = tbIdx;
+ fetch.fetchIdx = (*fetchIdx)++;
+ fetch.resIdx = resIdx;
+ fetch.flag = flag;
+
+ taosArrayPush(*pFetchs, &fetch);
+
+ return TSDB_CODE_SUCCESS;
+}
+
+SName* ctgGetFetchName(SArray* pNames, SCtgFetch* pFetch) {
+ STablesReq* pReq = (STablesReq*)taosArrayGet(pNames, pFetch->dbIdx);
+ return (SName*)taosArrayGet(pReq->pTables, pFetch->tbIdx);
+}
+
diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h
index b62ff2bef1..f8a7ab330f 100644
--- a/source/libs/executor/inc/executorimpl.h
+++ b/source/libs/executor/inc/executorimpl.h
@@ -737,6 +737,9 @@ typedef struct STimeSliceOperatorInfo {
SInterval interval;
int64_t current;
SArray* pPrevRow; // SArray
+ SArray* pNextRow; // SArray
+ bool isPrevRowSet;
+ bool isNextRowSet;
int32_t fillType; // fill type
SColumn tsCol; // primary timestamp column
SExprSupp scalarSup; // scalar calculation
diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c
index 6bbfca804f..34247d3b47 100644
--- a/source/libs/executor/src/executil.c
+++ b/source/libs/executor/src/executil.c
@@ -191,6 +191,7 @@ SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode) {
pBlock->info.blockId = pNode->dataBlockId;
pBlock->info.type = STREAM_INVALID;
pBlock->info.calWin = (STimeWindow){.skey = INT64_MIN, .ekey = INT64_MAX};
+ pBlock->info.watermark = INT64_MIN;
for (int32_t i = 0; i < numOfCols; ++i) {
SSlotDescNode* pDescNode = (SSlotDescNode*)nodesListGetNode(pNode->pSlots, i);
diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c
index c1a3d19b6d..eaffbc2579 100644
--- a/source/libs/executor/src/executorimpl.c
+++ b/source/libs/executor/src/executorimpl.c
@@ -4180,7 +4180,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
int32_t children = 0;
pOptr = createStreamFinalSessionAggOperatorInfo(ops[0], pPhyNode, pTaskInfo, children);
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION == type) {
- int32_t children = 1;
+ int32_t children = pHandle->numOfVgroups;
pOptr = createStreamFinalSessionAggOperatorInfo(ops[0], pPhyNode, pTaskInfo, children);
} else if (QUERY_NODE_PHYSICAL_PLAN_PARTITION == type) {
pOptr = createPartitionOperatorInfo(ops[0], (SPartitionPhysiNode*)pPhyNode, pTaskInfo);
diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c
index 0fccc40889..e7d9a8d8b2 100644
--- a/source/libs/executor/src/timewindowoperator.c
+++ b/source/libs/executor/src/timewindowoperator.c
@@ -1752,30 +1752,11 @@ void increaseTs(SqlFunctionCtx* pCtx) {
}
}
-SSDataBlock* createDeleteBlock() {
- SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
- pBlock->info.hasVarCol = false;
- pBlock->info.groupId = 0;
- pBlock->info.rows = 0;
- pBlock->info.type = STREAM_DELETE_RESULT;
- pBlock->info.rowSize = sizeof(TSKEY) + sizeof(uint64_t);
-
- pBlock->pDataBlock = taosArrayInit(2, sizeof(SColumnInfoData));
- SColumnInfoData infoData = {0};
- infoData.info.type = TSDB_DATA_TYPE_TIMESTAMP;
- infoData.info.bytes = sizeof(TSKEY);
- // window start ts
- taosArrayPush(pBlock->pDataBlock, &infoData);
-
- infoData.info.type = TSDB_DATA_TYPE_UBIGINT;
- infoData.info.bytes = sizeof(uint64_t);
- taosArrayPush(pBlock->pDataBlock, &infoData);
-
- return pBlock;
-}
-
void initIntervalDownStream(SOperatorInfo* downstream, uint8_t type, SAggSupporter* pSup) {
- ASSERT(downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN);
+ if (downstream->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
+ // Todo(liuyao) support partition by column
+ return;
+ }
SStreamScanInfo* pScanInfo = downstream->info;
pScanInfo->sessionSup.parentType = type;
pScanInfo->sessionSup.pIntervalAggSup = pSup;
@@ -2084,10 +2065,30 @@ static void doKeepPrevRows(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlock
memcpy(pkey->pData, val, pkey->bytes);
}
}
+
+ pSliceInfo->isPrevRowSet = true;
+}
+
+static void doKeepNextRows(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlock* pBlock, int32_t rowIndex) {
+ int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
+ for (int32_t i = 0; i < numOfCols; ++i) {
+ SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
+
+ // null data should not be kept since it can not be used to perform interpolation
+ if (!colDataIsNull_s(pColInfoData, i)) {
+ SGroupKeys* pkey = taosArrayGet(pSliceInfo->pNextRow, i);
+
+ pkey->isNull = false;
+ char* val = colDataGetData(pColInfoData, rowIndex);
+ memcpy(pkey->pData, val, pkey->bytes);
+ }
+ }
+
+ pSliceInfo->isNextRowSet = true;
}
static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp* pExprSup, SSDataBlock* pBlock,
- int32_t rowIndex, SSDataBlock* pResBlock) {
+ SSDataBlock* pResBlock) {
int32_t rows = pResBlock->info.rows;
// todo set the correct primary timestamp column
@@ -2163,6 +2164,10 @@ static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
break;
}
case TSDB_FILL_PREV: {
+ if (!pSliceInfo->isPrevRowSet) {
+ break;
+ }
+
SGroupKeys* pkey = taosArrayGet(pSliceInfo->pPrevRow, srcSlot);
colDataAppend(pDst, rows, pkey->pData, false);
pResBlock->info.rows += 1;
@@ -2170,8 +2175,12 @@ static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
}
case TSDB_FILL_NEXT: {
- char* p = colDataGetData(pSrc, rowIndex);
- colDataAppend(pDst, rows, p, colDataIsNull_s(pSrc, rowIndex));
+ if (!pSliceInfo->isNextRowSet) {
+ break;
+ }
+
+ SGroupKeys* pkey = taosArrayGet(pSliceInfo->pNextRow, srcSlot);
+ colDataAppend(pDst, rows, pkey->pData, false);
pResBlock->info.rows += 1;
break;
}
@@ -2205,6 +2214,35 @@ static int32_t initPrevRowsKeeper(STimeSliceOperatorInfo* pInfo, SSDataBlock* pB
taosArrayPush(pInfo->pPrevRow, &key);
}
+ pInfo->isPrevRowSet = false;
+
+ return TSDB_CODE_SUCCESS;
+}
+
+static int32_t initNextRowsKeeper(STimeSliceOperatorInfo* pInfo, SSDataBlock* pBlock) {
+ if (pInfo->pNextRow != NULL) {
+ return TSDB_CODE_SUCCESS;
+ }
+
+ pInfo->pNextRow = taosArrayInit(4, sizeof(SGroupKeys));
+ if (pInfo->pNextRow == NULL) {
+ return TSDB_CODE_OUT_OF_MEMORY;
+ }
+
+ int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
+ for (int32_t i = 0; i < numOfCols; ++i) {
+ SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, i);
+
+ SGroupKeys key = {0};
+ key.bytes = pColInfo->info.bytes;
+ key.type = pColInfo->info.type;
+ key.isNull = false;
+ key.pData = taosMemoryCalloc(1, pColInfo->info.bytes);
+ taosArrayPush(pInfo->pNextRow, &key);
+ }
+
+ pInfo->isNextRowSet = false;
+
return TSDB_CODE_SUCCESS;
}
@@ -2234,14 +2272,19 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
blockDataCleanup(pResBlock);
- int32_t numOfRows = 0;
while (1) {
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
if (pBlock == NULL) {
break;
}
- int32_t code = initPrevRowsKeeper(pSliceInfo, pBlock);
+ int32_t code;
+ code = initPrevRowsKeeper(pSliceInfo, pBlock);
+ if (code != TSDB_CODE_SUCCESS) {
+ longjmp(pTaskInfo->env, code);
+ }
+
+ code = initNextRowsKeeper(pSliceInfo, pBlock);
if (code != TSDB_CODE_SUCCESS) {
longjmp(pTaskInfo->env, code);
}
@@ -2263,7 +2306,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
SColumnInfoData* pDst = taosArrayGet(pResBlock->pDataBlock, dstSlot);
char* v = colDataGetData(pSrc, i);
- colDataAppend(pDst, numOfRows, v, false);
+ colDataAppend(pDst, pResBlock->info.rows, v, false);
}
pResBlock->info.rows += 1;
@@ -2280,11 +2323,16 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
break;
}
} else if (ts < pSliceInfo->current) {
+ // in case interpolation window starts and ends between two datapoints, fill(prev) need to interpolate
+ doKeepPrevRows(pSliceInfo, pBlock, i);
+
if (i < pBlock->info.rows - 1) {
+ // in case interpolation window starts and ends between two datapoints, fill(next) need to interpolate
+ doKeepNextRows(pSliceInfo, pBlock, i + 1);
int64_t nextTs = *(int64_t*)colDataGetData(pTsCol, i + 1);
if (nextTs > pSliceInfo->current) {
while (pSliceInfo->current < nextTs && pSliceInfo->current <= pSliceInfo->win.ekey) {
- genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pBlock, i, pResBlock);
+ genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pBlock, pResBlock);
pSliceInfo->current =
taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
if (pResBlock->info.rows >= pResBlock->info.capacity) {
@@ -2303,8 +2351,11 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
doKeepPrevRows(pSliceInfo, pBlock, i);
}
} else { // ts > pSliceInfo->current
+ // in case interpolation window starts and ends between two datapoints, fill(next) need to interpolate
+ doKeepNextRows(pSliceInfo, pBlock, i);
+
while (pSliceInfo->current < ts && pSliceInfo->current <= pSliceInfo->win.ekey) {
- genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pBlock, i, pResBlock);
+ genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pBlock, pResBlock);
pSliceInfo->current =
taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
if (pResBlock->info.rows >= pResBlock->info.capacity) {
@@ -2312,12 +2363,48 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
}
}
+ // add current row if timestamp match
+ if (ts == pSliceInfo->current && pSliceInfo->current <= pSliceInfo->win.ekey) {
+ for (int32_t j = 0; j < pOperator->exprSupp.numOfExprs; ++j) {
+ SExprInfo* pExprInfo = &pOperator->exprSupp.pExprInfo[j];
+ int32_t dstSlot = pExprInfo->base.resSchema.slotId;
+ int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId;
+
+ SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, srcSlot);
+ SColumnInfoData* pDst = taosArrayGet(pResBlock->pDataBlock, dstSlot);
+
+ char* v = colDataGetData(pSrc, i);
+ colDataAppend(pDst, pResBlock->info.rows, v, false);
+ }
+
+ pResBlock->info.rows += 1;
+ doKeepPrevRows(pSliceInfo, pBlock, i);
+
+ pSliceInfo->current =
+ taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
+
+ if (pResBlock->info.rows >= pResBlock->info.capacity) {
+ break;
+ }
+ }
+
if (pSliceInfo->current > pSliceInfo->win.ekey) {
doSetOperatorCompleted(pOperator);
break;
}
}
}
+
+ // check if need to interpolate after ts range
+ // except for fill(next)
+ while (pSliceInfo->current <= pSliceInfo->win.ekey && pSliceInfo->fillType != TSDB_FILL_NEXT) {
+ genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pBlock, pResBlock);
+ pSliceInfo->current =
+ taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
+ if (pResBlock->info.rows >= pResBlock->info.capacity) {
+ break;
+ }
+ }
}
// restore the value
@@ -2836,13 +2923,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
// process the rest of the data
return pInfo->pUpdateRes;
}
- // doBuildPullDataBlock(pInfo->pPullWins, &pInfo->pullIndex, pInfo->pPullDataRes);
- // if (pInfo->pPullDataRes->info.rows != 0) {
- // // process the rest of the data
- // ASSERT(IS_FINAL_OP(pInfo));
- // printDataBlock(pInfo->pPullDataRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi");
- // return pInfo->pPullDataRes;
- // }
doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes);
if (pInfo->pDelRes->info.rows != 0) {
// process the rest of the data
@@ -2862,6 +2942,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
}
printDataBlock(pBlock, IS_FINAL_OP(pInfo) ? "interval final recv" : "interval semi recv");
maxTs = TMAX(maxTs, pBlock->info.window.ekey);
+ maxTs = TMAX(maxTs, pBlock->info.watermark);
if (pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_PULL_DATA ||
pBlock->info.type == STREAM_INVALID) {
@@ -2950,6 +3031,8 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
closeIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, pInfo->pPullDataMap,
pUpdated, pInfo->pRecycledPages, pInfo->aggSup.pResultBuf);
closeChildIntervalWindow(pInfo->pChildren, pInfo->twAggSup.maxTs);
+ } else {
+ pInfo->binfo.pRes->info.watermark = pInfo->twAggSup.maxTs;
}
finalizeUpdatedResult(pOperator->exprSupp.numOfExprs, pInfo->aggSup.pResultBuf, pUpdated, pSup->rowEntryInfoOffset);
@@ -2984,7 +3067,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi");
return pInfo->pDelRes;
}
- // ASSERT(false);
return NULL;
}
@@ -2996,6 +3078,7 @@ SSDataBlock* createSpecialDataBlock(EStreamType type) {
pBlock->info.type = type;
pBlock->info.rowSize =
sizeof(TSKEY) + sizeof(TSKEY) + sizeof(uint64_t) + sizeof(uint64_t) + sizeof(TSKEY) + sizeof(TSKEY);
+ pBlock->info.watermark = INT64_MIN;
pBlock->pDataBlock = taosArrayInit(6, sizeof(SColumnInfoData));
SColumnInfoData infoData = {0};
@@ -3185,7 +3268,6 @@ void destroyStreamSessionAggOperatorInfo(void* param, int32_t numOfOutput) {
SStreamSessionAggOperatorInfo* pChInfo = pChild->info;
destroyStreamSessionAggOperatorInfo(pChInfo, numOfOutput);
taosMemoryFreeClear(pChild);
- taosMemoryFreeClear(pChInfo);
}
}
colDataDestroy(&pInfo->twAggSup.timeWindowData);
@@ -3950,6 +4032,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
doStreamSessionAggImpl(pChildOp, pBlock, NULL, NULL, true);
}
maxTs = TMAX(maxTs, pBlock->info.window.ekey);
+ maxTs = TMAX(maxTs, pBlock->info.watermark);
}
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs);
@@ -4073,6 +4156,7 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
}
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs);
+ pBInfo->pRes->info.watermark = pInfo->twAggSup.maxTs;
// restore the value
pOperator->status = OP_RES_TO_RETURN;
// semi operator
diff --git a/source/libs/parser/inc/parUtil.h b/source/libs/parser/inc/parUtil.h
index b010e4b9e3..2249bc7823 100644
--- a/source/libs/parser/inc/parUtil.h
+++ b/source/libs/parser/inc/parUtil.h
@@ -39,6 +39,11 @@ typedef struct SMsgBuf {
char* buf;
} SMsgBuf;
+typedef struct SParseTablesMetaReq {
+ char dbFName[TSDB_DB_FNAME_LEN];
+ SHashObj* pTables;
+} SParseTablesMetaReq;
+
typedef struct SParseMetaCache {
SHashObj* pTableMeta; // key is tbFName, element is STableMeta*
SHashObj* pDbVgroup; // key is dbFName, element is SArray*
@@ -95,7 +100,7 @@ int32_t getUdfInfoFromCache(SParseMetaCache* pMetaCache, const char* pFunc, SFun
int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName, SArray** pIndexes);
int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableCfg** pOutput);
int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes);
-void destoryParseMetaCache(SParseMetaCache* pMetaCache);
+void destoryParseMetaCache(SParseMetaCache* pMetaCache, bool request);
#ifdef __cplusplus
}
diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c
index db14a4f1c3..9971f20d3d 100644
--- a/source/libs/parser/src/parTranslater.c
+++ b/source/libs/parser/src/parTranslater.c
@@ -1253,20 +1253,21 @@ static int32_t translateRepeatScanFunc(STranslateContext* pCxt, SFunctionNode* p
if (!fmIsRepeatScanFunc(pFunc->funcId)) {
return TSDB_CODE_SUCCESS;
}
- if (isSelectStmt(pCxt->pCurrStmt)) {
- // select percentile() without from clause is also valid
- if (NULL == ((SSelectStmt*)pCxt->pCurrStmt)->pFromTable) {
- return TSDB_CODE_SUCCESS;
- }
- SNode* pTable = ((SSelectStmt*)pCxt->pCurrStmt)->pFromTable;
- if (QUERY_NODE_REAL_TABLE == nodeType(pTable) &&
- (TSDB_CHILD_TABLE == ((SRealTableNode*)pTable)->pMeta->tableType ||
- TSDB_NORMAL_TABLE == ((SRealTableNode*)pTable)->pMeta->tableType)) {
- return TSDB_CODE_SUCCESS;
- }
+ if (!isSelectStmt(pCxt->pCurrStmt)) {
+ return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE,
+ "%s is only supported in single table query", pFunc->functionName);
}
- return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE,
- "%s is only supported in single table query", pFunc->functionName);
+ SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt;
+ SNode* pTable = pSelect->pFromTable;
+ // select percentile() without from clause is also valid
+ if ((NULL != pTable && (QUERY_NODE_REAL_TABLE != nodeType(pTable) ||
+ (TSDB_CHILD_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType &&
+ TSDB_NORMAL_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType))) ||
+ NULL != pSelect->pPartitionByList) {
+ return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE,
+ "%s is only supported in single table query", pFunc->functionName);
+ }
+ return TSDB_CODE_SUCCESS;
}
static bool isStar(SNode* pNode) {
@@ -2509,9 +2510,31 @@ static EDealRes checkStateExpr(SNode* pNode, void* pContext) {
return DEAL_RES_CONTINUE;
}
-static int32_t translateStateWindow(STranslateContext* pCxt, SStateWindowNode* pState) {
+static bool isPartitionByTbname(SNodeList* pPartitionByList) {
+ if (1 != LIST_LENGTH(pPartitionByList)) {
+ return false;
+ }
+ SNode* pPartKey = nodesListGetNode(pPartitionByList, 0);
+ return QUERY_NODE_FUNCTION != nodeType(pPartKey) || FUNCTION_TYPE_TBNAME != ((SFunctionNode*)pPartKey)->funcType;
+}
+
+static int32_t checkStateWindowForStream(STranslateContext* pCxt, SSelectStmt* pSelect) {
+ if (!pCxt->createStream) {
+ return TSDB_CODE_SUCCESS;
+ }
+ if (TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType &&
+ !isPartitionByTbname(pSelect->pPartitionByList)) {
+ return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Unsupported stream query");
+ }
+ return TSDB_CODE_SUCCESS;
+}
+
+static int32_t translateStateWindow(STranslateContext* pCxt, SSelectStmt* pSelect) {
+ SStateWindowNode* pState = (SStateWindowNode*)pSelect->pWindow;
nodesWalkExprPostOrder(pState->pExpr, checkStateExpr, pCxt);
- // todo check for "function not support for state_window"
+ if (TSDB_CODE_SUCCESS == pCxt->errCode) {
+ pCxt->errCode = checkStateWindowForStream(pCxt, pSelect);
+ }
return pCxt->errCode;
}
@@ -2522,14 +2545,13 @@ static int32_t translateSessionWindow(STranslateContext* pCxt, SSessionWindowNod
if (PRIMARYKEY_TIMESTAMP_COL_ID != pSession->pCol->colId) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SESSION_COL);
}
- // todo check for "function not support for session"
return TSDB_CODE_SUCCESS;
}
static int32_t translateSpecificWindow(STranslateContext* pCxt, SSelectStmt* pSelect) {
switch (nodeType(pSelect->pWindow)) {
case QUERY_NODE_STATE_WINDOW:
- return translateStateWindow(pCxt, (SStateWindowNode*)pSelect->pWindow);
+ return translateStateWindow(pCxt, pSelect);
case QUERY_NODE_SESSION_WINDOW:
return translateSessionWindow(pCxt, (SSessionWindowNode*)pSelect->pWindow);
case QUERY_NODE_INTERVAL_WINDOW:
@@ -4708,7 +4730,7 @@ static int32_t checkCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pSt
}
}
- return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY);
+ return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Unsupported stream query");
}
static void getSourceDatabase(SNode* pStmt, int32_t acctId, char* pDbFName) {
diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c
index e51800aece..ae5a281aab 100644
--- a/source/libs/parser/src/parUtil.c
+++ b/source/libs/parser/src/parUtil.c
@@ -474,6 +474,24 @@ static int32_t buildDbReq(SHashObj* pDbsHash, SArray** pDbs) {
return TSDB_CODE_SUCCESS;
}
+static int32_t buildTableReqFromDb(SHashObj* pDbsHash, SArray** pDbs) {
+ if (NULL != pDbsHash) {
+ *pDbs = taosArrayInit(taosHashGetSize(pDbsHash), sizeof(STablesReq));
+ if (NULL == *pDbs) {
+ return TSDB_CODE_OUT_OF_MEMORY;
+ }
+ SParseTablesMetaReq* p = taosHashIterate(pDbsHash, NULL);
+ while (NULL != p) {
+ STablesReq req = {0};
+ strcpy(req.dbFName, p->dbFName);
+ buildTableReq(p->pTables, &req.pTables);
+ taosArrayPush(*pDbs, &req);
+ p = taosHashIterate(pDbsHash, p);
+ }
+ }
+ return TSDB_CODE_SUCCESS;
+}
+
static int32_t buildUserAuthReq(SHashObj* pUserAuthHash, SArray** pUserAuth) {
if (NULL != pUserAuthHash) {
*pUserAuth = taosArrayInit(taosHashGetSize(pUserAuthHash), sizeof(SUserAuthInfo));
@@ -513,12 +531,12 @@ static int32_t buildUdfReq(SHashObj* pUdfHash, SArray** pUdf) {
}
int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalogReq) {
- int32_t code = buildTableReq(pMetaCache->pTableMeta, &pCatalogReq->pTableMeta);
+ int32_t code = buildTableReqFromDb(pMetaCache->pTableMeta, &pCatalogReq->pTableMeta);
if (TSDB_CODE_SUCCESS == code) {
code = buildDbReq(pMetaCache->pDbVgroup, &pCatalogReq->pDbVgroup);
}
if (TSDB_CODE_SUCCESS == code) {
- code = buildTableReq(pMetaCache->pTableVgroup, &pCatalogReq->pTableHash);
+ code = buildTableReqFromDb(pMetaCache->pTableVgroup, &pCatalogReq->pTableHash);
}
if (TSDB_CODE_SUCCESS == code) {
code = buildDbReq(pMetaCache->pDbCfg, &pCatalogReq->pDbCfg);
@@ -587,6 +605,24 @@ static int32_t putDbDataToCache(const SArray* pDbReq, const SArray* pDbData, SHa
return TSDB_CODE_SUCCESS;
}
+static int32_t putDbTableDataToCache(const SArray* pDbReq, const SArray* pTableData, SHashObj** pTable) {
+ int32_t ndbs = taosArrayGetSize(pDbReq);
+ int32_t tableNo = 0;
+ for (int32_t i = 0; i < ndbs; ++i) {
+ STablesReq* pReq = taosArrayGet(pDbReq, i);
+ int32_t ntables = taosArrayGetSize(pReq->pTables);
+ for (int32_t j = 0; j < ntables; ++j) {
+ char fullName[TSDB_TABLE_FNAME_LEN];
+ tNameExtractFullName(taosArrayGet(pReq->pTables, j), fullName);
+ if (TSDB_CODE_SUCCESS != putMetaDataToHash(fullName, strlen(fullName), pTableData, tableNo, pTable)) {
+ return TSDB_CODE_OUT_OF_MEMORY;
+ }
+ ++tableNo;
+ }
+ }
+ return TSDB_CODE_SUCCESS;
+}
+
static int32_t putUserAuthToCache(const SArray* pUserAuthReq, const SArray* pUserAuthData, SHashObj** pUserAuth) {
int32_t nvgs = taosArrayGetSize(pUserAuthReq);
for (int32_t i = 0; i < nvgs; ++i) {
@@ -612,12 +648,12 @@ static int32_t putUdfToCache(const SArray* pUdfReq, const SArray* pUdfData, SHas
}
int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMetaData, SParseMetaCache* pMetaCache) {
- int32_t code = putTableDataToCache(pCatalogReq->pTableMeta, pMetaData->pTableMeta, &pMetaCache->pTableMeta);
+ int32_t code = putDbTableDataToCache(pCatalogReq->pTableMeta, pMetaData->pTableMeta, &pMetaCache->pTableMeta);
if (TSDB_CODE_SUCCESS == code) {
code = putDbDataToCache(pCatalogReq->pDbVgroup, pMetaData->pDbVgroup, &pMetaCache->pDbVgroup);
}
if (TSDB_CODE_SUCCESS == code) {
- code = putTableDataToCache(pCatalogReq->pTableHash, pMetaData->pTableHash, &pMetaCache->pTableVgroup);
+ code = putDbTableDataToCache(pCatalogReq->pTableHash, pMetaData->pTableHash, &pMetaCache->pTableVgroup);
}
if (TSDB_CODE_SUCCESS == code) {
code = putDbDataToCache(pCatalogReq->pDbCfg, pMetaData->pDbCfg, &pMetaCache->pDbCfg);
@@ -657,14 +693,38 @@ static int32_t reserveTableReqInCache(int32_t acctId, const char* pDb, const cha
return reserveTableReqInCacheImpl(fullName, len, pTables);
}
+static int32_t reserveTableReqInDbCacheImpl(int32_t acctId, const char* pDb, const char* pTable, SHashObj* pDbs) {
+ SParseTablesMetaReq req = {0};
+ int32_t len = snprintf(req.dbFName, sizeof(req.dbFName), "%d.%s", acctId, pDb);
+ int32_t code = reserveTableReqInCache(acctId, pDb, pTable, &req.pTables);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = taosHashPut(pDbs, req.dbFName, len, &req, sizeof(SParseTablesMetaReq));
+ }
+ return code;
+}
+
+static int32_t reserveTableReqInDbCache(int32_t acctId, const char* pDb, const char* pTable, SHashObj** pDbs) {
+ if (NULL == *pDbs) {
+ *pDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
+ if (NULL == *pDbs) {
+ return TSDB_CODE_OUT_OF_MEMORY;
+ }
+ }
+ char fullName[TSDB_DB_FNAME_LEN];
+ int32_t len = snprintf(fullName, sizeof(fullName), "%d.%s", acctId, pDb);
+ SParseTablesMetaReq* pReq = taosHashGet(*pDbs, fullName, len);
+ if (NULL == pReq) {
+ return reserveTableReqInDbCacheImpl(acctId, pDb, pTable, *pDbs);
+ }
+ return reserveTableReqInCache(acctId, pDb, pTable, &pReq->pTables);
+}
+
int32_t reserveTableMetaInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache) {
- return reserveTableReqInCache(acctId, pDb, pTable, &pMetaCache->pTableMeta);
+ return reserveTableReqInDbCache(acctId, pDb, pTable, &pMetaCache->pTableMeta);
}
int32_t reserveTableMetaInCacheExt(const SName* pName, SParseMetaCache* pMetaCache) {
- char fullName[TSDB_TABLE_FNAME_LEN];
- tNameExtractFullName(pName, fullName);
- return reserveTableReqInCacheImpl(fullName, strlen(fullName), &pMetaCache->pTableMeta);
+ return reserveTableReqInDbCache(pName->acctId, pName->dbname, pName->tname, &pMetaCache->pTableMeta);
}
int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta) {
@@ -711,13 +771,11 @@ int32_t getDbVgInfoFromCache(SParseMetaCache* pMetaCache, const char* pDbFName,
}
int32_t reserveTableVgroupInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache) {
- return reserveTableReqInCache(acctId, pDb, pTable, &pMetaCache->pTableVgroup);
+ return reserveTableReqInDbCache(acctId, pDb, pTable, &pMetaCache->pTableVgroup);
}
int32_t reserveTableVgroupInCacheExt(const SName* pName, SParseMetaCache* pMetaCache) {
- char fullName[TSDB_TABLE_FNAME_LEN];
- tNameExtractFullName(pName, fullName);
- return reserveTableReqInCacheImpl(fullName, strlen(fullName), &pMetaCache->pTableVgroup);
+ return reserveTableReqInDbCache(pName->acctId, pName->dbname, pName->tname, &pMetaCache->pTableVgroup);
}
int32_t getTableVgroupFromCache(SParseMetaCache* pMetaCache, const SName* pName, SVgroupInfo* pVgroup) {
@@ -919,10 +977,24 @@ int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes) {
return TSDB_CODE_SUCCESS;
}
-void destoryParseMetaCache(SParseMetaCache* pMetaCache) {
- taosHashCleanup(pMetaCache->pTableMeta);
+void destoryParseTablesMetaReqHash(SHashObj* pHash) {
+ SParseTablesMetaReq* p = taosHashIterate(pHash, NULL);
+ while (NULL != p) {
+ taosHashCleanup(p->pTables);
+ p = taosHashIterate(pHash, p);
+ }
+ taosHashCleanup(pHash);
+}
+
+void destoryParseMetaCache(SParseMetaCache* pMetaCache, bool request) {
+ if (request) {
+ destoryParseTablesMetaReqHash(pMetaCache->pTableMeta);
+ destoryParseTablesMetaReqHash(pMetaCache->pTableVgroup);
+ } else {
+ taosHashCleanup(pMetaCache->pTableMeta);
+ taosHashCleanup(pMetaCache->pTableVgroup);
+ }
taosHashCleanup(pMetaCache->pDbVgroup);
- taosHashCleanup(pMetaCache->pTableVgroup);
taosHashCleanup(pMetaCache->pDbCfg);
taosHashCleanup(pMetaCache->pDbInfo);
taosHashCleanup(pMetaCache->pUserAuth);
diff --git a/source/libs/parser/src/parser.c b/source/libs/parser/src/parser.c
index 53ee717af2..34cd783ace 100644
--- a/source/libs/parser/src/parser.c
+++ b/source/libs/parser/src/parser.c
@@ -85,13 +85,13 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) {
if (IS_VAR_DATA_TYPE(pVal->node.resType.type)) {
taosMemoryFreeClear(pVal->datum.p);
}
-
+
if (pParam->is_null && 1 == *(pParam->is_null)) {
pVal->node.resType.type = TSDB_DATA_TYPE_NULL;
pVal->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_NULL].bytes;
return TSDB_CODE_SUCCESS;
}
-
+
int32_t inputSize = (NULL != pParam->length ? *(pParam->length) : tDataTypes[pParam->buffer_type].bytes);
pVal->node.resType.type = pParam->buffer_type;
pVal->node.resType.bytes = inputSize;
@@ -187,7 +187,7 @@ int32_t qParseSqlSyntax(SParseContext* pCxt, SQuery** pQuery, struct SCatalogReq
if (TSDB_CODE_SUCCESS == code) {
code = buildCatalogReq(&metaCache, pCatalogReq);
}
- destoryParseMetaCache(&metaCache);
+ destoryParseMetaCache(&metaCache, true);
terrno = code;
return code;
}
@@ -203,7 +203,7 @@ int32_t qAnalyseSqlSemantic(SParseContext* pCxt, const struct SCatalogReq* pCata
code = analyseSemantic(pCxt, pQuery, &metaCache);
}
}
- destoryParseMetaCache(&metaCache);
+ destoryParseMetaCache(&metaCache, false);
terrno = code;
return code;
}
diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp
index 4158453110..6717a1fdf1 100644
--- a/source/libs/parser/test/mockCatalogService.cpp
+++ b/source/libs/parser/test/mockCatalogService.cpp
@@ -472,12 +472,16 @@ class MockCatalogServiceImpl {
int32_t getAllTableMeta(SArray* pTableMetaReq, SArray** pTableMetaData) const {
if (NULL != pTableMetaReq) {
- int32_t ntables = taosArrayGetSize(pTableMetaReq);
- *pTableMetaData = taosArrayInit(ntables, sizeof(SMetaRes));
- for (int32_t i = 0; i < ntables; ++i) {
- SMetaRes res = {0};
- res.code = catalogGetTableMeta((const SName*)taosArrayGet(pTableMetaReq, i), (STableMeta**)&res.pRes);
- taosArrayPush(*pTableMetaData, &res);
+ int32_t ndbs = taosArrayGetSize(pTableMetaReq);
+ *pTableMetaData = taosArrayInit(ndbs, sizeof(SMetaRes));
+ for (int32_t i = 0; i < ndbs; ++i) {
+ STablesReq* pReq = (STablesReq*)taosArrayGet(pTableMetaReq, i);
+ int32_t ntables = taosArrayGetSize(pReq->pTables);
+ for (int32_t j = 0; j < ntables; ++j) {
+ SMetaRes res = {0};
+ res.code = catalogGetTableMeta((const SName*)taosArrayGet(pReq->pTables, j), (STableMeta**)&res.pRes);
+ taosArrayPush(*pTableMetaData, &res);
+ }
}
}
return TSDB_CODE_SUCCESS;
@@ -485,13 +489,17 @@ class MockCatalogServiceImpl {
int32_t getAllTableVgroup(SArray* pTableVgroupReq, SArray** pTableVgroupData) const {
if (NULL != pTableVgroupReq) {
- int32_t ntables = taosArrayGetSize(pTableVgroupReq);
- *pTableVgroupData = taosArrayInit(ntables, sizeof(SMetaRes));
- for (int32_t i = 0; i < ntables; ++i) {
- SMetaRes res = {0};
- res.pRes = taosMemoryCalloc(1, sizeof(SVgroupInfo));
- res.code = catalogGetTableHashVgroup((const SName*)taosArrayGet(pTableVgroupReq, i), (SVgroupInfo*)res.pRes);
- taosArrayPush(*pTableVgroupData, &res);
+ int32_t ndbs = taosArrayGetSize(pTableVgroupReq);
+ *pTableVgroupData = taosArrayInit(ndbs, sizeof(SMetaRes));
+ for (int32_t i = 0; i < ndbs; ++i) {
+ STablesReq* pReq = (STablesReq*)taosArrayGet(pTableVgroupReq, i);
+ int32_t ntables = taosArrayGetSize(pReq->pTables);
+ for (int32_t j = 0; j < ntables; ++j) {
+ SMetaRes res = {0};
+ res.pRes = taosMemoryCalloc(1, sizeof(SVgroupInfo));
+ res.code = catalogGetTableHashVgroup((const SName*)taosArrayGet(pReq->pTables, j), (SVgroupInfo*)res.pRes);
+ taosArrayPush(*pTableVgroupData, &res);
+ }
}
}
return TSDB_CODE_SUCCESS;
@@ -677,12 +685,17 @@ int32_t MockCatalogService::catalogGetAllMeta(const SCatalogReq* pCatalogReq, SM
return impl_->catalogGetAllMeta(pCatalogReq, pMetaData);
}
+void MockCatalogService::destoryTablesReq(void* p) {
+ STablesReq* pRes = (STablesReq*)p;
+ taosArrayDestroy(pRes->pTables);
+}
+
void MockCatalogService::destoryCatalogReq(SCatalogReq* pReq) {
taosArrayDestroy(pReq->pDbVgroup);
taosArrayDestroy(pReq->pDbCfg);
taosArrayDestroy(pReq->pDbInfo);
- taosArrayDestroy(pReq->pTableMeta);
- taosArrayDestroy(pReq->pTableHash);
+ taosArrayDestroyEx(pReq->pTableMeta, destoryTablesReq);
+ taosArrayDestroyEx(pReq->pTableHash, destoryTablesReq);
taosArrayDestroy(pReq->pUdf);
taosArrayDestroy(pReq->pIndex);
taosArrayDestroy(pReq->pUser);
diff --git a/source/libs/parser/test/mockCatalogService.h b/source/libs/parser/test/mockCatalogService.h
index d76a6abca8..c0330692ee 100644
--- a/source/libs/parser/test/mockCatalogService.h
+++ b/source/libs/parser/test/mockCatalogService.h
@@ -50,6 +50,7 @@ struct MockTableMeta {
class MockCatalogServiceImpl;
class MockCatalogService {
public:
+ static void destoryTablesReq(void* p);
static void destoryCatalogReq(SCatalogReq* pReq);
static void destoryMetaRes(void* p);
static void destoryMetaArrayRes(void* p);
diff --git a/source/libs/parser/test/parInsertTest.cpp b/source/libs/parser/test/parInsertTest.cpp
index f3f87e945a..7302491ba7 100644
--- a/source/libs/parser/test/parInsertTest.cpp
+++ b/source/libs/parser/test/parInsertTest.cpp
@@ -13,6 +13,8 @@
* along with this program. If not, see .
*/
+#include
+
#include
#include "mockCatalogService.h"
@@ -20,6 +22,7 @@
#include "parInt.h"
using namespace std;
+using namespace std::placeholders;
using namespace testing;
namespace {
@@ -63,7 +66,9 @@ class InsertTest : public Test {
int32_t runAsync() {
cxt_.async = true;
- unique_ptr metaCache(new SParseMetaCache(), _destoryParseMetaCache);
+ bool request = true;
+ unique_ptr > metaCache(
+ new SParseMetaCache(), std::bind(_destoryParseMetaCache, _1, cref(request)));
code_ = parseInsertSyntax(&cxt_, &res_, metaCache.get());
if (code_ != TSDB_CODE_SUCCESS) {
cout << "parseInsertSyntax code:" << toString(code_) << ", msg:" << errMagBuf_ << endl;
@@ -81,6 +86,8 @@ class InsertTest : public Test {
unique_ptr metaData(new SMetaData(), MockCatalogService::destoryMetaData);
g_mockCatalogService->catalogGetAllMeta(catalogReq.get(), metaData.get());
+ metaCache.reset(new SParseMetaCache());
+ request = false;
code_ = putMetaDataToCache(catalogReq.get(), metaData.get(), metaCache.get());
if (code_ != TSDB_CODE_SUCCESS) {
cout << "putMetaDataToCache code:" << toString(code_) << ", msg:" << errMagBuf_ << endl;
@@ -144,8 +151,8 @@ class InsertTest : public Test {
static const int max_err_len = 1024;
static const int max_sql_len = 1024 * 1024;
- static void _destoryParseMetaCache(SParseMetaCache* pMetaCache) {
- destoryParseMetaCache(pMetaCache);
+ static void _destoryParseMetaCache(SParseMetaCache* pMetaCache, bool request) {
+ destoryParseMetaCache(pMetaCache, request);
delete pMetaCache;
}
diff --git a/source/libs/parser/test/parTestUtil.cpp b/source/libs/parser/test/parTestUtil.cpp
index 235cc487fb..3fe4b533e4 100644
--- a/source/libs/parser/test/parTestUtil.cpp
+++ b/source/libs/parser/test/parTestUtil.cpp
@@ -24,6 +24,7 @@
#include "parInt.h"
using namespace std;
+using namespace std::placeholders;
using namespace testing;
namespace ParserTest {
@@ -118,8 +119,8 @@ class ParserTestBaseImpl {
TEST_INTERFACE_ASYNC_API
};
- static void _destoryParseMetaCache(SParseMetaCache* pMetaCache) {
- destoryParseMetaCache(pMetaCache);
+ static void _destoryParseMetaCache(SParseMetaCache* pMetaCache, bool request) {
+ destoryParseMetaCache(pMetaCache, request);
delete pMetaCache;
}
@@ -340,7 +341,9 @@ class ParserTestBaseImpl {
doParse(&cxt, query.get());
SQuery* pQuery = *(query.get());
- unique_ptr metaCache(new SParseMetaCache(), _destoryParseMetaCache);
+ bool request = true;
+ unique_ptr > metaCache(
+ new SParseMetaCache(), bind(_destoryParseMetaCache, _1, cref(request)));
doCollectMetaKey(&cxt, pQuery, metaCache.get());
unique_ptr catalogReq(new SCatalogReq(),
@@ -353,6 +356,8 @@ class ParserTestBaseImpl {
unique_ptr metaData(new SMetaData(), MockCatalogService::destoryMetaData);
doGetAllMeta(catalogReq.get(), metaData.get());
+ metaCache.reset(new SParseMetaCache());
+ request = false;
doPutMetaDataToCache(catalogReq.get(), metaData.get(), metaCache.get());
doAuthenticate(&cxt, pQuery, metaCache.get());
diff --git a/source/libs/planner/src/planner.c b/source/libs/planner/src/planner.c
index 1f531b0708..c1296982e0 100644
--- a/source/libs/planner/src/planner.c
+++ b/source/libs/planner/src/planner.c
@@ -85,7 +85,7 @@ static int32_t setSubplanExecutionNode(SPhysiNode* pNode, int32_t groupId, SDown
}
int32_t qSetSubplanExecutionNode(SSubplan* subplan, int32_t groupId, SDownstreamSourceNode* pSource) {
- planDebug("QID:0x%" PRIx64 " set subplan execution node, groupId:%d", subplan->id.groupId, groupId);
+ planDebug("QID:0x%" PRIx64 " set subplan execution node, groupId:%d", subplan->id.queryId, groupId);
return setSubplanExecutionNode(subplan->pNode, groupId, pSource);
}
@@ -104,7 +104,10 @@ static void clearSubplanExecutionNode(SPhysiNode* pNode) {
FOREACH(pChild, pNode->pChildren) { clearSubplanExecutionNode((SPhysiNode*)pChild); }
}
-void qClearSubplanExecutionNode(SSubplan* pSubplan) { clearSubplanExecutionNode(pSubplan->pNode); }
+void qClearSubplanExecutionNode(SSubplan* pSubplan) {
+ planDebug("QID:0x%" PRIx64 " clear subplan execution node, groupId:%d", pSubplan->id.queryId, pSubplan->id.groupId);
+ clearSubplanExecutionNode(pSubplan->pNode);
+}
int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen) {
if (SUBPLAN_TYPE_MODIFY == pSubplan->subplanType && NULL == pSubplan->pNode) {
diff --git a/source/libs/qcom/src/queryUtil.c b/source/libs/qcom/src/queryUtil.c
index d8fda57791..4cad6a078b 100644
--- a/source/libs/qcom/src/queryUtil.c
+++ b/source/libs/qcom/src/queryUtil.c
@@ -462,3 +462,5 @@ int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst) {
return TSDB_CODE_SUCCESS;
}
+
+
diff --git a/source/libs/qworker/src/qwMsg.c b/source/libs/qworker/src/qwMsg.c
index e8ffd98153..2348f1ef21 100644
--- a/source/libs/qworker/src/qwMsg.c
+++ b/source/libs/qworker/src/qwMsg.c
@@ -387,10 +387,13 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int
char * sql = strndup(msg->msg, msg->sqlLen);
QW_SCH_TASK_DLOG("processQuery start, node:%p, type:%s, handle:%p, SQL:%s", node, TMSG_INFO(pMsg->msgType), pMsg->info.handle, sql);
- QW_ERR_RET(qwProcessQuery(QW_FPARAMS(), &qwMsg, sql));
- QW_SCH_TASK_DLOG("processQuery end, node:%p", node);
+ QW_ERR_JRET(qwProcessQuery(QW_FPARAMS(), &qwMsg, sql));
- return TSDB_CODE_SUCCESS;
+_return:
+
+ QW_SCH_TASK_DLOG("processQuery end, node:%p, code:%d", node, code);
+
+ return code;
}
int32_t qWorkerProcessCQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts) {
diff --git a/source/libs/scheduler/src/schStatus.c b/source/libs/scheduler/src/schStatus.c
index a4fa4f2839..64cda573f1 100644
--- a/source/libs/scheduler/src/schStatus.c
+++ b/source/libs/scheduler/src/schStatus.c
@@ -64,7 +64,7 @@ _return:
int32_t schHandleOpBeginEvent(int64_t jobId, SSchJob** job, SCH_OP_TYPE type, SSchedulerReq* pReq) {
SSchJob *pJob = schAcquireJob(jobId);
if (NULL == pJob) {
- qError("Acquire sch job failed, may be dropped, jobId:0x%" PRIx64, jobId);
+ qWarn("Acquire sch job failed, may be dropped, jobId:0x%" PRIx64, jobId);
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
}
diff --git a/source/libs/scheduler/src/schTask.c b/source/libs/scheduler/src/schTask.c
index ecd0253e1c..cabca0dc0c 100644
--- a/source/libs/scheduler/src/schTask.c
+++ b/source/libs/scheduler/src/schTask.c
@@ -284,7 +284,6 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
for (int32_t i = 0; i < parentNum; ++i) {
SSchTask *parent = *(SSchTask **)taosArrayGet(pTask->parents, i);
- int32_t readyNum = atomic_add_fetch_32(&parent->childReady, 1);
SCH_LOCK(SCH_WRITE, &parent->planLock);
SDownstreamSourceNode source = {
@@ -298,6 +297,8 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
qSetSubplanExecutionNode(parent->plan, pTask->plan->id.groupId, &source);
SCH_UNLOCK(SCH_WRITE, &parent->planLock);
+ int32_t readyNum = atomic_add_fetch_32(&parent->childReady, 1);
+
if (SCH_TASK_READY_FOR_LAUNCH(readyNum, parent)) {
SCH_TASK_DLOG("all %d children task done, start to launch parent task 0x%" PRIx64, readyNum, parent->taskId);
SCH_ERR_RET(schLaunchTask(pJob, parent));
@@ -536,6 +537,7 @@ int32_t schMoveTaskToExecList(SSchJob *pJob, SSchTask *pTask, bool *moved) {
int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bool *needRetry) {
if (TSDB_CODE_SCH_TIMEOUT_ERROR == errCode) {
pTask->maxExecTimes++;
+ pTask->maxRetryTimes++;
if (pTask->timeoutUsec < SCH_MAX_TASK_TIMEOUT_USEC) {
pTask->timeoutUsec *= 2;
if (pTask->timeoutUsec > SCH_MAX_TASK_TIMEOUT_USEC) {
diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c
index 3a15523040..a37cd4fd9e 100644
--- a/source/libs/scheduler/src/scheduler.c
+++ b/source/libs/scheduler/src/scheduler.c
@@ -150,7 +150,7 @@ void schedulerFreeJob(int64_t* jobId, int32_t errCode) {
SSchJob *pJob = schAcquireJob(*jobId);
if (NULL == pJob) {
- qError("Acquire sch job failed, may be dropped, jobId:0x%" PRIx64, *jobId);
+ qWarn("Acquire sch job failed, may be dropped, jobId:0x%" PRIx64, *jobId);
return;
}
diff --git a/source/libs/stream/src/streamData.c b/source/libs/stream/src/streamData.c
index 0bf6d4c921..54014d7df9 100644
--- a/source/libs/stream/src/streamData.c
+++ b/source/libs/stream/src/streamData.c
@@ -35,6 +35,7 @@ int32_t streamDispatchReqToData(const SStreamDispatchReq* pReq, SStreamDataBlock
pDataBlock->info.window.skey = be64toh(pRetrieve->skey);
pDataBlock->info.window.ekey = be64toh(pRetrieve->ekey);
pDataBlock->info.version = be64toh(pRetrieve->version);
+ pDataBlock->info.watermark = be64toh(pRetrieve->watermark);
pDataBlock->info.type = pRetrieve->streamBlockType;
pDataBlock->info.childId = pReq->upstreamChildId;
diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c
index 66e689dd3e..8d6d31e37f 100644
--- a/source/libs/stream/src/streamDispatch.c
+++ b/source/libs/stream/src/streamDispatch.c
@@ -184,6 +184,7 @@ static int32_t streamAddBlockToDispatchMsg(const SSDataBlock* pBlock, SStreamDis
pRetrieve->skey = htobe64(pBlock->info.window.skey);
pRetrieve->ekey = htobe64(pBlock->info.window.ekey);
pRetrieve->version = htobe64(pBlock->info.version);
+ pRetrieve->watermark = htobe64(pBlock->info.watermark);
int32_t numOfCols = (int32_t)taosArrayGetSize(pBlock->pDataBlock);
pRetrieve->numOfCols = htonl(numOfCols);
diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c
index 48ebf824e8..78004c0ad6 100644
--- a/source/libs/sync/src/syncMain.c
+++ b/source/libs/sync/src/syncMain.c
@@ -1270,6 +1270,8 @@ int32_t syncNodeStopElectTimer(SSyncNode* pSyncNode) {
atomic_add_fetch_64(&pSyncNode->electTimerLogicClockUser, 1);
taosTmrStop(pSyncNode->pElectTimer);
pSyncNode->pElectTimer = NULL;
+
+ sTrace("vgId:%d, sync %s stop elect timer", pSyncNode->vgId, syncUtilState2String(pSyncNode->state));
return ret;
}
@@ -1343,7 +1345,8 @@ int32_t syncNodeStopHeartbeatTimer(SSyncNode* pSyncNode) {
atomic_add_fetch_64(&pSyncNode->heartbeatTimerLogicClockUser, 1);
taosTmrStop(pSyncNode->pHeartbeatTimer);
pSyncNode->pHeartbeatTimer = NULL;
- sTrace("vgId:%d, stop heartbeat timer", pSyncNode->vgId);
+
+ sTrace("vgId:%d, sync %s stop heartbeat timer", pSyncNode->vgId, syncUtilState2String(pSyncNode->state));
return ret;
}
@@ -2965,7 +2968,7 @@ bool syncNodeCanChange(SSyncNode* pSyncNode) {
return true;
}
-inline void syncLogSendRequestVote(SSyncNode* pSyncNode, const SyncRequestVote* pMsg, const char* s) {
+void syncLogSendRequestVote(SSyncNode* pSyncNode, const SyncRequestVote* pMsg, const char* s) {
char host[64];
uint16_t port;
syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port);
@@ -2976,7 +2979,7 @@ inline void syncLogSendRequestVote(SSyncNode* pSyncNode, const SyncRequestVote*
syncNodeEventLog(pSyncNode, logBuf);
}
-inline void syncLogRecvRequestVote(SSyncNode* pSyncNode, const SyncRequestVote* pMsg, const char* s) {
+void syncLogRecvRequestVote(SSyncNode* pSyncNode, const SyncRequestVote* pMsg, const char* s) {
char logBuf[256];
char host[64];
uint16_t port;
@@ -2987,7 +2990,7 @@ inline void syncLogRecvRequestVote(SSyncNode* pSyncNode, const SyncRequestVote*
syncNodeEventLog(pSyncNode, logBuf);
}
-inline void syncLogSendRequestVoteReply(SSyncNode* pSyncNode, const SyncRequestVoteReply* pMsg, const char* s) {
+void syncLogSendRequestVoteReply(SSyncNode* pSyncNode, const SyncRequestVoteReply* pMsg, const char* s) {
char host[64];
uint16_t port;
syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port);
@@ -2997,7 +3000,7 @@ inline void syncLogSendRequestVoteReply(SSyncNode* pSyncNode, const SyncRequestV
syncNodeEventLog(pSyncNode, logBuf);
}
-inline void syncLogRecvRequestVoteReply(SSyncNode* pSyncNode, const SyncRequestVoteReply* pMsg, const char* s) {
+void syncLogRecvRequestVoteReply(SSyncNode* pSyncNode, const SyncRequestVoteReply* pMsg, const char* s) {
char host[64];
uint16_t port;
syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port);
@@ -3007,7 +3010,7 @@ inline void syncLogRecvRequestVoteReply(SSyncNode* pSyncNode, const SyncRequestV
syncNodeEventLog(pSyncNode, logBuf);
}
-inline void syncLogSendAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntries* pMsg, const char* s) {
+void syncLogSendAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntries* pMsg, const char* s) {
char host[64];
uint16_t port;
syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port);
@@ -3022,7 +3025,7 @@ inline void syncLogSendAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntri
syncNodeEventLog(pSyncNode, logBuf);
}
-inline void syncLogRecvAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntries* pMsg, const char* s) {
+void syncLogRecvAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntries* pMsg, const char* s) {
char host[64];
uint16_t port;
syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port);
@@ -3037,7 +3040,7 @@ inline void syncLogRecvAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntri
syncNodeEventLog(pSyncNode, logBuf);
}
-inline void syncLogSendAppendEntriesBatch(SSyncNode* pSyncNode, const SyncAppendEntriesBatch* pMsg, const char* s) {
+void syncLogSendAppendEntriesBatch(SSyncNode* pSyncNode, const SyncAppendEntriesBatch* pMsg, const char* s) {
char host[64];
uint16_t port;
syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port);
@@ -3050,7 +3053,7 @@ inline void syncLogSendAppendEntriesBatch(SSyncNode* pSyncNode, const SyncAppend
syncNodeEventLog(pSyncNode, logBuf);
}
-inline void syncLogRecvAppendEntriesBatch(SSyncNode* pSyncNode, const SyncAppendEntriesBatch* pMsg, const char* s) {
+void syncLogRecvAppendEntriesBatch(SSyncNode* pSyncNode, const SyncAppendEntriesBatch* pMsg, const char* s) {
char host[64];
uint16_t port;
syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port);
@@ -3063,7 +3066,7 @@ inline void syncLogRecvAppendEntriesBatch(SSyncNode* pSyncNode, const SyncAppend
syncNodeEventLog(pSyncNode, logBuf);
}
-inline void syncLogSendAppendEntriesReply(SSyncNode* pSyncNode, const SyncAppendEntriesReply* pMsg, const char* s) {
+ void syncLogSendAppendEntriesReply(SSyncNode* pSyncNode, const SyncAppendEntriesReply* pMsg, const char* s) {
char host[64];
uint16_t port;
syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port);
@@ -3075,7 +3078,7 @@ inline void syncLogSendAppendEntriesReply(SSyncNode* pSyncNode, const SyncAppend
syncNodeEventLog(pSyncNode, logBuf);
}
-inline void syncLogRecvAppendEntriesReply(SSyncNode* pSyncNode, const SyncAppendEntriesReply* pMsg, const char* s) {
+void syncLogRecvAppendEntriesReply(SSyncNode* pSyncNode, const SyncAppendEntriesReply* pMsg, const char* s) {
char host[64];
uint16_t port;
syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port);
diff --git a/source/libs/sync/src/syncRequestVote.c b/source/libs/sync/src/syncRequestVote.c
index b47294a8e1..122a81930b 100644
--- a/source/libs/sync/src/syncRequestVote.c
+++ b/source/libs/sync/src/syncRequestVote.c
@@ -57,11 +57,14 @@ int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg) {
// maybe update term
if (pMsg->term > ths->pRaftStore->currentTerm) {
+ syncNodeUpdateTerm(ths, pMsg->term);
+#if 0
if (logOK) {
syncNodeUpdateTerm(ths, pMsg->term);
} else {
syncNodeUpdateTermWithoutStepDown(ths, pMsg->term);
}
+#endif
}
ASSERT(pMsg->term <= ths->pRaftStore->currentTerm);
@@ -167,11 +170,14 @@ int32_t syncNodeOnRequestVoteSnapshotCb(SSyncNode* ths, SyncRequestVote* pMsg) {
// maybe update term
if (pMsg->term > ths->pRaftStore->currentTerm) {
+ syncNodeUpdateTerm(ths, pMsg->term);
+#if 0
if (logOK) {
syncNodeUpdateTerm(ths, pMsg->term);
} else {
syncNodeUpdateTermWithoutStepDown(ths, pMsg->term);
}
+#endif
}
ASSERT(pMsg->term <= ths->pRaftStore->currentTerm);
diff --git a/source/libs/sync/test/sh/a.sh b/source/libs/sync/test/sh/a.sh
index 3983d30b7c..f4ffaa5062 100644
--- a/source/libs/sync/test/sh/a.sh
+++ b/source/libs/sync/test/sh/a.sh
@@ -89,7 +89,7 @@ for file in `ls ${logpath}/log.dnode*.vgId*.commit`;do
line=`cat ${file} | tail -n1`
echo $line | awk '{print $5, $0}' >> ${tmpfile}
done
-cat ${tmpfile} | sort -k1 > ${logpath}/log.commits
+cat ${tmpfile} | sort -k1 | awk 'BEGIN{vgid=$1}{if($1==vgid){print $0}else{print ""; print $0; vgid=$1;}}END{}' > ${logpath}/log.commits
exit 0
diff --git a/source/libs/sync/test/sh/insert.tpl.json b/source/libs/sync/test/sh/insert.tpl.json
index 1d952b98e8..631e490a2a 100644
--- a/source/libs/sync/test/sh/insert.tpl.json
+++ b/source/libs/sync/test/sh/insert.tpl.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 8,
- "thread_count_create_tbl": 8,
+ "create_table_thread_count": 8,
"result_file": "./tpl_insert_result_tpl",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/parallel_test/run_case.sh b/tests/parallel_test/run_case.sh
index 52a5627e34..eda66a884a 100755
--- a/tests/parallel_test/run_case.sh
+++ b/tests/parallel_test/run_case.sh
@@ -49,11 +49,13 @@ if [ $ent -eq 0 ]; then
export PATH=$PATH:/home/TDengine/debug/build/bin
export LD_LIBRARY_PATH=/home/TDengine/debug/build/lib
ln -s /home/TDengine/debug/build/lib/libtaos.so /usr/lib/libtaos.so 2>/dev/null
+ ln -s /home/TDengine/debug/build/lib/libtaos.so /usr/lib/libtaos.so.1 2>/dev/null
CONTAINER_TESTDIR=/home/TDengine
else
export PATH=$PATH:/home/TDinternal/debug/build/bin
export LD_LIBRARY_PATH=/home/TDinternal/debug/build/lib
ln -s /home/TDinternal/debug/build/lib/libtaos.so /usr/lib/libtaos.so 2>/dev/null
+ ln -s /home/TDinternal/debug/build/lib/libtaos.so /usr/lib/libtaos.so.1 2>/dev/null
CONTAINER_TESTDIR=/home/TDinternal/community
fi
mkdir -p /var/lib/taos/subscribe
diff --git a/tests/parallel_test/run_container.sh b/tests/parallel_test/run_container.sh
index affd9128a4..f0ee9be46f 100755
--- a/tests/parallel_test/run_container.sh
+++ b/tests/parallel_test/run_container.sh
@@ -100,6 +100,7 @@ docker run \
-v "$TMP_DIR/thread_volume/$thread_no/sim:${SIM_DIR}" \
-v ${TMP_DIR}/thread_volume/$thread_no/coredump:$coredump_dir \
-v $WORKDIR/taos-connector-python/taos:/usr/local/lib/python3.8/site-packages/taos:ro \
+ -v $WORKDIR/taos-connector-python/taosrest:/usr/local/lib/python3.8/site-packages/taosrest:ro \
--rm --ulimit core=-1 taos_test:v1.0 $CONTAINER_TESTDIR/tests/parallel_test/run_case.sh -d "$exec_dir" -c "$cmd" $extra_param
ret=$?
exit $ret
diff --git a/tests/pytest/cluster/TD-3693/insert1Data.json b/tests/pytest/cluster/TD-3693/insert1Data.json
index 6900ce0366..ad83a35160 100644
--- a/tests/pytest/cluster/TD-3693/insert1Data.json
+++ b/tests/pytest/cluster/TD-3693/insert1Data.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/cluster/TD-3693/insert2Data.json b/tests/pytest/cluster/TD-3693/insert2Data.json
index e55fa996fb..86495f0ce9 100644
--- a/tests/pytest/cluster/TD-3693/insert2Data.json
+++ b/tests/pytest/cluster/TD-3693/insert2Data.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/dockerCluster/insert.json b/tests/pytest/dockerCluster/insert.json
index 32e1043c4e..ce8d7978fa 100644
--- a/tests/pytest/dockerCluster/insert.json
+++ b/tests/pytest/dockerCluster/insert.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 1,
+ "create_table_thread_count": 1,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"databases": [{
diff --git a/tests/pytest/manualTest/TD-5114/insertDataDb3Replica2.json b/tests/pytest/manualTest/TD-5114/insertDataDb3Replica2.json
index dc9de1626a..4b622c3f28 100644
--- a/tests/pytest/manualTest/TD-5114/insertDataDb3Replica2.json
+++ b/tests/pytest/manualTest/TD-5114/insertDataDb3Replica2.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/perfbenchmark/bug3433.py b/tests/pytest/perfbenchmark/bug3433.py
index 7f2dfad403..3e7de39bed 100644
--- a/tests/pytest/perfbenchmark/bug3433.py
+++ b/tests/pytest/perfbenchmark/bug3433.py
@@ -185,7 +185,7 @@ class TDTestCase:
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "/tmp/insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/perfbenchmark/joinPerformance.py b/tests/pytest/perfbenchmark/joinPerformance.py
index b85c09926a..d30bec6664 100644
--- a/tests/pytest/perfbenchmark/joinPerformance.py
+++ b/tests/pytest/perfbenchmark/joinPerformance.py
@@ -168,7 +168,7 @@ class JoinPerf:
"user": self.user,
"password": self.password,
"thread_count": cpu_count(),
- "thread_count_create_tbl": cpu_count(),
+ "create_table_thread_count": cpu_count(),
"result_file": "/tmp/insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/perfbenchmark/taosdemoInsert.py b/tests/pytest/perfbenchmark/taosdemoInsert.py
index 774103aa85..a23797a62b 100644
--- a/tests/pytest/perfbenchmark/taosdemoInsert.py
+++ b/tests/pytest/perfbenchmark/taosdemoInsert.py
@@ -172,7 +172,7 @@ class Taosdemo:
"user": self.user,
"password": self.password,
"thread_count": cpu_count(),
- "thread_count_create_tbl": cpu_count(),
+ "create_table_thread_count": cpu_count(),
"result_file": "/tmp/insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/query/nestedQuery/insertData.json b/tests/pytest/query/nestedQuery/insertData.json
index 1aad170bb0..18a843015c 100644
--- a/tests/pytest/query/nestedQuery/insertData.json
+++ b/tests/pytest/query/nestedQuery/insertData.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file":"./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/query/query1970YearsAf.py b/tests/pytest/query/query1970YearsAf.py
index 6a5c0796ed..e7e9fa5329 100644
--- a/tests/pytest/query/query1970YearsAf.py
+++ b/tests/pytest/query/query1970YearsAf.py
@@ -133,7 +133,7 @@ class TDTestCase:
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "/tmp/insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/insert-interlace.json b/tests/pytest/tools/insert-interlace.json
index 0e17edf8fd..8d96c20fe7 100644
--- a/tests/pytest/tools/insert-interlace.json
+++ b/tests/pytest/tools/insert-interlace.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 5000,
diff --git a/tests/pytest/tools/insert-tblimit-tboffset-createdb.json b/tests/pytest/tools/insert-tblimit-tboffset-createdb.json
index bbac60872e..e50e67943e 100644
--- a/tests/pytest/tools/insert-tblimit-tboffset-createdb.json
+++ b/tests/pytest/tools/insert-tblimit-tboffset-createdb.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/insert-tblimit-tboffset-insertrec.json b/tests/pytest/tools/insert-tblimit-tboffset-insertrec.json
index 8f795338d2..fe4945483c 100644
--- a/tests/pytest/tools/insert-tblimit-tboffset-insertrec.json
+++ b/tests/pytest/tools/insert-tblimit-tboffset-insertrec.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/insert-tblimit-tboffset.json b/tests/pytest/tools/insert-tblimit-tboffset.json
index 2c2d86c481..92b28241a6 100644
--- a/tests/pytest/tools/insert-tblimit-tboffset.json
+++ b/tests/pytest/tools/insert-tblimit-tboffset.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/insert-tblimit-tboffset0.json b/tests/pytest/tools/insert-tblimit-tboffset0.json
index ce83ea3e60..0c1e00976b 100644
--- a/tests/pytest/tools/insert-tblimit-tboffset0.json
+++ b/tests/pytest/tools/insert-tblimit-tboffset0.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/insert-tblimit1-tboffset.json b/tests/pytest/tools/insert-tblimit1-tboffset.json
index b15aaf4eed..ff002e9528 100644
--- a/tests/pytest/tools/insert-tblimit1-tboffset.json
+++ b/tests/pytest/tools/insert-tblimit1-tboffset.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/insert.json b/tests/pytest/tools/insert.json
index 523561dc6d..4489730722 100644
--- a/tests/pytest/tools/insert.json
+++ b/tests/pytest/tools/insert.json
@@ -7,7 +7,7 @@
"password": "taosdata",
"thread_count": 2,
"num_of_records_per_req": 10,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"databases": [{
"dbinfo": {
"name": "db01",
diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertMSDB.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertMSDB.json
index a11261681a..3c876c61c7 100644
--- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertMSDB.json
+++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertMSDB.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 10,
+ "create_table_thread_count": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertNanoDB.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertNanoDB.json
index 080231551e..b9162242d4 100644
--- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertNanoDB.json
+++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertNanoDB.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 10,
+ "create_table_thread_count": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertUSDB.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertUSDB.json
index fe0ecbe2de..3fbaeceeba 100644
--- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertUSDB.json
+++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoInsertUSDB.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 10,
+ "create_table_thread_count": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json
index 1af2952a69..6b0631da39 100644
--- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json
+++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 10,
+ "create_table_thread_count": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json
index 39c5e49909..bf9b015154 100644
--- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json
+++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 10,
+ "create_table_thread_count": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseNow.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseNow.json
index f4dbf1ee41..346fe31be9 100644
--- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseNow.json
+++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseNow.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 10,
+ "create_table_thread_count": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json
index 84b511a446..65a2836a49 100644
--- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json
+++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 10,
+ "create_table_thread_count": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.json b/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.json
index 75dbcb4432..b7b6c186e6 100644
--- a/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.json
+++ b/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.json b/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.json
index 0c2e9cf34a..edb9ed7cb8 100644
--- a/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.json
+++ b/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 10,
+ "create_table_thread_count": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json
index e90474e872..b1d7dc4935 100755
--- a/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json
+++ b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 10,
+ "create_table_thread_count": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insert-1s1tnt1r.json b/tests/pytest/tools/taosdemoAllTest/insert-1s1tnt1r.json
index 21603b1902..c1c27cf6d7 100644
--- a/tests/pytest/tools/taosdemoAllTest/insert-1s1tnt1r.json
+++ b/tests/pytest/tools/taosdemoAllTest/insert-1s1tnt1r.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insert-1s1tntmr.json b/tests/pytest/tools/taosdemoAllTest/insert-1s1tntmr.json
index c944c26915..360ec07370 100644
--- a/tests/pytest/tools/taosdemoAllTest/insert-1s1tntmr.json
+++ b/tests/pytest/tools/taosdemoAllTest/insert-1s1tntmr.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insert-disorder.json b/tests/pytest/tools/taosdemoAllTest/insert-disorder.json
index 4908d3999c..930496a877 100644
--- a/tests/pytest/tools/taosdemoAllTest/insert-disorder.json
+++ b/tests/pytest/tools/taosdemoAllTest/insert-disorder.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file":"./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-N00.json b/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-N00.json
index 03f531f52b..12dadf8006 100644
--- a/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-N00.json
+++ b/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-N00.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-Y00.json b/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-Y00.json
index ce2a34627b..759a3f074d 100644
--- a/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-Y00.json
+++ b/tests/pytest/tools/taosdemoAllTest/insert-drop-exist-auto-Y00.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insert-illegal.json b/tests/pytest/tools/taosdemoAllTest/insert-illegal.json
index 6e438b33df..321495782d 100644
--- a/tests/pytest/tools/taosdemoAllTest/insert-illegal.json
+++ b/tests/pytest/tools/taosdemoAllTest/insert-illegal.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insert-interlace-row.json b/tests/pytest/tools/taosdemoAllTest/insert-interlace-row.json
index 54e646a5a0..5dd37ee8b0 100644
--- a/tests/pytest/tools/taosdemoAllTest/insert-interlace-row.json
+++ b/tests/pytest/tools/taosdemoAllTest/insert-interlace-row.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insert-interval-speed.json b/tests/pytest/tools/taosdemoAllTest/insert-interval-speed.json
index 9a47a873dd..7fbee6fee0 100644
--- a/tests/pytest/tools/taosdemoAllTest/insert-interval-speed.json
+++ b/tests/pytest/tools/taosdemoAllTest/insert-interval-speed.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 100,
diff --git a/tests/pytest/tools/taosdemoAllTest/insert-newdb.json b/tests/pytest/tools/taosdemoAllTest/insert-newdb.json
index 2eb17b1aab..16e1f94481 100644
--- a/tests/pytest/tools/taosdemoAllTest/insert-newdb.json
+++ b/tests/pytest/tools/taosdemoAllTest/insert-newdb.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insert-newtable.json b/tests/pytest/tools/taosdemoAllTest/insert-newtable.json
index abe277bf5b..86c9359ffb 100644
--- a/tests/pytest/tools/taosdemoAllTest/insert-newtable.json
+++ b/tests/pytest/tools/taosdemoAllTest/insert-newtable.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insert-nodbnodrop.json b/tests/pytest/tools/taosdemoAllTest/insert-nodbnodrop.json
index 2dae7eb1d7..7eee9ce55b 100644
--- a/tests/pytest/tools/taosdemoAllTest/insert-nodbnodrop.json
+++ b/tests/pytest/tools/taosdemoAllTest/insert-nodbnodrop.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insert-offset.json b/tests/pytest/tools/taosdemoAllTest/insert-offset.json
index 642d01db3e..d3946cee3c 100644
--- a/tests/pytest/tools/taosdemoAllTest/insert-offset.json
+++ b/tests/pytest/tools/taosdemoAllTest/insert-offset.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insert-renewdb.json b/tests/pytest/tools/taosdemoAllTest/insert-renewdb.json
index 3ef4360aef..c812b4971e 100644
--- a/tests/pytest/tools/taosdemoAllTest/insert-renewdb.json
+++ b/tests/pytest/tools/taosdemoAllTest/insert-renewdb.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insert-sample.json b/tests/pytest/tools/taosdemoAllTest/insert-sample.json
index 5b25281e78..e24e20067c 100644
--- a/tests/pytest/tools/taosdemoAllTest/insert-sample.json
+++ b/tests/pytest/tools/taosdemoAllTest/insert-sample.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file":"./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insert-timestep.json b/tests/pytest/tools/taosdemoAllTest/insert-timestep.json
index 6432fde4ba..ceadfc677a 100644
--- a/tests/pytest/tools/taosdemoAllTest/insert-timestep.json
+++ b/tests/pytest/tools/taosdemoAllTest/insert-timestep.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file":"./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151.json b/tests/pytest/tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151.json
index 4e59d86679..69ebe45e50 100644
--- a/tests/pytest/tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151.json
+++ b/tests/pytest/tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insertChildTab0.json b/tests/pytest/tools/taosdemoAllTest/insertChildTab0.json
index 80d6817b5d..8b7086530e 100644
--- a/tests/pytest/tools/taosdemoAllTest/insertChildTab0.json
+++ b/tests/pytest/tools/taosdemoAllTest/insertChildTab0.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insertChildTabLess0.json b/tests/pytest/tools/taosdemoAllTest/insertChildTabLess0.json
index a35c28f0ac..1e052ff2a4 100644
--- a/tests/pytest/tools/taosdemoAllTest/insertChildTabLess0.json
+++ b/tests/pytest/tools/taosdemoAllTest/insertChildTabLess0.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNum4096.json b/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNum4096.json
index 05d47c3611..c67b1dba14 100644
--- a/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNum4096.json
+++ b/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNum4096.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNumLarge4096.json b/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNumLarge4096.json
index e63b3613ba..25e43aefa7 100644
--- a/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNumLarge4096.json
+++ b/tests/pytest/tools/taosdemoAllTest/insertColumnsAndTagNumLarge4096.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insertColumnsNum0.json b/tests/pytest/tools/taosdemoAllTest/insertColumnsNum0.json
index 137e608386..af04d9c1a3 100644
--- a/tests/pytest/tools/taosdemoAllTest/insertColumnsNum0.json
+++ b/tests/pytest/tools/taosdemoAllTest/insertColumnsNum0.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json b/tests/pytest/tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json
index 63a4a2ab58..84a5fe9452 100644
--- a/tests/pytest/tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json
+++ b/tests/pytest/tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insertMaxNumPerReq.json b/tests/pytest/tools/taosdemoAllTest/insertMaxNumPerReq.json
index f3212bc30d..d092a41483 100644
--- a/tests/pytest/tools/taosdemoAllTest/insertMaxNumPerReq.json
+++ b/tests/pytest/tools/taosdemoAllTest/insertMaxNumPerReq.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReq0.json b/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReq0.json
index 9711ead80e..45523618f0 100644
--- a/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReq0.json
+++ b/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReq0.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json b/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json
index 24c61cfa8c..a95c40f9eb 100644
--- a/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json
+++ b/tests/pytest/tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insertRestful.json b/tests/pytest/tools/taosdemoAllTest/insertRestful.json
index ab7ee9a73b..26770c3d09 100644
--- a/tests/pytest/tools/taosdemoAllTest/insertRestful.json
+++ b/tests/pytest/tools/taosdemoAllTest/insertRestful.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insertSigcolumnsNum4096.json b/tests/pytest/tools/taosdemoAllTest/insertSigcolumnsNum4096.json
index d835822e8f..74737b4dec 100644
--- a/tests/pytest/tools/taosdemoAllTest/insertSigcolumnsNum4096.json
+++ b/tests/pytest/tools/taosdemoAllTest/insertSigcolumnsNum4096.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insertTagsNumLarge128.json b/tests/pytest/tools/taosdemoAllTest/insertTagsNumLarge128.json
index 4c7cdfe39d..e0e9f72a56 100644
--- a/tests/pytest/tools/taosdemoAllTest/insertTagsNumLarge128.json
+++ b/tests/pytest/tools/taosdemoAllTest/insertTagsNumLarge128.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insertTimestepMulRowsLargeint16.json b/tests/pytest/tools/taosdemoAllTest/insertTimestepMulRowsLargeint16.json
index b563dcc94b..fdc1994782 100644
--- a/tests/pytest/tools/taosdemoAllTest/insertTimestepMulRowsLargeint16.json
+++ b/tests/pytest/tools/taosdemoAllTest/insertTimestepMulRowsLargeint16.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/insert_5M_rows.json b/tests/pytest/tools/taosdemoAllTest/insert_5M_rows.json
index 0f1a874cc3..91d6c1a837 100644
--- a/tests/pytest/tools/taosdemoAllTest/insert_5M_rows.json
+++ b/tests/pytest/tools/taosdemoAllTest/insert_5M_rows.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/manual_block1_comp.json b/tests/pytest/tools/taosdemoAllTest/manual_block1_comp.json
index bdab459987..45a718705a 100644
--- a/tests/pytest/tools/taosdemoAllTest/manual_block1_comp.json
+++ b/tests/pytest/tools/taosdemoAllTest/manual_block1_comp.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/manual_block2.json b/tests/pytest/tools/taosdemoAllTest/manual_block2.json
index 763421c7f3..f01e55fb53 100644
--- a/tests/pytest/tools/taosdemoAllTest/manual_block2.json
+++ b/tests/pytest/tools/taosdemoAllTest/manual_block2.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_A.json b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_A.json
index 0579aedf69..f097f15ee1 100644
--- a/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_A.json
+++ b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_A.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json
index d541cb6567..2df1fc42aa 100644
--- a/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json
+++ b/tests/pytest/tools/taosdemoAllTest/manual_change_time_1_1_B.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit1.json b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit1.json
index c134391a5f..be1df2030f 100644
--- a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit1.json
+++ b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit1.json
@@ -7,7 +7,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit5.json b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit5.json
index e9f759f8f7..a8552404d5 100644
--- a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit5.json
+++ b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit5.json
@@ -7,7 +7,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit94.json b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit94.json
index 9b46ff105b..316fbba4a0 100644
--- a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit94.json
+++ b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-limit94.json
@@ -7,7 +7,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-newdb.json b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-newdb.json
index fdcaa131e6..d03b29d90f 100644
--- a/tests/pytest/tools/taosdemoAllTest/moredemo-offset-newdb.json
+++ b/tests/pytest/tools/taosdemoAllTest/moredemo-offset-newdb.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/query-interrupt.json b/tests/pytest/tools/taosdemoAllTest/query-interrupt.json
index 01028f68ad..1b276cb2b0 100644
--- a/tests/pytest/tools/taosdemoAllTest/query-interrupt.json
+++ b/tests/pytest/tools/taosdemoAllTest/query-interrupt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/queryInsertdata.json b/tests/pytest/tools/taosdemoAllTest/queryInsertdata.json
index 0fc789c7e3..8565e4a711 100644
--- a/tests/pytest/tools/taosdemoAllTest/queryInsertdata.json
+++ b/tests/pytest/tools/taosdemoAllTest/queryInsertdata.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/queryInsertrestdata.json b/tests/pytest/tools/taosdemoAllTest/queryInsertrestdata.json
index 940adfb61c..0f9be9bdc3 100644
--- a/tests/pytest/tools/taosdemoAllTest/queryInsertrestdata.json
+++ b/tests/pytest/tools/taosdemoAllTest/queryInsertrestdata.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/1174-large-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/1174-large-stmt.json
index a4baf73689..443da39fa1 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/1174-large-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/1174-large-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 1,
+ "create_table_thread_count": 1,
"result_file": "1174.out",
"confirm_parameter_prompt": "no",
"num_of_records_per_req": 51,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/1174-large-taosc.json b/tests/pytest/tools/taosdemoAllTest/stmt/1174-large-taosc.json
index a7a514e9dc..bd5709ca5e 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/1174-large-taosc.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/1174-large-taosc.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 1,
+ "create_table_thread_count": 1,
"result_file": "1174.out",
"confirm_parameter_prompt": "no",
"num_of_records_per_req": 51,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/1174-small-stmt-random.json b/tests/pytest/tools/taosdemoAllTest/stmt/1174-small-stmt-random.json
index 3c38f92680..209f414c1b 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/1174-small-stmt-random.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/1174-small-stmt-random.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 1,
+ "create_table_thread_count": 1,
"result_file": "1174.out",
"confirm_parameter_prompt": "no",
"num_of_records_per_req": 51,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/1174-small-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/1174-small-stmt.json
index 2ee489c7a3..903c8a9c93 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/1174-small-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/1174-small-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 1,
+ "create_table_thread_count": 1,
"result_file": "1174.out",
"confirm_parameter_prompt": "no",
"num_of_records_per_req": 51,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/1174-small-taosc.json b/tests/pytest/tools/taosdemoAllTest/stmt/1174-small-taosc.json
index 44da22aa3f..dcbec40034 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/1174-small-taosc.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/1174-small-taosc.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 1,
+ "create_table_thread_count": 1,
"result_file": "1174.out",
"confirm_parameter_prompt": "no",
"num_of_records_per_req": 51,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tnt1r-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tnt1r-stmt.json
index b2805a38e5..1ea4de5cfe 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tnt1r-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tnt1r-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tntmr-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tntmr-stmt.json
index ac540befb6..86f2fa6c4d 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tntmr-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-1s1tntmr-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-disorder-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-disorder-stmt.json
index 9a7ad93636..d634ab8369 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-disorder-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-disorder-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file":"./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-N00-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-N00-stmt.json
index 919b918395..4b69118ef5 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-N00-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-N00-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-Y00-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-Y00-stmt.json
index dcf52931ad..32043996b6 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-Y00-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-drop-exist-auto-Y00-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-interlace-row-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-interlace-row-stmt.json
index d2304ed537..a1a0b89e48 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-interlace-row-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-interlace-row-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-interval-speed-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-interval-speed-stmt.json
index d297240613..f5cea2ccc3 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-interval-speed-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-interval-speed-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 100,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-newdb-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-newdb-stmt.json
index d117c5b345..c3bdea61c6 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-newdb-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-newdb-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-newtable-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-newtable-stmt.json
index 1b36b3cbe9..e92644d33e 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-newtable-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-newtable-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-nodbnodrop-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-nodbnodrop-stmt.json
index ea95736a00..0618c04b30 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-nodbnodrop-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-nodbnodrop-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-offset-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-offset-stmt.json
index 8318de6672..356ac38d14 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-offset-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-offset-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-renewdb-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-renewdb-stmt.json
index b6cb47f2c5..2f8f693166 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-renewdb-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-renewdb-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-sample-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-sample-stmt.json
index 348e93ff8b..c1da95ba8c 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-sample-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-sample-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file":"./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insert-timestep-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insert-timestep-stmt.json
index edbaae60a1..9522f0e7b5 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insert-timestep-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insert-timestep-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file":"./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertBinaryLenLarge16374AllcolLar49151-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertBinaryLenLarge16374AllcolLar49151-stmt.json
index 1c72b4f402..bcbda0a301 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insertBinaryLenLarge16374AllcolLar49151-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertBinaryLenLarge16374AllcolLar49151-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTab0-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTab0-stmt.json
index 4626babd95..2b30aa3e9e 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTab0-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTab0-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTabLess0-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTabLess0-stmt.json
index f140883de1..f3c577b30c 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTabLess0-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertChildTabLess0-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsAndTagNum4096-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsAndTagNum4096-stmt.json
index d1d2db2df3..a0ff887250 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsAndTagNum4096-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsAndTagNum4096-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsNum0-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsNum0-stmt.json
index d79d4cace5..5ff9ec63a2 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsNum0-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertColumnsNum0-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertInterlaceRowsLarge1M-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertInterlaceRowsLarge1M-stmt.json
index eb0ab0f04a..79ce66097b 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insertInterlaceRowsLarge1M-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertInterlaceRowsLarge1M-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertMaxNumPerReq-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertMaxNumPerReq-stmt.json
index 489632c645..4b21f0a184 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insertMaxNumPerReq-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertMaxNumPerReq-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReq0-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReq0-stmt.json
index 19eb92bf4c..9fb85aef23 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReq0-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReq0-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReqless0-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReqless0-stmt.json
index dbda4f74a1..80944de3f5 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReqless0-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertNumOfrecordPerReqless0-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertSigcolumnsNum4096-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertSigcolumnsNum4096-stmt.json
index 966c285d2f..834ffb56d3 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insertSigcolumnsNum4096-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertSigcolumnsNum4096-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertTagsNumLarge128-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertTagsNumLarge128-stmt.json
index c1fc02553f..f39aa94830 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insertTagsNumLarge128-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertTagsNumLarge128-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/insertTimestepMulRowsLargeint16-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/insertTimestepMulRowsLargeint16-stmt.json
index ed3eb280f6..6345227788 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/insertTimestepMulRowsLargeint16-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/insertTimestepMulRowsLargeint16-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/stmt/nsertColumnsAndTagNumLarge4096-stmt.json b/tests/pytest/tools/taosdemoAllTest/stmt/nsertColumnsAndTagNumLarge4096-stmt.json
index 1d7ad8a90e..75a365bbff 100644
--- a/tests/pytest/tools/taosdemoAllTest/stmt/nsertColumnsAndTagNumLarge4096-stmt.json
+++ b/tests/pytest/tools/taosdemoAllTest/stmt/nsertColumnsAndTagNumLarge4096-stmt.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/subInsertdata.json b/tests/pytest/tools/taosdemoAllTest/subInsertdata.json
index 1ca302a320..f5e7ac3018 100644
--- a/tests/pytest/tools/taosdemoAllTest/subInsertdata.json
+++ b/tests/pytest/tools/taosdemoAllTest/subInsertdata.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/subInsertdataMaxsql100.json b/tests/pytest/tools/taosdemoAllTest/subInsertdataMaxsql100.json
index ef63546278..896a72598d 100644
--- a/tests/pytest/tools/taosdemoAllTest/subInsertdataMaxsql100.json
+++ b/tests/pytest/tools/taosdemoAllTest/subInsertdataMaxsql100.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoInsertMSDB.json b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertMSDB.json
index b6e5847b54..8211a92a2d 100644
--- a/tests/pytest/tools/taosdemoAllTest/taosdemoInsertMSDB.json
+++ b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertMSDB.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 10,
+ "create_table_thread_count": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoInsertNanoDB.json b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertNanoDB.json
index ed97fea33e..304ff99c26 100644
--- a/tests/pytest/tools/taosdemoAllTest/taosdemoInsertNanoDB.json
+++ b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertNanoDB.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 10,
+ "create_table_thread_count": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoInsertUSDB.json b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertUSDB.json
index db34bfc6b8..444e6564be 100644
--- a/tests/pytest/tools/taosdemoAllTest/taosdemoInsertUSDB.json
+++ b/tests/pytest/tools/taosdemoAllTest/taosdemoInsertUSDB.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 10,
+ "create_table_thread_count": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabase.json b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabase.json
index d029ddea21..67003a1fb5 100644
--- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabase.json
+++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabase.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 10,
+ "create_table_thread_count": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseInsertForSub.json b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseInsertForSub.json
index f8a181d352..7454af6521 100644
--- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseInsertForSub.json
+++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseInsertForSub.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 10,
+ "create_table_thread_count": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseNow.json b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseNow.json
index b06ec55ef6..602a39ca24 100644
--- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseNow.json
+++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabaseNow.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 10,
+ "create_table_thread_count": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabasecsv.json b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabasecsv.json
index 6a6a6da297..79d3bc5ed8 100644
--- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabasecsv.json
+++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestNanoDatabasecsv.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 10,
+ "create_table_thread_count": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tools/taosdemoPerformance.py b/tests/pytest/tools/taosdemoPerformance.py
index 82c57a656d..9a4b564319 100644
--- a/tests/pytest/tools/taosdemoPerformance.py
+++ b/tests/pytest/tools/taosdemoPerformance.py
@@ -94,7 +94,7 @@ class taosdemoPerformace:
"user": "root",
"password": "taosdata",
"thread_count": 10,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"databases": [db]
}
diff --git a/tests/pytest/tsdb/insertDataDb1.json b/tests/pytest/tsdb/insertDataDb1.json
index 92735dad69..f771551b26 100644
--- a/tests/pytest/tsdb/insertDataDb1.json
+++ b/tests/pytest/tsdb/insertDataDb1.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tsdb/insertDataDb1Replica2.json b/tests/pytest/tsdb/insertDataDb1Replica2.json
index a5fc525157..ec84d71d88 100644
--- a/tests/pytest/tsdb/insertDataDb1Replica2.json
+++ b/tests/pytest/tsdb/insertDataDb1Replica2.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tsdb/insertDataDb2.json b/tests/pytest/tsdb/insertDataDb2.json
index 02301e0242..494465d23c 100644
--- a/tests/pytest/tsdb/insertDataDb2.json
+++ b/tests/pytest/tsdb/insertDataDb2.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tsdb/insertDataDb2Newstab.json b/tests/pytest/tsdb/insertDataDb2Newstab.json
index 2f5f2367b4..647a587cad 100644
--- a/tests/pytest/tsdb/insertDataDb2Newstab.json
+++ b/tests/pytest/tsdb/insertDataDb2Newstab.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tsdb/insertDataDb2NewstabReplica2.json b/tests/pytest/tsdb/insertDataDb2NewstabReplica2.json
index 67f3b2cd4f..13cf2e561c 100644
--- a/tests/pytest/tsdb/insertDataDb2NewstabReplica2.json
+++ b/tests/pytest/tsdb/insertDataDb2NewstabReplica2.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/tsdb/insertDataDb2Replica2.json b/tests/pytest/tsdb/insertDataDb2Replica2.json
index 3d033f13cc..c651657a6d 100644
--- a/tests/pytest/tsdb/insertDataDb2Replica2.json
+++ b/tests/pytest/tsdb/insertDataDb2Replica2.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/util/taosdemoCfg.py b/tests/pytest/util/taosdemoCfg.py
index 7523a80898..f708d303de 100644
--- a/tests/pytest/util/taosdemoCfg.py
+++ b/tests/pytest/util/taosdemoCfg.py
@@ -50,7 +50,7 @@ class TDTaosdemoCfg:
"user": "root",
"password": "taosdata",
"thread_count": cpu_count(),
- "thread_count_create_tbl": cpu_count(),
+ "create_table_thread_count": cpu_count(),
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/wal/insertDataDb1.json b/tests/pytest/wal/insertDataDb1.json
index a14fe58141..2dc0cf2b7f 100644
--- a/tests/pytest/wal/insertDataDb1.json
+++ b/tests/pytest/wal/insertDataDb1.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/wal/insertDataDb1Replica2.json b/tests/pytest/wal/insertDataDb1Replica2.json
index a5fc525157..ec84d71d88 100644
--- a/tests/pytest/wal/insertDataDb1Replica2.json
+++ b/tests/pytest/wal/insertDataDb1Replica2.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/wal/insertDataDb2.json b/tests/pytest/wal/insertDataDb2.json
index 891a21f73e..35232a6333 100644
--- a/tests/pytest/wal/insertDataDb2.json
+++ b/tests/pytest/wal/insertDataDb2.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/wal/insertDataDb2Newstab.json b/tests/pytest/wal/insertDataDb2Newstab.json
index 2f5f2367b4..647a587cad 100644
--- a/tests/pytest/wal/insertDataDb2Newstab.json
+++ b/tests/pytest/wal/insertDataDb2Newstab.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/wal/insertDataDb2NewstabReplica2.json b/tests/pytest/wal/insertDataDb2NewstabReplica2.json
index 67f3b2cd4f..13cf2e561c 100644
--- a/tests/pytest/wal/insertDataDb2NewstabReplica2.json
+++ b/tests/pytest/wal/insertDataDb2NewstabReplica2.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/pytest/wal/insertDataDb2Replica2.json b/tests/pytest/wal/insertDataDb2Replica2.json
index 3d033f13cc..c651657a6d 100644
--- a/tests/pytest/wal/insertDataDb2Replica2.json
+++ b/tests/pytest/wal/insertDataDb2Replica2.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 4,
- "thread_count_create_tbl": 4,
+ "create_table_thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/system-test/1-insert/manyVgroups.json b/tests/system-test/1-insert/manyVgroups.json
index 20ac320552..3b0fa96b08 100644
--- a/tests/system-test/1-insert/manyVgroups.json
+++ b/tests/system-test/1-insert/manyVgroups.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 8,
- "thread_count_create_tbl": 8,
+ "create_table_thread_count": 8,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tests/system-test/1-insert/performanceInsert.json b/tests/system-test/1-insert/performanceInsert.json
index de410c30f2..7278a6f735 100644
--- a/tests/system-test/1-insert/performanceInsert.json
+++ b/tests/system-test/1-insert/performanceInsert.json
@@ -6,7 +6,7 @@
"user": "root",
"password": "taosdata",
"thread_count": 8,
- "thread_count_create_tbl": 8,
+ "create_table_thread_count": 8,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c
index 4526ff2230..f0bda82172 100644
--- a/tools/shell/src/shellEngine.c
+++ b/tools/shell/src/shellEngine.c
@@ -22,7 +22,8 @@
static bool shellIsEmptyCommand(const char *cmd);
static int32_t shellRunSingleCommand(char *command);
-static int32_t shellRunCommand(char *command);
+static void shellRecordCommandToHistory(char *command);
+static int32_t shellRunCommand(char *command, bool recordHistory);
static void shellRunSingleCommandImp(char *command);
static char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision);
static int32_t shellDumpResultToFile(const char *fname, TAOS_RES *tres);
@@ -101,11 +102,7 @@ int32_t shellRunSingleCommand(char *command) {
return 0;
}
-int32_t shellRunCommand(char *command) {
- if (shellIsEmptyCommand(command)) {
- return 0;
- }
-
+void shellRecordCommandToHistory(char *command) {
SShellHistory *pHistory = &shell.history;
if (pHistory->hstart == pHistory->hend ||
pHistory->hist[(pHistory->hend + SHELL_MAX_HISTORY_SIZE - 1) % SHELL_MAX_HISTORY_SIZE] == NULL ||
@@ -120,6 +117,14 @@ int32_t shellRunCommand(char *command) {
pHistory->hstart = (pHistory->hstart + 1) % SHELL_MAX_HISTORY_SIZE;
}
}
+}
+
+int32_t shellRunCommand(char *command, bool recordHistory) {
+ if (shellIsEmptyCommand(command)) {
+ return 0;
+ }
+
+ if (recordHistory) shellRecordCommandToHistory(command);
char quote = 0, *cmd = command;
for (char c = *command++; c != 0; c = *command++) {
@@ -826,11 +831,15 @@ void shellSourceFile(const char *file) {
size_t cmd_len = 0;
char *line = NULL;
char fullname[PATH_MAX] = {0};
+ char sourceFileCommand[PATH_MAX + 8] = {0};
if (taosExpandDir(file, fullname, PATH_MAX) != 0) {
tstrncpy(fullname, file, PATH_MAX);
}
+ sprintf(sourceFileCommand, "source %s;",fullname);
+ shellRecordCommandToHistory(sourceFileCommand);
+
TdFilePtr pFile = taosOpenFile(fullname, TD_FILE_READ | TD_FILE_STREAM);
if (pFile == NULL) {
fprintf(stderr, "failed to open file %s\r\n", fullname);
@@ -853,9 +862,13 @@ void shellSourceFile(const char *file) {
continue;
}
+ if (line[read_len - 1] == '\r') {
+ line[read_len - 1] = ' ';
+ }
+
memcpy(cmd + cmd_len, line, read_len);
printf("%s%s\r\n", shell.info.promptHeader, cmd);
- shellRunCommand(cmd);
+ shellRunCommand(cmd, false);
memset(cmd, 0, TSDB_MAX_ALLOWED_SQL_LEN);
cmd_len = 0;
}
@@ -977,7 +990,7 @@ void *shellThreadLoop(void *arg) {
}
taosResetTerminalMode();
- } while (shellRunCommand(command) == 0);
+ } while (shellRunCommand(command, true) == 0);
taosMemoryFreeClear(command);
shellWriteHistory();
@@ -1019,7 +1032,7 @@ int32_t shellExecute() {
if (pArgs->commands != NULL) {
printf("%s%s\r\n", shell.info.promptHeader, pArgs->commands);
char *cmd = strdup(pArgs->commands);
- shellRunCommand(cmd);
+ shellRunCommand(cmd, true);
taosMemoryFree(cmd);
}