other: merge 3.0

This commit is contained in:
Haojun Liao 2024-08-21 14:39:53 +08:00
commit 1d50aae710
96 changed files with 1493 additions and 827 deletions

1
.gitignore vendored
View File

@ -134,3 +134,4 @@ tags
.clangd .clangd
*CMakeCache* *CMakeCache*
*CMakeFiles* *CMakeFiles*
.history/

View File

@ -0,0 +1,168 @@
---
toc_max_heading_level: 4
title: 权限管理
---
TDengine 中的权限管理分为[用户管理](../user)、数据库授权管理以及消息订阅授权管理,本节重点说明数据库授权和订阅授权。
## 数据库访问授权
系统管理员可以根据业务需要对系统中的每个用户针对每个数据库进行特定的授权,以防止业务数据被不恰当的用户读取或修改。对某个用户进行数据库访问授权的语法如下:
```sql
GRANT privileges ON priv_level TO user_name
privileges : {
ALL
| priv_type [, priv_type] ...
}
priv_type : {
READ
| WRITE
}
priv_level : {
dbname.tbname
| dbname.*
| *.*
}
```
对数据库的访问权限包含读和写两种权限,它们可以被分别授予,也可以被同时授予。
说明
- priv_level 格式中 "." 之前为数据库名称, "." 之后为表名称,意思为表级别的授权控制。如果 "." 之后为 "\*" ,意为 "." 前所指定的数据库中的所有表
- "dbname.\*" 意思是名为 "dbname" 的数据库中的所有表
- "\*.\*" 意思是所有数据库名中的所有表
### 数据库权限说明
对 root 用户和普通用户的权限的说明如下表
| 用户 | 描述 | 权限说明 |
| -------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 超级用户 | 只有 root 是超级用户 | DB 外部 所有操作权限例如user、dnode、udf、qnode等的CRUD DB 权限,包括 创建 删除 更新,例如修改 Option移动 Vgruop等 读 写 Enable/Disable 用户 |
| 普通用户 | 除 root 以外的其它用户均为普通用户 | 在可读的 DB 中,普通用户可以进行读操作 select describe show subscribe 在可写 DB 的内部,用户可以进行写操作: 创建、删除、修改 超级表 创建、删除、修改 子表 创建、删除、修改 topic 写入数据 被限制系统信息时,不可进行如下操作 show dnode、mnode、vgroups、qnode、snode 修改用户包括自身密码 show db时只能看到自己的db并且不能看到vgroups、副本、cache等信息 无论是否被限制系统信息,都可以 管理 udf 可以创建 DB 自己创建的 DB 具备所有权限 非自己创建的 DB ,参照读、写列表中的权限 |
## 消息订阅授权
任意用户都可以在自己拥有读权限的数据库上创建 topic。超级用户 root 可以在任意数据库上创建 topic。每个 topic 的订阅权限都可以被独立授权给任何用户,不管该用户是否拥有该数据库的访问权限。删除 topic 只能由 root 用户或者该 topic 的创建者进行。topic 只能由超级用户、topic的创建者或者被显式授予 subscribe 权限的用户订阅。
具体的 SQL 语法如下:
```sql
GRANT SUBSCRIBE ON topic_name TO user_name
REVOKE SUBSCRIBE ON topic_name FROM user_name
```
## 基于标签的授权(表级授权)
从 TDengine 3.0.5.0 开始,我们支持按标签授权某个超级表中部分特定的子表。具体的 SQL 语法如下。
```sql
GRANT privileges ON priv_level [WITH tag_condition] TO user_name
privileges : {
ALL
| priv_type [, priv_type] ...
}
priv_type : {
READ
| WRITE
}
priv_level : {
dbname.tbname
| dbname.*
| *.*
}
REVOKE privileges ON priv_level [WITH tag_condition] FROM user_name
privileges : {
ALL
| priv_type [, priv_type] ...
}
priv_type : {
READ
| WRITE
}
priv_level : {
dbname.tbname
| dbname.*
| *.*
}
```
上面 SQL 的语义为:
- 用户可以通过 dbname.tbname 来为指定的表(包括超级表和普通表)授予或回收其读写权限,不支持直接对子表授予或回收权限。
- 用户可以通过 dbname.tbname 和 WITH 子句来为符合条件的所有子表授予或回收其读写权限。使用 WITH 子句时,权限级别必须为超级表。
## 表级权限和数据库权限的关系
下表列出了在不同的数据库授权和表级授权的组合下产生的实际权限。
| | **表无授权** | **表读授权** | **表读授权有标签条件** | **表写授权** | **表写授权有标签条件** |
| ---------------- | ---------------- | ---------------------------------------- | ------------------------------------------------------------ | ---------------------------------------- | ---------------------------------------------------------- |
| **数据库无授权** | 无授权 | 对此表有读权限,对数据库下的其他表无权限 | 对此表符合标签权限的子表有读权限,对数据库下的其他表无权限 | 对此表有写权限,对数据库下的其他表无权限 | 对此表符合标签权限的子表有写权限,对数据库下的其他表无权限 |
| **数据库读授权** | 对所有表有读权限 | 对所有表有读权限 | 对此表符合标签权限的子表有读权限,对数据库下的其他表有读权限 | 对此表有写权限,对所有表有读权限 | 对此表符合标签权限的子表有写权限,所有表有读权限 |
| **数据库写授权** | 对所有表有写权限 | 对此表有读权限,对所有表有写权限 | 对此表符合标签权限的子表有读权限,对所有表有写权限 | 对所有表有写权限 | 对此表符合标签权限的子表有写权限,数据库下的其他表有写权限 |
## 查看用户授权
使用下面的命令可以显示一个用户所拥有的授权:
```sql
show user privileges
```
## 撤销授权
1. 撤销数据库访问的授权
```sql
REVOKE privileges ON priv_level FROM user_name
privileges : {
ALL
| priv_type [, priv_type] ...
}
priv_type : {
READ
| WRITE
}
priv_level : {
dbname.tbname
| dbname.*
| *.*
}
```
2. 撤销数据订阅的授权
```sql
REVOKE privileges ON priv_level FROM user_name
privileges : {
ALL
| priv_type [, priv_type] ...
}
priv_type : {
SUBSCRIBE
}
priv_level : {
topic_name
}
```

View File

@ -27,22 +27,21 @@ TDengine Source Connector 用于把数据实时地从 TDengine 读出来发送
## 安装 Kafka ## 安装 Kafka
在任意目录下执行: - 在任意目录下执行:
```shell ```shell
curl -O https://downloads.apache.org/kafka/3.4.0/kafka_2.13-3.4.0.tgz curl -O https://downloads.apache.org/kafka/3.4.0/kafka_2.13-3.4.0.tgz
tar xzf kafka_2.13-3.4.0.tgz -C /opt/ tar xzf kafka_2.13-3.4.0.tgz -C /opt/
ln -s /opt/kafka_2.13-3.4.0 /opt/kafka ln -s /opt/kafka_2.13-3.4.0 /opt/kafka
``` ```
然后需要把 `$KAFKA_HOME/bin` 目录加入 PATH。 - 然后需要把 `$KAFKA_HOME/bin` 目录加入 PATH。
```title=".profile" ```title=".profile"
export KAFKA_HOME=/opt/kafka export KAFKA_HOME=/opt/kafka
export PATH=$PATH:$KAFKA_HOME/bin export PATH=$PATH:$KAFKA_HOME/bin
``` ```
以上脚本可以追加到当前用户的 profile 文件(~/.profile 或 ~/.bash_profile
以上脚本可以追加到当前用户的 profile 文件(~/.profile 或 ~/.bash_profile
## 安装 TDengine Connector 插件 ## 安装 TDengine Connector 插件
@ -325,6 +324,21 @@ curl -X DELETE http://localhost:8083/connectors/TDengineSinkConnector
curl -X DELETE http://localhost:8083/connectors/TDengineSourceConnector curl -X DELETE http://localhost:8083/connectors/TDengineSourceConnector
``` ```
### 性能调优
如果在从 TDengine 同步数据到 Kafka 的过程中发现性能不达预期,可以尝试使用如下参数提升 Kafka 的写入吞吐量。
1. 打开 KAFKA_HOME/config/producer.properties 配置文件。
2. 参数说明及配置建议如下:
| **参数** | **参数说明** | **设置建议** |
| --------| --------------------------------- | -------------- |
| producer.type | 此参数用于设置消息的发送方式,默认值为 `sync` 表示同步发送,`async` 表示异步发送。采用异步发送能够提升消息发送的吞吐量。 | async |
| request.required.acks | 参数用于配置生产者发送消息后需要等待的确认数量。当设置为1时表示只要领导者副本成功写入消息就会给生产者发送确认而无需等待集群中的其他副本写入成功。这种设置可以在一定程度上保证消息的可靠性同时也能保证一定的吞吐量。因为不需要等待所有副本都写入成功所以可以减少生产者的等待时间提高发送消息的效率。|1|
| max.request.size| 该参数决定了生产者在一次请求中可以发送的最大数据量。其默认值为 1048576也就是 1M。如果设置得太小可能会导致频繁的网络请求降低吞吐量。如果设置得太大可能会导致内存占用过高或者在网络状况不佳时增加请求失败的概率。建议设置为 100M。|104857600|
|batch.size| 此参数用于设定 batch 的大小,默认值为 16384即 16KB。在消息发送过程中发送到 Kafka 缓冲区中的消息会被划分成一个个的 batch。故而减小 batch 大小有助于降低消息延迟,而增大 batch 大小则有利于提升吞吐量,可根据实际的数据量大小进行合理配置。可根据实际情况进行调整,建议设置为 512K。|524288|
| buffer.memory| 此参数用于设置生产者缓冲待发送消息的内存总量。较大的缓冲区可以允许生产者积累更多的消息后批量发送,提高吞吐量,但也会增加延迟和内存使用。可根据机器资源来配置,建议配置为 1G。|1073741824|
## 配置参考 ## 配置参考
### 通用配置 ### 通用配置

View File

@ -156,11 +156,11 @@ typedef struct SSnapshotParam {
typedef struct SSnapshot { typedef struct SSnapshot {
int32_t type; int32_t type;
SSyncTLV* data; SSyncTLV* data;
ESyncFsmState state; ESyncFsmState state;
SyncIndex lastApplyIndex; SyncIndex lastApplyIndex;
SyncTerm lastApplyTerm; SyncTerm lastApplyTerm;
SyncIndex lastConfigIndex; SyncIndex lastConfigIndex;
} SSnapshot; } SSnapshot;
typedef struct SSnapshotMeta { typedef struct SSnapshotMeta {
@ -263,16 +263,16 @@ typedef struct SSyncState {
int64_t startTimeMs; int64_t startTimeMs;
} SSyncState; } SSyncState;
int32_t syncInit(); int32_t syncInit();
void syncCleanUp(); void syncCleanUp();
int64_t syncOpen(SSyncInfo* pSyncInfo, int32_t vnodeVersion); int64_t syncOpen(SSyncInfo* pSyncInfo, int32_t vnodeVersion);
int32_t syncStart(int64_t rid); int32_t syncStart(int64_t rid);
void syncStop(int64_t rid); void syncStop(int64_t rid);
void syncPreStop(int64_t rid); void syncPreStop(int64_t rid);
void syncPostStop(int64_t rid); void syncPostStop(int64_t rid);
int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak, int64_t* seq); int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak, int64_t* seq);
int32_t syncCheckMember(int64_t rid); int32_t syncCheckMember(int64_t rid);
int32_t syncIsCatchUp(int64_t rid); int32_t syncIsCatchUp(int64_t rid);
ESyncRole syncGetRole(int64_t rid); ESyncRole syncGetRole(int64_t rid);
int64_t syncGetTerm(int64_t rid); int64_t syncGetTerm(int64_t rid);
int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg); int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg);
@ -296,7 +296,7 @@ int32_t syncGetAssignedLogSynced(int64_t rid);
void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet); void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet);
const char* syncStr(ESyncState state); const char* syncStr(ESyncState state);
int32_t syncNodeGetConfig(int64_t rid, SSyncCfg *cfg); int32_t syncNodeGetConfig(int64_t rid, SSyncCfg* cfg);
// util // util
int32_t syncSnapInfoDataRealloc(SSnapshot* pSnap, int32_t size); int32_t syncSnapInfoDataRealloc(SSnapshot* pSnap, int32_t size);

View File

@ -604,6 +604,9 @@ int32_t taosGetErrSize();
#define TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x0732) #define TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x0732)
#define TSDB_CODE_QRY_INVALID_JOIN_CONDITION TAOS_DEF_ERROR_CODE(0, 0x0733) #define TSDB_CODE_QRY_INVALID_JOIN_CONDITION TAOS_DEF_ERROR_CODE(0, 0x0733)
#define TSDB_CODE_QRY_FILTER_NOT_SUPPORT_TYPE TAOS_DEF_ERROR_CODE(0, 0x0734) #define TSDB_CODE_QRY_FILTER_NOT_SUPPORT_TYPE TAOS_DEF_ERROR_CODE(0, 0x0734)
#define TSDB_CODE_QRY_FILTER_WRONG_OPTR_TYPE TAOS_DEF_ERROR_CODE(0, 0x0735)
#define TSDB_CODE_QRY_FILTER_RANGE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0736)
#define TSDB_CODE_QRY_FILTER_INVALID_TYPE TAOS_DEF_ERROR_CODE(0, 0x0737)
// grant // grant
#define TSDB_CODE_GRANT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0800) #define TSDB_CODE_GRANT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0800)
@ -878,6 +881,8 @@ int32_t taosGetErrSize();
#define TSDB_CODE_FUNC_INVALID_VALUE_RANGE TAOS_DEF_ERROR_CODE(0, 0x280C) #define TSDB_CODE_FUNC_INVALID_VALUE_RANGE TAOS_DEF_ERROR_CODE(0, 0x280C)
#define TSDB_CODE_FUNC_SETUP_ERROR TAOS_DEF_ERROR_CODE(0, 0x280D) #define TSDB_CODE_FUNC_SETUP_ERROR TAOS_DEF_ERROR_CODE(0, 0x280D)
#define TSDB_CODE_FUNC_INVALID_RES_LENGTH TAOS_DEF_ERROR_CODE(0, 0x280E) #define TSDB_CODE_FUNC_INVALID_RES_LENGTH TAOS_DEF_ERROR_CODE(0, 0x280E)
#define TSDB_CODE_FUNC_HISTOGRAM_ERROR TAOS_DEF_ERROR_CODE(0, 0x280F)
#define TSDB_CODE_FUNC_PERCENTILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x2810)
//udf //udf
@ -892,6 +897,7 @@ int32_t taosGetErrSize();
#define TSDB_CODE_UDF_SCRIPT_NOT_SUPPORTED TAOS_DEF_ERROR_CODE(0, 0x2909) #define TSDB_CODE_UDF_SCRIPT_NOT_SUPPORTED TAOS_DEF_ERROR_CODE(0, 0x2909)
#define TSDB_CODE_UDF_FUNC_EXEC_FAILURE TAOS_DEF_ERROR_CODE(0, 0x290A) #define TSDB_CODE_UDF_FUNC_EXEC_FAILURE TAOS_DEF_ERROR_CODE(0, 0x290A)
#define TSDB_CODE_UDF_UV_EXEC_FAILURE TAOS_DEF_ERROR_CODE(0, 0x290B) #define TSDB_CODE_UDF_UV_EXEC_FAILURE TAOS_DEF_ERROR_CODE(0, 0x290B)
#define TSDB_CODE_UDF_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2920)
// sml // sml
#define TSDB_CODE_SML_INVALID_PROTOCOL_TYPE TAOS_DEF_ERROR_CODE(0, 0x3000) #define TSDB_CODE_SML_INVALID_PROTOCOL_TYPE TAOS_DEF_ERROR_CODE(0, 0x3000)

View File

@ -213,7 +213,6 @@ static FORCE_INLINE int32_t taosEncodeVariantU16(void **buf, uint16_t value) {
if (buf != NULL) ((uint8_t *)(*buf))[i] = (uint8_t)(value | ENCODE_LIMIT); if (buf != NULL) ((uint8_t *)(*buf))[i] = (uint8_t)(value | ENCODE_LIMIT);
value >>= 7; value >>= 7;
i++; i++;
ASSERT(i < 3);
} }
if (buf != NULL) { if (buf != NULL) {
@ -261,7 +260,6 @@ static FORCE_INLINE int32_t taosEncodeVariantU32(void **buf, uint32_t value) {
if (buf != NULL) ((uint8_t *)(*buf))[i] = (value | ENCODE_LIMIT); if (buf != NULL) ((uint8_t *)(*buf))[i] = (value | ENCODE_LIMIT);
value >>= 7; value >>= 7;
i++; i++;
ASSERT(i < 5);
} }
if (buf != NULL) { if (buf != NULL) {
@ -309,7 +307,6 @@ static FORCE_INLINE int32_t taosEncodeVariantU64(void **buf, uint64_t value) {
if (buf != NULL) ((uint8_t *)(*buf))[i] = (uint8_t)(value | ENCODE_LIMIT); if (buf != NULL) ((uint8_t *)(*buf))[i] = (uint8_t)(value | ENCODE_LIMIT);
value >>= 7; value >>= 7;
i++; i++;
ASSERT(i < 10);
} }
if (buf != NULL) { if (buf != NULL) {

View File

@ -29,8 +29,7 @@ typedef void (*RefFp)(void *);
int32_t taosOpenRef(int32_t max, RefFp fp); int32_t taosOpenRef(int32_t max, RefFp fp);
// close the reference set, refId is the return value by taosOpenRef // close the reference set, refId is the return value by taosOpenRef
// return 0 if success. On error, -1 is returned, and terrno is set appropriately void taosCloseRef(int32_t rsetId);
int32_t taosCloseRef(int32_t rsetId);
// add ref, p is the pointer to resource or pointer ID // add ref, p is the pointer to resource or pointer ID
// return Reference ID(rid) allocated. On error, -1 is returned, and terrno is set appropriately // return Reference ID(rid) allocated. On error, -1 is returned, and terrno is set appropriately

View File

@ -139,6 +139,13 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
#define QUERY_CHECK_CODE TSDB_CHECK_CODE #define QUERY_CHECK_CODE TSDB_CHECK_CODE
#define QUERY_CHECK_CONDITION(condition, CODE, LINO, LABEL, ERRNO) \
if (!condition) { \
(CODE) = (ERRNO); \
(LINO) = __LINE__; \
goto LABEL; \
}
#define TSDB_CHECK_NULL(ptr, CODE, LINO, LABEL, ERRNO) \ #define TSDB_CHECK_NULL(ptr, CODE, LINO, LABEL, ERRNO) \
if ((ptr) == NULL) { \ if ((ptr) == NULL) { \
(CODE) = (ERRNO); \ (CODE) = (ERRNO); \

View File

@ -166,7 +166,10 @@ int32_t taos_connect_internal(const char* ip, const char* user, const char* pass
pInst = &p; pInst = &p;
} else { } else {
ASSERTS((*pInst) && (*pInst)->pAppHbMgr, "*pInst:%p, pAppHgMgr:%p", *pInst, (*pInst) ? (*pInst)->pAppHbMgr : NULL); if (NULL == *pInst || NULL == (*pInst)->pAppHbMgr) {
tscError("*pInst:%p, pAppHgMgr:%p", *pInst, (*pInst) ? (*pInst)->pAppHbMgr : NULL);
TSC_ERR_JRET(TSDB_CODE_TSC_INTERNAL_ERROR);
}
// reset to 0 in case of conn with duplicated user key but its user has ever been dropped. // reset to 0 in case of conn with duplicated user key but its user has ever been dropped.
atomic_store_8(&(*pInst)->pAppHbMgr->connHbFlag, 0); atomic_store_8(&(*pInst)->pAppHbMgr->connHbFlag, 0);
} }
@ -1135,8 +1138,6 @@ void schedulerExecCb(SExecResult* pResult, void* param, int32_t code) {
(void)atomic_add_fetch_64((int64_t*)&pActivity->numOfInsertRows, pResult->numOfRows); (void)atomic_add_fetch_64((int64_t*)&pActivity->numOfInsertRows, pResult->numOfRows);
} }
} }
schedulerFreeJob(&pRequest->body.queryJob, 0);
} }
taosMemoryFree(pResult); taosMemoryFree(pResult);
@ -2038,9 +2039,9 @@ static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, i
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column // | version | total length | total rows | total columns | flag seg| block group id | column schema | each column
// length | // length |
int32_t cols = *(int32_t*)(p + sizeof(int32_t) * 3); int32_t cols = *(int32_t*)(p + sizeof(int32_t) * 3);
if (ASSERT(numOfCols == cols)) { if (numOfCols != cols) {
tscError("estimateJsonLen error: numOfCols:%d != cols:%d", numOfCols, cols); tscError("estimateJsonLen error: numOfCols:%d != cols:%d", numOfCols, cols);
return -1; return TSDB_CODE_TSC_INTERNAL_ERROR;
} }
int32_t len = getVersion1BlockMetaSize(p, numOfCols); int32_t len = getVersion1BlockMetaSize(p, numOfCols);
@ -2125,7 +2126,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
int32_t totalLen = 0; int32_t totalLen = 0;
int32_t cols = *(int32_t*)(p + sizeof(int32_t) * 3); int32_t cols = *(int32_t*)(p + sizeof(int32_t) * 3);
if (ASSERT(numOfCols == cols)) { if (numOfCols != cols) {
tscError("doConvertJson error: numOfCols:%d != cols:%d", numOfCols, cols); tscError("doConvertJson error: numOfCols:%d != cols:%d", numOfCols, cols);
return TSDB_CODE_TSC_INTERNAL_ERROR; return TSDB_CODE_TSC_INTERNAL_ERROR;
} }
@ -2150,7 +2151,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
for (int32_t i = 0; i < numOfCols; ++i) { for (int32_t i = 0; i < numOfCols; ++i) {
int32_t colLen = (blockVersion == BLOCK_VERSION_1) ? htonl(colLength[i]) : colLength[i]; int32_t colLen = (blockVersion == BLOCK_VERSION_1) ? htonl(colLength[i]) : colLength[i];
int32_t colLen1 = (blockVersion == BLOCK_VERSION_1) ? htonl(colLength1[i]) : colLength1[i]; int32_t colLen1 = (blockVersion == BLOCK_VERSION_1) ? htonl(colLength1[i]) : colLength1[i];
if (ASSERT(colLen < dataLen)) { if (colLen >= dataLen) {
tscError("doConvertJson error: colLen:%d >= dataLen:%d", colLen, dataLen); tscError("doConvertJson error: colLen:%d >= dataLen:%d", colLen, dataLen);
return TSDB_CODE_TSC_INTERNAL_ERROR; return TSDB_CODE_TSC_INTERNAL_ERROR;
} }
@ -2238,7 +2239,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows, int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows,
bool convertUcs4) { bool convertUcs4) {
if (ASSERT(numOfCols > 0 && pFields != NULL && pResultInfo != NULL)) { if (numOfCols <= 0 || pFields == NULL || pResultInfo == NULL) {
tscError("setResultDataPtr paras error"); tscError("setResultDataPtr paras error");
return TSDB_CODE_TSC_INTERNAL_ERROR; return TSDB_CODE_TSC_INTERNAL_ERROR;
} }
@ -2271,7 +2272,7 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
int32_t cols = *(int32_t*)p; int32_t cols = *(int32_t*)p;
p += sizeof(int32_t); p += sizeof(int32_t);
if (ASSERT(rows == numOfRows && cols == numOfCols)) { if (rows != numOfRows || cols != numOfCols) {
tscError("setResultDataPtr paras error:rows;%d numOfRows:%d cols:%d numOfCols:%d", rows, numOfRows, cols, tscError("setResultDataPtr paras error:rows;%d numOfRows:%d cols:%d numOfCols:%d", rows, numOfRows, cols,
numOfCols); numOfCols);
return TSDB_CODE_TSC_INTERNAL_ERROR; return TSDB_CODE_TSC_INTERNAL_ERROR;
@ -2290,8 +2291,6 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
int32_t bytes = *(int32_t*)p; int32_t bytes = *(int32_t*)p;
p += sizeof(int32_t); p += sizeof(int32_t);
/*ASSERT(type == pFields[i].type && bytes == pFields[i].bytes);*/
} }
int32_t* colLength = (int32_t*)p; int32_t* colLength = (int32_t*)p;
@ -2413,18 +2412,23 @@ int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableR
if (pRsp->compressed && compLen < rawLen) { if (pRsp->compressed && compLen < rawLen) {
int32_t len = tsDecompressString(pStart, compLen, 1, pResultInfo->decompBuf, rawLen, ONE_STAGE_COMP, NULL, 0); int32_t len = tsDecompressString(pStart, compLen, 1, pResultInfo->decompBuf, rawLen, ONE_STAGE_COMP, NULL, 0);
ASSERT(len == rawLen);
if (len < 0) { if (len < 0) {
tscError("tsDecompressString failed"); tscError("tsDecompressString failed");
return terrno ? terrno : TSDB_CODE_FAILED; return terrno ? terrno : TSDB_CODE_FAILED;
} }
if (len != rawLen) {
tscError("tsDecompressString failed, len:%d != rawLen:%d", len, rawLen);
return TSDB_CODE_TSC_INTERNAL_ERROR;
}
pResultInfo->pData = pResultInfo->decompBuf; pResultInfo->pData = pResultInfo->decompBuf;
pResultInfo->payloadLen = rawLen; pResultInfo->payloadLen = rawLen;
} else { } else {
pResultInfo->pData = pStart; pResultInfo->pData = pStart;
pResultInfo->payloadLen = htonl(pRsp->compLen); pResultInfo->payloadLen = htonl(pRsp->compLen);
ASSERT(pRsp->compLen == pRsp->payloadLen); if (pRsp->compLen != pRsp->payloadLen) {
tscError("pRsp->compLen:%d != pRsp->payloadLen:%d", pRsp->compLen, pRsp->payloadLen);
return TSDB_CODE_TSC_INTERNAL_ERROR;
}
} }
} }

View File

@ -74,15 +74,11 @@ void taos_cleanup(void) {
int32_t id = clientReqRefPool; int32_t id = clientReqRefPool;
clientReqRefPool = -1; clientReqRefPool = -1;
if (TSDB_CODE_SUCCESS != taosCloseRef(id)) { taosCloseRef(id);
tscWarn("failed to close clientReqRefPool");
}
id = clientConnRefPool; id = clientConnRefPool;
clientConnRefPool = -1; clientConnRefPool = -1;
if (TSDB_CODE_SUCCESS != taosCloseRef(id)) { taosCloseRef(id);
tscWarn("failed to close clientReqRefPool");
}
nodesDestroyAllocatorSet(); nodesDestroyAllocatorSet();
cleanupAppInfo(); cleanupAppInfo();
@ -481,7 +477,6 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
} else if (TD_RES_TMQ_META(res) || TD_RES_TMQ_BATCH_META(res)) { } else if (TD_RES_TMQ_META(res) || TD_RES_TMQ_BATCH_META(res)) {
return NULL; return NULL;
} else { } else {
// assert to avoid un-initialization error
tscError("invalid result passed to taos_fetch_row"); tscError("invalid result passed to taos_fetch_row");
terrno = TSDB_CODE_TSC_INTERNAL_ERROR; terrno = TSDB_CODE_TSC_INTERNAL_ERROR;
return NULL; return NULL;
@ -561,12 +556,14 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
case TSDB_DATA_TYPE_GEOMETRY: { case TSDB_DATA_TYPE_GEOMETRY: {
int32_t charLen = varDataLen((char *)row[i] - VARSTR_HEADER_SIZE); int32_t charLen = varDataLen((char *)row[i] - VARSTR_HEADER_SIZE);
if (fields[i].type == TSDB_DATA_TYPE_BINARY || fields[i].type == TSDB_DATA_TYPE_VARBINARY || fields[i].type == TSDB_DATA_TYPE_GEOMETRY) { if (fields[i].type == TSDB_DATA_TYPE_BINARY || fields[i].type == TSDB_DATA_TYPE_VARBINARY || fields[i].type == TSDB_DATA_TYPE_GEOMETRY) {
if (ASSERT(charLen <= fields[i].bytes && charLen >= 0)) { if (charLen > fields[i].bytes || charLen < 0) {
tscError("taos_print_row error binary. charLen:%d, fields[i].bytes:%d", charLen, fields[i].bytes); tscError("taos_print_row error binary. charLen:%d, fields[i].bytes:%d", charLen, fields[i].bytes);
break;
} }
} else { } else {
if (ASSERT(charLen <= fields[i].bytes * TSDB_NCHAR_SIZE && charLen >= 0)) { if (charLen > fields[i].bytes * TSDB_NCHAR_SIZE || charLen < 0) {
tscError("taos_print_row error. charLen:%d, fields[i].bytes:%d", charLen, fields[i].bytes); tscError("taos_print_row error. charLen:%d, fields[i].bytes:%d", charLen, fields[i].bytes);
break;
} }
} }
@ -1319,11 +1316,11 @@ void restartAsyncQuery(SRequestObj *pRequest, int32_t code) {
} }
void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) { void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
if (ASSERT(res != NULL && fp != NULL)) { if (res == NULL || fp == NULL) {
tscError("taos_fetch_rows_a invalid paras"); tscError("taos_fetch_rows_a invalid paras");
return; return;
} }
if (ASSERT(TD_RES_QUERY(res))) { if (!TD_RES_QUERY(res)) {
tscError("taos_fetch_rows_a res is NULL"); tscError("taos_fetch_rows_a res is NULL");
return; return;
} }
@ -1338,12 +1335,12 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
} }
void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) { void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
if (ASSERT(res != NULL && fp != NULL)) { if (res == NULL || fp == NULL) {
tscError("taos_fetch_rows_a invalid paras"); tscError("taos_fetch_raw_block_a invalid paras");
return; return;
} }
if (ASSERT(TD_RES_QUERY(res))) { if (!TD_RES_QUERY(res)) {
tscError("taos_fetch_rows_a res is NULL"); tscError("taos_fetch_raw_block_a res is NULL");
return; return;
} }
SRequestObj *pRequest = res; SRequestObj *pRequest = res;
@ -1357,12 +1354,12 @@ void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
} }
const void *taos_get_raw_block(TAOS_RES *res) { const void *taos_get_raw_block(TAOS_RES *res) {
if (ASSERT(res != NULL)) { if (res == NULL) {
tscError("taos_fetch_rows_a invalid paras"); tscError("taos_get_raw_block invalid paras");
return NULL; return NULL;
} }
if (ASSERT(TD_RES_QUERY(res))) { if (!TD_RES_QUERY(res)) {
tscError("taos_fetch_rows_a res is NULL"); tscError("taos_get_raw_block res is NULL");
return NULL; return NULL;
} }
SRequestObj *pRequest = res; SRequestObj *pRequest = res;

View File

@ -1184,7 +1184,7 @@ void tmqMgmtClose(void) {
} }
if (tmqMgmt.rsetId >= 0) { if (tmqMgmt.rsetId >= 0) {
(void)taosCloseRef(tmqMgmt.rsetId); taosCloseRef(tmqMgmt.rsetId);
tmqMgmt.rsetId = -1; tmqMgmt.rsetId = -1;
} }
} }

View File

@ -12,7 +12,7 @@ extern char tsS3AccessKeySecret[][TSDB_FQDN_LEN];
extern char tsS3BucketName[TSDB_FQDN_LEN]; extern char tsS3BucketName[TSDB_FQDN_LEN];
extern char tsS3AppId[][TSDB_FQDN_LEN]; extern char tsS3AppId[][TSDB_FQDN_LEN];
extern char tsS3Hostname[][TSDB_FQDN_LEN]; extern char tsS3Hostname[][TSDB_FQDN_LEN];
extern int8_t tsS3Https; extern int8_t tsS3Https[];
static int32_t s3ListBucketByEp(char const *bucketname, int8_t epIndex); static int32_t s3ListBucketByEp(char const *bucketname, int8_t epIndex);
static int32_t s3PutObjectFromFileOffsetByEp(const char *file, const char *object_name, int64_t offset, int64_t size, static int32_t s3PutObjectFromFileOffsetByEp(const char *file, const char *object_name, int64_t offset, int64_t size,
@ -33,13 +33,13 @@ static int verifyPeerG = 0;
static const char *awsRegionG = NULL; static const char *awsRegionG = NULL;
static int forceG = 0; static int forceG = 0;
static int showResponsePropertiesG = 0; static int showResponsePropertiesG = 0;
static S3Protocol protocolG = S3ProtocolHTTPS; static S3Protocol protocolG[TSDB_MAX_EP_NUM] = {S3ProtocolHTTPS};
// static S3Protocol protocolG = S3ProtocolHTTP; // static S3Protocol protocolG = S3ProtocolHTTP;
static S3UriStyle uriStyleG = S3UriStylePath; static S3UriStyle uriStyleG[TSDB_MAX_EP_NUM] = {S3UriStylePath};
static int retriesG = 5; static int retriesG = 5;
static int timeoutMsG = 0; static int timeoutMsG = 0;
extern int8_t tsS3Oss; extern int8_t tsS3Oss[];
int32_t s3Begin() { int32_t s3Begin() {
S3Status status; S3Status status;
@ -55,9 +55,9 @@ int32_t s3Begin() {
TAOS_RETURN(TSDB_CODE_FAILED); TAOS_RETURN(TSDB_CODE_FAILED);
} }
protocolG = !tsS3Https; for (int i = 0; i < tsS3EpNum; i++) {
if (tsS3Oss) { protocolG[i] = tsS3Https[i] ? S3ProtocolHTTPS : S3ProtocolHTTP;
uriStyleG = S3UriStyleVirtualHost; uriStyleG[i] = tsS3Oss[i] ? S3UriStyleVirtualHost : S3UriStylePath;
} }
TAOS_RETURN(TSDB_CODE_SUCCESS); TAOS_RETURN(TSDB_CODE_SUCCESS);
@ -976,8 +976,8 @@ int32_t s3PutObjectFromFile2ByEp(const char *file, const char *object_name, int8
S3BucketContext bucketContext = {tsS3Hostname[epIndex], S3BucketContext bucketContext = {tsS3Hostname[epIndex],
tsS3BucketName, tsS3BucketName,
protocolG, protocolG[epIndex],
uriStyleG, uriStyleG[epIndex],
tsS3AccessKeyId[epIndex], tsS3AccessKeyId[epIndex],
tsS3AccessKeySecret[epIndex], tsS3AccessKeySecret[epIndex],
0, 0,
@ -1059,8 +1059,8 @@ static int32_t s3PutObjectFromFileOffsetByEp(const char *file, const char *objec
S3BucketContext bucketContext = {tsS3Hostname[epIndex], S3BucketContext bucketContext = {tsS3Hostname[epIndex],
tsS3BucketName, tsS3BucketName,
protocolG, protocolG[epIndex],
uriStyleG, uriStyleG[epIndex],
tsS3AccessKeyId[epIndex], tsS3AccessKeyId[epIndex],
tsS3AccessKeySecret[epIndex], tsS3AccessKeySecret[epIndex],
0, 0,
@ -1155,8 +1155,8 @@ static void s3FreeObjectKey(void *pItem) {
static SArray *getListByPrefixByEp(const char *prefix, int8_t epIndex) { static SArray *getListByPrefixByEp(const char *prefix, int8_t epIndex) {
S3BucketContext bucketContext = {tsS3Hostname[epIndex], S3BucketContext bucketContext = {tsS3Hostname[epIndex],
tsS3BucketName, tsS3BucketName,
protocolG, protocolG[epIndex],
uriStyleG, uriStyleG[epIndex],
tsS3AccessKeyId[epIndex], tsS3AccessKeyId[epIndex],
tsS3AccessKeySecret[epIndex], tsS3AccessKeySecret[epIndex],
0, 0,
@ -1223,8 +1223,8 @@ static int32_t s3DeleteObjectsByEp(const char *object_name[], int nobject, int8_
S3BucketContext bucketContext = {tsS3Hostname[epIndex], S3BucketContext bucketContext = {tsS3Hostname[epIndex],
tsS3BucketName, tsS3BucketName,
protocolG, protocolG[epIndex],
uriStyleG, uriStyleG[epIndex],
tsS3AccessKeyId[epIndex], tsS3AccessKeyId[epIndex],
tsS3AccessKeySecret[epIndex], tsS3AccessKeySecret[epIndex],
0, 0,
@ -1299,8 +1299,8 @@ static int32_t s3GetObjectBlockByEp(const char *object_name, int64_t offset, int
S3BucketContext bucketContext = {tsS3Hostname[epIndex], S3BucketContext bucketContext = {tsS3Hostname[epIndex],
tsS3BucketName, tsS3BucketName,
protocolG, protocolG[epIndex],
uriStyleG, uriStyleG[epIndex],
tsS3AccessKeyId[epIndex], tsS3AccessKeyId[epIndex],
tsS3AccessKeySecret[epIndex], tsS3AccessKeySecret[epIndex],
0, 0,
@ -1372,8 +1372,8 @@ static int32_t s3GetObjectToFileByEp(const char *object_name, const char *fileNa
S3BucketContext bucketContext = {tsS3Hostname[epIndex], S3BucketContext bucketContext = {tsS3Hostname[epIndex],
tsS3BucketName, tsS3BucketName,
protocolG, protocolG[epIndex],
uriStyleG, uriStyleG[epIndex],
tsS3AccessKeyId[epIndex], tsS3AccessKeyId[epIndex],
tsS3AccessKeySecret[epIndex], tsS3AccessKeySecret[epIndex],
0, 0,
@ -1449,8 +1449,8 @@ static long s3SizeByEp(const char *object_name, int8_t epIndex) {
S3BucketContext bucketContext = {tsS3Hostname[epIndex], S3BucketContext bucketContext = {tsS3Hostname[epIndex],
tsS3BucketName, tsS3BucketName,
protocolG, protocolG[epIndex],
uriStyleG, uriStyleG[epIndex],
tsS3AccessKeyId[epIndex], tsS3AccessKeyId[epIndex],
tsS3AccessKeySecret[epIndex], tsS3AccessKeySecret[epIndex],
0, 0,

View File

@ -1976,6 +1976,7 @@ int32_t createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData, SSDataB
code = copyPkVal(&pDstBlock->info, &pDataBlock->info); code = copyPkVal(&pDstBlock->info, &pDataBlock->info);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
blockDataDestroy(pDstBlock);
uError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code)); uError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
return code; return code;
} }
@ -1991,10 +1992,14 @@ int32_t createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData, SSDataB
SColumnInfoData* pDst = taosArrayGet(pDstBlock->pDataBlock, i); SColumnInfoData* pDst = taosArrayGet(pDstBlock->pDataBlock, i);
SColumnInfoData* pSrc = taosArrayGet(pDataBlock->pDataBlock, i); SColumnInfoData* pSrc = taosArrayGet(pDataBlock->pDataBlock, i);
if (pDst == NULL) { if (pDst == NULL) {
blockDataDestroy(pDstBlock);
uError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
return terrno; return terrno;
} }
if (pSrc == NULL) { if (pSrc == NULL) {
blockDataDestroy(pDstBlock);
uError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
return terrno; return terrno;
} }

View File

@ -303,10 +303,10 @@ char tsS3BucketName[TSDB_FQDN_LEN] = "<bucketname>";
char tsS3AppId[TSDB_MAX_EP_NUM][TSDB_FQDN_LEN] = {"<appid>"}; char tsS3AppId[TSDB_MAX_EP_NUM][TSDB_FQDN_LEN] = {"<appid>"};
int8_t tsS3Enabled = false; int8_t tsS3Enabled = false;
int8_t tsS3EnabledCfg = false; int8_t tsS3EnabledCfg = false;
int8_t tsS3Oss = false; int8_t tsS3Oss[TSDB_MAX_EP_NUM] = {false};
int8_t tsS3StreamEnabled = false; int8_t tsS3StreamEnabled = false;
int8_t tsS3Https = true; int8_t tsS3Https[TSDB_MAX_EP_NUM] = {true};
char tsS3Hostname[TSDB_MAX_EP_NUM][TSDB_FQDN_LEN] = {"<hostname>"}; char tsS3Hostname[TSDB_MAX_EP_NUM][TSDB_FQDN_LEN] = {"<hostname>"};
int32_t tsS3BlockSize = -1; // number of tsdb pages (4096) int32_t tsS3BlockSize = -1; // number of tsdb pages (4096)
@ -431,11 +431,10 @@ int32_t taosSetS3Cfg(SConfig *pCfg) {
tstrncpy(tsS3AppId[i], appid + 1, TSDB_FQDN_LEN); tstrncpy(tsS3AppId[i], appid + 1, TSDB_FQDN_LEN);
} }
} }
tsS3Https[i] = (strstr(tsS3Endpoint[i], "https://") != NULL);
tsS3Oss[i] = (strstr(tsS3Endpoint[i], "aliyuncs.") != NULL);
} }
tsS3Https = (strstr(tsS3Endpoint[0], "https://") != NULL);
tsS3Oss = (strstr(tsS3Endpoint[0], "aliyuncs.") != NULL);
if (tsS3BucketName[0] != '<') { if (tsS3BucketName[0] != '<') {
#if defined(USE_COS) || defined(USE_S3) #if defined(USE_COS) || defined(USE_S3)
#ifdef TD_ENTERPRISE #ifdef TD_ENTERPRISE

View File

@ -486,7 +486,7 @@ int32_t mndInitSync(SMnode *pMnode) {
int32_t code = 0; int32_t code = 0;
(void)tsem_init(&pMgmt->syncSem, 0, 0); (void)tsem_init(&pMgmt->syncSem, 0, 0);
pMgmt->sync = syncOpen(&syncInfo, true); pMgmt->sync = syncOpen(&syncInfo, 1); // always check
if (pMgmt->sync <= 0) { if (pMgmt->sync <= 0) {
if (terrno != 0) code = terrno; if (terrno != 0) code = terrno;
mError("failed to open sync since %s", tstrerror(code)); mError("failed to open sync since %s", tstrerror(code));

View File

@ -694,9 +694,13 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv
SSchemaWrapper *pSchemaWrapper = &schema; SSchemaWrapper *pSchemaWrapper = &schema;
tDecoderInit(&dc, pData, nData); tDecoderInit(&dc, pData, nData);
(void)tDecodeSSchemaWrapper(&dc, pSchemaWrapper); code = tDecodeSSchemaWrapper(&dc, pSchemaWrapper);
tDecoderClear(&dc); tDecoderClear(&dc);
tdbFree(pData); tdbFree(pData);
if (TSDB_CODE_SUCCESS != code) {
taosMemoryFree(pSchemaWrapper->pSchema);
goto _exit;
}
// convert // convert
STSchema *pTSchema = tBuildTSchema(pSchemaWrapper->pSchema, pSchemaWrapper->nCols, pSchemaWrapper->version); STSchema *pTSchema = tBuildTSchema(pSchemaWrapper->pSchema, pSchemaWrapper->nCols, pSchemaWrapper->version);

View File

@ -254,6 +254,16 @@ static int32_t ttlMgrFindExpiredOneEntry(const void *pKey, int keyLen, const voi
return c; return c;
} }
// static int32_t ttlMgrDumpOneEntry(const void *pKey, int keyLen, const void *pVal, int valLen, void *pDumpCtx) {
// STtlIdxKeyV1 *ttlKey = (STtlIdxKeyV1 *)pKey;
// int64_t *ttlDays = (int64_t *)pVal;
// metaInfo("ttlMgr dump, ttl: %" PRId64 ", ctime: %" PRId64 ", uid: %" PRId64, *ttlDays, ttlKey->deleteTimeMs,
// ttlKey->uid);
// TAOS_RETURN(TSDB_CODE_SUCCESS);
// }
static int ttlMgrConvert(TTB *pOldTtlIdx, TTB *pNewTtlIdx, void *pMeta) { static int ttlMgrConvert(TTB *pOldTtlIdx, TTB *pNewTtlIdx, void *pMeta) {
SMeta *meta = pMeta; SMeta *meta = pMeta;
@ -402,15 +412,20 @@ int32_t ttlMgrFlush(STtlManger *pTtlMgr, TXN *pTxn) {
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
void *pIter = taosHashIterate(pTtlMgr->pDirtyUids, NULL); void *pIter = NULL;
while (pIter != NULL) { while ((pIter = taosHashIterate(pTtlMgr->pDirtyUids, pIter)) != NULL) {
STtlDirtyEntry *pEntry = (STtlDirtyEntry *)pIter; STtlDirtyEntry *pEntry = (STtlDirtyEntry *)pIter;
tb_uid_t *pUid = taosHashGetKey(pIter, NULL); tb_uid_t *pUid = taosHashGetKey(pIter, NULL);
STtlCacheEntry *cacheEntry = taosHashGet(pTtlMgr->pTtlCache, pUid, sizeof(*pUid)); STtlCacheEntry *cacheEntry = taosHashGet(pTtlMgr->pTtlCache, pUid, sizeof(*pUid));
if (cacheEntry == NULL) { if (cacheEntry == NULL) {
metaError("%s, ttlMgr flush failed to get ttl cache, uid: %" PRId64 ", type: %d", pTtlMgr->logPrefix, *pUid, metaInfo("%s, ttlMgr flush failed to get ttl cache, uid: %" PRId64 ", type: %d", pTtlMgr->logPrefix, *pUid,
pEntry->type); pEntry->type);
code = taosHashRemove(pTtlMgr->pDirtyUids, pUid, sizeof(*pUid));
if (TSDB_CODE_SUCCESS != code) {
metaError("%s, ttlMgr flush failed to remove dirty uid since %s", pTtlMgr->logPrefix, tstrerror(code));
goto _out;
}
continue; continue;
} }
@ -422,9 +437,9 @@ int32_t ttlMgrFlush(STtlManger *pTtlMgr, TXN *pTxn) {
if (pEntry->type == ENTRY_TYPE_UPSERT) { if (pEntry->type == ENTRY_TYPE_UPSERT) {
// delete old key & upsert new key // delete old key & upsert new key
(void)tdbTbDelete(pTtlMgr->pTtlIdx, &ttlKey, sizeof(ttlKey), pTxn); // maybe first insert, ignore error (void)tdbTbDelete(pTtlMgr->pTtlIdx, &ttlKey, sizeof(ttlKey), pTxn); // maybe first insert, ignore error
code = tdbTbUpsert(pTtlMgr->pTtlIdx, &ttlKeyDirty, sizeof(ttlKeyDirty), &cacheEntry->ttlDaysDirty, code = tdbTbUpsert(pTtlMgr->pTtlIdx, &ttlKeyDirty, sizeof(ttlKeyDirty), &cacheEntry->ttlDaysDirty,
sizeof(cacheEntry->ttlDaysDirty), pTxn); sizeof(cacheEntry->ttlDaysDirty), pTxn);
if (TSDB_CODE_SUCCESS != code) { if (TSDB_CODE_SUCCESS != code) {
metaError("%s, ttlMgr flush failed to upsert since %s", pTtlMgr->logPrefix, tstrerror(code)); metaError("%s, ttlMgr flush failed to upsert since %s", pTtlMgr->logPrefix, tstrerror(code));
goto _out; goto _out;
@ -449,9 +464,15 @@ int32_t ttlMgrFlush(STtlManger *pTtlMgr, TXN *pTxn) {
goto _out; goto _out;
} }
void *pIterTmp = pIter; metaDebug("isdel:%d", pEntry->type == ENTRY_TYPE_DELETE);
pIter = taosHashIterate(pTtlMgr->pDirtyUids, pIterTmp); metaDebug("ttlkey:%" PRId64 ", uid:%" PRId64, ttlKey.deleteTimeMs, ttlKey.uid);
(void)taosHashRemove(pTtlMgr->pDirtyUids, pUid, sizeof(tb_uid_t)); metaDebug("ttlkeyDirty:%" PRId64 ", uid:%" PRId64, ttlKeyDirty.deleteTimeMs, ttlKeyDirty.uid);
code = taosHashRemove(pTtlMgr->pDirtyUids, pUid, sizeof(*pUid));
if (TSDB_CODE_SUCCESS != code) {
metaError("%s, ttlMgr flush failed to remove dirty uid since %s", pTtlMgr->logPrefix, tstrerror(code));
goto _out;
}
} }
taosHashClear(pTtlMgr->pDirtyUids); taosHashClear(pTtlMgr->pDirtyUids);
@ -459,6 +480,8 @@ int32_t ttlMgrFlush(STtlManger *pTtlMgr, TXN *pTxn) {
code = TSDB_CODE_SUCCESS; code = TSDB_CODE_SUCCESS;
_out: _out:
taosHashCancelIterate(pTtlMgr->pDirtyUids, pIter);
endNs = taosGetTimestampNs(); endNs = taosGetTimestampNs();
metaTrace("%s, ttl mgr flush end, time consumed: %" PRId64 " ns", pTtlMgr->logPrefix, endNs - startNs); metaTrace("%s, ttl mgr flush end, time consumed: %" PRId64 " ns", pTtlMgr->logPrefix, endNs - startNs);

View File

@ -69,7 +69,7 @@ int32_t smaInit() {
if (!smaMgmt.refHash || !smaMgmt.tmrHandle) { if (!smaMgmt.refHash || !smaMgmt.tmrHandle) {
code = terrno; code = terrno;
(void)taosCloseRef(smaMgmt.rsetId); taosCloseRef(smaMgmt.rsetId);
if (smaMgmt.refHash) { if (smaMgmt.refHash) {
taosHashCleanup(smaMgmt.refHash); taosHashCleanup(smaMgmt.refHash);
smaMgmt.refHash = NULL; smaMgmt.refHash = NULL;
@ -103,7 +103,7 @@ void smaCleanUp() {
} }
if (old == 1) { if (old == 1) {
(void)taosCloseRef(smaMgmt.rsetId); taosCloseRef(smaMgmt.rsetId);
taosHashCleanup(smaMgmt.refHash); taosHashCleanup(smaMgmt.refHash);
smaMgmt.refHash = NULL; smaMgmt.refHash = NULL;
taosTmrCleanUp(smaMgmt.tmrHandle); taosTmrCleanUp(smaMgmt.tmrHandle);

View File

@ -115,16 +115,14 @@ void destroySttBlockReader(SArray *pLDataIterArray, SSttBlockLoadCostInfo *pLoad
SArray *pList = taosArrayGetP(pLDataIterArray, i); SArray *pList = taosArrayGetP(pLDataIterArray, i);
for (int32_t j = 0; j < taosArrayGetSize(pList); ++j) { for (int32_t j = 0; j < taosArrayGetSize(pList); ++j) {
SLDataIter *pIter = taosArrayGetP(pList, j); SLDataIter *pIter = taosArrayGetP(pList, j);
if (pIter->pBlockLoadInfo == NULL) { if (pIter->pBlockLoadInfo != NULL) {
continue; SSttBlockLoadCostInfo *pCost = &pIter->pBlockLoadInfo->cost;
} if (pLoadCost != NULL) {
pLoadCost->loadBlocks += pCost->loadBlocks;
SSttBlockLoadCostInfo *pCost = &pIter->pBlockLoadInfo->cost; pLoadCost->loadStatisBlocks += pCost->loadStatisBlocks;
if (pLoadCost != NULL) { pLoadCost->blockElapsedTime += pCost->blockElapsedTime;
pLoadCost->loadBlocks += pCost->loadBlocks; pLoadCost->statisElapsedTime += pCost->statisElapsedTime;
pLoadCost->loadStatisBlocks += pCost->loadStatisBlocks; }
pLoadCost->blockElapsedTime += pCost->blockElapsedTime;
pLoadCost->statisElapsedTime += pCost->statisElapsedTime;
} }
destroyLDataIter(pIter); destroyLDataIter(pIter);

View File

@ -61,7 +61,9 @@ int32_t tsdbSttFileReaderOpen(const char *fname, const SSttFileReaderConfig *con
// // open each segment reader // // open each segment reader
int64_t offset = config->file->size - sizeof(SSttFooter); int64_t offset = config->file->size - sizeof(SSttFooter);
ASSERT(offset >= TSDB_FHDR_SIZE); if (offset < TSDB_FHDR_SIZE) {
TSDB_CHECK_CODE(code = TSDB_CODE_FILE_CORRUPTED, lino, _exit);
}
int32_t encryptAlgoirthm = config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm; int32_t encryptAlgoirthm = config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
char *encryptKey = config->tsdb->pVnode->config.tsdbCfg.encryptKey; char *encryptKey = config->tsdb->pVnode->config.tsdbCfg.encryptKey;
@ -115,7 +117,9 @@ int32_t tsdbSttFileReaderClose(SSttFileReader **reader) {
int32_t tsdbSttFileReadStatisBlk(SSttFileReader *reader, const TStatisBlkArray **statisBlkArray) { int32_t tsdbSttFileReadStatisBlk(SSttFileReader *reader, const TStatisBlkArray **statisBlkArray) {
if (!reader->ctx->statisBlkLoaded) { if (!reader->ctx->statisBlkLoaded) {
if (reader->footer->statisBlkPtr->size > 0) { if (reader->footer->statisBlkPtr->size > 0) {
ASSERT(reader->footer->statisBlkPtr->size % sizeof(SStatisBlk) == 0); if (reader->footer->statisBlkPtr->size % sizeof(SStatisBlk) != 0) {
return TSDB_CODE_FILE_CORRUPTED;
}
int32_t size = reader->footer->statisBlkPtr->size / sizeof(SStatisBlk); int32_t size = reader->footer->statisBlkPtr->size / sizeof(SStatisBlk);
void *data = taosMemoryMalloc(reader->footer->statisBlkPtr->size); void *data = taosMemoryMalloc(reader->footer->statisBlkPtr->size);
@ -147,7 +151,9 @@ int32_t tsdbSttFileReadStatisBlk(SSttFileReader *reader, const TStatisBlkArray *
int32_t tsdbSttFileReadTombBlk(SSttFileReader *reader, const TTombBlkArray **tombBlkArray) { int32_t tsdbSttFileReadTombBlk(SSttFileReader *reader, const TTombBlkArray **tombBlkArray) {
if (!reader->ctx->tombBlkLoaded) { if (!reader->ctx->tombBlkLoaded) {
if (reader->footer->tombBlkPtr->size > 0) { if (reader->footer->tombBlkPtr->size > 0) {
ASSERT(reader->footer->tombBlkPtr->size % sizeof(STombBlk) == 0); if (reader->footer->tombBlkPtr->size % sizeof(STombBlk) != 0) {
return TSDB_CODE_FILE_CORRUPTED;
}
int32_t size = reader->footer->tombBlkPtr->size / sizeof(STombBlk); int32_t size = reader->footer->tombBlkPtr->size / sizeof(STombBlk);
void *data = taosMemoryMalloc(reader->footer->tombBlkPtr->size); void *data = taosMemoryMalloc(reader->footer->tombBlkPtr->size);
@ -179,7 +185,9 @@ int32_t tsdbSttFileReadTombBlk(SSttFileReader *reader, const TTombBlkArray **tom
int32_t tsdbSttFileReadSttBlk(SSttFileReader *reader, const TSttBlkArray **sttBlkArray) { int32_t tsdbSttFileReadSttBlk(SSttFileReader *reader, const TSttBlkArray **sttBlkArray) {
if (!reader->ctx->sttBlkLoaded) { if (!reader->ctx->sttBlkLoaded) {
if (reader->footer->sttBlkPtr->size > 0) { if (reader->footer->sttBlkPtr->size > 0) {
ASSERT(reader->footer->sttBlkPtr->size % sizeof(SSttBlk) == 0); if (reader->footer->sttBlkPtr->size % sizeof(SSttBlk) != 0) {
return TSDB_CODE_FILE_CORRUPTED;
}
int32_t size = reader->footer->sttBlkPtr->size / sizeof(SSttBlk); int32_t size = reader->footer->sttBlkPtr->size / sizeof(SSttBlk);
void *data = taosMemoryMalloc(reader->footer->sttBlkPtr->size); void *data = taosMemoryMalloc(reader->footer->sttBlkPtr->size);
@ -256,7 +264,9 @@ int32_t tsdbSttFileReadBlockDataByColumn(SSttFileReader *reader, const SSttBlk *
SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer0); SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer0);
TAOS_CHECK_GOTO(tGetDiskDataHdr(&br, &hdr), &lino, _exit); TAOS_CHECK_GOTO(tGetDiskDataHdr(&br, &hdr), &lino, _exit);
ASSERT(hdr.delimiter == TSDB_FILE_DLMT); if (hdr.delimiter != TSDB_FILE_DLMT) {
TSDB_CHECK_CODE(code = TSDB_CODE_FILE_CORRUPTED, lino, _exit);
}
// set data container // set data container
tBlockDataReset(bData); tBlockDataReset(bData);
@ -266,7 +276,9 @@ int32_t tsdbSttFileReadBlockDataByColumn(SSttFileReader *reader, const SSttBlk *
// key part // key part
TAOS_CHECK_GOTO(tBlockDataDecompressKeyPart(&hdr, &br, bData, assist), &lino, _exit); TAOS_CHECK_GOTO(tBlockDataDecompressKeyPart(&hdr, &br, bData, assist), &lino, _exit);
ASSERT(br.offset == buffer0->size); if (br.offset != buffer0->size) {
TSDB_CHECK_CODE(code = TSDB_CODE_FILE_CORRUPTED, lino, _exit);
}
bool loadExtra = false; bool loadExtra = false;
for (int i = 0; i < ncid; i++) { for (int i = 0; i < ncid; i++) {
@ -376,7 +388,10 @@ int32_t tsdbSttFileReadTombBlock(SSttFileReader *reader, const STombBlk *tombBlk
br.offset += tombBlk->size[i]; br.offset += tombBlk->size[i];
} }
ASSERT(br.offset == tombBlk->dp->size); if (br.offset != tombBlk->dp->size) {
TSDB_CHECK_CODE(code = TSDB_CODE_FILE_CORRUPTED, lino, _exit);
}
_exit: _exit:
if (code) { if (code) {
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(reader->config->tsdb->pVnode), __func__, __FILE__, lino, tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(reader->config->tsdb->pVnode), __func__, __FILE__, lino,
@ -444,7 +459,9 @@ int32_t tsdbSttFileReadStatisBlock(SSttFileReader *reader, const SStatisBlk *sta
} }
} }
ASSERT(br.offset == buffer0->size); if (br.offset != buffer0->size) {
TSDB_CHECK_CODE(code = TSDB_CODE_FILE_CORRUPTED, lino, _exit);
}
_exit: _exit:
if (code) { if (code) {
@ -814,8 +831,6 @@ _exit:
} }
static void tsdbSttFWriterDoClose(SSttFileWriter *writer) { static void tsdbSttFWriterDoClose(SSttFileWriter *writer) {
ASSERT(writer->fd == NULL);
for (int32_t i = 0; i < ARRAY_SIZE(writer->local); ++i) { for (int32_t i = 0; i < ARRAY_SIZE(writer->local); ++i) {
tBufferDestroy(writer->local + i); tBufferDestroy(writer->local + i);
} }
@ -854,7 +869,6 @@ static int32_t tsdbSttFWriterCloseCommit(SSttFileWriter *writer, TFileOpArray *o
tsdbCloseFile(&writer->fd); tsdbCloseFile(&writer->fd);
ASSERT(writer->file->size > 0);
STFileOp op = (STFileOp){ STFileOp op = (STFileOp){
.optype = TSDB_FOP_CREATE, .optype = TSDB_FOP_CREATE,
.fid = writer->config->fid, .fid = writer->config->fid,

View File

@ -171,7 +171,7 @@ static int32_t tStatisBlockUpdate(STbStatisBlock *block, SRowInfo *row) {
TAOS_CHECK_RETURN(tBufferPutAt(&block->counts, (block->numOfRecords - 1) * sizeof(record.count), &record.count, TAOS_CHECK_RETURN(tBufferPutAt(&block->counts, (block->numOfRecords - 1) * sizeof(record.count), &record.count,
sizeof(record.count))); sizeof(record.count)));
} else { } else {
ASSERT(0); return TSDB_CODE_INVALID_PARA;
} }
return 0; return 0;

View File

@ -165,9 +165,7 @@ static int32_t vnodeAsyncTaskDone(SVAsync *async, SVATask *task) {
} }
ret = vHashDrop(async->taskTable, task); ret = vHashDrop(async->taskTable, task);
if (ret != 0) { TAOS_UNUSED(ret);
ASSERT(0);
}
async->numTasks--; async->numTasks--;
if (task->numWait == 0) { if (task->numWait == 0) {
@ -403,7 +401,6 @@ static int32_t vnodeAsyncDestroy(SVAsync **async) {
} }
(void)taosThreadJoin((*async)->workers[i].thread, NULL); (void)taosThreadJoin((*async)->workers[i].thread, NULL);
ASSERT((*async)->workers[i].state == EVA_WORKER_STATE_STOP);
(*async)->workers[i].state = EVA_WORKER_STATE_UINIT; (*async)->workers[i].state = EVA_WORKER_STATE_UINIT;
} }
@ -413,18 +410,11 @@ static int32_t vnodeAsyncDestroy(SVAsync **async) {
channel->prev->next = channel->next; channel->prev->next = channel->next;
int32_t ret = vHashDrop((*async)->channelTable, channel); int32_t ret = vHashDrop((*async)->channelTable, channel);
if (ret) { TAOS_UNUSED(ret);
ASSERT(0);
}
(*async)->numChannels--; (*async)->numChannels--;
taosMemoryFree(channel); taosMemoryFree(channel);
} }
ASSERT((*async)->numLaunchWorkers == 0);
ASSERT((*async)->numIdleWorkers == 0);
ASSERT((*async)->numChannels == 0);
ASSERT((*async)->numTasks == 0);
(void)taosThreadMutexDestroy(&(*async)->mutex); (void)taosThreadMutexDestroy(&(*async)->mutex);
(void)taosThreadCondDestroy(&(*async)->hasTask); (void)taosThreadCondDestroy(&(*async)->hasTask);
@ -438,7 +428,6 @@ static int32_t vnodeAsyncDestroy(SVAsync **async) {
static int32_t vnodeAsyncLaunchWorker(SVAsync *async) { static int32_t vnodeAsyncLaunchWorker(SVAsync *async) {
for (int32_t i = 0; i < async->numWorkers; i++) { for (int32_t i = 0; i < async->numWorkers; i++) {
ASSERT(async->workers[i].state != EVA_WORKER_STATE_IDLE);
if (async->workers[i].state == EVA_WORKER_STATE_ACTIVE) { if (async->workers[i].state == EVA_WORKER_STATE_ACTIVE) {
continue; continue;
} else if (async->workers[i].state == EVA_WORKER_STATE_STOP) { } else if (async->workers[i].state == EVA_WORKER_STATE_STOP) {

View File

@ -375,11 +375,11 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
} }
tjsonGetNumberValue(pJson, "s3ChunkSize", pCfg->s3ChunkSize, code); tjsonGetNumberValue(pJson, "s3ChunkSize", pCfg->s3ChunkSize, code);
if (code < 0) { if (code < 0 || pCfg->s3ChunkSize < TSDB_MIN_S3_CHUNK_SIZE) {
pCfg->s3ChunkSize = TSDB_DEFAULT_S3_CHUNK_SIZE; pCfg->s3ChunkSize = TSDB_DEFAULT_S3_CHUNK_SIZE;
} }
tjsonGetNumberValue(pJson, "s3KeepLocal", pCfg->s3KeepLocal, code); tjsonGetNumberValue(pJson, "s3KeepLocal", pCfg->s3KeepLocal, code);
if (code < 0) { if (code < 0 || pCfg->s3KeepLocal < TSDB_MIN_S3_KEEP_LOCAL) {
pCfg->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL; pCfg->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
} }
tjsonGetNumberValue(pJson, "s3Compact", pCfg->s3Compact, code); tjsonGetNumberValue(pJson, "s3Compact", pCfg->s3Compact, code);

View File

@ -302,7 +302,6 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) {
TSDB_CHECK_CODE(code, lino, _exit); TSDB_CHECK_CODE(code, lino, _exit);
(void)taosThreadMutexLock(&pVnode->mutex); (void)taosThreadMutexLock(&pVnode->mutex);
ASSERT(pVnode->onCommit == NULL);
pVnode->onCommit = pVnode->inUse; pVnode->onCommit = pVnode->inUse;
pVnode->inUse = NULL; pVnode->inUse = NULL;
(void)taosThreadMutexUnlock(&pVnode->mutex); (void)taosThreadMutexUnlock(&pVnode->mutex);
@ -339,7 +338,7 @@ static void vnodeReturnBufPool(SVnode *pVnode) {
pVnode->recycleTail = pPool; pVnode->recycleTail = pPool;
} }
} else { } else {
ASSERT(0); vError("vgId:%d, buffer pool %p of id %d nRef:%d", TD_VID(pVnode), pPool, pPool->id, nRef);
} }
(void)taosThreadMutexUnlock(&pVnode->mutex); (void)taosThreadMutexUnlock(&pVnode->mutex);

View File

@ -77,7 +77,6 @@ int32_t vHashDestroy(SVHashTable** ht) {
} }
if (*ht) { if (*ht) {
ASSERT((*ht)->numEntries == 0);
taosMemoryFree((*ht)->buckets); taosMemoryFree((*ht)->buckets);
taosMemoryFree(*ht); taosMemoryFree(*ht);
(*ht) = NULL; (*ht) = NULL;

View File

@ -558,7 +558,9 @@ void vnodeClose(SVnode *pVnode) {
// start the sync timer after the queue is ready // start the sync timer after the queue is ready
int32_t vnodeStart(SVnode *pVnode) { int32_t vnodeStart(SVnode *pVnode) {
ASSERT(pVnode); if (pVnode == NULL) {
return TSDB_CODE_INVALID_PARA;
}
return vnodeSyncStart(pVnode); return vnodeSyncStart(pVnode);
} }

View File

@ -298,7 +298,11 @@ int32_t doScanCacheNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
int32_t resultRows = pBufRes->info.rows; int32_t resultRows = pBufRes->info.rows;
// the results may be null, if last values are all null // the results may be null, if last values are all null
ASSERT(resultRows == 0 || resultRows == taosArrayGetSize(pInfo->pUidList)); if (resultRows != 0 && resultRows != taosArrayGetSize(pInfo->pUidList)) {
pTaskInfo->code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(pTaskInfo->code));
T_LONG_JMP(pTaskInfo->env, pTaskInfo->code);
}
pInfo->indexOfBufferedRes = 0; pInfo->indexOfBufferedRes = 0;
} }

View File

@ -66,14 +66,17 @@ static void clearWinStateBuff(SCountWindowResult* pBuff) { pBuff->winRows = 0; }
static SCountWindowResult* getCountWinStateInfo(SCountWindowSupp* pCountSup) { static SCountWindowResult* getCountWinStateInfo(SCountWindowSupp* pCountSup) {
SCountWindowResult* pBuffInfo = taosArrayGet(pCountSup->pWinStates, pCountSup->stateIndex); SCountWindowResult* pBuffInfo = taosArrayGet(pCountSup->pWinStates, pCountSup->stateIndex);
if (!pBuffInfo) { if (!pBuffInfo) {
terrno = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
return NULL; return NULL;
} }
int32_t size = taosArrayGetSize(pCountSup->pWinStates); int32_t size = taosArrayGetSize(pCountSup->pWinStates);
// coverity scan if (size == 0) {
ASSERTS(size > 0, "WinStates is empty"); terrno = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
if (size > 0) { qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
pCountSup->stateIndex = (pCountSup->stateIndex + 1) % size; return NULL;
} }
pCountSup->stateIndex = (pCountSup->stateIndex + 1) % size;
return pBuffInfo; return pBuffInfo;
} }

View File

@ -318,6 +318,7 @@ int32_t createDataDispatcher(SDataSinkManager* pManager, const SDataSinkNode* pD
dispatcher->sink.fGetCacheSize = getCacheSize; dispatcher->sink.fGetCacheSize = getCacheSize;
dispatcher->pManager = pManager; dispatcher->pManager = pManager;
pManager = NULL;
dispatcher->pSchema = pDataSink->pInputDataBlockDesc; dispatcher->pSchema = pDataSink->pInputDataBlockDesc;
dispatcher->status = DS_BUF_EMPTY; dispatcher->status = DS_BUF_EMPTY;
dispatcher->queryEnd = false; dispatcher->queryEnd = false;
@ -336,6 +337,9 @@ int32_t createDataDispatcher(SDataSinkManager* pManager, const SDataSinkNode* pD
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
_return: _return:
taosMemoryFree(pManager);
if (dispatcher) { if (dispatcher) {
dsDestroyDataSinker(dispatcher); dsDestroyDataSinker(dispatcher);
} }

View File

@ -320,7 +320,7 @@ static int32_t buildMergeJoinOperatorParam(SOperatorParam** ppRes, bool initPara
return code; return code;
} }
(*ppRes)->pChildren = taosArrayInit(2, POINTER_BYTES); (*ppRes)->pChildren = taosArrayInit(2, POINTER_BYTES);
if (NULL == *ppRes) { if (NULL == (*ppRes)->pChildren) {
code = terrno; code = terrno;
freeOperatorParam(pChild0, OP_GET_PARAM); freeOperatorParam(pChild0, OP_GET_PARAM);
freeOperatorParam(pChild1, OP_GET_PARAM); freeOperatorParam(pChild1, OP_GET_PARAM);

View File

@ -225,7 +225,10 @@ static SSDataBlock* doLoadRemoteDataImpl(SOperatorInfo* pOperator) {
} else { } else {
concurrentlyLoadRemoteDataImpl(pOperator, pExchangeInfo, pTaskInfo); concurrentlyLoadRemoteDataImpl(pOperator, pExchangeInfo, pTaskInfo);
} }
if (TSDB_CODE_SUCCESS != pOperator->pTaskInfo->code) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
T_LONG_JMP(pTaskInfo->env, pOperator->pTaskInfo->code);
}
if (taosArrayGetSize(pExchangeInfo->pResultBlockList) == 0) { if (taosArrayGetSize(pExchangeInfo->pResultBlockList) == 0) {
return NULL; return NULL;
} else { } else {
@ -850,6 +853,7 @@ int32_t doExtractResultBlocks(SExchangeInfo* pExchangeInfo, SSourceDataInfo* pDa
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0; int32_t lino = 0;
SRetrieveTableRsp* pRetrieveRsp = pDataInfo->pRsp; SRetrieveTableRsp* pRetrieveRsp = pDataInfo->pRsp;
SSDataBlock* pb = NULL;
char* pNextStart = pRetrieveRsp->data; char* pNextStart = pRetrieveRsp->data;
char* pStart = pNextStart; char* pStart = pNextStart;
@ -874,7 +878,6 @@ int32_t doExtractResultBlocks(SExchangeInfo* pExchangeInfo, SSourceDataInfo* pDa
} }
while (index++ < pRetrieveRsp->numOfBlocks) { while (index++ < pRetrieveRsp->numOfBlocks) {
SSDataBlock* pb = NULL;
pStart = pNextStart; pStart = pNextStart;
if (taosArrayGetSize(pExchangeInfo->pRecycledBlocks) > 0) { if (taosArrayGetSize(pExchangeInfo->pRecycledBlocks) > 0) {
@ -902,15 +905,17 @@ int32_t doExtractResultBlocks(SExchangeInfo* pExchangeInfo, SSourceDataInfo* pDa
code = extractDataBlockFromFetchRsp(pb, pStart, NULL, &pStart); code = extractDataBlockFromFetchRsp(pb, pStart, NULL, &pStart);
if (code != 0) { if (code != 0) {
taosMemoryFreeClear(pDataInfo->pRsp); taosMemoryFreeClear(pDataInfo->pRsp);
return code; goto _end;
} }
void* tmp = taosArrayPush(pExchangeInfo->pResultBlockList, &pb); void* tmp = taosArrayPush(pExchangeInfo->pResultBlockList, &pb);
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno); QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
pb = NULL;
} }
_end: _end:
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
blockDataDestroy(pb);
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
} }
return code; return code;

View File

@ -1942,6 +1942,8 @@ int32_t createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, SExprInfo**
pTargetNode = (STargetNode*)nodesListGetNode(pGroupKeys, i - numOfFuncs); pTargetNode = (STargetNode*)nodesListGetNode(pGroupKeys, i - numOfFuncs);
} }
if (!pTargetNode) { if (!pTargetNode) {
destroyExprInfo(pExprs, *numOfExprs);
taosMemoryFreeClear(pExprs);
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno)); qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
return terrno; return terrno;
} }
@ -1950,6 +1952,7 @@ int32_t createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, SExprInfo**
code = createExprFromTargetNode(pExp, pTargetNode); code = createExprFromTargetNode(pExp, pTargetNode);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
destroyExprInfo(pExprs, *numOfExprs); destroyExprInfo(pExprs, *numOfExprs);
taosMemoryFreeClear(pExprs);
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code)); qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
return code; return code;
} }

View File

@ -31,7 +31,7 @@ int32_t exchangeObjRefPool = -1;
static void cleanupRefPool() { static void cleanupRefPool() {
int32_t ref = atomic_val_compare_exchange_32(&exchangeObjRefPool, exchangeObjRefPool, 0); int32_t ref = atomic_val_compare_exchange_32(&exchangeObjRefPool, exchangeObjRefPool, 0);
(void)taosCloseRef(ref); taosCloseRef(ref);
} }
static void initRefPool() { static void initRefPool() {
@ -158,7 +158,8 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
SStreamScanInfo* pInfo = pOperator->info; SStreamScanInfo* pInfo = pOperator->info;
qDebug("s-task:%s in this batch, %d blocks need to be processed", id, (int32_t)numOfBlocks); qDebug("s-task:%s in this batch, %d blocks need to be processed", id, (int32_t)numOfBlocks);
ASSERT(pInfo->validBlockIndex == 0 && taosArrayGetSize(pInfo->pBlockLists) == 0); QUERY_CHECK_CONDITION((pInfo->validBlockIndex == 0 && taosArrayGetSize(pInfo->pBlockLists) == 0), code, lino, _end,
TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
if (type == STREAM_INPUT__MERGED_SUBMIT) { if (type == STREAM_INPUT__MERGED_SUBMIT) {
for (int32_t i = 0; i < numOfBlocks; i++) { for (int32_t i = 0; i < numOfBlocks; i++) {
@ -189,7 +190,8 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
pInfo->blockType = STREAM_INPUT__CHECKPOINT; pInfo->blockType = STREAM_INPUT__CHECKPOINT;
} else { } else {
ASSERT(0); code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
QUERY_CHECK_CODE(code, lino, _end);
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
@ -543,7 +545,9 @@ int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* table
int32_t* tversion, int32_t idx, bool* tbGet) { int32_t* tversion, int32_t idx, bool* tbGet) {
*tbGet = false; *tbGet = false;
ASSERT(tinfo != NULL && dbName != NULL && tableName != NULL); if (tinfo == NULL || dbName == NULL || tableName == NULL) {
return TSDB_CODE_INVALID_PARA;
}
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
if (taosArrayGetSize(pTaskInfo->schemaInfos) <= idx) { if (taosArrayGetSize(pTaskInfo->schemaInfos) <= idx) {
@ -722,7 +726,8 @@ int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bo
blockIndex += 1; blockIndex += 1;
current += p->info.rows; current += p->info.rows;
ASSERT(p->info.rows > 0 || p->info.type == STREAM_CHECKPOINT); QUERY_CHECK_CONDITION((p->info.rows > 0 || p->info.type == STREAM_CHECKPOINT), code, lino, _end,
TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
void* tmp = taosArrayPush(pResList, &p); void* tmp = taosArrayPush(pResList, &p);
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno); QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
@ -987,15 +992,17 @@ void qExtractStreamScanner(qTaskInfo_t tinfo, void** scanner) {
*scanner = pOperator->info; *scanner = pOperator->info;
break; break;
} else { } else {
ASSERT(pOperator->numOfDownstream == 1);
pOperator = pOperator->pDownstream[0]; pOperator = pOperator->pDownstream[0];
} }
} }
} }
int32_t qStreamSourceScanParamForHistoryScanStep1(qTaskInfo_t tinfo, SVersionRange* pVerRange, STimeWindow* pWindow) { int32_t qStreamSourceScanParamForHistoryScanStep1(qTaskInfo_t tinfo, SVersionRange* pVerRange, STimeWindow* pWindow) {
int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0;
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM); QUERY_CHECK_CONDITION((pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM), code, lino, _end,
TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
SStreamTaskInfo* pStreamInfo = &pTaskInfo->streamInfo; SStreamTaskInfo* pStreamInfo = &pTaskInfo->streamInfo;
@ -1007,12 +1014,19 @@ int32_t qStreamSourceScanParamForHistoryScanStep1(qTaskInfo_t tinfo, SVersionRan
", window:%" PRId64 " - %" PRId64, ", window:%" PRId64 " - %" PRId64,
GET_TASKID(pTaskInfo), pStreamInfo->fillHistoryVer.minVer, pStreamInfo->fillHistoryVer.maxVer, pWindow->skey, GET_TASKID(pTaskInfo), pStreamInfo->fillHistoryVer.minVer, pStreamInfo->fillHistoryVer.maxVer, pWindow->skey,
pWindow->ekey); pWindow->ekey);
return 0; _end:
if (code != TSDB_CODE_SUCCESS) {
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
}
return code;
} }
int32_t qStreamSourceScanParamForHistoryScanStep2(qTaskInfo_t tinfo, SVersionRange* pVerRange, STimeWindow* pWindow) { int32_t qStreamSourceScanParamForHistoryScanStep2(qTaskInfo_t tinfo, SVersionRange* pVerRange, STimeWindow* pWindow) {
int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0;
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM); QUERY_CHECK_CONDITION((pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM), code, lino, _end,
TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
SStreamTaskInfo* pStreamInfo = &pTaskInfo->streamInfo; SStreamTaskInfo* pStreamInfo = &pTaskInfo->streamInfo;
@ -1024,14 +1038,26 @@ int32_t qStreamSourceScanParamForHistoryScanStep2(qTaskInfo_t tinfo, SVersionRan
"-%" PRId64, "-%" PRId64,
GET_TASKID(pTaskInfo), pStreamInfo->fillHistoryVer.minVer, pStreamInfo->fillHistoryVer.maxVer, pWindow->skey, GET_TASKID(pTaskInfo), pStreamInfo->fillHistoryVer.minVer, pStreamInfo->fillHistoryVer.maxVer, pWindow->skey,
pWindow->ekey); pWindow->ekey);
return 0; _end:
if (code != TSDB_CODE_SUCCESS) {
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
}
return code;
} }
int32_t qStreamRecoverFinish(qTaskInfo_t tinfo) { int32_t qStreamRecoverFinish(qTaskInfo_t tinfo) {
int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0;
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM); QUERY_CHECK_CONDITION((pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM), code, lino, _end,
TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
pTaskInfo->streamInfo.recoverStep = STREAM_RECOVER_STEP__NONE; pTaskInfo->streamInfo.recoverStep = STREAM_RECOVER_STEP__NONE;
return 0;
_end:
if (code != TSDB_CODE_SUCCESS) {
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
}
return code;
} }
int32_t qSetStreamOperatorOptionForScanHistory(qTaskInfo_t tinfo) { int32_t qSetStreamOperatorOptionForScanHistory(qTaskInfo_t tinfo) {
@ -1046,9 +1072,6 @@ int32_t qSetStreamOperatorOptionForScanHistory(qTaskInfo_t tinfo) {
SStreamIntervalOperatorInfo* pInfo = pOperator->info; SStreamIntervalOperatorInfo* pInfo = pOperator->info;
STimeWindowAggSupp* pSup = &pInfo->twAggSup; STimeWindowAggSupp* pSup = &pInfo->twAggSup;
ASSERT(pSup->calTrigger == STREAM_TRIGGER_AT_ONCE || pSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);
ASSERT(pSup->calTriggerSaved == 0 && pSup->deleteMarkSaved == 0);
qInfo("save stream param for interval: %d, %" PRId64, pSup->calTrigger, pSup->deleteMark); qInfo("save stream param for interval: %d, %" PRId64, pSup->calTrigger, pSup->deleteMark);
pSup->calTriggerSaved = pSup->calTrigger; pSup->calTriggerSaved = pSup->calTrigger;
@ -1063,9 +1086,6 @@ int32_t qSetStreamOperatorOptionForScanHistory(qTaskInfo_t tinfo) {
SStreamSessionAggOperatorInfo* pInfo = pOperator->info; SStreamSessionAggOperatorInfo* pInfo = pOperator->info;
STimeWindowAggSupp* pSup = &pInfo->twAggSup; STimeWindowAggSupp* pSup = &pInfo->twAggSup;
ASSERT(pSup->calTrigger == STREAM_TRIGGER_AT_ONCE || pSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);
ASSERT(pSup->calTriggerSaved == 0 && pSup->deleteMarkSaved == 0);
qInfo("save stream param for session: %d, %" PRId64, pSup->calTrigger, pSup->deleteMark); qInfo("save stream param for session: %d, %" PRId64, pSup->calTrigger, pSup->deleteMark);
pSup->calTriggerSaved = pSup->calTrigger; pSup->calTriggerSaved = pSup->calTrigger;
@ -1078,9 +1098,6 @@ int32_t qSetStreamOperatorOptionForScanHistory(qTaskInfo_t tinfo) {
SStreamStateAggOperatorInfo* pInfo = pOperator->info; SStreamStateAggOperatorInfo* pInfo = pOperator->info;
STimeWindowAggSupp* pSup = &pInfo->twAggSup; STimeWindowAggSupp* pSup = &pInfo->twAggSup;
ASSERT(pSup->calTrigger == STREAM_TRIGGER_AT_ONCE || pSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);
ASSERT(pSup->calTriggerSaved == 0 && pSup->deleteMarkSaved == 0);
qInfo("save stream param for state: %d, %" PRId64, pSup->calTrigger, pSup->deleteMark); qInfo("save stream param for state: %d, %" PRId64, pSup->calTrigger, pSup->deleteMark);
pSup->calTriggerSaved = pSup->calTrigger; pSup->calTriggerSaved = pSup->calTrigger;
@ -1093,9 +1110,6 @@ int32_t qSetStreamOperatorOptionForScanHistory(qTaskInfo_t tinfo) {
SStreamEventAggOperatorInfo* pInfo = pOperator->info; SStreamEventAggOperatorInfo* pInfo = pOperator->info;
STimeWindowAggSupp* pSup = &pInfo->twAggSup; STimeWindowAggSupp* pSup = &pInfo->twAggSup;
ASSERT(pSup->calTrigger == STREAM_TRIGGER_AT_ONCE || pSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);
ASSERT(pSup->calTriggerSaved == 0 && pSup->deleteMarkSaved == 0);
qInfo("save stream param for state: %d, %" PRId64, pSup->calTrigger, pSup->deleteMark); qInfo("save stream param for state: %d, %" PRId64, pSup->calTrigger, pSup->deleteMark);
pSup->calTriggerSaved = pSup->calTrigger; pSup->calTriggerSaved = pSup->calTrigger;
@ -1108,9 +1122,6 @@ int32_t qSetStreamOperatorOptionForScanHistory(qTaskInfo_t tinfo) {
SStreamCountAggOperatorInfo* pInfo = pOperator->info; SStreamCountAggOperatorInfo* pInfo = pOperator->info;
STimeWindowAggSupp* pSup = &pInfo->twAggSup; STimeWindowAggSupp* pSup = &pInfo->twAggSup;
ASSERT(pSup->calTrigger == STREAM_TRIGGER_AT_ONCE || pSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);
ASSERT(pSup->calTriggerSaved == 0 && pSup->deleteMarkSaved == 0);
qInfo("save stream param for state: %d, %" PRId64, pSup->calTrigger, pSup->deleteMark); qInfo("save stream param for state: %d, %" PRId64, pSup->calTrigger, pSup->deleteMark);
pSup->calTriggerSaved = pSup->calTrigger; pSup->calTriggerSaved = pSup->calTrigger;
@ -1126,7 +1137,6 @@ int32_t qSetStreamOperatorOptionForScanHistory(qTaskInfo_t tinfo) {
if (pOperator->numOfDownstream != 1 || pOperator->pDownstream[0] == NULL) { if (pOperator->numOfDownstream != 1 || pOperator->pDownstream[0] == NULL) {
if (pOperator->numOfDownstream > 1) { if (pOperator->numOfDownstream > 1) {
qError("unexpected stream, multiple downstream"); qError("unexpected stream, multiple downstream");
ASSERT(0);
return -1; return -1;
} }
return 0; return 0;

View File

@ -163,7 +163,11 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
return NULL; return NULL;
} }
ASSERT(pResult->pageId == p1->pageId && pResult->offset == p1->offset); if (pResult->pageId != p1->pageId || pResult->offset != p1->offset) {
terrno = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
pTaskInfo->code = terrno;
return NULL;
}
} }
} else { } else {
// In case of group by column query, the required SResultRow object must be existInCurrentResusltRowInfo in the // In case of group by column query, the required SResultRow object must be existInCurrentResusltRowInfo in the
@ -176,7 +180,11 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
return NULL; return NULL;
} }
ASSERT(pResult->pageId == p1->pageId && pResult->offset == p1->offset); if (pResult->pageId != p1->pageId || pResult->offset != p1->offset) {
terrno = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
pTaskInfo->code = terrno;
return NULL;
}
} }
} }
@ -324,6 +332,7 @@ _end:
static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag, static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag,
bool createDummyCol) { bool createDummyCol) {
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0;
SqlFunctionCtx* pCtx = pExprSup->pCtx; SqlFunctionCtx* pCtx = pExprSup->pCtx;
for (int32_t i = 0; i < pExprSup->numOfExprs; ++i) { for (int32_t i = 0; i < pExprSup->numOfExprs; ++i) {
@ -363,7 +372,7 @@ static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int
if (hasPk && (j == pkParamIdx)) { if (hasPk && (j == pkParamIdx)) {
pInput->pPrimaryKey = pInput->pData[j]; pInput->pPrimaryKey = pInput->pData[j];
} }
ASSERT(pInput->pData[j] != NULL); QUERY_CHECK_CONDITION((pInput->pData[j] != NULL), code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
} else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) { } else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) {
// todo avoid case: top(k, 12), 12 is the value parameter. // todo avoid case: top(k, 12), 12 is the value parameter.
// sum(11), 11 is also the value parameter. // sum(11), 11 is also the value parameter.
@ -374,14 +383,16 @@ static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int
pInput->blankFill = pBlock->info.blankFill; pInput->blankFill = pBlock->info.blankFill;
code = doCreateConstantValColumnInfo(pInput, pFuncParam, j, pBlock->info.rows); code = doCreateConstantValColumnInfo(pInput, pFuncParam, j, pBlock->info.rows);
if (code != TSDB_CODE_SUCCESS) { QUERY_CHECK_CODE(code, lino, _end);
return code;
}
} }
} }
} }
} }
_end:
if (code != TSDB_CODE_SUCCESS) {
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
}
return code; return code;
} }

View File

@ -55,7 +55,6 @@ typedef struct SFillOperatorInfo {
SExprSupp noFillExprSupp; SExprSupp noFillExprSupp;
} SFillOperatorInfo; } SFillOperatorInfo;
static void revisedFillStartKey(SFillOperatorInfo* pInfo, SSDataBlock* pBlock, int32_t order);
static void destroyFillOperatorInfo(void* param); static void destroyFillOperatorInfo(void* param);
static void doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t order, int32_t scanFlag); static void doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t order, int32_t scanFlag);
static int32_t fillResetPrevForNewGroup(SFillInfo* pFillInfo); static int32_t fillResetPrevForNewGroup(SFillInfo* pFillInfo);
@ -168,56 +167,6 @@ _end:
return code; return code;
} }
// todo refactor: decide the start key according to the query time range.
static void revisedFillStartKey(SFillOperatorInfo* pInfo, SSDataBlock* pBlock, int32_t order) {
if (order == TSDB_ORDER_ASC) {
int64_t skey = pBlock->info.window.skey;
if (skey < pInfo->pFillInfo->start) { // the start key may be smaller than the
ASSERT(taosFillNotStarted(pInfo->pFillInfo));
taosFillUpdateStartTimestampInfo(pInfo->pFillInfo, skey);
} else if (pInfo->pFillInfo->start < skey) {
int64_t t = skey;
SInterval* pInterval = &pInfo->pFillInfo->interval;
while (1) {
int64_t prev = taosTimeAdd(t, -pInterval->sliding, pInterval->slidingUnit, pInterval->precision);
if (prev <= pInfo->pFillInfo->start) {
t = prev;
break;
}
t = prev;
}
// todo time window chosen problem: t or prev value?
taosFillUpdateStartTimestampInfo(pInfo->pFillInfo, t);
}
} else {
int64_t ekey = pBlock->info.window.ekey;
if (ekey > pInfo->pFillInfo->start) {
ASSERT(taosFillNotStarted(pInfo->pFillInfo));
taosFillUpdateStartTimestampInfo(pInfo->pFillInfo, ekey);
} else if (ekey < pInfo->pFillInfo->start) {
int64_t t = ekey;
SInterval* pInterval = &pInfo->pFillInfo->interval;
int64_t prev = t;
while (1) {
int64_t next = taosTimeAdd(t, pInterval->sliding, pInterval->slidingUnit, pInterval->precision);
if (next >= pInfo->pFillInfo->start) {
prev = t;
t = next;
break;
}
prev = t;
t = next;
}
// todo time window chosen problem: t or next value?
if (t > pInfo->pFillInfo->start) t = prev;
taosFillUpdateStartTimestampInfo(pInfo->pFillInfo, t);
}
}
}
static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) { static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) {
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0; int32_t lino = 0;
@ -602,7 +551,6 @@ static void reviseFillStartAndEndKey(SFillOperatorInfo* pInfo, int32_t order) {
} }
pInfo->win.ekey = ekey; pInfo->win.ekey = ekey;
} else { } else {
assert(order == TSDB_ORDER_DESC);
skey = taosTimeTruncate(pInfo->win.skey, &pInfo->pFillInfo->interval); skey = taosTimeTruncate(pInfo->win.skey, &pInfo->pFillInfo->interval);
next = skey; next = skey;
while (next < pInfo->win.skey) { while (next < pInfo->win.skey) {

View File

@ -1746,6 +1746,9 @@ void destroyGrpArray(void* ppArray) {
} }
void destroyMergeJoinTableCtx(SMJoinTableCtx* pTable) { void destroyMergeJoinTableCtx(SMJoinTableCtx* pTable) {
if (NULL == pTable) {
return;
}
mJoinDestroyCreatedBlks(pTable->createdBlks); mJoinDestroyCreatedBlks(pTable->createdBlks);
taosArrayDestroy(pTable->createdBlks); taosArrayDestroy(pTable->createdBlks);
tSimpleHashCleanup(pTable->pGrpHash); tSimpleHashCleanup(pTable->pGrpHash);

View File

@ -1236,14 +1236,11 @@ static SSDataBlock* groupSeqTableScan(SOperatorInfo* pOperator) {
taosRUnLockLatch(&pTaskInfo->lock); taosRUnLockLatch(&pTaskInfo->lock);
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
ASSERT(pInfo->base.dataReader == NULL); QUERY_CHECK_CONDITION((pInfo->base.dataReader == NULL), code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
code = pAPI->tsdReader.tsdReaderOpen(pInfo->base.readHandle.vnode, &pInfo->base.cond, pList, num, pInfo->pResBlock, code = pAPI->tsdReader.tsdReaderOpen(pInfo->base.readHandle.vnode, &pInfo->base.cond, pList, num, pInfo->pResBlock,
(void**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo), &pInfo->pIgnoreTables); (void**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo), &pInfo->pIgnoreTables);
if (code != TSDB_CODE_SUCCESS) { QUERY_CHECK_CODE(code, lino, _end);
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
T_LONG_JMP(pTaskInfo->env, code);
}
if (pInfo->filesetDelimited) { if (pInfo->filesetDelimited) {
pAPI->tsdReader.tsdSetFilesetDelimited(pInfo->base.dataReader); pAPI->tsdReader.tsdSetFilesetDelimited(pInfo->base.dataReader);
@ -1585,7 +1582,6 @@ static bool isCountWindow(SStreamScanInfo* pInfo) {
static void setGroupId(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_t groupColIndex, int32_t rowIndex) { static void setGroupId(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_t groupColIndex, int32_t rowIndex) {
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, groupColIndex); SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, groupColIndex);
uint64_t* groupCol = (uint64_t*)pColInfo->pData; uint64_t* groupCol = (uint64_t*)pColInfo->pData;
ASSERT(rowIndex < pBlock->info.rows);
pInfo->groupId = groupCol[rowIndex]; pInfo->groupId = groupCol[rowIndex];
} }
@ -1654,9 +1650,8 @@ _end:
bool comparePrimaryKey(SColumnInfoData* pCol, int32_t rowId, void* pVal) { bool comparePrimaryKey(SColumnInfoData* pCol, int32_t rowId, void* pVal) {
// coverity scan // coverity scan
ASSERTS(pVal != NULL, "pVal should not be NULL"); if (!pVal || !pCol) {
if (!pVal) { qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(TSDB_CODE_INVALID_PARA));
qError("failed to compare primary key, since primary key is null");
return false; return false;
} }
void* pData = colDataGetData(pCol, rowId); void* pData = colDataGetData(pCol, rowId);
@ -1720,6 +1715,8 @@ static uint64_t getGroupIdByData(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts,
} }
static void prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_t* pRowIndex, bool* pRes) { static void prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_t* pRowIndex, bool* pRes) {
int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0;
if (pBlock->info.rows == 0) { if (pBlock->info.rows == 0) {
if (pRes) { if (pRes) {
(*pRes) = false; (*pRes) = false;
@ -1733,7 +1730,6 @@ static void prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_
goto _end; goto _end;
} }
ASSERT(taosArrayGetSize(pBlock->pDataBlock) >= 3);
SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
TSKEY* startData = (TSKEY*)pStartTsCol->pData; TSKEY* startData = (TSKEY*)pStartTsCol->pData;
SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX); SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX);
@ -1765,27 +1761,25 @@ static void prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_
win.skey = TMIN(win.skey, startData[*pRowIndex]); win.skey = TMIN(win.skey, startData[*pRowIndex]);
continue; continue;
} }
ASSERT(!(win.skey > startData[*pRowIndex] && win.ekey < endData[*pRowIndex]) ||
!(isInTimeWindow(&win, startData[*pRowIndex], 0) || isInTimeWindow(&win, endData[*pRowIndex], 0)));
break; break;
} }
STableScanInfo* pTScanInfo = pInfo->pTableScanOp->info; STableScanInfo* pTScanInfo = pInfo->pTableScanOp->info;
// coverity scan // coverity scan
ASSERTS(pInfo->pUpdateInfo != NULL, "Failed to set data version, since pInfo->pUpdateInfo is NULL"); QUERY_CHECK_NULL(pInfo->pUpdateInfo, code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
if (pInfo->pUpdateInfo) {
qDebug("prepare range scan start:%" PRId64 ",end:%" PRId64 ",maxVer:%" PRIu64, win.skey, win.ekey, qDebug("prepare range scan start:%" PRId64 ",end:%" PRId64 ",maxVer:%" PRIu64, win.skey, win.ekey,
pInfo->pUpdateInfo->maxDataVersion); pInfo->pUpdateInfo->maxDataVersion);
resetTableScanInfo(pInfo->pTableScanOp->info, &win, pInfo->pUpdateInfo->maxDataVersion); resetTableScanInfo(pInfo->pTableScanOp->info, &win, pInfo->pUpdateInfo->maxDataVersion);
}
pInfo->pTableScanOp->status = OP_OPENED; pInfo->pTableScanOp->status = OP_OPENED;
if (pRes) { if (pRes) {
(*pRes) = true; (*pRes) = true;
} }
_end: _end:
qTrace("%s success", __func__); if (code != TSDB_CODE_SUCCESS) {
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
}
} }
static STimeWindow getSlidingWindow(TSKEY* startTsCol, TSKEY* endTsCol, uint64_t* gpIdCol, SInterval* pInterval, static STimeWindow getSlidingWindow(TSKEY* startTsCol, TSKEY* endTsCol, uint64_t* gpIdCol, SInterval* pInterval,
@ -2193,7 +2187,6 @@ static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pS
} }
uint64_t* srcUidData = (uint64_t*)pSrcUidCol->pData; uint64_t* srcUidData = (uint64_t*)pSrcUidCol->pData;
ASSERT(pSrcStartTsCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
TSKEY* srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData; TSKEY* srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData;
TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData; TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
int64_t ver = pSrcBlock->info.version - 1; int64_t ver = pSrcBlock->info.version - 1;
@ -2291,7 +2284,6 @@ static int32_t generatePartitionDelResBlock(SStreamScanInfo* pInfo, SSDataBlock*
SColumnInfoData* pSrcGpCol = taosArrayGet(pSrcBlock->pDataBlock, GROUPID_COLUMN_INDEX); SColumnInfoData* pSrcGpCol = taosArrayGet(pSrcBlock->pDataBlock, GROUPID_COLUMN_INDEX);
uint64_t* srcGp = (uint64_t*)pSrcGpCol->pData; uint64_t* srcGp = (uint64_t*)pSrcGpCol->pData;
ASSERT(pSrcStartTsCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
TSKEY* srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData; TSKEY* srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData;
TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData; TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
int64_t ver = pSrcBlock->info.version - 1; int64_t ver = pSrcBlock->info.version - 1;
@ -2352,7 +2344,6 @@ static int32_t generateDeleteResultBlockImpl(SStreamScanInfo* pInfo, SSDataBlock
pSrcPkCol = taosArrayGet(pSrcBlock->pDataBlock, PRIMARY_KEY_COLUMN_INDEX); pSrcPkCol = taosArrayGet(pSrcBlock->pDataBlock, PRIMARY_KEY_COLUMN_INDEX);
} }
ASSERT(pSrcStartTsCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
TSKEY* srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData; TSKEY* srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData;
TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData; TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
int64_t ver = pSrcBlock->info.version - 1; int64_t ver = pSrcBlock->info.version - 1;
@ -2472,7 +2463,6 @@ static int32_t checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBl
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
} }
SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex); SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex);
ASSERT(pColDataInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP);
TSKEY* tsCol = (TSKEY*)pColDataInfo->pData; TSKEY* tsCol = (TSKEY*)pColDataInfo->pData;
SColumnInfoData* pPkColDataInfo = NULL; SColumnInfoData* pPkColDataInfo = NULL;
if (hasPrimaryKeyCol(pInfo)) { if (hasPrimaryKeyCol(pInfo)) {
@ -2549,7 +2539,7 @@ static int32_t doBlockDataWindowFilter(SSDataBlock* pBlock, int32_t tsIndex, STi
if (pWindow->skey != INT64_MIN) { if (pWindow->skey != INT64_MIN) {
qDebug("%s filter for additional history window, skey:%" PRId64, id, pWindow->skey); qDebug("%s filter for additional history window, skey:%" PRId64, id, pWindow->skey);
ASSERT(pCol->pData != NULL); QUERY_CHECK_NULL(pCol->pData, code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
for (int32_t i = 0; i < pBlock->info.rows; ++i) { for (int32_t i = 0; i < pBlock->info.rows; ++i) {
int64_t* ts = (int64_t*)colDataGetData(pCol, i); int64_t* ts = (int64_t*)colDataGetData(pCol, i);
p[i] = (*ts >= pWindow->skey); p[i] = (*ts >= pWindow->skey);
@ -2598,7 +2588,8 @@ static int32_t doBlockDataPrimaryKeyFilter(SSDataBlock* pBlock, STqOffsetVal* of
SColumnInfoData* pColPk = taosArrayGet(pBlock->pDataBlock, 1); SColumnInfoData* pColPk = taosArrayGet(pBlock->pDataBlock, 1);
qDebug("doBlockDataWindowFilter primary key, ts:%" PRId64 " %" PRId64, offset->ts, offset->primaryKey.val); qDebug("doBlockDataWindowFilter primary key, ts:%" PRId64 " %" PRId64, offset->ts, offset->primaryKey.val);
ASSERT(pColPk->info.type == offset->primaryKey.type); QUERY_CHECK_CONDITION((pColPk->info.type == offset->primaryKey.type), code, lino, _end,
TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
__compar_fn_t func = getComparFunc(pColPk->info.type, 0); __compar_fn_t func = getComparFunc(pColPk->info.type, 0);
for (int32_t i = 0; i < pBlock->info.rows; ++i) { for (int32_t i = 0; i < pBlock->info.rows; ++i) {
@ -3940,7 +3931,9 @@ void streamScanReloadState(SOperatorInfo* pOperator) {
pInfo->stateStore.windowSBfDelete(pInfo->pUpdateInfo, 1); pInfo->stateStore.windowSBfDelete(pInfo->pUpdateInfo, 1);
code = pInfo->stateStore.windowSBfAdd(pInfo->pUpdateInfo, 1); code = pInfo->stateStore.windowSBfAdd(pInfo->pUpdateInfo, 1);
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
ASSERT(pInfo->pUpdateInfo->minTS > pUpInfo->minTS);
QUERY_CHECK_CONDITION((pInfo->pUpdateInfo->minTS > pUpInfo->minTS), code, lino, _end,
TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
pInfo->pUpdateInfo->maxDataVersion = TMAX(pInfo->pUpdateInfo->maxDataVersion, pUpInfo->maxDataVersion); pInfo->pUpdateInfo->maxDataVersion = TMAX(pInfo->pUpdateInfo->maxDataVersion, pUpInfo->maxDataVersion);
SHashObj* curMap = pInfo->pUpdateInfo->pMap; SHashObj* curMap = pInfo->pUpdateInfo->pMap;
void* pIte = taosHashIterate(curMap, NULL); void* pIte = taosHashIterate(curMap, NULL);
@ -4100,12 +4093,11 @@ int32_t createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode*
} }
if (pHandle->initTqReader) { if (pHandle->initTqReader) {
ASSERT(pHandle->tqReader == NULL);
pInfo->tqReader = pAPI->tqReaderFn.tqReaderOpen(pHandle->vnode); pInfo->tqReader = pAPI->tqReaderFn.tqReaderOpen(pHandle->vnode);
ASSERT(pInfo->tqReader); QUERY_CHECK_NULL(pInfo->tqReader, code, lino, _error, terrno);
} else { } else {
ASSERT(pHandle->tqReader);
pInfo->tqReader = pHandle->tqReader; pInfo->tqReader = pHandle->tqReader;
QUERY_CHECK_NULL(pInfo->tqReader, code, lino, _error, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
} }
pInfo->pUpdateInfo = NULL; pInfo->pUpdateInfo = NULL;
@ -5882,7 +5874,10 @@ void destroyTableMergeScanOperatorInfo(void* param) {
} }
int32_t getTableMergeScanExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) { int32_t getTableMergeScanExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) {
ASSERT(pOptr != NULL); if (pOptr == NULL) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(TSDB_CODE_INVALID_PARA));
return TSDB_CODE_INVALID_PARA;
}
// TODO: merge these two info into one struct // TODO: merge these two info into one struct
STableMergeScanExecInfo* execInfo = taosMemoryCalloc(1, sizeof(STableMergeScanExecInfo)); STableMergeScanExecInfo* execInfo = taosMemoryCalloc(1, sizeof(STableMergeScanExecInfo));
if (!execInfo) { if (!execInfo) {
@ -6195,7 +6190,7 @@ int32_t fillTableCountScanDataBlock(STableCountScanSupp* pSupp, char* dbName, ch
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0; int32_t lino = 0;
if (pSupp->dbNameSlotId != -1) { if (pSupp->dbNameSlotId != -1) {
ASSERT(strlen(dbName)); QUERY_CHECK_CONDITION((strlen(dbName) > 0), code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->dbNameSlotId); SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->dbNameSlotId);
QUERY_CHECK_NULL(colInfoData, code, lino, _end, terrno); QUERY_CHECK_NULL(colInfoData, code, lino, _end, terrno);

View File

@ -735,7 +735,12 @@ int32_t doGroupSort(SOperatorInfo* pOperator, SSDataBlock** pResBlock) {
} }
// beginSortGroup would fetch all child blocks of pInfo->currGroupId; // beginSortGroup would fetch all child blocks of pInfo->currGroupId;
ASSERT(pInfo->childOpStatus != CHILD_OP_SAME_GROUP); if (pInfo->childOpStatus == CHILD_OP_SAME_GROUP) {
code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
pOperator->pTaskInfo->code = code;
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
T_LONG_JMP(pOperator->pTaskInfo->env, code);
}
code = getGroupSortedBlockData(pInfo->pCurrSortHandle, pInfo->binfo.pRes, pOperator->resultInfo.capacity, code = getGroupSortedBlockData(pInfo->pCurrSortHandle, pInfo->binfo.pRes, pOperator->resultInfo.capacity,
pInfo->matchInfo.pList, pInfo, &pBlock); pInfo->matchInfo.pList, pInfo, &pBlock);
if (pBlock != NULL && (code == 0)) { if (pBlock != NULL && (code == 0)) {

View File

@ -88,7 +88,7 @@ int32_t setCountOutputBuf(SStreamAggSupporter* pAggSup, TSKEY ts, uint64_t group
winCode = TSDB_CODE_FAILED; winCode = TSDB_CODE_FAILED;
} else if (pBuffInfo->winBuffOp == MOVE_NEXT_WINDOW) { } else if (pBuffInfo->winBuffOp == MOVE_NEXT_WINDOW) {
ASSERT(pBuffInfo->pCur); QUERY_CHECK_NULL(pBuffInfo->pCur, code, lino, _end, terrno);
pAggSup->stateStore.streamStateCurNext(pAggSup->pState, pBuffInfo->pCur); pAggSup->stateStore.streamStateCurNext(pAggSup->pState, pBuffInfo->pCur);
winCode = pAggSup->stateStore.streamStateSessionGetKVByCur(pBuffInfo->pCur, &pCurWin->winInfo.sessionWin, winCode = pAggSup->stateStore.streamStateSessionGetKVByCur(pBuffInfo->pCur, &pCurWin->winInfo.sessionWin,
(void**)&pCurWin->winInfo.pStatePos, &size); (void**)&pCurWin->winInfo.pStatePos, &size);
@ -345,7 +345,6 @@ static void doStreamCountAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
if (slidingRows + winRows > pAggSup->windowSliding) { if (slidingRows + winRows > pAggSup->windowSliding) {
buffInfo.winBuffOp = CREATE_NEW_WINDOW; buffInfo.winBuffOp = CREATE_NEW_WINDOW;
winRows = pAggSup->windowSliding - slidingRows; winRows = pAggSup->windowSliding - slidingRows;
ASSERT(i >= 0);
} }
} else { } else {
buffInfo.winBuffOp = MOVE_NEXT_WINDOW; buffInfo.winBuffOp = MOVE_NEXT_WINDOW;
@ -690,7 +689,10 @@ static int32_t doStreamCountAggNext(SOperatorInfo* pOperator, SSDataBlock** ppRe
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
continue; continue;
} else { } else {
ASSERTS(pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_INVALID, "invalid SSDataBlock type"); if (pBlock->info.type != STREAM_NORMAL && pBlock->info.type != STREAM_INVALID) {
code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
QUERY_CHECK_CODE(code, lino, _end);
}
} }
if (pInfo->scalarSupp.pExprInfo != NULL) { if (pInfo->scalarSupp.pExprInfo != NULL) {

View File

@ -378,7 +378,6 @@ static void doStreamEventAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
rows, i, pAggSup->pResultRows, pSeUpdated, pStDeleted, &rebuild, &winRows); rows, i, pAggSup->pResultRows, pSeUpdated, pStDeleted, &rebuild, &winRows);
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
ASSERT(winRows >= 1);
if (rebuild) { if (rebuild) {
uint64_t uid = 0; uint64_t uid = 0;
code = appendDataToSpecialBlock(pAggSup->pScanBlock, &curWin.winInfo.sessionWin.win.skey, code = appendDataToSpecialBlock(pAggSup->pScanBlock, &curWin.winInfo.sessionWin.win.skey,
@ -660,7 +659,10 @@ static int32_t doStreamEventAggNext(SOperatorInfo* pOperator, SSDataBlock** ppRe
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
continue; continue;
} else { } else {
ASSERTS(pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_INVALID, "invalid SSDataBlock type"); if (pBlock->info.type != STREAM_NORMAL && pBlock->info.type != STREAM_INVALID) {
code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
QUERY_CHECK_CODE(code, lino, _end);
}
} }
if (pInfo->scalarSupp.pExprInfo != NULL) { if (pInfo->scalarSupp.pExprInfo != NULL) {
@ -779,7 +781,6 @@ void streamEventReloadState(SOperatorInfo* pOperator) {
int32_t num = (size - sizeof(TSKEY)) / sizeof(SSessionKey); int32_t num = (size - sizeof(TSKEY)) / sizeof(SSessionKey);
qDebug("===stream=== event window operator reload state. get result count:%d", num); qDebug("===stream=== event window operator reload state. get result count:%d", num);
SSessionKey* pSeKeyBuf = (SSessionKey*)pBuf; SSessionKey* pSeKeyBuf = (SSessionKey*)pBuf;
ASSERT(size == num * sizeof(SSessionKey) + sizeof(TSKEY));
TSKEY ts = *(TSKEY*)((char*)pBuf + size - sizeof(TSKEY)); TSKEY ts = *(TSKEY*)((char*)pBuf + size - sizeof(TSKEY));
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, ts); pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, ts);

View File

@ -331,7 +331,7 @@ void setDeleteFillValueInfo(TSKEY start, TSKEY end, SStreamFillSupporter* pFillS
pFillInfo->pLinearInfo->winIndex = 0; pFillInfo->pLinearInfo->winIndex = 0;
} break; } break;
default: default:
ASSERT(0); qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR));
break; break;
} }
} }
@ -419,7 +419,6 @@ void setFillValueInfo(SSDataBlock* pBlock, TSKEY ts, int32_t rowId, SStreamFillS
pFillSup->next.pRowVal = pFillSup->cur.pRowVal; pFillSup->next.pRowVal = pFillSup->cur.pRowVal;
pFillInfo->preRowKey = INT64_MIN; pFillInfo->preRowKey = INT64_MIN;
} else { } else {
ASSERT(hasNextWindow(pFillSup));
setFillKeyInfo(ts, nextWKey, &pFillSup->interval, pFillInfo); setFillKeyInfo(ts, nextWKey, &pFillSup->interval, pFillInfo);
pFillInfo->pos = FILL_POS_START; pFillInfo->pos = FILL_POS_START;
} }
@ -447,7 +446,6 @@ void setFillValueInfo(SSDataBlock* pBlock, TSKEY ts, int32_t rowId, SStreamFillS
pFillInfo->pResRow = &pFillSup->prev; pFillInfo->pResRow = &pFillSup->prev;
pFillInfo->pLinearInfo->hasNext = false; pFillInfo->pLinearInfo->hasNext = false;
} else { } else {
ASSERT(hasNextWindow(pFillSup));
setFillKeyInfo(ts, nextWKey, &pFillSup->interval, pFillInfo); setFillKeyInfo(ts, nextWKey, &pFillSup->interval, pFillInfo);
pFillInfo->pos = FILL_POS_START; pFillInfo->pos = FILL_POS_START;
pFillInfo->pLinearInfo->nextEnd = INT64_MIN; pFillInfo->pLinearInfo->nextEnd = INT64_MIN;
@ -458,10 +456,9 @@ void setFillValueInfo(SSDataBlock* pBlock, TSKEY ts, int32_t rowId, SStreamFillS
} }
} break; } break;
default: default:
ASSERT(0); qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR));
break; break;
} }
ASSERT(pFillInfo->pos != FILL_POS_INVALID);
} }
static int32_t checkResult(SStreamFillSupporter* pFillSup, TSKEY ts, uint64_t groupId, bool* pRes) { static int32_t checkResult(SStreamFillSupporter* pFillSup, TSKEY ts, uint64_t groupId, bool* pRes) {
@ -628,7 +625,9 @@ static void keepResultInDiscBuf(SOperatorInfo* pOperator, uint64_t groupId, SRes
SWinKey key = {.groupId = groupId, .ts = pRow->key}; SWinKey key = {.groupId = groupId, .ts = pRow->key};
int32_t code = pAPI->stateStore.streamStateFillPut(pOperator->pTaskInfo->streamInfo.pState, &key, pRow->pRowVal, len); int32_t code = pAPI->stateStore.streamStateFillPut(pOperator->pTaskInfo->streamInfo.pState, &key, pRow->pRowVal, len);
qDebug("===stream===fill operator save key ts:%" PRId64 " group id:%" PRIu64 " code:%d", key.ts, key.groupId, code); qDebug("===stream===fill operator save key ts:%" PRId64 " group id:%" PRIu64 " code:%d", key.ts, key.groupId, code);
ASSERT(code == TSDB_CODE_SUCCESS); if (code != TSDB_CODE_SUCCESS) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
}
} }
static void doStreamFillRange(SStreamFillInfo* pFillInfo, SStreamFillSupporter* pFillSup, SSDataBlock* pRes) { static void doStreamFillRange(SStreamFillInfo* pFillInfo, SStreamFillSupporter* pFillSup, SSDataBlock* pRes) {
@ -795,7 +794,6 @@ static int32_t buildDeleteRange(SOperatorInfo* pOp, TSKEY start, TSKEY end, uint
if (winCode != TSDB_CODE_SUCCESS) { if (winCode != TSDB_CODE_SUCCESS) {
colDataSetNULL(pTableCol, pBlock->info.rows); colDataSetNULL(pTableCol, pBlock->info.rows);
} else { } else {
ASSERT(tbname);
char parTbName[VARSTR_HEADER_SIZE + TSDB_TABLE_NAME_LEN]; char parTbName[VARSTR_HEADER_SIZE + TSDB_TABLE_NAME_LEN];
STR_WITH_MAXSIZE_TO_VARSTR(parTbName, tbname, sizeof(parTbName)); STR_WITH_MAXSIZE_TO_VARSTR(parTbName, tbname, sizeof(parTbName));
code = colDataSetVal(pTableCol, pBlock->info.rows, (const char*)parTbName, false); code = colDataSetVal(pTableCol, pBlock->info.rows, (const char*)parTbName, false);
@ -1125,7 +1123,7 @@ static int32_t doStreamFillNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
return code; return code;
} break; } break;
default: default:
ASSERTS(false, "invalid SSDataBlock type"); return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
} }
} }

View File

@ -213,7 +213,6 @@ static void removeDeleteResults(SSHashObj* pUpdatedMap, SArray* pDelWins) {
} }
bool isOverdue(TSKEY ekey, STimeWindowAggSupp* pTwSup) { bool isOverdue(TSKEY ekey, STimeWindowAggSupp* pTwSup) {
ASSERTS(pTwSup->maxTs == INT64_MIN || pTwSup->maxTs > 0, "maxts should greater than 0");
return pTwSup->maxTs != INT64_MIN && ekey < pTwSup->maxTs - pTwSup->waterMark; return pTwSup->maxTs != INT64_MIN && ekey < pTwSup->maxTs - pTwSup->waterMark;
} }
@ -415,7 +414,7 @@ static void doBuildDeleteResult(SStreamIntervalOperatorInfo* pInfo, SArray* pWin
code = appendDataToSpecialBlock(pBlock, &pWin->ts, &pWin->ts, &uid, &pWin->groupId, NULL); code = appendDataToSpecialBlock(pBlock, &pWin->ts, &pWin->ts, &uid, &pWin->groupId, NULL);
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
} else { } else {
ASSERT(tbname); QUERY_CHECK_CONDITION((tbname), code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
char parTbName[VARSTR_HEADER_SIZE + TSDB_TABLE_NAME_LEN]; char parTbName[VARSTR_HEADER_SIZE + TSDB_TABLE_NAME_LEN];
STR_WITH_MAXSIZE_TO_VARSTR(parTbName, tbname, sizeof(parTbName)); STR_WITH_MAXSIZE_TO_VARSTR(parTbName, tbname, sizeof(parTbName));
code = appendDataToSpecialBlock(pBlock, &pWin->ts, &pWin->ts, &uid, &pWin->groupId, parTbName); code = appendDataToSpecialBlock(pBlock, &pWin->ts, &pWin->ts, &uid, &pWin->groupId, parTbName);
@ -439,6 +438,11 @@ void destroyFlusedPos(void* pRes) {
} }
} }
void destroyFlusedppPos(void* ppRes) {
void *pRes = *(void **)ppRes;
destroyFlusedPos(pRes);
}
void clearGroupResInfo(SGroupResInfo* pGroupResInfo) { void clearGroupResInfo(SGroupResInfo* pGroupResInfo) {
if (pGroupResInfo->freeItem) { if (pGroupResInfo->freeItem) {
int32_t size = taosArrayGetSize(pGroupResInfo->pRows); int32_t size = taosArrayGetSize(pGroupResInfo->pRows);
@ -916,7 +920,6 @@ void buildDataBlockFromGroupRes(SOperatorInfo* pOperator, void* pState, SSDataBl
} }
if (pBlock->info.rows + pRow->numOfRows > pBlock->info.capacity) { if (pBlock->info.rows + pRow->numOfRows > pBlock->info.capacity) {
ASSERT(pBlock->info.rows > 0);
break; break;
} }
pGroupResInfo->index += 1; pGroupResInfo->index += 1;
@ -1366,7 +1369,7 @@ void doStreamIntervalDecodeOpState(void* buf, int32_t len, SOperatorInfo* pOpera
int32_t winCode = TSDB_CODE_SUCCESS; int32_t winCode = TSDB_CODE_SUCCESS;
code = pInfo->stateStore.streamStateAddIfNotExist(pInfo->pState, &key, (void**)&pPos, &resSize, &winCode); code = pInfo->stateStore.streamStateAddIfNotExist(pInfo->pState, &key, (void**)&pPos, &resSize, &winCode);
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
ASSERT(winCode == TSDB_CODE_SUCCESS); QUERY_CHECK_CONDITION((winCode == TSDB_CODE_SUCCESS), code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
code = tSimpleHashPut(pInfo->aggSup.pResultRowHashTable, &key, sizeof(SWinKey), &pPos, POINTER_BYTES); code = tSimpleHashPut(pInfo->aggSup.pResultRowHashTable, &key, sizeof(SWinKey), &pPos, POINTER_BYTES);
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
@ -1694,7 +1697,10 @@ static int32_t doStreamFinalIntervalAggNext(SOperatorInfo* pOperator, SSDataBloc
} else if (IS_FINAL_INTERVAL_OP(pOperator) && pBlock->info.type == STREAM_MID_RETRIEVE) { } else if (IS_FINAL_INTERVAL_OP(pOperator) && pBlock->info.type == STREAM_MID_RETRIEVE) {
continue; continue;
} else { } else {
ASSERTS(pBlock->info.type == STREAM_INVALID, "invalid SSDataBlock type"); if (pBlock->info.type != STREAM_INVALID) {
code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
QUERY_CHECK_CODE(code, lino, _end);
}
} }
if (pInfo->scalarSupp.pExprInfo != NULL) { if (pInfo->scalarSupp.pExprInfo != NULL) {
@ -1883,7 +1889,6 @@ int32_t createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiN
.deleteMarkSaved = 0, .deleteMarkSaved = 0,
.calTriggerSaved = 0, .calTriggerSaved = 0,
}; };
ASSERTS(pInfo->twAggSup.calTrigger != STREAM_TRIGGER_MAX_DELAY, "trigger type should not be max delay");
pInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId; pInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
initResultSizeInfo(&pOperator->resultInfo, 4096); initResultSizeInfo(&pOperator->resultInfo, 4096);
@ -1920,6 +1925,7 @@ int32_t createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiN
code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str, code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str,
pInfo->pState, &pTaskInfo->storageAPI.functionStore); pInfo->pState, &pTaskInfo->storageAPI.functionStore);
QUERY_CHECK_CODE(code, lino, _error); QUERY_CHECK_CODE(code, lino, _error);
tSimpleHashSetFreeFp(pInfo->aggSup.pResultRowHashTable, destroyFlusedppPos);
code = initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window); code = initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window);
QUERY_CHECK_CODE(code, lino, _error); QUERY_CHECK_CODE(code, lino, _error);
@ -2090,7 +2096,6 @@ int32_t initBasicInfoEx(SOptrBasicInfo* pBasicInfo, SExprSupp* pSup, SExprInfo*
pSup->pCtx[i].saveHandle.pBuf = NULL; pSup->pCtx[i].saveHandle.pBuf = NULL;
} }
ASSERT(numOfCols > 0);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
@ -2391,7 +2396,6 @@ _end:
static int32_t initSessionOutputBuf(SResultWindowInfo* pWinInfo, SResultRow** pResult, SqlFunctionCtx* pCtx, static int32_t initSessionOutputBuf(SResultWindowInfo* pWinInfo, SResultRow** pResult, SqlFunctionCtx* pCtx,
int32_t numOfOutput, int32_t* rowEntryInfoOffset) { int32_t numOfOutput, int32_t* rowEntryInfoOffset) {
ASSERT(pWinInfo->sessionWin.win.skey <= pWinInfo->sessionWin.win.ekey);
*pResult = (SResultRow*)pWinInfo->pStatePos->pRowBuff; *pResult = (SResultRow*)pWinInfo->pStatePos->pRowBuff;
// set time window for current result // set time window for current result
(*pResult)->win = pWinInfo->sessionWin.win; (*pResult)->win = pWinInfo->sessionWin.win;
@ -3022,7 +3026,6 @@ int32_t buildSessionResultDataBlock(SOperatorInfo* pOperator, void* pState, SSDa
} }
if (pBlock->info.rows + pRow->numOfRows > pBlock->info.capacity) { if (pBlock->info.rows + pRow->numOfRows > pBlock->info.capacity) {
ASSERT(pBlock->info.rows > 0);
break; break;
} }
@ -3262,7 +3265,7 @@ int32_t doStreamSessionDecodeOpState(void* buf, int32_t len, SOperatorInfo* pOpe
code = pAggSup->stateStore.streamStateSessionAddIfNotExist( code = pAggSup->stateStore.streamStateSessionAddIfNotExist(
pAggSup->pState, &winfo.sessionWin, pAggSup->gap, (void**)&winfo.pStatePos, &pAggSup->resultRowSize, &winCode); pAggSup->pState, &winfo.sessionWin, pAggSup->gap, (void**)&winfo.pStatePos, &pAggSup->resultRowSize, &winCode);
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
ASSERT(winCode == TSDB_CODE_SUCCESS); QUERY_CHECK_CONDITION((winCode == TSDB_CODE_SUCCESS), code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
buf = decodeSResultWindowInfo(buf, &winfo, pInfo->streamAggSup.resultRowSize); buf = decodeSResultWindowInfo(buf, &winfo, pInfo->streamAggSup.resultRowSize);
code = code =
@ -3276,7 +3279,6 @@ int32_t doStreamSessionDecodeOpState(void* buf, int32_t len, SOperatorInfo* pOpe
// 3.pChildren // 3.pChildren
int32_t size = 0; int32_t size = 0;
buf = taosDecodeFixedI32(buf, &size); buf = taosDecodeFixedI32(buf, &size);
ASSERT(size <= taosArrayGetSize(pInfo->pChildren));
for (int32_t i = 0; i < size; i++) { for (int32_t i = 0; i < size; i++) {
SOperatorInfo* pChOp = taosArrayGetP(pInfo->pChildren, i); SOperatorInfo* pChOp = taosArrayGetP(pInfo->pChildren, i);
code = doStreamSessionDecodeOpState(buf, 0, pChOp, false, &buf); code = doStreamSessionDecodeOpState(buf, 0, pChOp, false, &buf);
@ -3447,7 +3449,10 @@ static int32_t doStreamSessionAggNext(SOperatorInfo* pOperator, SSDataBlock** pp
continue; continue;
} else { } else {
ASSERTS(pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_INVALID, "invalid SSDataBlock type"); if (pBlock->info.type != STREAM_NORMAL && pBlock->info.type != STREAM_INVALID) {
code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
QUERY_CHECK_CODE(code, lino, _end);
}
} }
if (pInfo->scalarSupp.pExprInfo != NULL) { if (pInfo->scalarSupp.pExprInfo != NULL) {
@ -3621,7 +3626,6 @@ void streamSessionSemiReloadState(SOperatorInfo* pOperator) {
int32_t num = (size - sizeof(TSKEY)) / sizeof(SSessionKey); int32_t num = (size - sizeof(TSKEY)) / sizeof(SSessionKey);
SSessionKey* pSeKeyBuf = (SSessionKey*)pBuf; SSessionKey* pSeKeyBuf = (SSessionKey*)pBuf;
ASSERT(size == num * sizeof(SSessionKey) + sizeof(TSKEY));
for (int32_t i = 0; i < num; i++) { for (int32_t i = 0; i < num; i++) {
SResultWindowInfo winInfo = {0}; SResultWindowInfo winInfo = {0};
code = getSessionWindowInfoByKey(pAggSup, pSeKeyBuf + i, &winInfo); code = getSessionWindowInfoByKey(pAggSup, pSeKeyBuf + i, &winInfo);
@ -3667,7 +3671,6 @@ void streamSessionReloadState(SOperatorInfo* pOperator) {
int32_t num = (size - sizeof(TSKEY)) / sizeof(SSessionKey); int32_t num = (size - sizeof(TSKEY)) / sizeof(SSessionKey);
SSessionKey* pSeKeyBuf = (SSessionKey*)pBuf; SSessionKey* pSeKeyBuf = (SSessionKey*)pBuf;
ASSERT(size == num * sizeof(SSessionKey) + sizeof(TSKEY));
TSKEY ts = *(TSKEY*)((char*)pBuf + size - sizeof(TSKEY)); TSKEY ts = *(TSKEY*)((char*)pBuf + size - sizeof(TSKEY));
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, ts); pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, ts);
@ -3990,7 +3993,10 @@ static int32_t doStreamSessionSemiAggNext(SOperatorInfo* pOperator, SSDataBlock*
doStreamSessionSaveCheckpoint(pOperator); doStreamSessionSaveCheckpoint(pOperator);
continue; continue;
} else { } else {
ASSERTS(pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_INVALID, "invalid SSDataBlock type"); if (pBlock->info.type != STREAM_NORMAL && pBlock->info.type != STREAM_INVALID) {
code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
QUERY_CHECK_CODE(code, lino, _end);
}
} }
if (pInfo->scalarSupp.pExprInfo != NULL) { if (pInfo->scalarSupp.pExprInfo != NULL) {
@ -4205,7 +4211,8 @@ int32_t getStateWindowInfoByKey(SStreamAggSupporter* pAggSup, SSessionKey* pKey,
pCurWin->winInfo.sessionWin.win.ekey = pKey->win.ekey; pCurWin->winInfo.sessionWin.win.ekey = pKey->win.ekey;
code = getSessionWindowInfoByKey(pAggSup, pKey, &pCurWin->winInfo); code = getSessionWindowInfoByKey(pAggSup, pKey, &pCurWin->winInfo);
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
ASSERT(IS_VALID_SESSION_WIN(pCurWin->winInfo)); QUERY_CHECK_CONDITION((IS_VALID_SESSION_WIN(pCurWin->winInfo)), code, lino, _end,
TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
pCurWin->pStateKey = pCurWin->pStateKey =
(SStateKeys*)((char*)pCurWin->winInfo.pStatePos->pRowBuff + (pAggSup->resultRowSize - pAggSup->stateKeySize)); (SStateKeys*)((char*)pCurWin->winInfo.pStatePos->pRowBuff + (pAggSup->resultRowSize - pAggSup->stateKeySize));
@ -4575,7 +4582,6 @@ int32_t doStreamStateDecodeOpState(void* buf, int32_t len, SOperatorInfo* pOpera
// 3.pChildren // 3.pChildren
int32_t size = 0; int32_t size = 0;
buf = taosDecodeFixedI32(buf, &size); buf = taosDecodeFixedI32(buf, &size);
ASSERT(size <= taosArrayGetSize(pInfo->pChildren));
for (int32_t i = 0; i < size; i++) { for (int32_t i = 0; i < size; i++) {
SOperatorInfo* pChOp = taosArrayGetP(pInfo->pChildren, i); SOperatorInfo* pChOp = taosArrayGetP(pInfo->pChildren, i);
code = doStreamStateDecodeOpState(buf, 0, pChOp, false, &buf); code = doStreamStateDecodeOpState(buf, 0, pChOp, false, &buf);
@ -4717,7 +4723,10 @@ static int32_t doStreamStateAggNext(SOperatorInfo* pOperator, SSDataBlock** ppRe
continue; continue;
} else { } else {
ASSERTS(pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_INVALID, "invalid SSDataBlock type"); if (pBlock->info.type != STREAM_NORMAL && pBlock->info.type != STREAM_INVALID) {
code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
QUERY_CHECK_CODE(code, lino, _end);
}
} }
if (pInfo->scalarSupp.pExprInfo != NULL) { if (pInfo->scalarSupp.pExprInfo != NULL) {
@ -4829,7 +4838,6 @@ void streamStateReloadState(SOperatorInfo* pOperator) {
int32_t num = (size - sizeof(TSKEY)) / sizeof(SSessionKey); int32_t num = (size - sizeof(TSKEY)) / sizeof(SSessionKey);
qDebug("===stream=== reload state. get result count:%d", num); qDebug("===stream=== reload state. get result count:%d", num);
SSessionKey* pSeKeyBuf = (SSessionKey*)pBuf; SSessionKey* pSeKeyBuf = (SSessionKey*)pBuf;
ASSERT(size == num * sizeof(SSessionKey) + sizeof(TSKEY));
TSKEY ts = *(TSKEY*)((char*)pBuf + size - sizeof(TSKEY)); TSKEY ts = *(TSKEY*)((char*)pBuf + size - sizeof(TSKEY));
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, ts); pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, ts);
@ -5135,7 +5143,10 @@ static int32_t doStreamIntervalAggNext(SOperatorInfo* pOperator, SSDataBlock** p
continue; continue;
} else { } else {
ASSERTS(pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_INVALID, "invalid SSDataBlock type"); if (pBlock->info.type != STREAM_NORMAL && pBlock->info.type != STREAM_INVALID) {
code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
QUERY_CHECK_CODE(code, lino, _end);
}
} }
if (pBlock->info.type == STREAM_NORMAL && pBlock->info.version != 0) { if (pBlock->info.type == STREAM_NORMAL && pBlock->info.version != 0) {
@ -5254,8 +5265,6 @@ int32_t createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode*
.minTs = INT64_MAX, .minTs = INT64_MAX,
.deleteMark = getDeleteMark(&pIntervalPhyNode->window, pIntervalPhyNode->interval)}; .deleteMark = getDeleteMark(&pIntervalPhyNode->window, pIntervalPhyNode->interval)};
ASSERTS(pInfo->twAggSup.calTrigger != STREAM_TRIGGER_MAX_DELAY, "trigger type should not be max delay");
pOperator->pTaskInfo = pTaskInfo; pOperator->pTaskInfo = pTaskInfo;
SStorageAPI* pAPI = &pOperator->pTaskInfo->storageAPI; SStorageAPI* pAPI = &pOperator->pTaskInfo->storageAPI;
@ -5283,6 +5292,7 @@ int32_t createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode*
code = initAggSup(pSup, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str, pInfo->pState, code = initAggSup(pSup, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str, pInfo->pState,
&pTaskInfo->storageAPI.functionStore); &pTaskInfo->storageAPI.functionStore);
QUERY_CHECK_CODE(code, lino, _error); QUERY_CHECK_CODE(code, lino, _error);
tSimpleHashSetFreeFp(pInfo->aggSup.pResultRowHashTable, destroyFlusedppPos);
if (pIntervalPhyNode->window.pExprs != NULL) { if (pIntervalPhyNode->window.pExprs != NULL) {
int32_t numOfScalar = 0; int32_t numOfScalar = 0;
@ -5635,7 +5645,6 @@ static int32_t doStreamMidIntervalAggNext(SOperatorInfo* pOperator, SSDataBlock*
} else { } else {
pInfo->pDelRes->info.type = STREAM_DELETE_RESULT; pInfo->pDelRes->info.type = STREAM_DELETE_RESULT;
} }
ASSERT(taosArrayGetSize(pInfo->pUpdated) == 0);
(*ppRes) = pInfo->pDelRes; (*ppRes) = pInfo->pDelRes;
return code; return code;
} }
@ -5684,7 +5693,10 @@ static int32_t doStreamMidIntervalAggNext(SOperatorInfo* pOperator, SSDataBlock*
pInfo->clearState = true; pInfo->clearState = true;
break; break;
} else { } else {
ASSERTS(pBlock->info.type == STREAM_INVALID, "invalid SSDataBlock type"); if (pBlock->info.type != STREAM_INVALID) {
code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
QUERY_CHECK_CODE(code, lino, _end);
}
} }
if (pInfo->scalarSupp.pExprInfo != NULL) { if (pInfo->scalarSupp.pExprInfo != NULL) {

View File

@ -1670,6 +1670,7 @@ static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) {
pAPI->metaReaderFn.clearReader(&mr); pAPI->metaReaderFn.clearReader(&mr);
pAPI->metaFn.closeTableMetaCursor(pInfo->pCur); pAPI->metaFn.closeTableMetaCursor(pInfo->pCur);
pInfo->pCur = NULL; pInfo->pCur = NULL;
blockDataDestroy(p);
T_LONG_JMP(pTaskInfo->env, terrno); T_LONG_JMP(pTaskInfo->env, terrno);
} }
@ -1829,6 +1830,8 @@ _end:
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
blockDataDestroy(p); blockDataDestroy(p);
pTaskInfo->code = code; pTaskInfo->code = code;
pAPI->metaFn.closeTableMetaCursor(pInfo->pCur);
pInfo->pCur = NULL;
T_LONG_JMP(pTaskInfo->env, code); T_LONG_JMP(pTaskInfo->env, code);
} }
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes; return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;

View File

@ -114,7 +114,6 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
pLinearInfo->start.key = *(int64_t*)colDataGetData(pTsCol, rowIndex); pLinearInfo->start.key = *(int64_t*)colDataGetData(pTsCol, rowIndex);
char* p = colDataGetData(pColInfoData, rowIndex); char* p = colDataGetData(pColInfoData, rowIndex);
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) { if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
ASSERT(varDataTLen(p) <= pColInfoData->info.bytes);
memcpy(pLinearInfo->start.val, p, varDataTLen(p)); memcpy(pLinearInfo->start.val, p, varDataTLen(p));
} else { } else {
memcpy(pLinearInfo->start.val, p, pLinearInfo->bytes); memcpy(pLinearInfo->start.val, p, pLinearInfo->bytes);
@ -127,7 +126,6 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
char* p = colDataGetData(pColInfoData, rowIndex); char* p = colDataGetData(pColInfoData, rowIndex);
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) { if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
ASSERT(varDataTLen(p) <= pColInfoData->info.bytes);
memcpy(pLinearInfo->end.val, p, varDataTLen(p)); memcpy(pLinearInfo->end.val, p, varDataTLen(p));
} else { } else {
memcpy(pLinearInfo->end.val, p, pLinearInfo->bytes); memcpy(pLinearInfo->end.val, p, pLinearInfo->bytes);
@ -143,7 +141,6 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
char* p = colDataGetData(pColInfoData, rowIndex); char* p = colDataGetData(pColInfoData, rowIndex);
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) { if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
ASSERT(varDataTLen(p) <= pColInfoData->info.bytes);
memcpy(pLinearInfo->end.val, p, varDataTLen(p)); memcpy(pLinearInfo->end.val, p, varDataTLen(p));
} else { } else {
memcpy(pLinearInfo->end.val, p, pLinearInfo->bytes); memcpy(pLinearInfo->end.val, p, pLinearInfo->bytes);

View File

@ -136,7 +136,6 @@ FORCE_INLINE int32_t getForwardStepsInBlock(int32_t numOfRows, __block_search_fn
// } // }
} }
ASSERT(forwardRows >= 0);
return forwardRows; return forwardRows;
} }
@ -211,8 +210,6 @@ int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order) {
int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn, int32_t startPos, TSKEY ekey, int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn, int32_t startPos, TSKEY ekey,
__block_search_fn_t searchFn, STableQueryInfo* item, int32_t order) { __block_search_fn_t searchFn, STableQueryInfo* item, int32_t order) {
ASSERT(startPos >= 0 && startPos < pDataBlockInfo->rows);
int32_t num = -1; int32_t num = -1;
int32_t step = GET_FORWARD_DIRECTION_FACTOR(order); int32_t step = GET_FORWARD_DIRECTION_FACTOR(order);
@ -259,8 +256,6 @@ void doTimeWindowInterpolation(SArray* pPrevValues, SArray* pDataBlock, TSKEY pr
SFunctParam* pParam = &pCtx[k].param[0]; SFunctParam* pParam = &pCtx[k].param[0];
SColumnInfoData* pColInfo = taosArrayGet(pDataBlock, pParam->pCol->slotId); SColumnInfoData* pColInfo = taosArrayGet(pDataBlock, pParam->pCol->slotId);
ASSERT(pColInfo->info.type == pParam->pCol->type && curTs != windowKey);
double v1 = 0, v2 = 0, v = 0; double v1 = 0, v2 = 0, v = 0;
if (prevRowIndex == -1) { if (prevRowIndex == -1) {
SGroupKeys* p = taosArrayGet(pPrevValues, index); SGroupKeys* p = taosArrayGet(pPrevValues, index);
@ -356,9 +351,11 @@ static bool setTimeWindowInterpolationStartTs(SIntervalAggOperatorInfo* pInfo, i
return true; return true;
} }
static bool setTimeWindowInterpolationEndTs(SIntervalAggOperatorInfo* pInfo, SExprSupp* pSup, int32_t endRowIndex, static int32_t setTimeWindowInterpolationEndTs(SIntervalAggOperatorInfo* pInfo, SExprSupp* pSup, int32_t endRowIndex,
int32_t nextRowIndex, SArray* pDataBlock, const TSKEY* tsCols, int32_t nextRowIndex, SArray* pDataBlock, const TSKEY* tsCols,
TSKEY blockEkey, STimeWindow* win) { TSKEY blockEkey, STimeWindow* win, bool* pRes) {
int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0;
int32_t order = pInfo->binfo.inputTsOrder; int32_t order = pInfo->binfo.inputTsOrder;
TSKEY actualEndKey = tsCols[endRowIndex]; TSKEY actualEndKey = tsCols[endRowIndex];
@ -367,21 +364,27 @@ static bool setTimeWindowInterpolationEndTs(SIntervalAggOperatorInfo* pInfo, SEx
// not ended in current data block, do not invoke interpolation // not ended in current data block, do not invoke interpolation
if ((key > blockEkey && (order == TSDB_ORDER_ASC)) || (key < blockEkey && (order == TSDB_ORDER_DESC))) { if ((key > blockEkey && (order == TSDB_ORDER_ASC)) || (key < blockEkey && (order == TSDB_ORDER_DESC))) {
setNotInterpoWindowKey(pSup->pCtx, pSup->numOfExprs, RESULT_ROW_END_INTERP); setNotInterpoWindowKey(pSup->pCtx, pSup->numOfExprs, RESULT_ROW_END_INTERP);
return false; (*pRes) = false;
return code;
} }
// there is actual end point of current time window, no interpolation needs // there is actual end point of current time window, no interpolation needs
if (key == actualEndKey) { if (key == actualEndKey) {
setNotInterpoWindowKey(pSup->pCtx, pSup->numOfExprs, RESULT_ROW_END_INTERP); setNotInterpoWindowKey(pSup->pCtx, pSup->numOfExprs, RESULT_ROW_END_INTERP);
return true; (*pRes) = true;
return code;
} }
ASSERT(nextRowIndex >= 0); if (nextRowIndex < 0) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR));
return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
}
TSKEY nextKey = tsCols[nextRowIndex]; TSKEY nextKey = tsCols[nextRowIndex];
doTimeWindowInterpolation(pInfo->pPrevValues, pDataBlock, actualEndKey, endRowIndex, nextKey, nextRowIndex, key, doTimeWindowInterpolation(pInfo->pPrevValues, pDataBlock, actualEndKey, endRowIndex, nextKey, nextRowIndex, key,
RESULT_ROW_END_INTERP, pSup); RESULT_ROW_END_INTERP, pSup);
return true; (*pRes) = true;
return code;
} }
bool inCalSlidingWindow(SInterval* pInterval, STimeWindow* pWin, TSKEY calStart, TSKEY calEnd, EStreamType blockType) { bool inCalSlidingWindow(SInterval* pInterval, STimeWindow* pWin, TSKEY calStart, TSKEY calEnd, EStreamType blockType) {
@ -437,13 +440,7 @@ int32_t getNextQualifiedWindow(SInterval* pInterval, STimeWindow* pNext, SDataBl
* This time window does not cover any data, try next time window, * This time window does not cover any data, try next time window,
* this case may happen when the time window is too small * this case may happen when the time window is too small
*/ */
if (primaryKeys == NULL) { if (primaryKeys != NULL) {
if (ascQuery) {
ASSERT(pDataBlockInfo->window.skey <= pNext->ekey);
} else {
ASSERT(pDataBlockInfo->window.ekey >= pNext->skey);
}
} else {
if (ascQuery && primaryKeys[startPos] > pNext->ekey) { if (ascQuery && primaryKeys[startPos] > pNext->ekey) {
TSKEY next = primaryKeys[startPos]; TSKEY next = primaryKeys[startPos];
if (pInterval->intervalUnit == 'n' || pInterval->intervalUnit == 'y') { if (pInterval->intervalUnit == 'n' || pInterval->intervalUnit == 'y') {
@ -469,7 +466,6 @@ int32_t getNextQualifiedWindow(SInterval* pInterval, STimeWindow* pNext, SDataBl
} }
static bool isResultRowInterpolated(SResultRow* pResult, SResultTsInterpType type) { static bool isResultRowInterpolated(SResultRow* pResult, SResultTsInterpType type) {
ASSERT(pResult != NULL && (type == RESULT_ROW_START_INTERP || type == RESULT_ROW_END_INTERP));
if (type == RESULT_ROW_START_INTERP) { if (type == RESULT_ROW_START_INTERP) {
return pResult->startInterp == true; return pResult->startInterp == true;
} else { } else {
@ -485,15 +481,21 @@ static void setResultRowInterpo(SResultRow* pResult, SResultTsInterpType type) {
} }
} }
static void doWindowBorderInterpolation(SIntervalAggOperatorInfo* pInfo, SSDataBlock* pBlock, SResultRow* pResult, static int32_t doWindowBorderInterpolation(SIntervalAggOperatorInfo* pInfo, SSDataBlock* pBlock, SResultRow* pResult,
STimeWindow* win, int32_t startPos, int32_t forwardRows, SExprSupp* pSup) { STimeWindow* win, int32_t startPos, int32_t forwardRows, SExprSupp* pSup) {
int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0;
if (!pInfo->timeWindowInterpo) { if (!pInfo->timeWindowInterpo) {
return; return code;
}
if (pBlock == NULL) {
code = TSDB_CODE_INVALID_PARA;
return code;
} }
ASSERT(pBlock != NULL);
if (pBlock->pDataBlock == NULL) { if (pBlock->pDataBlock == NULL) {
return; return code;
} }
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex); SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex);
@ -528,14 +530,22 @@ static void doWindowBorderInterpolation(SIntervalAggOperatorInfo* pInfo, SSDataB
} }
TSKEY endKey = (pInfo->binfo.inputTsOrder == TSDB_ORDER_ASC) ? pBlock->info.window.ekey : pBlock->info.window.skey; TSKEY endKey = (pInfo->binfo.inputTsOrder == TSDB_ORDER_ASC) ? pBlock->info.window.ekey : pBlock->info.window.skey;
bool interp = setTimeWindowInterpolationEndTs(pInfo, pSup, endRowIndex, nextRowIndex, pBlock->pDataBlock, tsCols, bool interp = false;
endKey, win); code = setTimeWindowInterpolationEndTs(pInfo, pSup, endRowIndex, nextRowIndex, pBlock->pDataBlock, tsCols,
endKey, win, &interp);
QUERY_CHECK_CODE(code, lino, _end);
if (interp) { if (interp) {
setResultRowInterpo(pResult, RESULT_ROW_END_INTERP); setResultRowInterpo(pResult, RESULT_ROW_END_INTERP);
} }
} else { } else {
setNotInterpoWindowKey(pSup->pCtx, pSup->numOfExprs, RESULT_ROW_END_INTERP); setNotInterpoWindowKey(pSup->pCtx, pSup->numOfExprs, RESULT_ROW_END_INTERP);
} }
_end:
if (code != TSDB_CODE_SUCCESS) {
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
}
return code;
} }
static void saveDataBlockLastRow(SArray* pPrevKeys, const SSDataBlock* pBlock, SArray* pCols) { static void saveDataBlockLastRow(SArray* pPrevKeys, const SSDataBlock* pBlock, SArray* pCols) {
@ -558,7 +568,6 @@ static void saveDataBlockLastRow(SArray* pPrevKeys, const SSDataBlock* pBlock, S
char* val = colDataGetData(pColInfo, i); char* val = colDataGetData(pColInfo, i);
if (IS_VAR_DATA_TYPE(pkey->type)) { if (IS_VAR_DATA_TYPE(pkey->type)) {
memcpy(pkey->pData, val, varDataTLen(val)); memcpy(pkey->pData, val, varDataTLen(val));
ASSERT(varDataTLen(val) <= pkey->bytes);
} else { } else {
memcpy(pkey->pData, val, pkey->bytes); memcpy(pkey->pData, val, pkey->bytes);
} }
@ -594,11 +603,17 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num
T_LONG_JMP(pTaskInfo->env, terrno); T_LONG_JMP(pTaskInfo->env, terrno);
} }
ASSERT(pr->offset == p1->offset && pr->pageId == p1->pageId); if (!(pr->offset == p1->offset && pr->pageId == p1->pageId)) {
pTaskInfo->code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
T_LONG_JMP(pTaskInfo->env, terrno);
}
if (pr->closed) { if (pr->closed) {
ASSERT(isResultRowInterpolated(pr, RESULT_ROW_START_INTERP) && if (!(isResultRowInterpolated(pr, RESULT_ROW_START_INTERP) &&
isResultRowInterpolated(pr, RESULT_ROW_END_INTERP)); isResultRowInterpolated(pr, RESULT_ROW_END_INTERP)) ) {
pTaskInfo->code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
T_LONG_JMP(pTaskInfo->env, terrno);
}
SListNode* pNode = tdListPopHead(pResultRowInfo->openWindow); SListNode* pNode = tdListPopHead(pResultRowInfo->openWindow);
taosMemoryFree(pNode); taosMemoryFree(pNode);
continue; continue;
@ -611,7 +626,10 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
} }
ASSERT(!isResultRowInterpolated(pResult, RESULT_ROW_END_INTERP)); if(isResultRowInterpolated(pResult, RESULT_ROW_END_INTERP)) {
pTaskInfo->code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
T_LONG_JMP(pTaskInfo->env, terrno);
}
SGroupKeys* pTsKey = taosArrayGet(pInfo->pPrevValues, 0); SGroupKeys* pTsKey = taosArrayGet(pInfo->pPrevValues, 0);
if (!pTsKey) { if (!pTsKey) {
@ -764,11 +782,14 @@ static bool hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx, ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx,
numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
if (ret != TSDB_CODE_SUCCESS) { if (ret != TSDB_CODE_SUCCESS) {
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); T_LONG_JMP(pTaskInfo->env, ret);
} }
// window start key interpolation // window start key interpolation
doWindowBorderInterpolation(pInfo, pBlock, pResult, &win, startPos, forwardRows, pSup); ret = doWindowBorderInterpolation(pInfo, pBlock, pResult, &win, startPos, forwardRows, pSup);
if (ret != TSDB_CODE_SUCCESS) {
T_LONG_JMP(pTaskInfo->env, ret);
}
} }
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &win, 1); updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &win, 1);
@ -796,7 +817,10 @@ static bool hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
forwardRows = getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, forwardRows = getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL,
pInfo->binfo.inputTsOrder); pInfo->binfo.inputTsOrder);
// window start(end) key interpolation // window start(end) key interpolation
doWindowBorderInterpolation(pInfo, pBlock, pResult, &nextWin, startPos, forwardRows, pSup); code = doWindowBorderInterpolation(pInfo, pBlock, pResult, &nextWin, startPos, forwardRows, pSup);
if (code != TSDB_CODE_SUCCESS) {
T_LONG_JMP(pTaskInfo->env, code);
}
// TODO: add to open window? how to close the open windows after input blocks exhausted? // TODO: add to open window? how to close the open windows after input blocks exhausted?
#if 0 #if 0
if ((ascScan && ekey <= pBlock->info.window.ekey) || if ((ascScan && ekey <= pBlock->info.window.ekey) ||
@ -869,7 +893,10 @@ int64_t* extractTsCol(SSDataBlock* pBlock, const SIntervalAggOperatorInfo* pInfo
} }
tsCols = (int64_t*)pColDataInfo->pData; tsCols = (int64_t*)pColDataInfo->pData;
ASSERT(tsCols[0] != 0); if(tsCols[0] == 0) {
pTaskInfo->code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
T_LONG_JMP(pTaskInfo->env, terrno);
}
// no data in primary ts // no data in primary ts
if (tsCols[0] == 0 && tsCols[pBlock->info.rows - 1] == 0) { if (tsCols[0] == 0 && tsCols[pBlock->info.rows - 1] == 0) {
@ -1959,7 +1986,10 @@ static void doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) {
} else { } else {
if (pMiaInfo->groupId != pBlock->info.id.groupId) { if (pMiaInfo->groupId != pBlock->info.id.groupId) {
// if there are unclosed time window, close it firstly. // if there are unclosed time window, close it firstly.
ASSERT(pMiaInfo->curTs != INT64_MIN); if (pMiaInfo->curTs == INT64_MIN) {
pTaskInfo->code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
T_LONG_JMP(pTaskInfo->env, terrno);
}
finalizeResultRows(pIaInfo->aggSup.pResultBuf, &pResultRowInfo->cur, pSup, pRes, pTaskInfo); finalizeResultRows(pIaInfo->aggSup.pResultBuf, &pResultRowInfo->cur, pSup, pRes, pTaskInfo);
resetResultRow(pMiaInfo->pResultRow, pIaInfo->aggSup.resultRowSize - sizeof(SResultRow)); resetResultRow(pMiaInfo->pResultRow, pIaInfo->aggSup.resultRowSize - sizeof(SResultRow));
@ -2216,7 +2246,9 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
TSKEY ekey = ascScan ? win.ekey : win.skey; TSKEY ekey = ascScan ? win.ekey : win.skey;
int32_t forwardRows = getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, int32_t forwardRows = getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL,
iaInfo->binfo.inputTsOrder); iaInfo->binfo.inputTsOrder);
ASSERT(forwardRows > 0); if(forwardRows <= 0) {
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
}
// prev time window not interpolation yet. // prev time window not interpolation yet.
if (iaInfo->timeWindowInterpo) { if (iaInfo->timeWindowInterpo) {
@ -2227,11 +2259,14 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pExprSup->pCtx, ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pExprSup->pCtx,
numOfOutput, pExprSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo); numOfOutput, pExprSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo);
if (ret != TSDB_CODE_SUCCESS) { if (ret != TSDB_CODE_SUCCESS) {
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); T_LONG_JMP(pTaskInfo->env, ret);
} }
// window start key interpolation // window start key interpolation
doWindowBorderInterpolation(iaInfo, pBlock, pResult, &win, startPos, forwardRows, pExprSup); ret = doWindowBorderInterpolation(iaInfo, pBlock, pResult, &win, startPos, forwardRows, pExprSup);
if (ret != TSDB_CODE_SUCCESS) {
T_LONG_JMP(pTaskInfo->env, ret);
}
} }
updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &win, 1); updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &win, 1);
@ -2268,7 +2303,10 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
iaInfo->binfo.inputTsOrder); iaInfo->binfo.inputTsOrder);
// window start(end) key interpolation // window start(end) key interpolation
doWindowBorderInterpolation(iaInfo, pBlock, pResult, &nextWin, startPos, forwardRows, pExprSup); code = doWindowBorderInterpolation(iaInfo, pBlock, pResult, &nextWin, startPos, forwardRows, pExprSup);
if (code != TSDB_CODE_SUCCESS) {
T_LONG_JMP(pTaskInfo->env, code);
}
updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &nextWin, 1); updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &nextWin, 1);
applyAggFunctionOnPartialTuples(pTaskInfo, pExprSup->pCtx, &iaInfo->twAggSup.timeWindowData, startPos, forwardRows, applyAggFunctionOnPartialTuples(pTaskInfo, pExprSup->pCtx, &iaInfo->twAggSup.timeWindowData, startPos, forwardRows,

View File

@ -59,7 +59,7 @@ int32_t tHistogramCreate(int32_t numOfEntries, SHistogramInfo** pHisto);
SHistogramInfo* tHistogramCreateFrom(void* pBuf, int32_t numOfBins); SHistogramInfo* tHistogramCreateFrom(void* pBuf, int32_t numOfBins);
int32_t tHistogramAdd(SHistogramInfo** pHisto, double val); int32_t tHistogramAdd(SHistogramInfo** pHisto, double val);
int64_t tHistogramSum(SHistogramInfo* pHisto, double v); int32_t tHistogramSum(SHistogramInfo* pHisto, double v, int64_t *res);
int32_t tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num, double** pVal); int32_t tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num, double** pVal);
int32_t tHistogramMerge(SHistogramInfo* pHisto1, SHistogramInfo* pHisto2, int32_t numOfEntries, int32_t tHistogramMerge(SHistogramInfo* pHisto1, SHistogramInfo* pHisto2, int32_t numOfEntries,

View File

@ -47,7 +47,7 @@ typedef struct tMemBucketSlot {
} tMemBucketSlot; } tMemBucketSlot;
struct tMemBucket; struct tMemBucket;
typedef int32_t (*__perc_hash_func_t)(struct tMemBucket *pBucket, const void *value); typedef int32_t (*__perc_hash_func_t)(struct tMemBucket *pBucket, const void *value, int32_t *index);
typedef struct tMemBucket { typedef struct tMemBucket {
int16_t numOfSlots; int16_t numOfSlots;

View File

@ -4018,7 +4018,9 @@ int32_t saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock*
if (NULL == pColInfo) { if (NULL == pColInfo) {
return TSDB_CODE_OUT_OF_RANGE; return TSDB_CODE_OUT_OF_RANGE;
} }
ASSERT(pColInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP); if (pColInfo->info.type != TSDB_DATA_TYPE_TIMESTAMP) {
return TSDB_CODE_FUNC_FUNTION_PARA_TYPE;
}
key.groupId = pSrcBlock->info.id.groupId; key.groupId = pSrcBlock->info.id.groupId;
key.ts = *(int64_t*)colDataGetData(pColInfo, rowIndex); key.ts = *(int64_t*)colDataGetData(pColInfo, rowIndex);
} }

View File

@ -14,6 +14,7 @@
*/ */
#include "os.h" #include "os.h"
#include "query.h"
#include "taosdef.h" #include "taosdef.h"
#include "thistogram.h" #include "thistogram.h"
#include "tlosertree.h" #include "tlosertree.h"
@ -81,9 +82,9 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
#if defined(USE_ARRAYLIST) #if defined(USE_ARRAYLIST)
int32_t idx = histoBinarySearch((*pHisto)->elems, (*pHisto)->numOfEntries, val); int32_t idx = histoBinarySearch((*pHisto)->elems, (*pHisto)->numOfEntries, val);
if (ASSERTS(idx >= 0 && idx <= (*pHisto)->maxEntries && (*pHisto)->elems != NULL, "tHistogramAdd Error, idx:%d, maxEntries:%d, elems:%p", if (idx < 0 || idx > (*pHisto)->maxEntries || (*pHisto)->elems == NULL) {
idx, (*pHisto)->maxEntries, (*pHisto)->elems)) { qError("tHistogramAdd Error, idx:%d, maxEntries:%d, elems:%p", idx, (*pHisto)->maxEntries, (*pHisto)->elems);
return TSDB_CODE_FAILED; return TSDB_CODE_FUNC_HISTOGRAM_ERROR;
} }
if ((*pHisto)->elems[idx].val == val && idx >= 0) { if ((*pHisto)->elems[idx].val == val && idx >= 0) {
@ -95,21 +96,19 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
} else { /* insert a new slot */ } else { /* insert a new slot */
if ((*pHisto)->numOfElems >= 1 && idx < (*pHisto)->numOfEntries) { if ((*pHisto)->numOfElems >= 1 && idx < (*pHisto)->numOfEntries) {
if (idx > 0) { if (idx > 0) {
if (ASSERTS((*pHisto)->elems[idx - 1].val <= val, "tHistogramAdd Error, elems[%d].val:%lf, val:%lf", if ((*pHisto)->elems[idx - 1].val > val) {
idx - 1, (*pHisto)->elems[idx - 1].val, val)) { qError("tHistogramAdd Error, elems[%d].val:%lf, val:%lf", idx - 1, (*pHisto)->elems[idx - 1].val, val);
return TSDB_CODE_FAILED; return TSDB_CODE_FUNC_HISTOGRAM_ERROR;
} }
} else { } else {
if (ASSERTS((*pHisto)->elems[idx].val > val, "tHistogramAdd Error, elems[%d].val:%lf, val:%lf", if ((*pHisto)->elems[idx].val <= val) {
idx, (*pHisto)->elems[idx].val, val)) { qError("tHistogramAdd Error, elems[%d].val:%lf, val:%lf", idx, (*pHisto)->elems[idx].val, val);
return TSDB_CODE_FAILED; return TSDB_CODE_FUNC_HISTOGRAM_ERROR;
} }
} }
} else if ((*pHisto)->numOfElems > 0) { } else if ((*pHisto)->numOfElems > 0 && (*pHisto)->elems[(*pHisto)->numOfEntries].val > val) {
if (ASSERTS((*pHisto)->elems[(*pHisto)->numOfEntries].val <= val, "tHistogramAdd Error, elems[%d].val:%lf, val:%lf", qError("tHistogramAdd Error, elems[%d].val:%lf, val:%lf", (*pHisto)->numOfEntries, (*pHisto)->elems[idx].val, val);
(*pHisto)->numOfEntries, (*pHisto)->elems[idx].val, val)) { return TSDB_CODE_FUNC_HISTOGRAM_ERROR;
return TSDB_CODE_FAILED;
}
} }
code = histogramCreateBin(*pHisto, idx, val); code = histogramCreateBin(*pHisto, idx, val);
@ -225,9 +224,9 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
tSkipListNode* pNext = pNode->pForward[0]; tSkipListNode* pNext = pNode->pForward[0];
SHistBin* pNextEntry = (SHistBin*)pNext->pData; SHistBin* pNextEntry = (SHistBin*)pNext->pData;
if (ASSERTS(pNextEntry->val - pEntry->val == pEntry->delta, "tHistogramAdd Error, pNextEntry->val:%lf, pEntry->val:%lf, pEntry->delta:%lf", if (pNextEntry->val - pEntry->val != pEntry->delta) {
pNextEntry->val, pEntry->val, pEntry->delta)) { qError("tHistogramAdd Error, pNextEntry->val:%lf, pEntry->val:%lf, pEntry->delta:%lf", pNextEntry->val, pEntry->val, pEntry->delta);
return -1; return TSDB_CODE_FUNC_HISTOGRAM_ERROR;
} }
double newVal = (pEntry->val * pEntry->num + pNextEntry->val * pNextEntry->num) / (pEntry->num + pNextEntry->num); double newVal = (pEntry->val * pEntry->num + pNextEntry->val * pNextEntry->num) / (pEntry->num + pNextEntry->num);
@ -278,8 +277,9 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
} else { } else {
SHistBin* pEntry = (SHistBin*)pResNode->pData; SHistBin* pEntry = (SHistBin*)pResNode->pData;
if (ASSERTS(pEntry->val == val, "tHistogramAdd Error, pEntry->val:%lf, val:%lf")) { if (pEntry->val != val) {
return -1; qError("tHistogramAdd Error, pEntry->val:%lf, val:%lf", pEntry->val, val);
return TSDB_CODE_FUNC_HISTOGRAM_ERROR;
} }
pEntry->num += 1; pEntry->num += 1;
} }
@ -356,9 +356,9 @@ int32_t histogramCreateBin(SHistogramInfo* pHisto, int32_t index, double val) {
(void)memmove(&pHisto->elems[index + 1], &pHisto->elems[index], sizeof(SHistBin) * remain); (void)memmove(&pHisto->elems[index + 1], &pHisto->elems[index], sizeof(SHistBin) * remain);
} }
if (ASSERTS(index >= 0 && index <= pHisto->maxEntries, "histogramCreateBin Error, index:%d, maxEntries:%d", if (index < 0 || index > pHisto->maxEntries) {
index, pHisto->maxEntries)) { qError("histogramCreateBin Error, index:%d, maxEntries:%d", index, pHisto->maxEntries);
return TSDB_CODE_FAILED; return TSDB_CODE_FUNC_HISTOGRAM_ERROR;
} }
pHisto->elems[index].num = 1; pHisto->elems[index].num = 1;
@ -373,9 +373,9 @@ int32_t histogramCreateBin(SHistogramInfo* pHisto, int32_t index, double val) {
pHisto->elems[pHisto->maxEntries].num = 0; pHisto->elems[pHisto->maxEntries].num = 0;
} }
#endif #endif
if (ASSERTS(pHisto->numOfEntries <= pHisto->maxEntries, "histogramCreateBin Error, numOfEntries:%d, maxEntries:%d", if (pHisto->numOfEntries > pHisto->maxEntries) {
pHisto->numOfEntries, pHisto->maxEntries)) { qError("histogramCreateBin Error, numOfEntries:%d, maxEntries:%d", pHisto->numOfEntries, pHisto->maxEntries);
return TSDB_CODE_FAILED; return TSDB_CODE_FUNC_HISTOGRAM_ERROR;
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
@ -411,8 +411,9 @@ void tHistogramPrint(SHistogramInfo* pHisto) {
* Estimated number of points in the interval (inf,b]. * Estimated number of points in the interval (inf,b].
* @param pHisto * @param pHisto
* @param v * @param v
* @param res
*/ */
int64_t tHistogramSum(SHistogramInfo* pHisto, double v) { int32_t tHistogramSum(SHistogramInfo* pHisto, double v, int64_t *res) {
#if defined(USE_ARRAYLIST) #if defined(USE_ARRAYLIST)
int32_t slotIdx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, v); int32_t slotIdx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, v);
if (pHisto->elems[slotIdx].val != v) { if (pHisto->elems[slotIdx].val != v) {
@ -420,14 +421,18 @@ int64_t tHistogramSum(SHistogramInfo* pHisto, double v) {
if (slotIdx < 0) { if (slotIdx < 0) {
slotIdx = 0; slotIdx = 0;
ASSERTS(v <= pHisto->elems[slotIdx].val, "tHistogramSum Error, elems[%d].val:%lf, v:%lf", if (v > pHisto->elems[slotIdx].val) {
slotIdx, pHisto->elems[slotIdx].val, v); qError("tHistogramSum Error, elems[%d].val:%lf, v:%lf", slotIdx, pHisto->elems[slotIdx].val, v);
return TSDB_CODE_FUNC_HISTOGRAM_ERROR;
}
} else { } else {
ASSERTS(v >= pHisto->elems[slotIdx].val, "tHistogramSum Error, elems[%d].val:%lf, v:%lf", if (v < pHisto->elems[slotIdx].val) {
slotIdx, pHisto->elems[slotIdx].val, v); qError("tHistogramSum Error, elems[%d].val:%lf, v:%lf", slotIdx, pHisto->elems[slotIdx].val, v);
if (slotIdx + 1 < pHisto->numOfEntries) { return TSDB_CODE_FUNC_HISTOGRAM_ERROR;
ASSERTS(v < pHisto->elems[slotIdx + 1].val, "tHistogramSum Error, elems[%d].val:%lf, v:%lf", }
slotIdx + 1, pHisto->elems[slotIdx + 1].val, v); if (slotIdx + 1 < pHisto->numOfEntries && v >= pHisto->elems[slotIdx + 1].val) {
qError("tHistogramSum Error, elems[%d].val:%lf, v:%lf", slotIdx + 1, pHisto->elems[slotIdx + 1].val, v);
return TSDB_CODE_FUNC_HISTOGRAM_ERROR;
} }
} }
} }
@ -447,8 +452,9 @@ int64_t tHistogramSum(SHistogramInfo* pHisto, double v) {
s1 = s1 + m1 / 2; s1 = s1 + m1 / 2;
return (int64_t)s1; *res = (int64_t)s1;
#endif #endif
return TSDB_CODE_SUCCESS;
} }
int32_t tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num, double** pVal) { int32_t tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num, double** pVal) {
@ -484,9 +490,11 @@ int32_t tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num, do
j += 1; j += 1;
} }
ASSERTS(total <= numOfElem && total + pHisto->elems[j + 1].num > numOfElem, if (total > numOfElem || total + pHisto->elems[j + 1].num <= numOfElem) {
"tHistogramUniform Error, total:%ld, numOfElem:%ld, elems[%d].num:%ld", qError("tHistogramUniform Error, total:%d, numOfElem:%d, elems[%d].num:%d",
total, (int64_t)numOfElem, j + 1, pHisto->elems[j + 1].num); (int32_t)total, (int32_t)numOfElem, j + 1, (int32_t)pHisto->elems[j + 1].num);
return TSDB_CODE_FUNC_HISTOGRAM_ERROR;
}
double delta = numOfElem - total; double delta = numOfElem - total;
if (fabs(delta) < FLT_EPSILON) { if (fabs(delta) < FLT_EPSILON) {
@ -545,9 +553,10 @@ int32_t tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num, do
j += 1; j += 1;
} }
ASSERTS(total <= numOfElem && total + pEntry->num > numOfElem, if (total > numOfElem || total + pEntry->num <= numOfElem) {
"tHistogramUniform Error, total:%d, numOfElem:%d, pEntry->num:%d", qError("tHistogramUniform Error, total:%d, numOfElem:%d, pEntry->num:%d", (int32_t)total, (int32_t)numOfElem, (int32_t)pEntry->num);
total, numOfElem, pEntry->num); return TSDB_CODE_FUNC_HISTOGRAM_ERROR;
}
double delta = numOfElem - total; double delta = numOfElem - total;
if (fabs(delta) < FLT_EPSILON) { if (fabs(delta) < FLT_EPSILON) {

View File

@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "query.h"
#include "taoserror.h" #include "taoserror.h"
#include "tcompare.h" #include "tcompare.h"
#include "tglobal.h" #include "tglobal.h"
@ -107,7 +108,10 @@ static void resetPosInfo(SSlotInfo *pInfo) {
} }
int32_t findOnlyResult(tMemBucket *pMemBucket, double *result) { int32_t findOnlyResult(tMemBucket *pMemBucket, double *result) {
ASSERT(pMemBucket->total == 1); if (pMemBucket->total != 1) {
qError("MemBucket:%p, total:%d, but only one element is expected", pMemBucket, pMemBucket->total);
return TSDB_CODE_FUNC_PERCENTILE_ERROR;
}
terrno = 0; terrno = 0;
for (int32_t i = 0; i < pMemBucket->numOfSlots; ++i) { for (int32_t i = 0; i < pMemBucket->numOfSlots; ++i) {
@ -120,7 +124,10 @@ int32_t findOnlyResult(tMemBucket *pMemBucket, double *result) {
SArray **pList = taosHashGet(pMemBucket->groupPagesMap, &groupId, sizeof(groupId)); SArray **pList = taosHashGet(pMemBucket->groupPagesMap, &groupId, sizeof(groupId));
if (pList != NULL) { if (pList != NULL) {
SArray *list = *pList; SArray *list = *pList;
ASSERT(list->size == 1); if (list->size != 1) {
qError("list:%p, total list size:%zu, but only one element is expected", list, list->size);
return TSDB_CODE_FUNC_PERCENTILE_ERROR;
}
int32_t *pageId = taosArrayGet(list, 0); int32_t *pageId = taosArrayGet(list, 0);
if (NULL == pageId) { if (NULL == pageId) {
@ -130,7 +137,11 @@ int32_t findOnlyResult(tMemBucket *pMemBucket, double *result) {
if (pPage == NULL) { if (pPage == NULL) {
return terrno; return terrno;
} }
ASSERT(pPage->num == 1); if (pPage->num != 1) {
qError("page:%p, total num:%d, but only one element is expected", pPage, pPage->num);
releaseBufPage(pMemBucket->pBuffer, pPage);
return TSDB_CODE_FUNC_PERCENTILE_ERROR;
}
GET_TYPED_DATA(*result, double, pMemBucket->type, pPage->data); GET_TYPED_DATA(*result, double, pMemBucket->type, pPage->data);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
@ -141,64 +152,69 @@ int32_t findOnlyResult(tMemBucket *pMemBucket, double *result) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t tBucketIntHash(tMemBucket *pBucket, const void *value) { int32_t tBucketIntHash(tMemBucket *pBucket, const void *value, int32_t *index) {
int64_t v = 0; int64_t v = 0;
GET_TYPED_DATA(v, int64_t, pBucket->type, value); GET_TYPED_DATA(v, int64_t, pBucket->type, value);
int32_t index = -1; *index = -1;
if (v > pBucket->range.dMaxVal || v < pBucket->range.dMinVal) { if (v > pBucket->range.dMaxVal || v < pBucket->range.dMinVal) {
return index; return TSDB_CODE_SUCCESS;
} }
// divide the value range into 1024 buckets // divide the value range into 1024 buckets
uint64_t span = pBucket->range.dMaxVal - pBucket->range.dMinVal; uint64_t span = pBucket->range.dMaxVal - pBucket->range.dMinVal;
if (span < pBucket->numOfSlots) { if (span < pBucket->numOfSlots) {
int64_t delta = v - pBucket->range.dMinVal; int64_t delta = v - pBucket->range.dMinVal;
index = (delta % pBucket->numOfSlots); *index = (delta % pBucket->numOfSlots);
} else { } else {
double slotSpan = ((double)span) / pBucket->numOfSlots; double slotSpan = ((double)span) / pBucket->numOfSlots;
uint64_t delta = (uint64_t)(v - pBucket->range.dMinVal); uint64_t delta = (uint64_t)(v - pBucket->range.dMinVal);
index = delta / slotSpan; *index = delta / slotSpan;
if (v == pBucket->range.dMaxVal || index == pBucket->numOfSlots) { if (v == pBucket->range.dMaxVal || *index == pBucket->numOfSlots) {
index -= 1; *index -= 1;
} }
} }
ASSERTS(index >= 0 && index < pBucket->numOfSlots, "tBucketIntHash Error, index:%d, numOfSlots:%d", if (*index < 0 || *index >= pBucket->numOfSlots) {
index, pBucket->numOfSlots); qError("tBucketIntHash Error, index:%d, numOfSlots:%d", *index, pBucket->numOfSlots);
return index; return TSDB_CODE_FUNC_PERCENTILE_ERROR;
}
return TSDB_CODE_SUCCESS;
} }
int32_t tBucketUintHash(tMemBucket *pBucket, const void *value) { int32_t tBucketUintHash(tMemBucket *pBucket, const void *value, int32_t *index) {
int64_t v = 0; int64_t v = 0;
GET_TYPED_DATA(v, uint64_t, pBucket->type, value); GET_TYPED_DATA(v, uint64_t, pBucket->type, value);
int32_t index = -1; *index = -1;
if (v > pBucket->range.u64MaxVal || v < pBucket->range.u64MinVal) { if (v > pBucket->range.u64MaxVal || v < pBucket->range.u64MinVal) {
return index; return TSDB_CODE_SUCCESS;
} }
// divide the value range into 1024 buckets // divide the value range into 1024 buckets
uint64_t span = pBucket->range.u64MaxVal - pBucket->range.u64MinVal; uint64_t span = pBucket->range.u64MaxVal - pBucket->range.u64MinVal;
if (span < pBucket->numOfSlots) { if (span < pBucket->numOfSlots) {
int64_t delta = v - pBucket->range.u64MinVal; int64_t delta = v - pBucket->range.u64MinVal;
index = (int32_t)(delta % pBucket->numOfSlots); *index = (int32_t)(delta % pBucket->numOfSlots);
} else { } else {
double slotSpan = (double)span / pBucket->numOfSlots; double slotSpan = (double)span / pBucket->numOfSlots;
index = (int32_t)((v - pBucket->range.u64MinVal) / slotSpan); *index = (int32_t)((v - pBucket->range.u64MinVal) / slotSpan);
if (v == pBucket->range.u64MaxVal) { if (v == pBucket->range.u64MaxVal) {
index -= 1; *index -= 1;
} }
} }
ASSERT(index >= 0 && index < pBucket->numOfSlots); if (*index < 0 || *index >= pBucket->numOfSlots) {
return index; qError("tBucketUintHash Error, index:%d, numOfSlots:%d", *index, pBucket->numOfSlots);
return TSDB_CODE_FUNC_PERCENTILE_ERROR;
}
return TSDB_CODE_SUCCESS;
} }
int32_t tBucketDoubleHash(tMemBucket *pBucket, const void *value) { int32_t tBucketDoubleHash(tMemBucket *pBucket, const void *value, int32_t *index) {
double v = 0; double v = 0;
if (pBucket->type == TSDB_DATA_TYPE_FLOAT) { if (pBucket->type == TSDB_DATA_TYPE_FLOAT) {
v = GET_FLOAT_VAL(value); v = GET_FLOAT_VAL(value);
@ -206,27 +222,30 @@ int32_t tBucketDoubleHash(tMemBucket *pBucket, const void *value) {
v = GET_DOUBLE_VAL(value); v = GET_DOUBLE_VAL(value);
} }
int32_t index = -1; *index = -1;
if (v > pBucket->range.dMaxVal || v < pBucket->range.dMinVal) { if (v > pBucket->range.dMaxVal || v < pBucket->range.dMinVal) {
return index; return TSDB_CODE_SUCCESS;
} }
// divide a range of [dMinVal, dMaxVal] into 1024 buckets // divide a range of [dMinVal, dMaxVal] into 1024 buckets
double span = pBucket->range.dMaxVal - pBucket->range.dMinVal; double span = pBucket->range.dMaxVal - pBucket->range.dMinVal;
if (span < pBucket->numOfSlots) { if (span < pBucket->numOfSlots) {
int32_t delta = (int32_t)(v - pBucket->range.dMinVal); int32_t delta = (int32_t)(v - pBucket->range.dMinVal);
index = (delta % pBucket->numOfSlots); *index = (delta % pBucket->numOfSlots);
} else { } else {
double slotSpan = span / pBucket->numOfSlots; double slotSpan = span / pBucket->numOfSlots;
index = (int32_t)((v - pBucket->range.dMinVal) / slotSpan); *index = (int32_t)((v - pBucket->range.dMinVal) / slotSpan);
if (v == pBucket->range.dMaxVal) { if (v == pBucket->range.dMaxVal) {
index -= 1; *index -= 1;
} }
} }
ASSERT(index >= 0 && index < pBucket->numOfSlots); if (*index < 0 || *index >= pBucket->numOfSlots) {
return index; qError("tBucketDoubleHash Error, index:%d, numOfSlots:%d", *index, pBucket->numOfSlots);
return TSDB_CODE_FUNC_PERCENTILE_ERROR;
}
return TSDB_CODE_SUCCESS;
} }
static __perc_hash_func_t getHashFunc(int32_t type) { static __perc_hash_func_t getHashFunc(int32_t type) {
@ -333,7 +352,7 @@ void tMemBucketDestroy(tMemBucket *pBucket) {
taosMemoryFreeClear(pBucket); taosMemoryFreeClear(pBucket);
} }
void tMemBucketUpdateBoundingBox(MinMaxEntry *r, const char *data, int32_t dataType) { int32_t tMemBucketUpdateBoundingBox(MinMaxEntry *r, const char *data, int32_t dataType) {
if (IS_SIGNED_NUMERIC_TYPE(dataType)) { if (IS_SIGNED_NUMERIC_TYPE(dataType)) {
int64_t v = 0; int64_t v = 0;
GET_TYPED_DATA(v, int64_t, dataType, data); GET_TYPED_DATA(v, int64_t, dataType, data);
@ -368,8 +387,10 @@ void tMemBucketUpdateBoundingBox(MinMaxEntry *r, const char *data, int32_t dataT
r->dMaxVal = v; r->dMaxVal = v;
} }
} else { } else {
ASSERT(0); qError("tMemBucketUpdateBoundingBox Error, invalid data type:%d", dataType);
return TSDB_CODE_FUNC_PERCENTILE_ERROR;
} }
return TSDB_CODE_SUCCESS;
} }
/* /*
@ -378,9 +399,14 @@ void tMemBucketUpdateBoundingBox(MinMaxEntry *r, const char *data, int32_t dataT
int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) { int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
int32_t count = 0; int32_t count = 0;
int32_t bytes = pBucket->bytes; int32_t bytes = pBucket->bytes;
int32_t code = TSDB_CODE_SUCCESS;
for (int32_t i = 0; i < size; ++i) { for (int32_t i = 0; i < size; ++i) {
char *d = (char *)data + i * bytes; char *d = (char *)data + i * bytes;
int32_t index = (pBucket->hashFunc)(pBucket, d); int32_t index = -1;
code = (pBucket->hashFunc)(pBucket, d, &index);
if (TSDB_CODE_SUCCESS != code) {
return code;
}
if (index < 0) { if (index < 0) {
continue; continue;
} }
@ -388,7 +414,10 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
count += 1; count += 1;
tMemBucketSlot *pSlot = &pBucket->pSlots[index]; tMemBucketSlot *pSlot = &pBucket->pSlots[index];
tMemBucketUpdateBoundingBox(&pSlot->range, d, pBucket->type); code = tMemBucketUpdateBoundingBox(&pSlot->range, d, pBucket->type);
if (TSDB_CODE_SUCCESS != code) {
return code;
}
// ensure available memory pages to allocate // ensure available memory pages to allocate
int32_t groupId = getGroupId(pBucket->numOfSlots, index, pBucket->times); int32_t groupId = getGroupId(pBucket->numOfSlots, index, pBucket->times);
@ -396,7 +425,11 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
if (pSlot->info.data == NULL || pSlot->info.data->num >= pBucket->elemPerPage) { if (pSlot->info.data == NULL || pSlot->info.data->num >= pBucket->elemPerPage) {
if (pSlot->info.data != NULL) { if (pSlot->info.data != NULL) {
ASSERT(pSlot->info.data->num >= pBucket->elemPerPage && pSlot->info.size > 0); if (pSlot->info.data->num < pBucket->elemPerPage || pSlot->info.size <= 0) {
qError("tMemBucketPut failed since wrong pSLot info dataNum : %d, size : %d",
pSlot->info.data->num, pSlot->info.size);
return TSDB_CODE_FUNC_PERCENTILE_ERROR;
}
// keep the pointer in memory // keep the pointer in memory
setBufPageDirty(pSlot->info.data, true); setBufPageDirty(pSlot->info.data, true);
@ -411,7 +444,7 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
if (NULL == pPageIdList) { if (NULL == pPageIdList) {
return terrno; return terrno;
} }
int32_t code = taosHashPut(pBucket->groupPagesMap, &groupId, sizeof(groupId), &pPageIdList, POINTER_BYTES); code = taosHashPut(pBucket->groupPagesMap, &groupId, sizeof(groupId), &pPageIdList, POINTER_BYTES);
if (TSDB_CODE_SUCCESS != code) { if (TSDB_CODE_SUCCESS != code) {
taosArrayDestroy(pPageIdList); taosArrayDestroy(pPageIdList);
return code; return code;
@ -449,21 +482,23 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
* j is the last slot of current segment, we need to get the first * j is the last slot of current segment, we need to get the first
* slot of the next segment. * slot of the next segment.
*/ */
static MinMaxEntry getMinMaxEntryOfNextSlotWithData(tMemBucket *pMemBucket, int32_t slotIdx) { static int32_t getMinMaxEntryOfNextSlotWithData(tMemBucket *pMemBucket, int32_t slotIdx, MinMaxEntry *next) {
int32_t j = slotIdx + 1; int32_t j = slotIdx + 1;
while (j < pMemBucket->numOfSlots && (pMemBucket->pSlots[j].info.size == 0)) { while (j < pMemBucket->numOfSlots && (pMemBucket->pSlots[j].info.size == 0)) {
++j; ++j;
} }
ASSERT(j < pMemBucket->numOfSlots); if (j >= pMemBucket->numOfSlots) {
return pMemBucket->pSlots[j].range; qError("getMinMaxEntryOfNextSlotWithData can not get valid slot, start with slotIdx:%d", slotIdx);
return TSDB_CODE_FUNC_PERCENTILE_ERROR;
}
*next = pMemBucket->pSlots[j].range;
return TSDB_CODE_SUCCESS;
} }
static bool isIdenticalData(tMemBucket *pMemBucket, int32_t index); static bool isIdenticalData(tMemBucket *pMemBucket, int32_t index);
static double getIdenticalDataVal(tMemBucket *pMemBucket, int32_t slotIndex) { static double getIdenticalDataVal(tMemBucket *pMemBucket, int32_t slotIndex) {
ASSERT(isIdenticalData(pMemBucket, slotIndex));
tMemBucketSlot *pSlot = &pMemBucket->pSlots[slotIndex]; tMemBucketSlot *pSlot = &pMemBucket->pSlots[slotIndex];
double finalResult = 0.0; double finalResult = 0.0;
@ -494,7 +529,11 @@ int32_t getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction
* now, we need to find the minimum value of the next slot for interpolating the percentile value * now, we need to find the minimum value of the next slot for interpolating the percentile value
* j is the last slot of current segment, we need to get the first slot of the next segment. * j is the last slot of current segment, we need to get the first slot of the next segment.
*/ */
MinMaxEntry next = getMinMaxEntryOfNextSlotWithData(pMemBucket, i); MinMaxEntry next;
int32_t code = getMinMaxEntryOfNextSlotWithData(pMemBucket, i, &next);
if (TSDB_CODE_SUCCESS != code) {
return code;
}
double maxOfThisSlot = 0; double maxOfThisSlot = 0;
double minOfNextSlot = 0; double minOfNextSlot = 0;
@ -509,7 +548,10 @@ int32_t getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction
minOfNextSlot = (double)next.dMinVal; minOfNextSlot = (double)next.dMinVal;
} }
ASSERT(minOfNextSlot > maxOfThisSlot); if (minOfNextSlot <= maxOfThisSlot) {
qError("getPercentileImpl get minOfNextSlot : %f less equal than maxOfThisSlot : %f", minOfNextSlot, maxOfThisSlot);
return TSDB_CODE_FUNC_PERCENTILE_ERROR;
}
*result = (1 - fraction) * maxOfThisSlot + fraction * minOfNextSlot; *result = (1 - fraction) * maxOfThisSlot + fraction * minOfNextSlot;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;

View File

@ -796,9 +796,14 @@ void *decodeUdfResponse(const void *buf, SUdfResponse *rsp) {
buf = decodeUdfTeardownResponse(buf, &rsp->teardownRsp); buf = decodeUdfTeardownResponse(buf, &rsp->teardownRsp);
break; break;
default: default:
rsp->code = TSDB_CODE_UDF_INTERNAL_ERROR;
fnError("decode udf response, invalid udf response type %d", rsp->type); fnError("decode udf response, invalid udf response type %d", rsp->type);
break; break;
} }
if(buf == NULL) {
rsp->code = terrno;
fnError("decode udf response failed, code:0x%x", rsp->code);
}
return (void *)buf; return (void *)buf;
} }

View File

@ -131,12 +131,12 @@ _exit:
int32_t executeMakePointFunc(SColumnInfoData *pInputData[], int32_t iLeft, int32_t iRight, int32_t executeMakePointFunc(SColumnInfoData *pInputData[], int32_t iLeft, int32_t iRight,
SColumnInfoData *pOutputData) { SColumnInfoData *pOutputData) {
int32_t code = TSDB_CODE_FAILED; int32_t code = TSDB_CODE_FAILED;
unsigned char *output = NULL;
_getDoubleValue_fn_t getDoubleValueFn[2]; _getDoubleValue_fn_t getDoubleValueFn[2];
getDoubleValueFn[0] = getVectorDoubleValueFn(pInputData[0]->info.type); TAOS_CHECK_GOTO(getVectorDoubleValueFn(pInputData[0]->info.type, &getDoubleValueFn[0]), NULL, _exit);
getDoubleValueFn[1] = getVectorDoubleValueFn(pInputData[1]->info.type); TAOS_CHECK_GOTO(getVectorDoubleValueFn(pInputData[1]->info.type, &getDoubleValueFn[1]), NULL, _exit);
unsigned char *output = NULL;
double leftRes = 0; double leftRes = 0;
double rightRes = 0; double rightRes = 0;

View File

@ -74,7 +74,7 @@ void indexCleanup() {
// refacto later // refacto later
taosCleanUpScheduler(indexQhandle); taosCleanUpScheduler(indexQhandle);
taosMemoryFreeClear(indexQhandle); taosMemoryFreeClear(indexQhandle);
(void)taosCloseRef(indexRefMgt); taosCloseRef(indexRefMgt);
} }
typedef struct SIdxColInfo { typedef struct SIdxColInfo {

View File

@ -238,7 +238,7 @@ void nodesDestroyAllocatorSet() {
(void)taosRemoveRef(g_allocatorReqRefPool, refId); (void)taosRemoveRef(g_allocatorReqRefPool, refId);
pAllocator = taosIterateRef(g_allocatorReqRefPool, refId); pAllocator = taosIterateRef(g_allocatorReqRefPool, refId);
} }
(void)taosCloseRef(g_allocatorReqRefPool); taosCloseRef(g_allocatorReqRefPool);
} }
} }

View File

@ -12628,6 +12628,27 @@ static int32_t createParOperatorNode(EOperatorType opType, const char* pLeftCol,
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static int32_t createIsOperatorNode(EOperatorType opType, const char* pColName, SNode** pOp) {
SOperatorNode* pOper = NULL;
int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOper);
if (NULL == pOper) {
return code;
}
pOper->opType = opType;
code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pOper->pLeft);
if (TSDB_CODE_SUCCESS != code) {
nodesDestroyNode((SNode*)pOper);
return code;
}
pOper->pRight = NULL;
snprintf(((SColumnNode*)pOper->pLeft)->colName, sizeof(((SColumnNode*)pOper->pLeft)->colName), "%s", pColName);
*pOp = (SNode*)pOper;
return TSDB_CODE_SUCCESS;
}
static const char* getTbNameColName(ENodeType type) { static const char* getTbNameColName(ENodeType type) {
const char* colName; const char* colName;
switch (type) { switch (type) {
@ -15035,7 +15056,7 @@ static int32_t rewriteShowAliveStmt(STranslateContext* pCxt, SQuery* pQuery) {
// pWhenThenlist and pElse need to free // pWhenThenlist and pElse need to free
// case when (v1_status = "leader" or v2_status = "lead er" or v3_status = "leader" or v4_status = "leader") then 1 // case when (v1_status = "leader" or v2_status = "leader" or v3_status = "leader" or v4_status = "leader") then 1
// else 0 end // else 0 end
SNode* pCaseWhen = NULL; SNode* pCaseWhen = NULL;
code = createParCaseWhenNode(NULL, pWhenThenlist, pElse, NULL, &pCaseWhen); code = createParCaseWhenNode(NULL, pWhenThenlist, pElse, NULL, &pCaseWhen);
@ -15190,23 +15211,42 @@ static int32_t rewriteShowAliveStmt(STranslateContext* pCxt, SQuery* pQuery) {
return code; return code;
} }
// pSubSelect, pTemp1, pTempVal need to free SNode* pCondIsNULL = NULL;
code = createIsOperatorNode(OP_TYPE_IS_NULL, pSumColAlias, &pCondIsNULL);
pThen = NULL;
code = nodesMakeValueNodeFromInt32(1, &pThen);
if (TSDB_CODE_SUCCESS != code) { if (TSDB_CODE_SUCCESS != code) {
nodesDestroyNode((SNode*)pSubSelect); nodesDestroyNode((SNode*)pSubSelect);
nodesDestroyNode(pTemp1); nodesDestroyNode(pTemp1);
nodesDestroyNode(pTempVal); nodesDestroyNode(pTempVal);
return code; return code;
} }
// pSubSelect, pTemp1, pThen, pTempVal need to free
pWhenThen = NULL; SNode* pCondFull1 = NULL;
code = createParWhenThenNode(pTemp1, pThen, &pWhenThen); code = createLogicCondNode(&pTemp1, &pCondIsNULL, &pCondFull1, LOGIC_COND_TYPE_OR);
if (TSDB_CODE_SUCCESS != code) { if (TSDB_CODE_SUCCESS != code) {
nodesDestroyNode((SNode*)pSubSelect); nodesDestroyNode((SNode*)pSubSelect);
nodesDestroyNode(pTemp1); nodesDestroyNode(pTemp1);
nodesDestroyNode(pTempVal);
nodesDestroyNode(pCondIsNULL);
return code;
}
// pSubSelect, pCondFull1, pTempVal need to free
pThen = NULL;
code = nodesMakeValueNodeFromInt32(1, &pThen);
if (TSDB_CODE_SUCCESS != code) {
nodesDestroyNode((SNode*)pSubSelect);
nodesDestroyNode(pCondFull1);
nodesDestroyNode(pTempVal);
return code;
}
// pSubSelect, pCondFull1, pThen, pTempVal need to free
pWhenThen = NULL;
code = createParWhenThenNode(pCondFull1, pThen, &pWhenThen);
if (TSDB_CODE_SUCCESS != code) {
nodesDestroyNode((SNode*)pSubSelect);
nodesDestroyNode(pCondFull1);
nodesDestroyNode(pThen); nodesDestroyNode(pThen);
nodesDestroyNode(pTempVal); nodesDestroyNode(pTempVal);
return code; return code;
@ -15289,7 +15329,7 @@ static int32_t rewriteShowAliveStmt(STranslateContext* pCxt, SQuery* pQuery) {
} }
// pSubSelect, pWhenThenlist need to free // pSubSelect, pWhenThenlist need to free
// case when leader_col = count_col and count_col > 0 then 1 when leader_col < count_col and count_col > 0 then 2 else // case when leader_col = count_col and leader_col > 0 then 1 when leader_col < count_col and leader_col > 0 then 2 else
// 0 end as status // 0 end as status
pElse = NULL; pElse = NULL;
code = nodesMakeValueNodeFromInt32(0, &pElse); code = nodesMakeValueNodeFromInt32(0, &pElse);

View File

@ -564,7 +564,7 @@ int32_t qwSaveTbVersionInfo(qTaskInfo_t pTaskInfo, SQWTaskCtx *ctx) {
void qwCloseRef(void) { void qwCloseRef(void) {
taosWLockLatch(&gQwMgmt.lock); taosWLockLatch(&gQwMgmt.lock);
if (atomic_load_32(&gQwMgmt.qwNum) <= 0 && gQwMgmt.qwRef >= 0) { if (atomic_load_32(&gQwMgmt.qwNum) <= 0 && gQwMgmt.qwRef >= 0) {
(void)taosCloseRef(gQwMgmt.qwRef); // ignore error taosCloseRef(gQwMgmt.qwRef); // ignore error
gQwMgmt.qwRef = -1; gQwMgmt.qwRef = -1;
} }
taosWUnLockLatch(&gQwMgmt.lock); taosWUnLockLatch(&gQwMgmt.lock);

View File

@ -78,40 +78,41 @@ static FORCE_INLINE int32_t getVectorDoubleValue_BOOL(void *src, int32_t index,
int32_t getVectorDoubleValue_JSON(void *src, int32_t index, double *out); int32_t getVectorDoubleValue_JSON(void *src, int32_t index, double *out);
static FORCE_INLINE _getDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType) { static FORCE_INLINE int32_t getVectorDoubleValueFn(int32_t srcType, _getDoubleValue_fn_t *p) {
_getDoubleValue_fn_t p = NULL; *p = NULL;
if (srcType == TSDB_DATA_TYPE_TINYINT) { if (srcType == TSDB_DATA_TYPE_TINYINT) {
p = getVectorDoubleValue_TINYINT; *p = getVectorDoubleValue_TINYINT;
} else if (srcType == TSDB_DATA_TYPE_UTINYINT) { } else if (srcType == TSDB_DATA_TYPE_UTINYINT) {
p = getVectorDoubleValue_UTINYINT; *p = getVectorDoubleValue_UTINYINT;
} else if (srcType == TSDB_DATA_TYPE_SMALLINT) { } else if (srcType == TSDB_DATA_TYPE_SMALLINT) {
p = getVectorDoubleValue_SMALLINT; *p = getVectorDoubleValue_SMALLINT;
} else if (srcType == TSDB_DATA_TYPE_USMALLINT) { } else if (srcType == TSDB_DATA_TYPE_USMALLINT) {
p = getVectorDoubleValue_USMALLINT; *p = getVectorDoubleValue_USMALLINT;
} else if (srcType == TSDB_DATA_TYPE_INT) { } else if (srcType == TSDB_DATA_TYPE_INT) {
p = getVectorDoubleValue_INT; *p = getVectorDoubleValue_INT;
} else if (srcType == TSDB_DATA_TYPE_UINT) { } else if (srcType == TSDB_DATA_TYPE_UINT) {
p = getVectorDoubleValue_UINT; *p = getVectorDoubleValue_UINT;
} else if (srcType == TSDB_DATA_TYPE_BIGINT) { } else if (srcType == TSDB_DATA_TYPE_BIGINT) {
p = getVectorDoubleValue_BIGINT; *p = getVectorDoubleValue_BIGINT;
} else if (srcType == TSDB_DATA_TYPE_UBIGINT) { } else if (srcType == TSDB_DATA_TYPE_UBIGINT) {
p = getVectorDoubleValue_UBIGINT; *p = getVectorDoubleValue_UBIGINT;
} else if (srcType == TSDB_DATA_TYPE_FLOAT) { } else if (srcType == TSDB_DATA_TYPE_FLOAT) {
p = getVectorDoubleValue_FLOAT; *p = getVectorDoubleValue_FLOAT;
} else if (srcType == TSDB_DATA_TYPE_DOUBLE) { } else if (srcType == TSDB_DATA_TYPE_DOUBLE) {
p = getVectorDoubleValue_DOUBLE; *p = getVectorDoubleValue_DOUBLE;
} else if (srcType == TSDB_DATA_TYPE_TIMESTAMP) { } else if (srcType == TSDB_DATA_TYPE_TIMESTAMP) {
p = getVectorDoubleValue_BIGINT; *p = getVectorDoubleValue_BIGINT;
} else if (srcType == TSDB_DATA_TYPE_JSON) { } else if (srcType == TSDB_DATA_TYPE_JSON) {
p = getVectorDoubleValue_JSON; *p = getVectorDoubleValue_JSON;
} else if (srcType == TSDB_DATA_TYPE_BOOL) { } else if (srcType == TSDB_DATA_TYPE_BOOL) {
p = getVectorDoubleValue_BOOL; *p = getVectorDoubleValue_BOOL;
} else if (srcType == TSDB_DATA_TYPE_NULL) { } else if (srcType == TSDB_DATA_TYPE_NULL) {
p = NULL; *p = NULL;
} else { } else {
ASSERT(0); *p = NULL;
return TSDB_CODE_SCALAR_CONVERT_ERROR;
} }
return p; return TSDB_CODE_SUCCESS;
} }
typedef int32_t (*_bufConverteFunc)(char *buf, SScalarParam *pOut, int32_t outType, int32_t *overflow); typedef int32_t (*_bufConverteFunc)(char *buf, SScalarParam *pOut, int32_t outType, int32_t *overflow);

View File

@ -92,7 +92,9 @@ rangeCompFunc gRangeCompare[] = {filterRangeCompee, filterRangeCompei, filterRan
int8_t filterGetRangeCompFuncFromOptrs(uint8_t optr, uint8_t optr2) { int8_t filterGetRangeCompFuncFromOptrs(uint8_t optr, uint8_t optr2) {
if (optr2) { if (optr2) {
ASSERT(optr2 == OP_TYPE_LOWER_THAN || optr2 == OP_TYPE_LOWER_EQUAL); if (optr2 != OP_TYPE_LOWER_THAN && optr2 != OP_TYPE_LOWER_EQUAL) {
return -1;
}
if (optr == OP_TYPE_GREATER_THAN) { if (optr == OP_TYPE_GREATER_THAN) {
if (optr2 == OP_TYPE_LOWER_THAN) { if (optr2 == OP_TYPE_LOWER_THAN) {
@ -763,7 +765,10 @@ int32_t filterAddRangeCtx(void *dst, void *src, int32_t optr) {
SFilterRangeCtx *dctx = (SFilterRangeCtx *)dst; SFilterRangeCtx *dctx = (SFilterRangeCtx *)dst;
SFilterRangeCtx *sctx = (SFilterRangeCtx *)src; SFilterRangeCtx *sctx = (SFilterRangeCtx *)src;
ASSERT(optr == LOGIC_COND_TYPE_OR); if (optr != LOGIC_COND_TYPE_OR) {
fltError("filterAddRangeCtx get invalid optr:%d", optr);
return TSDB_CODE_QRY_FILTER_WRONG_OPTR_TYPE;
}
if (sctx->rs == NULL) { if (sctx->rs == NULL) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
@ -1204,7 +1209,10 @@ int32_t filterAddUnitImpl(SFilterInfo *info, uint8_t optr, SFilterFieldId *left,
if (u->right.type == FLD_TYPE_VALUE) { if (u->right.type == FLD_TYPE_VALUE) {
SFilterField *val = FILTER_UNIT_RIGHT_FIELD(info, u); SFilterField *val = FILTER_UNIT_RIGHT_FIELD(info, u);
ASSERT(FILTER_GET_FLAG(val->flag, FLD_TYPE_VALUE)); if (!FILTER_GET_FLAG(val->flag, FLD_TYPE_VALUE)) {
fltError("filterAddUnitImpl get invalid flag : %d in val", val->flag);
return TSDB_CODE_APP_ERROR;
}
} else { } else {
int32_t paramNum = scalarGetOperatorParamNum(optr); int32_t paramNum = scalarGetOperatorParamNum(optr);
if (1 != paramNum) { if (1 != paramNum) {
@ -1214,7 +1222,10 @@ int32_t filterAddUnitImpl(SFilterInfo *info, uint8_t optr, SFilterFieldId *left,
} }
SFilterField *col = FILTER_UNIT_LEFT_FIELD(info, u); SFilterField *col = FILTER_UNIT_LEFT_FIELD(info, u);
ASSERT(FILTER_GET_FLAG(col->flag, FLD_TYPE_COLUMN)); if (!FILTER_GET_FLAG(col->flag, FLD_TYPE_COLUMN)) {
fltError("filterAddUnitImpl get invalid flag : %d in col", col->flag);
return TSDB_CODE_APP_ERROR;
}
info->units[info->unitNum].compare.type = FILTER_GET_COL_FIELD_TYPE(col); info->units[info->unitNum].compare.type = FILTER_GET_COL_FIELD_TYPE(col);
info->units[info->unitNum].compare.precision = FILTER_GET_COL_FIELD_PRECISION(col); info->units[info->unitNum].compare.precision = FILTER_GET_COL_FIELD_PRECISION(col);
@ -1398,29 +1409,48 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
if (optr == LOGIC_COND_TYPE_AND) { if (optr == LOGIC_COND_TYPE_AND) {
if (ctx->isnull) { if (ctx->isnull) {
ASSERT(ctx->notnull == false && ctx->isrange == false); if (ctx->notnull || ctx->isrange) {
fltError("filterAddGroupUnitFromCtx get invalid ctx : isnull %d, notnull %d, isrange %d",
ctx->isnull, ctx->notnull, ctx->isrange);
FLT_ERR_RET(TSDB_CODE_QRY_FILTER_RANGE_ERROR);
}
FLT_ERR_RET(filterAddUnit(dst, OP_TYPE_IS_NULL, &left, NULL, &uidx)); FLT_ERR_RET(filterAddUnit(dst, OP_TYPE_IS_NULL, &left, NULL, &uidx));
FLT_ERR_RET(filterAddUnitToGroup(g, uidx)); FLT_ERR_RET(filterAddUnitToGroup(g, uidx));
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
if (ctx->notnull) { if (ctx->notnull) {
ASSERT(ctx->isnull == false && ctx->isrange == false); if (ctx->isnull || ctx->isrange) {
fltError("filterAddGroupUnitFromCtx get invalid ctx : isnull %d, notnull %d, isrange %d",
ctx->isnull, ctx->notnull, ctx->isrange);
FLT_ERR_RET(TSDB_CODE_QRY_FILTER_RANGE_ERROR);
}
FLT_ERR_RET(filterAddUnit(dst, OP_TYPE_IS_NOT_NULL, &left, NULL, &uidx)); FLT_ERR_RET(filterAddUnit(dst, OP_TYPE_IS_NOT_NULL, &left, NULL, &uidx));
FLT_ERR_RET(filterAddUnitToGroup(g, uidx)); FLT_ERR_RET(filterAddUnitToGroup(g, uidx));
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
if (!ctx->isrange) { if (!ctx->isrange) {
ASSERT(ctx->isnull || ctx->notnull); if (!ctx->isnull && !ctx->notnull) {
fltError("filterAddGroupUnitFromCtx get invalid ctx : isnull %d, notnull %d, isrange %d",
ctx->isnull, ctx->notnull, ctx->isrange);
FLT_ERR_RET(TSDB_CODE_QRY_FILTER_RANGE_ERROR);
}
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
ASSERT(ctx->rs && ctx->rs->next == NULL); if (!ctx->rs || ctx->rs->next != NULL) {
fltError("filterAddGroupUnitFromCtx get invalid range node with rs:%p", ctx->rs);
FLT_ERR_RET(TSDB_CODE_QRY_FILTER_RANGE_ERROR);
}
SFilterRange *ra = &ctx->rs->ra; SFilterRange *ra = &ctx->rs->ra;
ASSERT(!((FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL)) && (FILTER_GET_FLAG(ra->eflag, RANGE_FLG_NULL)))); if (((FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL)) && (FILTER_GET_FLAG(ra->eflag, RANGE_FLG_NULL)))) {
fltError("filterAddGroupUnitFromCtx get invalid range with sflag:%d, eflag:%d",
FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL), FILTER_GET_FLAG(ra->eflag, RANGE_FLG_NULL));
FLT_ERR_RET(TSDB_CODE_QRY_FILTER_RANGE_ERROR);
}
if ((!FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL)) && (!FILTER_GET_FLAG(ra->eflag, RANGE_FLG_NULL))) { if ((!FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL)) && (!FILTER_GET_FLAG(ra->eflag, RANGE_FLG_NULL))) {
__compar_fn_t func = getComparFunc(type, 0); __compar_fn_t func = getComparFunc(type, 0);
@ -1489,7 +1519,11 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
SFilterGroup ng = {0}; SFilterGroup ng = {0};
g = &ng; g = &ng;
ASSERT(ctx->isnull || ctx->notnull || ctx->isrange); if (!ctx->isnull && !ctx->notnull && !ctx->isrange) {
fltError("filterAddGroupUnitFromCtx get invalid ctx : isnull %d, notnull %d, isrange %d",
ctx->isnull, ctx->notnull, ctx->isrange);
FLT_ERR_RET(TSDB_CODE_APP_ERROR);
}
if (ctx->isnull) { if (ctx->isnull) {
FLT_ERR_RET(filterAddUnit(dst, OP_TYPE_IS_NULL, &left, NULL, &uidx)); FLT_ERR_RET(filterAddUnit(dst, OP_TYPE_IS_NULL, &left, NULL, &uidx));
@ -1500,7 +1534,11 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
} }
if (ctx->notnull) { if (ctx->notnull) {
ASSERT(!ctx->isrange); if (ctx->isrange) {
fltError("filterAddGroupUnitFromCtx get invalid ctx : isnull %d, notnull %d, isrange %d",
ctx->isnull, ctx->notnull, ctx->isrange);
FLT_ERR_RET(TSDB_CODE_QRY_FILTER_RANGE_ERROR);
}
(void)memset(g, 0, sizeof(*g)); (void)memset(g, 0, sizeof(*g));
FLT_ERR_RET(filterAddUnit(dst, OP_TYPE_IS_NOT_NULL, &left, NULL, &uidx)); FLT_ERR_RET(filterAddUnit(dst, OP_TYPE_IS_NOT_NULL, &left, NULL, &uidx));
@ -1511,7 +1549,11 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
} }
if (!ctx->isrange) { if (!ctx->isrange) {
ASSERT(ctx->isnull || ctx->notnull); if (!ctx->isnull && !ctx->notnull) {
fltError("filterAddGroupUnitFromCtx get invalid ctx : isnull %d, notnull %d, isrange %d",
ctx->isnull, ctx->notnull, ctx->isrange);
FLT_ERR_RET(TSDB_CODE_QRY_FILTER_RANGE_ERROR);
}
g->unitNum = 0; g->unitNum = 0;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
@ -1586,7 +1628,10 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
FLT_ERR_RET(filterAddUnitToGroup(g, uidx)); FLT_ERR_RET(filterAddUnitToGroup(g, uidx));
} }
ASSERT(g->unitNum > 0); if (g->unitNum <= 0) {
fltError("filterAddGroupUnitFromCtx get invalid filter group unit num %d", g->unitNum);
FLT_ERR_RET(TSDB_CODE_QRY_FILTER_RANGE_ERROR);
}
if (NULL == taosArrayPush(res,g)) { if (NULL == taosArrayPush(res,g)) {
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
@ -2066,7 +2111,10 @@ void filterFreeInfo(SFilterInfo *info) {
} }
int32_t filterHandleValueExtInfo(SFilterUnit *unit, char extInfo) { int32_t filterHandleValueExtInfo(SFilterUnit *unit, char extInfo) {
ASSERT(extInfo > 0 || extInfo < 0); if (extInfo == 0) {
fltError("filterHandleValueExtInfo get invalid extInfo : %d", extInfo);
return TSDB_CODE_APP_ERROR;
}
uint8_t optr = FILTER_UNIT_OPTR(unit); uint8_t optr = FILTER_UNIT_OPTR(unit);
switch (optr) { switch (optr) {
@ -2093,13 +2141,20 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
for (uint32_t i = 0; i < info->unitNum; ++i) { for (uint32_t i = 0; i < info->unitNum; ++i) {
SFilterUnit *unit = &info->units[i]; SFilterUnit *unit = &info->units[i];
if (unit->right.type != FLD_TYPE_VALUE) { if (unit->right.type != FLD_TYPE_VALUE) {
ASSERT(unit->compare.optr == FILTER_DUMMY_EMPTY_OPTR || scalarGetOperatorParamNum(unit->compare.optr) == 1); if (unit->compare.optr != FILTER_DUMMY_EMPTY_OPTR && scalarGetOperatorParamNum(unit->compare.optr) != 1) {
fltError("filterInitValFieldData get invalid operator param num : %d and invalid compare optr %d",
scalarGetOperatorParamNum(unit->compare.optr), unit->compare.optr);
return TSDB_CODE_APP_ERROR;
}
continue; continue;
} }
SFilterField *right = FILTER_UNIT_RIGHT_FIELD(info, unit); SFilterField *right = FILTER_UNIT_RIGHT_FIELD(info, unit);
ASSERT(FILTER_GET_FLAG(right->flag, FLD_TYPE_VALUE)); if (!FILTER_GET_FLAG(right->flag, FLD_TYPE_VALUE)) {
fltError("filterInitValFieldData get invalid field flag : %d", right->flag);
return TSDB_CODE_APP_ERROR;
}
uint32_t type = FILTER_UNIT_DATA_TYPE(unit); uint32_t type = FILTER_UNIT_DATA_TYPE(unit);
int8_t precision = FILTER_UNIT_DATA_PRECISION(unit); int8_t precision = FILTER_UNIT_DATA_PRECISION(unit);
@ -2107,7 +2162,10 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
SValueNode *var = (SValueNode *)fi->desc; SValueNode *var = (SValueNode *)fi->desc;
if (var == NULL) { if (var == NULL) {
ASSERT(fi->data != NULL); if (!fi->data) {
fltError("filterInitValFieldData get invalid field data : NULL");
return TSDB_CODE_APP_ERROR;
}
continue; continue;
} }
@ -2257,7 +2315,10 @@ int32_t filterAddUnitRange(SFilterInfo *info, SFilterUnit *u, SFilterRangeCtx *c
FILTER_SET_FLAG(ra.sflag, RANGE_FLG_NULL); FILTER_SET_FLAG(ra.sflag, RANGE_FLG_NULL);
break; break;
case OP_TYPE_NOT_EQUAL: case OP_TYPE_NOT_EQUAL:
ASSERT(type == TSDB_DATA_TYPE_BOOL); if (type != TSDB_DATA_TYPE_BOOL) {
fltError("filterAddUnitRange get invalid type : %d", type);
return TSDB_CODE_QRY_FILTER_INVALID_TYPE;
}
if (GET_INT8_VAL(val)) { if (GET_INT8_VAL(val)) {
SIMPLE_COPY_VALUES(&ra.s, &tmp); SIMPLE_COPY_VALUES(&ra.s, &tmp);
SIMPLE_COPY_VALUES(&ra.e, &tmp); SIMPLE_COPY_VALUES(&ra.e, &tmp);
@ -2273,7 +2334,7 @@ int32_t filterAddUnitRange(SFilterInfo *info, SFilterUnit *u, SFilterRangeCtx *c
break; break;
default: default:
fltError("unsupported operator type"); fltError("unsupported operator type");
return TSDB_CODE_APP_ERROR; return TSDB_CODE_QRY_FILTER_NOT_SUPPORT_TYPE;
} }
FLT_ERR_RET(filterAddRange(ctx, &ra, optr)); FLT_ERR_RET(filterAddRange(ctx, &ra, optr));
@ -2372,6 +2433,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t
} }
gRes[gResIdx]->colInfo = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(SFilterColInfo)); gRes[gResIdx]->colInfo = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(SFilterColInfo));
if (gRes[gResIdx]->colInfo == NULL) { if (gRes[gResIdx]->colInfo == NULL) {
filterFreeGroupCtx(gRes[gResIdx]);
FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
} }
colIdxi = 0; colIdxi = 0;
@ -2384,6 +2446,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t
if (gRes[gResIdx]->colInfo[cidx].info == NULL) { if (gRes[gResIdx]->colInfo[cidx].info == NULL) {
gRes[gResIdx]->colInfo[cidx].info = (SArray *)taosArrayInit(4, POINTER_BYTES); gRes[gResIdx]->colInfo[cidx].info = (SArray *)taosArrayInit(4, POINTER_BYTES);
if (gRes[gResIdx]->colInfo[cidx].info == NULL) { if (gRes[gResIdx]->colInfo[cidx].info == NULL) {
filterFreeGroupCtx(gRes[gResIdx]);
FLT_ERR_JRET(terrno); FLT_ERR_JRET(terrno);
} }
colIdx[colIdxi++] = cidx; colIdx[colIdxi++] = cidx;
@ -2408,7 +2471,11 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t
continue; continue;
} }
FLT_ERR_JRET(filterMergeUnits(info, gRes[gResIdx], colIdx[l], &empty)); code = filterMergeUnits(info, gRes[gResIdx], colIdx[l], &empty);
if (TSDB_CODE_SUCCESS != code) {
filterFreeGroupCtx(gRes[gResIdx]);
SCL_ERR_JRET(code);
}
if (empty) { if (empty) {
break; break;
@ -2426,10 +2493,9 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t
gRes[gResIdx]->colNum = colIdxi; gRes[gResIdx]->colNum = colIdxi;
FILTER_COPY_IDX(&gRes[gResIdx]->colIdx, colIdx, colIdxi); FILTER_COPY_IDX(&gRes[gResIdx]->colIdx, colIdx, colIdxi);
++gResIdx; ++gResIdx;
*gResNum = gResIdx;
} }
*gResNum = gResIdx;
if (gResIdx == 0) { if (gResIdx == 0) {
FILTER_SET_FLAG(info->status, FI_STATUS_EMPTY); FILTER_SET_FLAG(info->status, FI_STATUS_EMPTY);
} }
@ -2542,8 +2608,11 @@ int32_t filterMergeTwoGroupsImpl(SFilterInfo *info, SFilterRangeCtx **ctx, int32
FLT_ERR_RET(filterReuseRangeCtx(*ctx, type, 0)); FLT_ERR_RET(filterReuseRangeCtx(*ctx, type, 0));
} }
ASSERT(gRes2->colInfo[cidx].type == RANGE_TYPE_MR_CTX); if (gRes2->colInfo[cidx].type != RANGE_TYPE_MR_CTX || gRes1->colInfo[cidx].type != RANGE_TYPE_MR_CTX) {
ASSERT(gRes1->colInfo[cidx].type == RANGE_TYPE_MR_CTX); fltError("filterMergeTwoGroupsImpl get invalid col type : %d and %d",
gRes2->colInfo[cidx].type, gRes1->colInfo[cidx].type);
return TSDB_CODE_QRY_FILTER_NOT_SUPPORT_TYPE;
}
FLT_ERR_RET(filterCopyRangeCtx(*ctx, gRes2->colInfo[cidx].info)); FLT_ERR_RET(filterCopyRangeCtx(*ctx, gRes2->colInfo[cidx].info));
FLT_ERR_RET(filterSourceRangeFromCtx(*ctx, gRes1->colInfo[cidx].info, optr, empty, all)); FLT_ERR_RET(filterSourceRangeFromCtx(*ctx, gRes1->colInfo[cidx].info, optr, empty, all));
@ -2583,7 +2652,10 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx **gRes1, SFilter
continue; continue;
} }
ASSERT(idx1 == idx2); if (idx1 != idx2) {
fltError("filterMergeTwoGroups get invalid idx : %d and %d", idx1, idx2);
FLT_ERR_JRET(TSDB_CODE_APP_ERROR);
}
++merNum; ++merNum;
@ -2639,16 +2711,19 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx **gRes1, SFilter
} }
} }
ASSERT(merNum > 0); if (merNum == 0 || (equal1 != merNum && equal2 != merNum)) {
fltError("filterMergeTwoGroups get invalid merge num : %d, equal1 : %d, equal2 : %d", merNum, equal1, equal2);
SFilterColInfo *colInfo = NULL; FLT_ERR_JRET(TSDB_CODE_APP_ERROR);
ASSERT(merNum == equal1 || merNum == equal2); }
filterFreeGroupCtx(*gRes2); filterFreeGroupCtx(*gRes2);
*gRes2 = NULL; *gRes2 = NULL;
ASSERT(colCtxs && taosArrayGetSize(colCtxs) > 0); if (!colCtxs || taosArrayGetSize(colCtxs) <= 0) {
fltError("filterMergeTwoGroups get invalid colCtxs with size %zu", taosArrayGetSize(colCtxs));
FLT_ERR_JRET(TSDB_CODE_APP_ERROR);
}
SFilterColInfo *colInfo = NULL;
int32_t ctxSize = (int32_t)taosArrayGetSize(colCtxs); int32_t ctxSize = (int32_t)taosArrayGetSize(colCtxs);
SFilterColCtx *pctx = NULL; SFilterColCtx *pctx = NULL;
@ -2708,7 +2783,10 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t *gR
if (pColNum > 0) { if (pColNum > 0) {
for (int32_t m = 0; m <= pEnd; ++m) { for (int32_t m = 0; m <= pEnd; ++m) {
for (int32_t n = cStart; n <= cEnd; ++n) { for (int32_t n = cStart; n <= cEnd; ++n) {
ASSERT(m < n); if (m >= n) {
fltError("filterMergeGroups get invalid m : %d and n : %d", m, n);
FLT_ERR_JRET(TSDB_CODE_APP_ERROR);
}
FLT_ERR_JRET(filterMergeTwoGroups(info, &gRes[m], &gRes[n], &all)); FLT_ERR_JRET(filterMergeTwoGroups(info, &gRes[m], &gRes[n], &all));
FLT_CHK_JMP(all); FLT_CHK_JMP(all);
@ -2729,7 +2807,10 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t *gR
for (int32_t m = cStart; m < cEnd; ++m) { for (int32_t m = cStart; m < cEnd; ++m) {
for (int32_t n = m + 1; n <= cEnd; ++n) { for (int32_t n = m + 1; n <= cEnd; ++n) {
ASSERT(m < n); if (m >= n) {
fltError("filterMergeGroups get invalid m : %d and n : %d", m, n);
FLT_ERR_JRET(TSDB_CODE_APP_ERROR);
}
FLT_ERR_JRET(filterMergeTwoGroups(info, &gRes[m], &gRes[n], &all)); FLT_ERR_JRET(filterMergeTwoGroups(info, &gRes[m], &gRes[n], &all));
FLT_CHK_JMP(all); FLT_CHK_JMP(all);
@ -2839,7 +2920,10 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t gResNum
for (uint32_t m = 0; m < res->colNum; ++m) { for (uint32_t m = 0; m < res->colNum; ++m) {
colInfo = &res->colInfo[res->colIdx[m]]; colInfo = &res->colInfo[res->colIdx[m]];
if (FILTER_NO_MERGE_DATA_TYPE(colInfo->dataType)) { if (FILTER_NO_MERGE_DATA_TYPE(colInfo->dataType)) {
ASSERT(colInfo->type == RANGE_TYPE_UNIT); if (colInfo->type != RANGE_TYPE_UNIT) {
fltError("filterRewrite get invalid col type : %d", colInfo->type);
FLT_ERR_JRET(TSDB_CODE_QRY_FILTER_INVALID_TYPE);
}
int32_t usize = (int32_t)taosArrayGetSize((SArray *)colInfo->info); int32_t usize = (int32_t)taosArrayGetSize((SArray *)colInfo->info);
for (int32_t n = 0; n < usize; ++n) { for (int32_t n = 0; n < usize; ++n) {
@ -2854,7 +2938,10 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t gResNum
continue; continue;
} }
ASSERT(colInfo->type == RANGE_TYPE_MR_CTX); if (colInfo->type != RANGE_TYPE_MR_CTX) {
fltError("filterRewrite get invalid col type : %d", colInfo->type);
FLT_ERR_JRET(TSDB_CODE_QRY_FILTER_INVALID_TYPE);
}
FLT_ERR_JRET(filterAddGroupUnitFromCtx(info, &oinfo, colInfo->info, res->colIdx[m], &ng, optr, group)); FLT_ERR_JRET(filterAddGroupUnitFromCtx(info, &oinfo, colInfo->info, res->colIdx[m], &ng, optr, group));
} }
@ -2900,7 +2987,10 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_
continue; continue;
} }
ASSERT(idxNum[i] == gResNum); if (idxNum[i] != gResNum) {
fltError("filterGenerateColRange get invalid idxNum : %d and gResNum : %d", idxNum[i], gResNum);
FLT_ERR_JRET(TSDB_CODE_APP_ERROR);
}
if (idxs == NULL) { if (idxs == NULL) {
idxs = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(*idxs)); idxs = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(*idxs));
@ -2931,7 +3021,10 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_
continue; continue;
} }
ASSERT(res->colIdx[n] == idxs[m]); if (res->colIdx[n] != idxs[m]) {
fltError("filterGenerateColRange get invalid colIdx : %d and idxs : %d", res->colIdx[n], idxs[m]);
SCL_ERR_JRET(TSDB_CODE_APP_ERROR);
}
SFilterColInfo *colInfo = &res->colInfo[res->colIdx[n]]; SFilterColInfo *colInfo = &res->colInfo[res->colIdx[n]];
if (info->colRange[m] == NULL) { if (info->colRange[m] == NULL) {
@ -2940,7 +3033,10 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_
info->colRange[m]->colId = FILTER_GET_COL_FIELD_ID(fi); info->colRange[m]->colId = FILTER_GET_COL_FIELD_ID(fi);
} }
ASSERT(colInfo->type == RANGE_TYPE_MR_CTX); if (colInfo->type != RANGE_TYPE_MR_CTX) {
fltError("filterGenerateColRange get invalid col type : %d", colInfo->type);
FLT_ERR_JRET(TSDB_CODE_QRY_FILTER_INVALID_TYPE);
}
bool all = false; bool all = false;
FLT_ERR_JRET(filterSourceRangeFromCtx(info->colRange[m], colInfo->info, LOGIC_COND_TYPE_OR, NULL, &all)); FLT_ERR_JRET(filterSourceRangeFromCtx(info->colRange[m], colInfo->info, LOGIC_COND_TYPE_OR, NULL, &all));
@ -3190,7 +3286,10 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3
unitIdx = pGroupIdx; unitIdx = pGroupIdx;
--info->blkGroupNum; --info->blkGroupNum;
ASSERT(empty || all); if (!empty && !all) {
fltError("filterRmUnitByRange get invalid empty and all : %d and %d", empty, all);
FLT_ERR_RET(TSDB_CODE_APP_ERROR);
}
if (empty) { if (empty) {
FILTER_SET_FLAG(info->blkFlag, FI_STATUS_BLK_EMPTY); FILTER_SET_FLAG(info->blkFlag, FI_STATUS_BLK_EMPTY);
@ -3298,7 +3397,10 @@ int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, SColumn
goto _return; goto _return;
} }
ASSERT(info->unitNum > 1); if (info->unitNum <= 1) {
fltError("filterExecuteBasedOnStatis get invalid unit num : %d", info->unitNum);
FLT_ERR_JRET(TSDB_CODE_APP_ERROR);
}
*all = filterExecuteBasedOnStatisImpl(info, numOfRows, p, statis, numOfCols); *all = filterExecuteBasedOnStatisImpl(info, numOfRows, p, statis, numOfCols);
goto _return; goto _return;
@ -5156,7 +5258,6 @@ int32_t filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p,
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
ASSERT(false == info->scalarMode);
*p = output.columnData; *p = output.columnData;
output.numOfRows = pSrc->info.rows; output.numOfRows = pSrc->info.rows;

View File

@ -297,7 +297,8 @@ static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SS
SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pInputData = pInput->columnData;
SColumnInfoData *pOutputData = pOutput->columnData; SColumnInfoData *pOutputData = pOutput->columnData;
_getDoubleValue_fn_t getValueFn = getVectorDoubleValueFn(type); _getDoubleValue_fn_t getValueFn;
SCL_ERR_RET(getVectorDoubleValueFn(type, &getValueFn));
double *out = (double *)pOutputData->pData; double *out = (double *)pOutputData->pData;
@ -328,7 +329,7 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
for (int32_t i = 0; i < inputNum; ++i) { for (int32_t i = 0; i < inputNum; ++i) {
pInputData[i] = pInput[i].columnData; pInputData[i] = pInput[i].columnData;
getValueFn[i] = getVectorDoubleValueFn(GET_PARAM_TYPE(&pInput[i])); SCL_ERR_RET(getVectorDoubleValueFn(GET_PARAM_TYPE(&pInput[i]), &getValueFn[i]));
} }
double *out = (double *)pOutputData->pData; double *out = (double *)pOutputData->pData;
@ -1767,7 +1768,7 @@ int32_t repeatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
continue; continue;
} }
int32_t count = 0; int32_t count = 0;
GET_TYPED_DATA(count, int32_t, GET_PARAM_TYPE(&pInput[1]), colDataGetData(pInput[1].columnData, i)); GET_TYPED_DATA(count, int32_t, GET_PARAM_TYPE(&pInput[1]), colDataGetData(pInput[1].columnData, 0));
if (count <= 0) { if (count <= 0) {
varDataSetLen(output, 0); varDataSetLen(output, 0);
SCL_ERR_JRET(colDataSetVal(pOutputData, i, outputBuf, false)); SCL_ERR_JRET(colDataSetVal(pOutputData, i, outputBuf, false));
@ -2918,7 +2919,7 @@ static int32_t doScalarFunction2(SScalarParam *pInput, int32_t inputNum, SScalar
for (int32_t i = 0; i < inputNum; ++i) { for (int32_t i = 0; i < inputNum; ++i) {
pInputData[i] = pInput[i].columnData; pInputData[i] = pInput[i].columnData;
getValueFn[i] = getVectorDoubleValueFn(GET_PARAM_TYPE(&pInput[i])); SCL_ERR_RET(getVectorDoubleValueFn(GET_PARAM_TYPE(&pInput[i]), &getValueFn[i]));
} }
bool hasNullType = (IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[0])) || IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[1]))); bool hasNullType = (IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[0])) || IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[1])));

View File

@ -43,7 +43,7 @@ bool noConvertBeforeCompare(int32_t leftType, int32_t rightType, int32_t optr) {
(optr >= OP_TYPE_GREATER_THAN && optr <= OP_TYPE_NOT_EQUAL); (optr >= OP_TYPE_GREATER_THAN && optr <= OP_TYPE_NOT_EQUAL);
} }
void convertNumberToNumber(const void *inData, void *outData, int8_t inType, int8_t outType) { int32_t convertNumberToNumber(const void *inData, void *outData, int8_t inType, int8_t outType) {
switch (outType) { switch (outType) {
case TSDB_DATA_TYPE_BOOL: { case TSDB_DATA_TYPE_BOOL: {
GET_TYPED_DATA(*((bool *)outData), bool, inType, inData); GET_TYPED_DATA(*((bool *)outData), bool, inType, inData);
@ -91,9 +91,10 @@ void convertNumberToNumber(const void *inData, void *outData, int8_t inType, int
break; break;
} }
default: { default: {
ASSERT(0); return TSDB_CODE_SCALAR_CONVERT_ERROR;
} }
} }
return TSDB_CODE_SUCCESS;
} }
int32_t convertNcharToDouble(const void *inData, void *outData) { int32_t convertNcharToDouble(const void *inData, void *outData) {
@ -180,7 +181,10 @@ int32_t getVectorBigintValue_BOOL(void *src, int32_t index, int64_t *res) {
} }
int32_t getVectorBigintValue_JSON(void *src, int32_t index, int64_t *res) { int32_t getVectorBigintValue_JSON(void *src, int32_t index, int64_t *res) {
ASSERT(!colDataIsNull_var(((SColumnInfoData *)src), index)); if (colDataIsNull_var(((SColumnInfoData *)src), index)) {
sclError("getVectorBigintValue_JSON get json data null with index %d", index);
SCL_ERR_RET(TSDB_CODE_SCALAR_CONVERT_ERROR);
}
char *data = colDataGetVarData((SColumnInfoData *)src, index); char *data = colDataGetVarData((SColumnInfoData *)src, index);
double out = 0; double out = 0;
if (*data == TSDB_DATA_TYPE_NULL) { if (*data == TSDB_DATA_TYPE_NULL) {
@ -192,46 +196,47 @@ int32_t getVectorBigintValue_JSON(void *src, int32_t index, int64_t *res) {
*res = 0; *res = 0;
SCL_ERR_RET(TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR); SCL_ERR_RET(TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR);
} else { } else {
convertNumberToNumber(data + CHAR_BYTES, &out, *data, TSDB_DATA_TYPE_DOUBLE); SCL_ERR_RET(convertNumberToNumber(data + CHAR_BYTES, &out, *data, TSDB_DATA_TYPE_DOUBLE));
} }
*res = (int64_t)out; *res = (int64_t)out;
SCL_RET(TSDB_CODE_SUCCESS); SCL_RET(TSDB_CODE_SUCCESS);
} }
_getBigintValue_fn_t getVectorBigintValueFn(int32_t srcType) { int32_t getVectorBigintValueFn(int32_t srcType, _getBigintValue_fn_t *p) {
_getBigintValue_fn_t p = NULL; *p = NULL;
if (srcType == TSDB_DATA_TYPE_TINYINT) { if (srcType == TSDB_DATA_TYPE_TINYINT) {
p = getVectorBigintValue_TINYINT; *p = getVectorBigintValue_TINYINT;
} else if (srcType == TSDB_DATA_TYPE_UTINYINT) { } else if (srcType == TSDB_DATA_TYPE_UTINYINT) {
p = getVectorBigintValue_UTINYINT; *p = getVectorBigintValue_UTINYINT;
} else if (srcType == TSDB_DATA_TYPE_SMALLINT) { } else if (srcType == TSDB_DATA_TYPE_SMALLINT) {
p = getVectorBigintValue_SMALLINT; *p = getVectorBigintValue_SMALLINT;
} else if (srcType == TSDB_DATA_TYPE_USMALLINT) { } else if (srcType == TSDB_DATA_TYPE_USMALLINT) {
p = getVectorBigintValue_USMALLINT; *p = getVectorBigintValue_USMALLINT;
} else if (srcType == TSDB_DATA_TYPE_INT) { } else if (srcType == TSDB_DATA_TYPE_INT) {
p = getVectorBigintValue_INT; *p = getVectorBigintValue_INT;
} else if (srcType == TSDB_DATA_TYPE_UINT) { } else if (srcType == TSDB_DATA_TYPE_UINT) {
p = getVectorBigintValue_UINT; *p = getVectorBigintValue_UINT;
} else if (srcType == TSDB_DATA_TYPE_BIGINT) { } else if (srcType == TSDB_DATA_TYPE_BIGINT) {
p = getVectorBigintValue_BIGINT; *p = getVectorBigintValue_BIGINT;
} else if (srcType == TSDB_DATA_TYPE_UBIGINT) { } else if (srcType == TSDB_DATA_TYPE_UBIGINT) {
p = getVectorBigintValue_UBIGINT; *p = getVectorBigintValue_UBIGINT;
} else if (srcType == TSDB_DATA_TYPE_FLOAT) { } else if (srcType == TSDB_DATA_TYPE_FLOAT) {
p = getVectorBigintValue_FLOAT; *p = getVectorBigintValue_FLOAT;
} else if (srcType == TSDB_DATA_TYPE_DOUBLE) { } else if (srcType == TSDB_DATA_TYPE_DOUBLE) {
p = getVectorBigintValue_DOUBLE; *p = getVectorBigintValue_DOUBLE;
} else if (srcType == TSDB_DATA_TYPE_TIMESTAMP) { } else if (srcType == TSDB_DATA_TYPE_TIMESTAMP) {
p = getVectorBigintValue_BIGINT; *p = getVectorBigintValue_BIGINT;
} else if (srcType == TSDB_DATA_TYPE_BOOL) { } else if (srcType == TSDB_DATA_TYPE_BOOL) {
p = getVectorBigintValue_BOOL; *p = getVectorBigintValue_BOOL;
} else if (srcType == TSDB_DATA_TYPE_JSON) { } else if (srcType == TSDB_DATA_TYPE_JSON) {
p = getVectorBigintValue_JSON; *p = getVectorBigintValue_JSON;
} else if (srcType == TSDB_DATA_TYPE_NULL) { } else if (srcType == TSDB_DATA_TYPE_NULL) {
p = NULL; *p = NULL;
} else { } else {
ASSERT(0); sclError("getVectorBigintValueFn invalid srcType : %d", srcType);
return TSDB_CODE_SCALAR_CONVERT_ERROR;
} }
return p; return TSDB_CODE_SUCCESS;
} }
static FORCE_INLINE int32_t varToTimestamp(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) { static FORCE_INLINE int32_t varToTimestamp(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) {
@ -467,7 +472,7 @@ static FORCE_INLINE int32_t varToGeometry(char *buf, SScalarParam *pOut, int32_t
_return: _return:
taosMemoryFree(output); taosMemoryFree(output);
geosFreeBuffer(t); geosFreeBuffer(t);
ASSERT(t == NULL && len == 0); t = NULL;
VarDataLenT dummyHeader = 0; VarDataLenT dummyHeader = 0;
SCL_ERR_RET(colDataSetVal(pOut->columnData, rowIndex, (const char *)&dummyHeader, false)); SCL_ERR_RET(colDataSetVal(pOut->columnData, rowIndex, (const char *)&dummyHeader, false));
SCL_RET(code); SCL_RET(code);
@ -525,7 +530,7 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) {
} else if (tTagIsJson(data) || *data == TSDB_DATA_TYPE_NULL) { } else if (tTagIsJson(data) || *data == TSDB_DATA_TYPE_NULL) {
SCL_ERR_JRET(TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR); SCL_ERR_JRET(TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR);
} else { } else {
convertNumberToNumber(data + CHAR_BYTES, colDataGetNumData(pCtx->pOut->columnData, i), *data, pCtx->outType); SCL_ERR_JRET(convertNumberToNumber(data + CHAR_BYTES, colDataGetNumData(pCtx->pOut->columnData, i), *data, pCtx->outType));
continue; continue;
} }
} }
@ -582,7 +587,7 @@ int32_t getVectorDoubleValue_JSON(void *src, int32_t index, double *out) {
} else if (tTagIsJson(data)) { } else if (tTagIsJson(data)) {
SCL_ERR_RET(TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR); SCL_ERR_RET(TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR);
} else { } else {
convertNumberToNumber(data + CHAR_BYTES, out, *data, TSDB_DATA_TYPE_DOUBLE); SCL_ERR_RET(convertNumberToNumber(data + CHAR_BYTES, out, *data, TSDB_DATA_TYPE_DOUBLE));
} }
SCL_RET(TSDB_CODE_SUCCESS); SCL_RET(TSDB_CODE_SUCCESS);
} }
@ -673,7 +678,7 @@ int32_t convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_
*result = false; *result = false;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} else if (typeLeft != type) { } else if (typeLeft != type) {
convertNumberToNumber(*pLeftData, pLeftOut, typeLeft, type); SCL_ERR_RET(convertNumberToNumber(*pLeftData, pLeftOut, typeLeft, type));
*pLeftData = pLeftOut; *pLeftData = pLeftOut;
} }
@ -683,7 +688,7 @@ int32_t convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_
*result = false; *result = false;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} else if (typeRight != type) { } else if (typeRight != type) {
convertNumberToNumber(*pRightData, pRightOut, typeRight, type); SCL_ERR_RET(convertNumberToNumber(*pRightData, pRightOut, typeRight, type));
*pRightData = pRightOut; *pRightData = pRightOut;
} }
} else if (type == TSDB_DATA_TYPE_BINARY || } else if (type == TSDB_DATA_TYPE_BINARY ||
@ -1130,8 +1135,10 @@ enum {
// TODO not correct for descending order scan // TODO not correct for descending order scan
static int32_t vectorMathAddHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol, static int32_t vectorMathAddHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol,
int32_t numOfRows, int32_t step, int32_t i) { int32_t numOfRows, int32_t step, int32_t i) {
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnLeft;
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnRight;
SCL_ERR_RET(getVectorDoubleValueFn(pLeftCol->info.type, &getVectorDoubleValueFnLeft));
SCL_ERR_RET(getVectorDoubleValueFn(pRightCol->info.type, &getVectorDoubleValueFnRight));
double *output = (double *)pOutputCol->pData; double *output = (double *)pOutputCol->pData;
@ -1155,9 +1162,10 @@ static int32_t vectorMathAddHelper(SColumnInfoData *pLeftCol, SColumnInfoData *p
static int32_t vectorMathTsAddHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol, static int32_t vectorMathTsAddHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol,
int32_t numOfRows, int32_t step, int32_t i) { int32_t numOfRows, int32_t step, int32_t i) {
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnLeft;
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnRight;
SCL_ERR_RET(getVectorBigintValueFn(pLeftCol->info.type, &getVectorBigintValueFnLeft));
SCL_ERR_RET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
int64_t *output = (int64_t *)pOutputCol->pData; int64_t *output = (int64_t *)pOutputCol->pData;
if (IS_HELPER_NULL(pRightCol, 0)) { // Set pLeft->numOfRows NULL value if (IS_HELPER_NULL(pRightCol, 0)) { // Set pLeft->numOfRows NULL value
@ -1230,8 +1238,10 @@ int32_t vectorMathAdd(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *p
(GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP && (GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP &&
GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_BOOL)) { // timestamp plus duration GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_BOOL)) { // timestamp plus duration
int64_t *output = (int64_t *)pOutputCol->pData; int64_t *output = (int64_t *)pOutputCol->pData;
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnLeft;
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnRight;
SCL_ERR_JRET(getVectorBigintValueFn(pLeftCol->info.type, &getVectorBigintValueFnLeft));
SCL_ERR_JRET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
if (pLeft->numOfRows == 1 && pRight->numOfRows == 1) { if (pLeft->numOfRows == 1 && pRight->numOfRows == 1) {
if (GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_TIMESTAMP) { if (GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_TIMESTAMP) {
@ -1258,9 +1268,10 @@ int32_t vectorMathAdd(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *p
} }
} else { } else {
double *output = (double *)pOutputCol->pData; double *output = (double *)pOutputCol->pData;
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnLeft;
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnRight;
SCL_ERR_JRET(getVectorDoubleValueFn(pLeftCol->info.type, &getVectorDoubleValueFnLeft));
SCL_ERR_JRET(getVectorDoubleValueFn(pRightCol->info.type, &getVectorDoubleValueFnRight));
if (pLeft->numOfRows == pRight->numOfRows) { if (pLeft->numOfRows == pRight->numOfRows) {
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) { for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
if (IS_NULL) { if (IS_NULL) {
@ -1289,8 +1300,10 @@ _return:
// TODO not correct for descending order scan // TODO not correct for descending order scan
static int32_t vectorMathSubHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol, static int32_t vectorMathSubHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol,
int32_t numOfRows, int32_t step, int32_t factor, int32_t i) { int32_t numOfRows, int32_t step, int32_t factor, int32_t i) {
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnLeft;
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnRight;
SCL_ERR_RET(getVectorDoubleValueFn(pLeftCol->info.type, &getVectorDoubleValueFnLeft));
SCL_ERR_RET(getVectorDoubleValueFn(pRightCol->info.type, &getVectorDoubleValueFnRight));
double *output = (double *)pOutputCol->pData; double *output = (double *)pOutputCol->pData;
@ -1314,8 +1327,10 @@ static int32_t vectorMathSubHelper(SColumnInfoData *pLeftCol, SColumnInfoData *p
static int32_t vectorMathTsSubHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol, static int32_t vectorMathTsSubHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol,
int32_t numOfRows, int32_t step, int32_t factor, int32_t i) { int32_t numOfRows, int32_t step, int32_t factor, int32_t i) {
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnLeft;
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnRight;
SCL_ERR_RET(getVectorBigintValueFn(pLeftCol->info.type, &getVectorBigintValueFnLeft));
SCL_ERR_RET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
int64_t *output = (int64_t *)pOutputCol->pData; int64_t *output = (int64_t *)pOutputCol->pData;
@ -1357,8 +1372,10 @@ int32_t vectorMathSub(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *p
(GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP && (GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP &&
GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_BIGINT)) { // timestamp minus duration GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_BIGINT)) { // timestamp minus duration
int64_t *output = (int64_t *)pOutputCol->pData; int64_t *output = (int64_t *)pOutputCol->pData;
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnLeft;
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnRight;
SCL_ERR_JRET(getVectorBigintValueFn(pLeftCol->info.type, &getVectorBigintValueFnLeft));
SCL_ERR_JRET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
if (pLeft->numOfRows == 1 && pRight->numOfRows == 1) { if (pLeft->numOfRows == 1 && pRight->numOfRows == 1) {
SCL_ERR_JRET(vectorMathTsSubHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, 1, i)); SCL_ERR_JRET(vectorMathTsSubHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, 1, i));
@ -1381,8 +1398,10 @@ int32_t vectorMathSub(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *p
} }
} else { } else {
double *output = (double *)pOutputCol->pData; double *output = (double *)pOutputCol->pData;
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnLeft;
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnRight;
SCL_ERR_JRET(getVectorDoubleValueFn(pLeftCol->info.type, &getVectorDoubleValueFnLeft));
SCL_ERR_JRET(getVectorDoubleValueFn(pRightCol->info.type, &getVectorDoubleValueFnRight));
if (pLeft->numOfRows == pRight->numOfRows) { if (pLeft->numOfRows == pRight->numOfRows) {
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) { for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
@ -1412,8 +1431,10 @@ _return:
// TODO not correct for descending order scan // TODO not correct for descending order scan
static int32_t vectorMathMultiplyHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol, static int32_t vectorMathMultiplyHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol,
int32_t numOfRows, int32_t step, int32_t i) { int32_t numOfRows, int32_t step, int32_t i) {
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnLeft;
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnRight;
SCL_ERR_RET(getVectorDoubleValueFn(pLeftCol->info.type, &getVectorDoubleValueFnLeft));
SCL_ERR_RET(getVectorDoubleValueFn(pRightCol->info.type, &getVectorDoubleValueFnRight));
double *output = (double *)pOutputCol->pData; double *output = (double *)pOutputCol->pData;
@ -1449,8 +1470,10 @@ int32_t vectorMathMultiply(SScalarParam *pLeft, SScalarParam *pRight, SScalarPar
SCL_ERR_JRET(vectorConvertVarToDouble(pLeft, &leftConvert, &pLeftCol)); SCL_ERR_JRET(vectorConvertVarToDouble(pLeft, &leftConvert, &pLeftCol));
SCL_ERR_JRET(vectorConvertVarToDouble(pRight, &rightConvert, &pRightCol)); SCL_ERR_JRET(vectorConvertVarToDouble(pRight, &rightConvert, &pRightCol));
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnLeft;
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnRight;
SCL_ERR_JRET(getVectorDoubleValueFn(pLeftCol->info.type, &getVectorDoubleValueFnLeft));
SCL_ERR_JRET(getVectorDoubleValueFn(pRightCol->info.type, &getVectorDoubleValueFnRight));
double *output = (double *)pOutputCol->pData; double *output = (double *)pOutputCol->pData;
if (pLeft->numOfRows == pRight->numOfRows) { if (pLeft->numOfRows == pRight->numOfRows) {
@ -1491,8 +1514,10 @@ int32_t vectorMathDivide(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam
SCL_ERR_JRET(vectorConvertVarToDouble(pLeft, &leftConvert, &pLeftCol)); SCL_ERR_JRET(vectorConvertVarToDouble(pLeft, &leftConvert, &pLeftCol));
SCL_ERR_JRET(vectorConvertVarToDouble(pRight, &rightConvert, &pRightCol)); SCL_ERR_JRET(vectorConvertVarToDouble(pRight, &rightConvert, &pRightCol));
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnLeft;
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnRight;
SCL_ERR_JRET(getVectorDoubleValueFn(pLeftCol->info.type, &getVectorDoubleValueFnLeft));
SCL_ERR_JRET(getVectorDoubleValueFn(pRightCol->info.type, &getVectorDoubleValueFnRight));
double *output = (double *)pOutputCol->pData; double *output = (double *)pOutputCol->pData;
if (pLeft->numOfRows == pRight->numOfRows) { if (pLeft->numOfRows == pRight->numOfRows) {
@ -1573,8 +1598,10 @@ int32_t vectorMathRemainder(SScalarParam *pLeft, SScalarParam *pRight, SScalarPa
SCL_ERR_JRET(vectorConvertVarToDouble(pLeft, &leftConvert, &pLeftCol)); SCL_ERR_JRET(vectorConvertVarToDouble(pLeft, &leftConvert, &pLeftCol));
SCL_ERR_JRET(vectorConvertVarToDouble(pRight, &rightConvert, &pRightCol)); SCL_ERR_JRET(vectorConvertVarToDouble(pRight, &rightConvert, &pRightCol));
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnLeft;
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnRight;
SCL_ERR_JRET(getVectorDoubleValueFn(pLeftCol->info.type, &getVectorDoubleValueFnLeft));
SCL_ERR_JRET(getVectorDoubleValueFn(pRightCol->info.type, &getVectorDoubleValueFnRight));
double *output = (double *)pOutputCol->pData; double *output = (double *)pOutputCol->pData;
@ -1661,7 +1688,8 @@ int32_t vectorMathMinus(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam
SColumnInfoData *pLeftCol = NULL; SColumnInfoData *pLeftCol = NULL;
SCL_ERR_JRET(vectorConvertVarToDouble(pLeft, &leftConvert, &pLeftCol)); SCL_ERR_JRET(vectorConvertVarToDouble(pLeft, &leftConvert, &pLeftCol));
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnLeft;
SCL_ERR_JRET(getVectorDoubleValueFn(pLeftCol->info.type, &getVectorDoubleValueFnLeft));
double *output = (double *)pOutputCol->pData; double *output = (double *)pOutputCol->pData;
for (; i < pLeft->numOfRows && i >= 0; i += step, output += 1) { for (; i < pLeft->numOfRows && i >= 0; i += step, output += 1) {
@ -1692,15 +1720,20 @@ int32_t vectorAssign(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pO
} }
} }
ASSERT(pRight->numOfQualified == 1 || pRight->numOfQualified == 0); if (pRight->numOfQualified != 1 && pRight->numOfQualified != 0) {
sclError("vectorAssign: invalid qualified number %d", pRight->numOfQualified);
SCL_ERR_RET(TSDB_CODE_APP_ERROR);
}
pOut->numOfQualified = pRight->numOfQualified * pOut->numOfRows; pOut->numOfQualified = pRight->numOfQualified * pOut->numOfRows;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static int32_t vectorBitAndHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol, static int32_t vectorBitAndHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol,
int32_t numOfRows, int32_t step, int32_t i) { int32_t numOfRows, int32_t step, int32_t i) {
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnLeft;
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnRight;
SCL_ERR_RET(getVectorBigintValueFn(pLeftCol->info.type, &getVectorBigintValueFnLeft));
SCL_ERR_RET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
int64_t *output = (int64_t *)pOutputCol->pData; int64_t *output = (int64_t *)pOutputCol->pData;
@ -1736,8 +1769,10 @@ int32_t vectorBitAnd(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pO
SCL_ERR_JRET(vectorConvertVarToDouble(pLeft, &leftConvert, &pLeftCol)); SCL_ERR_JRET(vectorConvertVarToDouble(pLeft, &leftConvert, &pLeftCol));
SCL_ERR_JRET(vectorConvertVarToDouble(pRight, &rightConvert, &pRightCol)); SCL_ERR_JRET(vectorConvertVarToDouble(pRight, &rightConvert, &pRightCol));
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnLeft;
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnRight;
SCL_ERR_JRET(getVectorBigintValueFn(pLeftCol->info.type, &getVectorBigintValueFnLeft));
SCL_ERR_JRET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
int64_t *output = (int64_t *)pOutputCol->pData; int64_t *output = (int64_t *)pOutputCol->pData;
if (pLeft->numOfRows == pRight->numOfRows) { if (pLeft->numOfRows == pRight->numOfRows) {
@ -1766,8 +1801,10 @@ _return:
static int32_t vectorBitOrHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol, static int32_t vectorBitOrHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol,
int32_t numOfRows, int32_t step, int32_t i) { int32_t numOfRows, int32_t step, int32_t i) {
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnLeft;
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnRight;
SCL_ERR_RET(getVectorBigintValueFn(pLeftCol->info.type, &getVectorBigintValueFnLeft));
SCL_ERR_RET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
int64_t *output = (int64_t *)pOutputCol->pData; int64_t *output = (int64_t *)pOutputCol->pData;
@ -1803,8 +1840,10 @@ int32_t vectorBitOr(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOu
SCL_ERR_JRET(vectorConvertVarToDouble(pLeft, &leftConvert, &pLeftCol)); SCL_ERR_JRET(vectorConvertVarToDouble(pLeft, &leftConvert, &pLeftCol));
SCL_ERR_JRET(vectorConvertVarToDouble(pRight, &rightConvert, &pRightCol)); SCL_ERR_JRET(vectorConvertVarToDouble(pRight, &rightConvert, &pRightCol));
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnLeft;
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnRight;
SCL_ERR_JRET(getVectorBigintValueFn(pLeftCol->info.type, &getVectorBigintValueFnLeft));
SCL_ERR_JRET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
int64_t *output = (int64_t *)pOutputCol->pData; int64_t *output = (int64_t *)pOutputCol->pData;
if (pLeft->numOfRows == pRight->numOfRows) { if (pLeft->numOfRows == pRight->numOfRows) {
@ -1892,7 +1931,8 @@ int32_t doVectorCompareImpl(SScalarParam *pLeft, SScalarParam *pRight, SScalarPa
&leftOut, &rightOut, &isJsonnull, &freeLeft, &freeRight, &result)); &leftOut, &rightOut, &isJsonnull, &freeLeft, &freeRight, &result));
if (isJsonnull) { if (isJsonnull) {
ASSERT(0); sclError("doVectorCompareImpl: invalid json null value");
SCL_ERR_RET(TSDB_CODE_APP_ERROR);
} }
if (!pLeftData || !pRightData) { if (!pLeftData || !pRightData) {

View File

@ -1,7 +1,7 @@
MESSAGE(STATUS "build filter unit test") MESSAGE(STATUS "build filter unit test")
IF(NOT TD_DARWIN) IF(TD_DARWIN)
# GoogleTest requires at least C++11 # GoogleTest requires at least C++11
SET(CMAKE_CXX_STANDARD 11) SET(CMAKE_CXX_STANDARD 11)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)

View File

@ -113,8 +113,7 @@ int32_t flttMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType,
if (NULL == *block) { if (NULL == *block) {
SSDataBlock *res = NULL; SSDataBlock *res = NULL;
int32_t code = createDataBlock(&res); FLT_ERR_RET(createDataBlock(&res));
ASSERT(code == 0);
for (int32_t i = 0; i < 2; ++i) { for (int32_t i = 0; i < 2; ++i) {
SColumnInfoData idata = createColumnInfoData(TSDB_DATA_TYPE_NULL, 10, 1 + i); SColumnInfoData idata = createColumnInfoData(TSDB_DATA_TYPE_NULL, 10, 1 + i);

View File

@ -115,7 +115,10 @@ int32_t scltAppendReservedSlot(SArray *pBlockList, int16_t *dataBlockId, int16_t
res->info.capacity = rows; res->info.capacity = rows;
res->info.rows = rows; res->info.rows = rows;
SColumnInfoData *p = static_cast<SColumnInfoData *>(taosArrayGet(res->pDataBlock, 0)); SColumnInfoData *p = static_cast<SColumnInfoData *>(taosArrayGet(res->pDataBlock, 0));
ASSERT(p->pData != NULL && p->nullbitmap != NULL); if (p->pData == NULL || p->nullbitmap == NULL) {
sclError("data block is not initialized since pData or nullbitmap is NULL");
SCL_ERR_RET(TSDB_CODE_APP_ERROR);
}
(void)taosArrayPush(pBlockList, &res); (void)taosArrayPush(pBlockList, &res);
*dataBlockId = taosArrayGetSize(pBlockList) - 1; *dataBlockId = taosArrayGetSize(pBlockList) - 1;
@ -189,8 +192,7 @@ int32_t scltMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType,
if (NULL == *block) { if (NULL == *block) {
SSDataBlock *res = NULL; SSDataBlock *res = NULL;
int32_t code = createDataBlock(&res); SCL_ERR_RET(createDataBlock(&res));
ASSERT(code == 0);
for (int32_t i = 0; i < 2; ++i) { for (int32_t i = 0; i < 2; ++i) {
SColumnInfoData idata = createColumnInfoData(TSDB_DATA_TYPE_INT, 10, i + 1); SColumnInfoData idata = createColumnInfoData(TSDB_DATA_TYPE_INT, 10, i + 1);
@ -1422,8 +1424,10 @@ int32_t makeCalculate(void *json, void *key, int32_t rightType, void *rightData,
opType == OP_TYPE_NMATCH) { opType == OP_TYPE_NMATCH) {
(void)printf("op:%s,3result:%d,except:%f\n", operatorTypeStr(opType), *((bool *)colDataGetData(column, 0)), (void)printf("op:%s,3result:%d,except:%f\n", operatorTypeStr(opType), *((bool *)colDataGetData(column, 0)),
exceptValue); exceptValue);
assert(*(bool *)colDataGetData(column, 0) == exceptValue); if(*(bool *)colDataGetData(column, 0) != exceptValue) {
// ASSERT_EQ((int) *((bool *)colDataGetData(column, 0)), (int)exceptValue); (void)printf("expect value %d, but got %d\n", *((bool *)colDataGetData(column, 0)), exceptValue);
SCL_ERR_RET(TSDB_CODE_FAILED);
}
} }
taosArrayDestroyEx(blockList, scltFreeDataBlock); taosArrayDestroyEx(blockList, scltFreeDataBlock);

View File

@ -273,7 +273,7 @@ void schCloseJobRef(void) {
} }
if (schMgmt.jobRef >= 0) { if (schMgmt.jobRef >= 0) {
(void)taosCloseRef(schMgmt.jobRef); taosCloseRef(schMgmt.jobRef);
schMgmt.jobRef = -1; schMgmt.jobRef = -1;
} }
} }

View File

@ -97,8 +97,6 @@ void streamTaskSendCheckMsg(SStreamTask* pTask) {
.stage = pTask->pMeta->stage, .stage = pTask->pMeta->stage,
}; };
ASSERT(pTask->status.downstreamReady == 0);
// serialize streamProcessScanHistoryFinishRsp // serialize streamProcessScanHistoryFinishRsp
if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) { if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) {
streamTaskStartMonitorCheckRsp(pTask); streamTaskStartMonitorCheckRsp(pTask);
@ -187,8 +185,6 @@ void streamTaskProcessCheckMsg(SStreamMeta* pMeta, SStreamTaskCheckReq* pReq, SS
} }
int32_t streamTaskProcessCheckRsp(SStreamTask* pTask, const SStreamTaskCheckRsp* pRsp) { int32_t streamTaskProcessCheckRsp(SStreamTask* pTask, const SStreamTaskCheckRsp* pRsp) {
ASSERT(pTask->id.taskId == pRsp->upstreamTaskId);
int64_t now = taosGetTimestampMs(); int64_t now = taosGetTimestampMs();
const char* id = pTask->id.idStr; const char* id = pTask->id.idStr;
STaskCheckInfo* pInfo = &pTask->taskCheckInfo; STaskCheckInfo* pInfo = &pTask->taskCheckInfo;
@ -200,6 +196,11 @@ int32_t streamTaskProcessCheckRsp(SStreamTask* pTask, const SStreamTaskCheckRsp*
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
if (pTask->id.taskId != pRsp->upstreamTaskId) {
stError("s-task:%s invalid check downstream rsp, upstream task:0x%x discard", id, pRsp->upstreamTaskId);
return TSDB_CODE_INVALID_MSG;
}
if (pRsp->status == TASK_DOWNSTREAM_READY) { if (pRsp->status == TASK_DOWNSTREAM_READY) {
int32_t code = streamTaskUpdateCheckInfo(pInfo, pRsp->downstreamTaskId, pRsp->status, now, pRsp->reqId, &left, id); int32_t code = streamTaskUpdateCheckInfo(pInfo, pRsp->downstreamTaskId, pRsp->status, now, pRsp->reqId, &left, id);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
@ -235,7 +236,6 @@ int32_t streamTaskProcessCheckRsp(SStreamTask* pTask, const SStreamTaskCheckRsp*
streamMetaAddFailedTaskSelf(pTask, now); streamMetaAddFailedTaskSelf(pTask, now);
} else { // TASK_DOWNSTREAM_NOT_READY, rsp-check monitor will retry in 300 ms } else { // TASK_DOWNSTREAM_NOT_READY, rsp-check monitor will retry in 300 ms
ASSERT(left > 0);
stDebug("s-task:%s (vgId:%d) recv check rsp from task:0x%x (vgId:%d) status:%d, total:%d not ready:%d", id, stDebug("s-task:%s (vgId:%d) recv check rsp from task:0x%x (vgId:%d) status:%d, total:%d not ready:%d", id,
pRsp->upstreamNodeId, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->status, total, left); pRsp->upstreamNodeId, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->status, total, left);
} }
@ -315,8 +315,6 @@ void streamTaskStopMonitorCheckRsp(STaskCheckInfo* pInfo, const char* id) {
} }
void streamTaskCleanupCheckInfo(STaskCheckInfo* pInfo) { void streamTaskCleanupCheckInfo(STaskCheckInfo* pInfo) {
ASSERT(pInfo->inCheckProcess == 0);
taosArrayDestroy(pInfo->pList); taosArrayDestroy(pInfo->pList);
pInfo->pList = NULL; pInfo->pList = NULL;
@ -338,7 +336,10 @@ void processDownstreamReadyRsp(SStreamTask* pTask) {
(void) streamMetaAddTaskLaunchResult(pTask->pMeta, pTask->id.streamId, pTask->id.taskId, checkTs, readyTs, true); (void) streamMetaAddTaskLaunchResult(pTask->pMeta, pTask->id.streamId, pTask->id.taskId, checkTs, readyTs, true);
if (pTask->status.taskStatus == TASK_STATUS__HALT) { if (pTask->status.taskStatus == TASK_STATUS__HALT) {
ASSERT(HAS_RELATED_FILLHISTORY_TASK(pTask) && (pTask->info.fillHistory == 0)); if (!HAS_RELATED_FILLHISTORY_TASK(pTask) || (pTask->info.fillHistory != 0)) {
stError("s-task:%s status:halt fillhistory:%d not handle the ready rsp", pTask->id.idStr,
pTask->info.fillHistory);
}
// halt it self for count window stream task until the related fill history task completed. // halt it self for count window stream task until the related fill history task completed.
stDebug("s-task:%s level:%d initial status is %s from mnode, set it to be halt", pTask->id.idStr, stDebug("s-task:%s level:%d initial status is %s from mnode, set it to be halt", pTask->id.idStr,
@ -396,7 +397,6 @@ void streamTaskInitTaskCheckInfo(STaskCheckInfo* pInfo, STaskOutputInfo* pOutput
pInfo->notReadyTasks = 1; pInfo->notReadyTasks = 1;
} else if (pOutputInfo->type == TASK_OUTPUT__SHUFFLE_DISPATCH) { } else if (pOutputInfo->type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
pInfo->notReadyTasks = taosArrayGetSize(pOutputInfo->shuffleDispatcher.dbInfo.pVgroupInfos); pInfo->notReadyTasks = taosArrayGetSize(pOutputInfo->shuffleDispatcher.dbInfo.pVgroupInfos);
ASSERT(pInfo->notReadyTasks == pOutputInfo->shuffleDispatcher.dbInfo.vgNum);
} }
pInfo->startTs = startTs; pInfo->startTs = startTs;
@ -461,7 +461,6 @@ int32_t streamTaskStartCheckDownstream(STaskCheckInfo* pInfo, const char* id) {
if (pInfo->inCheckProcess == 0) { if (pInfo->inCheckProcess == 0) {
pInfo->inCheckProcess = 1; pInfo->inCheckProcess = 1;
} else { } else {
ASSERT(pInfo->startTs > 0);
stError("s-task:%s already in check procedure, checkTs:%" PRId64 ", start monitor check rsp failed", id, stError("s-task:%s already in check procedure, checkTs:%" PRId64 ", start monitor check rsp failed", id,
pInfo->startTs); pInfo->startTs);
pInfo->stopCheckProcess = 0; // disable auto stop of check process pInfo->stopCheckProcess = 0; // disable auto stop of check process
@ -564,8 +563,6 @@ void doSendCheckMsg(SStreamTask* pTask, SDownstreamStatusInfo* p) {
break; break;
} }
} }
} else {
ASSERT(0);
} }
} }
@ -585,7 +582,6 @@ void getCheckRspStatus(STaskCheckInfo* pInfo, int64_t el, int32_t* numOfReady, i
(*numOfFault) += 1; (*numOfFault) += 1;
} else { // TASK_DOWNSTREAM_NOT_READY } else { // TASK_DOWNSTREAM_NOT_READY
if (p->rspTs == 0) { // not response yet if (p->rspTs == 0) { // not response yet
ASSERT(p->status == -1);
if (el >= CHECK_NOT_RSP_DURATION) { // not receive info for 10 sec. if (el >= CHECK_NOT_RSP_DURATION) { // not receive info for 10 sec.
(void) taosArrayPush(pTimeoutList, &p->taskId); (void) taosArrayPush(pTimeoutList, &p->taskId);
} else { // el < CHECK_NOT_RSP_DURATION } else { // el < CHECK_NOT_RSP_DURATION
@ -610,9 +606,7 @@ void handleTimeoutDownstreamTasks(SStreamTask* pTask, SArray* pTimeoutList) {
int32_t vgId = pTask->pMeta->vgId; int32_t vgId = pTask->pMeta->vgId;
int32_t numOfTimeout = taosArrayGetSize(pTimeoutList); int32_t numOfTimeout = taosArrayGetSize(pTimeoutList);
ASSERT(pTask->status.downstreamReady == 0);
pInfo->timeoutStartTs = taosGetTimestampMs(); pInfo->timeoutStartTs = taosGetTimestampMs();
for (int32_t i = 0; i < numOfTimeout; ++i) { for (int32_t i = 0; i < numOfTimeout; ++i) {
int32_t* px = taosArrayGet(pTimeoutList, i); int32_t* px = taosArrayGet(pTimeoutList, i);
if (px == NULL) { if (px == NULL) {
@ -623,7 +617,13 @@ void handleTimeoutDownstreamTasks(SStreamTask* pTask, SArray* pTimeoutList) {
SDownstreamStatusInfo* p = NULL; SDownstreamStatusInfo* p = NULL;
findCheckRspStatus(pInfo, taskId, &p); findCheckRspStatus(pInfo, taskId, &p);
if (p != NULL) { if (p != NULL) {
ASSERT(p->status == -1 && p->rspTs == 0);
if (p->status != -1 || p->rspTs != 0) {
stError("s-task:%s invalid rsp record entry, index:%d, status:%d, rspTs:%"PRId64, pTask->id.idStr, i, p->status,
p->rspTs);
continue;
}
doSendCheckMsg(pTask, p); doSendCheckMsg(pTask, p);
} }
} }
@ -662,8 +662,6 @@ void handleNotReadyDownstreamTask(SStreamTask* pTask, SArray* pNotReadyList) {
int32_t vgId = pTask->pMeta->vgId; int32_t vgId = pTask->pMeta->vgId;
int32_t numOfNotReady = taosArrayGetSize(pNotReadyList); int32_t numOfNotReady = taosArrayGetSize(pNotReadyList);
ASSERT(pTask->status.downstreamReady == 0);
// reset the info, and send the check msg to failure downstream again // reset the info, and send the check msg to failure downstream again
for (int32_t i = 0; i < numOfNotReady; ++i) { for (int32_t i = 0; i < numOfNotReady; ++i) {
int32_t* pTaskId = taosArrayGet(pNotReadyList, i); int32_t* pTaskId = taosArrayGet(pNotReadyList, i);
@ -696,12 +694,10 @@ int32_t addDownstreamFailedStatusResultAsync(SMsgCb* pMsgCb, int32_t vgId, int64
void rspMonitorFn(void* param, void* tmrId) { void rspMonitorFn(void* param, void* tmrId) {
SStreamTask* pTask = param; SStreamTask* pTask = param;
SStreamMeta* pMeta = pTask->pMeta; SStreamMeta* pMeta = pTask->pMeta;
SStreamTaskState pStat = streamTaskGetStatus(pTask);
STaskCheckInfo* pInfo = &pTask->taskCheckInfo; STaskCheckInfo* pInfo = &pTask->taskCheckInfo;
int32_t vgId = pTask->pMeta->vgId; int32_t vgId = pTask->pMeta->vgId;
int64_t now = taosGetTimestampMs(); int64_t now = taosGetTimestampMs();
int64_t timeoutDuration = now - pInfo->timeoutStartTs; int64_t timeoutDuration = now - pInfo->timeoutStartTs;
ETaskStatus state = pStat.state;
const char* id = pTask->id.idStr; const char* id = pTask->id.idStr;
int32_t numOfReady = 0; int32_t numOfReady = 0;
int32_t numOfFault = 0; int32_t numOfFault = 0;
@ -712,9 +708,13 @@ void rspMonitorFn(void* param, void* tmrId) {
stDebug("s-task:%s start to do check-downstream-rsp check in tmr", id); stDebug("s-task:%s start to do check-downstream-rsp check in tmr", id);
if (state == TASK_STATUS__STOP) { streamMutexLock(&pTask->lock);
SStreamTaskState state = streamTaskGetStatus(pTask);
streamMutexUnlock(&pTask->lock);
if (state.state == TASK_STATUS__STOP) {
int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1);
stDebug("s-task:%s status:%s vgId:%d quit from monitor check-rsp tmr, ref:%d", id, pStat.name, vgId, ref); stDebug("s-task:%s status:%s vgId:%d quit from monitor check-rsp tmr, ref:%d", id, state.name, vgId, ref);
streamTaskCompleteCheckRsp(pInfo, true, id); streamTaskCompleteCheckRsp(pInfo, true, id);
@ -728,9 +728,9 @@ void rspMonitorFn(void* param, void* tmrId) {
return; return;
} }
if (state == TASK_STATUS__DROPPING || state == TASK_STATUS__READY) { if (state.state == TASK_STATUS__DROPPING || state.state == TASK_STATUS__READY) {
int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1);
stDebug("s-task:%s status:%s vgId:%d quit from monitor check-rsp tmr, ref:%d", id, pStat.name, vgId, ref); stDebug("s-task:%s status:%s vgId:%d quit from monitor check-rsp tmr, ref:%d", id, state.name, vgId, ref);
streamTaskCompleteCheckRsp(pInfo, true, id); streamTaskCompleteCheckRsp(pInfo, true, id);
streamMetaReleaseTask(pMeta, pTask); streamMetaReleaseTask(pMeta, pTask);
@ -740,7 +740,7 @@ void rspMonitorFn(void* param, void* tmrId) {
streamMutexLock(&pInfo->checkInfoLock); streamMutexLock(&pInfo->checkInfoLock);
if (pInfo->notReadyTasks == 0) { if (pInfo->notReadyTasks == 0) {
int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1);
stDebug("s-task:%s status:%s vgId:%d all downstream ready, quit from monitor rsp tmr, ref:%d", id, pStat.name, stDebug("s-task:%s status:%s vgId:%d all downstream ready, quit from monitor rsp tmr, ref:%d", id, state.name,
vgId, ref); vgId, ref);
streamTaskCompleteCheckRsp(pInfo, false, id); streamTaskCompleteCheckRsp(pInfo, false, id);
@ -752,21 +752,34 @@ void rspMonitorFn(void* param, void* tmrId) {
SArray* pNotReadyList = taosArrayInit(4, sizeof(int64_t)); SArray* pNotReadyList = taosArrayInit(4, sizeof(int64_t));
SArray* pTimeoutList = taosArrayInit(4, sizeof(int64_t)); SArray* pTimeoutList = taosArrayInit(4, sizeof(int64_t));
if (pStat.state == TASK_STATUS__UNINIT) { if (state.state == TASK_STATUS__UNINIT) {
getCheckRspStatus(pInfo, timeoutDuration, &numOfReady, &numOfFault, &numOfNotRsp, pTimeoutList, pNotReadyList, id); getCheckRspStatus(pInfo, timeoutDuration, &numOfReady, &numOfFault, &numOfNotRsp, pTimeoutList, pNotReadyList, id);
numOfNotReady = (int32_t)taosArrayGetSize(pNotReadyList); numOfNotReady = (int32_t)taosArrayGetSize(pNotReadyList);
numOfTimeout = (int32_t)taosArrayGetSize(pTimeoutList); numOfTimeout = (int32_t)taosArrayGetSize(pTimeoutList);
// fault tasks detected, not try anymore // fault tasks detected, not try anymore
ASSERT((numOfReady + numOfFault + numOfNotReady + numOfTimeout + numOfNotRsp) == total); bool jumpOut = false;
if ((numOfReady + numOfFault + numOfNotReady + numOfTimeout + numOfNotRsp) != total) {
int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1);
stError(
"s-task:%s vgId:%d internal error in handling the check downstream procedure, rsp number is inconsistent, "
"stop rspMonitor tmr, total:%d, notRsp:%d, notReady:%d, fault:%d, timeout:%d, ready:%d ref:%d",
id, vgId, total, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady, ref);
jumpOut = true;
}
if (numOfFault > 0) { if (numOfFault > 0) {
int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1);
stDebug( stDebug(
"s-task:%s status:%s vgId:%d all rsp. quit from monitor rsp tmr, since vnode-transfer/leader-change/restart " "s-task:%s status:%s vgId:%d all rsp. quit from monitor rsp tmr, since vnode-transfer/leader-change/restart "
"detected, total:%d, notRsp:%d, notReady:%d, fault:%d, timeout:%d, ready:%d ref:%d", "detected, total:%d, notRsp:%d, notReady:%d, fault:%d, timeout:%d, ready:%d ref:%d",
id, pStat.name, vgId, total, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady, ref); id, state.name, vgId, total, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady, ref);
jumpOut = true;
}
if (jumpOut) {
streamTaskCompleteCheckRsp(pInfo, false, id); streamTaskCompleteCheckRsp(pInfo, false, id);
streamMutexUnlock(&pInfo->checkInfoLock); streamMutexUnlock(&pInfo->checkInfoLock);
streamMetaReleaseTask(pMeta, pTask); streamMetaReleaseTask(pMeta, pTask);
@ -776,7 +789,7 @@ void rspMonitorFn(void* param, void* tmrId) {
return; return;
} }
} else { // unexpected status } else { // unexpected status
stError("s-task:%s unexpected task status:%s during waiting for check rsp", id, pStat.name); stError("s-task:%s unexpected task status:%s during waiting for check rsp", id, state.name);
} }
// checking of downstream tasks has been stopped by other threads // checking of downstream tasks has been stopped by other threads
@ -785,7 +798,7 @@ void rspMonitorFn(void* param, void* tmrId) {
stDebug( stDebug(
"s-task:%s status:%s vgId:%d stopped by other threads to check downstream process, total:%d, notRsp:%d, " "s-task:%s status:%s vgId:%d stopped by other threads to check downstream process, total:%d, notRsp:%d, "
"notReady:%d, fault:%d, timeout:%d, ready:%d ref:%d", "notReady:%d, fault:%d, timeout:%d, ready:%d ref:%d",
id, pStat.name, vgId, total, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady, ref); id, state.name, vgId, total, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady, ref);
streamTaskCompleteCheckRsp(pInfo, false, id); streamTaskCompleteCheckRsp(pInfo, false, id);
streamMutexUnlock(&pInfo->checkInfoLock); streamMutexUnlock(&pInfo->checkInfoLock);

View File

@ -254,7 +254,11 @@ static SStreamDispatchReq* createDispatchDataReq(SStreamTask* pTask, const SStre
int32_t type = pTask->outputInfo.type; int32_t type = pTask->outputInfo.type;
int32_t num = streamTaskGetNumOfDownstream(pTask); int32_t num = streamTaskGetNumOfDownstream(pTask);
ASSERT(type == TASK_OUTPUT__SHUFFLE_DISPATCH || type == TASK_OUTPUT__FIXED_DISPATCH); if(type != TASK_OUTPUT__SHUFFLE_DISPATCH && type != TASK_OUTPUT__FIXED_DISPATCH) {
terrno = TSDB_CODE_INVALID_PARA;
stError("s-task:%s invalid dispatch type:%d not dispatch data", pTask->id.idStr, type);
return NULL;
}
SStreamDispatchReq* pReqs = taosMemoryCalloc(num, sizeof(SStreamDispatchReq)); SStreamDispatchReq* pReqs = taosMemoryCalloc(num, sizeof(SStreamDispatchReq));
if (pReqs == NULL) { if (pReqs == NULL) {
@ -279,7 +283,7 @@ static SStreamDispatchReq* createDispatchDataReq(SStreamTask* pTask, const SStre
return NULL; return NULL;
} }
} }
} else { } else { // shuffle dispatch
int32_t numOfBlocks = taosArrayGetSize(pData->blocks); int32_t numOfBlocks = taosArrayGetSize(pData->blocks);
int32_t downstreamTaskId = pTask->outputInfo.fixedDispatcher.taskId; int32_t downstreamTaskId = pTask->outputInfo.fixedDispatcher.taskId;

View File

@ -65,9 +65,9 @@ static void streamMetaEnvInit() {
void streamMetaInit() { (void)taosThreadOnce(&streamMetaModuleInit, streamMetaEnvInit); } void streamMetaInit() { (void)taosThreadOnce(&streamMetaModuleInit, streamMetaEnvInit); }
void streamMetaCleanup() { void streamMetaCleanup() {
(void)taosCloseRef(streamBackendId); taosCloseRef(streamBackendId);
(void)taosCloseRef(streamBackendCfWrapperId); taosCloseRef(streamBackendCfWrapperId);
(void)taosCloseRef(streamMetaId); taosCloseRef(streamMetaId);
metaRefMgtCleanup(); metaRefMgtCleanup();
streamTimerCleanUp(); streamTimerCleanUp();

View File

@ -282,7 +282,6 @@ _end:
int32_t getSessionRowBuff(SStreamFileState* pFileState, void* pKey, int32_t keyLen, void** pVal, int32_t* pVLen, int32_t getSessionRowBuff(SStreamFileState* pFileState, void* pKey, int32_t keyLen, void** pVal, int32_t* pVLen,
int32_t* pWinCode) { int32_t* pWinCode) {
SWinKey* pTmpkey = pKey; SWinKey* pTmpkey = pKey;
ASSERT(keyLen == sizeof(SWinKey));
SSessionKey pWinKey = {.groupId = pTmpkey->groupId, .win.skey = pTmpkey->ts, .win.ekey = pTmpkey->ts}; SSessionKey pWinKey = {.groupId = pTmpkey->groupId, .win.skey = pTmpkey->ts, .win.ekey = pTmpkey->ts};
return getSessionWinResultBuff(pFileState, &pWinKey, 0, pVal, pVLen, pWinCode); return getSessionWinResultBuff(pFileState, &pWinKey, 0, pVal, pVLen, pWinCode);
} }
@ -455,7 +454,7 @@ int32_t allocSessioncWinBuffByNextPosition(SStreamFileState* pFileState, SStream
SSessionKey pTmpKey = *pWinKey; SSessionKey pTmpKey = *pWinKey;
int32_t winCode = TSDB_CODE_SUCCESS; int32_t winCode = TSDB_CODE_SUCCESS;
code = getSessionWinResultBuff(pFileState, &pTmpKey, 0, (void**)&pNewPos, pVLen, &winCode); code = getSessionWinResultBuff(pFileState, &pTmpKey, 0, (void**)&pNewPos, pVLen, &winCode);
ASSERT(winCode == TSDB_CODE_FAILED); QUERY_CHECK_CONDITION((winCode == TSDB_CODE_FAILED), code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
goto _end; goto _end;
} }

View File

@ -497,8 +497,11 @@ int32_t streamTaskOnHandleEventSuccess(SStreamTaskSM* pSM, EStreamTaskEvent even
STaskStateTrans* pTrans = pSM->pActiveTrans; STaskStateTrans* pTrans = pSM->pActiveTrans;
if (pTrans == NULL) { if (pTrans == NULL) {
ETaskStatus s = pSM->current.state; ETaskStatus s = pSM->current.state;
ASSERT(s == TASK_STATUS__DROPPING || s == TASK_STATUS__PAUSE || s == TASK_STATUS__STOP ||
s == TASK_STATUS__UNINIT || s == TASK_STATUS__READY); if (s != TASK_STATUS__DROPPING && s != TASK_STATUS__PAUSE && s != TASK_STATUS__STOP &&
s != TASK_STATUS__UNINIT && s != TASK_STATUS__READY) {
stError("s-task:%s invalid task status:%s on handling event:%s success", id, pSM->current.name, GET_EVT_NAME(pSM->prev.evt));
}
// the pSM->prev.evt may be 0, so print string is not appropriate. // the pSM->prev.evt may be 0, so print string is not appropriate.
stDebug("s-task:%s event:%s handled failed, current status:%s, trigger event:%s", id, GET_EVT_NAME(event), stDebug("s-task:%s event:%s handled failed, current status:%s, trigger event:%s", id, GET_EVT_NAME(event),

View File

@ -564,10 +564,7 @@ _end:
int32_t updateInfoDeserialize(void* buf, int32_t bufLen, SUpdateInfo* pInfo) { int32_t updateInfoDeserialize(void* buf, int32_t bufLen, SUpdateInfo* pInfo) {
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0; int32_t lino = 0;
if (pInfo == NULL) { QUERY_CHECK_NULL(pInfo, code, lino, _error, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
return TSDB_CODE_INVALID_PARA;
}
SDecoder decoder = {0}; SDecoder decoder = {0};
tDecoderInit(&decoder, buf, bufLen); tDecoderInit(&decoder, buf, bufLen);
if (tStartDecode(&decoder) < 0) return -1; if (tStartDecode(&decoder) < 0) return -1;
@ -575,6 +572,8 @@ int32_t updateInfoDeserialize(void* buf, int32_t bufLen, SUpdateInfo* pInfo) {
int32_t size = 0; int32_t size = 0;
if (tDecodeI32(&decoder, &size) < 0) return -1; if (tDecodeI32(&decoder, &size) < 0) return -1;
pInfo->pTsBuckets = taosArrayInit(size, sizeof(TSKEY)); pInfo->pTsBuckets = taosArrayInit(size, sizeof(TSKEY));
QUERY_CHECK_NULL(pInfo->pTsBuckets, code, lino, _error, terrno);
TSKEY ts = INT64_MIN; TSKEY ts = INT64_MIN;
for (int32_t i = 0; i < size; i++) { for (int32_t i = 0; i < size; i++) {
if (tDecodeI64(&decoder, &ts) < 0) return -1; if (tDecodeI64(&decoder, &ts) < 0) return -1;
@ -626,11 +625,8 @@ int32_t updateInfoDeserialize(void* buf, int32_t bufLen, SUpdateInfo* pInfo) {
code = taosHashPut(pInfo->pMap, &uid, sizeof(uint64_t), pVal, valSize); code = taosHashPut(pInfo->pMap, &uid, sizeof(uint64_t), pVal, valSize);
QUERY_CHECK_CODE(code, lino, _error); QUERY_CHECK_CODE(code, lino, _error);
} }
QUERY_CHECK_CONDITION((mapSize == taosHashGetSize(pInfo->pMap)), code, lino, _error,
if (mapSize != taosHashGetSize(pInfo->pMap)) { TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
return TSDB_CODE_INVALID_MSG;
}
if (tDecodeU64(&decoder, &pInfo->maxDataVersion) < 0) return -1; if (tDecodeU64(&decoder, &pInfo->maxDataVersion) < 0) return -1;
if (tDecodeI32(&decoder, &pInfo->pkColLen) < 0) return -1; if (tDecodeI32(&decoder, &pInfo->pkColLen) < 0) return -1;
@ -641,7 +637,6 @@ int32_t updateInfoDeserialize(void* buf, int32_t bufLen, SUpdateInfo* pInfo) {
if (pInfo->pkColLen != 0) { if (pInfo->pkColLen != 0) {
pInfo->comparePkRowFn = compareKeyTsAndPk; pInfo->comparePkRowFn = compareKeyTsAndPk;
pInfo->comparePkCol = getKeyComparFunc(pInfo->pkColType, TSDB_ORDER_ASC); pInfo->comparePkCol = getKeyComparFunc(pInfo->pkColType, TSDB_ORDER_ASC);
;
} else { } else {
pInfo->comparePkRowFn = compareKeyTs; pInfo->comparePkRowFn = compareKeyTs;
pInfo->comparePkCol = NULL; pInfo->comparePkCol = NULL;

View File

@ -125,7 +125,6 @@ static void streamFileStateEncode(TSKEY* pKey, void** pVal, int32_t* pLen) {
(*pVal) = taosMemoryCalloc(1, *pLen); (*pVal) = taosMemoryCalloc(1, *pLen);
void* buff = *pVal; void* buff = *pVal;
int32_t tmp = taosEncodeFixedI64(&buff, *pKey); int32_t tmp = taosEncodeFixedI64(&buff, *pKey);
ASSERT(tmp == sizeof(TSKEY));
} }
SStreamFileState* streamFileStateInit(int64_t memSize, uint32_t keySize, uint32_t rowSize, uint32_t selectRowSize, SStreamFileState* streamFileStateInit(int64_t memSize, uint32_t keySize, uint32_t rowSize, uint32_t selectRowSize,
@ -204,7 +203,7 @@ SStreamFileState* streamFileStateInit(int64_t memSize, uint32_t keySize, uint32_
int32_t len = 0; int32_t len = 0;
int32_t tmpRes = streamDefaultGet_rocksdb(pFileState->pFileStore, STREAM_STATE_INFO_NAME, &valBuf, &len); int32_t tmpRes = streamDefaultGet_rocksdb(pFileState->pFileStore, STREAM_STATE_INFO_NAME, &valBuf, &len);
if (tmpRes == TSDB_CODE_SUCCESS) { if (tmpRes == TSDB_CODE_SUCCESS) {
ASSERT(len == sizeof(TSKEY)); QUERY_CHECK_CONDITION((len == sizeof(TSKEY)), code, lino, _error, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
streamFileStateDecode(&pFileState->flushMark, valBuf, len); streamFileStateDecode(&pFileState->flushMark, valBuf, len);
qDebug("===stream===flushMark read:%" PRId64, pFileState->flushMark); qDebug("===stream===flushMark read:%" PRId64, pFileState->flushMark);
} }
@ -361,7 +360,7 @@ int32_t popUsedBuffs(SStreamFileState* pFileState, SStreamSnapshot* pFlushList,
SRowBuffPos* pPos = *(SRowBuffPos**)pNode->data; SRowBuffPos* pPos = *(SRowBuffPos**)pNode->data;
if (pPos->beUsed == used) { if (pPos->beUsed == used) {
if (used && !pPos->pRowBuff) { if (used && !pPos->pRowBuff) {
ASSERT(pPos->needFree == true); QUERY_CHECK_CONDITION((pPos->needFree == true), code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
continue; continue;
} }
code = tdListAppend(pFlushList, &pPos); code = tdListAppend(pFlushList, &pPos);
@ -496,13 +495,13 @@ _end:
code = tdListAppend(pFileState->usedBuffs, &pPos); code = tdListAppend(pFileState->usedBuffs, &pPos);
QUERY_CHECK_CODE(code, lino, _error); QUERY_CHECK_CODE(code, lino, _error);
QUERY_CHECK_CONDITION((pPos->pRowBuff != NULL), code, lino, _error, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
_error: _error:
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
return NULL; return NULL;
} }
ASSERT(pPos->pRowBuff != NULL);
return pPos; return pPos;
} }
@ -636,7 +635,7 @@ int32_t getRowBuffByPos(SStreamFileState* pFileState, SRowBuffPos* pPos, void**
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
pPos->pRowBuff = getFreeBuff(pFileState); pPos->pRowBuff = getFreeBuff(pFileState);
} }
ASSERT(pPos->pRowBuff); QUERY_CHECK_CONDITION((pPos->pRowBuff != NULL), code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
} }
code = recoverSessionRowBuff(pFileState, pPos); code = recoverSessionRowBuff(pFileState, pPos);
@ -877,7 +876,10 @@ void recoverSnapshot(SStreamFileState* pFileState, int64_t ckId) {
taosMemoryFreeClear(pVal); taosMemoryFreeClear(pVal);
break; break;
} }
ASSERT(vlen == pFileState->rowSize); if (vlen != pFileState->rowSize) {
code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
QUERY_CHECK_CODE(code, lino, _end);
}
memcpy(pNewPos->pRowBuff, pVal, vlen); memcpy(pNewPos->pRowBuff, pVal, vlen);
taosMemoryFreeClear(pVal); taosMemoryFreeClear(pVal);
pNewPos->beFlushed = true; pNewPos->beFlushed = true;

View File

@ -23,29 +23,12 @@ extern "C" {
#include "syncInt.h" #include "syncInt.h"
#define TIMER_MAX_MS 0x7FFFFFFF #define TIMER_MAX_MS 0x7FFFFFFF
#define ENV_TICK_TIMER_MS 1000
#define PING_TIMER_MS 5000 #define PING_TIMER_MS 5000
#define ELECT_TIMER_MS_MIN 2500
#define HEARTBEAT_TIMER_MS 1000
#define HEARTBEAT_TICK_NUM 20 #define HEARTBEAT_TICK_NUM 20
typedef struct SSyncEnv { typedef struct SSyncEnv {
uint8_t isStart; uint8_t isStart;
tmr_h pTimerManager;
// tick timer
tmr_h pEnvTickTimer;
int32_t envTickTimerMS;
uint64_t envTickTimerLogicClock; // if use queue, should pass logic clock into queue item
uint64_t envTickTimerLogicClockUser;
TAOS_TMR_CALLBACK FpEnvTickTimer; // Timer Fp
uint64_t envTickTimerCounter;
// timer manager
tmr_h pTimerManager;
// other resources shared by SyncNodes
// ...
} SSyncEnv; } SSyncEnv;
SSyncEnv* syncEnv(); SSyncEnv* syncEnv();

View File

@ -24,7 +24,6 @@ extern "C" {
int32_t syncWriteCfgFile(SSyncNode *pNode); int32_t syncWriteCfgFile(SSyncNode *pNode);
int32_t syncReadCfgFile(SSyncNode *pNode); int32_t syncReadCfgFile(SSyncNode *pNode);
int32_t syncAddCfgIndex(SSyncNode *pNode, SyncIndex cfgIndex);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -75,8 +75,6 @@ int32_t syncUtilElectRandomMS(int32_t min, int32_t max);
int32_t syncUtilQuorum(int32_t replicaNum); int32_t syncUtilQuorum(int32_t replicaNum);
const char* syncStr(ESyncState state); const char* syncStr(ESyncState state);
void syncUtilMsgHtoN(void* msg); void syncUtilMsgHtoN(void* msg);
bool syncUtilUserPreCommit(tmsg_t msgType);
bool syncUtilUserRollback(tmsg_t msgType);
void syncUtilGenerateArbToken(int32_t nodeId, int32_t groupId, char* buf); void syncUtilGenerateArbToken(int32_t nodeId, int32_t groupId, char* buf);
@ -109,7 +107,7 @@ void syncLogRecvAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntries* pMs
void syncLogSendAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntries* pMsg, const char* s); void syncLogSendAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntries* pMsg, const char* s);
void syncLogRecvRequestVote(SSyncNode* pSyncNode, const SyncRequestVote* pMsg, int32_t voteGranted, const char* s); void syncLogRecvRequestVote(SSyncNode* pSyncNode, const SyncRequestVote* pMsg, int32_t voteGranted, const char* s);
void syncLogSendRequestVote(SSyncNode* pNode, const SyncRequestVote* pMsg, const char* s); void syncLogSendRequestVote(SSyncNode* pSyncNode, const SyncRequestVote* pMsg, const char* s);
void syncLogRecvRequestVoteReply(SSyncNode* pSyncNode, const SyncRequestVoteReply* pMsg, const char* s); void syncLogRecvRequestVoteReply(SSyncNode* pSyncNode, const SyncRequestVoteReply* pMsg, const char* s);
void syncLogSendRequestVoteReply(SSyncNode* pSyncNode, const SyncRequestVoteReply* pMsg, const char* s); void syncLogSendRequestVoteReply(SSyncNode* pSyncNode, const SyncRequestVoteReply* pMsg, const char* s);

View File

@ -21,7 +21,6 @@
static SSyncEnv gSyncEnv = {0}; static SSyncEnv gSyncEnv = {0};
static int32_t gNodeRefId = -1; static int32_t gNodeRefId = -1;
static int32_t gHbDataRefId = -1; static int32_t gHbDataRefId = -1;
static void syncEnvTick(void *param, void *tmrId);
SSyncEnv *syncEnv() { return &gSyncEnv; } SSyncEnv *syncEnv() { return &gSyncEnv; }
@ -33,67 +32,69 @@ int32_t syncInit() {
uint32_t seed = (uint32_t)(taosGetTimestampNs() & 0x00000000FFFFFFFF); uint32_t seed = (uint32_t)(taosGetTimestampNs() & 0x00000000FFFFFFFF);
taosSeedRand(seed); taosSeedRand(seed);
memset(&gSyncEnv, 0, sizeof(SSyncEnv)); (void)memset(&gSyncEnv, 0, sizeof(SSyncEnv));
gSyncEnv.envTickTimerCounter = 0;
gSyncEnv.envTickTimerMS = ENV_TICK_TIMER_MS;
gSyncEnv.FpEnvTickTimer = syncEnvTick;
atomic_store_64(&gSyncEnv.envTickTimerLogicClock, 0);
atomic_store_64(&gSyncEnv.envTickTimerLogicClockUser, 0);
// start tmr thread
gSyncEnv.pTimerManager = taosTmrInit(1000, 50, 10000, "SYNC-ENV"); gSyncEnv.pTimerManager = taosTmrInit(1000, 50, 10000, "SYNC-ENV");
atomic_store_8(&gSyncEnv.isStart, 1);
gNodeRefId = taosOpenRef(200, (RefFp)syncNodeClose); gNodeRefId = taosOpenRef(200, (RefFp)syncNodeClose);
if (gNodeRefId < 0) { if (gNodeRefId < 0) {
sError("failed to init node ref"); sError("failed to init node rset");
syncCleanUp(); syncCleanUp();
return TSDB_CODE_SYN_WRONG_REF; return TSDB_CODE_SYN_WRONG_REF;
} }
sDebug("sync node rset is open, rsetId:%d", gNodeRefId);
gHbDataRefId = taosOpenRef(200, (RefFp)syncHbTimerDataFree); gHbDataRefId = taosOpenRef(200, (RefFp)syncHbTimerDataFree);
if (gHbDataRefId < 0) { if (gHbDataRefId < 0) {
sError("failed to init hb-data ref"); sError("failed to init hbdata rset");
syncCleanUp(); syncCleanUp();
return TSDB_CODE_SYN_WRONG_REF; return TSDB_CODE_SYN_WRONG_REF;
} }
sDebug("sync rsetId:%d is open", gNodeRefId); sDebug("sync hbdata rset is open, rsetId:%d", gHbDataRefId);
atomic_store_8(&gSyncEnv.isStart, 1);
return 0; return 0;
} }
void syncCleanUp() { void syncCleanUp() {
atomic_store_8(&gSyncEnv.isStart, 0); atomic_store_8(&gSyncEnv.isStart, 0);
taosTmrCleanUp(gSyncEnv.pTimerManager); taosTmrCleanUp(gSyncEnv.pTimerManager);
memset(&gSyncEnv, 0, sizeof(SSyncEnv)); (void)memset(&gSyncEnv, 0, sizeof(SSyncEnv));
if (gNodeRefId != -1) { if (gNodeRefId != -1) {
sDebug("sync rsetId:%d is closed", gNodeRefId); sDebug("sync node rset is closed, rsetId:%d", gNodeRefId);
(void)taosCloseRef(gNodeRefId); taosCloseRef(gNodeRefId);
gNodeRefId = -1; gNodeRefId = -1;
} }
if (gHbDataRefId != -1) { if (gHbDataRefId != -1) {
sDebug("sync rsetId:%d is closed", gHbDataRefId); sDebug("sync hbdata rset is closed, rsetId:%d", gHbDataRefId);
(void)taosCloseRef(gHbDataRefId); taosCloseRef(gHbDataRefId);
gHbDataRefId = -1; gHbDataRefId = -1;
} }
} }
int64_t syncNodeAdd(SSyncNode *pNode) { int64_t syncNodeAdd(SSyncNode *pNode) {
pNode->rid = taosAddRef(gNodeRefId, pNode); pNode->rid = taosAddRef(gNodeRefId, pNode);
if (pNode->rid < 0) return -1; if (pNode->rid < 0) {
return terrno = TSDB_CODE_SYN_WRONG_REF;
}
sDebug("vgId:%d, sync rid:%" PRId64 " is added to rsetId:%d", pNode->vgId, pNode->rid, gNodeRefId); sDebug("vgId:%d, sync node refId:%" PRId64 " is added to rsetId:%d", pNode->vgId, pNode->rid, gNodeRefId);
return pNode->rid; return pNode->rid;
} }
void syncNodeRemove(int64_t rid) { (void)taosRemoveRef(gNodeRefId, rid); } void syncNodeRemove(int64_t rid) {
sDebug("sync node refId:%" PRId64 " is removed from rsetId:%d", rid, gNodeRefId);
if (rid > 0) {
(void)taosRemoveRef(gNodeRefId, rid);
}
}
SSyncNode *syncNodeAcquire(int64_t rid) { SSyncNode *syncNodeAcquire(int64_t rid) {
SSyncNode *pNode = taosAcquireRef(gNodeRefId, rid); SSyncNode *pNode = taosAcquireRef(gNodeRefId, rid);
if (pNode == NULL) { if (pNode == NULL) {
sError("failed to acquire node from refId:%" PRId64, rid); sError("failed to acquire sync node from refId:%" PRId64 ", rsetId:%d", rid, gNodeRefId);
terrno = TSDB_CODE_SYN_INTERNAL_ERROR; terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
} }
@ -101,62 +102,38 @@ SSyncNode *syncNodeAcquire(int64_t rid) {
} }
void syncNodeRelease(SSyncNode *pNode) { void syncNodeRelease(SSyncNode *pNode) {
if (pNode) (void)taosReleaseRef(gNodeRefId, pNode->rid); if (pNode) {
(void)taosReleaseRef(gNodeRefId, pNode->rid);
}
} }
int64_t syncHbTimerDataAdd(SSyncHbTimerData *pData) { int64_t syncHbTimerDataAdd(SSyncHbTimerData *pData) {
pData->rid = taosAddRef(gHbDataRefId, pData); pData->rid = taosAddRef(gHbDataRefId, pData);
if (pData->rid < 0) return TSDB_CODE_SYN_WRONG_REF; if (pData->rid < 0) {
return terrno = TSDB_CODE_SYN_WRONG_REF;
}
return pData->rid; return pData->rid;
} }
void syncHbTimerDataRemove(int64_t rid) { (void)taosRemoveRef(gHbDataRefId, rid); } void syncHbTimerDataRemove(int64_t rid) {
if (rid > 0) {
(void)taosRemoveRef(gHbDataRefId, rid);
}
}
SSyncHbTimerData *syncHbTimerDataAcquire(int64_t rid) { SSyncHbTimerData *syncHbTimerDataAcquire(int64_t rid) {
SSyncHbTimerData *pData = taosAcquireRef(gHbDataRefId, rid); SSyncHbTimerData *pData = taosAcquireRef(gHbDataRefId, rid);
if (pData == NULL && rid > 0) { if (pData == NULL && rid > 0) {
sInfo("failed to acquire hb-timer-data from refId:%" PRId64, rid); sInfo("failed to acquire hbdata from refId:%" PRId64 ", rsetId:%d", rid, gHbDataRefId);
terrno = TSDB_CODE_SYN_INTERNAL_ERROR; terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
} }
return pData; return pData;
} }
void syncHbTimerDataRelease(SSyncHbTimerData *pData) { (void)taosReleaseRef(gHbDataRefId, pData->rid); } void syncHbTimerDataRelease(SSyncHbTimerData *pData) {
if (pData) {
#if 0 (void)taosReleaseRef(gHbDataRefId, pData->rid);
void syncEnvStartTimer() {
taosTmrReset(gSyncEnv.FpEnvTickTimer, gSyncEnv.envTickTimerMS, &gSyncEnv, gSyncEnv.pTimerManager,
&gSyncEnv.pEnvTickTimer);
atomic_store_64(&gSyncEnv.envTickTimerLogicClock, gSyncEnv.envTickTimerLogicClockUser);
}
void syncEnvStopTimer() {
int32_t ret = 0;
atomic_add_fetch_64(&gSyncEnv.envTickTimerLogicClockUser, 1);
taosTmrStop(gSyncEnv.pEnvTickTimer);
gSyncEnv.pEnvTickTimer = NULL;
return ret;
}
#endif
static void syncEnvTick(void *param, void *tmrId) {
#if 0
SSyncEnv *pSyncEnv = param;
if (atomic_load_64(&gSyncEnv.envTickTimerLogicClockUser) <= atomic_load_64(&gSyncEnv.envTickTimerLogicClock)) {
gSyncEnv.envTickTimerCounter++;
sTrace("syncEnvTick do ... envTickTimerLogicClockUser:%" PRIu64 ", envTickTimerLogicClock:%" PRIu64
", envTickTimerCounter:%" PRIu64 ", envTickTimerMS:%d, tmrId:%p",
gSyncEnv.envTickTimerLogicClockUser, gSyncEnv.envTickTimerLogicClock, gSyncEnv.envTickTimerCounter,
gSyncEnv.envTickTimerMS, tmrId);
// do something, tick ...
taosTmrReset(syncEnvTick, gSyncEnv.envTickTimerMS, pSyncEnv, gSyncEnv.pTimerManager, &gSyncEnv.pEnvTickTimer);
} else {
sTrace("syncEnvTick pass ... envTickTimerLogicClockUser:%" PRIu64 ", envTickTimerLogicClock:%" PRIu64
", envTickTimerCounter:%" PRIu64 ", envTickTimerMS:%d, tmrId:%p",
gSyncEnv.envTickTimerLogicClockUser, gSyncEnv.envTickTimerLogicClock, gSyncEnv.envTickTimerCounter,
gSyncEnv.envTickTimerMS, tmrId);
} }
#endif
} }

View File

@ -50,7 +50,7 @@ static int32_t syncHbTimerStart(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer);
static int32_t syncHbTimerStop(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer); static int32_t syncHbTimerStop(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer);
static int32_t syncNodeUpdateNewConfigIndex(SSyncNode* ths, SSyncCfg* pNewCfg); static int32_t syncNodeUpdateNewConfigIndex(SSyncNode* ths, SSyncCfg* pNewCfg);
static bool syncNodeInConfig(SSyncNode* pSyncNode, const SSyncCfg* config); static bool syncNodeInConfig(SSyncNode* pSyncNode, const SSyncCfg* config);
static void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* newConfig, SyncIndex lastConfigChangeIndex); static int32_t syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* newConfig, SyncIndex lastConfigChangeIndex);
static bool syncNodeIsOptimizedOneReplica(SSyncNode* ths, SRpcMsg* pMsg); static bool syncNodeIsOptimizedOneReplica(SSyncNode* ths, SRpcMsg* pMsg);
static bool syncNodeCanChange(SSyncNode* pSyncNode); static bool syncNodeCanChange(SSyncNode* pSyncNode);
@ -182,7 +182,12 @@ int32_t syncReconfig(int64_t rid, SSyncCfg* pNewCfg) {
} }
TAOS_CHECK_RETURN(syncNodeUpdateNewConfigIndex(pSyncNode, pNewCfg)); TAOS_CHECK_RETURN(syncNodeUpdateNewConfigIndex(pSyncNode, pNewCfg));
syncNodeDoConfigChange(pSyncNode, pNewCfg, pNewCfg->lastIndex);
if (syncNodeDoConfigChange(pSyncNode, pNewCfg, pNewCfg->lastIndex) != 0) {
code = TSDB_CODE_SYN_NEW_CONFIG_ERROR;
sError("vgId:%d, failed to reconfig since do change error", pSyncNode->vgId);
TAOS_RETURN(code);
}
if (pSyncNode->state == TAOS_SYNC_STATE_LEADER || pSyncNode->state == TAOS_SYNC_STATE_ASSIGNED_LEADER) { if (pSyncNode->state == TAOS_SYNC_STATE_LEADER || pSyncNode->state == TAOS_SYNC_STATE_ASSIGNED_LEADER) {
// TODO check return value // TODO check return value
@ -1015,7 +1020,7 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo, int32_t vnodeVersion) {
if (!taosDirExist((char*)(pSyncInfo->path))) { if (!taosDirExist((char*)(pSyncInfo->path))) {
if (taosMkDir(pSyncInfo->path) != 0) { if (taosMkDir(pSyncInfo->path) != 0) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
sError("failed to create dir:%s since %s", pSyncInfo->path, terrstr()); sError("vgId:%d, failed to create dir:%s since %s", pSyncInfo->vgId, pSyncInfo->path, terrstr());
goto _error; goto _error;
} }
} }
@ -1108,37 +1113,6 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo, int32_t vnodeVersion) {
goto _error; goto _error;
} }
// init internal
pSyncNode->myNodeInfo = pSyncNode->raftCfg.cfg.nodeInfo[pSyncNode->raftCfg.cfg.myIndex];
if (!syncUtilNodeInfo2RaftId(&pSyncNode->myNodeInfo, pSyncNode->vgId, &pSyncNode->myRaftId)) {
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
sError("vgId:%d, failed to determine my raft member id", pSyncNode->vgId);
goto _error;
}
pSyncNode->arbTerm = -1;
(void)taosThreadMutexInit(&pSyncNode->arbTokenMutex, NULL);
syncUtilGenerateArbToken(pSyncNode->myNodeInfo.nodeId, pSyncInfo->vgId, pSyncNode->arbToken);
sInfo("vgId:%d, arb token:%s", pSyncNode->vgId, pSyncNode->arbToken);
// init peersNum, peers, peersId
pSyncNode->peersNum = pSyncNode->raftCfg.cfg.totalReplicaNum - 1;
int32_t j = 0;
for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.totalReplicaNum; ++i) {
if (i != pSyncNode->raftCfg.cfg.myIndex) {
pSyncNode->peersNodeInfo[j] = pSyncNode->raftCfg.cfg.nodeInfo[i];
syncUtilNodeInfo2EpSet(&pSyncNode->peersNodeInfo[j], &pSyncNode->peersEpset[j]);
j++;
}
}
for (int32_t i = 0; i < pSyncNode->peersNum; ++i) {
if (!syncUtilNodeInfo2RaftId(&pSyncNode->peersNodeInfo[i], pSyncNode->vgId, &pSyncNode->peersId[i])) {
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
sError("vgId:%d, failed to determine raft member id, peer:%d", pSyncNode->vgId, i);
goto _error;
}
}
// init replicaNum, replicasId // init replicaNum, replicasId
pSyncNode->replicaNum = pSyncNode->raftCfg.cfg.replicaNum; pSyncNode->replicaNum = pSyncNode->raftCfg.cfg.replicaNum;
pSyncNode->totalReplicaNum = pSyncNode->raftCfg.cfg.totalReplicaNum; pSyncNode->totalReplicaNum = pSyncNode->raftCfg.cfg.totalReplicaNum;
@ -1150,6 +1124,27 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo, int32_t vnodeVersion) {
} }
} }
// init internal
pSyncNode->myNodeInfo = pSyncNode->raftCfg.cfg.nodeInfo[pSyncNode->raftCfg.cfg.myIndex];
pSyncNode->myRaftId = pSyncNode->replicasId[pSyncNode->raftCfg.cfg.myIndex];
// init peersNum, peers, peersId
pSyncNode->peersNum = pSyncNode->raftCfg.cfg.totalReplicaNum - 1;
int32_t j = 0;
for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.totalReplicaNum; ++i) {
if (i != pSyncNode->raftCfg.cfg.myIndex) {
pSyncNode->peersNodeInfo[j] = pSyncNode->raftCfg.cfg.nodeInfo[i];
pSyncNode->peersId[j] = pSyncNode->replicasId[i];
syncUtilNodeInfo2EpSet(&pSyncNode->peersNodeInfo[j], &pSyncNode->peersEpset[j]);
j++;
}
}
pSyncNode->arbTerm = -1;
(void)taosThreadMutexInit(&pSyncNode->arbTokenMutex, NULL);
syncUtilGenerateArbToken(pSyncNode->myNodeInfo.nodeId, pSyncInfo->vgId, pSyncNode->arbToken);
sInfo("vgId:%d, generate arb token:%s", pSyncNode->vgId, pSyncNode->arbToken);
// init raft algorithm // init raft algorithm
pSyncNode->pFsm = pSyncInfo->pFsm; pSyncNode->pFsm = pSyncInfo->pFsm;
pSyncInfo->pFsm = NULL; pSyncInfo->pFsm = NULL;
@ -1766,11 +1761,11 @@ static bool syncIsConfigChanged(const SSyncCfg* pOldCfg, const SSyncCfg* pNewCfg
return false; return false;
} }
void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncIndex lastConfigChangeIndex) { int32_t syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncIndex lastConfigChangeIndex) {
SSyncCfg oldConfig = pSyncNode->raftCfg.cfg; SSyncCfg oldConfig = pSyncNode->raftCfg.cfg;
if (!syncIsConfigChanged(&oldConfig, pNewConfig)) { if (!syncIsConfigChanged(&oldConfig, pNewConfig)) {
sInfo("vgId:1, sync not reconfig since not changed"); sInfo("vgId:1, sync not reconfig since not changed");
return; return 0;
} }
pSyncNode->raftCfg.cfg = *pNewConfig; pSyncNode->raftCfg.cfg = *pNewConfig;
@ -1809,7 +1804,15 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde
} }
// add last config index // add last config index
(void)syncAddCfgIndex(pSyncNode, lastConfigChangeIndex); SRaftCfg* pCfg = &pSyncNode->raftCfg;
if (pCfg->configIndexCount >= MAX_CONFIG_INDEX_COUNT) {
sNError(pSyncNode, "failed to add cfg index:%d since out of range", pCfg->configIndexCount);
terrno = TSDB_CODE_OUT_OF_RANGE;
return -1;
}
pCfg->configIndexArr[pCfg->configIndexCount] = lastConfigChangeIndex;
pCfg->configIndexCount++;
if (IamInNew) { if (IamInNew) {
//----------------------------------------- //-----------------------------------------
@ -1924,6 +1927,7 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde
_END: _END:
// log end config change // log end config change
sNInfo(pSyncNode, "end do config change, from %d to %d", oldConfig.totalReplicaNum, pNewConfig->totalReplicaNum); sNInfo(pSyncNode, "end do config change, from %d to %d", oldConfig.totalReplicaNum, pNewConfig->totalReplicaNum);
return 0;
} }
// raft state change -------------- // raft state change --------------

View File

@ -18,7 +18,7 @@
#include "syncUtil.h" #include "syncUtil.h"
#include "tjson.h" #include "tjson.h"
const char *syncRoleToStr(ESyncRole role) { static const char *syncRoleToStr(ESyncRole role) {
switch (role) { switch (role) {
case TAOS_SYNC_ROLE_VOTER: case TAOS_SYNC_ROLE_VOTER:
return "true"; return "true";
@ -29,15 +29,14 @@ const char *syncRoleToStr(ESyncRole role) {
} }
} }
const ESyncRole syncStrToRole(char *str) { static const ESyncRole syncStrToRole(char *str) {
if (strcmp(str, "true") == 0) { if (strcmp(str, "true") == 0) {
return TAOS_SYNC_ROLE_VOTER; return TAOS_SYNC_ROLE_VOTER;
} } else if (strcmp(str, "false") == 0) {
if (strcmp(str, "false") == 0) {
return TAOS_SYNC_ROLE_LEARNER; return TAOS_SYNC_ROLE_LEARNER;
} else {
return TAOS_SYNC_ROLE_ERROR;
} }
return TAOS_SYNC_ROLE_ERROR;
} }
static int32_t syncEncodeSyncCfg(const void *pObj, SJson *pJson) { static int32_t syncEncodeSyncCfg(const void *pObj, SJson *pJson) {
@ -52,10 +51,12 @@ static int32_t syncEncodeSyncCfg(const void *pObj, SJson *pJson) {
if (nodeInfo == NULL) { if (nodeInfo == NULL) {
TAOS_CHECK_EXIT(TSDB_CODE_OUT_OF_MEMORY); TAOS_CHECK_EXIT(TSDB_CODE_OUT_OF_MEMORY);
} }
if ((code = tjsonAddItemToObject(pJson, "nodeInfo", nodeInfo)) < 0) { if ((code = tjsonAddItemToObject(pJson, "nodeInfo", nodeInfo)) < 0) {
tjsonDelete(nodeInfo); tjsonDelete(nodeInfo);
TAOS_CHECK_EXIT(code); TAOS_CHECK_EXIT(code);
} }
for (int32_t i = 0; i < pCfg->totalReplicaNum; ++i) { for (int32_t i = 0; i < pCfg->totalReplicaNum; ++i) {
SJson *info = tjsonCreateObject(); SJson *info = tjsonCreateObject();
if (info == NULL) { if (info == NULL) {
@ -68,20 +69,25 @@ static int32_t syncEncodeSyncCfg(const void *pObj, SJson *pJson) {
TAOS_CHECK_GOTO(tjsonAddStringToObject(info, "isReplica", syncRoleToStr(pCfg->nodeInfo[i].nodeRole)), NULL, _err); TAOS_CHECK_GOTO(tjsonAddStringToObject(info, "isReplica", syncRoleToStr(pCfg->nodeInfo[i].nodeRole)), NULL, _err);
TAOS_CHECK_GOTO(tjsonAddItemToArray(nodeInfo, info), NULL, _err); TAOS_CHECK_GOTO(tjsonAddItemToArray(nodeInfo, info), NULL, _err);
continue; continue;
_err: _err:
tjsonDelete(info); tjsonDelete(info);
break; break;
} }
_exit: _exit:
if (code < 0) { if (code < 0) {
sError("failed to encode sync cfg at line %d since %s", lino, tstrerror(code)); sError("failed to encode sync cfg at line %d since %s", lino, tstrerror(code));
} }
TAOS_RETURN(code); TAOS_RETURN(code);
} }
static int32_t syncEncodeRaftCfg(const void *pObj, SJson *pJson) { static int32_t syncEncodeRaftCfg(const void *pObj, SJson *pJson) {
SRaftCfg *pCfg = (SRaftCfg *)pObj; SRaftCfg *pCfg = (SRaftCfg *)pObj;
int32_t code = 0, lino = 0; int32_t code = 0;
int32_t lino = 0;
TAOS_CHECK_EXIT(tjsonAddObject(pJson, "SSyncCfg", syncEncodeSyncCfg, (void *)&pCfg->cfg)); TAOS_CHECK_EXIT(tjsonAddObject(pJson, "SSyncCfg", syncEncodeSyncCfg, (void *)&pCfg->cfg));
TAOS_CHECK_EXIT(tjsonAddDoubleToObject(pJson, "isStandBy", pCfg->isStandBy)); TAOS_CHECK_EXIT(tjsonAddDoubleToObject(pJson, "isStandBy", pCfg->isStandBy));
TAOS_CHECK_EXIT(tjsonAddDoubleToObject(pJson, "snapshotStrategy", pCfg->snapshotStrategy)); TAOS_CHECK_EXIT(tjsonAddDoubleToObject(pJson, "snapshotStrategy", pCfg->snapshotStrategy));
@ -93,10 +99,12 @@ static int32_t syncEncodeRaftCfg(const void *pObj, SJson *pJson) {
if (configIndexArr == NULL) { if (configIndexArr == NULL) {
TAOS_CHECK_EXIT(TSDB_CODE_OUT_OF_MEMORY); TAOS_CHECK_EXIT(TSDB_CODE_OUT_OF_MEMORY);
} }
if ((code = tjsonAddItemToObject(pJson, "configIndexArr", configIndexArr)) < 0) { if ((code = tjsonAddItemToObject(pJson, "configIndexArr", configIndexArr)) < 0) {
tjsonDelete(configIndexArr); tjsonDelete(configIndexArr);
TAOS_CHECK_EXIT(code); TAOS_CHECK_EXIT(code);
} }
for (int32_t i = 0; i < pCfg->configIndexCount; ++i) { for (int32_t i = 0; i < pCfg->configIndexCount; ++i) {
SJson *configIndex = tjsonCreateObject(); SJson *configIndex = tjsonCreateObject();
if (configIndex == NULL) { if (configIndex == NULL) {
@ -105,14 +113,17 @@ static int32_t syncEncodeRaftCfg(const void *pObj, SJson *pJson) {
TAOS_CHECK_EXIT(tjsonAddIntegerToObject(configIndex, "index", pCfg->configIndexArr[i])); TAOS_CHECK_EXIT(tjsonAddIntegerToObject(configIndex, "index", pCfg->configIndexArr[i]));
TAOS_CHECK_EXIT(tjsonAddItemToArray(configIndexArr, configIndex)); TAOS_CHECK_EXIT(tjsonAddItemToArray(configIndexArr, configIndex));
continue; continue;
_err: _err:
tjsonDelete(configIndex); tjsonDelete(configIndex);
break; break;
} }
_exit: _exit:
if (code < 0) { if (code < 0) {
sError("failed to encode raft cfg at line %d since %s", lino, tstrerror(code)); sError("failed to encode raft cfg at line %d since %s", lino, tstrerror(code));
} }
TAOS_RETURN(code); TAOS_RETURN(code);
} }
@ -124,11 +135,13 @@ int32_t syncWriteCfgFile(SSyncNode *pNode) {
const char *realfile = pNode->configPath; const char *realfile = pNode->configPath;
SRaftCfg *pCfg = &pNode->raftCfg; SRaftCfg *pCfg = &pNode->raftCfg;
char file[PATH_MAX] = {0}; char file[PATH_MAX] = {0};
(void)snprintf(file, sizeof(file), "%s.bak", realfile); (void)snprintf(file, sizeof(file), "%s.bak", realfile);
if ((pJson = tjsonCreateObject()) == NULL) { if ((pJson = tjsonCreateObject()) == NULL) {
TAOS_CHECK_EXIT(TSDB_CODE_OUT_OF_MEMORY); TAOS_CHECK_EXIT(TSDB_CODE_OUT_OF_MEMORY);
} }
TAOS_CHECK_EXIT(tjsonAddObject(pJson, "RaftCfg", syncEncodeRaftCfg, pCfg)); TAOS_CHECK_EXIT(tjsonAddObject(pJson, "RaftCfg", syncEncodeRaftCfg, pCfg));
buffer = tjsonToString(pJson); buffer = tjsonToString(pJson);
if (buffer == NULL) { if (buffer == NULL) {
@ -145,6 +158,7 @@ int32_t syncWriteCfgFile(SSyncNode *pNode) {
if (taosWriteFile(pFile, buffer, len) <= 0) { if (taosWriteFile(pFile, buffer, len) <= 0) {
TAOS_CHECK_EXIT(TAOS_SYSTEM_ERROR(errno)); TAOS_CHECK_EXIT(TAOS_SYSTEM_ERROR(errno));
} }
if (taosFsyncFile(pFile) < 0) { if (taosFsyncFile(pFile) < 0) {
TAOS_CHECK_EXIT(TAOS_SYSTEM_ERROR(errno)); TAOS_CHECK_EXIT(TAOS_SYSTEM_ERROR(errno));
} }
@ -165,6 +179,7 @@ _exit:
if (code != 0) { if (code != 0) {
sError("vgId:%d, failed to write sync cfg file:%s since %s", pNode->vgId, realfile, tstrerror(code)); sError("vgId:%d, failed to write sync cfg file:%s since %s", pNode->vgId, realfile, tstrerror(code));
} }
TAOS_RETURN(code); TAOS_RETURN(code);
} }
@ -232,6 +247,7 @@ static int32_t syncDecodeRaftCfg(const SJson *pJson, void *pObj) {
tjsonGetNumberValue(configIndex, "index", pCfg->configIndexArr[i], code); tjsonGetNumberValue(configIndex, "index", pCfg->configIndexArr[i], code);
if (code < 0) return TSDB_CODE_INVALID_JSON_FORMAT; if (code < 0) return TSDB_CODE_INVALID_JSON_FORMAT;
} }
return 0; return 0;
} }
@ -292,16 +308,6 @@ _OVER:
if (code != 0) { if (code != 0) {
sError("vgId:%d, failed to read sync cfg file:%s since %s", pNode->vgId, file, tstrerror(code)); sError("vgId:%d, failed to read sync cfg file:%s since %s", pNode->vgId, file, tstrerror(code));
} }
TAOS_RETURN(code); TAOS_RETURN(code);
} }
int32_t syncAddCfgIndex(SSyncNode *pNode, SyncIndex cfgIndex) {
SRaftCfg *pCfg = &pNode->raftCfg;
if (pCfg->configIndexCount >= MAX_CONFIG_INDEX_COUNT) {
return TSDB_CODE_OUT_OF_RANGE;
}
pCfg->configIndexArr[pCfg->configIndexCount] = cfgIndex;
pCfg->configIndexCount++;
return 0;
}

View File

@ -23,7 +23,7 @@
#include "syncSnapshot.h" #include "syncSnapshot.h"
#include "tglobal.h" #include "tglobal.h"
void syncCfg2SimpleStr(const SSyncCfg* pCfg, char* buf, int32_t bufLen) { static void syncCfg2SimpleStr(const SSyncCfg* pCfg, char* buf, int32_t bufLen) {
int32_t len = snprintf(buf, bufLen, "{num:%d, as:%d, [", pCfg->replicaNum, pCfg->myIndex); int32_t len = snprintf(buf, bufLen, "{num:%d, as:%d, [", pCfg->replicaNum, pCfg->myIndex);
for (int32_t i = 0; i < pCfg->replicaNum; ++i) { for (int32_t i = 0; i < pCfg->replicaNum; ++i) {
len += snprintf(buf + len, bufLen - len, "%s:%d", pCfg->nodeInfo[i].nodeFqdn, pCfg->nodeInfo[i].nodePort); len += snprintf(buf + len, bufLen - len, "%s:%d", pCfg->nodeInfo[i].nodeFqdn, pCfg->nodeInfo[i].nodePort);
@ -43,14 +43,11 @@ void syncUtilNodeInfo2EpSet(const SNodeInfo* pInfo, SEpSet* pEpSet) {
bool syncUtilNodeInfo2RaftId(const SNodeInfo* pInfo, SyncGroupId vgId, SRaftId* raftId) { bool syncUtilNodeInfo2RaftId(const SNodeInfo* pInfo, SyncGroupId vgId, SRaftId* raftId) {
uint32_t ipv4 = 0xFFFFFFFF; uint32_t ipv4 = 0xFFFFFFFF;
sDebug( sDebug("vgId:%d, resolve sync addr from fqdn, ep:%s:%u", vgId, pInfo->nodeFqdn, pInfo->nodePort);
"vgId:%d, start to resolve sync addr fqdn in %d seconds, " for (int32_t i = 0; i < tsResolveFQDNRetryTime; i++) {
"dnode:%d cluster:%" PRId64 " fqdn:%s port:%u ",
vgId, tsResolveFQDNRetryTime, pInfo->nodeId, pInfo->clusterId, pInfo->nodeFqdn, pInfo->nodePort);
for (int i = 0; i < tsResolveFQDNRetryTime; i++) {
int32_t code = taosGetIpv4FromFqdn(pInfo->nodeFqdn, &ipv4); int32_t code = taosGetIpv4FromFqdn(pInfo->nodeFqdn, &ipv4);
if (code) { if (code) {
sError("failed to resolve ipv4 addr, fqdn:%s, wait one second", pInfo->nodeFqdn); sError("vgId:%d, failed to resolve sync addr, dnode:%d fqdn:%s, retry", vgId, pInfo->nodeId, pInfo->nodeFqdn);
taosSsleep(1); taosSsleep(1);
} else { } else {
break; break;
@ -58,7 +55,7 @@ bool syncUtilNodeInfo2RaftId(const SNodeInfo* pInfo, SyncGroupId vgId, SRaftId*
} }
if (ipv4 == 0xFFFFFFFF || ipv4 == 1) { if (ipv4 == 0xFFFFFFFF || ipv4 == 1) {
sError("failed to resolve ipv4 addr, fqdn:%s", pInfo->nodeFqdn); sError("vgId:%d, failed to resolve sync addr, dnode:%d fqdn:%s", vgId, pInfo->nodeId, pInfo->nodeFqdn);
terrno = TSDB_CODE_TSC_INVALID_FQDN; terrno = TSDB_CODE_TSC_INVALID_FQDN;
return false; return false;
} }
@ -68,14 +65,20 @@ bool syncUtilNodeInfo2RaftId(const SNodeInfo* pInfo, SyncGroupId vgId, SRaftId*
raftId->addr = SYNC_ADDR(pInfo); raftId->addr = SYNC_ADDR(pInfo);
raftId->vgId = vgId; raftId->vgId = vgId;
sInfo("vgId:%d, sync addr:%" PRIu64 ", dnode:%d cluster:%" PRId64 " fqdn:%s ip:%s port:%u ipv4:%u", vgId, sInfo("vgId:%d, sync addr:%" PRIu64 " is resolved, ep:%s:%u ip:%s ipv4:%u dnode:%d cluster:%" PRId64, vgId,
raftId->addr, pInfo->nodeId, pInfo->clusterId, pInfo->nodeFqdn, ipbuf, pInfo->nodePort, ipv4); raftId->addr, pInfo->nodeFqdn, pInfo->nodePort, ipbuf, ipv4, pInfo->nodeId, pInfo->clusterId);
return true; return true;
} }
bool syncUtilSameId(const SRaftId* pId1, const SRaftId* pId2) { bool syncUtilSameId(const SRaftId* pId1, const SRaftId* pId2) {
if (pId1->addr == pId2->addr && pId1->vgId == pId2->vgId) return true; if (pId1->addr == pId2->addr && pId1->vgId == pId2->vgId) {
if ((CID(pId1) == 0 || CID(pId2) == 0) && (DID(pId1) == DID(pId2)) && pId1->vgId == pId2->vgId) return true; return true;
}
if ((CID(pId1) == 0 || CID(pId2) == 0) && (DID(pId1) == DID(pId2)) && pId1->vgId == pId2->vgId) {
return true;
}
return false; return false;
} }
@ -98,10 +101,6 @@ void syncUtilMsgHtoN(void* msg) {
pHead->vgId = htonl(pHead->vgId); pHead->vgId = htonl(pHead->vgId);
} }
bool syncUtilUserPreCommit(tmsg_t msgType) { return msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_LEADER_TRANSFER; }
bool syncUtilUserRollback(tmsg_t msgType) { return msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_LEADER_TRANSFER; }
void syncUtilGenerateArbToken(int32_t nodeId, int32_t groupId, char* buf) { void syncUtilGenerateArbToken(int32_t nodeId, int32_t groupId, char* buf) {
(void)memset(buf, 0, TSDB_ARB_TOKEN_SIZE); (void)memset(buf, 0, TSDB_ARB_TOKEN_SIZE);
int32_t randVal = taosSafeRand() % 1000; int32_t randVal = taosSafeRand() % 1000;
@ -142,18 +141,18 @@ static void syncLogBufferStates2Str(SSyncNode* pSyncNode, char* buf, int32_t buf
if (pBuf == NULL) { if (pBuf == NULL) {
return; return;
} }
int len = 0; int32_t len = 0;
len += snprintf(buf + len, bufLen - len, "[%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", pBuf->startIndex, len += snprintf(buf + len, bufLen - len, "[%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", pBuf->startIndex,
pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex);
} }
static void syncLogReplStates2Str(SSyncNode* pSyncNode, char* buf, int32_t bufLen) { static void syncLogReplStates2Str(SSyncNode* pSyncNode, char* buf, int32_t bufLen) {
int len = 0; int32_t len = 0;
len += snprintf(buf + len, bufLen - len, "%s", "{"); len += snprintf(buf + len, bufLen - len, "%s", "{");
for (int32_t i = 0; i < pSyncNode->replicaNum; i++) { for (int32_t i = 0; i < pSyncNode->replicaNum; i++) {
SSyncLogReplMgr* pMgr = pSyncNode->logReplMgrs[i]; SSyncLogReplMgr* pMgr = pSyncNode->logReplMgrs[i];
if (pMgr == NULL) break; if (pMgr == NULL) break;
len += snprintf(buf + len, bufLen - len, "%d:%d [%" PRId64 " %" PRId64 ", %" PRId64 ")", i, pMgr->restored, len += snprintf(buf + len, bufLen - len, "%d:%d [%" PRId64 " %" PRId64 ", %" PRId64 "]", i, pMgr->restored,
pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex); pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex);
if (i + 1 < pSyncNode->replicaNum) { if (i + 1 < pSyncNode->replicaNum) {
len += snprintf(buf + len, bufLen - len, "%s", ", "); len += snprintf(buf + len, bufLen - len, "%s", ", ");
@ -280,7 +279,7 @@ void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dfla
" end:%" PRId64 " last-index:%" PRId64 " last-term:%" PRId64 " last-cfg:%" PRId64 " end:%" PRId64 " last-index:%" PRId64 " last-term:%" PRId64 " last-cfg:%" PRId64
", seq:%d, ack:%d, " ", seq:%d, ack:%d, "
" buf:[%" PRId64 " %" PRId64 ", %" PRId64 " buf:[%" PRId64 " %" PRId64 ", %" PRId64
"), finish:%d, as:%d, to-dnode:%d}" "], finish:%d, as:%d, to-dnode:%d}"
", term:%" PRIu64 ", commit-index:%" PRId64 ", firstver:%" PRId64 ", lastver:%" PRId64 ", term:%" PRIu64 ", commit-index:%" PRId64 ", firstver:%" PRId64 ", lastver:%" PRId64
", min-match:%" PRId64 ", snap:{last-index:%" PRId64 ", term:%" PRIu64 ", min-match:%" PRId64 ", snap:{last-index:%" PRId64 ", term:%" PRIu64
"}, standby:%d, batch-sz:%d, replicas:%d, last-cfg:%" PRId64 "}, standby:%d, batch-sz:%d, replicas:%d, last-cfg:%" PRId64

View File

@ -2302,7 +2302,7 @@ static FORCE_INLINE void destroyCmsgAndAhandle(void* param) {
pThrd->destroyAhandleFp(pMsg->ctx->ahandle); pThrd->destroyAhandleFp(pMsg->ctx->ahandle);
} }
if (pMsg->msg.info.handle !=0) { if (pMsg->msg.info.handle != 0) {
(void)transReleaseExHandle(transGetRefMgt(), (int64_t)pMsg->msg.info.handle); (void)transReleaseExHandle(transGetRefMgt(), (int64_t)pMsg->msg.info.handle);
(void)transRemoveExHandle(transGetRefMgt(), (int64_t)pMsg->msg.info.handle); (void)transRemoveExHandle(transGetRefMgt(), (int64_t)pMsg->msg.info.handle);
} }
@ -2957,6 +2957,7 @@ int32_t transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, S
STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle); STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle);
if (pTransInst == NULL) { if (pTransInst == NULL) {
transFreeMsg(pReq->pCont); transFreeMsg(pReq->pCont);
pReq->pCont = NULL;
return TSDB_CODE_RPC_MODULE_QUIT; return TSDB_CODE_RPC_MODULE_QUIT;
} }
int32_t code = 0; int32_t code = 0;
@ -3008,6 +3009,7 @@ int32_t transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, S
_exception: _exception:
transFreeMsg(pReq->pCont); transFreeMsg(pReq->pCont);
pReq->pCont = NULL;
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); (void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
return code; return code;
} }
@ -3053,6 +3055,7 @@ int32_t transSendRequestWithId(void* shandle, const SEpSet* pEpSet, STransMsg* p
_exception: _exception:
transFreeMsg(pReq->pCont); transFreeMsg(pReq->pCont);
pReq->pCont = NULL;
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); (void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
return code; return code;
} }
@ -3061,6 +3064,7 @@ int32_t transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STra
STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle); STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle);
if (pTransInst == NULL) { if (pTransInst == NULL) {
transFreeMsg(pReq->pCont); transFreeMsg(pReq->pCont);
pReq->pCont = NULL;
return TSDB_CODE_RPC_MODULE_QUIT; return TSDB_CODE_RPC_MODULE_QUIT;
} }
int32_t code = 0; int32_t code = 0;
@ -3139,6 +3143,7 @@ _RETURN1:
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); (void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
taosMemoryFree(pTransRsp); taosMemoryFree(pTransRsp);
taosMemoryFree(pReq->pCont); taosMemoryFree(pReq->pCont);
pReq->pCont = NULL;
return code; return code;
} }
int32_t transCreateSyncMsg(STransMsg* pTransMsg, int64_t* refId) { int32_t transCreateSyncMsg(STransMsg* pTransMsg, int64_t* refId) {
@ -3183,6 +3188,7 @@ int32_t transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pReq,
STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle); STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle);
if (pTransInst == NULL) { if (pTransInst == NULL) {
transFreeMsg(pReq->pCont); transFreeMsg(pReq->pCont);
pReq->pCont = NULL;
return TSDB_CODE_RPC_MODULE_QUIT; return TSDB_CODE_RPC_MODULE_QUIT;
} }
@ -3263,6 +3269,7 @@ _RETURN:
return code; return code;
_RETURN2: _RETURN2:
transFreeMsg(pReq->pCont); transFreeMsg(pReq->pCont);
pReq->pCont = NULL;
taosMemoryFree(pTransMsg); taosMemoryFree(pTransMsg);
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); (void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
return code; return code;

View File

@ -736,7 +736,7 @@ int32_t transOpenRefMgt(int size, void (*func)(void*)) {
} }
void transCloseRefMgt(int32_t mgt) { void transCloseRefMgt(int32_t mgt) {
// close ref // close ref
(void)taosCloseRef(mgt); taosCloseRef(mgt);
} }
int64_t transAddExHandle(int32_t refMgt, void* p) { int64_t transAddExHandle(int32_t refMgt, void* p) {
// acquire extern handle // acquire extern handle

View File

@ -75,7 +75,7 @@ void walCleanUp() {
if (old == 1) { if (old == 1) {
walStopThread(); walStopThread();
TAOS_UNUSED(taosCloseRef(tsWal.refSetId)); taosCloseRef(tsWal.refSetId);
wInfo("wal module is cleaned up"); wInfo("wal module is cleaned up");
atomic_store_8(&tsWal.inited, 0); atomic_store_8(&tsWal.inited, 0);
} }

View File

@ -252,7 +252,7 @@ int32_t l2ComressInitImpl_xz(char *lossyColumns, float fPrecision, double dPreci
} }
int32_t l2CompressImpl_xz(const char *const input, const int32_t inputSize, char *const output, int32_t outputSize, int32_t l2CompressImpl_xz(const char *const input, const int32_t inputSize, char *const output, int32_t outputSize,
const char type, int8_t lvl) { const char type, int8_t lvl) {
size_t len = 0;//FL2_compress(output + 1, outputSize - 1, input, inputSize, lvl); size_t len = FL2_compress(output + 1, outputSize - 1, input, inputSize, lvl);
if (len > inputSize) { if (len > inputSize) {
output[0] = 0; output[0] = 0;
memcpy(output + 1, input, inputSize); memcpy(output + 1, input, inputSize);
@ -264,7 +264,7 @@ int32_t l2CompressImpl_xz(const char *const input, const int32_t inputSize, char
int32_t l2DecompressImpl_xz(const char *const input, const int32_t compressedSize, char *const output, int32_t l2DecompressImpl_xz(const char *const input, const int32_t compressedSize, char *const output,
int32_t outputSize, const char type) { int32_t outputSize, const char type) {
if (input[0] == 1) { if (input[0] == 1) {
return 0;//FL2_decompress(output, outputSize, input + 1, compressedSize - 1); return FL2_decompress(output, outputSize, input + 1, compressedSize - 1);
} else if (input[0] == 0) { } else if (input[0] == 0) {
memcpy(output, input + 1, compressedSize - 1); memcpy(output, input + 1, compressedSize - 1);
return compressedSize - 1; return compressedSize - 1;

View File

@ -478,6 +478,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_WINDOW_CONDITION, "The time pseudo colum
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR, "Executor internal error") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR, "Executor internal error")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_JOIN_CONDITION, "Not supported join on condition") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_JOIN_CONDITION, "Not supported join on condition")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_FILTER_NOT_SUPPORT_TYPE, "Not supported range type") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_FILTER_NOT_SUPPORT_TYPE, "Not supported range type")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_FILTER_WRONG_OPTR_TYPE, "Wrong operator type")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_FILTER_RANGE_ERROR, "Wrong filter range")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_FILTER_INVALID_TYPE, "Invalid filter type")
// grant // grant
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, "License expired") TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, "License expired")
@ -724,6 +727,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_TIME_UNIT_TOO_SMALL, "Function time unit c
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_INVALID_VALUE_RANGE, "Function got invalid value range") TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_INVALID_VALUE_RANGE, "Function got invalid value range")
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_SETUP_ERROR, "Function set up failed") TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_SETUP_ERROR, "Function set up failed")
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_INVALID_RES_LENGTH, "Function result exceed max length") TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_INVALID_RES_LENGTH, "Function result exceed max length")
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_HISTOGRAM_ERROR, "Function failed to calculate histogram")
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_PERCENTILE_ERROR, "Function failed to calculate percentile")
//udf //udf
TAOS_DEFINE_ERROR(TSDB_CODE_UDF_STOPPING, "udf is stopping") TAOS_DEFINE_ERROR(TSDB_CODE_UDF_STOPPING, "udf is stopping")
@ -737,6 +742,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_UDF_INVALID_OUTPUT_TYPE, "udf invalid output
TAOS_DEFINE_ERROR(TSDB_CODE_UDF_SCRIPT_NOT_SUPPORTED, "udf program language not supported") TAOS_DEFINE_ERROR(TSDB_CODE_UDF_SCRIPT_NOT_SUPPORTED, "udf program language not supported")
TAOS_DEFINE_ERROR(TSDB_CODE_UDF_FUNC_EXEC_FAILURE, "udf function execution failure") TAOS_DEFINE_ERROR(TSDB_CODE_UDF_FUNC_EXEC_FAILURE, "udf function execution failure")
TAOS_DEFINE_ERROR(TSDB_CODE_UDF_UV_EXEC_FAILURE, "udf uvlib function execution failure") TAOS_DEFINE_ERROR(TSDB_CODE_UDF_UV_EXEC_FAILURE, "udf uvlib function execution failure")
TAOS_DEFINE_ERROR(TSDB_CODE_UDF_INTERNAL_ERROR, "udf internal error")
//schemaless //schemaless
TAOS_DEFINE_ERROR(TSDB_CODE_SML_INVALID_PROTOCOL_TYPE, "Invalid line protocol type") TAOS_DEFINE_ERROR(TSDB_CODE_SML_INVALID_PROTOCOL_TYPE, "Invalid line protocol type")

View File

@ -110,13 +110,13 @@ int32_t taosOpenRef(int32_t max, RefFp fp) {
return rsetId; return rsetId;
} }
int32_t taosCloseRef(int32_t rsetId) { void taosCloseRef(int32_t rsetId) {
SRefSet *pSet; SRefSet *pSet;
int32_t deleted = 0; int32_t deleted = 0;
if (rsetId < 0 || rsetId >= TSDB_REF_OBJECTS) { if (rsetId < 0 || rsetId >= TSDB_REF_OBJECTS) {
uTrace("rsetId:%d is invalid, out of range", rsetId); uTrace("rsetId:%d is invalid, out of range", rsetId);
return terrno = TSDB_CODE_REF_INVALID_ID; return;
} }
pSet = tsRefSetList + rsetId; pSet = tsRefSetList + rsetId;
@ -134,8 +134,6 @@ int32_t taosCloseRef(int32_t rsetId) {
(void)taosThreadMutexUnlock(&tsRefMutex); (void)taosThreadMutexUnlock(&tsRefMutex);
if (deleted) taosDecRsetCount(pSet); if (deleted) taosDecRsetCount(pSet);
return 0;
} }
int64_t taosAddRef(int32_t rsetId, void *p) { int64_t taosAddRef(int32_t rsetId, void *p) {

View File

@ -71,8 +71,7 @@ int32_t tScalableBfPutNoCheck(SScalableBf* pSBf, const void* keyBuf, uint32_t le
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0; int32_t lino = 0;
if (pSBf->status == SBF_INVALID) { if (pSBf->status == SBF_INVALID) {
code = TSDB_CODE_OUT_OF_BUFFER; return code;
QUERY_CHECK_CODE(code, lino, _error);
} }
int32_t size = taosArrayGetSize(pSBf->bfArray); int32_t size = taosArrayGetSize(pSBf->bfArray);
SBloomFilter* pNormalBf = taosArrayGetP(pSBf->bfArray, size - 1); SBloomFilter* pNormalBf = taosArrayGetP(pSBf->bfArray, size - 1);
@ -85,6 +84,10 @@ int32_t tScalableBfPutNoCheck(SScalableBf* pSBf, const void* keyBuf, uint32_t le
pNormalBf->errorRate * DEFAULT_TIGHTENING_RATIO, &pNormalBf); pNormalBf->errorRate * DEFAULT_TIGHTENING_RATIO, &pNormalBf);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
pSBf->status = SBF_INVALID; pSBf->status = SBF_INVALID;
if (code == TSDB_CODE_OUT_OF_BUFFER) {
code = TSDB_CODE_SUCCESS;
return code;
}
QUERY_CHECK_CODE(code, lino, _error); QUERY_CHECK_CODE(code, lino, _error);
} }
} }
@ -101,8 +104,8 @@ int32_t tScalableBfPut(SScalableBf* pSBf, const void* keyBuf, uint32_t len, int3
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0; int32_t lino = 0;
if (pSBf->status == SBF_INVALID) { if (pSBf->status == SBF_INVALID) {
code = TSDB_CODE_OUT_OF_BUFFER; (*winRes) = TSDB_CODE_FAILED;
QUERY_CHECK_CODE(code, lino, _end); return code;
} }
uint64_t h1 = (uint64_t)pSBf->hashFn1(keyBuf, len); uint64_t h1 = (uint64_t)pSBf->hashFn1(keyBuf, len);
uint64_t h2 = (uint64_t)pSBf->hashFn2(keyBuf, len); uint64_t h2 = (uint64_t)pSBf->hashFn2(keyBuf, len);
@ -121,6 +124,11 @@ int32_t tScalableBfPut(SScalableBf* pSBf, const void* keyBuf, uint32_t len, int3
pNormalBf->errorRate * DEFAULT_TIGHTENING_RATIO, &pNormalBf); pNormalBf->errorRate * DEFAULT_TIGHTENING_RATIO, &pNormalBf);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
pSBf->status = SBF_INVALID; pSBf->status = SBF_INVALID;
if (code == TSDB_CODE_OUT_OF_BUFFER) {
code = TSDB_CODE_SUCCESS;
(*winRes) = TSDB_CODE_FAILED;
goto _end;
}
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
} }
} }

View File

@ -21,6 +21,30 @@ sql create dnode $hostname4 port 7500
sleep 1000 sleep 1000
$loop_count = 0
loop00:
sleep 1000
$loop_count = $loop_count + 1
if $loop_count == 20 then
return -1
endi
print 0 show cluster alive;
sql show cluster alive;
print res------------------------
print $data00 $data01
print $data10 $data11
if $data00 != 1 then
print =====data00=$data00
goto loop00
endi
print =============== create database, stable, table print =============== create database, stable, table
sql create database test vgroups 6; sql create database test vgroups 6;
sql use test; sql use test;
@ -46,6 +70,15 @@ endi
print show cluster alive; print show cluster alive;
sql show cluster alive; sql show cluster alive;
print res------------------------
print $data00 $data01
print $data10 $data11
if $rows != 1 then
print =====rows=$rows
goto loop0
endi
if $data00 != 1 then if $data00 != 1 then
print =====data00=$data00 print =====data00=$data00
goto loop0 goto loop0
@ -54,6 +87,15 @@ endi
print show test.alive; print show test.alive;
sql show test.alive; sql show test.alive;
print res------------------------
print $data00 $data01
print $data10 $data11
if $rows != 1 then
print =====rows=$rows
goto loop0
endi
if $data00 != 1 then if $data00 != 1 then
print =====data00=$data00 print =====data00=$data00
goto loop0 goto loop0

View File

@ -1,3 +1,5 @@
./test.sh -f tsim/query/timeline.sim
./test.sh -f tsim/join/join.sim
./test.sh -f tsim/tmq/basic2Of2ConsOverlap.sim ./test.sh -f tsim/tmq/basic2Of2ConsOverlap.sim
./test.sh -f tsim/parser/where.sim ./test.sh -f tsim/parser/where.sim
./test.sh -f tsim/parser/join_manyblocks.sim ./test.sh -f tsim/parser/join_manyblocks.sim
@ -150,6 +152,7 @@
./test.sh -f tsim/parser/join_multivnode.sim ./test.sh -f tsim/parser/join_multivnode.sim
./test.sh -f tsim/parser/join.sim ./test.sh -f tsim/parser/join.sim
./test.sh -f tsim/parser/last_cache.sim ./test.sh -f tsim/parser/last_cache.sim
./test.sh -f tsim/parser/last_both.sim
./test.sh -f tsim/parser/last_groupby.sim ./test.sh -f tsim/parser/last_groupby.sim
./test.sh -f tsim/parser/lastrow.sim ./test.sh -f tsim/parser/lastrow.sim
./test.sh -f tsim/parser/lastrow2.sim ./test.sh -f tsim/parser/lastrow2.sim
@ -192,6 +195,7 @@
./test.sh -f tsim/query/session.sim ./test.sh -f tsim/query/session.sim
./test.sh -f tsim/query/join_interval.sim ./test.sh -f tsim/query/join_interval.sim
./test.sh -f tsim/query/join_pk.sim ./test.sh -f tsim/query/join_pk.sim
./test.sh -f tsim/query/join_order.sim
./test.sh -f tsim/query/count_spread.sim ./test.sh -f tsim/query/count_spread.sim
./test.sh -f tsim/query/unionall_as_table.sim ./test.sh -f tsim/query/unionall_as_table.sim
./test.sh -f tsim/query/multi_order_by.sim ./test.sh -f tsim/query/multi_order_by.sim
@ -214,6 +218,9 @@
./test.sh -f tsim/query/bug3398.sim ./test.sh -f tsim/query/bug3398.sim
./test.sh -f tsim/query/explain_tsorder.sim ./test.sh -f tsim/query/explain_tsorder.sim
./test.sh -f tsim/query/apercentile.sim ./test.sh -f tsim/query/apercentile.sim
./test.sh -f tsim/query/query_count0.sim
./test.sh -f tsim/query/query_count_sliding0.sim
./test.sh -f tsim/query/union_precision.sim
./test.sh -f tsim/qnode/basic1.sim ./test.sh -f tsim/qnode/basic1.sim
./test.sh -f tsim/snode/basic1.sim ./test.sh -f tsim/snode/basic1.sim
./test.sh -f tsim/mnode/basic1.sim ./test.sh -f tsim/mnode/basic1.sim
@ -287,9 +294,6 @@
./test.sh -f tsim/sma/tsmaCreateInsertQuery.sim ./test.sh -f tsim/sma/tsmaCreateInsertQuery.sim
./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim ./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim
./test.sh -f tsim/sma/rsmaCreateInsertQueryDelete.sim ./test.sh -f tsim/sma/rsmaCreateInsertQueryDelete.sim
### refactor stream backend, open case after rsma refactored
#./test.sh -f tsim/sma/rsmaPersistenceRecovery.sim
./test.sh -f tsim/sync/vnodesnapshot-rsma-test.sim ./test.sh -f tsim/sync/vnodesnapshot-rsma-test.sim
./test.sh -f tsim/valgrind/checkError1.sim ./test.sh -f tsim/valgrind/checkError1.sim
./test.sh -f tsim/valgrind/checkError2.sim ./test.sh -f tsim/valgrind/checkError2.sim
@ -326,6 +330,7 @@
./test.sh -f tsim/compress/commitlog.sim ./test.sh -f tsim/compress/commitlog.sim
./test.sh -f tsim/compress/compress2.sim ./test.sh -f tsim/compress/compress2.sim
./test.sh -f tsim/compress/compress.sim ./test.sh -f tsim/compress/compress.sim
./test.sh -f tsim/compress/compress_col.sim
./test.sh -f tsim/compress/uncompress.sim ./test.sh -f tsim/compress/uncompress.sim
./test.sh -f tsim/compute/avg.sim ./test.sh -f tsim/compute/avg.sim
./test.sh -f tsim/compute/block_dist.sim ./test.sh -f tsim/compute/block_dist.sim
@ -401,8 +406,9 @@
./test.sh -f tsim/tag/tbNameIn.sim ./test.sh -f tsim/tag/tbNameIn.sim
./test.sh -f tmp/monitor.sim ./test.sh -f tmp/monitor.sim
./test.sh -f tsim/tagindex/add_index.sim ./test.sh -f tsim/tagindex/add_index.sim
./test.sh -f tsim/tagindex/indexOverflow.sim
./test.sh -f tsim/tagindex/sma_and_tag_index.sim ./test.sh -f tsim/tagindex/sma_and_tag_index.sim
./test.sh -f tsim/tagindex/indexOverflow.sim
./test.sh -f tsim/view/view.sim ./test.sh -f tsim/view/view.sim
./test.sh -f tsim/query/cache_last.sim ./test.sh -f tsim/query/cache_last.sim
./test.sh -f tsim/query/const.sim ./test.sh -f tsim/query/const.sim
./test.sh -f tsim/query/nestedJoinView.sim

View File

@ -1,5 +1,13 @@
python3 ./test.py -f 2-query/pk_error.py
python3 ./test.py -f 2-query/pk_func.py
python3 ./test.py -f 2-query/pk_varchar.py
python3 ./test.py -f 2-query/pk_func_group.py
python3 ./test.py -f 2-query/partition_expr.py
python3 ./test.py -f 2-query/project_group.py
python3 ./test.py -f 2-query/tbname_vgroup.py python3 ./test.py -f 2-query/tbname_vgroup.py
python3 ./test.py -f 2-query/count_interval.py
python3 ./test.py -f 2-query/compact-col.py python3 ./test.py -f 2-query/compact-col.py
python3 ./test.py -f 2-query/tms_memleak.py
python3 ./test.py -f 2-query/stbJoin.py python3 ./test.py -f 2-query/stbJoin.py
python3 ./test.py -f 2-query/stbJoin.py -Q 2 python3 ./test.py -f 2-query/stbJoin.py -Q 2
python3 ./test.py -f 2-query/stbJoin.py -Q 3 python3 ./test.py -f 2-query/stbJoin.py -Q 3
@ -8,6 +16,8 @@ python3 ./test.py -f 2-query/hint.py
python3 ./test.py -f 2-query/hint.py -Q 2 python3 ./test.py -f 2-query/hint.py -Q 2
python3 ./test.py -f 2-query/hint.py -Q 3 python3 ./test.py -f 2-query/hint.py -Q 3
python3 ./test.py -f 2-query/hint.py -Q 4 python3 ./test.py -f 2-query/hint.py -Q 4
python3 ./test.py -f 2-query/para_tms.py
python3 ./test.py -f 2-query/para_tms2.py
python3 ./test.py -f 2-query/nestedQuery.py python3 ./test.py -f 2-query/nestedQuery.py
python3 ./test.py -f 2-query/nestedQuery_str.py python3 ./test.py -f 2-query/nestedQuery_str.py
python3 ./test.py -f 2-query/nestedQuery_math.py python3 ./test.py -f 2-query/nestedQuery_math.py
@ -52,6 +62,20 @@ python3 ./test.py -f 2-query/last_cache_scan.py
python3 ./test.py -f 2-query/last_cache_scan.py -Q 2 python3 ./test.py -f 2-query/last_cache_scan.py -Q 2
python3 ./test.py -f 2-query/last_cache_scan.py -Q 3 python3 ./test.py -f 2-query/last_cache_scan.py -Q 3
python3 ./test.py -f 2-query/last_cache_scan.py -Q 4 python3 ./test.py -f 2-query/last_cache_scan.py -Q 4
python3 ./test.py -f 2-query/tbname.py
python3 ./test.py -f 2-query/tbname.py -Q 2
python3 ./test.py -f 2-query/tbname.py -Q 3
python3 ./test.py -f 2-query/tbname.py -Q 4
python3 ./test.py -f 2-query/tsma.py
python3 ./test.py -f 2-query/tsma.py -R
python3 ./test.py -f 2-query/tsma.py -Q 2
python3 ./test.py -f 2-query/tsma.py -Q 3
python3 ./test.py -f 2-query/tsma.py -Q 4
python3 ./test.py -f 2-query/tsma2.py
python3 ./test.py -f 2-query/tsma2.py -R
python3 ./test.py -f 2-query/tsma2.py -Q 2
python3 ./test.py -f 2-query/tsma2.py -Q 3
python3 ./test.py -f 2-query/tsma2.py -Q 4
python3 ./test.py -f 7-tmq/tmqShow.py python3 ./test.py -f 7-tmq/tmqShow.py
python3 ./test.py -f 7-tmq/tmqDropStb.py python3 ./test.py -f 7-tmq/tmqDropStb.py
python3 ./test.py -f 7-tmq/subscribeStb0.py python3 ./test.py -f 7-tmq/subscribeStb0.py
@ -67,11 +91,14 @@ python3 ./test.py -f 7-tmq/tmqClientConsLog.py
python3 ./test.py -f 7-tmq/tmqMaxGroupIds.py python3 ./test.py -f 7-tmq/tmqMaxGroupIds.py
python3 ./test.py -f 7-tmq/tmqConsumeDiscontinuousData.py python3 ./test.py -f 7-tmq/tmqConsumeDiscontinuousData.py
python3 ./test.py -f 7-tmq/tmqOffset.py python3 ./test.py -f 7-tmq/tmqOffset.py
python3 ./test.py -f 7-tmq/tmq_primary_key.py
python3 ./test.py -f 7-tmq/tmqDropConsumer.py python3 ./test.py -f 7-tmq/tmqDropConsumer.py
python3 ./test.py -f 1-insert/insert_stb.py python3 ./test.py -f 1-insert/insert_stb.py
python3 ./test.py -f 1-insert/delete_stable.py python3 ./test.py -f 1-insert/delete_stable.py
python3 ./test.py -f 1-insert/stt_blocks_check.py
python3 ./test.py -f 2-query/out_of_order.py -Q 3 python3 ./test.py -f 2-query/out_of_order.py -Q 3
python3 ./test.py -f 2-query/out_of_order.py python3 ./test.py -f 2-query/out_of_order.py
python3 ./test.py -f 2-query/agg_null.py
python3 ./test.py -f 2-query/insert_null_none.py python3 ./test.py -f 2-query/insert_null_none.py
python3 ./test.py -f 2-query/insert_null_none.py -R python3 ./test.py -f 2-query/insert_null_none.py -R
python3 ./test.py -f 2-query/insert_null_none.py -Q 2 python3 ./test.py -f 2-query/insert_null_none.py -Q 2
@ -108,6 +135,18 @@ python3 ./test.py -f 2-query/match.py
python3 ./test.py -f 2-query/match.py -Q 2 python3 ./test.py -f 2-query/match.py -Q 2
python3 ./test.py -f 2-query/match.py -Q 3 python3 ./test.py -f 2-query/match.py -Q 3
python3 ./test.py -f 2-query/match.py -Q 4 python3 ./test.py -f 2-query/match.py -Q 4
python3 ./test.py -f 2-query/td-28068.py
python3 ./test.py -f 2-query/td-28068.py -Q 2
python3 ./test.py -f 2-query/td-28068.py -Q 3
python3 ./test.py -f 2-query/td-28068.py -Q 4
python3 ./test.py -f 2-query/agg_group_AlwaysReturnValue.py
python3 ./test.py -f 2-query/agg_group_AlwaysReturnValue.py -Q 2
python3 ./test.py -f 2-query/agg_group_AlwaysReturnValue.py -Q 3
python3 ./test.py -f 2-query/agg_group_AlwaysReturnValue.py -Q 4
python3 ./test.py -f 2-query/agg_group_NotReturnValue.py
python3 ./test.py -f 2-query/agg_group_NotReturnValue.py -Q 2
python3 ./test.py -f 2-query/agg_group_NotReturnValue.py -Q 3
python3 ./test.py -f 2-query/agg_group_NotReturnValue.py -Q 4
python3 ./test.py -f 3-enterprise/restore/restoreDnode.py -N 5 -M 3 -i False python3 ./test.py -f 3-enterprise/restore/restoreDnode.py -N 5 -M 3 -i False
python3 ./test.py -f 3-enterprise/restore/restoreVnode.py -N 5 -M 3 -i False python3 ./test.py -f 3-enterprise/restore/restoreVnode.py -N 5 -M 3 -i False
python3 ./test.py -f 3-enterprise/restore/restoreMnode.py -N 5 -M 3 -i False python3 ./test.py -f 3-enterprise/restore/restoreMnode.py -N 5 -M 3 -i False
@ -158,7 +197,8 @@ python3 ./test.py -f 7-tmq/tmqDropNtb-snapshot1.py
python3 ./test.py -f 7-tmq/stbTagFilter-1ctb.py python3 ./test.py -f 7-tmq/stbTagFilter-1ctb.py
python3 ./test.py -f 7-tmq/dataFromTsdbNWal.py python3 ./test.py -f 7-tmq/dataFromTsdbNWal.py
python3 ./test.py -f 7-tmq/dataFromTsdbNWal-multiCtb.py python3 ./test.py -f 7-tmq/dataFromTsdbNWal-multiCtb.py
# python3 ./test.py -f 7-tmq/tmq_taosx.py python3 ./test.py -f 7-tmq/tmq_taosx.py
python3 ./test.py -f 7-tmq/tmq_ts4563.py
python3 ./test.py -f 7-tmq/tmq_replay.py python3 ./test.py -f 7-tmq/tmq_replay.py
python3 ./test.py -f 7-tmq/tmqSeekAndCommit.py python3 ./test.py -f 7-tmq/tmqSeekAndCommit.py
python3 ./test.py -f 7-tmq/tmq_offset.py python3 ./test.py -f 7-tmq/tmq_offset.py
@ -168,15 +208,21 @@ python3 ./test.py -f 7-tmq/stbTagFilter-multiCtb.py
python3 ./test.py -f 7-tmq/tmqSubscribeStb-r3.py -N 5 python3 ./test.py -f 7-tmq/tmqSubscribeStb-r3.py -N 5
python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 6 -M 3 -i True python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 6 -M 3 -i True
python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 6 -M 3 -n 3 -i True python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 6 -M 3 -n 3 -i True
python3 test.py -f 7-tmq/tmqVnodeTransform-db-removewal.py -N 2 -n 1
python3 test.py -f 7-tmq/tmqVnodeTransform-stb-removewal.py -N 6 -n 3
python3 test.py -f 7-tmq/tmqVnodeTransform-stb.py -N 2 -n 1 python3 test.py -f 7-tmq/tmqVnodeTransform-stb.py -N 2 -n 1
python3 test.py -f 7-tmq/tmqVnodeTransform-stb.py -N 6 -n 3 python3 test.py -f 7-tmq/tmqVnodeTransform-stb.py -N 6 -n 3
python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select.py -N 2 -n 1 python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select.py -N 2 -n 1
python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select-duplicatedata.py -N 3 -n 3 python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select-duplicatedata.py -N 3 -n 3
python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select-duplicatedata-false.py -N 3 -n 3 python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select-duplicatedata-false.py -N 3 -n 3
python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select.py -N 3 -n 3 python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select.py -N 3 -n 3
python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select-false.py -N 3 -n 3
python3 test.py -f 7-tmq/tmqVnodeSplit-stb.py -N 3 -n 3 python3 test.py -f 7-tmq/tmqVnodeSplit-stb.py -N 3 -n 3
python3 test.py -f 7-tmq/tmqVnodeSplit-stb-false.py -N 3 -n 3
python3 test.py -f 7-tmq/tmqVnodeSplit-column.py -N 3 -n 3 python3 test.py -f 7-tmq/tmqVnodeSplit-column.py -N 3 -n 3
python3 test.py -f 7-tmq/tmqVnodeSplit-column-false.py -N 3 -n 3
python3 test.py -f 7-tmq/tmqVnodeSplit-db.py -N 3 -n 3 python3 test.py -f 7-tmq/tmqVnodeSplit-db.py -N 3 -n 3
python3 test.py -f 7-tmq/tmqVnodeSplit-db-false.py -N 3 -n 3
python3 test.py -f 7-tmq/tmqVnodeReplicate.py -M 3 -N 3 -n 3 python3 test.py -f 7-tmq/tmqVnodeReplicate.py -M 3 -N 3 -n 3
python3 ./test.py -f 99-TDcase/TD-19201.py python3 ./test.py -f 99-TDcase/TD-19201.py
python3 ./test.py -f 99-TDcase/TD-21561.py python3 ./test.py -f 99-TDcase/TD-21561.py
@ -184,6 +230,7 @@ python3 ./test.py -f 99-TDcase/TS-3404.py
python3 ./test.py -f 99-TDcase/TS-3581.py python3 ./test.py -f 99-TDcase/TS-3581.py
python3 ./test.py -f 99-TDcase/TS-3311.py python3 ./test.py -f 99-TDcase/TS-3311.py
python3 ./test.py -f 99-TDcase/TS-3821.py python3 ./test.py -f 99-TDcase/TS-3821.py
python3 ./test.py -f 99-TDcase/TS-5130.py
python3 ./test.py -f 0-others/balance_vgroups_r1.py -N 6 python3 ./test.py -f 0-others/balance_vgroups_r1.py -N 6
python3 ./test.py -f 0-others/taosShell.py python3 ./test.py -f 0-others/taosShell.py
python3 ./test.py -f 0-others/taosShellError.py python3 ./test.py -f 0-others/taosShellError.py
@ -217,6 +264,10 @@ python3 ./test.py -f 0-others/splitVGroupWal.py -N 3 -n 3
python3 ./test.py -f 0-others/timeRangeWise.py -N 3 python3 ./test.py -f 0-others/timeRangeWise.py -N 3
python3 ./test.py -f 0-others/delete_check.py python3 ./test.py -f 0-others/delete_check.py
python3 ./test.py -f 0-others/test_hot_refresh_configurations.py python3 ./test.py -f 0-others/test_hot_refresh_configurations.py
python3 ./test.py -f 0-others/empty_identifier.py
python3 ./test.py -f 1-insert/composite_primary_key_create.py
python3 ./test.py -f 1-insert/composite_primary_key_insert.py
python3 ./test.py -f 1-insert/composite_primary_key_delete.py
python3 ./test.py -f 1-insert/insert_double.py python3 ./test.py -f 1-insert/insert_double.py
python3 ./test.py -f 1-insert/alter_database.py python3 ./test.py -f 1-insert/alter_database.py
python3 ./test.py -f 1-insert/alter_replica.py -N 3 python3 ./test.py -f 1-insert/alter_replica.py -N 3
@ -270,7 +321,10 @@ python3 ./test.py -f 1-insert/test_ts4219.py
python3 ./test.py -f 1-insert/ts-4272.py python3 ./test.py -f 1-insert/ts-4272.py
python3 ./test.py -f 1-insert/test_ts4295.py python3 ./test.py -f 1-insert/test_ts4295.py
python3 ./test.py -f 1-insert/test_td27388.py python3 ./test.py -f 1-insert/test_td27388.py
python3 ./test.py -f 1-insert/test_ts4479.py
python3 ./test.py -f 1-insert/test_td29793.py
python3 ./test.py -f 1-insert/insert_timestamp.py python3 ./test.py -f 1-insert/insert_timestamp.py
python3 ./test.py -f 1-insert/test_td29157.py
python3 ./test.py -f 0-others/show.py python3 ./test.py -f 0-others/show.py
python3 ./test.py -f 0-others/show_tag_index.py python3 ./test.py -f 0-others/show_tag_index.py
python3 ./test.py -f 0-others/information_schema.py python3 ./test.py -f 0-others/information_schema.py
@ -308,6 +362,11 @@ python3 ./test.py -f 2-query/concat_ws2.py
python3 ./test.py -f 2-query/concat_ws2.py -R python3 ./test.py -f 2-query/concat_ws2.py -R
python3 ./test.py -f 2-query/cos.py python3 ./test.py -f 2-query/cos.py
python3 ./test.py -f 2-query/cos.py -R python3 ./test.py -f 2-query/cos.py -R
python3 ./test.py -f 2-query/group_partition.py
python3 ./test.py -f 2-query/group_partition.py -R
python3 ./test.py -f 2-query/group_partition.py -Q 2
python3 ./test.py -f 2-query/group_partition.py -Q 3
python3 ./test.py -f 2-query/group_partition.py -Q 4
python3 ./test.py -f 2-query/count_partition.py python3 ./test.py -f 2-query/count_partition.py
python3 ./test.py -f 2-query/count_partition.py -R python3 ./test.py -f 2-query/count_partition.py -R
python3 ./test.py -f 2-query/count.py python3 ./test.py -f 2-query/count.py
@ -361,6 +420,40 @@ python3 ./test.py -f 2-query/last_row.py
python3 ./test.py -f 2-query/last_row.py -R python3 ./test.py -f 2-query/last_row.py -R
python3 ./test.py -f 2-query/last.py python3 ./test.py -f 2-query/last.py
python3 ./test.py -f 2-query/last.py -R python3 ./test.py -f 2-query/last.py -R
python3 ./test.py -f 2-query/last_and_last_row.py
python3 ./test.py -f 2-query/last_and_last_row.py -R
python3 ./test.py -f 2-query/last_and_last_row.py -Q 2
python3 ./test.py -f 2-query/last_and_last_row.py -Q 3
python3 ./test.py -f 2-query/last_and_last_row.py -Q 4
python3 ./test.py -f 2-query/last+last_row.py
python3 ./test.py -f 2-query/last+last_row.py -Q 2
python3 ./test.py -f 2-query/last+last_row.py -Q 3
python3 ./test.py -f 2-query/last+last_row.py -Q 4
python3 ./test.py -f 2-query/primary_ts_base_1.py
python3 ./test.py -f 2-query/primary_ts_base_1.py -R
python3 ./test.py -f 2-query/primary_ts_base_1.py -Q 2
python3 ./test.py -f 2-query/primary_ts_base_1.py -Q 3
python3 ./test.py -f 2-query/primary_ts_base_1.py -Q 4
python3 ./test.py -f 2-query/primary_ts_base_2.py
python3 ./test.py -f 2-query/primary_ts_base_2.py -R
python3 ./test.py -f 2-query/primary_ts_base_2.py -Q 2
python3 ./test.py -f 2-query/primary_ts_base_2.py -Q 3
python3 ./test.py -f 2-query/primary_ts_base_2.py -Q 4
python3 ./test.py -f 2-query/primary_ts_base_3.py
python3 ./test.py -f 2-query/primary_ts_base_3.py -R
python3 ./test.py -f 2-query/primary_ts_base_3.py -Q 2
python3 ./test.py -f 2-query/primary_ts_base_3.py -Q 3
python3 ./test.py -f 2-query/primary_ts_base_3.py -Q 4
python3 ./test.py -f 2-query/primary_ts_base_4.py
python3 ./test.py -f 2-query/primary_ts_base_4.py -R
python3 ./test.py -f 2-query/primary_ts_base_4.py -Q 2
python3 ./test.py -f 2-query/primary_ts_base_4.py -Q 3
python3 ./test.py -f 2-query/primary_ts_base_4.py -Q 4
python3 ./test.py -f 2-query/primary_ts_base_5.py
python3 ./test.py -f 2-query/primary_ts_base_5.py -R
python3 ./test.py -f 2-query/primary_ts_base_5.py -Q 2
python3 ./test.py -f 2-query/primary_ts_base_5.py -Q 3
python3 ./test.py -f 2-query/primary_ts_base_5.py -Q 4
python3 ./test.py -f 2-query/leastsquares.py python3 ./test.py -f 2-query/leastsquares.py
python3 ./test.py -f 2-query/leastsquares.py -R python3 ./test.py -f 2-query/leastsquares.py -R
python3 ./test.py -f 2-query/length.py python3 ./test.py -f 2-query/length.py
@ -368,6 +461,8 @@ python3 ./test.py -f 2-query/length.py -R
python3 ./test.py -f 2-query/limit.py python3 ./test.py -f 2-query/limit.py
python3 ./test.py -f 2-query/log.py python3 ./test.py -f 2-query/log.py
python3 ./test.py -f 2-query/log.py -R python3 ./test.py -f 2-query/log.py -R
python3 ./test.py -f 2-query/logical_operators.py
python3 ./test.py -f 2-query/logical_operators.py -R
python3 ./test.py -f 2-query/lower.py python3 ./test.py -f 2-query/lower.py
python3 ./test.py -f 2-query/lower.py -R python3 ./test.py -f 2-query/lower.py -R
python3 ./test.py -f 2-query/ltrim.py python3 ./test.py -f 2-query/ltrim.py
@ -376,6 +471,8 @@ python3 ./test.py -f 2-query/mavg.py
python3 ./test.py -f 2-query/mavg.py -R python3 ./test.py -f 2-query/mavg.py -R
python3 ./test.py -f 2-query/max_partition.py python3 ./test.py -f 2-query/max_partition.py
python3 ./test.py -f 2-query/max_partition.py -R python3 ./test.py -f 2-query/max_partition.py -R
python3 ./test.py -f 2-query/partition_limit_interval.py
python3 ./test.py -f 2-query/partition_limit_interval.py -R
python3 ./test.py -f 2-query/max_min_last_interval.py python3 ./test.py -f 2-query/max_min_last_interval.py
python3 ./test.py -f 2-query/last_row_interval.py python3 ./test.py -f 2-query/last_row_interval.py
python3 ./test.py -f 2-query/max.py python3 ./test.py -f 2-query/max.py
@ -478,6 +575,8 @@ python3 ./test.py -f 2-query/json_tag.py
python3 ./test.py -f 2-query/nestedQueryInterval.py python3 ./test.py -f 2-query/nestedQueryInterval.py
python3 ./test.py -f 2-query/systable_func.py python3 ./test.py -f 2-query/systable_func.py
python3 ./test.py -f 2-query/test_ts4382.py python3 ./test.py -f 2-query/test_ts4382.py
python3 ./test.py -f 2-query/test_ts4403.py
python3 ./test.py -f 2-query/test_td28163.py
python3 ./test.py -f 2-query/stablity.py python3 ./test.py -f 2-query/stablity.py
python3 ./test.py -f 2-query/stablity_1.py python3 ./test.py -f 2-query/stablity_1.py
python3 ./test.py -f 2-query/elapsed.py python3 ./test.py -f 2-query/elapsed.py
@ -486,6 +585,10 @@ python3 ./test.py -f 2-query/function_diff.py
python3 ./test.py -f 2-query/tagFilter.py python3 ./test.py -f 2-query/tagFilter.py
python3 ./test.py -f 2-query/projectionDesc.py python3 ./test.py -f 2-query/projectionDesc.py
python3 ./test.py -f 2-query/ts_3405_3398_3423.py -N 3 -n 3 python3 ./test.py -f 2-query/ts_3405_3398_3423.py -N 3 -n 3
python3 ./test.py -f 2-query/ts-4348-td-27939.py
python3 ./test.py -f 2-query/backslash_g.py
python3 ./test.py -f 2-query/test_ts4467.py
python3 ./test.py -f 2-query/geometry.py
python3 ./test.py -f 2-query/queryQnode.py python3 ./test.py -f 2-query/queryQnode.py
python3 ./test.py -f 6-cluster/5dnode1mnode.py python3 ./test.py -f 6-cluster/5dnode1mnode.py
python3 ./test.py -f 6-cluster/5dnode2mnode.py -N 5 python3 ./test.py -f 6-cluster/5dnode2mnode.py -N 5
@ -612,6 +715,7 @@ python3 ./test.py -f 2-query/irate.py -Q 2
python3 ./test.py -f 2-query/function_null.py -Q 2 python3 ./test.py -f 2-query/function_null.py -Q 2
python3 ./test.py -f 2-query/count_partition.py -Q 2 python3 ./test.py -f 2-query/count_partition.py -Q 2
python3 ./test.py -f 2-query/max_partition.py -Q 2 python3 ./test.py -f 2-query/max_partition.py -Q 2
python3 ./test.py -f 2-query/partition_limit_interval.py -Q 2
python3 ./test.py -f 2-query/max_min_last_interval.py -Q 2 python3 ./test.py -f 2-query/max_min_last_interval.py -Q 2
python3 ./test.py -f 2-query/last_row_interval.py -Q 2 python3 ./test.py -f 2-query/last_row_interval.py -Q 2
python3 ./test.py -f 2-query/last_row.py -Q 2 python3 ./test.py -f 2-query/last_row.py -Q 2
@ -707,6 +811,7 @@ python3 ./test.py -f 2-query/irate.py -Q 3
python3 ./test.py -f 2-query/function_null.py -Q 3 python3 ./test.py -f 2-query/function_null.py -Q 3
python3 ./test.py -f 2-query/count_partition.py -Q 3 python3 ./test.py -f 2-query/count_partition.py -Q 3
python3 ./test.py -f 2-query/max_partition.py -Q 3 python3 ./test.py -f 2-query/max_partition.py -Q 3
python3 ./test.py -f 2-query/partition_limit_interval.py -Q 3
python3 ./test.py -f 2-query/max_min_last_interval.py -Q 3 python3 ./test.py -f 2-query/max_min_last_interval.py -Q 3
python3 ./test.py -f 2-query/last_row_interval.py -Q 3 python3 ./test.py -f 2-query/last_row_interval.py -Q 3
python3 ./test.py -f 2-query/last_row.py -Q 3 python3 ./test.py -f 2-query/last_row.py -Q 3
@ -802,6 +907,7 @@ python3 ./test.py -f 2-query/irate.py -Q 4
python3 ./test.py -f 2-query/function_null.py -Q 4 python3 ./test.py -f 2-query/function_null.py -Q 4
python3 ./test.py -f 2-query/count_partition.py -Q 4 python3 ./test.py -f 2-query/count_partition.py -Q 4
python3 ./test.py -f 2-query/max_partition.py -Q 4 python3 ./test.py -f 2-query/max_partition.py -Q 4
python3 ./test.py -f 2-query/partition_limit_interval.py -Q 4
python3 ./test.py -f 2-query/max_min_last_interval.py -Q 4 python3 ./test.py -f 2-query/max_min_last_interval.py -Q 4
python3 ./test.py -f 2-query/last_row_interval.py -Q 4 python3 ./test.py -f 2-query/last_row_interval.py -Q 4
python3 ./test.py -f 2-query/last_row.py -Q 4 python3 ./test.py -f 2-query/last_row.py -Q 4