Merge branch '3.0' into fix/TD-30545
This commit is contained in:
commit
356f6645ad
|
@ -2,7 +2,7 @@
|
||||||
IF (DEFINED VERNUMBER)
|
IF (DEFINED VERNUMBER)
|
||||||
SET(TD_VER_NUMBER ${VERNUMBER})
|
SET(TD_VER_NUMBER ${VERNUMBER})
|
||||||
ELSE ()
|
ELSE ()
|
||||||
SET(TD_VER_NUMBER "3.3.1.0.alpha")
|
SET(TD_VER_NUMBER "3.3.2.0.alpha")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (DEFINED VERCOMPATIBLE)
|
IF (DEFINED VERCOMPATIBLE)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# libuv
|
# libuv
|
||||||
ExternalProject_Add(libuv
|
ExternalProject_Add(libuv
|
||||||
GIT_REPOSITORY https://github.com/libuv/libuv.git
|
GIT_REPOSITORY https://github.com/libuv/libuv.git
|
||||||
GIT_TAG v1.44.2
|
GIT_TAG v1.48.0
|
||||||
SOURCE_DIR "${TD_CONTRIB_DIR}/libuv"
|
SOURCE_DIR "${TD_CONTRIB_DIR}/libuv"
|
||||||
BINARY_DIR "${TD_CONTRIB_DIR}/libuv"
|
BINARY_DIR "${TD_CONTRIB_DIR}/libuv"
|
||||||
CONFIGURE_COMMAND ""
|
CONFIGURE_COMMAND ""
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# taos-tools
|
# taos-tools
|
||||||
ExternalProject_Add(taos-tools
|
ExternalProject_Add(taos-tools
|
||||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||||
GIT_TAG main
|
GIT_TAG 3.0
|
||||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||||
BINARY_DIR ""
|
BINARY_DIR ""
|
||||||
#BUILD_IN_SOURCE TRUE
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
|
|
@ -47,7 +47,7 @@ window_clause: {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
`SESSION` indicates a session window, and `tol_val` indicates the maximum range of the time interval. If the time interval between two continuous rows are within the time interval specified by `tol_val` they belong to the same session window; otherwise a new session window is started automatically.
|
`SESSION` indicates a session window, and `tol_val` indicates the maximum range of the time interval. If the time interval between two continuous rows are within the time interval specified by `tol_val` they belong to the same session window; otherwise a new session window is started automatically.The `_wend` of this window is the time of the last data plus `tol_val`.
|
||||||
|
|
||||||
`EVENT_WINDOW` is determined according to the window start condition and the window close condition. The window is started when `start_trigger_condition` is evaluated to true, the window is closed when `end_trigger_condition` is evaluated to true. `start_trigger_condition` and `end_trigger_condition` can be any conditional expressions supported by TDengine and can include multiple columns.
|
`EVENT_WINDOW` is determined according to the window start condition and the window close condition. The window is started when `start_trigger_condition` is evaluated to true, the window is closed when `end_trigger_condition` is evaluated to true. `start_trigger_condition` and `end_trigger_condition` can be any conditional expressions supported by TDengine and can include multiple columns.
|
||||||
|
|
||||||
|
|
|
@ -432,7 +432,7 @@ The charset that takes effect is UTF-8.
|
||||||
| Applicable | Server Only |
|
| Applicable | Server Only |
|
||||||
| Meaning | Maximum number of threads to commit |
|
| Meaning | Maximum number of threads to commit |
|
||||||
| Value Range | 0-1024 |
|
| Value Range | 0-1024 |
|
||||||
| Default Value | |
|
| Default Value | 4 |
|
||||||
|
|
||||||
## Log Parameters
|
## Log Parameters
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
title: Configurable Column Compression
|
title: Configurable Column Compression
|
||||||
description: Configurable column storage compression method
|
description: Configurable column storage compression method
|
||||||
---
|
---
|
||||||
|
|
||||||
# Configurable Storage Compression
|
|
||||||
|
|
||||||
Since TDengine 3.3.0.0, more advanced compression feature is introduced, you can specify compression or not, the compression method and compression level for each column.
|
Since TDengine 3.3.0.0, more advanced compression feature is introduced, you can specify compression or not, the compression method and compression level for each column.
|
||||||
|
|
||||||
## Compression Terminology Definition
|
## Compression Terminology Definition
|
||||||
|
@ -32,16 +28,14 @@ In this article, it specifically refers to the level within the secondary compre
|
||||||
|
|
||||||
- Default compression algorithm list and applicable range for each data type
|
- Default compression algorithm list and applicable range for each data type
|
||||||
|
|
||||||
| Data Type | Optional Encoding Algorithm | Default Encoding Algorithm | Optional Compression Algorithm|Default Compression Algorithm| Default Compression Level|
|
| Data Type | Optional Encoding Algorithm | Default Encoding Algorithm | Optional Compression Algorithm|Default Compression Algorithm| Default Compression Level|
|
||||||
| :-----------:|:----------:|:-------:|:-------:|:----------:|:----:|
|
| :-----------:|:----------:|:-------:|:-------:|:----------:|:----:|
|
||||||
tinyint/untinyint/smallint/usmallint/int/uint | simple8b| simple8b | lz4/zlib/zstd/xz| lz4 | medium|
|
| tinyint/untinyint/smallint/usmallint/int/uint | simple8b| simple8b | lz4/zlib/zstd/xz| lz4 | medium|
|
||||||
| bigint/ubigint/timestamp | simple8b/delta-i | delta-i |lz4/zlib/zstd/xz | lz4| medium|
|
| bigint/ubigint/timestamp | simple8b/delta-i | delta-i |lz4/zlib/zstd/xz | lz4| medium|
|
||||||
|float/double | delta-d|delta-d |lz4/zlib/zstd/xz/tsz|tsz| medium|
|
|float/double | delta-d|delta-d |lz4/zlib/zstd/xz/tsz|lz4| medium|
|
||||||
|binary/nchar| disabled| disabled|lz4/zlib/zstd/xz| lz4| medium|
|
|binary/nchar| disabled| disabled|lz4/zlib/zstd/xz| lz4| medium|
|
||||||
|bool| bit-packing| bit-packing| lz4/zlib/zstd/xz| lz4| medium|
|
|bool| bit-packing| bit-packing| lz4/zlib/zstd/xz| lz4| medium|
|
||||||
|
|
||||||
Note: For floating point types, if configured as tsz, its precision is determined by the global configuration of taosd. If configured as tsz, but the lossy compression flag is not configured, lz4 is used for compression by default.
|
|
||||||
|
|
||||||
## SQL
|
## SQL
|
||||||
|
|
||||||
### Create Table with Compression
|
### Create Table with Compression
|
||||||
|
@ -76,7 +70,7 @@ ALTER TABLE [db_name.]tabName MODIFY COLUMN colName [ENCODE 'ecode_type'] [COMPR
|
||||||
|
|
||||||
- Change the compression method of the column
|
- Change the compression method of the column
|
||||||
|
|
||||||
### View Compression Dethod
|
### View Compression Method
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
DESCRIBE [dbname.]tabName
|
DESCRIBE [dbname.]tabName
|
||||||
|
|
|
@ -10,6 +10,10 @@ For TDengine 2.x installation packages by version, please visit [here](https://t
|
||||||
|
|
||||||
import Release from "/components/ReleaseV3";
|
import Release from "/components/ReleaseV3";
|
||||||
|
|
||||||
|
## 3.3.1.0
|
||||||
|
|
||||||
|
<Release type="tdengine" version="3.3.1.0" />
|
||||||
|
|
||||||
## 3.3.0.3
|
## 3.3.0.3
|
||||||
|
|
||||||
<Release type="tdengine" version="3.3.0.3" />
|
<Release type="tdengine" version="3.3.0.3" />
|
||||||
|
|
|
@ -54,8 +54,10 @@ window_clause: {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
其中,SESSION 是会话窗口,tol_val 是时间间隔的最大范围。在 tol_val 时间间隔范围内的数据都属于同一个窗口,如果连续的两条数据的时间超过 tol_val,则自动开启下一个窗口。
|
其中,SESSION 是会话窗口,tol_val 是时间间隔的最大范围。在 tol_val 时间间隔范围内的数据都属于同一个窗口,如果连续的两条数据的时间超过 tol_val,则自动开启下一个窗口。该窗口的 _wend 等于最后一条数据的时间加上 tol_val。
|
||||||
|
|
||||||
EVENT_WINDOW 是事件窗口,根据开始条件和结束条件来划定窗口。当 start_trigger_condition 满足时则窗口开始,直到 end_trigger_condition 满足时窗口关闭。 start_trigger_condition 和 end_trigger_condition 可以是任意 TDengine 支持的条件表达式,且可以包含不同的列。
|
EVENT_WINDOW 是事件窗口,根据开始条件和结束条件来划定窗口。当 start_trigger_condition 满足时则窗口开始,直到 end_trigger_condition 满足时窗口关闭。 start_trigger_condition 和 end_trigger_condition 可以是任意 TDengine 支持的条件表达式,且可以包含不同的列。
|
||||||
|
|
||||||
COUNT_WINDOW 是计数窗口,按固定的数据行数来划分窗口。 count_val 是常量,是正整数,必须大于等于2,小于2147483648。 count_val 表示每个 COUNT_WINDOW 包含的最大数据行数,总数据行数不能整除 count_val 时,最后一个窗口的行数会小于 count_val 。 sliding_val 是常量,表示窗口滑动的数量,类似于 INTERVAL 的 SLIDING 。
|
COUNT_WINDOW 是计数窗口,按固定的数据行数来划分窗口。 count_val 是常量,是正整数,必须大于等于2,小于2147483648。 count_val 表示每个 COUNT_WINDOW 包含的最大数据行数,总数据行数不能整除 count_val 时,最后一个窗口的行数会小于 count_val 。 sliding_val 是常量,表示窗口滑动的数量,类似于 INTERVAL 的 SLIDING 。
|
||||||
|
|
||||||
窗口的定义与时序数据特色查询中的定义完全相同,详见 [TDengine 特色查询](../distinguished)
|
窗口的定义与时序数据特色查询中的定义完全相同,详见 [TDengine 特色查询](../distinguished)
|
||||||
|
|
|
@ -430,7 +430,7 @@ charset 的有效值是 UTF-8。
|
||||||
| 适用范围 | 仅服务端适用 |
|
| 适用范围 | 仅服务端适用 |
|
||||||
| 含义 | 设置写入线程的最大数量 |
|
| 含义 | 设置写入线程的最大数量 |
|
||||||
| 取值范围 | 0-1024 |
|
| 取值范围 | 0-1024 |
|
||||||
| 缺省值 | |
|
| 缺省值 | 4 |
|
||||||
|
|
||||||
## 日志相关
|
## 日志相关
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@ title: 可配置压缩算法
|
||||||
description: 可配置压缩算法
|
description: 可配置压缩算法
|
||||||
---
|
---
|
||||||
|
|
||||||
# 可配置存储压缩
|
|
||||||
|
|
||||||
从 TDengine 3.3.0.0 版本开始,TDengine 提供了更高级的压缩功能,用户可以在建表时针对每一列配置是否进行压缩、以及使用的压缩算法和压缩级别。
|
从 TDengine 3.3.0.0 版本开始,TDengine 提供了更高级的压缩功能,用户可以在建表时针对每一列配置是否进行压缩、以及使用的压缩算法和压缩级别。
|
||||||
|
|
||||||
## 压缩术语定义
|
## 压缩术语定义
|
||||||
|
@ -30,16 +28,14 @@ description: 可配置压缩算法
|
||||||
|
|
||||||
- 各个数据类型的默认压缩算法列表和适用范围
|
- 各个数据类型的默认压缩算法列表和适用范围
|
||||||
|
|
||||||
| 数据类型 | 可选编码算法 | 编码算法默认值 | 可选压缩算法|可选压缩算法| 压缩等级默认值|
|
| 数据类型 | 可选编码算法 | 编码算法默认值 | 可选压缩算法|压缩算法默认值| 压缩等级默认值|
|
||||||
| :-----------:|:----------:|:-------:|:-------:|:----------:|:----:|
|
| :-----------:|:----------:|:-------:|:-------:|:----------:|:----:|
|
||||||
tinyint/untinyint/smallint/usmallint/int/uint | simple8b| simple8b | lz4/zlib/zstd/xz| lz4 | medium|
|
| tinyint/untinyint/smallint/usmallint/int/uint | simple8b| simple8b | lz4/zlib/zstd/xz| lz4 | medium|
|
||||||
| bigint/ubigint/timestamp | simple8b/delta-i | delta-i |lz4/zlib/zstd/xz | lz4| medium|
|
| bigint/ubigint/timestamp | simple8b/delta-i | delta-i |lz4/zlib/zstd/xz | lz4| medium|
|
||||||
|float/double | delta-d|delta-d |lz4/zlib/zstd/xz/tsz|tsz| medium|
|
|float/double | delta-d|delta-d |lz4/zlib/zstd/xz/tsz|lz4| medium|
|
||||||
|binary/nchar| disabled| disabled|lz4/zlib/zstd/xz| lz4| medium|
|
|binary/nchar| disabled| disabled|lz4/zlib/zstd/xz| lz4| medium|
|
||||||
|bool| bit-packing| bit-packing| lz4/zlib/zstd/xz| lz4| medium|
|
|bool| bit-packing| bit-packing| lz4/zlib/zstd/xz| lz4| medium|
|
||||||
|
|
||||||
注意: 针对浮点类型,如果配置为tsz, 其精度由taosd的全局配置决定,如果配置为tsz, 但是没有配置有损压缩标志, 则使用lz4进行压缩
|
|
||||||
|
|
||||||
## SQL 语法
|
## SQL 语法
|
||||||
|
|
||||||
### 建表时指定压缩
|
### 建表时指定压缩
|
||||||
|
|
|
@ -10,6 +10,10 @@ TDengine 2.x 各版本安装包请访问[这里](https://www.taosdata.com/all-do
|
||||||
|
|
||||||
import Release from "/components/ReleaseV3";
|
import Release from "/components/ReleaseV3";
|
||||||
|
|
||||||
|
## 3.3.1.0
|
||||||
|
|
||||||
|
<Release type="tdengine" version="3.3.1.0" />
|
||||||
|
|
||||||
## 3.3.0.3
|
## 3.3.0.3
|
||||||
|
|
||||||
<Release type="tdengine" version="3.3.0.3" />
|
<Release type="tdengine" version="3.3.0.3" />
|
||||||
|
|
|
@ -240,7 +240,7 @@ typedef struct SDataBlockInfo {
|
||||||
} SDataBlockInfo;
|
} SDataBlockInfo;
|
||||||
|
|
||||||
typedef struct SSDataBlock {
|
typedef struct SSDataBlock {
|
||||||
SColumnDataAgg** pBlockAgg;
|
SColumnDataAgg* pBlockAgg;
|
||||||
SArray* pDataBlock; // SArray<SColumnInfoData>
|
SArray* pDataBlock; // SArray<SColumnInfoData>
|
||||||
SDataBlockInfo info;
|
SDataBlockInfo info;
|
||||||
} SSDataBlock;
|
} SSDataBlock;
|
||||||
|
|
|
@ -102,7 +102,7 @@ static FORCE_INLINE bool colDataIsNull(const SColumnInfoData* pColumnInfoData, u
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pColAgg != NULL) {
|
if (pColAgg != NULL && pColAgg->colId != -1) {
|
||||||
if (pColAgg->numOfNull == totalRows) {
|
if (pColAgg->numOfNull == totalRows) {
|
||||||
ASSERT(pColumnInfoData->nullbitmap == NULL);
|
ASSERT(pColumnInfoData->nullbitmap == NULL);
|
||||||
return true;
|
return true;
|
||||||
|
@ -282,6 +282,8 @@ int32_t buildCtbNameByGroupIdImpl(const char* stbName, uint64_t groupId, char* p
|
||||||
|
|
||||||
void trimDataBlock(SSDataBlock* pBlock, int32_t totalRows, const bool* pBoolList);
|
void trimDataBlock(SSDataBlock* pBlock, int32_t totalRows, const bool* pBoolList);
|
||||||
|
|
||||||
|
void copyPkVal(SDataBlockInfo* pDst, const SDataBlockInfo* pSrc);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -86,6 +86,7 @@ extern int32_t tsNumOfQnodeFetchThreads;
|
||||||
extern int32_t tsNumOfSnodeStreamThreads;
|
extern int32_t tsNumOfSnodeStreamThreads;
|
||||||
extern int32_t tsNumOfSnodeWriteThreads;
|
extern int32_t tsNumOfSnodeWriteThreads;
|
||||||
extern int64_t tsRpcQueueMemoryAllowed;
|
extern int64_t tsRpcQueueMemoryAllowed;
|
||||||
|
extern int32_t tsRetentionSpeedLimitMB;
|
||||||
|
|
||||||
// sync raft
|
// sync raft
|
||||||
extern int32_t tsElectInterval;
|
extern int32_t tsElectInterval;
|
||||||
|
|
|
@ -1054,10 +1054,10 @@ typedef struct {
|
||||||
int8_t enable;
|
int8_t enable;
|
||||||
int8_t isView;
|
int8_t isView;
|
||||||
union {
|
union {
|
||||||
int8_t flag;
|
uint8_t flag;
|
||||||
struct {
|
struct {
|
||||||
int8_t createdb : 1;
|
uint8_t createdb : 1;
|
||||||
int8_t reserve : 7;
|
uint8_t reserve : 7;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
|
@ -3494,9 +3494,9 @@ typedef struct SVUpdateCheckpointInfoReq {
|
||||||
int64_t checkpointVer;
|
int64_t checkpointVer;
|
||||||
int64_t checkpointTs;
|
int64_t checkpointTs;
|
||||||
int32_t transId;
|
int32_t transId;
|
||||||
int8_t dropRelHTask;
|
int64_t hStreamId; // add encode/decode
|
||||||
int64_t hStreamId;
|
|
||||||
int64_t hTaskId;
|
int64_t hTaskId;
|
||||||
|
int8_t dropRelHTask;
|
||||||
} SVUpdateCheckpointInfoReq;
|
} SVUpdateCheckpointInfoReq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -3649,10 +3649,6 @@ typedef struct {
|
||||||
int32_t taskId;
|
int32_t taskId;
|
||||||
} SVPauseStreamTaskReq, SVResetStreamTaskReq;
|
} SVPauseStreamTaskReq, SVResetStreamTaskReq;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int8_t reserved;
|
|
||||||
} SVPauseStreamTaskRsp;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_STREAM_FNAME_LEN];
|
char name[TSDB_STREAM_FNAME_LEN];
|
||||||
int8_t igNotExists;
|
int8_t igNotExists;
|
||||||
|
|
|
@ -225,9 +225,9 @@
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_RESTORE_DNODE, "restore-dnode", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_RESTORE_DNODE, "restore-dnode", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_PAUSE_STREAM, "pause-stream", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_PAUSE_STREAM, "pause-stream", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_RESUME_STREAM, "resume-stream", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_RESUME_STREAM, "resume-stream", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_CHECKPOINT_TIMER, "stream-checkpoint-tmr", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_UPDATE_CHKPT_EVT, "stream-update-chkpt-evt", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_BEGIN_CHECKPOINT, "stream-begin-checkpoint", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_BEGIN_CHECKPOINT, "stream-begin-checkpoint", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_CHECKPOINT_CANDIDITATE, "stream-checkpoint-remain", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_CHKPT_REPORT, "stream-chkpt-report", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_NODECHANGE_CHECK, "stream-nodechange-check", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_NODECHANGE_CHECK, "stream-nodechange-check", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_TRIM_DB_TIMER, "trim-db-tmr", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_TRIM_DB_TIMER, "trim-db-tmr", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_GRANT_NOTIFY, "grant-notify", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_GRANT_NOTIFY, "grant-notify", NULL, NULL)
|
||||||
|
@ -390,6 +390,7 @@
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TASK_RESET, "vnode-stream-reset", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TASK_RESET, "vnode-stream-reset", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TASK_CHECK, "vnode-stream-task-check", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TASK_CHECK, "vnode-stream-task-check", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_UNUSED, "vnd-stream-unused", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_UNUSED, "vnd-stream-unused", NULL, NULL)
|
||||||
|
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_GET_STREAM_PROGRESS, "vnd-stream-progress", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_GET_STREAM_PROGRESS, "vnd-stream-progress", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_MAX_MSG, "vnd-stream-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_MAX_MSG, "vnd-stream-max", NULL, NULL)
|
||||||
TD_CLOSE_MSG_SEG(TDMT_END_VND_STREAM_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_END_VND_STREAM_MSG)
|
||||||
|
|
|
@ -28,6 +28,7 @@ int32_t tqStreamTaskProcessCheckRsp(SStreamMeta* pMeta, SRpcMsg* pMsg, bool isLe
|
||||||
int32_t tqStreamTaskProcessCheckpointReadyMsg(SStreamMeta* pMeta, SRpcMsg* pMsg);
|
int32_t tqStreamTaskProcessCheckpointReadyMsg(SStreamMeta* pMeta, SRpcMsg* pMsg);
|
||||||
int32_t tqStreamProcessStreamHbRsp(SStreamMeta* pMeta, SRpcMsg* pMsg);
|
int32_t tqStreamProcessStreamHbRsp(SStreamMeta* pMeta, SRpcMsg* pMsg);
|
||||||
int32_t tqStreamProcessReqCheckpointRsp(SStreamMeta* pMeta, SRpcMsg* pMsg);
|
int32_t tqStreamProcessReqCheckpointRsp(SStreamMeta* pMeta, SRpcMsg* pMsg);
|
||||||
|
int32_t tqStreamProcessChkptReportRsp(SStreamMeta* pMeta, SRpcMsg* pMsg);
|
||||||
int32_t tqStreamProcessCheckpointReadyRsp(SStreamMeta* pMeta, SRpcMsg* pMsg);
|
int32_t tqStreamProcessCheckpointReadyRsp(SStreamMeta* pMeta, SRpcMsg* pMsg);
|
||||||
int32_t tqStreamTaskProcessDeployReq(SStreamMeta* pMeta, SMsgCb* cb, int64_t sversion, char* msg, int32_t msgLen,
|
int32_t tqStreamTaskProcessDeployReq(SStreamMeta* pMeta, SMsgCb* cb, int64_t sversion, char* msg, int32_t msgLen,
|
||||||
bool isLeader, bool restored);
|
bool isLeader, bool restored);
|
||||||
|
@ -42,7 +43,7 @@ int32_t tqStreamTaskProcessTaskPauseReq(SStreamMeta* pMeta, char* pMsg);
|
||||||
int32_t tqStreamTaskProcessTaskResumeReq(void* handle, int64_t sversion, char* pMsg, bool fromVnode);
|
int32_t tqStreamTaskProcessTaskResumeReq(void* handle, int64_t sversion, char* pMsg, bool fromVnode);
|
||||||
int32_t tqStreamTaskProcessUpdateCheckpointReq(SStreamMeta* pMeta, char* msg, int32_t msgLen);
|
int32_t tqStreamTaskProcessUpdateCheckpointReq(SStreamMeta* pMeta, char* msg, int32_t msgLen);
|
||||||
|
|
||||||
int32_t tqExpandStreamTask(SStreamTask* pTask, SStreamMeta* pMeta);
|
|
||||||
void tqSetRestoreVersionInfo(SStreamTask* pTask);
|
void tqSetRestoreVersionInfo(SStreamTask* pTask);
|
||||||
|
int32_t tqExpandStreamTask(SStreamTask* pTask);
|
||||||
|
|
||||||
#endif // TDENGINE_TQ_COMMON_H
|
#endif // TDENGINE_TQ_COMMON_H
|
||||||
|
|
|
@ -410,7 +410,7 @@ typedef struct SStateStore {
|
||||||
void (*streamFileStateClear)(struct SStreamFileState* pFileState);
|
void (*streamFileStateClear)(struct SStreamFileState* pFileState);
|
||||||
bool (*needClearDiskBuff)(struct SStreamFileState* pFileState);
|
bool (*needClearDiskBuff)(struct SStreamFileState* pFileState);
|
||||||
|
|
||||||
SStreamState* (*streamStateOpen)(const char* path, void* pTask, bool specPath, int32_t szPage, int32_t pages);
|
SStreamState* (*streamStateOpen)(const char* path, void* pTask, int64_t streamId, int32_t taskId, bool specPath, int32_t szPage, int32_t pages);
|
||||||
void (*streamStateClose)(SStreamState* pState, bool remove);
|
void (*streamStateClose)(SStreamState* pState, bool remove);
|
||||||
int32_t (*streamStateBegin)(SStreamState* pState);
|
int32_t (*streamStateBegin)(SStreamState* pState);
|
||||||
int32_t (*streamStateCommit)(SStreamState* pState);
|
int32_t (*streamStateCommit)(SStreamState* pState);
|
||||||
|
|
|
@ -58,7 +58,7 @@ extern int32_t filterGetTimeRange(SNode *pNode, STimeWindow *win, bool *isStrict
|
||||||
extern int32_t filterConverNcharColumns(SFilterInfo *pFilterInfo, int32_t rows, bool *gotNchar);
|
extern int32_t filterConverNcharColumns(SFilterInfo *pFilterInfo, int32_t rows, bool *gotNchar);
|
||||||
extern int32_t filterFreeNcharColumns(SFilterInfo *pFilterInfo);
|
extern int32_t filterFreeNcharColumns(SFilterInfo *pFilterInfo);
|
||||||
extern void filterFreeInfo(SFilterInfo *info);
|
extern void filterFreeInfo(SFilterInfo *info);
|
||||||
extern bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg **pColsAgg, int32_t numOfCols, int32_t numOfRows);
|
extern bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pColsAgg, int32_t numOfCols, int32_t numOfRows);
|
||||||
|
|
||||||
/* condition split interface */
|
/* condition split interface */
|
||||||
int32_t filterPartitionCond(SNode **pCondition, SNode **pPrimaryKeyCond, SNode **pTagIndexCond, SNode **pTagCond,
|
int32_t filterPartitionCond(SNode **pCondition, SNode **pPrimaryKeyCond, SNode **pTagIndexCond, SNode **pTagCond,
|
||||||
|
|
|
@ -29,7 +29,8 @@ extern "C" {
|
||||||
|
|
||||||
#include "storageapi.h"
|
#include "storageapi.h"
|
||||||
|
|
||||||
SStreamState* streamStateOpen(const char* path, void* pTask, bool specPath, int32_t szPage, int32_t pages);
|
SStreamState* streamStateOpen(const char* path, void* pTask, int64_t streamId, int32_t taskId, bool specPath,
|
||||||
|
int32_t szPage, int32_t pages);
|
||||||
void streamStateClose(SStreamState* pState, bool remove);
|
void streamStateClose(SStreamState* pState, bool remove);
|
||||||
int32_t streamStateBegin(SStreamState* pState);
|
int32_t streamStateBegin(SStreamState* pState);
|
||||||
int32_t streamStateCommit(SStreamState* pState);
|
int32_t streamStateCommit(SStreamState* pState);
|
||||||
|
|
|
@ -190,6 +190,20 @@ typedef struct SCheckpointTriggerRsp {
|
||||||
int32_t rspCode;
|
int32_t rspCode;
|
||||||
} SCheckpointTriggerRsp;
|
} SCheckpointTriggerRsp;
|
||||||
|
|
||||||
|
typedef struct SCheckpointReport {
|
||||||
|
int64_t streamId;
|
||||||
|
int32_t taskId;
|
||||||
|
int32_t nodeId;
|
||||||
|
int64_t checkpointId;
|
||||||
|
int64_t checkpointVer;
|
||||||
|
int64_t checkpointTs;
|
||||||
|
int32_t transId;
|
||||||
|
int8_t dropHTask;
|
||||||
|
} SCheckpointReport;
|
||||||
|
|
||||||
|
int32_t tEncodeStreamTaskChkptReport(SEncoder* pEncoder, const SCheckpointReport* pReq);
|
||||||
|
int32_t tDecodeStreamTaskChkptReport(SDecoder* pDecoder, SCheckpointReport* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMsgHead head;
|
SMsgHead head;
|
||||||
int64_t streamId;
|
int64_t streamId;
|
||||||
|
|
|
@ -157,7 +157,8 @@ typedef enum EStreamTaskEvent {
|
||||||
|
|
||||||
typedef void FTbSink(SStreamTask* pTask, void* vnode, void* data);
|
typedef void FTbSink(SStreamTask* pTask, void* vnode, void* data);
|
||||||
typedef void FSmaSink(void* vnode, int64_t smaId, const SArray* data);
|
typedef void FSmaSink(void* vnode, int64_t smaId, const SArray* data);
|
||||||
typedef int32_t FTaskExpand(void* ahandle, SStreamTask* pTask, int64_t ver);
|
typedef int32_t FTaskBuild(void* ahandle, SStreamTask* pTask, int64_t ver);
|
||||||
|
typedef int32_t FTaskExpand(SStreamTask* pTask);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
|
@ -205,7 +206,6 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char stbFullName[TSDB_TABLE_FNAME_LEN];
|
char stbFullName[TSDB_TABLE_FNAME_LEN];
|
||||||
int32_t waitingRspCnt;
|
|
||||||
SUseDbRsp dbInfo;
|
SUseDbRsp dbInfo;
|
||||||
} STaskDispatcherShuffle;
|
} STaskDispatcherShuffle;
|
||||||
|
|
||||||
|
@ -312,15 +312,18 @@ typedef struct SMetaHbInfo SMetaHbInfo;
|
||||||
|
|
||||||
typedef struct SDispatchMsgInfo {
|
typedef struct SDispatchMsgInfo {
|
||||||
SStreamDispatchReq* pData; // current dispatch data
|
SStreamDispatchReq* pData; // current dispatch data
|
||||||
int8_t dispatchMsgType;
|
|
||||||
int64_t checkpointId;// checkpoint id msg
|
int8_t dispatchMsgType;
|
||||||
int32_t transId; // transId for current checkpoint
|
int64_t checkpointId; // checkpoint id msg
|
||||||
int16_t msgType; // dispatch msg type
|
int32_t transId; // transId for current checkpoint
|
||||||
int32_t retryCount; // retry send data count
|
int16_t msgType; // dispatch msg type
|
||||||
int64_t startTs; // dispatch start time, record total elapsed time for dispatch
|
int32_t msgId;
|
||||||
SArray* pRetryList; // current dispatch successfully completed node of downstream
|
int64_t startTs; // dispatch start time, record total elapsed time for dispatch
|
||||||
void* pRetryTmr; // used to dispatch data after a given time duration
|
int64_t rspTs; // latest rsp time
|
||||||
void* pRspTmr; // used to dispatch data after a given time duration
|
void* pRetryTmr; // used to dispatch data after a given time duration
|
||||||
|
TdThreadMutex lock;
|
||||||
|
int8_t inMonitor;
|
||||||
|
SArray* pSendInfo; // SArray<SDispatchEntry>
|
||||||
} SDispatchMsgInfo;
|
} SDispatchMsgInfo;
|
||||||
|
|
||||||
typedef struct STaskQueue {
|
typedef struct STaskQueue {
|
||||||
|
@ -484,7 +487,8 @@ typedef struct SStreamMeta {
|
||||||
SArray* pTaskList; // SArray<STaskId*>
|
SArray* pTaskList; // SArray<STaskId*>
|
||||||
void* ahandle;
|
void* ahandle;
|
||||||
TXN* txn;
|
TXN* txn;
|
||||||
FTaskExpand* expandFunc;
|
FTaskBuild* buildTaskFn;
|
||||||
|
FTaskExpand* expandTaskFn;
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
int64_t stage;
|
int64_t stage;
|
||||||
int32_t role;
|
int32_t role;
|
||||||
|
@ -708,8 +712,8 @@ SScanhistoryDataInfo streamScanHistoryData(SStreamTask* pTask, int64_t st);
|
||||||
// stream task meta
|
// stream task meta
|
||||||
void streamMetaInit();
|
void streamMetaInit();
|
||||||
void streamMetaCleanup();
|
void streamMetaCleanup();
|
||||||
SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandFunc, int32_t vgId, int64_t stage,
|
SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskBuild expandFunc, FTaskExpand expandTaskFn,
|
||||||
startComplete_fn_t fn);
|
int32_t vgId, int64_t stage, startComplete_fn_t fn);
|
||||||
void streamMetaClose(SStreamMeta* streamMeta);
|
void streamMetaClose(SStreamMeta* streamMeta);
|
||||||
int32_t streamMetaSaveTask(SStreamMeta* pMeta, SStreamTask* pTask); // save to stream meta store
|
int32_t streamMetaSaveTask(SStreamMeta* pMeta, SStreamTask* pTask); // save to stream meta store
|
||||||
int32_t streamMetaRemoveTask(SStreamMeta* pMeta, STaskId* pKey);
|
int32_t streamMetaRemoveTask(SStreamMeta* pMeta, STaskId* pKey);
|
||||||
|
@ -734,6 +738,9 @@ int32_t streamMetaAddFailedTask(SStreamMeta* pMeta, int64_t streamId, int32
|
||||||
void streamMetaAddFailedTaskSelf(SStreamTask* pTask, int64_t failedTs);
|
void streamMetaAddFailedTaskSelf(SStreamTask* pTask, int64_t failedTs);
|
||||||
void streamMetaAddIntoUpdateTaskList(SStreamMeta* pMeta, SStreamTask* pTask, SStreamTask* pHTask, int32_t transId,
|
void streamMetaAddIntoUpdateTaskList(SStreamMeta* pMeta, SStreamTask* pTask, SStreamTask* pHTask, int32_t transId,
|
||||||
int64_t startTs);
|
int64_t startTs);
|
||||||
|
void streamMetaClearUpdateTaskList(SStreamMeta* pMeta);
|
||||||
|
void streamMetaInitUpdateTaskList(SStreamMeta* pMeta, int32_t transId);
|
||||||
|
|
||||||
void streamMetaRLock(SStreamMeta* pMeta);
|
void streamMetaRLock(SStreamMeta* pMeta);
|
||||||
void streamMetaRUnLock(SStreamMeta* pMeta);
|
void streamMetaRUnLock(SStreamMeta* pMeta);
|
||||||
void streamMetaWLock(SStreamMeta* pMeta);
|
void streamMetaWLock(SStreamMeta* pMeta);
|
||||||
|
@ -762,8 +769,7 @@ int32_t streamBuildAndSendDropTaskMsg(SMsgCb* pMsgCb, int32_t vgId, SStreamTaskI
|
||||||
int32_t streamAddCheckpointSourceRspMsg(SStreamCheckpointSourceReq* pReq, SRpcHandleInfo* pRpcInfo, SStreamTask* pTask);
|
int32_t streamAddCheckpointSourceRspMsg(SStreamCheckpointSourceReq* pReq, SRpcHandleInfo* pRpcInfo, SStreamTask* pTask);
|
||||||
int32_t streamTaskBuildCheckpointSourceRsp(SStreamCheckpointSourceReq* pReq, SRpcHandleInfo* pRpcInfo, SRpcMsg* pMsg,
|
int32_t streamTaskBuildCheckpointSourceRsp(SStreamCheckpointSourceReq* pReq, SRpcHandleInfo* pRpcInfo, SRpcMsg* pMsg,
|
||||||
int32_t setCode);
|
int32_t setCode);
|
||||||
int32_t streamBuildAndSendCheckpointUpdateMsg(SMsgCb* pMsgCb, int32_t vgId, SStreamTaskId* pTaskId, STaskId* pHTaskId,
|
int32_t streamSendChkptReportMsg(SStreamTask* pTask, SCheckpointInfo* pCheckpointInfo, int8_t dropRelHTask);
|
||||||
SCheckpointInfo* pCheckpointInfo, int8_t dropRelHTask);
|
|
||||||
int32_t streamTaskUpdateTaskCheckpointInfo(SStreamTask* pTask, SVUpdateCheckpointInfoReq* pReq);
|
int32_t streamTaskUpdateTaskCheckpointInfo(SStreamTask* pTask, SVUpdateCheckpointInfoReq* pReq);
|
||||||
SActiveCheckpointInfo* streamTaskCreateActiveChkptInfo();
|
SActiveCheckpointInfo* streamTaskCreateActiveChkptInfo();
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,14 @@ extern "C" {
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t val;
|
||||||
|
const char* str;
|
||||||
|
const char* macro;
|
||||||
|
} STaosError;
|
||||||
|
|
||||||
|
extern STaosError errors[];
|
||||||
|
|
||||||
#define TAOS_DEF_ERROR_CODE(mod, code) ((int32_t)((0x80000000 | ((mod)<<16) | (code))))
|
#define TAOS_DEF_ERROR_CODE(mod, code) ((int32_t)((0x80000000 | ((mod)<<16) | (code))))
|
||||||
|
|
||||||
#define TAOS_SYSTEM_ERROR(code) (0x80ff0000 | (code))
|
#define TAOS_SYSTEM_ERROR(code) (0x80ff0000 | (code))
|
||||||
|
@ -38,6 +46,7 @@ const char* terrstr();
|
||||||
char* taosGetErrMsgReturn();
|
char* taosGetErrMsgReturn();
|
||||||
char* taosGetErrMsg();
|
char* taosGetErrMsg();
|
||||||
int32_t* taosGetErrno();
|
int32_t* taosGetErrno();
|
||||||
|
int32_t taosGetErrSize();
|
||||||
#define terrno (*taosGetErrno())
|
#define terrno (*taosGetErrno())
|
||||||
#define terrMsg (taosGetErrMsg())
|
#define terrMsg (taosGetErrMsg())
|
||||||
|
|
||||||
|
@ -316,7 +325,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_MND_DB_OPTION_UNCHANGED TAOS_DEF_ERROR_CODE(0, 0x038A) //
|
#define TSDB_CODE_MND_DB_OPTION_UNCHANGED TAOS_DEF_ERROR_CODE(0, 0x038A) //
|
||||||
#define TSDB_CODE_MND_DB_INDEX_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x038B)
|
#define TSDB_CODE_MND_DB_INDEX_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x038B)
|
||||||
#define TSDB_CODE_MND_DB_RETENTION_PERIOD_ZERO TAOS_DEF_ERROR_CODE(0, 0x038C)
|
#define TSDB_CODE_MND_DB_RETENTION_PERIOD_ZERO TAOS_DEF_ERROR_CODE(0, 0x038C)
|
||||||
#define TSDB_CODE_MND_INCONSIST_ENCRYPT_KEY TAOS_DEF_ERROR_CODE(0, 0x038D)
|
// #define TSDB_CODE_MND_INCONSIST_ENCRYPT_KEY TAOS_DEF_ERROR_CODE(0, 0x038D) // unused
|
||||||
#define TSDB_CODE_MND_INVALID_ENCRYPT_KEY TAOS_DEF_ERROR_CODE(0, 0x038E)
|
#define TSDB_CODE_MND_INVALID_ENCRYPT_KEY TAOS_DEF_ERROR_CODE(0, 0x038E)
|
||||||
// #define TSDB_CODE_MND_INVALID_DB_OPTION_DAYS TAOS_DEF_ERROR_CODE(0, 0x0390) // 2.x
|
// #define TSDB_CODE_MND_INVALID_DB_OPTION_DAYS TAOS_DEF_ERROR_CODE(0, 0x0390) // 2.x
|
||||||
// #define TSDB_CODE_MND_INVALID_DB_OPTION_KEEP TAOS_DEF_ERROR_CODE(0, 0x0391) // 2.x
|
// #define TSDB_CODE_MND_INVALID_DB_OPTION_KEEP TAOS_DEF_ERROR_CODE(0, 0x0391) // 2.x
|
||||||
|
|
|
@ -795,10 +795,10 @@ function is_version_compatible() {
|
||||||
if [ -f ${script_dir}/driver/vercomp.txt ]; then
|
if [ -f ${script_dir}/driver/vercomp.txt ]; then
|
||||||
min_compatible_version=$(cat ${script_dir}/driver/vercomp.txt)
|
min_compatible_version=$(cat ${script_dir}/driver/vercomp.txt)
|
||||||
else
|
else
|
||||||
min_compatible_version=$(${script_dir}/bin/${serverName} -V | head -1 | cut -d ' ' -f 5)
|
min_compatible_version=$(${script_dir}/bin/${serverName} -V | grep version | head -1 | cut -d ' ' -f 5)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exist_version=$(${installDir}/bin/${serverName} -V | head -1 | cut -d ' ' -f 3)
|
exist_version=$(${installDir}/bin/${serverName} -V | grep version | head -1 | cut -d ' ' -f 3)
|
||||||
vercomp $exist_version "3.0.0.0"
|
vercomp $exist_version "3.0.0.0"
|
||||||
case $? in
|
case $? in
|
||||||
2)
|
2)
|
||||||
|
|
|
@ -327,7 +327,9 @@ int32_t setColCompressByOption(uint8_t type, uint8_t encode, uint16_t compressTy
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool useCompress(uint8_t tableType) { return TSDB_SUPER_TABLE == tableType || TSDB_NORMAL_TABLE == tableType; }
|
bool useCompress(uint8_t tableType) {
|
||||||
|
return TSDB_SUPER_TABLE == tableType || TSDB_NORMAL_TABLE == tableType || TSDB_CHILD_TABLE == tableType;
|
||||||
|
}
|
||||||
|
|
||||||
int8_t validColCompressLevel(uint8_t type, uint8_t level) {
|
int8_t validColCompressLevel(uint8_t type, uint8_t level) {
|
||||||
if (level == TSDB_COLVAL_LEVEL_DISABLED) return 1;
|
if (level == TSDB_COLVAL_LEVEL_DISABLED) return 1;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#define MALLOC_ALIGN_BYTES 32
|
#define MALLOC_ALIGN_BYTES 32
|
||||||
|
|
||||||
static void copyPkVal(SDataBlockInfo* pDst, const SDataBlockInfo* pSrc);
|
|
||||||
|
|
||||||
int32_t colDataGetLength(const SColumnInfoData* pColumnInfoData, int32_t numOfRows) {
|
int32_t colDataGetLength(const SColumnInfoData* pColumnInfoData, int32_t numOfRows) {
|
||||||
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
||||||
|
@ -848,7 +848,7 @@ SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int3
|
||||||
if (pBlock->pBlockAgg == NULL) {
|
if (pBlock->pBlockAgg == NULL) {
|
||||||
isNull = colDataIsNull_s(pColData, j);
|
isNull = colDataIsNull_s(pColData, j);
|
||||||
} else {
|
} else {
|
||||||
isNull = colDataIsNull(pColData, pBlock->info.rows, j, pBlock->pBlockAgg[i]);
|
isNull = colDataIsNull(pColData, pBlock->info.rows, j, &pBlock->pBlockAgg[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNull) {
|
if (isNull) {
|
||||||
|
@ -1362,6 +1362,8 @@ void blockDataEmpty(SSDataBlock* pDataBlock) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosMemoryFreeClear(pDataBlock->pBlockAgg);
|
||||||
|
|
||||||
size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock);
|
size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SColumnInfoData* p = taosArrayGet(pDataBlock->pDataBlock, i);
|
SColumnInfoData* p = taosArrayGet(pDataBlock->pDataBlock, i);
|
||||||
|
|
|
@ -74,6 +74,7 @@ int32_t tsNumOfSnodeStreamThreads = 4;
|
||||||
int32_t tsNumOfSnodeWriteThreads = 1;
|
int32_t tsNumOfSnodeWriteThreads = 1;
|
||||||
int32_t tsMaxStreamBackendCache = 128; // M
|
int32_t tsMaxStreamBackendCache = 128; // M
|
||||||
int32_t tsPQSortMemThreshold = 16; // M
|
int32_t tsPQSortMemThreshold = 16; // M
|
||||||
|
int32_t tsRetentionSpeedLimitMB = 0; // unlimited
|
||||||
|
|
||||||
// sync raft
|
// sync raft
|
||||||
int32_t tsElectInterval = 25 * 1000;
|
int32_t tsElectInterval = 25 * 1000;
|
||||||
|
@ -667,6 +668,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
if (cfgAddInt32(pCfg, "queryBufferSize", tsQueryBufferSize, -1, 500000000000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
if (cfgAddInt32(pCfg, "queryBufferSize", tsQueryBufferSize, -1, 500000000000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "queryRspPolicy", tsQueryRspPolicy, 0, 1, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1;
|
if (cfgAddInt32(pCfg, "queryRspPolicy", tsQueryRspPolicy, 0, 1, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "numOfCommitThreads", tsNumOfCommitThreads, 1, 1024, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
if (cfgAddInt32(pCfg, "numOfCommitThreads", tsNumOfCommitThreads, 1, 1024, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "retentionSpeedLimitMB", tsRetentionSpeedLimitMB, 0, 1024, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||||
|
|
||||||
if (cfgAddInt32(pCfg, "numOfMnodeReadThreads", tsNumOfMnodeReadThreads, 1, 1024, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
if (cfgAddInt32(pCfg, "numOfMnodeReadThreads", tsNumOfMnodeReadThreads, 1, 1024, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 4, 1024, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
if (cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 4, 1024, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||||
|
@ -776,7 +778,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
|
|
||||||
// min free disk space used to check if the disk is full [50MB, 1GB]
|
// min free disk space used to check if the disk is full [50MB, 1GB]
|
||||||
if (cfgAddInt64(pCfg, "minDiskFreeSize", tsMinDiskFreeSize, TFS_MIN_DISK_FREE_SIZE, 1024 * 1024 * 1024, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1;
|
if (cfgAddInt64(pCfg, "minDiskFreeSize", tsMinDiskFreeSize, TFS_MIN_DISK_FREE_SIZE, 1024 * 1024 * 1024, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1;
|
||||||
if (cfgAddBool(pCfg, "enableWhiteList", tsEnableWhiteList, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1;
|
if (cfgAddBool(pCfg, "enableWhiteList", tsEnableWhiteList, CFG_SCOPE_SERVER, CFG_DYN_SERVER) != 0) return -1;
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
@ -1117,6 +1119,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
tsTimeToGetAvailableConn = cfgGetItem(pCfg, "timeToGetAvailableConn")->i32;
|
tsTimeToGetAvailableConn = cfgGetItem(pCfg, "timeToGetAvailableConn")->i32;
|
||||||
|
|
||||||
tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32;
|
tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32;
|
||||||
|
tsRetentionSpeedLimitMB = cfgGetItem(pCfg, "retentionSpeedLimitMB")->i32;
|
||||||
tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32;
|
tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32;
|
||||||
tsNumOfVnodeQueryThreads = cfgGetItem(pCfg, "numOfVnodeQueryThreads")->i32;
|
tsNumOfVnodeQueryThreads = cfgGetItem(pCfg, "numOfVnodeQueryThreads")->i32;
|
||||||
tsRatioOfVnodeStreamThreads = cfgGetItem(pCfg, "ratioOfVnodeStreamThreads")->fval;
|
tsRatioOfVnodeStreamThreads = cfgGetItem(pCfg, "ratioOfVnodeStreamThreads")->fval;
|
||||||
|
@ -1299,8 +1302,8 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd,
|
int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd, const char *envFile, char *apolloUrl,
|
||||||
const char *envFile, char *apolloUrl, SArray *pArgs) {
|
SArray *pArgs) {
|
||||||
if (tsCfg == NULL) osDefaultInit();
|
if (tsCfg == NULL) osDefaultInit();
|
||||||
|
|
||||||
SConfig *pCfg = cfgInit();
|
SConfig *pCfg = cfgInit();
|
||||||
|
|
|
@ -1813,7 +1813,7 @@ int32_t tSerializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq)
|
||||||
}
|
}
|
||||||
if (tEncodeI64(&encoder, pReq->privileges) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->privileges) < 0) return -1;
|
||||||
ENCODESQL();
|
ENCODESQL();
|
||||||
if (tEncodeI8(&encoder, pReq->flag) < 0) return -1;
|
if (tEncodeU8(&encoder, pReq->flag) < 0) return -1;
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -1854,7 +1854,7 @@ int32_t tDeserializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq
|
||||||
if (tDecodeI64(&decoder, &pReq->privileges) < 0) return -1;
|
if (tDecodeI64(&decoder, &pReq->privileges) < 0) return -1;
|
||||||
DECODESQL();
|
DECODESQL();
|
||||||
if (!tDecodeIsEnd(&decoder)) {
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
if (tDecodeI8(&decoder, &pReq->flag) < 0) return -1;
|
if (tDecodeU8(&decoder, &pReq->flag) < 0) return -1;
|
||||||
}
|
}
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ static int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint
|
||||||
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
if (val > UINT64_MAX) {
|
if (val > (double)UINT64_MAX) {
|
||||||
errno = ERANGE;
|
errno = ERANGE;
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) {
|
||||||
} break;
|
} break;
|
||||||
case TK_NK_FLOAT: {
|
case TK_NK_FLOAT: {
|
||||||
double val = round(taosStr2Double(z, &endPtr));
|
double val = round(taosStr2Double(z, &endPtr));
|
||||||
if (!IS_VALID_INT64(val)) {
|
if(val < (double)INT64_MIN || val > (double)INT64_MAX){
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
||||||
|
@ -271,7 +271,7 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) {
|
||||||
} break;
|
} break;
|
||||||
case TK_NK_FLOAT: {
|
case TK_NK_FLOAT: {
|
||||||
double val = round(taosStr2Double(p, &endPtr));
|
double val = round(taosStr2Double(p, &endPtr));
|
||||||
if (!IS_VALID_UINT64(val)) {
|
if (val < 0 || val > (double)UINT64_MAX) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
||||||
|
|
|
@ -261,7 +261,7 @@ static void dmPrintVersion() {
|
||||||
printf("%s\ntaosd version: %s compatible_version: %s\n", TD_PRODUCT_NAME, version, compatible_version);
|
printf("%s\ntaosd version: %s compatible_version: %s\n", TD_PRODUCT_NAME, version, compatible_version);
|
||||||
printf("git: %s\n", gitinfo);
|
printf("git: %s\n", gitinfo);
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
printf("git: %s\n", gitinfoOfInternal);
|
printf("gitOfInternal: %s\n", gitinfoOfInternal);
|
||||||
#endif
|
#endif
|
||||||
printf("build: %s\n", buildinfo);
|
printf("build: %s\n", buildinfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,6 +232,7 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_PAUSE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_PAUSE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RESUME_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RESUME_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_STOP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_STOP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_UPDATE_CHKPT_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_CREATE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_CREATE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_DROP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_DROP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_CREATE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_CREATE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
@ -240,6 +241,7 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_UPDATE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_UPDATE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_RESET_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_RESET_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_HEARTBEAT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_HEARTBEAT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_CHKPT_REPORT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_REQ_CHKPT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_REQ_CHKPT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_KILL_COMPACT_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_KILL_COMPACT_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
|
|
|
@ -75,26 +75,27 @@ SArray *smGetMsgHandles() {
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_UPDATE, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_UPDATE, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_UPDATE_CHKPT, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RUN, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RUN, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_UPDATE_CHKPT, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_PAUSE, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_PAUSE, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RESUME, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RESUME, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_STOP, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_STOP, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_CHECK, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_CHECK_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_CHECKPOINT_READY, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_CHECKPOINT_READY, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_CHECKPOINT_READY_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_CHECKPOINT_READY_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE_TRIGGER, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE_TRIGGER, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE_TRIGGER_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE_TRIGGER_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_CHECK, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_CHECK_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_RESET, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_RESET, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_VND_GET_STREAM_PROGRESS, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_HEARTBEAT_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_HEARTBEAT_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_REQ_CHKPT_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_REQ_CHKPT_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_GET_STREAM_PROGRESS, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_CHKPT_REPORT_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
_OVER:
|
_OVER:
|
||||||
|
|
|
@ -971,6 +971,7 @@ SArray *vmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_RESET, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_RESET, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_HEARTBEAT_RSP, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_HEARTBEAT_RSP, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_REQ_CHKPT_RSP, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_REQ_CHKPT_RSP, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_CHKPT_REPORT_RSP, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_GET_STREAM_PROGRESS, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_GET_STREAM_PROGRESS, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_UPDATE_CHKPT, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_UPDATE_CHKPT, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -103,8 +103,8 @@ typedef enum {
|
||||||
TRN_CONFLICT_GLOBAL = 1,
|
TRN_CONFLICT_GLOBAL = 1,
|
||||||
TRN_CONFLICT_DB = 2,
|
TRN_CONFLICT_DB = 2,
|
||||||
TRN_CONFLICT_DB_INSIDE = 3,
|
TRN_CONFLICT_DB_INSIDE = 3,
|
||||||
TRN_CONFLICT_TOPIC = 4,
|
// TRN_CONFLICT_TOPIC = 4,
|
||||||
TRN_CONFLICT_TOPIC_INSIDE = 5,
|
// TRN_CONFLICT_TOPIC_INSIDE = 5,
|
||||||
TRN_CONFLICT_ARBGROUP = 6,
|
TRN_CONFLICT_ARBGROUP = 6,
|
||||||
} ETrnConflct;
|
} ETrnConflct;
|
||||||
|
|
||||||
|
@ -332,10 +332,10 @@ typedef struct {
|
||||||
int8_t sysInfo;
|
int8_t sysInfo;
|
||||||
int8_t enable;
|
int8_t enable;
|
||||||
union {
|
union {
|
||||||
int8_t flag;
|
uint8_t flag;
|
||||||
struct {
|
struct {
|
||||||
int8_t createdb : 1;
|
uint8_t createdb : 1;
|
||||||
int8_t reserve : 7;
|
uint8_t reserve : 7;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
int32_t acctId;
|
int32_t acctId;
|
||||||
|
|
|
@ -26,13 +26,14 @@ extern "C" {
|
||||||
#define MND_STREAM_RESERVE_SIZE 64
|
#define MND_STREAM_RESERVE_SIZE 64
|
||||||
#define MND_STREAM_VER_NUMBER 5
|
#define MND_STREAM_VER_NUMBER 5
|
||||||
|
|
||||||
#define MND_STREAM_CREATE_NAME "stream-create"
|
#define MND_STREAM_CREATE_NAME "stream-create"
|
||||||
#define MND_STREAM_CHECKPOINT_NAME "stream-checkpoint"
|
#define MND_STREAM_CHECKPOINT_NAME "stream-checkpoint"
|
||||||
#define MND_STREAM_PAUSE_NAME "stream-pause"
|
#define MND_STREAM_PAUSE_NAME "stream-pause"
|
||||||
#define MND_STREAM_RESUME_NAME "stream-resume"
|
#define MND_STREAM_RESUME_NAME "stream-resume"
|
||||||
#define MND_STREAM_DROP_NAME "stream-drop"
|
#define MND_STREAM_DROP_NAME "stream-drop"
|
||||||
#define MND_STREAM_TASK_RESET_NAME "stream-task-reset"
|
#define MND_STREAM_TASK_RESET_NAME "stream-task-reset"
|
||||||
#define MND_STREAM_TASK_UPDATE_NAME "stream-task-update"
|
#define MND_STREAM_TASK_UPDATE_NAME "stream-task-update"
|
||||||
|
#define MND_STREAM_CHKPT_UPDATE_NAME "stream-chkpt-update"
|
||||||
|
|
||||||
typedef struct SStreamTransInfo {
|
typedef struct SStreamTransInfo {
|
||||||
int64_t startTime;
|
int64_t startTime;
|
||||||
|
@ -51,6 +52,7 @@ typedef struct SStreamTransMgmt {
|
||||||
} SStreamTransMgmt;
|
} SStreamTransMgmt;
|
||||||
|
|
||||||
typedef struct SStreamExecInfo {
|
typedef struct SStreamExecInfo {
|
||||||
|
bool initTaskList;
|
||||||
SArray *pNodeList;
|
SArray *pNodeList;
|
||||||
int64_t ts; // snapshot ts
|
int64_t ts; // snapshot ts
|
||||||
SStreamTransMgmt transMgmt;
|
SStreamTransMgmt transMgmt;
|
||||||
|
@ -58,6 +60,7 @@ typedef struct SStreamExecInfo {
|
||||||
SArray *pTaskList;
|
SArray *pTaskList;
|
||||||
TdThreadMutex lock;
|
TdThreadMutex lock;
|
||||||
SHashObj *pTransferStateStreams;
|
SHashObj *pTransferStateStreams;
|
||||||
|
SHashObj *pChkptStreams;
|
||||||
} SStreamExecInfo;
|
} SStreamExecInfo;
|
||||||
|
|
||||||
extern SStreamExecInfo execInfo;
|
extern SStreamExecInfo execInfo;
|
||||||
|
@ -78,7 +81,18 @@ typedef struct SOrphanTask {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMsgHead head;
|
SMsgHead head;
|
||||||
} SMStreamHbRspMsg, SMStreamReqCheckpointRspMsg;
|
} SMStreamHbRspMsg, SMStreamReqCheckpointRsp, SMStreamUpdateChkptRsp;
|
||||||
|
|
||||||
|
typedef struct STaskChkptInfo {
|
||||||
|
int32_t nodeId;
|
||||||
|
int32_t taskId;
|
||||||
|
int64_t streamId;
|
||||||
|
int64_t checkpointId;
|
||||||
|
int64_t version;
|
||||||
|
int64_t ts;
|
||||||
|
int32_t transId;
|
||||||
|
int8_t dropHTask;
|
||||||
|
}STaskChkptInfo;
|
||||||
|
|
||||||
int32_t mndInitStream(SMnode *pMnode);
|
int32_t mndInitStream(SMnode *pMnode);
|
||||||
void mndCleanupStream(SMnode *pMnode);
|
void mndCleanupStream(SMnode *pMnode);
|
||||||
|
@ -96,7 +110,7 @@ int32_t mndGetNumOfStreamTasks(const SStreamObj *pStream);
|
||||||
SArray *mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady);
|
SArray *mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady);
|
||||||
void mndKillTransImpl(SMnode *pMnode, int32_t transId, const char *pDbName);
|
void mndKillTransImpl(SMnode *pMnode, int32_t transId, const char *pDbName);
|
||||||
int32_t setTransAction(STrans *pTrans, void *pCont, int32_t contLen, int32_t msgType, const SEpSet *pEpset,
|
int32_t setTransAction(STrans *pTrans, void *pCont, int32_t contLen, int32_t msgType, const SEpSet *pEpset,
|
||||||
int32_t retryCode);
|
int32_t retryCode, int32_t acceptCode);
|
||||||
STrans *doCreateTrans(SMnode *pMnode, SStreamObj *pStream, SRpcMsg *pReq, ETrnConflct conflict, const char *name, const char *pMsg);
|
STrans *doCreateTrans(SMnode *pMnode, SStreamObj *pStream, SRpcMsg *pReq, ETrnConflct conflict, const char *name, const char *pMsg);
|
||||||
int32_t mndPersistTransLog(SStreamObj *pStream, STrans *pTrans, int32_t status);
|
int32_t mndPersistTransLog(SStreamObj *pStream, STrans *pTrans, int32_t status);
|
||||||
SSdbRaw *mndStreamActionEncode(SStreamObj *pStream);
|
SSdbRaw *mndStreamActionEncode(SStreamObj *pStream);
|
||||||
|
@ -114,14 +128,19 @@ int32_t mndStreamSetDropAction(SMnode *pMnode, STrans *pTrans, SStreamObj *p
|
||||||
int32_t mndStreamSetDropActionFromList(SMnode *pMnode, STrans *pTrans, SArray *pList);
|
int32_t mndStreamSetDropActionFromList(SMnode *pMnode, STrans *pTrans, SArray *pList);
|
||||||
int32_t mndStreamSetResetTaskAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
|
int32_t mndStreamSetResetTaskAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
|
||||||
int32_t mndCreateStreamResetStatusTrans(SMnode *pMnode, SStreamObj *pStream);
|
int32_t mndCreateStreamResetStatusTrans(SMnode *pMnode, SStreamObj *pStream);
|
||||||
|
int32_t mndStreamSetUpdateChkptAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
|
||||||
|
int32_t mndCreateStreamChkptInfoUpdateTrans(SMnode *pMnode, SStreamObj *pStream, SArray *pChkptInfoList);
|
||||||
|
int32_t mndScanCheckpointReportInfo(SRpcMsg *pReq);
|
||||||
|
void removeTasksInBuf(SArray *pTaskIds, SStreamExecInfo *pExecInfo);
|
||||||
|
|
||||||
SStreamTaskIter *createStreamTaskIter(SStreamObj *pStream);
|
SStreamTaskIter *createStreamTaskIter(SStreamObj *pStream);
|
||||||
void destroyStreamTaskIter(SStreamTaskIter *pIter);
|
void destroyStreamTaskIter(SStreamTaskIter *pIter);
|
||||||
bool streamTaskIterNextTask(SStreamTaskIter *pIter);
|
bool streamTaskIterNextTask(SStreamTaskIter *pIter);
|
||||||
SStreamTask *streamTaskIterGetCurrent(SStreamTaskIter *pIter);
|
SStreamTask *streamTaskIterGetCurrent(SStreamTaskIter *pIter);
|
||||||
void mndInitExecInfo();
|
void mndInitExecInfo();
|
||||||
void removeExpiredNodeInfo(const SArray *pNodeSnapshot);
|
void mndInitStreamExecInfo(SMnode *pMnode, SStreamExecInfo *pExecInfo);
|
||||||
void removeTasksInBuf(SArray* pTaskIds, SStreamExecInfo* pExecInfo);
|
int32_t removeExpiredNodeEntryAndTaskInBuf(SArray *pNodeSnapshot);
|
||||||
|
void removeStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ void mndSendConsumerMsg(SMnode *pMnode, int64_t consumerId, uint16_t msgType, SR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t validateTopics(STrans *pTrans, const SArray *pTopicList, SMnode *pMnode, const char *pUser,
|
static int32_t validateTopics(const SArray *pTopicList, SMnode *pMnode, const char *pUser,
|
||||||
bool enableReplay) {
|
bool enableReplay) {
|
||||||
SMqTopicObj *pTopic = NULL;
|
SMqTopicObj *pTopic = NULL;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -135,11 +135,6 @@ static int32_t validateTopics(STrans *pTrans, const SArray *pTopicList, SMnode *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mndTransSetDbName(pTrans, pOneTopic, NULL);
|
|
||||||
if (mndTransCheckConflict(pMnode, pTrans) != 0) {
|
|
||||||
code = -1;
|
|
||||||
goto FAILED;
|
|
||||||
}
|
|
||||||
mndReleaseTopic(pMnode, pTopic);
|
mndReleaseTopic(pMnode, pTopic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,12 +172,12 @@ static int32_t mndProcessConsumerRecoverMsg(SRpcMsg *pMsg) {
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_TOPIC, pMsg, "recover-csm");
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pMsg, "recover-csm");
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
code = -1;
|
code = -1;
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
code = validateTopics(pTrans, pConsumer->assignedTopics, pMnode, pMsg->info.conn.user, false);
|
code = validateTopics(pConsumer->assignedTopics, pMnode, pMsg->info.conn.user, false);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
@ -675,13 +670,13 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
||||||
goto _over;
|
goto _over;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_TOPIC_INSIDE, pMsg, "subscribe");
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pMsg, "subscribe");
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _over;
|
goto _over;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = validateTopics(pTrans, subscribe.topicNames, pMnode, pMsg->info.conn.user, subscribe.enableReplay);
|
code = validateTopics(subscribe.topicNames, pMnode, pMsg->info.conn.user, subscribe.enableReplay);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _over;
|
goto _over;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include <stdio.h>
|
|
||||||
#include "tjson.h"
|
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
|
#include <stdio.h>
|
||||||
#include "audit.h"
|
#include "audit.h"
|
||||||
#include "mndCluster.h"
|
#include "mndCluster.h"
|
||||||
#include "mndDb.h"
|
#include "mndDb.h"
|
||||||
|
@ -28,9 +27,10 @@
|
||||||
#include "mndTrans.h"
|
#include "mndTrans.h"
|
||||||
#include "mndUser.h"
|
#include "mndUser.h"
|
||||||
#include "mndVgroup.h"
|
#include "mndVgroup.h"
|
||||||
|
#include "taos_monitor.h"
|
||||||
|
#include "tjson.h"
|
||||||
#include "tmisce.h"
|
#include "tmisce.h"
|
||||||
#include "tunit.h"
|
#include "tunit.h"
|
||||||
#include "taos_monitor.h"
|
|
||||||
|
|
||||||
#define TSDB_DNODE_VER_NUMBER 2
|
#define TSDB_DNODE_VER_NUMBER 2
|
||||||
#define TSDB_DNODE_RESERVE_SIZE 40
|
#define TSDB_DNODE_RESERVE_SIZE 40
|
||||||
|
@ -191,8 +191,8 @@ static SSdbRaw *mndDnodeActionEncode(SDnodeObj *pDnode) {
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pDnode->fqdn, TSDB_FQDN_LEN, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pDnode->fqdn, TSDB_FQDN_LEN, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pDnode->machineId, TSDB_MACHINE_ID_LEN, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pDnode->machineId, TSDB_MACHINE_ID_LEN, _OVER)
|
||||||
SDB_SET_RESERVE(pRaw, dataPos, TSDB_DNODE_RESERVE_SIZE, _OVER)
|
SDB_SET_RESERVE(pRaw, dataPos, TSDB_DNODE_RESERVE_SIZE, _OVER)
|
||||||
SDB_SET_INT16(pRaw, dataPos, 0, _OVER) // forward/backward compatible
|
SDB_SET_INT16(pRaw, dataPos, 0, _OVER) // forward/backward compatible
|
||||||
SDB_SET_INT16(pRaw, dataPos, 0, _OVER) // forward/backward compatible
|
SDB_SET_INT16(pRaw, dataPos, 0, _OVER) // forward/backward compatible
|
||||||
SDB_SET_DATALEN(pRaw, dataPos, _OVER);
|
SDB_SET_DATALEN(pRaw, dataPos, _OVER);
|
||||||
|
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
@ -536,49 +536,49 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
|
||||||
char strClusterId[TSDB_CLUSTER_ID_LEN] = {0};
|
char strClusterId[TSDB_CLUSTER_ID_LEN] = {0};
|
||||||
sprintf(strClusterId, "%"PRId64, pMnode->clusterId);
|
sprintf(strClusterId, "%" PRId64, pMnode->clusterId);
|
||||||
|
|
||||||
if (tDeserializeSStatisReq(pReq->pCont, pReq->contLen, &statisReq) != 0) {
|
if (tDeserializeSStatisReq(pReq->pCont, pReq->contLen, &statisReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tsMonitorLogProtocol){
|
if (tsMonitorLogProtocol) {
|
||||||
mInfo("process statis req,\n %s", statisReq.pCont);
|
mInfo("process statis req,\n %s", statisReq.pCont);
|
||||||
}
|
}
|
||||||
|
|
||||||
SJson* pJson = tjsonParse(statisReq.pCont);
|
SJson *pJson = tjsonParse(statisReq.pCont);
|
||||||
|
|
||||||
int32_t ts_size = tjsonGetArraySize(pJson);
|
int32_t ts_size = tjsonGetArraySize(pJson);
|
||||||
|
|
||||||
for(int32_t i = 0; i < ts_size; i++){
|
for (int32_t i = 0; i < ts_size; i++) {
|
||||||
SJson* item = tjsonGetArrayItem(pJson, i);
|
SJson *item = tjsonGetArrayItem(pJson, i);
|
||||||
|
|
||||||
SJson* tables = tjsonGetObjectItem(item, "tables");
|
SJson *tables = tjsonGetObjectItem(item, "tables");
|
||||||
|
|
||||||
int32_t tableSize = tjsonGetArraySize(tables);
|
int32_t tableSize = tjsonGetArraySize(tables);
|
||||||
for(int32_t i = 0; i < tableSize; i++){
|
for (int32_t i = 0; i < tableSize; i++) {
|
||||||
SJson* table = tjsonGetArrayItem(tables, i);
|
SJson *table = tjsonGetArrayItem(tables, i);
|
||||||
|
|
||||||
char tableName[MONITOR_TABLENAME_LEN] = {0};
|
char tableName[MONITOR_TABLENAME_LEN] = {0};
|
||||||
tjsonGetStringValue(table, "name", tableName);
|
tjsonGetStringValue(table, "name", tableName);
|
||||||
|
|
||||||
SJson* metricGroups = tjsonGetObjectItem(table, "metric_groups");
|
SJson *metricGroups = tjsonGetObjectItem(table, "metric_groups");
|
||||||
|
|
||||||
int32_t size = tjsonGetArraySize(metricGroups);
|
int32_t size = tjsonGetArraySize(metricGroups);
|
||||||
for(int32_t i = 0; i < size; i++){
|
for (int32_t i = 0; i < size; i++) {
|
||||||
SJson* item = tjsonGetArrayItem(metricGroups, i);
|
SJson *item = tjsonGetArrayItem(metricGroups, i);
|
||||||
|
|
||||||
SJson* arrayTag = tjsonGetObjectItem(item, "tags");
|
SJson *arrayTag = tjsonGetObjectItem(item, "tags");
|
||||||
|
|
||||||
int32_t tagSize = tjsonGetArraySize(arrayTag);
|
int32_t tagSize = tjsonGetArraySize(arrayTag);
|
||||||
for(int32_t j = 0; j < tagSize; j++){
|
for (int32_t j = 0; j < tagSize; j++) {
|
||||||
SJson* item = tjsonGetArrayItem(arrayTag, j);
|
SJson *item = tjsonGetArrayItem(arrayTag, j);
|
||||||
|
|
||||||
char tagName[MONITOR_TAG_NAME_LEN] = {0};
|
char tagName[MONITOR_TAG_NAME_LEN] = {0};
|
||||||
tjsonGetStringValue(item, "name", tagName);
|
tjsonGetStringValue(item, "name", tagName);
|
||||||
|
|
||||||
if(strncmp(tagName, "cluster_id", MONITOR_TAG_NAME_LEN) == 0) {
|
if (strncmp(tagName, "cluster_id", MONITOR_TAG_NAME_LEN) == 0) {
|
||||||
tjsonDeleteItemFromObject(item, "value");
|
tjsonDeleteItemFromObject(item, "value");
|
||||||
tjsonAddStringToObject(item, "value", strClusterId);
|
tjsonAddStringToObject(item, "value", strClusterId);
|
||||||
}
|
}
|
||||||
|
@ -590,12 +590,12 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
||||||
char *pCont = tjsonToString(pJson);
|
char *pCont = tjsonToString(pJson);
|
||||||
monSendContent(pCont);
|
monSendContent(pCont);
|
||||||
|
|
||||||
if(pJson != NULL){
|
if (pJson != NULL) {
|
||||||
tjsonDelete(pJson);
|
tjsonDelete(pJson);
|
||||||
pJson = NULL;
|
pJson = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pCont != NULL){
|
if (pCont != NULL) {
|
||||||
taosMemoryFree(pCont);
|
taosMemoryFree(pCont);
|
||||||
pCont = NULL;
|
pCont = NULL;
|
||||||
}
|
}
|
||||||
|
@ -603,132 +603,132 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
||||||
tFreeSStatisReq(&statisReq);
|
tFreeSStatisReq(&statisReq);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SJson* pJson = tjsonParse(statisReq.pCont);
|
SJson* pJson = tjsonParse(statisReq.pCont);
|
||||||
|
|
||||||
int32_t ts_size = tjsonGetArraySize(pJson);
|
int32_t ts_size = tjsonGetArraySize(pJson);
|
||||||
|
|
||||||
for(int32_t i = 0; i < ts_size; i++){
|
for(int32_t i = 0; i < ts_size; i++){
|
||||||
SJson* item = tjsonGetArrayItem(pJson, i);
|
SJson* item = tjsonGetArrayItem(pJson, i);
|
||||||
|
|
||||||
SJson* tables = tjsonGetObjectItem(item, "tables");
|
SJson* tables = tjsonGetObjectItem(item, "tables");
|
||||||
|
|
||||||
int32_t tableSize = tjsonGetArraySize(tables);
|
int32_t tableSize = tjsonGetArraySize(tables);
|
||||||
for(int32_t i = 0; i < tableSize; i++){
|
for(int32_t i = 0; i < tableSize; i++){
|
||||||
SJson* table = tjsonGetArrayItem(tables, i);
|
SJson* table = tjsonGetArrayItem(tables, i);
|
||||||
|
|
||||||
char tableName[MONITOR_TABLENAME_LEN] = {0};
|
char tableName[MONITOR_TABLENAME_LEN] = {0};
|
||||||
tjsonGetStringValue(table, "name", tableName);
|
tjsonGetStringValue(table, "name", tableName);
|
||||||
|
|
||||||
SJson* metricGroups = tjsonGetObjectItem(table, "metric_groups");
|
SJson* metricGroups = tjsonGetObjectItem(table, "metric_groups");
|
||||||
|
|
||||||
int32_t size = tjsonGetArraySize(metricGroups);
|
int32_t size = tjsonGetArraySize(metricGroups);
|
||||||
for(int32_t i = 0; i < size; i++){
|
for(int32_t i = 0; i < size; i++){
|
||||||
SJson* item = tjsonGetArrayItem(metricGroups, i);
|
SJson* item = tjsonGetArrayItem(metricGroups, i);
|
||||||
|
|
||||||
SJson* arrayTag = tjsonGetObjectItem(item, "tags");
|
SJson* arrayTag = tjsonGetObjectItem(item, "tags");
|
||||||
|
|
||||||
int32_t tagSize = tjsonGetArraySize(arrayTag);
|
int32_t tagSize = tjsonGetArraySize(arrayTag);
|
||||||
|
|
||||||
char** labels = taosMemoryMalloc(sizeof(char*) * tagSize);
|
char** labels = taosMemoryMalloc(sizeof(char*) * tagSize);
|
||||||
char** sample_labels = taosMemoryMalloc(sizeof(char*) * tagSize);
|
char** sample_labels = taosMemoryMalloc(sizeof(char*) * tagSize);
|
||||||
|
|
||||||
for(int32_t j = 0; j < tagSize; j++){
|
for(int32_t j = 0; j < tagSize; j++){
|
||||||
SJson* item = tjsonGetArrayItem(arrayTag, j);
|
SJson* item = tjsonGetArrayItem(arrayTag, j);
|
||||||
|
|
||||||
*(labels + j) = taosMemoryMalloc(MONITOR_TAG_NAME_LEN);
|
*(labels + j) = taosMemoryMalloc(MONITOR_TAG_NAME_LEN);
|
||||||
tjsonGetStringValue(item, "name", *(labels + j));
|
tjsonGetStringValue(item, "name", *(labels + j));
|
||||||
|
|
||||||
*(sample_labels + j) = taosMemoryMalloc(MONITOR_TAG_VALUE_LEN);
|
*(sample_labels + j) = taosMemoryMalloc(MONITOR_TAG_VALUE_LEN);
|
||||||
tjsonGetStringValue(item, "value", *(sample_labels + j));
|
tjsonGetStringValue(item, "value", *(sample_labels + j));
|
||||||
if(strncmp(*(labels + j), "cluster_id", MONITOR_TAG_NAME_LEN) == 0) {
|
if(strncmp(*(labels + j), "cluster_id", MONITOR_TAG_NAME_LEN) == 0) {
|
||||||
strncpy(*(sample_labels + j), strClusterId, MONITOR_TAG_VALUE_LEN);
|
strncpy(*(sample_labels + j), strClusterId, MONITOR_TAG_VALUE_LEN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SJson* metrics = tjsonGetObjectItem(item, "metrics");
|
SJson* metrics = tjsonGetObjectItem(item, "metrics");
|
||||||
|
|
||||||
int32_t metricLen = tjsonGetArraySize(metrics);
|
int32_t metricLen = tjsonGetArraySize(metrics);
|
||||||
for(int32_t j = 0; j < metricLen; j++){
|
for(int32_t j = 0; j < metricLen; j++){
|
||||||
SJson *item = tjsonGetArrayItem(metrics, j);
|
SJson *item = tjsonGetArrayItem(metrics, j);
|
||||||
|
|
||||||
char name[MONITOR_METRIC_NAME_LEN] = {0};
|
char name[MONITOR_METRIC_NAME_LEN] = {0};
|
||||||
tjsonGetStringValue(item, "name", name);
|
tjsonGetStringValue(item, "name", name);
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
tjsonGetDoubleValue(item, "value", &value);
|
tjsonGetDoubleValue(item, "value", &value);
|
||||||
|
|
||||||
double type = 0;
|
double type = 0;
|
||||||
tjsonGetDoubleValue(item, "type", &type);
|
tjsonGetDoubleValue(item, "type", &type);
|
||||||
|
|
||||||
int32_t metricNameLen = strlen(name) + strlen(tableName) + 2;
|
int32_t metricNameLen = strlen(name) + strlen(tableName) + 2;
|
||||||
char* metricName = taosMemoryMalloc(metricNameLen);
|
char* metricName = taosMemoryMalloc(metricNameLen);
|
||||||
memset(metricName, 0, metricNameLen);
|
memset(metricName, 0, metricNameLen);
|
||||||
sprintf(metricName, "%s:%s", tableName, name);
|
sprintf(metricName, "%s:%s", tableName, name);
|
||||||
|
|
||||||
taos_metric_t* metric = taos_collector_registry_get_metric(metricName);
|
taos_metric_t* metric = taos_collector_registry_get_metric(metricName);
|
||||||
if(metric == NULL){
|
if(metric == NULL){
|
||||||
if(type == 0){
|
|
||||||
metric = taos_counter_new(metricName, "", tagSize, (const char**)labels);
|
|
||||||
}
|
|
||||||
if(type == 1){
|
|
||||||
metric = taos_gauge_new(metricName, "", tagSize, (const char**)labels);
|
|
||||||
}
|
|
||||||
mTrace("fail to get metric from registry, new one metric:%p", metric);
|
|
||||||
|
|
||||||
if(taos_collector_registry_register_metric(metric) == 1){
|
|
||||||
if(type == 0){
|
if(type == 0){
|
||||||
taos_counter_destroy(metric);
|
metric = taos_counter_new(metricName, "", tagSize, (const char**)labels);
|
||||||
}
|
}
|
||||||
if(type == 1){
|
if(type == 1){
|
||||||
taos_gauge_destroy(metric);
|
metric = taos_gauge_new(metricName, "", tagSize, (const char**)labels);
|
||||||
}
|
}
|
||||||
|
mTrace("fail to get metric from registry, new one metric:%p", metric);
|
||||||
|
|
||||||
metric = taos_collector_registry_get_metric(metricName);
|
if(taos_collector_registry_register_metric(metric) == 1){
|
||||||
|
if(type == 0){
|
||||||
|
taos_counter_destroy(metric);
|
||||||
|
}
|
||||||
|
if(type == 1){
|
||||||
|
taos_gauge_destroy(metric);
|
||||||
|
}
|
||||||
|
|
||||||
mTrace("fail to register metric, get metric from registry:%p", metric);
|
metric = taos_collector_registry_get_metric(metricName);
|
||||||
|
|
||||||
|
mTrace("fail to register metric, get metric from registry:%p", metric);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
mTrace("succeed to register metric:%p", metric);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
mTrace("succeed to register metric:%p", metric);
|
mTrace("get metric from registry:%p", metric);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else{
|
if(type == 0){
|
||||||
mTrace("get metric from registry:%p", metric);
|
taos_counter_add(metric, value, (const char**)sample_labels);
|
||||||
|
}
|
||||||
|
if(type == 1){
|
||||||
|
taos_gauge_set(metric, value, (const char**)sample_labels);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFreeClear(metricName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == 0){
|
for(int32_t j = 0; j < tagSize; j++){
|
||||||
taos_counter_add(metric, value, (const char**)sample_labels);
|
taosMemoryFreeClear(*(labels + j));
|
||||||
}
|
taosMemoryFreeClear(*(sample_labels + j));
|
||||||
if(type == 1){
|
|
||||||
taos_gauge_set(metric, value, (const char**)sample_labels);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(metricName);
|
taosMemoryFreeClear(sample_labels);
|
||||||
|
taosMemoryFreeClear(labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int32_t j = 0; j < tagSize; j++){
|
|
||||||
taosMemoryFreeClear(*(labels + j));
|
|
||||||
taosMemoryFreeClear(*(sample_labels + j));
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFreeClear(sample_labels);
|
|
||||||
taosMemoryFreeClear(labels);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
code = 0;
|
||||||
|
|
||||||
code = 0;
|
_OVER:
|
||||||
|
if(pJson != NULL){
|
||||||
|
tjsonDelete(pJson);
|
||||||
|
pJson = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
_OVER:
|
tFreeSStatisReq(&statisReq);
|
||||||
if(pJson != NULL){
|
return code;
|
||||||
tjsonDelete(pJson);
|
*/
|
||||||
pJson = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
tFreeSStatisReq(&statisReq);
|
|
||||||
return code;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndUpdateDnodeObj(SMnode *pMnode, SDnodeObj *pDnode) {
|
static int32_t mndUpdateDnodeObj(SMnode *pMnode, SDnodeObj *pDnode) {
|
||||||
|
@ -816,8 +816,9 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
|
bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
|
||||||
bool supportVnodesChanged = pDnode->numOfSupportVnodes != statusReq.numOfSupportVnodes;
|
bool supportVnodesChanged = pDnode->numOfSupportVnodes != statusReq.numOfSupportVnodes;
|
||||||
bool encryptKeyChanged = pDnode->encryptionKeyChksum != statusReq.clusterCfg.encryptionKeyChksum;
|
bool encryptKeyChanged = pDnode->encryptionKeyChksum != statusReq.clusterCfg.encryptionKeyChksum;
|
||||||
|
bool enableWhiteListChanged = statusReq.clusterCfg.enableWhiteList != (tsEnableWhiteList ? 1 : 0);
|
||||||
bool needCheck = !online || dnodeChanged || reboot || supportVnodesChanged ||
|
bool needCheck = !online || dnodeChanged || reboot || supportVnodesChanged ||
|
||||||
pMnode->ipWhiteVer != statusReq.ipWhiteVer || encryptKeyChanged;
|
pMnode->ipWhiteVer != statusReq.ipWhiteVer || encryptKeyChanged || enableWhiteListChanged;
|
||||||
|
|
||||||
const STraceId *trace = &pReq->info.traceId;
|
const STraceId *trace = &pReq->info.traceId;
|
||||||
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
||||||
|
|
|
@ -56,13 +56,14 @@ static int32_t mndBuildStreamCheckpointSourceReq(void **pBuf, int32_t *pLen, int
|
||||||
int64_t streamId, int32_t taskId, int32_t transId, int8_t mndTrigger);
|
int64_t streamId, int32_t taskId, int32_t transId, int8_t mndTrigger);
|
||||||
static int32_t mndProcessNodeCheck(SRpcMsg *pReq);
|
static int32_t mndProcessNodeCheck(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessNodeCheckReq(SRpcMsg *pMsg);
|
static int32_t mndProcessNodeCheckReq(SRpcMsg *pMsg);
|
||||||
static SArray *extractNodeListFromStream(SMnode *pMnode, SArray* pNodeList);
|
static int32_t extractNodeListFromStream(SMnode *pMnode, SArray* pNodeList);
|
||||||
static int32_t mndProcessStreamReqCheckpoint(SRpcMsg *pReq);
|
static int32_t mndProcessStreamReqCheckpoint(SRpcMsg *pReq);
|
||||||
|
static int32_t mndProcessCheckpointReport(SRpcMsg *pReq);
|
||||||
|
|
||||||
static SVgroupChangeInfo mndFindChangedNodeInfo(SMnode *pMnode, const SArray *pPrevNodeList, const SArray *pNodeList);
|
static SVgroupChangeInfo mndFindChangedNodeInfo(SMnode *pMnode, const SArray *pPrevNodeList, const SArray *pNodeList);
|
||||||
|
|
||||||
void removeStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode);
|
static void addAllStreamTasksIntoBuf(SMnode *pMnode, SStreamExecInfo *pExecInfo);
|
||||||
static int32_t removeExpiredNodeEntryAndTaskInBuf(SArray *pNodeSnapshot);
|
static void removeExpiredNodeInfo(const SArray *pNodeSnapshot);
|
||||||
static int32_t doKillCheckpointTrans(SMnode *pMnode, const char *pDbName, size_t len);
|
static int32_t doKillCheckpointTrans(SMnode *pMnode, const char *pDbName, size_t len);
|
||||||
static SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw);
|
static SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw);
|
||||||
|
|
||||||
|
@ -103,6 +104,7 @@ int32_t mndInitStream(SMnode *pMnode) {
|
||||||
mndSetMsgHandle(pMnode, TDMT_STREAM_TASK_STOP_RSP, mndTransProcessRsp);
|
mndSetMsgHandle(pMnode, TDMT_STREAM_TASK_STOP_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_STREAM_TASK_UPDATE_RSP, mndTransProcessRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_STREAM_TASK_UPDATE_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_STREAM_TASK_RESET_RSP, mndTransProcessRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_STREAM_TASK_RESET_RSP, mndTransProcessRsp);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_STREAM_TASK_UPDATE_CHKPT_RSP, mndTransProcessRsp);
|
||||||
|
|
||||||
// for msgs inside mnode
|
// for msgs inside mnode
|
||||||
// TODO change the name
|
// TODO change the name
|
||||||
|
@ -114,8 +116,10 @@ int32_t mndInitStream(SMnode *pMnode) {
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_STREAM_CHECK_POINT_SOURCE_RSP, mndTransProcessRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_STREAM_CHECK_POINT_SOURCE_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_BEGIN_CHECKPOINT, mndProcessStreamCheckpoint);
|
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_BEGIN_CHECKPOINT, mndProcessStreamCheckpoint);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_REQ_CHKPT, mndProcessStreamReqCheckpoint);
|
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_REQ_CHKPT, mndProcessStreamReqCheckpoint);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_HEARTBEAT, mndProcessStreamHb);
|
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_CHKPT_REPORT, mndProcessCheckpointReport);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_UPDATE_CHKPT_EVT, mndScanCheckpointReportInfo);
|
||||||
mndSetMsgHandle(pMnode, TDMT_STREAM_TASK_REPORT_CHECKPOINT, mndTransProcessRsp);
|
mndSetMsgHandle(pMnode, TDMT_STREAM_TASK_REPORT_CHECKPOINT, mndTransProcessRsp);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_HEARTBEAT, mndProcessStreamHb);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_NODECHANGE_CHECK, mndProcessNodeCheckReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_NODECHANGE_CHECK, mndProcessNodeCheckReq);
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_PAUSE_STREAM, mndProcessPauseStreamReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_PAUSE_STREAM, mndProcessPauseStreamReq);
|
||||||
|
@ -131,9 +135,11 @@ int32_t mndInitStream(SMnode *pMnode) {
|
||||||
if (sdbSetTable(pMnode->pSdb, table) != 0) {
|
if (sdbSetTable(pMnode->pSdb, table) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdbSetTable(pMnode->pSdb, tableSeq) != 0) {
|
if (sdbSetTable(pMnode->pSdb, tableSeq) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +149,7 @@ void mndCleanupStream(SMnode *pMnode) {
|
||||||
taosHashCleanup(execInfo.pTaskMap);
|
taosHashCleanup(execInfo.pTaskMap);
|
||||||
taosHashCleanup(execInfo.transMgmt.pDBTrans);
|
taosHashCleanup(execInfo.transMgmt.pDBTrans);
|
||||||
taosHashCleanup(execInfo.pTransferStateStreams);
|
taosHashCleanup(execInfo.pTransferStateStreams);
|
||||||
|
taosHashCleanup(execInfo.pChkptStreams);
|
||||||
taosThreadMutexDestroy(&execInfo.lock);
|
taosThreadMutexDestroy(&execInfo.lock);
|
||||||
mDebug("mnd stream exec info cleanup");
|
mDebug("mnd stream exec info cleanup");
|
||||||
}
|
}
|
||||||
|
@ -508,7 +515,7 @@ int32_t mndPersistTaskDeployReq(STrans *pTrans, SStreamTask *pTask) {
|
||||||
tEncodeStreamTask(&encoder, pTask);
|
tEncodeStreamTask(&encoder, pTask);
|
||||||
tEncoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
int32_t code = setTransAction(pTrans, buf, tlen, TDMT_STREAM_TASK_DEPLOY, &pTask->info.epSet, 0);
|
int32_t code = setTransAction(pTrans, buf, tlen, TDMT_STREAM_TASK_DEPLOY, &pTask->info.epSet, 0, 0);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -952,7 +959,7 @@ static int32_t doSetCheckpointAction(SMnode *pMnode, STrans *pTrans, SStreamTask
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = setTransAction(pTrans, buf, tlen, TDMT_VND_STREAM_CHECK_POINT_SOURCE, &epset, TSDB_CODE_SYN_PROPOSE_NOT_READY);
|
code = setTransAction(pTrans, buf, tlen, TDMT_VND_STREAM_CHECK_POINT_SOURCE, &epset, TSDB_CODE_SYN_PROPOSE_NOT_READY, 0);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
}
|
}
|
||||||
|
@ -1088,7 +1095,7 @@ static bool taskNodeIsUpdated(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndCheckTaskAndNodeStatus(SMnode *pMnode) {
|
static int32_t mndCheckTaskAndNodeStatus(SMnode *pMnode) {
|
||||||
bool ready = true;
|
bool ready = true;
|
||||||
if (taskNodeIsUpdated(pMnode)) {
|
if (taskNodeIsUpdated(pMnode)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1099,6 +1106,8 @@ static int32_t mndCheckTaskAndNodeStatus(SMnode *pMnode) {
|
||||||
ASSERT(taosArrayGetSize(execInfo.pTaskList) == 0);
|
ASSERT(taosArrayGetSize(execInfo.pTaskList) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SArray* pInvalidList = taosArrayInit(4, sizeof(STaskId));
|
||||||
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(execInfo.pTaskList); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(execInfo.pTaskList); ++i) {
|
||||||
STaskId *p = taosArrayGet(execInfo.pTaskList, i);
|
STaskId *p = taosArrayGet(execInfo.pTaskList, i);
|
||||||
STaskStatusEntry *pEntry = taosHashGet(execInfo.pTaskMap, p, sizeof(*p));
|
STaskStatusEntry *pEntry = taosHashGet(execInfo.pTaskMap, p, sizeof(*p));
|
||||||
|
@ -1106,11 +1115,20 @@ static int32_t mndCheckTaskAndNodeStatus(SMnode *pMnode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pEntry->status == TASK_STATUS__STOP) {
|
||||||
|
for(int32_t j = 0; j < taosArrayGetSize(pInvalidList); ++j) {
|
||||||
|
STaskId* pId = taosArrayGet(pInvalidList, j);
|
||||||
|
if (pEntry->id.streamId == pId->streamId) {
|
||||||
|
taosArrayPush(pInvalidList, &pEntry->id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (pEntry->status != TASK_STATUS__READY) {
|
if (pEntry->status != TASK_STATUS__READY) {
|
||||||
mDebug("s-task:0x%" PRIx64 "-0x%x (nodeId:%d) status:%s not ready, checkpoint msg not issued",
|
mDebug("s-task:0x%" PRIx64 "-0x%x (nodeId:%d) status:%s, checkpoint not issued",
|
||||||
pEntry->id.streamId, (int32_t)pEntry->id.taskId, pEntry->nodeId, streamTaskGetStatusStr(pEntry->status));
|
pEntry->id.streamId, (int32_t)pEntry->id.taskId, pEntry->nodeId, streamTaskGetStatusStr(pEntry->status));
|
||||||
ready = false;
|
ready = false;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pEntry->hTaskId != 0) {
|
if (pEntry->hTaskId != 0) {
|
||||||
|
@ -1123,6 +1141,9 @@ static int32_t mndCheckTaskAndNodeStatus(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeTasksInBuf(pInvalidList, &execInfo);
|
||||||
|
taosArrayDestroy(pInvalidList);
|
||||||
|
|
||||||
taosThreadMutexUnlock(&execInfo.lock);
|
taosThreadMutexUnlock(&execInfo.lock);
|
||||||
return ready ? 0 : -1;
|
return ready ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
@ -1151,7 +1172,8 @@ static int32_t mndProcessStreamCheckpoint(SRpcMsg *pReq) {
|
||||||
int32_t numOfCheckpointTrans = 0;
|
int32_t numOfCheckpointTrans = 0;
|
||||||
|
|
||||||
if ((code = mndCheckTaskAndNodeStatus(pMnode)) != 0) {
|
if ((code = mndCheckTaskAndNodeStatus(pMnode)) != 0) {
|
||||||
return code;
|
terrno = TSDB_CODE_STREAM_TASK_IVLD_STATUS;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* pList = taosArrayInit(4, sizeof(SCheckpointInterval));
|
SArray* pList = taosArrayInit(4, sizeof(SCheckpointInterval));
|
||||||
|
@ -1798,6 +1820,10 @@ static int32_t mndRetrieveStreamTask(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
SStreamObj *pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
|
|
||||||
|
taosThreadMutexLock(&execInfo.lock);
|
||||||
|
mndInitStreamExecInfo(pMnode, &execInfo);
|
||||||
|
taosThreadMutexUnlock(&execInfo.lock);
|
||||||
|
|
||||||
while (numOfRows < rowsCapacity) {
|
while (numOfRows < rowsCapacity) {
|
||||||
pShow->pIter = sdbFetch(pSdb, SDB_STREAM, pShow->pIter, (void **)&pStream);
|
pShow->pIter = sdbFetch(pSdb, SDB_STREAM, pShow->pIter, (void **)&pStream);
|
||||||
if (pShow->pIter == NULL) {
|
if (pShow->pIter == NULL) {
|
||||||
|
@ -2169,7 +2195,7 @@ static int32_t mndProcessVgroupChange(SMnode *pMnode, SVgroupChangeInfo *pChange
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SArray *extractNodeListFromStream(SMnode *pMnode, SArray* pNodeList) {
|
static int32_t extractNodeListFromStream(SMnode *pMnode, SArray* pNodeList) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
SStreamObj *pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
|
@ -2215,48 +2241,6 @@ static SArray *extractNodeListFromStream(SMnode *pMnode, SArray* pNodeList) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool taskNodeExists(SArray *pList, int32_t nodeId) {
|
|
||||||
size_t num = taosArrayGetSize(pList);
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
|
||||||
SNodeEntry *pEntry = taosArrayGet(pList, i);
|
|
||||||
if (pEntry->nodeId == nodeId) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t removeExpiredNodeEntryAndTaskInBuf(SArray *pNodeSnapshot) {
|
|
||||||
SArray *pRemovedTasks = taosArrayInit(4, sizeof(STaskId));
|
|
||||||
|
|
||||||
int32_t numOfTask = taosArrayGetSize(execInfo.pTaskList);
|
|
||||||
for (int32_t i = 0; i < numOfTask; ++i) {
|
|
||||||
STaskId *pId = taosArrayGet(execInfo.pTaskList, i);
|
|
||||||
|
|
||||||
STaskStatusEntry *pEntry = taosHashGet(execInfo.pTaskMap, pId, sizeof(*pId));
|
|
||||||
if (pEntry->nodeId == SNODE_HANDLE) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool existed = taskNodeExists(pNodeSnapshot, pEntry->nodeId);
|
|
||||||
if (!existed) {
|
|
||||||
taosArrayPush(pRemovedTasks, pId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
removeTasksInBuf(pRemovedTasks, &execInfo);
|
|
||||||
|
|
||||||
mDebug("remove invalid stream tasks:%d, remain:%d", (int32_t)taosArrayGetSize(pRemovedTasks),
|
|
||||||
(int32_t)taosArrayGetSize(execInfo.pTaskList));
|
|
||||||
|
|
||||||
removeExpiredNodeInfo(pNodeSnapshot);
|
|
||||||
|
|
||||||
taosArrayDestroy(pRemovedTasks);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// this function runs by only one thread, so it is not multi-thread safe
|
// this function runs by only one thread, so it is not multi-thread safe
|
||||||
static int32_t mndProcessNodeCheckReq(SRpcMsg *pMsg) {
|
static int32_t mndProcessNodeCheckReq(SRpcMsg *pMsg) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -2476,13 +2460,137 @@ int32_t mndProcessStreamReqCheckpoint(SRpcMsg *pReq) {
|
||||||
taosThreadMutexUnlock(&execInfo.lock);
|
taosThreadMutexUnlock(&execInfo.lock);
|
||||||
|
|
||||||
{
|
{
|
||||||
SRpcMsg rsp = {.code = 0, .info = pReq->info, .contLen = sizeof(SMStreamReqCheckpointRspMsg)};
|
SRpcMsg rsp = {.code = 0, .info = pReq->info, .contLen = sizeof(SMStreamReqCheckpointRsp)};
|
||||||
rsp.pCont = rpcMallocCont(rsp.contLen);
|
rsp.pCont = rpcMallocCont(rsp.contLen);
|
||||||
SMsgHead *pHead = rsp.pCont;
|
SMsgHead *pHead = rsp.pCont;
|
||||||
pHead->vgId = htonl(req.nodeId);
|
pHead->vgId = htonl(req.nodeId);
|
||||||
|
|
||||||
tmsgSendRsp(&rsp);
|
tmsgSendRsp(&rsp);
|
||||||
|
pReq->info.handle = NULL; // disable auto rsp
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void doAddTaskInfo(SArray* pList, SCheckpointReport* pReport) {
|
||||||
|
bool existed = false;
|
||||||
|
for(int32_t i = 0; i < taosArrayGetSize(pList); ++i) {
|
||||||
|
STaskChkptInfo* p = taosArrayGet(pList ,i);
|
||||||
|
if (p->taskId == pReport->taskId) {
|
||||||
|
existed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!existed) {
|
||||||
|
STaskChkptInfo info = {
|
||||||
|
.streamId = pReport->streamId,
|
||||||
|
.taskId = pReport->taskId,
|
||||||
|
.transId = pReport->transId,
|
||||||
|
.dropHTask = pReport->dropHTask,
|
||||||
|
.version = pReport->checkpointVer,
|
||||||
|
.ts = pReport->checkpointTs,
|
||||||
|
.checkpointId = pReport->checkpointId,
|
||||||
|
.nodeId = pReport->nodeId,
|
||||||
|
};
|
||||||
|
taosArrayPush(pList, &info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndProcessCheckpointReport(SRpcMsg *pReq) {
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
SCheckpointReport req = {0};
|
||||||
|
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
tDecoderInit(&decoder, pReq->pCont, pReq->contLen);
|
||||||
|
|
||||||
|
if (tDecodeStreamTaskChkptReport(&decoder, &req)) {
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
mError("invalid task checkpoint-report msg received");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
|
mDebug("receive stream task checkpoint-report msg, vgId:%d, s-task:0x%x, checkpointId:%" PRId64
|
||||||
|
" checkpointVer:%" PRId64 " transId:%d",
|
||||||
|
req.nodeId, req.taskId, req.checkpointId, req.checkpointVer, req.transId);
|
||||||
|
|
||||||
|
// register to the stream task done map, if all tasks has sent this kinds of message, start the checkpoint trans.
|
||||||
|
taosThreadMutexLock(&execInfo.lock);
|
||||||
|
|
||||||
|
SStreamObj *pStream = mndGetStreamObj(pMnode, req.streamId);
|
||||||
|
if (pStream == NULL) {
|
||||||
|
mWarn("failed to find the stream:0x%" PRIx64 ", not handle checkpoint-report, try to acquire in buf",
|
||||||
|
req.streamId);
|
||||||
|
|
||||||
|
// not in meta-store yet, try to acquire the task in exec buffer
|
||||||
|
// the checkpoint req arrives too soon before the completion of the create stream trans.
|
||||||
|
STaskId id = {.streamId = req.streamId, .taskId = req.taskId};
|
||||||
|
void *p = taosHashGet(execInfo.pTaskMap, &id, sizeof(id));
|
||||||
|
if (p == NULL) {
|
||||||
|
mError("failed to find the stream:0x%" PRIx64 " in buf, not handle the checkpoint-report", req.streamId);
|
||||||
|
terrno = TSDB_CODE_MND_STREAM_NOT_EXIST;
|
||||||
|
taosThreadMutexUnlock(&execInfo.lock);
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
mDebug("s-task:0x%" PRIx64 "-0x%x in buf not in mnode/meta, create stream trans may not complete yet",
|
||||||
|
req.streamId, req.taskId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t numOfTasks = (pStream == NULL) ? 0 : mndGetNumOfStreamTasks(pStream);
|
||||||
|
|
||||||
|
SArray **pReqTaskList = (SArray **)taosHashGet(execInfo.pChkptStreams, &req.streamId, sizeof(req.streamId));
|
||||||
|
if (pReqTaskList == NULL) {
|
||||||
|
SArray *pList = taosArrayInit(4, sizeof(STaskChkptInfo));
|
||||||
|
doAddTaskInfo(pList, &req);
|
||||||
|
taosHashPut(execInfo.pChkptStreams, &req.streamId, sizeof(req.streamId), &pList, POINTER_BYTES);
|
||||||
|
|
||||||
|
pReqTaskList = (SArray **)taosHashGet(execInfo.pChkptStreams, &req.streamId, sizeof(req.streamId));
|
||||||
|
} else {
|
||||||
|
doAddTaskInfo(*pReqTaskList, &req);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t total = taosArrayGetSize(*pReqTaskList);
|
||||||
|
if (total == numOfTasks) { // all tasks has send the reqs
|
||||||
|
mInfo("stream:0x%" PRIx64 " %s all %d tasks send checkpoint-report, checkpoint meta-info for checkpointId:%" PRId64
|
||||||
|
" will be issued soon",
|
||||||
|
req.streamId, pStream->name, total, req.checkpointId);
|
||||||
|
|
||||||
|
// if (pStream != NULL) {
|
||||||
|
// bool conflict = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_CHKPT_UPDATE_NAME, false);
|
||||||
|
// if (conflict) {
|
||||||
|
// mDebug("stream:0x%"PRIx64" active checkpoint trans not finished yet, wait", req.streamId);
|
||||||
|
// } else {
|
||||||
|
// int32_t code = mndCreateStreamChkptInfoUpdateTrans(pMnode, pStream, *pReqTaskList);
|
||||||
|
// if (code == TSDB_CODE_SUCCESS) { // remove this entry
|
||||||
|
// taosHashRemove(execInfo.pChkptStreams, &req.streamId, sizeof(req.streamId));
|
||||||
|
//
|
||||||
|
// int32_t numOfStreams = taosHashGetSize(execInfo.pChkptStreams);
|
||||||
|
// mDebug("stream:0x%" PRIx64 " removed, remain streams:%d in checkpoint procedure", req.streamId,
|
||||||
|
// numOfStreams);
|
||||||
|
// } else {
|
||||||
|
// mDebug("stream:0x%" PRIx64 " not launch chkpt update trans, due to checkpoint not finished yet",
|
||||||
|
// req.streamId);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pStream != NULL) {
|
||||||
|
mndReleaseStream(pMnode, pStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosThreadMutexUnlock(&execInfo.lock);
|
||||||
|
|
||||||
|
{
|
||||||
|
SRpcMsg rsp = {.code = 0, .info = pReq->info, .contLen = sizeof(SMStreamUpdateChkptRsp)};
|
||||||
|
rsp.pCont = rpcMallocCont(rsp.contLen);
|
||||||
|
SMsgHead *pHead = rsp.pCont;
|
||||||
|
pHead->vgId = htonl(req.nodeId);
|
||||||
|
|
||||||
|
tmsgSendRsp(&rsp);
|
||||||
pReq->info.handle = NULL; // disable auto rsp
|
pReq->info.handle = NULL; // disable auto rsp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2510,3 +2618,63 @@ static int32_t mndProcessDropStreamReqFromMNode(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mndInitStreamExecInfo(SMnode *pMnode, SStreamExecInfo *pExecInfo) {
|
||||||
|
if (pExecInfo->initTaskList || pMnode == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
addAllStreamTasksIntoBuf(pMnode, pExecInfo);
|
||||||
|
extractNodeListFromStream(pMnode, pExecInfo->pNodeList);
|
||||||
|
pExecInfo->initTaskList = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addAllStreamTasksIntoBuf(SMnode *pMnode, SStreamExecInfo* pExecInfo) {
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
SStreamObj *pStream = NULL;
|
||||||
|
void *pIter = NULL;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
pIter = sdbFetch(pSdb, SDB_STREAM, pIter, (void **)&pStream);
|
||||||
|
if (pIter == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
saveTaskAndNodeInfoIntoBuf(pStream, pExecInfo);
|
||||||
|
sdbRelease(pSdb, pStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndCreateStreamChkptInfoUpdateTrans(SMnode *pMnode, SStreamObj *pStream, SArray* pChkptInfoList) {
|
||||||
|
STrans *pTrans = doCreateTrans(pMnode, pStream, NULL, TRN_CONFLICT_NOTHING, MND_STREAM_CHKPT_UPDATE_NAME, "update checkpoint-info");
|
||||||
|
if (pTrans == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int32_t code = */mndStreamRegisterTrans(pTrans, MND_STREAM_CHKPT_UPDATE_NAME, pStream->uid);
|
||||||
|
int32_t code = mndStreamSetUpdateChkptAction(pMnode, pTrans, pStream);
|
||||||
|
if (code != 0) {
|
||||||
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndPersistTransLog(pStream, pTrans, SDB_STATUS_READY);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
||||||
|
mError("trans:%d, failed to prepare update checkpoint-info meta trans since %s", pTrans->id, terrstr());
|
||||||
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
|
||||||
|
return TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
}
|
|
@ -22,54 +22,7 @@ typedef struct SFailedCheckpointInfo {
|
||||||
int32_t transId;
|
int32_t transId;
|
||||||
} SFailedCheckpointInfo;
|
} SFailedCheckpointInfo;
|
||||||
|
|
||||||
static void addAllStreamTasksIntoBuf(SMnode *pMnode, SStreamExecInfo* pExecInfo) {
|
static void mndStreamStartUpdateCheckpointInfo(SMnode *pMnode);
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
|
||||||
SStreamObj *pStream = NULL;
|
|
||||||
void *pIter = NULL;
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
pIter = sdbFetch(pSdb, SDB_STREAM, pIter, (void **)&pStream);
|
|
||||||
if (pIter == NULL) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
saveTaskAndNodeInfoIntoBuf(pStream, pExecInfo);
|
|
||||||
sdbRelease(pSdb, pStream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void removeDroppedStreamTasksInBuf(SMnode *pMnode, SStreamExecInfo *pExecInfo) {
|
|
||||||
if (pMnode == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t num = taosArrayGetSize(pExecInfo->pTaskList);
|
|
||||||
|
|
||||||
SHashObj *pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
|
||||||
SArray *pIdList = taosArrayInit(4, sizeof(STaskId));
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
|
||||||
STaskId* pId = taosArrayGet(pExecInfo->pTaskList, i);
|
|
||||||
|
|
||||||
void* p = taosHashGet(pHash, &pId->streamId, sizeof(int64_t));
|
|
||||||
if (p != NULL) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* pObj = mndGetStreamObj(pMnode, pId->streamId);
|
|
||||||
if (pObj != NULL) {
|
|
||||||
mndReleaseStream(pMnode, pObj);
|
|
||||||
taosHashPut(pHash, &pId->streamId, sizeof(int64_t), NULL, 0);
|
|
||||||
} else {
|
|
||||||
taosArrayPush(pIdList, pId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
removeTasksInBuf(pIdList, &execInfo);
|
|
||||||
|
|
||||||
taosArrayDestroy(pIdList);
|
|
||||||
taosHashCleanup(pHash);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void updateStageInfo(STaskStatusEntry *pTaskEntry, int64_t stage) {
|
static void updateStageInfo(STaskStatusEntry *pTaskEntry, int64_t stage) {
|
||||||
int32_t numOfNodes = taosArrayGetSize(execInfo.pNodeList);
|
int32_t numOfNodes = taosArrayGetSize(execInfo.pNodeList);
|
||||||
|
@ -290,16 +243,7 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
|
|
||||||
taosThreadMutexLock(&execInfo.lock);
|
taosThreadMutexLock(&execInfo.lock);
|
||||||
|
|
||||||
// extract stream task list
|
mndInitStreamExecInfo(pMnode, &execInfo);
|
||||||
if (taosHashGetSize(execInfo.pTaskMap) == 0) {
|
|
||||||
addAllStreamTasksIntoBuf(pMnode, &execInfo);
|
|
||||||
} else {
|
|
||||||
// the already dropped tasks may be added by hb from vnode at the time when the pTaskMap happens to be empty.
|
|
||||||
// let's drop them here.
|
|
||||||
removeDroppedStreamTasksInBuf(pMnode, &execInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
extractStreamNodeList(pMnode);
|
|
||||||
|
|
||||||
int32_t numOfUpdated = taosArrayGetSize(req.pUpdateNodes);
|
int32_t numOfUpdated = taosArrayGetSize(req.pUpdateNodes);
|
||||||
if (numOfUpdated > 0) {
|
if (numOfUpdated > 0) {
|
||||||
|
@ -326,18 +270,6 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
snodeChanged = true;
|
snodeChanged = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// task is idle for more than 50 sec.
|
|
||||||
// if (fabs(pTaskEntry->inputQUsed - p->inputQUsed) <= DBL_EPSILON) {
|
|
||||||
// if (!pTaskEntry->inputQChanging) {
|
|
||||||
// pTaskEntry->inputQUnchangeCounter++;
|
|
||||||
// } else {
|
|
||||||
// pTaskEntry->inputQChanging = false;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// pTaskEntry->inputQChanging = true;
|
|
||||||
// pTaskEntry->inputQUnchangeCounter = 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
streamTaskStatusCopy(pTaskEntry, p);
|
streamTaskStatusCopy(pTaskEntry, p);
|
||||||
|
|
||||||
STaskCkptInfo *pChkInfo = &p->checkpointInfo;
|
STaskCkptInfo *pChkInfo = &p->checkpointInfo;
|
||||||
|
@ -348,6 +280,9 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
SFailedCheckpointInfo info = {
|
SFailedCheckpointInfo info = {
|
||||||
.transId = pChkInfo->activeTransId, .checkpointId = pChkInfo->activeId, .streamUid = p->id.streamId};
|
.transId = pChkInfo->activeTransId, .checkpointId = pChkInfo->activeId, .streamUid = p->id.streamId};
|
||||||
addIntoCheckpointList(pFailedChkpt, &info);
|
addIntoCheckpointList(pFailedChkpt, &info);
|
||||||
|
|
||||||
|
// remove failed trans from pChkptStreams
|
||||||
|
taosHashRemove(execInfo.pChkptStreams, &p->id.streamId, sizeof(p->id.streamId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,6 +328,10 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
mndDropOrphanTasks(pMnode, pOrphanTasks);
|
mndDropOrphanTasks(pMnode, pOrphanTasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pMnode != NULL) { // make sure that the unit test case can work
|
||||||
|
mndStreamStartUpdateCheckpointInfo(pMnode);
|
||||||
|
}
|
||||||
|
|
||||||
taosThreadMutexUnlock(&execInfo.lock);
|
taosThreadMutexUnlock(&execInfo.lock);
|
||||||
tCleanupStreamHbMsg(&req);
|
tCleanupStreamHbMsg(&req);
|
||||||
|
|
||||||
|
@ -411,3 +350,12 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mndStreamStartUpdateCheckpointInfo(SMnode *pMnode) { // here reuse the doCheckpointmsg
|
||||||
|
SMStreamDoCheckpointMsg *pMsg = rpcMallocCont(sizeof(SMStreamDoCheckpointMsg));
|
||||||
|
if (pMsg != NULL) {
|
||||||
|
int32_t size = sizeof(SMStreamDoCheckpointMsg);
|
||||||
|
SRpcMsg rpcMsg = {.msgType = TDMT_MND_STREAM_UPDATE_CHKPT_EVT, .pCont = pMsg, .contLen = size};
|
||||||
|
tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||||
|
}
|
||||||
|
}
|
|
@ -127,7 +127,7 @@ bool mndStreamTransConflictCheck(SMnode* pMnode, int64_t streamId, const char* p
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndStreamGetRelTrans(SMnode* pMnode, int64_t streamUid) {
|
int32_t mndStreamGetRelTrans(SMnode* pMnode, int64_t streamId) {
|
||||||
taosThreadMutexLock(&execInfo.lock);
|
taosThreadMutexLock(&execInfo.lock);
|
||||||
int32_t num = taosHashGetSize(execInfo.transMgmt.pDBTrans);
|
int32_t num = taosHashGetSize(execInfo.transMgmt.pDBTrans);
|
||||||
if (num <= 0) {
|
if (num <= 0) {
|
||||||
|
@ -136,12 +136,13 @@ int32_t mndStreamGetRelTrans(SMnode* pMnode, int64_t streamUid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mndStreamClearFinishedTrans(pMnode, NULL);
|
mndStreamClearFinishedTrans(pMnode, NULL);
|
||||||
SStreamTransInfo* pEntry = taosHashGet(execInfo.transMgmt.pDBTrans, &streamUid, sizeof(streamUid));
|
SStreamTransInfo* pEntry = taosHashGet(execInfo.transMgmt.pDBTrans, &streamId, sizeof(streamId));
|
||||||
if (pEntry != NULL) {
|
if (pEntry != NULL) {
|
||||||
SStreamTransInfo tInfo = *pEntry;
|
SStreamTransInfo tInfo = *pEntry;
|
||||||
taosThreadMutexUnlock(&execInfo.lock);
|
taosThreadMutexUnlock(&execInfo.lock);
|
||||||
|
|
||||||
if (strcmp(tInfo.name, MND_STREAM_CHECKPOINT_NAME) == 0 || strcmp(tInfo.name, MND_STREAM_TASK_UPDATE_NAME) == 0) {
|
if (strcmp(tInfo.name, MND_STREAM_CHECKPOINT_NAME) == 0 || strcmp(tInfo.name, MND_STREAM_TASK_UPDATE_NAME) == 0 ||
|
||||||
|
strcmp(tInfo.name, MND_STREAM_CHKPT_UPDATE_NAME) == 0) {
|
||||||
return tInfo.transId;
|
return tInfo.transId;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -159,7 +160,7 @@ STrans *doCreateTrans(SMnode *pMnode, SStreamObj *pStream, SRpcMsg *pReq, ETrnCo
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo("s-task:0x%" PRIx64 " start to build trans %s, transId:%d", pStream->uid, pMsg, pTrans->id);
|
mInfo("stream:0x%" PRIx64 " start to build trans %s, transId:%d", pStream->uid, pMsg, pTrans->id);
|
||||||
|
|
||||||
mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetSTbName);
|
mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetSTbName);
|
||||||
if (mndTransCheckConflict(pMnode, pTrans) != 0) {
|
if (mndTransCheckConflict(pMnode, pTrans) != 0) {
|
||||||
|
@ -246,8 +247,9 @@ int32_t mndPersistTransLog(SStreamObj *pStream, STrans *pTrans, int32_t status)
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t setTransAction(STrans *pTrans, void *pCont, int32_t contLen, int32_t msgType, const SEpSet *pEpset,
|
int32_t setTransAction(STrans *pTrans, void *pCont, int32_t contLen, int32_t msgType, const SEpSet *pEpset,
|
||||||
int32_t retryCode) {
|
int32_t retryCode, int32_t acceptCode) {
|
||||||
STransAction action = {.epSet = *pEpset, .contLen = contLen, .pCont = pCont, .msgType = msgType, .retryCode = retryCode};
|
STransAction action = {.epSet = *pEpset, .contLen = contLen, .pCont = pCont, .msgType = msgType, .retryCode = retryCode,
|
||||||
|
.acceptableCode = acceptCode};
|
||||||
return mndTransAppendRedoAction(pTrans, &action);
|
return mndTransAppendRedoAction(pTrans, &action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,7 +230,7 @@ static int32_t doSetResumeAction(STrans *pTrans, SMnode *pMnode, SStreamTask *pT
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = setTransAction(pTrans, pReq, sizeof(SVResumeStreamTaskReq), TDMT_STREAM_TASK_RESUME, &epset, 0);
|
code = setTransAction(pTrans, pReq, sizeof(SVResumeStreamTaskReq), TDMT_STREAM_TASK_RESUME, &epset, 0, 0);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
taosMemoryFree(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -308,7 +308,7 @@ static int32_t doSetPauseAction(SMnode *pMnode, STrans *pTrans, SStreamTask *pTa
|
||||||
epsetToStr(&epset, buf, tListLen(buf));
|
epsetToStr(&epset, buf, tListLen(buf));
|
||||||
mDebug("pause stream task in node:%d, epset:%s", pTask->info.nodeId, buf);
|
mDebug("pause stream task in node:%d, epset:%s", pTask->info.nodeId, buf);
|
||||||
|
|
||||||
code = setTransAction(pTrans, pReq, sizeof(SVPauseStreamTaskReq), TDMT_STREAM_TASK_PAUSE, &epset, 0);
|
code = setTransAction(pTrans, pReq, sizeof(SVPauseStreamTaskReq), TDMT_STREAM_TASK_PAUSE, &epset, 0, 0);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
taosMemoryFree(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -356,7 +356,7 @@ static int32_t doSetDropAction(SMnode *pMnode, STrans *pTrans, SStreamTask *pTas
|
||||||
}
|
}
|
||||||
|
|
||||||
// The epset of nodeId of this task may have been expired now, let's use the newest epset from mnode.
|
// The epset of nodeId of this task may have been expired now, let's use the newest epset from mnode.
|
||||||
code = setTransAction(pTrans, pReq, sizeof(SVDropStreamTaskReq), TDMT_STREAM_TASK_DROP, &epset, 0);
|
code = setTransAction(pTrans, pReq, sizeof(SVDropStreamTaskReq), TDMT_STREAM_TASK_DROP, &epset, 0, 0);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
taosMemoryFree(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -400,7 +400,7 @@ static int32_t doSetDropActionFromId(SMnode *pMnode, STrans *pTrans, SOrphanTask
|
||||||
}
|
}
|
||||||
|
|
||||||
// The epset of nodeId of this task may have been expired now, let's use the newest epset from mnode.
|
// The epset of nodeId of this task may have been expired now, let's use the newest epset from mnode.
|
||||||
code = setTransAction(pTrans, pReq, sizeof(SVDropStreamTaskReq), TDMT_STREAM_TASK_DROP, &epset, 0);
|
code = setTransAction(pTrans, pReq, sizeof(SVDropStreamTaskReq), TDMT_STREAM_TASK_DROP, &epset, 0, 0);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
taosMemoryFree(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -484,7 +484,7 @@ static int32_t doSetUpdateTaskAction(SMnode *pMnode, STrans *pTrans, SStreamTask
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = setTransAction(pTrans, pBuf, len, TDMT_VND_STREAM_TASK_UPDATE, &epset, TSDB_CODE_VND_INVALID_VGROUP_ID);
|
code = setTransAction(pTrans, pBuf, len, TDMT_VND_STREAM_TASK_UPDATE, &epset, TSDB_CODE_VND_INVALID_VGROUP_ID, 0);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
taosMemoryFree(pBuf);
|
taosMemoryFree(pBuf);
|
||||||
}
|
}
|
||||||
|
@ -534,7 +534,7 @@ static int32_t doSetResetAction(SMnode *pMnode, STrans *pTrans, SStreamTask *pTa
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = setTransAction(pTrans, pReq, sizeof(SVResetStreamTaskReq), TDMT_VND_STREAM_TASK_RESET, &epset, 0);
|
code = setTransAction(pTrans, pReq, sizeof(SVResetStreamTaskReq), TDMT_VND_STREAM_TASK_RESET, &epset, 0, 0);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
taosMemoryFree(pReq);
|
taosMemoryFree(pReq);
|
||||||
}
|
}
|
||||||
|
@ -574,9 +574,11 @@ void mndInitExecInfo() {
|
||||||
execInfo.pTaskMap = taosHashInit(64, fn, true, HASH_NO_LOCK);
|
execInfo.pTaskMap = taosHashInit(64, fn, true, HASH_NO_LOCK);
|
||||||
execInfo.transMgmt.pDBTrans = taosHashInit(32, fn, true, HASH_NO_LOCK);
|
execInfo.transMgmt.pDBTrans = taosHashInit(32, fn, true, HASH_NO_LOCK);
|
||||||
execInfo.pTransferStateStreams = taosHashInit(32, fn, true, HASH_NO_LOCK);
|
execInfo.pTransferStateStreams = taosHashInit(32, fn, true, HASH_NO_LOCK);
|
||||||
|
execInfo.pChkptStreams = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||||
execInfo.pNodeList = taosArrayInit(4, sizeof(SNodeEntry));
|
execInfo.pNodeList = taosArrayInit(4, sizeof(SNodeEntry));
|
||||||
|
|
||||||
taosHashSetFreeFp(execInfo.pTransferStateStreams, freeTaskList);
|
taosHashSetFreeFp(execInfo.pTransferStateStreams, freeTaskList);
|
||||||
|
taosHashSetFreeFp(execInfo.pChkptStreams, freeTaskList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeExpiredNodeInfo(const SArray *pNodeSnapshot) {
|
void removeExpiredNodeInfo(const SArray *pNodeSnapshot) {
|
||||||
|
@ -645,4 +647,174 @@ void removeStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode) {
|
||||||
taosThreadMutexUnlock(&pExecNode->lock);
|
taosThreadMutexUnlock(&pExecNode->lock);
|
||||||
|
|
||||||
destroyStreamTaskIter(pIter);
|
destroyStreamTaskIter(pIter);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool taskNodeExists(SArray *pList, int32_t nodeId) {
|
||||||
|
size_t num = taosArrayGetSize(pList);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
|
SNodeEntry *pEntry = taosArrayGet(pList, i);
|
||||||
|
if (pEntry->nodeId == nodeId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t removeExpiredNodeEntryAndTaskInBuf(SArray *pNodeSnapshot) {
|
||||||
|
SArray *pRemovedTasks = taosArrayInit(4, sizeof(STaskId));
|
||||||
|
|
||||||
|
int32_t numOfTask = taosArrayGetSize(execInfo.pTaskList);
|
||||||
|
for (int32_t i = 0; i < numOfTask; ++i) {
|
||||||
|
STaskId *pId = taosArrayGet(execInfo.pTaskList, i);
|
||||||
|
|
||||||
|
STaskStatusEntry *pEntry = taosHashGet(execInfo.pTaskMap, pId, sizeof(*pId));
|
||||||
|
if (pEntry->nodeId == SNODE_HANDLE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool existed = taskNodeExists(pNodeSnapshot, pEntry->nodeId);
|
||||||
|
if (!existed) {
|
||||||
|
taosArrayPush(pRemovedTasks, pId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
removeTasksInBuf(pRemovedTasks, &execInfo);
|
||||||
|
|
||||||
|
mDebug("remove invalid stream tasks:%d, remain:%d", (int32_t)taosArrayGetSize(pRemovedTasks),
|
||||||
|
(int32_t)taosArrayGetSize(execInfo.pTaskList));
|
||||||
|
|
||||||
|
removeExpiredNodeInfo(pNodeSnapshot);
|
||||||
|
|
||||||
|
taosArrayDestroy(pRemovedTasks);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t doSetUpdateChkptAction(SMnode *pMnode, STrans *pTrans, SStreamTask *pTask) {
|
||||||
|
SVUpdateCheckpointInfoReq *pReq = taosMemoryCalloc(1, sizeof(SVUpdateCheckpointInfoReq));
|
||||||
|
if (pReq == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
mError("failed to malloc in reset stream, size:%" PRIzu ", code:%s", sizeof(SVUpdateCheckpointInfoReq),
|
||||||
|
tstrerror(TSDB_CODE_OUT_OF_MEMORY));
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
pReq->head.vgId = htonl(pTask->info.nodeId);
|
||||||
|
pReq->taskId = pTask->id.taskId;
|
||||||
|
pReq->streamId = pTask->id.streamId;
|
||||||
|
|
||||||
|
SArray **pReqTaskList = (SArray **)taosHashGet(execInfo.pChkptStreams, &pTask->id.streamId, sizeof(pTask->id.streamId));
|
||||||
|
ASSERT(pReqTaskList);
|
||||||
|
|
||||||
|
int32_t size = taosArrayGetSize(*pReqTaskList);
|
||||||
|
for(int32_t i = 0; i < size; ++i) {
|
||||||
|
STaskChkptInfo* pInfo = taosArrayGet(*pReqTaskList, i);
|
||||||
|
if (pInfo->taskId == pTask->id.taskId) {
|
||||||
|
pReq->checkpointId = pInfo->checkpointId;
|
||||||
|
pReq->checkpointVer = pInfo->version;
|
||||||
|
pReq->checkpointTs = pInfo->ts;
|
||||||
|
pReq->dropRelHTask = pInfo->dropHTask;
|
||||||
|
pReq->transId = pInfo->transId;
|
||||||
|
pReq->hStreamId = pTask->hTaskInfo.id.streamId;
|
||||||
|
pReq->hTaskId = pTask->hTaskInfo.id.taskId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SEpSet epset = {0};
|
||||||
|
bool hasEpset = false;
|
||||||
|
int32_t code = extractNodeEpset(pMnode, &epset, &hasEpset, pTask->id.taskId, pTask->info.nodeId);
|
||||||
|
if (code != TSDB_CODE_SUCCESS || !hasEpset) {
|
||||||
|
taosMemoryFree(pReq);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = setTransAction(pTrans, pReq, sizeof(SVUpdateCheckpointInfoReq), TDMT_STREAM_TASK_UPDATE_CHKPT, &epset, 0, TSDB_CODE_VND_INVALID_VGROUP_ID);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
taosMemoryFree(pReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndStreamSetUpdateChkptAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) {
|
||||||
|
taosWLockLatch(&pStream->lock);
|
||||||
|
|
||||||
|
SStreamTaskIter *pIter = createStreamTaskIter(pStream);
|
||||||
|
while (streamTaskIterNextTask(pIter)) {
|
||||||
|
SStreamTask *pTask = streamTaskIterGetCurrent(pIter);
|
||||||
|
|
||||||
|
int32_t code = doSetUpdateChkptAction(pMnode, pTrans, pTask);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
destroyStreamTaskIter(pIter);
|
||||||
|
taosWUnLockLatch(&pStream->lock);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
destroyStreamTaskIter(pIter);
|
||||||
|
taosWUnLockLatch(&pStream->lock);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndScanCheckpointReportInfo(SRpcMsg *pReq) {
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
void *pIter = NULL;
|
||||||
|
SArray *pDropped = taosArrayInit(4, sizeof(int64_t));
|
||||||
|
|
||||||
|
mDebug("start to scan checkpoint report info");
|
||||||
|
|
||||||
|
while ((pIter = taosHashIterate(execInfo.pChkptStreams, pIter)) != NULL) {
|
||||||
|
SArray *pList = *(SArray **)pIter;
|
||||||
|
|
||||||
|
STaskChkptInfo* pInfo = taosArrayGet(pList, 0);
|
||||||
|
SStreamObj* pStream = mndGetStreamObj(pMnode, pInfo->streamId);
|
||||||
|
if (pStream == NULL) {
|
||||||
|
mDebug("failed to acquire stream:0x%" PRIx64 " remove it from checkpoint-report list", pInfo->streamId);
|
||||||
|
taosArrayPush(pDropped, &pInfo->streamId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t total = mndGetNumOfStreamTasks(pStream);
|
||||||
|
int32_t existed = (int32_t) taosArrayGetSize(pList);
|
||||||
|
|
||||||
|
if (total == existed) {
|
||||||
|
mDebug("stream:0x%" PRIx64 " %s all %d tasks send checkpoint-report, start to update checkpoint-info",
|
||||||
|
pStream->uid, pStream->name, total);
|
||||||
|
|
||||||
|
bool conflict = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_CHKPT_UPDATE_NAME, false);
|
||||||
|
if (!conflict) {
|
||||||
|
int32_t code = mndCreateStreamChkptInfoUpdateTrans(pMnode, pStream, pList);
|
||||||
|
if (code == TSDB_CODE_SUCCESS || code == TSDB_CODE_ACTION_IN_PROGRESS) { // remove this entry
|
||||||
|
taosArrayPush(pDropped, &pInfo->streamId);
|
||||||
|
mDebug("stream:0x%" PRIx64 " removed", pInfo->streamId);
|
||||||
|
} else {
|
||||||
|
mDebug("stream:0x%" PRIx64 " not launch chkpt-meta update trans, due to checkpoint not finished yet",
|
||||||
|
pInfo->streamId);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
mDebug("stream:0x%"PRIx64" active checkpoint trans not finished yet, wait", pInfo->streamId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mDebug("stream:0x%" PRIx64 " %s %d/%d tasks send checkpoint-report, %d not send", pInfo->streamId, pStream->name,
|
||||||
|
existed, total, total - existed);
|
||||||
|
}
|
||||||
|
|
||||||
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t size = taosArrayGetSize(pDropped);
|
||||||
|
if (size > 0) {
|
||||||
|
for (int32_t i = 0; i < size; ++i) {
|
||||||
|
int64_t streamId = *(int64_t *)taosArrayGet(pDropped, i);
|
||||||
|
taosHashRemove(execInfo.pChkptStreams, &streamId, sizeof(streamId));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t numOfStreams = taosHashGetSize(execInfo.pChkptStreams);
|
||||||
|
mDebug("drop %d stream(s) in checkpoint-report list, remain:%d", size, numOfStreams);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pDropped);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
|
@ -618,13 +618,13 @@ static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOu
|
||||||
char cgroup[TSDB_CGROUP_LEN] = {0};
|
char cgroup[TSDB_CGROUP_LEN] = {0};
|
||||||
mndSplitSubscribeKey(pOutput->pSub->key, topic, cgroup, true);
|
mndSplitSubscribeKey(pOutput->pSub->key, topic, cgroup, true);
|
||||||
|
|
||||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_TOPIC_INSIDE, pMsg, "tmq-reb");
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pMsg, "tmq-reb");
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
mndTransSetDbName(pTrans, topic, cgroup);
|
mndTransSetDbName(pTrans, pOutput->pSub->dbName, cgroup);
|
||||||
code = mndTransCheckConflict(pMnode, pTrans);
|
code = mndTransCheckConflict(pMnode, pTrans);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
goto END;
|
goto END;
|
||||||
|
@ -908,33 +908,37 @@ END:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sendDeleteSubToVnode(SMnode *pMnode, SMqSubscribeObj *pSub, STrans *pTrans){
|
static int32_t sendDeleteSubToVnode(SMnode *pMnode, SMqSubscribeObj *pSub, STrans *pTrans){
|
||||||
// iter all vnode to delete handle
|
void* pIter = NULL;
|
||||||
int32_t sz = taosArrayGetSize(pSub->unassignedVgs);
|
SVgObj* pVgObj = NULL;
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
while (1) {
|
||||||
SMqVgEp *pVgEp = taosArrayGetP(pSub->unassignedVgs, i);
|
pIter = sdbFetch(pMnode->pSdb, SDB_VGROUP, pIter, (void**)&pVgObj);
|
||||||
|
if (pIter == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mndVgroupInDb(pVgObj, pSub->dbUid)) {
|
||||||
|
sdbRelease(pMnode->pSdb, pVgObj);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
SMqVDeleteReq *pReq = taosMemoryCalloc(1, sizeof(SMqVDeleteReq));
|
SMqVDeleteReq *pReq = taosMemoryCalloc(1, sizeof(SMqVDeleteReq));
|
||||||
if(pReq == NULL){
|
if(pReq == NULL){
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
sdbRelease(pMnode->pSdb, pVgObj);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pReq->head.vgId = htonl(pVgEp->vgId);
|
pReq->head.vgId = htonl(pVgObj->vgId);
|
||||||
pReq->vgId = pVgEp->vgId;
|
pReq->vgId = pVgObj->vgId;
|
||||||
pReq->consumerId = -1;
|
pReq->consumerId = -1;
|
||||||
memcpy(pReq->subKey, pSub->key, TSDB_SUBSCRIBE_KEY_LEN);
|
memcpy(pReq->subKey, pSub->key, TSDB_SUBSCRIBE_KEY_LEN);
|
||||||
|
|
||||||
SVgObj *pVgObj = mndAcquireVgroup(pMnode, pVgEp->vgId);
|
|
||||||
if (pVgObj == NULL) {
|
|
||||||
taosMemoryFree(pReq);
|
|
||||||
terrno = TSDB_CODE_MND_VGROUP_NOT_EXIST;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
STransAction action = {0};
|
STransAction action = {0};
|
||||||
action.epSet = mndGetVgroupEpset(pMnode, pVgObj);;
|
action.epSet = mndGetVgroupEpset(pMnode, pVgObj);;
|
||||||
action.pCont = pReq;
|
action.pCont = pReq;
|
||||||
action.contLen = sizeof(SMqVDeleteReq);
|
action.contLen = sizeof(SMqVDeleteReq);
|
||||||
action.msgType = TDMT_VND_TMQ_DELETE_SUB;
|
action.msgType = TDMT_VND_TMQ_DELETE_SUB;
|
||||||
|
action.acceptableCode = TSDB_CODE_MND_VGROUP_NOT_EXIST;
|
||||||
|
|
||||||
mndReleaseVgroup(pMnode, pVgObj);
|
sdbRelease(pMnode->pSdb, pVgObj);
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
taosMemoryFree(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -996,7 +1000,7 @@ static int32_t mndProcessDropCgroupReq(SRpcMsg *pMsg) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_TOPIC_INSIDE, pMsg, "drop-cgroup");
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pMsg, "drop-cgroup");
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
mError("cgroup: %s on topic:%s, failed to drop since %s", dropReq.cgroup, dropReq.topic, terrstr());
|
mError("cgroup: %s on topic:%s, failed to drop since %s", dropReq.cgroup, dropReq.topic, terrstr());
|
||||||
code = -1;
|
code = -1;
|
||||||
|
@ -1004,7 +1008,7 @@ static int32_t mndProcessDropCgroupReq(SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo("trans:%d, used to drop cgroup:%s on topic %s", pTrans->id, dropReq.cgroup, dropReq.topic);
|
mInfo("trans:%d, used to drop cgroup:%s on topic %s", pTrans->id, dropReq.cgroup, dropReq.topic);
|
||||||
mndTransSetDbName(pTrans, dropReq.topic, dropReq.cgroup);
|
mndTransSetDbName(pTrans, pSub->dbName, dropReq.cgroup);
|
||||||
code = mndTransCheckConflict(pMnode, pTrans);
|
code = mndTransCheckConflict(pMnode, pTrans);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
goto end;
|
goto end;
|
||||||
|
|
|
@ -422,14 +422,14 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
|
||||||
SQueryPlan *pPlan = NULL;
|
SQueryPlan *pPlan = NULL;
|
||||||
SMqTopicObj topicObj = {0};
|
SMqTopicObj topicObj = {0};
|
||||||
|
|
||||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_TOPIC, pReq, "create-topic");
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB, pReq, "create-topic");
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||||
code = -1;
|
code = -1;
|
||||||
goto _OUT;
|
goto _OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
mndTransSetDbName(pTrans, pCreate->name, NULL);
|
mndTransSetDbName(pTrans, pDb->name, NULL);
|
||||||
code = mndTransCheckConflict(pMnode, pTrans);
|
code = mndTransCheckConflict(pMnode, pTrans);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
goto _OUT;
|
goto _OUT;
|
||||||
|
@ -779,14 +779,14 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_TOPIC, pReq, "drop-topic");
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "drop-topic");
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
mError("topic:%s, failed to drop since %s", pTopic->name, terrstr());
|
mError("topic:%s, failed to drop since %s", pTopic->name, terrstr());
|
||||||
code = -1;
|
code = -1;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
mndTransSetDbName(pTrans, pTopic->name, NULL);
|
mndTransSetDbName(pTrans, pTopic->db, NULL);
|
||||||
code = mndTransCheckConflict(pMnode, pTrans);
|
code = mndTransCheckConflict(pMnode, pTrans);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
goto end;
|
goto end;
|
||||||
|
|
|
@ -836,26 +836,26 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pNew->conflict == TRN_CONFLICT_TOPIC) {
|
// if (pNew->conflict == TRN_CONFLICT_TOPIC) {
|
||||||
if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true;
|
// if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true;
|
||||||
if (pTrans->conflict == TRN_CONFLICT_TOPIC || pTrans->conflict == TRN_CONFLICT_TOPIC_INSIDE) {
|
// if (pTrans->conflict == TRN_CONFLICT_TOPIC || pTrans->conflict == TRN_CONFLICT_TOPIC_INSIDE) {
|
||||||
if (strcasecmp(pNew->dbname, pTrans->dbname) == 0) conflict = true;
|
// if (strcasecmp(pNew->dbname, pTrans->dbname) == 0) conflict = true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (pNew->conflict == TRN_CONFLICT_TOPIC_INSIDE) {
|
// if (pNew->conflict == TRN_CONFLICT_TOPIC_INSIDE) {
|
||||||
if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true;
|
// if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true;
|
||||||
if (pTrans->conflict == TRN_CONFLICT_TOPIC) {
|
// if (pTrans->conflict == TRN_CONFLICT_TOPIC) {
|
||||||
if (strcasecmp(pNew->dbname, pTrans->dbname) == 0) conflict = true;
|
// if (strcasecmp(pNew->dbname, pTrans->dbname) == 0) conflict = true;
|
||||||
}
|
// }
|
||||||
if (pTrans->conflict == TRN_CONFLICT_TOPIC_INSIDE) {
|
// if (pTrans->conflict == TRN_CONFLICT_TOPIC_INSIDE) {
|
||||||
if (strcasecmp(pNew->dbname, pTrans->dbname) == 0 && strcasecmp(pNew->stbname, pTrans->stbname) == 0)
|
// if (strcasecmp(pNew->dbname, pTrans->dbname) == 0 && strcasecmp(pNew->stbname, pTrans->stbname) == 0)
|
||||||
conflict = true;
|
// conflict = true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (pNew->conflict == TRN_CONFLICT_ARBGROUP) {
|
if (pNew->conflict == TRN_CONFLICT_ARBGROUP) {
|
||||||
if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true;
|
if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true;
|
||||||
if (pTrans->conflict == TRN_CONFLICT_ARBGROUP) {
|
if (pTrans->conflict == TRN_CONFLICT_ARBGROUP) {
|
||||||
void *pIter = taosHashIterate(pNew->arbGroupIds, NULL);
|
pIter = taosHashIterate(pNew->arbGroupIds, NULL);
|
||||||
while (pIter != NULL) {
|
while (pIter != NULL) {
|
||||||
int32_t groupId = *(int32_t *)pIter;
|
int32_t groupId = *(int32_t *)pIter;
|
||||||
if (taosHashGet(pTrans->arbGroupIds, &groupId, sizeof(int32_t)) != NULL) {
|
if (taosHashGet(pTrans->arbGroupIds, &groupId, sizeof(int32_t)) != NULL) {
|
||||||
|
|
|
@ -818,7 +818,7 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
|
||||||
SDB_SET_INT8(pRaw, dataPos, pUser->superUser, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pUser->superUser, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pUser->sysInfo, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pUser->sysInfo, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pUser->enable, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pUser->enable, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pUser->flag, _OVER)
|
SDB_SET_UINT8(pRaw, dataPos, pUser->flag, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pUser->authVersion, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pUser->authVersion, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pUser->passVersion, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pUser->passVersion, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, numOfReadDbs, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, numOfReadDbs, _OVER)
|
||||||
|
@ -1002,7 +1002,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pUser->superUser, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &pUser->superUser, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pUser->sysInfo, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &pUser->sysInfo, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pUser->enable, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &pUser->enable, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pUser->flag, _OVER)
|
SDB_GET_UINT8(pRaw, dataPos, &pUser->flag, _OVER)
|
||||||
if (pUser->superUser) pUser->createdb = 1;
|
if (pUser->superUser) pUser->createdb = 1;
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pUser->authVersion, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pUser->authVersion, _OVER)
|
||||||
if (sver >= 4) {
|
if (sver >= 4) {
|
||||||
|
|
|
@ -169,7 +169,8 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
|
||||||
SRetrieveFuncReq retrieveReq = {0};
|
SRetrieveFuncReq retrieveReq = {0};
|
||||||
retrieveReq.numOfFuncs = 1;
|
retrieveReq.numOfFuncs = 1;
|
||||||
retrieveReq.pFuncNames = taosArrayInit(1, TSDB_FUNC_NAME_LEN);
|
retrieveReq.pFuncNames = taosArrayInit(1, TSDB_FUNC_NAME_LEN);
|
||||||
taosArrayPush(retrieveReq.pFuncNames, "f1");
|
char name[TSDB_FUNC_NAME_LEN] = "f1";
|
||||||
|
taosArrayPush(retrieveReq.pFuncNames, name);
|
||||||
|
|
||||||
int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq);
|
int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
@ -220,7 +221,8 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
|
||||||
retrieveReq.numOfFuncs = TSDB_FUNC_MAX_RETRIEVE + 1;
|
retrieveReq.numOfFuncs = TSDB_FUNC_MAX_RETRIEVE + 1;
|
||||||
retrieveReq.pFuncNames = taosArrayInit(TSDB_FUNC_MAX_RETRIEVE + 1, TSDB_FUNC_NAME_LEN);
|
retrieveReq.pFuncNames = taosArrayInit(TSDB_FUNC_MAX_RETRIEVE + 1, TSDB_FUNC_NAME_LEN);
|
||||||
for (int32_t i = 0; i < TSDB_FUNC_MAX_RETRIEVE + 1; ++i) {
|
for (int32_t i = 0; i < TSDB_FUNC_MAX_RETRIEVE + 1; ++i) {
|
||||||
taosArrayPush(retrieveReq.pFuncNames, "1");
|
char name[TSDB_FUNC_NAME_LEN] = "1";
|
||||||
|
taosArrayPush(retrieveReq.pFuncNames, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq);
|
int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq);
|
||||||
|
@ -237,7 +239,8 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
|
||||||
SRetrieveFuncReq retrieveReq = {0};
|
SRetrieveFuncReq retrieveReq = {0};
|
||||||
retrieveReq.numOfFuncs = 1;
|
retrieveReq.numOfFuncs = 1;
|
||||||
retrieveReq.pFuncNames = taosArrayInit(1, TSDB_FUNC_NAME_LEN);
|
retrieveReq.pFuncNames = taosArrayInit(1, TSDB_FUNC_NAME_LEN);
|
||||||
taosArrayPush(retrieveReq.pFuncNames, "f2");
|
char name[TSDB_FUNC_NAME_LEN] = "f2";
|
||||||
|
taosArrayPush(retrieveReq.pFuncNames, name);
|
||||||
|
|
||||||
int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq);
|
int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
@ -279,7 +282,8 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
|
||||||
SRetrieveFuncReq retrieveReq = {0};
|
SRetrieveFuncReq retrieveReq = {0};
|
||||||
retrieveReq.numOfFuncs = 1;
|
retrieveReq.numOfFuncs = 1;
|
||||||
retrieveReq.pFuncNames = taosArrayInit(1, TSDB_FUNC_NAME_LEN);
|
retrieveReq.pFuncNames = taosArrayInit(1, TSDB_FUNC_NAME_LEN);
|
||||||
taosArrayPush(retrieveReq.pFuncNames, "f2");
|
char name[TSDB_FUNC_NAME_LEN] = "f2";
|
||||||
|
taosArrayPush(retrieveReq.pFuncNames, name);
|
||||||
|
|
||||||
int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq);
|
int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
@ -316,8 +320,10 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
|
||||||
SRetrieveFuncReq retrieveReq = {0};
|
SRetrieveFuncReq retrieveReq = {0};
|
||||||
retrieveReq.numOfFuncs = 2;
|
retrieveReq.numOfFuncs = 2;
|
||||||
retrieveReq.pFuncNames = taosArrayInit(1, TSDB_FUNC_NAME_LEN);
|
retrieveReq.pFuncNames = taosArrayInit(1, TSDB_FUNC_NAME_LEN);
|
||||||
taosArrayPush(retrieveReq.pFuncNames, "f2");
|
char name1[TSDB_FUNC_NAME_LEN] = "f2";
|
||||||
taosArrayPush(retrieveReq.pFuncNames, "f1");
|
taosArrayPush(retrieveReq.pFuncNames, name1);
|
||||||
|
char name2[TSDB_FUNC_NAME_LEN] = "f1";
|
||||||
|
taosArrayPush(retrieveReq.pFuncNames, name2);
|
||||||
|
|
||||||
int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq);
|
int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
@ -367,8 +373,10 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
|
||||||
SRetrieveFuncReq retrieveReq = {0};
|
SRetrieveFuncReq retrieveReq = {0};
|
||||||
retrieveReq.numOfFuncs = 2;
|
retrieveReq.numOfFuncs = 2;
|
||||||
retrieveReq.pFuncNames = taosArrayInit(1, TSDB_FUNC_NAME_LEN);
|
retrieveReq.pFuncNames = taosArrayInit(1, TSDB_FUNC_NAME_LEN);
|
||||||
taosArrayPush(retrieveReq.pFuncNames, "f2");
|
char name1[TSDB_FUNC_NAME_LEN] = "f2";
|
||||||
taosArrayPush(retrieveReq.pFuncNames, "f3");
|
taosArrayPush(retrieveReq.pFuncNames, name1);
|
||||||
|
char name2[TSDB_FUNC_NAME_LEN] = "f3";
|
||||||
|
taosArrayPush(retrieveReq.pFuncNames, name2);
|
||||||
|
|
||||||
int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq);
|
int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
@ -483,7 +491,8 @@ TEST_F(MndTestFunc, 05_Actual_code) {
|
||||||
SRetrieveFuncReq retrieveReq = {0};
|
SRetrieveFuncReq retrieveReq = {0};
|
||||||
retrieveReq.numOfFuncs = 1;
|
retrieveReq.numOfFuncs = 1;
|
||||||
retrieveReq.pFuncNames = taosArrayInit(1, TSDB_FUNC_NAME_LEN);
|
retrieveReq.pFuncNames = taosArrayInit(1, TSDB_FUNC_NAME_LEN);
|
||||||
taosArrayPush(retrieveReq.pFuncNames, "udf1");
|
char name[TSDB_FUNC_NAME_LEN] = "udf1";
|
||||||
|
taosArrayPush(retrieveReq.pFuncNames, name);
|
||||||
|
|
||||||
int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq);
|
int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
|
|
@ -57,6 +57,7 @@ extern "C" {
|
||||||
#define SDB_GET_INT32(pData, dataPos, val, pos) SDB_GET_VAL(pData, dataPos, val, pos, sdbGetRawInt32, int32_t)
|
#define SDB_GET_INT32(pData, dataPos, val, pos) SDB_GET_VAL(pData, dataPos, val, pos, sdbGetRawInt32, int32_t)
|
||||||
#define SDB_GET_INT16(pData, dataPos, val, pos) SDB_GET_VAL(pData, dataPos, val, pos, sdbGetRawInt16, int16_t)
|
#define SDB_GET_INT16(pData, dataPos, val, pos) SDB_GET_VAL(pData, dataPos, val, pos, sdbGetRawInt16, int16_t)
|
||||||
#define SDB_GET_INT8(pData, dataPos, val, pos) SDB_GET_VAL(pData, dataPos, val, pos, sdbGetRawInt8, int8_t)
|
#define SDB_GET_INT8(pData, dataPos, val, pos) SDB_GET_VAL(pData, dataPos, val, pos, sdbGetRawInt8, int8_t)
|
||||||
|
#define SDB_GET_UINT8(pData, dataPos, val, pos) SDB_GET_VAL(pData, dataPos, val, pos, sdbGetRawUInt8, uint8_t)
|
||||||
|
|
||||||
#define SDB_GET_RESERVE(pRaw, dataPos, valLen, pos) \
|
#define SDB_GET_RESERVE(pRaw, dataPos, valLen, pos) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -76,6 +77,7 @@ extern "C" {
|
||||||
#define SDB_SET_INT32(pRaw, dataPos, val, pos) SDB_SET_VAL(pRaw, dataPos, val, pos, sdbSetRawInt32, int32_t)
|
#define SDB_SET_INT32(pRaw, dataPos, val, pos) SDB_SET_VAL(pRaw, dataPos, val, pos, sdbSetRawInt32, int32_t)
|
||||||
#define SDB_SET_INT16(pRaw, dataPos, val, pos) SDB_SET_VAL(pRaw, dataPos, val, pos, sdbSetRawInt16, int16_t)
|
#define SDB_SET_INT16(pRaw, dataPos, val, pos) SDB_SET_VAL(pRaw, dataPos, val, pos, sdbSetRawInt16, int16_t)
|
||||||
#define SDB_SET_INT8(pRaw, dataPos, val, pos) SDB_SET_VAL(pRaw, dataPos, val, pos, sdbSetRawInt8, int8_t)
|
#define SDB_SET_INT8(pRaw, dataPos, val, pos) SDB_SET_VAL(pRaw, dataPos, val, pos, sdbSetRawInt8, int8_t)
|
||||||
|
#define SDB_SET_UINT8(pRaw, dataPos, val, pos) SDB_SET_VAL(pRaw, dataPos, val, pos, sdbSetRawUInt8, uint8_t)
|
||||||
|
|
||||||
#define SDB_SET_BINARY(pRaw, dataPos, val, valLen, pos) \
|
#define SDB_SET_BINARY(pRaw, dataPos, val, valLen, pos) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -388,6 +390,7 @@ void sdbGetCommitInfo(SSdb *pSdb, int64_t *index, int64_t *term, int64_t *config
|
||||||
SSdbRaw *sdbAllocRaw(ESdbType type, int8_t sver, int32_t dataLen);
|
SSdbRaw *sdbAllocRaw(ESdbType type, int8_t sver, int32_t dataLen);
|
||||||
void sdbFreeRaw(SSdbRaw *pRaw);
|
void sdbFreeRaw(SSdbRaw *pRaw);
|
||||||
int32_t sdbSetRawInt8(SSdbRaw *pRaw, int32_t dataPos, int8_t val);
|
int32_t sdbSetRawInt8(SSdbRaw *pRaw, int32_t dataPos, int8_t val);
|
||||||
|
int32_t sdbSetRawUInt8(SSdbRaw *pRaw, int32_t dataPos, uint8_t val);
|
||||||
int32_t sdbSetRawInt16(SSdbRaw *pRaw, int32_t dataPos, int16_t val);
|
int32_t sdbSetRawInt16(SSdbRaw *pRaw, int32_t dataPos, int16_t val);
|
||||||
int32_t sdbSetRawInt32(SSdbRaw *pRaw, int32_t dataPos, int32_t val);
|
int32_t sdbSetRawInt32(SSdbRaw *pRaw, int32_t dataPos, int32_t val);
|
||||||
int32_t sdbSetRawInt64(SSdbRaw *pRaw, int32_t dataPos, int64_t val);
|
int32_t sdbSetRawInt64(SSdbRaw *pRaw, int32_t dataPos, int64_t val);
|
||||||
|
@ -395,6 +398,7 @@ int32_t sdbSetRawBinary(SSdbRaw *pRaw, int32_t dataPos, const char *pVal, int32
|
||||||
int32_t sdbSetRawDataLen(SSdbRaw *pRaw, int32_t dataLen);
|
int32_t sdbSetRawDataLen(SSdbRaw *pRaw, int32_t dataLen);
|
||||||
int32_t sdbSetRawStatus(SSdbRaw *pRaw, ESdbStatus status);
|
int32_t sdbSetRawStatus(SSdbRaw *pRaw, ESdbStatus status);
|
||||||
int32_t sdbGetRawInt8(SSdbRaw *pRaw, int32_t dataPos, int8_t *val);
|
int32_t sdbGetRawInt8(SSdbRaw *pRaw, int32_t dataPos, int8_t *val);
|
||||||
|
int32_t sdbGetRawUInt8(SSdbRaw *pRaw, int32_t dataPos, uint8_t *val);
|
||||||
int32_t sdbGetRawInt16(SSdbRaw *pRaw, int32_t dataPos, int16_t *val);
|
int32_t sdbGetRawInt16(SSdbRaw *pRaw, int32_t dataPos, int16_t *val);
|
||||||
int32_t sdbGetRawInt32(SSdbRaw *pRaw, int32_t dataPos, int32_t *val);
|
int32_t sdbGetRawInt32(SSdbRaw *pRaw, int32_t dataPos, int32_t *val);
|
||||||
int32_t sdbGetRawInt64(SSdbRaw *pRaw, int32_t dataPos, int64_t *val);
|
int32_t sdbGetRawInt64(SSdbRaw *pRaw, int32_t dataPos, int64_t *val);
|
||||||
|
|
|
@ -67,6 +67,21 @@ int32_t sdbSetRawInt8(SSdbRaw *pRaw, int32_t dataPos, int8_t val) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t sdbSetRawUInt8(SSdbRaw *pRaw, int32_t dataPos, uint8_t val) {
|
||||||
|
if (pRaw == NULL) {
|
||||||
|
terrno = TSDB_CODE_INVALID_PTR;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataPos + sizeof(uint8_t) > pRaw->dataLen) {
|
||||||
|
terrno = TSDB_CODE_SDB_INVALID_DATA_LEN;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*(uint8_t *)(pRaw->pData + dataPos) = val;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t sdbSetRawInt32(SSdbRaw *pRaw, int32_t dataPos, int32_t val) {
|
int32_t sdbSetRawInt32(SSdbRaw *pRaw, int32_t dataPos, int32_t val) {
|
||||||
if (pRaw == NULL) {
|
if (pRaw == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PTR;
|
terrno = TSDB_CODE_INVALID_PTR;
|
||||||
|
@ -174,6 +189,21 @@ int32_t sdbGetRawInt8(SSdbRaw *pRaw, int32_t dataPos, int8_t *val) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t sdbGetRawUInt8(SSdbRaw *pRaw, int32_t dataPos, uint8_t *val) {
|
||||||
|
if (pRaw == NULL) {
|
||||||
|
terrno = TSDB_CODE_INVALID_PTR;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataPos + sizeof(uint8_t) > pRaw->dataLen) {
|
||||||
|
terrno = TSDB_CODE_SDB_INVALID_DATA_LEN;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*val = *(uint8_t *)(pRaw->pData + dataPos);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t sdbGetRawInt32(SSdbRaw *pRaw, int32_t dataPos, int32_t *val) {
|
int32_t sdbGetRawInt32(SSdbRaw *pRaw, int32_t dataPos, int32_t *val) {
|
||||||
if (pRaw == NULL) {
|
if (pRaw == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PTR;
|
terrno = TSDB_CODE_INVALID_PTR;
|
||||||
|
|
|
@ -25,20 +25,6 @@
|
||||||
#define sndDebug(...) do { if (sndDebugFlag & DEBUG_DEBUG) { taosPrintLog("SND ", DEBUG_DEBUG, sndDebugFlag, __VA_ARGS__);}} while (0)
|
#define sndDebug(...) do { if (sndDebugFlag & DEBUG_DEBUG) { taosPrintLog("SND ", DEBUG_DEBUG, sndDebugFlag, __VA_ARGS__);}} while (0)
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
static STaskId replaceStreamTaskId(SStreamTask *pTask) {
|
|
||||||
ASSERT(pTask->info.fillHistory);
|
|
||||||
STaskId id = {.streamId = pTask->id.streamId, .taskId = pTask->id.taskId};
|
|
||||||
pTask->id.streamId = pTask->streamTaskId.streamId;
|
|
||||||
pTask->id.taskId = pTask->streamTaskId.taskId;
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void restoreStreamTaskId(SStreamTask *pTask, STaskId *pId) {
|
|
||||||
ASSERT(pTask->info.fillHistory);
|
|
||||||
pTask->id.taskId = pId->taskId;
|
|
||||||
pTask->id.streamId = pId->streamId;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t sndExpandTask(SSnode *pSnode, SStreamTask *pTask, int64_t nextProcessVer) {
|
int32_t sndExpandTask(SSnode *pSnode, SStreamTask *pTask, int64_t nextProcessVer) {
|
||||||
ASSERT(pTask->info.taskLevel == TASK_LEVEL__AGG && taosArrayGetSize(pTask->upstreamInfo.pList) != 0);
|
ASSERT(pTask->info.taskLevel == TASK_LEVEL__AGG && taosArrayGetSize(pTask->upstreamInfo.pList) != 0);
|
||||||
int32_t code = streamTaskInit(pTask, pSnode->pMeta, &pSnode->msgCb, nextProcessVer);
|
int32_t code = streamTaskInit(pTask, pSnode->pMeta, &pSnode->msgCb, nextProcessVer);
|
||||||
|
@ -85,7 +71,7 @@ SSnode *sndOpen(const char *path, const SSnodeOpt *pOption) {
|
||||||
startRsync();
|
startRsync();
|
||||||
|
|
||||||
pSnode->msgCb = pOption->msgCb;
|
pSnode->msgCb = pOption->msgCb;
|
||||||
pSnode->pMeta = streamMetaOpen(path, pSnode, (FTaskExpand *)sndExpandTask, SNODE_HANDLE, taosGetTimestampMs(), tqStartTaskCompleteCallback);
|
pSnode->pMeta = streamMetaOpen(path, pSnode, (FTaskBuild *)sndExpandTask, tqExpandStreamTask, SNODE_HANDLE, taosGetTimestampMs(), tqStartTaskCompleteCallback);
|
||||||
if (pSnode->pMeta == NULL) {
|
if (pSnode->pMeta == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
|
@ -136,6 +122,8 @@ int32_t sndProcessStreamMsg(SSnode *pSnode, SRpcMsg *pMsg) {
|
||||||
return tqStreamProcessReqCheckpointRsp(pSnode->pMeta, pMsg);
|
return tqStreamProcessReqCheckpointRsp(pSnode->pMeta, pMsg);
|
||||||
case TDMT_STREAM_TASK_CHECKPOINT_READY_RSP:
|
case TDMT_STREAM_TASK_CHECKPOINT_READY_RSP:
|
||||||
return tqStreamProcessCheckpointReadyRsp(pSnode->pMeta, pMsg);
|
return tqStreamProcessCheckpointReadyRsp(pSnode->pMeta, pMsg);
|
||||||
|
case TDMT_MND_STREAM_CHKPT_REPORT_RSP:
|
||||||
|
return tqStreamProcessChkptReportRsp(pSnode->pMeta, pMsg);
|
||||||
case TDMT_STREAM_RETRIEVE_TRIGGER:
|
case TDMT_STREAM_RETRIEVE_TRIGGER:
|
||||||
return tqStreamTaskProcessRetrieveTriggerReq(pSnode->pMeta, pMsg);
|
return tqStreamTaskProcessRetrieveTriggerReq(pSnode->pMeta, pMsg);
|
||||||
case TDMT_STREAM_RETRIEVE_TRIGGER_RSP:
|
case TDMT_STREAM_RETRIEVE_TRIGGER_RSP:
|
||||||
|
|
|
@ -261,9 +261,10 @@ int32_t tqProcessTaskUpdateReq(STQ* pTq, SRpcMsg* pMsg);
|
||||||
int32_t tqProcessTaskResetReq(STQ* pTq, SRpcMsg* pMsg);
|
int32_t tqProcessTaskResetReq(STQ* pTq, SRpcMsg* pMsg);
|
||||||
int32_t tqProcessStreamHbRsp(STQ* pTq, SRpcMsg* pMsg);
|
int32_t tqProcessStreamHbRsp(STQ* pTq, SRpcMsg* pMsg);
|
||||||
int32_t tqProcessStreamReqCheckpointRsp(STQ* pTq, SRpcMsg* pMsg);
|
int32_t tqProcessStreamReqCheckpointRsp(STQ* pTq, SRpcMsg* pMsg);
|
||||||
|
int32_t tqProcessTaskChkptReportRsp(STQ* pTq, SRpcMsg* pMsg);
|
||||||
int32_t tqProcessTaskCheckpointReadyRsp(STQ* pTq, SRpcMsg* pMsg);
|
int32_t tqProcessTaskCheckpointReadyRsp(STQ* pTq, SRpcMsg* pMsg);
|
||||||
|
|
||||||
int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver);
|
int32_t tqBuildStreamTask(void* pTq, SStreamTask* pTask, int64_t ver);
|
||||||
int32_t tqScanWal(STQ* pTq);
|
int32_t tqScanWal(STQ* pTq);
|
||||||
|
|
||||||
int tqCommit(STQ*);
|
int tqCommit(STQ*);
|
||||||
|
|
|
@ -299,7 +299,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
|
||||||
tdRSmaTaskInit(pStreamTask->pMeta, pItem, &pStreamTask->id);
|
tdRSmaTaskInit(pStreamTask->pMeta, pItem, &pStreamTask->id);
|
||||||
pStreamTask->status.pSM = streamCreateStateMachine(pStreamTask);
|
pStreamTask->status.pSM = streamCreateStateMachine(pStreamTask);
|
||||||
pStreamTask->chkInfo.pActiveInfo = streamTaskCreateActiveChkptInfo();
|
pStreamTask->chkInfo.pActiveInfo = streamTaskCreateActiveChkptInfo();
|
||||||
pStreamState = streamStateOpen(taskInfDir, pStreamTask, true, -1, -1);
|
pStreamState = streamStateOpen(taskInfDir, pStreamTask, pStreamTask->id.streamId, pStreamTask->id.taskId, true, -1, -1);
|
||||||
if (!pStreamState) {
|
if (!pStreamState) {
|
||||||
terrno = TSDB_CODE_RSMA_STREAM_STATE_OPEN;
|
terrno = TSDB_CODE_RSMA_STREAM_STATE_OPEN;
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
|
|
|
@ -50,6 +50,9 @@ void tqDestroyTqHandle(void* data) {
|
||||||
if (pData->block != NULL) {
|
if (pData->block != NULL) {
|
||||||
blockDataDestroy(pData->block);
|
blockDataDestroy(pData->block);
|
||||||
}
|
}
|
||||||
|
if (pData->pRef) {
|
||||||
|
walCloseRef(pData->pRef->pWal, pData->pRef->refId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool tqOffsetEqual(const STqOffset* pLeft, const STqOffset* pRight) {
|
static bool tqOffsetEqual(const STqOffset* pLeft, const STqOffset* pRight) {
|
||||||
|
@ -87,7 +90,8 @@ STQ* tqOpen(const char* path, SVnode* pVnode) {
|
||||||
|
|
||||||
int32_t tqInitialize(STQ* pTq) {
|
int32_t tqInitialize(STQ* pTq) {
|
||||||
int32_t vgId = TD_VID(pTq->pVnode);
|
int32_t vgId = TD_VID(pTq->pVnode);
|
||||||
pTq->pStreamMeta = streamMetaOpen(pTq->path, pTq, (FTaskExpand*)tqExpandTask, vgId, -1, tqStartTaskCompleteCallback);
|
pTq->pStreamMeta =
|
||||||
|
streamMetaOpen(pTq->path, pTq, tqBuildStreamTask, tqExpandStreamTask, vgId, -1, tqStartTaskCompleteCallback);
|
||||||
if (pTq->pStreamMeta == NULL) {
|
if (pTq->pStreamMeta == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -571,9 +575,6 @@ int32_t tqProcessDeleteSubReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
|
||||||
taosMsleep(10);
|
taosMsleep(10);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (pHandle->pRef) {
|
|
||||||
walCloseRef(pTq->pVnode->pWal, pHandle->pRef->refId);
|
|
||||||
}
|
|
||||||
|
|
||||||
tqUnregisterPushHandle(pTq, pHandle);
|
tqUnregisterPushHandle(pTq, pHandle);
|
||||||
|
|
||||||
|
@ -658,12 +659,10 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
|
||||||
taosRLockLatch(&pTq->lock);
|
taosRLockLatch(&pTq->lock);
|
||||||
ret = tqMetaGetHandle(pTq, req.subKey);
|
ret = tqMetaGetHandle(pTq, req.subKey);
|
||||||
taosRUnLockLatch(&pTq->lock);
|
taosRUnLockLatch(&pTq->lock);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pHandle == NULL) {
|
if (pHandle == NULL) {
|
||||||
if (req.oldConsumerId != -1) {
|
if (req.oldConsumerId != -1) {
|
||||||
tqError("vgId:%d, build new consumer handle %s for consumer:0x%" PRIx64 ", but old consumerId:0x%" PRIx64,
|
tqError("vgId:%d, build new consumer handle %s for consumer:0x%" PRIx64 ", but old consumerId:0x%" PRIx64,
|
||||||
|
@ -708,14 +707,16 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void freePtr(void* ptr) { taosMemoryFree(*(void**)ptr); }
|
static void freePtr(void* ptr) { taosMemoryFree(*(void**)ptr); }
|
||||||
|
|
||||||
int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t nextProcessVer) {
|
int32_t tqBuildStreamTask(void* pTqObj, SStreamTask* pTask, int64_t nextProcessVer) {
|
||||||
|
STQ* pTq = (STQ*) pTqObj;
|
||||||
|
|
||||||
int32_t vgId = TD_VID(pTq->pVnode);
|
int32_t vgId = TD_VID(pTq->pVnode);
|
||||||
tqDebug("s-task:0x%x start to build task", pTask->id.taskId);
|
tqDebug("s-task:0x%x start to build task", pTask->id.taskId);
|
||||||
|
|
||||||
|
@ -1012,16 +1013,6 @@ int32_t tqProcessTaskDropReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqProcessTaskUpdateCheckpointReq(STQ* pTq, char* msg, int32_t msgLen) {
|
int32_t tqProcessTaskUpdateCheckpointReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
int32_t vgId = TD_VID(pTq->pVnode);
|
|
||||||
SVUpdateCheckpointInfoReq* pReq = (SVUpdateCheckpointInfoReq*)msg;
|
|
||||||
|
|
||||||
// if (!pTq->pVnode->restored) {
|
|
||||||
// tqDebug("vgId:%d update-checkpoint-info msg received during restoring, checkpointId:%" PRId64
|
|
||||||
// ", transId:%d s-task:0x%x ignore it",
|
|
||||||
// vgId, pReq->checkpointId, pReq->transId, pReq->taskId);
|
|
||||||
// return TSDB_CODE_SUCCESS;
|
|
||||||
// }
|
|
||||||
|
|
||||||
return tqStreamTaskProcessUpdateCheckpointReq(pTq->pStreamMeta, msg, msgLen);
|
return tqStreamTaskProcessUpdateCheckpointReq(pTq->pStreamMeta, msg, msgLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1278,3 +1269,7 @@ int32_t tqProcessStreamReqCheckpointRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
int32_t tqProcessTaskCheckpointReadyRsp(STQ* pTq, SRpcMsg* pMsg) {
|
int32_t tqProcessTaskCheckpointReadyRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
return tqStreamProcessCheckpointReadyRsp(pTq->pStreamMeta, pMsg);
|
return tqStreamProcessCheckpointReadyRsp(pTq->pStreamMeta, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tqProcessTaskChkptReportRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
|
return tqStreamProcessChkptReportRsp(pTq->pStreamMeta, pMsg);
|
||||||
|
}
|
||||||
|
|
|
@ -352,7 +352,6 @@ int32_t tqCreateHandle(STQ* pTq, SMqRebVgReq* req, STqHandle* handle){
|
||||||
|
|
||||||
memcpy(handle->subKey, req->subKey, TSDB_SUBSCRIBE_KEY_LEN);
|
memcpy(handle->subKey, req->subKey, TSDB_SUBSCRIBE_KEY_LEN);
|
||||||
handle->consumerId = req->newConsumerId;
|
handle->consumerId = req->newConsumerId;
|
||||||
handle->epoch = -1;
|
|
||||||
|
|
||||||
handle->execHandle.subType = req->subType;
|
handle->execHandle.subType = req->subType;
|
||||||
handle->fetchMeta = req->withMeta;
|
handle->fetchMeta = req->withMeta;
|
||||||
|
@ -371,7 +370,7 @@ int32_t tqCreateHandle(STQ* pTq, SMqRebVgReq* req, STqHandle* handle){
|
||||||
if(buildHandle(pTq, handle) < 0){
|
if(buildHandle(pTq, handle) < 0){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
tqInfo("tqCreateHandle %s consumer 0x%" PRIx64 " vgId:%d", handle->subKey, handle->consumerId, vgId);
|
tqInfo("tqCreateHandle %s consumer 0x%" PRIx64 " vgId:%d, snapshotVer:%" PRId64, handle->subKey, handle->consumerId, vgId, handle->snapshotVer);
|
||||||
return taosHashPut(pTq->pHandle, handle->subKey, strlen(handle->subKey), handle, sizeof(STqHandle));
|
return taosHashPut(pTq->pHandle, handle->subKey, strlen(handle->subKey), handle, sizeof(STqHandle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ int tqUnregisterPushHandle(STQ* pTq, void *handle) {
|
||||||
int32_t ret = taosHashRemove(pTq->pPushMgr, pHandle->subKey, strlen(pHandle->subKey));
|
int32_t ret = taosHashRemove(pTq->pPushMgr, pHandle->subKey, strlen(pHandle->subKey));
|
||||||
tqInfo("vgId:%d remove pHandle:%p,ret:%d consumer Id:0x%" PRIx64, vgId, pHandle, ret, pHandle->consumerId);
|
tqInfo("vgId:%d remove pHandle:%p,ret:%d consumer Id:0x%" PRIx64, vgId, pHandle, ret, pHandle->consumerId);
|
||||||
|
|
||||||
if(pHandle->msg != NULL) {
|
if(ret == 0 && pHandle->msg != NULL) {
|
||||||
// tqPushDataRsp(pHandle, vgId);
|
// tqPushDataRsp(pHandle, vgId);
|
||||||
tqPushEmptyDataRsp(pHandle, vgId);
|
tqPushEmptyDataRsp(pHandle, vgId);
|
||||||
|
|
||||||
|
|
|
@ -605,14 +605,15 @@ int32_t tqGetStreamExecInfo(SVnode* pVnode, int64_t streamId, int64_t* pDelay, b
|
||||||
numOfTasks = taosArrayGetSize(pMeta->pTaskList);
|
numOfTasks = taosArrayGetSize(pMeta->pTaskList);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfTasks; ++i) {
|
for (int32_t i = 0; i < numOfTasks; ++i) {
|
||||||
STaskId* pId = taosArrayGet(pMeta->pTaskList, i);
|
SStreamTaskId* pId = taosArrayGet(pMeta->pTaskList, i);
|
||||||
if (pId->streamId != streamId) {
|
if (pId->streamId != streamId) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SStreamTask** ppTask = taosHashGet(pMeta->pTasksMap, pId, sizeof(*pId));
|
STaskId id = {.streamId = pId->streamId, .taskId = pId->taskId};
|
||||||
|
SStreamTask** ppTask = taosHashGet(pMeta->pTasksMap, &id, sizeof(id));
|
||||||
if (ppTask == NULL) {
|
if (ppTask == NULL) {
|
||||||
tqError("vgId:%d failed to acquire task:0x%" PRIx64 " in retrieving progress", pMeta->vgId, pId->taskId);
|
tqError("vgId:%d failed to acquire task:0x%x in retrieving progress", pMeta->vgId, pId->taskId);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,37 +30,26 @@ typedef struct SMStreamCheckpointReadyRspMsg {
|
||||||
|
|
||||||
static int32_t doProcessDummyRspMsg(SStreamMeta* pMeta, SRpcMsg* pMsg);
|
static int32_t doProcessDummyRspMsg(SStreamMeta* pMeta, SRpcMsg* pMsg);
|
||||||
|
|
||||||
static STaskId replaceStreamTaskId(SStreamTask* pTask) {
|
|
||||||
ASSERT(pTask->info.fillHistory);
|
|
||||||
STaskId id = {.streamId = pTask->id.streamId, .taskId = pTask->id.taskId};
|
|
||||||
|
|
||||||
pTask->id.streamId = pTask->streamTaskId.streamId;
|
|
||||||
pTask->id.taskId = pTask->streamTaskId.taskId;
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void restoreStreamTaskId(SStreamTask* pTask, STaskId* pId) {
|
|
||||||
ASSERT(pTask->info.fillHistory);
|
|
||||||
pTask->id.taskId = pId->taskId;
|
|
||||||
pTask->id.streamId = pId->streamId;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tqExpandStreamTask(SStreamTask* pTask) {
|
int32_t tqExpandStreamTask(SStreamTask* pTask) {
|
||||||
SStreamMeta* pMeta = pTask->pMeta;
|
SStreamMeta* pMeta = pTask->pMeta;
|
||||||
int32_t vgId = pMeta->vgId;
|
int32_t vgId = pMeta->vgId;
|
||||||
STaskId taskId = {0};
|
|
||||||
int64_t st = taosGetTimestampMs();
|
int64_t st = taosGetTimestampMs();
|
||||||
|
int64_t streamId = 0;
|
||||||
|
int32_t taskId = 0;
|
||||||
|
|
||||||
tqDebug("s-task:%s vgId:%d start to expand stream task", pTask->id.idStr, vgId);
|
tqDebug("s-task:%s vgId:%d start to expand stream task", pTask->id.idStr, vgId);
|
||||||
|
|
||||||
if (pTask->info.fillHistory) {
|
if (pTask->info.fillHistory) {
|
||||||
taskId = replaceStreamTaskId(pTask);
|
streamId = pTask->streamTaskId.streamId;
|
||||||
|
taskId = pTask->streamTaskId.taskId;
|
||||||
|
} else {
|
||||||
|
streamId = pTask->id.streamId;
|
||||||
|
taskId = pTask->id.taskId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sink task does not need the pState
|
// sink task does not need the pState
|
||||||
if (pTask->info.taskLevel != TASK_LEVEL__SINK) {
|
if (pTask->info.taskLevel != TASK_LEVEL__SINK) {
|
||||||
pTask->pState = streamStateOpen(pMeta->path, pTask, false, -1, -1);
|
pTask->pState = streamStateOpen(pMeta->path, pTask, false, streamId, taskId, -1, -1);
|
||||||
if (pTask->pState == NULL) {
|
if (pTask->pState == NULL) {
|
||||||
tqError("s-task:%s (vgId:%d) failed to open state for task, expand task failed", pTask->id.idStr, vgId);
|
tqError("s-task:%s (vgId:%d) failed to open state for task, expand task failed", pTask->id.idStr, vgId);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -69,10 +58,6 @@ int32_t tqExpandStreamTask(SStreamTask* pTask) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTask->info.fillHistory) {
|
|
||||||
restoreStreamTaskId(pTask, &taskId);
|
|
||||||
}
|
|
||||||
|
|
||||||
SReadHandle handle = {
|
SReadHandle handle = {
|
||||||
.checkpointId = pTask->chkInfo.checkpointId,
|
.checkpointId = pTask->chkInfo.checkpointId,
|
||||||
.pStateBackend = pTask->pState,
|
.pStateBackend = pTask->pState,
|
||||||
|
@ -185,7 +170,7 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM
|
||||||
SStreamTask* pTask = *ppTask;
|
SStreamTask* pTask = *ppTask;
|
||||||
const char* idstr = pTask->id.idStr;
|
const char* idstr = pTask->id.idStr;
|
||||||
|
|
||||||
if (pMeta->updateInfo.transId != req.transId) {
|
if ((pMeta->updateInfo.transId != req.transId) && (pMeta->updateInfo.transId != -1)) {
|
||||||
if (req.transId < pMeta->updateInfo.transId) {
|
if (req.transId < pMeta->updateInfo.transId) {
|
||||||
tqError("s-task:%s vgId:%d disorder update nodeEp msg recv, discarded, newest transId:%d, recv:%d", idstr, vgId,
|
tqError("s-task:%s vgId:%d disorder update nodeEp msg recv, discarded, newest transId:%d, recv:%d", idstr, vgId,
|
||||||
pMeta->updateInfo.transId, req.transId);
|
pMeta->updateInfo.transId, req.transId);
|
||||||
|
@ -197,10 +182,8 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM
|
||||||
} else {
|
} else {
|
||||||
tqInfo("s-task:%s vgId:%d receive new trans to update nodeEp msg from mnode, transId:%d, prev transId:%d", idstr,
|
tqInfo("s-task:%s vgId:%d receive new trans to update nodeEp msg from mnode, transId:%d, prev transId:%d", idstr,
|
||||||
vgId, req.transId, pMeta->updateInfo.transId);
|
vgId, req.transId, pMeta->updateInfo.transId);
|
||||||
|
|
||||||
// info needs to be kept till the new trans to update the nodeEp arrived.
|
// info needs to be kept till the new trans to update the nodeEp arrived.
|
||||||
taosHashClear(pMeta->updateInfo.pTasks);
|
streamMetaInitUpdateTaskList(pMeta, req.transId);
|
||||||
pMeta->updateInfo.transId = req.transId;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tqDebug("s-task:%s vgId:%d recv trans to update nodeEp from mnode, transId:%d", idstr, vgId, req.transId);
|
tqDebug("s-task:%s vgId:%d recv trans to update nodeEp from mnode, transId:%d", idstr, vgId, req.transId);
|
||||||
|
@ -280,6 +263,8 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM
|
||||||
// persist to disk
|
// persist to disk
|
||||||
}
|
}
|
||||||
|
|
||||||
|
streamMetaClearUpdateTaskList(pMeta);
|
||||||
|
|
||||||
if (!restored) {
|
if (!restored) {
|
||||||
tqDebug("vgId:%d vnode restore not completed, not start the tasks, clear the start after nodeUpdate flag", vgId);
|
tqDebug("vgId:%d vnode restore not completed, not start the tasks, clear the start after nodeUpdate flag", vgId);
|
||||||
pMeta->startInfo.tasksWillRestart = 0;
|
pMeta->startInfo.tasksWillRestart = 0;
|
||||||
|
@ -362,6 +347,7 @@ int32_t tqStreamTaskProcessDispatchRsp(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
||||||
SStreamDispatchRsp* pRsp = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
SStreamDispatchRsp* pRsp = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||||
|
|
||||||
int32_t vgId = pMeta->vgId;
|
int32_t vgId = pMeta->vgId;
|
||||||
|
pRsp->upstreamNodeId = htonl(pRsp->upstreamNodeId);
|
||||||
pRsp->upstreamTaskId = htonl(pRsp->upstreamTaskId);
|
pRsp->upstreamTaskId = htonl(pRsp->upstreamTaskId);
|
||||||
pRsp->streamId = htobe64(pRsp->streamId);
|
pRsp->streamId = htobe64(pRsp->streamId);
|
||||||
pRsp->downstreamTaskId = htonl(pRsp->downstreamTaskId);
|
pRsp->downstreamTaskId = htonl(pRsp->downstreamTaskId);
|
||||||
|
@ -369,6 +355,9 @@ int32_t tqStreamTaskProcessDispatchRsp(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
||||||
pRsp->stage = htobe64(pRsp->stage);
|
pRsp->stage = htobe64(pRsp->stage);
|
||||||
pRsp->msgId = htonl(pRsp->msgId);
|
pRsp->msgId = htonl(pRsp->msgId);
|
||||||
|
|
||||||
|
tqDebug("s-task:0x%x vgId:%d recv dispatch-rsp from 0x%x vgId:%d", pRsp->upstreamTaskId, pRsp->upstreamNodeId,
|
||||||
|
pRsp->downstreamTaskId, pRsp->downstreamNodeId);
|
||||||
|
|
||||||
SStreamTask* pTask = streamMetaAcquireTask(pMeta, pRsp->streamId, pRsp->upstreamTaskId);
|
SStreamTask* pTask = streamMetaAcquireTask(pMeta, pRsp->streamId, pRsp->upstreamTaskId);
|
||||||
if (pTask) {
|
if (pTask) {
|
||||||
streamProcessDispatchRsp(pTask, pRsp, pMsg->code);
|
streamProcessDispatchRsp(pTask, pRsp, pMsg->code);
|
||||||
|
@ -414,7 +403,9 @@ int32_t tqStreamTaskProcessRetrieveReq(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
||||||
|
|
||||||
streamMetaReleaseTask(pMeta, pTask);
|
streamMetaReleaseTask(pMeta, pTask);
|
||||||
tCleanupStreamRetrieveReq(&req);
|
tCleanupStreamRetrieveReq(&req);
|
||||||
return code;
|
|
||||||
|
// always return success, to disable the auto rsp
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqStreamTaskProcessCheckReq(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
int32_t tqStreamTaskProcessCheckReq(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
||||||
|
@ -629,8 +620,8 @@ int32_t tqStreamTaskProcessDropReq(SStreamMeta* pMeta, char* msg, int32_t msgLen
|
||||||
|
|
||||||
// drop the related fill-history task firstly
|
// drop the related fill-history task firstly
|
||||||
if (hTaskId.taskId != 0 && hTaskId.streamId != 0) {
|
if (hTaskId.taskId != 0 && hTaskId.streamId != 0) {
|
||||||
streamMetaUnregisterTask(pMeta, hTaskId.streamId, hTaskId.taskId);
|
|
||||||
tqDebug("s-task:0x%x vgId:%d drop rel fill-history task:0x%x firstly", pReq->taskId, vgId, (int32_t)hTaskId.taskId);
|
tqDebug("s-task:0x%x vgId:%d drop rel fill-history task:0x%x firstly", pReq->taskId, vgId, (int32_t)hTaskId.taskId);
|
||||||
|
streamMetaUnregisterTask(pMeta, hTaskId.streamId, hTaskId.taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// drop the stream task now
|
// drop the stream task now
|
||||||
|
@ -646,8 +637,6 @@ int32_t tqStreamTaskProcessDropReq(SStreamMeta* pMeta, char* msg, int32_t msgLen
|
||||||
}
|
}
|
||||||
|
|
||||||
streamMetaWUnLock(pMeta);
|
streamMetaWUnLock(pMeta);
|
||||||
|
|
||||||
// tqStreamRemoveTaskBackend(pMeta, &id);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1078,6 +1067,8 @@ int32_t tqStreamProcessStreamHbRsp(SStreamMeta* pMeta, SRpcMsg* pMsg) { return d
|
||||||
|
|
||||||
int32_t tqStreamProcessReqCheckpointRsp(SStreamMeta* pMeta, SRpcMsg* pMsg) { return doProcessDummyRspMsg(pMeta, pMsg); }
|
int32_t tqStreamProcessReqCheckpointRsp(SStreamMeta* pMeta, SRpcMsg* pMsg) { return doProcessDummyRspMsg(pMeta, pMsg); }
|
||||||
|
|
||||||
|
int32_t tqStreamProcessChkptReportRsp(SStreamMeta* pMeta, SRpcMsg* pMsg) {return doProcessDummyRspMsg(pMeta, pMsg);}
|
||||||
|
|
||||||
int32_t tqStreamProcessCheckpointReadyRsp(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
int32_t tqStreamProcessCheckpointReadyRsp(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
||||||
SMStreamCheckpointReadyRspMsg* pRsp = pMsg->pCont;
|
SMStreamCheckpointReadyRspMsg* pRsp = pMsg->pCont;
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,12 @@ SSttBlockLoadInfo *tCreateSttBlockLoadInfo(STSchema *pSchema, int16_t *colList,
|
||||||
}
|
}
|
||||||
|
|
||||||
pLoadInfo->aSttBlk = taosArrayInit(4, sizeof(SSttBlk));
|
pLoadInfo->aSttBlk = taosArrayInit(4, sizeof(SSttBlk));
|
||||||
|
if (pLoadInfo->aSttBlk == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
taosMemoryFreeClear(pLoadInfo);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
pLoadInfo->pSchema = pSchema;
|
pLoadInfo->pSchema = pSchema;
|
||||||
pLoadInfo->colIds = colList;
|
pLoadInfo->colIds = colList;
|
||||||
pLoadInfo->numOfCols = numOfCols;
|
pLoadInfo->numOfCols = numOfCols;
|
||||||
|
@ -107,15 +113,21 @@ void *destroySttBlockReader(SArray *pLDataIterArray, SSttBlockLoadCostInfo *pLoa
|
||||||
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) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSttBlockLoadCostInfo* pCost = &pIter->pBlockLoadInfo->cost;
|
||||||
if (pLoadCost != NULL) {
|
if (pLoadCost != NULL) {
|
||||||
pLoadCost->loadBlocks += pIter->pBlockLoadInfo->cost.loadBlocks;
|
pLoadCost->loadBlocks += pCost->loadBlocks;
|
||||||
pLoadCost->loadStatisBlocks += pIter->pBlockLoadInfo->cost.loadStatisBlocks;
|
pLoadCost->loadStatisBlocks += pCost->loadStatisBlocks;
|
||||||
pLoadCost->blockElapsedTime += pIter->pBlockLoadInfo->cost.blockElapsedTime;
|
pLoadCost->blockElapsedTime += pCost->blockElapsedTime;
|
||||||
pLoadCost->statisElapsedTime += pIter->pBlockLoadInfo->cost.statisElapsedTime;
|
pLoadCost->statisElapsedTime += pCost->statisElapsedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyLDataIter(pIter);
|
destroyLDataIter(pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pList);
|
taosArrayDestroy(pList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -903,6 +915,10 @@ int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf, SSttDataInfoF
|
||||||
|
|
||||||
if (pLoadInfo == NULL) {
|
if (pLoadInfo == NULL) {
|
||||||
pLoadInfo = tCreateSttBlockLoadInfo(pConf->pSchema, pConf->pCols, pConf->numOfCols);
|
pLoadInfo = tCreateSttBlockLoadInfo(pConf->pSchema, pConf->pCols, pConf->numOfCols);
|
||||||
|
if (pLoadInfo == NULL) {
|
||||||
|
code = terrno;
|
||||||
|
goto _end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(pIter, 0, sizeof(SLDataIter));
|
memset(pIter, 0, sizeof(SLDataIter));
|
||||||
|
|
|
@ -2240,7 +2240,8 @@ static bool initSttBlockReader(SSttBlockReader* pSttBlockReader, STableBlockScan
|
||||||
};
|
};
|
||||||
|
|
||||||
SSttDataInfoForTable info = {.pKeyRangeList = taosArrayInit(4, sizeof(SSttKeyRange))};
|
SSttDataInfoForTable info = {.pKeyRangeList = taosArrayInit(4, sizeof(SSttKeyRange))};
|
||||||
int32_t code = tMergeTreeOpen2(&pSttBlockReader->mergeTree, &conf, &info);
|
|
||||||
|
int32_t code = tMergeTreeOpen2(&pSttBlockReader->mergeTree, &conf, &info);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -4896,7 +4897,7 @@ static void doFillNullColSMA(SBlockLoadSuppInfo* pSup, int32_t numOfRows, int32_
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbRetrieveDatablockSMA2(STsdbReader* pReader, SSDataBlock* pDataBlock, bool* allHave, bool* hasNullSMA) {
|
int32_t tsdbRetrieveDatablockSMA2(STsdbReader* pReader, SSDataBlock* pDataBlock, bool* allHave, bool* hasNullSMA) {
|
||||||
SColumnDataAgg*** pBlockSMA = &pDataBlock->pBlockAgg;
|
SColumnDataAgg** pBlockSMA = &pDataBlock->pBlockAgg;
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
*allHave = false;
|
*allHave = false;
|
||||||
|
@ -4951,7 +4952,13 @@ int32_t tsdbRetrieveDatablockSMA2(STsdbReader* pReader, SSDataBlock* pDataBlock,
|
||||||
|
|
||||||
if (pResBlock->pBlockAgg == NULL) {
|
if (pResBlock->pBlockAgg == NULL) {
|
||||||
size_t num = taosArrayGetSize(pResBlock->pDataBlock);
|
size_t num = taosArrayGetSize(pResBlock->pDataBlock);
|
||||||
pResBlock->pBlockAgg = taosMemoryCalloc(num, POINTER_BYTES);
|
pResBlock->pBlockAgg = taosMemoryCalloc(num, sizeof(SColumnDataAgg));
|
||||||
|
if (pResBlock->pBlockAgg == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
for(int i = 0; i < num; ++i) {
|
||||||
|
pResBlock->pBlockAgg[i].colId = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// do fill all null column value SMA info
|
// do fill all null column value SMA info
|
||||||
|
@ -4963,13 +4970,12 @@ int32_t tsdbRetrieveDatablockSMA2(STsdbReader* pReader, SSDataBlock* pDataBlock,
|
||||||
while (j < numOfCols && i < size) {
|
while (j < numOfCols && i < size) {
|
||||||
SColumnDataAgg* pAgg = &pSup->colAggArray.data[i];
|
SColumnDataAgg* pAgg = &pSup->colAggArray.data[i];
|
||||||
if (pAgg->colId == pSup->colId[j]) {
|
if (pAgg->colId == pSup->colId[j]) {
|
||||||
pResBlock->pBlockAgg[pSup->slotId[j]] = pAgg;
|
pResBlock->pBlockAgg[pSup->slotId[j]] = *pAgg;
|
||||||
i += 1;
|
i += 1;
|
||||||
j += 1;
|
j += 1;
|
||||||
} else if (pAgg->colId < pSup->colId[j]) {
|
} else if (pAgg->colId < pSup->colId[j]) {
|
||||||
i += 1;
|
i += 1;
|
||||||
} else if (pSup->colId[j] < pAgg->colId) {
|
} else if (pSup->colId[j] < pAgg->colId) {
|
||||||
pResBlock->pBlockAgg[pSup->slotId[j]] = NULL;
|
|
||||||
*allHave = false;
|
*allHave = false;
|
||||||
j += 1;
|
j += 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -985,6 +985,10 @@ int32_t tsdbGetRowsInSttFiles(STFileSet* pFileSet, SArray* pSttFileBlockIterArra
|
||||||
|
|
||||||
if (pIter->pBlockLoadInfo == NULL) {
|
if (pIter->pBlockLoadInfo == NULL) {
|
||||||
pIter->pBlockLoadInfo = tCreateSttBlockLoadInfo(pConf->pSchema, pConf->pCols, pConf->numOfCols);
|
pIter->pBlockLoadInfo = tCreateSttBlockLoadInfo(pConf->pSchema, pConf->pCols, pConf->numOfCols);
|
||||||
|
if (pIter->pBlockLoadInfo == NULL) {
|
||||||
|
tsdbError("failed to create block load info, code: out of memory, %s", pstr);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// load stt blocks statis for all stt-blocks, to decide if the data of queried table exists in current stt file
|
// load stt blocks statis for all stt-blocks, to decide if the data of queried table exists in current stt file
|
||||||
|
|
|
@ -38,6 +38,34 @@ static int32_t tsdbDoRemoveFileObject(SRTNer *rtner, const STFileObj *fobj) {
|
||||||
return TARRAY2_APPEND(&rtner->fopArr, op);
|
return TARRAY2_APPEND(&rtner->fopArr, op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int64_t tsdbCopyFileWithLimitedSpeed(TdFilePtr from, TdFilePtr to, int64_t size, uint32_t limitMB) {
|
||||||
|
int64_t total = 0;
|
||||||
|
int64_t interval = 1000; // 1s
|
||||||
|
int64_t limit = limitMB ? limitMB * 1024 * 1024 : INT64_MAX;
|
||||||
|
int64_t offset = 0;
|
||||||
|
int64_t remain = size;
|
||||||
|
|
||||||
|
while (remain > 0) {
|
||||||
|
int64_t n;
|
||||||
|
int64_t last = taosGetTimestampMs();
|
||||||
|
if ((n = taosFSendFile(to, from, &offset, TMIN(limit, remain))) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
total += n;
|
||||||
|
remain -= n;
|
||||||
|
|
||||||
|
if (remain > 0) {
|
||||||
|
int64_t elapsed = taosGetTimestampMs() - last;
|
||||||
|
if (elapsed < interval) {
|
||||||
|
taosMsleep(interval - elapsed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t tsdbDoCopyFileLC(SRTNer *rtner, const STFileObj *from, const STFile *to) {
|
static int32_t tsdbDoCopyFileLC(SRTNer *rtner, const STFileObj *from, const STFile *to) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
@ -98,7 +126,8 @@ static int32_t tsdbDoCopyFile(SRTNer *rtner, const STFileObj *from, const STFile
|
||||||
if (fdTo == NULL) code = terrno;
|
if (fdTo == NULL) code = terrno;
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
int64_t n = taosFSendFile(fdTo, fdFrom, 0, tsdbLogicToFileSize(from->f->size, rtner->szPage));
|
int64_t n = tsdbCopyFileWithLimitedSpeed(fdFrom, fdTo, tsdbLogicToFileSize(from->f->size, rtner->szPage),
|
||||||
|
tsRetentionSpeedLimitMB);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
|
@ -120,7 +120,8 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
||||||
memcpy(metaRsp.pSchemas + schema.nCols, schemaTag.pSchema, sizeof(SSchema) * schemaTag.nCols);
|
memcpy(metaRsp.pSchemas + schema.nCols, schemaTag.pSchema, sizeof(SSchema) * schemaTag.nCols);
|
||||||
}
|
}
|
||||||
if (metaRsp.pSchemaExt) {
|
if (metaRsp.pSchemaExt) {
|
||||||
code = fillTableColCmpr(&mer1, metaRsp.pSchemaExt, metaRsp.numOfColumns);
|
SMetaReader *pReader = mer1.me.type == TSDB_CHILD_TABLE ? &mer2 : &mer1;
|
||||||
|
code = fillTableColCmpr(pReader, metaRsp.pSchemaExt, metaRsp.numOfColumns);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
@ -254,15 +255,18 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
||||||
memcpy(cfgRsp.pSchemas + schema.nCols, schemaTag.pSchema, sizeof(SSchema) * schemaTag.nCols);
|
memcpy(cfgRsp.pSchemas + schema.nCols, schemaTag.pSchema, sizeof(SSchema) * schemaTag.nCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useCompress(cfgRsp.tableType)) {
|
// if (useCompress(cfgRsp.tableType)) {
|
||||||
SColCmprWrapper *pColCmpr = &mer1.me.colCmpr;
|
|
||||||
for (int32_t i = 0; i < cfgRsp.numOfColumns; i++) {
|
SMetaReader *pReader = mer1.me.type == TSDB_CHILD_TABLE ? &mer2 : &mer1;
|
||||||
SColCmpr *pCmpr = &pColCmpr->pColCmpr[i];
|
SColCmprWrapper *pColCmpr = &pReader->me.colCmpr;
|
||||||
SSchemaExt *pSchExt = cfgRsp.pSchemaExt + i;
|
|
||||||
pSchExt->colId = pCmpr->id;
|
for (int32_t i = 0; i < cfgRsp.numOfColumns; i++) {
|
||||||
pSchExt->compress = pCmpr->alg;
|
SColCmpr *pCmpr = &pColCmpr->pColCmpr[i];
|
||||||
}
|
SSchemaExt *pSchExt = cfgRsp.pSchemaExt + i;
|
||||||
|
pSchExt->colId = pCmpr->id;
|
||||||
|
pSchExt->compress = pCmpr->alg;
|
||||||
}
|
}
|
||||||
|
//}
|
||||||
|
|
||||||
// encode and send response
|
// encode and send response
|
||||||
rspLen = tSerializeSTableCfgRsp(NULL, 0, &cfgRsp);
|
rspLen = tSerializeSTableCfgRsp(NULL, 0, &cfgRsp);
|
||||||
|
@ -752,13 +756,13 @@ int32_t vnodeGetTableSchema(void *pVnode, int64_t uid, STSchema **pSchema, int64
|
||||||
return tsdbGetTableSchema(((SVnode *)pVnode)->pMeta, uid, pSchema, suid);
|
return tsdbGetTableSchema(((SVnode *)pVnode)->pMeta, uid, pSchema, suid);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vnodeGetStreamProgress(SVnode* pVnode, SRpcMsg* pMsg, bool direct) {
|
int32_t vnodeGetStreamProgress(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SStreamProgressReq req;
|
SStreamProgressReq req;
|
||||||
SStreamProgressRsp rsp = {0};
|
SStreamProgressRsp rsp = {0};
|
||||||
SRpcMsg rpcMsg = {.info = pMsg->info, .code = 0};
|
SRpcMsg rpcMsg = {.info = pMsg->info, .code = 0};
|
||||||
char * buf = NULL;
|
char *buf = NULL;
|
||||||
int32_t rspLen = 0;
|
int32_t rspLen = 0;
|
||||||
code = tDeserializeStreamProgressReq(pMsg->pCont, pMsg->contLen, &req);
|
code = tDeserializeStreamProgressReq(pMsg->pCont, pMsg->contLen, &req);
|
||||||
|
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
|
|
@ -854,6 +854,8 @@ int32_t vnodeProcessStreamMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo)
|
||||||
return tqProcessStreamReqCheckpointRsp(pVnode->pTq, pMsg);
|
return tqProcessStreamReqCheckpointRsp(pVnode->pTq, pMsg);
|
||||||
case TDMT_VND_GET_STREAM_PROGRESS:
|
case TDMT_VND_GET_STREAM_PROGRESS:
|
||||||
return tqStreamProgressRetrieveReq(pVnode->pTq, pMsg);
|
return tqStreamProgressRetrieveReq(pVnode->pTq, pMsg);
|
||||||
|
case TDMT_MND_STREAM_CHKPT_REPORT_RSP:
|
||||||
|
return tqProcessTaskChkptReportRsp(pVnode->pTq, pMsg);
|
||||||
default:
|
default:
|
||||||
vError("unknown msg type:%d in stream queue", pMsg->msgType);
|
vError("unknown msg type:%d in stream queue", pMsg->msgType);
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
|
|
|
@ -624,6 +624,8 @@ typedef struct SDataGroupInfo {
|
||||||
uint64_t groupId;
|
uint64_t groupId;
|
||||||
int64_t numOfRows;
|
int64_t numOfRows;
|
||||||
SArray* pPageList;
|
SArray* pPageList;
|
||||||
|
SArray* blockForNotLoaded; // SSDataBlock that data is not loaded
|
||||||
|
int32_t offsetForNotLoaded; // read offset for SSDataBlock that data is not loaded
|
||||||
} SDataGroupInfo;
|
} SDataGroupInfo;
|
||||||
|
|
||||||
typedef struct SWindowRowsSup {
|
typedef struct SWindowRowsSup {
|
||||||
|
@ -861,7 +863,7 @@ void setTbNameColData(const SSDataBlock* pBlock, SColumnInfoData* pColInfoData,
|
||||||
void setVgIdColData(const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId, int32_t vgId);
|
void setVgIdColData(const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId, int32_t vgId);
|
||||||
void setVgVerColData(const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId, int64_t vgVer);
|
void setVgVerColData(const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId, int64_t vgVer);
|
||||||
|
|
||||||
void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowEntryInfoOffset);
|
int32_t setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowEntryInfoOffset);
|
||||||
void clearResultRowInitFlag(SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
void clearResultRowInitFlag(SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
||||||
|
|
||||||
SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, char* pData,
|
SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, char* pData,
|
||||||
|
|
|
@ -406,7 +406,10 @@ void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setResultRowInitCtx(pResultRow, pCtx, numOfOutput, rowEntryInfoOffset);
|
int32_t ret = setResultRowInitCtx(pResultRow, pCtx, numOfOutput, rowEntryInfoOffset);
|
||||||
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
|
T_LONG_JMP(pTaskInfo->env, ret);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// a new buffer page for each table. Needs to opt this design
|
// a new buffer page for each table. Needs to opt this design
|
||||||
|
|
|
@ -221,8 +221,7 @@ static int32_t setSingleOutputTupleBufv1(SResultRowInfo* pResultRowInfo, STimeWi
|
||||||
|
|
||||||
(*pResult)->win = *win;
|
(*pResult)->win = *win;
|
||||||
|
|
||||||
setResultRowInitCtx(*pResult, pExprSup->pCtx, pExprSup->numOfExprs, pExprSup->rowEntryInfoOffset);
|
return setResultRowInitCtx(*pResult, pExprSup->pCtx, pExprSup->numOfExprs, pExprSup->rowEntryInfoOffset);
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doEventWindowAggImpl(SEventWindowOperatorInfo* pInfo, SExprSupp* pSup, int32_t startIndex, int32_t endIndex,
|
static void doEventWindowAggImpl(SEventWindowOperatorInfo* pInfo, SExprSupp* pSup, int32_t startIndex, int32_t endIndex,
|
||||||
|
|
|
@ -2178,9 +2178,25 @@ int32_t buildGroupIdMapForAllTables(STableListInfo* pTableListInfo, SReadHandle*
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
if (group == NULL || groupByTbname) {
|
if (group == NULL || groupByTbname) {
|
||||||
for (int32_t i = 0; i < numOfTables; i++) {
|
if (tsCountAlwaysReturnValue && QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == nodeType(pScanNode) && ((STableScanPhysiNode*)pScanNode)->needCountEmptyTable) {
|
||||||
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
pTableListInfo->remainGroups =
|
||||||
info->groupId = groupByTbname ? info->uid : 0;
|
taosHashInit(numOfTables, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||||
|
if (pTableListInfo->remainGroups == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < numOfTables; i++) {
|
||||||
|
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
||||||
|
info->groupId = info->uid;
|
||||||
|
|
||||||
|
taosHashPut(pTableListInfo->remainGroups, &(info->groupId), sizeof(info->groupId), &(info->uid),
|
||||||
|
sizeof(info->uid));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int32_t i = 0; i < numOfTables; i++) {
|
||||||
|
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
||||||
|
info->groupId = groupByTbname ? info->uid : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pTableListInfo->oneTableForEachGroup = groupByTbname;
|
pTableListInfo->oneTableForEachGroup = groupByTbname;
|
||||||
|
@ -2193,8 +2209,6 @@ int32_t buildGroupIdMapForAllTables(STableListInfo* pTableListInfo, SReadHandle*
|
||||||
pTableListInfo->numOfOuputGroups = numOfTables;
|
pTableListInfo->numOfOuputGroups = numOfTables;
|
||||||
} else if (groupByTbname && pScanNode->groupOrderScan) {
|
} else if (groupByTbname && pScanNode->groupOrderScan) {
|
||||||
pTableListInfo->numOfOuputGroups = numOfTables;
|
pTableListInfo->numOfOuputGroups = numOfTables;
|
||||||
} else if (groupByTbname && tsCountAlwaysReturnValue && ((STableScanPhysiNode*)pScanNode)->needCountEmptyTable) {
|
|
||||||
pTableListInfo->numOfOuputGroups = numOfTables;
|
|
||||||
} else {
|
} else {
|
||||||
pTableListInfo->numOfOuputGroups = 1;
|
pTableListInfo->numOfOuputGroups = 1;
|
||||||
}
|
}
|
||||||
|
@ -2354,7 +2368,7 @@ int32_t compKeys(const SArray* pSortGroupCols, const char* oldkeyBuf, int32_t ol
|
||||||
for (int32_t i = 0; i < pSortGroupCols->size; ++i) {
|
for (int32_t i = 0; i < pSortGroupCols->size; ++i) {
|
||||||
const SColumn* pCol = (SColumn*)TARRAY_GET_ELEM(pSortGroupCols, i);
|
const SColumn* pCol = (SColumn*)TARRAY_GET_ELEM(pSortGroupCols, i);
|
||||||
const SColumnInfoData* pColInfoData = TARRAY_GET_ELEM(pBlock->pDataBlock, pCol->slotId);
|
const SColumnInfoData* pColInfoData = TARRAY_GET_ELEM(pBlock->pDataBlock, pCol->slotId);
|
||||||
if (pBlock->pBlockAgg) pColAgg = pBlock->pBlockAgg[pCol->slotId];
|
if (pBlock->pBlockAgg) pColAgg = &pBlock->pBlockAgg[pCol->slotId];
|
||||||
|
|
||||||
if (colDataIsNull(pColInfoData, pBlock->info.rows, rowIndex, pColAgg)) {
|
if (colDataIsNull(pColInfoData, pBlock->info.rows, rowIndex, pColAgg)) {
|
||||||
if (isNull[i] != 1) return 1;
|
if (isNull[i] != 1) return 1;
|
||||||
|
@ -2389,7 +2403,7 @@ int32_t buildKeys(char* keyBuf, const SArray* pSortGroupCols, const SSDataBlock*
|
||||||
const SColumnInfoData* pColInfoData = TARRAY_GET_ELEM(pBlock->pDataBlock, pCol->slotId);
|
const SColumnInfoData* pColInfoData = TARRAY_GET_ELEM(pBlock->pDataBlock, pCol->slotId);
|
||||||
if (pCol->slotId > pBlock->pDataBlock->size) continue;
|
if (pCol->slotId > pBlock->pDataBlock->size) continue;
|
||||||
|
|
||||||
if (pBlock->pBlockAgg) pColAgg = pBlock->pBlockAgg[pCol->slotId];
|
if (pBlock->pBlockAgg) pColAgg = &pBlock->pBlockAgg[pCol->slotId];
|
||||||
|
|
||||||
if (colDataIsNull(pColInfoData, pBlock->info.rows, rowIndex, pColAgg)) {
|
if (colDataIsNull(pColInfoData, pBlock->info.rows, rowIndex, pColAgg)) {
|
||||||
isNull[i] = 1;
|
isNull[i] = 1;
|
||||||
|
|
|
@ -434,8 +434,8 @@ void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, SSDataBlock* pB
|
||||||
|
|
||||||
if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) {
|
if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) {
|
||||||
int32_t slotId = pFuncParam->pCol->slotId;
|
int32_t slotId = pFuncParam->pCol->slotId;
|
||||||
pInput->pColumnDataAgg[j] = pBlock->pBlockAgg[slotId];
|
pInput->pColumnDataAgg[j] = &pBlock->pBlockAgg[slotId];
|
||||||
if (pInput->pColumnDataAgg[j] == NULL) {
|
if (pInput->pColumnDataAgg[j]->colId == -1) {
|
||||||
pInput->colDataSMAIsSet = false;
|
pInput->colDataSMAIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,7 +468,7 @@ STimeWindow getAlignQueryTimeWindow(const SInterval* pInterval, int64_t key) {
|
||||||
return win;
|
return win;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowEntryInfoOffset) {
|
int32_t setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowEntryInfoOffset) {
|
||||||
bool init = false;
|
bool init = false;
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||||
pCtx[i].resultInfo = getResultEntryInfo(pResult, i, rowEntryInfoOffset);
|
pCtx[i].resultInfo = getResultEntryInfo(pResult, i, rowEntryInfoOffset);
|
||||||
|
@ -487,7 +487,11 @@ void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numO
|
||||||
|
|
||||||
if (!pResInfo->initialized) {
|
if (!pResInfo->initialized) {
|
||||||
if (pCtx[i].functionId != -1) {
|
if (pCtx[i].functionId != -1) {
|
||||||
pCtx[i].fpSet.init(&pCtx[i], pResInfo);
|
bool ini = pCtx[i].fpSet.init(&pCtx[i], pResInfo);
|
||||||
|
if (!ini && fmIsUserDefinedFunc(pCtx[i].functionId)){
|
||||||
|
pResInfo->initialized = false;
|
||||||
|
return TSDB_CODE_UDF_FUNC_EXEC_FAILURE;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pResInfo->initialized = true;
|
pResInfo->initialized = true;
|
||||||
}
|
}
|
||||||
|
@ -495,6 +499,7 @@ void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numO
|
||||||
init = true;
|
init = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearResultRowInitFlag(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
|
void clearResultRowInitFlag(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
|
||||||
|
|
|
@ -131,7 +131,7 @@ static bool groupKeyCompare(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlo
|
||||||
SColumn* pCol = taosArrayGet(pGroupCols, i);
|
SColumn* pCol = taosArrayGet(pGroupCols, i);
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pCol->slotId);
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pCol->slotId);
|
||||||
if (pBlock->pBlockAgg != NULL) {
|
if (pBlock->pBlockAgg != NULL) {
|
||||||
pColAgg = pBlock->pBlockAgg[pCol->slotId]; // TODO is agg data matched?
|
pColAgg = &pBlock->pBlockAgg[pCol->slotId]; // TODO is agg data matched?
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNull = colDataIsNull(pColInfoData, pBlock->info.rows, rowIndex, pColAgg);
|
bool isNull = colDataIsNull(pColInfoData, pBlock->info.rows, rowIndex, pColAgg);
|
||||||
|
@ -187,7 +187,7 @@ static void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSData
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pBlock->pBlockAgg != NULL) {
|
if (pBlock->pBlockAgg != NULL) {
|
||||||
pColAgg = pBlock->pBlockAgg[pCol->slotId]; // TODO is agg data matched?
|
pColAgg = &pBlock->pBlockAgg[pCol->slotId]; // TODO is agg data matched?
|
||||||
}
|
}
|
||||||
|
|
||||||
SGroupKeys* pkey = taosArrayGet(pGroupColVals, i);
|
SGroupKeys* pkey = taosArrayGet(pGroupColVals, i);
|
||||||
|
@ -319,7 +319,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
int32_t ret = setGroupResultOutputBuf(pOperator, &(pInfo->binfo), pOperator->exprSupp.numOfExprs, pInfo->keyBuf,
|
int32_t ret = setGroupResultOutputBuf(pOperator, &(pInfo->binfo), pOperator->exprSupp.numOfExprs, pInfo->keyBuf,
|
||||||
len, pBlock->info.id.groupId, pInfo->aggSup.pResultBuf, &pInfo->aggSup);
|
len, pBlock->info.id.groupId, pInfo->aggSup.pResultBuf, &pInfo->aggSup);
|
||||||
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
|
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
|
||||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_APP_ERROR);
|
T_LONG_JMP(pTaskInfo->env, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t rowIndex = j - num;
|
int32_t rowIndex = j - num;
|
||||||
|
@ -337,7 +337,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
int32_t ret = setGroupResultOutputBuf(pOperator, &(pInfo->binfo), pOperator->exprSupp.numOfExprs, pInfo->keyBuf,
|
int32_t ret = setGroupResultOutputBuf(pOperator, &(pInfo->binfo), pOperator->exprSupp.numOfExprs, pInfo->keyBuf,
|
||||||
len, pBlock->info.id.groupId, pInfo->aggSup.pResultBuf, &pInfo->aggSup);
|
len, pBlock->info.id.groupId, pInfo->aggSup.pResultBuf, &pInfo->aggSup);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_APP_ERROR);
|
T_LONG_JMP(pTaskInfo->env, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t rowIndex = pBlock->info.rows - num;
|
int32_t rowIndex = pBlock->info.rows - num;
|
||||||
|
@ -563,6 +563,55 @@ _error:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SSDataBlock* createBlockDataNotLoaded(const SOperatorInfo* pOperator, SSDataBlock* pDataBlock) {
|
||||||
|
if (pDataBlock == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSDataBlock* pDstBlock = createDataBlock();
|
||||||
|
pDstBlock->info = pDataBlock->info;
|
||||||
|
pDstBlock->info.id.blockId = pOperator->resultDataBlockId;
|
||||||
|
pDstBlock->info.capacity = 0;
|
||||||
|
pDstBlock->info.rowSize = 0;
|
||||||
|
|
||||||
|
size_t numOfCols = pOperator->exprSupp.numOfExprs;
|
||||||
|
if (pDataBlock->pBlockAgg) {
|
||||||
|
pDstBlock->pBlockAgg = taosMemoryCalloc(numOfCols, sizeof(SColumnDataAgg));
|
||||||
|
if (pDstBlock->pBlockAgg == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
blockDataDestroy(pDstBlock);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
for(int i = 0; i < numOfCols; ++i) {
|
||||||
|
pDstBlock->pBlockAgg[i].colId = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) {
|
||||||
|
SExprInfo* pExpr = &pOperator->exprSupp.pExprInfo[i];
|
||||||
|
int32_t slotId = pExpr->base.pParam[0].pCol->slotId;
|
||||||
|
SColumnInfoData* pSrc = taosArrayGet(pDataBlock->pDataBlock, slotId);
|
||||||
|
SColumnInfoData colInfo = {.hasNull = true, .info = pSrc->info};
|
||||||
|
blockDataAppendColInfo(pDstBlock, &colInfo);
|
||||||
|
|
||||||
|
SColumnInfoData* pDst = taosArrayGet(pDstBlock->pDataBlock, i);
|
||||||
|
if (pDataBlock->pBlockAgg && pDataBlock->pBlockAgg[slotId].colId != -1) {
|
||||||
|
pDstBlock->pBlockAgg[i] = pDataBlock->pBlockAgg[slotId];
|
||||||
|
} else {
|
||||||
|
int32_t code = doEnsureCapacity(pDst, &pDstBlock->info, pDataBlock->info.rows, false);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
terrno = code;
|
||||||
|
blockDataDestroy(pDstBlock);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
colDataAssign(pDst, pSrc, pDataBlock->info.rows, &pDataBlock->info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pDstBlock;
|
||||||
|
}
|
||||||
|
|
||||||
static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
SPartitionOperatorInfo* pInfo = pOperator->info;
|
SPartitionOperatorInfo* pInfo = pOperator->info;
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
@ -584,71 +633,86 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
pGroupInfo->groupId = calcGroupId(pInfo->keyBuf, len);
|
pGroupInfo->groupId = calcGroupId(pInfo->keyBuf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
// number of rows
|
if (pBlock->info.dataLoad) {
|
||||||
int32_t* rows = (int32_t*)pPage;
|
// number of rows
|
||||||
|
int32_t* rows = (int32_t*)pPage;
|
||||||
|
|
||||||
size_t numOfCols = pOperator->exprSupp.numOfExprs;
|
size_t numOfCols = pOperator->exprSupp.numOfExprs;
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SExprInfo* pExpr = &pOperator->exprSupp.pExprInfo[i];
|
SExprInfo* pExpr = &pOperator->exprSupp.pExprInfo[i];
|
||||||
int32_t slotId = pExpr->base.pParam[0].pCol->slotId;
|
int32_t slotId = pExpr->base.pParam[0].pCol->slotId;
|
||||||
|
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, slotId);
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
|
|
||||||
int32_t bytes = pColInfoData->info.bytes;
|
int32_t bytes = pColInfoData->info.bytes;
|
||||||
int32_t startOffset = pInfo->columnOffset[i];
|
int32_t startOffset = pInfo->columnOffset[i];
|
||||||
|
|
||||||
int32_t* columnLen = NULL;
|
int32_t* columnLen = NULL;
|
||||||
int32_t contentLen = 0;
|
int32_t contentLen = 0;
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
||||||
int32_t* offset = (int32_t*)((char*)pPage + startOffset);
|
int32_t* offset = (int32_t*)((char*)pPage + startOffset);
|
||||||
columnLen = (int32_t*)((char*)pPage + startOffset + sizeof(int32_t) * pInfo->rowCapacity);
|
columnLen = (int32_t*)((char*)pPage + startOffset + sizeof(int32_t) * pInfo->rowCapacity);
|
||||||
char* data = (char*)((char*)columnLen + sizeof(int32_t));
|
char* data = (char*)((char*)columnLen + sizeof(int32_t));
|
||||||
|
|
||||||
if (colDataIsNull_s(pColInfoData, j)) {
|
if (colDataIsNull_s(pColInfoData, j)) {
|
||||||
offset[(*rows)] = -1;
|
offset[(*rows)] = -1;
|
||||||
contentLen = 0;
|
contentLen = 0;
|
||||||
} else if (pColInfoData->info.type == TSDB_DATA_TYPE_JSON) {
|
} else if (pColInfoData->info.type == TSDB_DATA_TYPE_JSON) {
|
||||||
offset[*rows] = (*columnLen);
|
offset[*rows] = (*columnLen);
|
||||||
char* src = colDataGetData(pColInfoData, j);
|
char* src = colDataGetData(pColInfoData, j);
|
||||||
int32_t dataLen = getJsonValueLen(src);
|
int32_t dataLen = getJsonValueLen(src);
|
||||||
|
|
||||||
memcpy(data + (*columnLen), src, dataLen);
|
memcpy(data + (*columnLen), src, dataLen);
|
||||||
int32_t v = (data + (*columnLen) + dataLen - (char*)pPage);
|
int32_t v = (data + (*columnLen) + dataLen - (char*)pPage);
|
||||||
ASSERT(v > 0);
|
ASSERT(v > 0);
|
||||||
|
|
||||||
contentLen = dataLen;
|
contentLen = dataLen;
|
||||||
|
} else {
|
||||||
|
offset[*rows] = (*columnLen);
|
||||||
|
char* src = colDataGetData(pColInfoData, j);
|
||||||
|
memcpy(data + (*columnLen), src, varDataTLen(src));
|
||||||
|
int32_t v = (data + (*columnLen) + varDataTLen(src) - (char*)pPage);
|
||||||
|
ASSERT(v > 0);
|
||||||
|
|
||||||
|
contentLen = varDataTLen(src);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
offset[*rows] = (*columnLen);
|
char* bitmap = (char*)pPage + startOffset;
|
||||||
char* src = colDataGetData(pColInfoData, j);
|
columnLen = (int32_t*)((char*)pPage + startOffset + BitmapLen(pInfo->rowCapacity));
|
||||||
memcpy(data + (*columnLen), src, varDataTLen(src));
|
char* data = (char*)columnLen + sizeof(int32_t);
|
||||||
int32_t v = (data + (*columnLen) + varDataTLen(src) - (char*)pPage);
|
|
||||||
ASSERT(v > 0);
|
|
||||||
|
|
||||||
contentLen = varDataTLen(src);
|
bool isNull = colDataIsNull_f(pColInfoData->nullbitmap, j);
|
||||||
|
if (isNull) {
|
||||||
|
colDataSetNull_f(bitmap, (*rows));
|
||||||
|
} else {
|
||||||
|
memcpy(data + (*columnLen), colDataGetData(pColInfoData, j), bytes);
|
||||||
|
ASSERT((data + (*columnLen) + bytes - (char*)pPage) <= getBufPageSize(pInfo->pBuf));
|
||||||
|
}
|
||||||
|
contentLen = bytes;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
char* bitmap = (char*)pPage + startOffset;
|
|
||||||
columnLen = (int32_t*)((char*)pPage + startOffset + BitmapLen(pInfo->rowCapacity));
|
|
||||||
char* data = (char*)columnLen + sizeof(int32_t);
|
|
||||||
|
|
||||||
bool isNull = colDataIsNull_f(pColInfoData->nullbitmap, j);
|
(*columnLen) += contentLen;
|
||||||
if (isNull) {
|
|
||||||
colDataSetNull_f(bitmap, (*rows));
|
|
||||||
} else {
|
|
||||||
memcpy(data + (*columnLen), colDataGetData(pColInfoData, j), bytes);
|
|
||||||
ASSERT((data + (*columnLen) + bytes - (char*)pPage) <= getBufPageSize(pInfo->pBuf));
|
|
||||||
}
|
|
||||||
contentLen = bytes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(*columnLen) += contentLen;
|
(*rows) += 1;
|
||||||
|
|
||||||
|
setBufPageDirty(pPage, true);
|
||||||
|
releaseBufPage(pInfo->pBuf, pPage);
|
||||||
|
} else {
|
||||||
|
SSDataBlock* dataNotLoadBlock = createBlockDataNotLoaded(pOperator, pBlock);
|
||||||
|
if (dataNotLoadBlock == NULL) {
|
||||||
|
T_LONG_JMP(pTaskInfo->env, terrno);
|
||||||
|
}
|
||||||
|
if (pGroupInfo->blockForNotLoaded == NULL) {
|
||||||
|
pGroupInfo->blockForNotLoaded = taosArrayInit(0, sizeof(SSDataBlock*));
|
||||||
|
pGroupInfo->offsetForNotLoaded = 0;
|
||||||
|
}
|
||||||
|
dataNotLoadBlock->info.id.groupId = pGroupInfo->groupId;
|
||||||
|
dataNotLoadBlock->info.dataLoad = 0;
|
||||||
|
taosArrayPush(pGroupInfo->blockForNotLoaded, &dataNotLoadBlock);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*rows) += 1;
|
|
||||||
|
|
||||||
setBufPageDirty(pPage, true);
|
|
||||||
releaseBufPage(pInfo->pBuf, pPage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,6 +794,14 @@ static void clearPartitionOperator(SPartitionOperatorInfo* pInfo) {
|
||||||
int32_t size = taosArrayGetSize(pInfo->sortedGroupArray);
|
int32_t size = taosArrayGetSize(pInfo->sortedGroupArray);
|
||||||
for (int32_t i = 0; i < size; i++) {
|
for (int32_t i = 0; i < size; i++) {
|
||||||
SDataGroupInfo* pGp = taosArrayGet(pInfo->sortedGroupArray, i);
|
SDataGroupInfo* pGp = taosArrayGet(pInfo->sortedGroupArray, i);
|
||||||
|
if (pGp->blockForNotLoaded) {
|
||||||
|
for (int32_t i = 0; i < pGp->blockForNotLoaded->size; i++) {
|
||||||
|
SSDataBlock** pBlock = taosArrayGet(pGp->blockForNotLoaded, i);
|
||||||
|
blockDataDestroy(*pBlock);
|
||||||
|
}
|
||||||
|
taosArrayClear(pGp->blockForNotLoaded);
|
||||||
|
pGp->offsetForNotLoaded = 0;
|
||||||
|
}
|
||||||
taosArrayDestroy(pGp->pPageList);
|
taosArrayDestroy(pGp->pPageList);
|
||||||
}
|
}
|
||||||
taosArrayClear(pInfo->sortedGroupArray);
|
taosArrayClear(pInfo->sortedGroupArray);
|
||||||
|
@ -747,6 +819,15 @@ static int compareDataGroupInfo(const void* group1, const void* group2) {
|
||||||
return (pGroupInfo1->groupId < pGroupInfo2->groupId) ? -1 : 1;
|
return (pGroupInfo1->groupId < pGroupInfo2->groupId) ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SSDataBlock* buildPartitionResultForNotLoadBlock(SDataGroupInfo* pGroupInfo) {
|
||||||
|
if (pGroupInfo->blockForNotLoaded && pGroupInfo->offsetForNotLoaded < pGroupInfo->blockForNotLoaded->size) {
|
||||||
|
SSDataBlock** pBlock = taosArrayGet(pGroupInfo->blockForNotLoaded, pGroupInfo->offsetForNotLoaded);
|
||||||
|
pGroupInfo->offsetForNotLoaded++;
|
||||||
|
return *pBlock;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
|
static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
|
||||||
SPartitionOperatorInfo* pInfo = pOperator->info;
|
SPartitionOperatorInfo* pInfo = pOperator->info;
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
@ -756,13 +837,17 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
|
||||||
SDataGroupInfo* pGroupInfo =
|
SDataGroupInfo* pGroupInfo =
|
||||||
(pInfo->groupIndex != -1) ? taosArrayGet(pInfo->sortedGroupArray, pInfo->groupIndex) : NULL;
|
(pInfo->groupIndex != -1) ? taosArrayGet(pInfo->sortedGroupArray, pInfo->groupIndex) : NULL;
|
||||||
if (pInfo->groupIndex == -1 || pInfo->pageIndex >= taosArrayGetSize(pGroupInfo->pPageList)) {
|
if (pInfo->groupIndex == -1 || pInfo->pageIndex >= taosArrayGetSize(pGroupInfo->pPageList)) {
|
||||||
|
if(pGroupInfo != NULL) {
|
||||||
|
SSDataBlock* ret = buildPartitionResultForNotLoadBlock(pGroupInfo);
|
||||||
|
if(ret != NULL) return ret;
|
||||||
|
}
|
||||||
// try next group data
|
// try next group data
|
||||||
++pInfo->groupIndex;
|
if (pInfo->groupIndex + 1 >= taosArrayGetSize(pInfo->sortedGroupArray)) {
|
||||||
if (pInfo->groupIndex >= taosArrayGetSize(pInfo->sortedGroupArray)) {
|
|
||||||
setOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
clearPartitionOperator(pInfo);
|
clearPartitionOperator(pInfo);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
++pInfo->groupIndex;
|
||||||
|
|
||||||
pGroupInfo = taosArrayGet(pInfo->sortedGroupArray, pInfo->groupIndex);
|
pGroupInfo = taosArrayGet(pInfo->sortedGroupArray, pInfo->groupIndex);
|
||||||
pInfo->pageIndex = 0;
|
pInfo->pageIndex = 0;
|
||||||
|
@ -774,6 +859,20 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
|
||||||
qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo));
|
qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo));
|
||||||
T_LONG_JMP(pTaskInfo->env, terrno);
|
T_LONG_JMP(pTaskInfo->env, terrno);
|
||||||
}
|
}
|
||||||
|
if (*(int32_t*)page == 0) {
|
||||||
|
releaseBufPage(pInfo->pBuf, page);
|
||||||
|
SSDataBlock* ret = buildPartitionResultForNotLoadBlock(pGroupInfo);
|
||||||
|
if (ret != NULL) return ret;
|
||||||
|
if (pInfo->groupIndex + 1 < taosArrayGetSize(pInfo->sortedGroupArray)) {
|
||||||
|
pInfo->groupIndex++;
|
||||||
|
pInfo->pageIndex = 0;
|
||||||
|
} else {
|
||||||
|
setOperatorCompleted(pOperator);
|
||||||
|
clearPartitionOperator(pInfo);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return buildPartitionResult(pOperator);
|
||||||
|
}
|
||||||
|
|
||||||
blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->rowCapacity);
|
blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->rowCapacity);
|
||||||
blockDataFromBuf1(pInfo->binfo.pRes, page, pInfo->rowCapacity);
|
blockDataFromBuf1(pInfo->binfo.pRes, page, pInfo->rowCapacity);
|
||||||
|
@ -783,6 +882,8 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
|
||||||
pInfo->binfo.pRes->info.id.groupId = pGroupInfo->groupId;
|
pInfo->binfo.pRes->info.id.groupId = pGroupInfo->groupId;
|
||||||
pInfo->binfo.pRes->info.dataLoad = 1;
|
pInfo->binfo.pRes->info.dataLoad = 1;
|
||||||
pInfo->orderedRows = 0;
|
pInfo->orderedRows = 0;
|
||||||
|
} else if (pInfo->pOrderInfoArr == NULL) {
|
||||||
|
qError("Exception, remainRows not zero, but pOrderInfoArr is NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->pOrderInfoArr) {
|
if (pInfo->pOrderInfoArr) {
|
||||||
|
@ -1009,8 +1110,7 @@ int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo,
|
||||||
SResultRow* pResultRow =
|
SResultRow* pResultRow =
|
||||||
doSetResultOutBufByKey(pBuf, pResultRowInfo, (char*)pData, bytes, true, groupId, pTaskInfo, false, pAggSup, false);
|
doSetResultOutBufByKey(pBuf, pResultRowInfo, (char*)pData, bytes, true, groupId, pTaskInfo, false, pAggSup, false);
|
||||||
|
|
||||||
setResultRowInitCtx(pResultRow, pCtx, numOfCols, pOperator->exprSupp.rowEntryInfoOffset);
|
return setResultRowInitCtx(pResultRow, pCtx, numOfCols, pOperator->exprSupp.rowEntryInfoOffset);
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId) {
|
uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId) {
|
||||||
|
|
|
@ -220,7 +220,7 @@ static int32_t doDynamicPruneDataBlock(SOperatorInfo* pOperator, SDataBlockInfo*
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool doFilterByBlockSMA(SFilterInfo* pFilterInfo, SColumnDataAgg** pColsAgg, int32_t numOfCols,
|
static bool doFilterByBlockSMA(SFilterInfo* pFilterInfo, SColumnDataAgg* pColsAgg, int32_t numOfCols,
|
||||||
int32_t numOfRows) {
|
int32_t numOfRows) {
|
||||||
if (pColsAgg == NULL || pFilterInfo == NULL) {
|
if (pColsAgg == NULL || pFilterInfo == NULL) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -725,7 +725,7 @@ void markGroupProcessed(STableScanInfo* pInfo, uint64_t groupId) {
|
||||||
if (pInfo->countState == TABLE_COUNT_STATE_END) {
|
if (pInfo->countState == TABLE_COUNT_STATE_END) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pInfo->base.pTableListInfo->oneTableForEachGroup || pInfo->base.pTableListInfo->groupOffset) {
|
if (pInfo->base.pTableListInfo->groupOffset) {
|
||||||
pInfo->countState = TABLE_COUNT_STATE_PROCESSED;
|
pInfo->countState = TABLE_COUNT_STATE_PROCESSED;
|
||||||
} else {
|
} else {
|
||||||
taosHashRemove(pInfo->base.pTableListInfo->remainGroups, &groupId, sizeof(groupId));
|
taosHashRemove(pInfo->base.pTableListInfo->remainGroups, &groupId, sizeof(groupId));
|
||||||
|
@ -769,6 +769,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
|
||||||
SSDataBlock* pBlock = pTableScanInfo->pResBlock;
|
SSDataBlock* pBlock = pTableScanInfo->pResBlock;
|
||||||
bool hasNext = false;
|
bool hasNext = false;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
pBlock->info.dataLoad = false;
|
||||||
|
|
||||||
int64_t st = taosGetTimestampUs();
|
int64_t st = taosGetTimestampUs();
|
||||||
|
|
||||||
|
@ -890,7 +891,7 @@ static SSDataBlock* doGroupedTableScan(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
if (pTableScanInfo->countState < TABLE_COUNT_STATE_END) {
|
if (pTableScanInfo->countState < TABLE_COUNT_STATE_END) {
|
||||||
STableListInfo* pTableListInfo = pTableScanInfo->base.pTableListInfo;
|
STableListInfo* pTableListInfo = pTableScanInfo->base.pTableListInfo;
|
||||||
if (pTableListInfo->oneTableForEachGroup || pTableListInfo->groupOffset) { // group by tbname, group by tag + sort
|
if (pTableListInfo->groupOffset) { // group by tbname, group by tag + sort
|
||||||
if (pTableScanInfo->countState < TABLE_COUNT_STATE_PROCESSED) {
|
if (pTableScanInfo->countState < TABLE_COUNT_STATE_PROCESSED) {
|
||||||
pTableScanInfo->countState = TABLE_COUNT_STATE_PROCESSED;
|
pTableScanInfo->countState = TABLE_COUNT_STATE_PROCESSED;
|
||||||
STableKeyInfo* pStart =
|
STableKeyInfo* pStart =
|
||||||
|
|
|
@ -1975,8 +1975,7 @@ static int32_t initSessionOutputBuf(SResultWindowInfo* pWinInfo, SResultRow** pR
|
||||||
*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;
|
||||||
setResultRowInitCtx(*pResult, pCtx, numOfOutput, rowEntryInfoOffset);
|
return setResultRowInitCtx(*pResult, pCtx, numOfOutput, rowEntryInfoOffset);
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doOneWindowAggImpl(SColumnInfoData* pTimeWindowData, SResultWindowInfo* pCurWin, SResultRow** pResult,
|
int32_t doOneWindowAggImpl(SColumnInfoData* pTimeWindowData, SResultWindowInfo* pCurWin, SResultRow** pResult,
|
||||||
|
|
|
@ -84,9 +84,7 @@ static int32_t setTimeWindowOutputBuf(SResultRowInfo* pResultRowInfo, STimeWindo
|
||||||
pResultRow->win = (*win);
|
pResultRow->win = (*win);
|
||||||
|
|
||||||
*pResult = pResultRow;
|
*pResult = pResultRow;
|
||||||
setResultRowInitCtx(pResultRow, pCtx, numOfOutput, rowEntryInfoOffset);
|
return setResultRowInitCtx(pResultRow, pCtx, numOfOutput, rowEntryInfoOffset);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doKeepTuple(SWindowRowsSup* pRowSup, int64_t ts, uint64_t groupId) {
|
static void doKeepTuple(SWindowRowsSup* pRowSup, int64_t ts, uint64_t groupId) {
|
||||||
|
@ -911,7 +909,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
|
||||||
|
|
||||||
struct SColumnDataAgg* pAgg = NULL;
|
struct SColumnDataAgg* pAgg = NULL;
|
||||||
for (int32_t j = 0; j < pBlock->info.rows; ++j) {
|
for (int32_t j = 0; j < pBlock->info.rows; ++j) {
|
||||||
pAgg = (pBlock->pBlockAgg != NULL) ? pBlock->pBlockAgg[pInfo->stateCol.slotId] : NULL;
|
pAgg = (pBlock->pBlockAgg != NULL) ? &pBlock->pBlockAgg[pInfo->stateCol.slotId] : NULL;
|
||||||
if (colDataIsNull(pStateColInfoData, pBlock->info.rows, j, pAgg)) {
|
if (colDataIsNull(pStateColInfoData, pBlock->info.rows, j, pAgg)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1647,8 +1645,7 @@ static int32_t setSingleOutputTupleBuf(SResultRowInfo* pResultRowInfo, STimeWind
|
||||||
|
|
||||||
// set time window for current result
|
// set time window for current result
|
||||||
(*pResult)->win = (*win);
|
(*pResult)->win = (*win);
|
||||||
setResultRowInitCtx((*pResult), pExprSup->pCtx, pExprSup->numOfExprs, pExprSup->rowEntryInfoOffset);
|
return setResultRowInitCtx((*pResult), pExprSup->pCtx, pExprSup->numOfExprs, pExprSup->rowEntryInfoOffset);
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo,
|
static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo,
|
||||||
|
|
|
@ -651,7 +651,7 @@ int32_t tsortComparBlockCell(SSDataBlock* pLeftBlock, SSDataBlock* pRightBlock,
|
||||||
leftNull = colDataIsNull_t(pLeftColInfoData, leftRowIndex, isVarType);
|
leftNull = colDataIsNull_t(pLeftColInfoData, leftRowIndex, isVarType);
|
||||||
} else {
|
} else {
|
||||||
leftNull =
|
leftNull =
|
||||||
colDataIsNull(pLeftColInfoData, pLeftBlock->info.rows, leftRowIndex, pLeftBlock->pBlockAgg[pOrder->slotId]);
|
colDataIsNull(pLeftColInfoData, pLeftBlock->info.rows, leftRowIndex, &pLeftBlock->pBlockAgg[pOrder->slotId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,7 +661,7 @@ int32_t tsortComparBlockCell(SSDataBlock* pLeftBlock, SSDataBlock* pRightBlock,
|
||||||
rightNull = colDataIsNull_t(pRightColInfoData, rightRowIndex, isVarType);
|
rightNull = colDataIsNull_t(pRightColInfoData, rightRowIndex, isVarType);
|
||||||
} else {
|
} else {
|
||||||
rightNull = colDataIsNull(pRightColInfoData, pRightBlock->info.rows, rightRowIndex,
|
rightNull = colDataIsNull(pRightColInfoData, pRightBlock->info.rows, rightRowIndex,
|
||||||
pRightBlock->pBlockAgg[pOrder->slotId]);
|
&pRightBlock->pBlockAgg[pOrder->slotId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,7 +742,7 @@ int32_t msortComparFn(const void* pLeft, const void* pRight, void* param) {
|
||||||
leftNull = colDataIsNull_t(pLeftColInfoData, pLeftSource->src.rowIndex, isVarType);
|
leftNull = colDataIsNull_t(pLeftColInfoData, pLeftSource->src.rowIndex, isVarType);
|
||||||
} else {
|
} else {
|
||||||
leftNull = colDataIsNull(pLeftColInfoData, pLeftBlock->info.rows, pLeftSource->src.rowIndex,
|
leftNull = colDataIsNull(pLeftColInfoData, pLeftBlock->info.rows, pLeftSource->src.rowIndex,
|
||||||
pLeftBlock->pBlockAgg[i]);
|
&pLeftBlock->pBlockAgg[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,7 +752,7 @@ int32_t msortComparFn(const void* pLeft, const void* pRight, void* param) {
|
||||||
rightNull = colDataIsNull_t(pRightColInfoData, pRightSource->src.rowIndex, isVarType);
|
rightNull = colDataIsNull_t(pRightColInfoData, pRightSource->src.rowIndex, isVarType);
|
||||||
} else {
|
} else {
|
||||||
rightNull = colDataIsNull(pRightColInfoData, pRightBlock->info.rows, pRightSource->src.rowIndex,
|
rightNull = colDataIsNull(pRightColInfoData, pRightBlock->info.rows, pRightSource->src.rowIndex,
|
||||||
pRightBlock->pBlockAgg[i]);
|
&pRightBlock->pBlockAgg[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2366,7 +2366,10 @@ EFuncDataRequired firstDynDataReq(void* pRes, SDataBlockInfo* pBlockInfo) {
|
||||||
}
|
}
|
||||||
if (pResult->ts < pBlockInfo->window.skey) {
|
if (pResult->ts < pBlockInfo->window.skey) {
|
||||||
return FUNC_DATA_REQUIRED_NOT_LOAD;
|
return FUNC_DATA_REQUIRED_NOT_LOAD;
|
||||||
} else if (pResult->ts == pBlockInfo->window.skey && pResult->pkData) {
|
} else if (pResult->ts == pBlockInfo->window.skey) {
|
||||||
|
if (NULL == pResult->pkData) {
|
||||||
|
return FUNC_DATA_REQUIRED_NOT_LOAD;
|
||||||
|
}
|
||||||
if (comparePkDataWithSValue(pResult->pkType, pResult->pkData, pBlockInfo->pks + 0, TSDB_ORDER_ASC) < 0) {
|
if (comparePkDataWithSValue(pResult->pkType, pResult->pkData, pBlockInfo->pks + 0, TSDB_ORDER_ASC) < 0) {
|
||||||
return FUNC_DATA_REQUIRED_NOT_LOAD;
|
return FUNC_DATA_REQUIRED_NOT_LOAD;
|
||||||
}
|
}
|
||||||
|
@ -3628,7 +3631,7 @@ int32_t saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock*
|
||||||
SColumnInfoData* pColInfo = taosArrayGet(pSrcBlock->pDataBlock, pCtx->saveHandle.pState->tsIndex);
|
SColumnInfoData* pColInfo = taosArrayGet(pSrcBlock->pDataBlock, pCtx->saveHandle.pState->tsIndex);
|
||||||
ASSERT(pColInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
ASSERT(pColInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* buf = serializeTupleData(pSrcBlock, rowIndex, &pCtx->subsidiaries, pCtx->subsidiaries.buf);
|
char* buf = serializeTupleData(pSrcBlock, rowIndex, &pCtx->subsidiaries, pCtx->subsidiaries.buf);
|
||||||
|
|
|
@ -702,23 +702,16 @@ static void doExtractVal(SColumnInfoData* pCol, int32_t i, int32_t end, SqlFunct
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t saveRelatedTuple(SqlFunctionCtx* pCtx, SInputColumnInfoData* pInput, int32_t index, void* tval) {
|
static int32_t saveRelatedTupleTag(SqlFunctionCtx* pCtx, SInputColumnInfoData* pInput, void* tval) {
|
||||||
SColumnInfoData* pCol = pInput->pData[0];
|
SColumnInfoData* pCol = pInput->pData[0];
|
||||||
|
|
||||||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
SMinmaxResInfo* pBuf = GET_ROWCELL_INTERBUF(pResInfo);
|
SMinmaxResInfo* pBuf = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
code = saveTupleData(pCtx, 0, pCtx->pSrcBlock, &pBuf->tuplePos);
|
||||||
if (index >= 0) {
|
|
||||||
code = saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -758,7 +751,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems)
|
||||||
pBuf->v = GET_INT64_VAL(tval);
|
pBuf->v = GET_INT64_VAL(tval);
|
||||||
}
|
}
|
||||||
|
|
||||||
code = saveRelatedTuple(pCtx, pInput, index, tval);
|
code = saveRelatedTupleTag(pCtx, pInput, tval);
|
||||||
} else {
|
} else {
|
||||||
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
||||||
int64_t prev = 0;
|
int64_t prev = 0;
|
||||||
|
@ -767,7 +760,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems)
|
||||||
int64_t val = GET_INT64_VAL(tval);
|
int64_t val = GET_INT64_VAL(tval);
|
||||||
if ((prev < val) ^ isMinFunc) {
|
if ((prev < val) ^ isMinFunc) {
|
||||||
GET_INT64_VAL(&pBuf->v) = val;
|
GET_INT64_VAL(&pBuf->v) = val;
|
||||||
code = saveRelatedTuple(pCtx, pInput, index, tval);
|
code = saveRelatedTupleTag(pCtx, pInput, tval);
|
||||||
}
|
}
|
||||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||||
uint64_t prev = 0;
|
uint64_t prev = 0;
|
||||||
|
@ -776,7 +769,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems)
|
||||||
uint64_t val = GET_UINT64_VAL(tval);
|
uint64_t val = GET_UINT64_VAL(tval);
|
||||||
if ((prev < val) ^ isMinFunc) {
|
if ((prev < val) ^ isMinFunc) {
|
||||||
GET_UINT64_VAL(&pBuf->v) = val;
|
GET_UINT64_VAL(&pBuf->v) = val;
|
||||||
code = saveRelatedTuple(pCtx, pInput, index, tval);
|
code = saveRelatedTupleTag(pCtx, pInput, tval);
|
||||||
}
|
}
|
||||||
} else if (type == TSDB_DATA_TYPE_DOUBLE) {
|
} else if (type == TSDB_DATA_TYPE_DOUBLE) {
|
||||||
double prev = 0;
|
double prev = 0;
|
||||||
|
@ -785,7 +778,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems)
|
||||||
double val = GET_DOUBLE_VAL(tval);
|
double val = GET_DOUBLE_VAL(tval);
|
||||||
if ((prev < val) ^ isMinFunc) {
|
if ((prev < val) ^ isMinFunc) {
|
||||||
GET_DOUBLE_VAL(&pBuf->v) = val;
|
GET_DOUBLE_VAL(&pBuf->v) = val;
|
||||||
code = saveRelatedTuple(pCtx, pInput, index, tval);
|
code = saveRelatedTupleTag(pCtx, pInput, tval);
|
||||||
}
|
}
|
||||||
} else if (type == TSDB_DATA_TYPE_FLOAT) {
|
} else if (type == TSDB_DATA_TYPE_FLOAT) {
|
||||||
float prev = 0;
|
float prev = 0;
|
||||||
|
@ -794,7 +787,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems)
|
||||||
float val = GET_DOUBLE_VAL(tval);
|
float val = GET_DOUBLE_VAL(tval);
|
||||||
if ((prev < val) ^ isMinFunc) {
|
if ((prev < val) ^ isMinFunc) {
|
||||||
GET_FLOAT_VAL(&pBuf->v) = val;
|
GET_FLOAT_VAL(&pBuf->v) = val;
|
||||||
code = saveRelatedTuple(pCtx, pInput, index, tval);
|
code = saveRelatedTupleTag(pCtx, pInput, tval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ static SFilePage *loadDataFromFilePage(tMemBucket *pMemBucket, int32_t slotIdx)
|
||||||
static void resetBoundingBox(MinMaxEntry *range, int32_t type) {
|
static void resetBoundingBox(MinMaxEntry *range, int32_t type) {
|
||||||
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
||||||
range->dMaxVal = INT64_MIN;
|
range->dMaxVal = INT64_MIN;
|
||||||
range->dMinVal = INT64_MAX;
|
range->dMinVal = (double)INT64_MAX;
|
||||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||||
range->u64MaxVal = 0;
|
range->u64MaxVal = 0;
|
||||||
range->u64MinVal = UINT64_MAX;
|
range->u64MinVal = UINT64_MAX;
|
||||||
|
|
|
@ -26,6 +26,10 @@
|
||||||
#include "tudf.h"
|
#include "tudf.h"
|
||||||
#include "tudfInt.h"
|
#include "tudfInt.h"
|
||||||
|
|
||||||
|
#ifdef _TD_DARWIN_64
|
||||||
|
#include <mach-o/dyld.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct SUdfdData {
|
typedef struct SUdfdData {
|
||||||
bool startCalled;
|
bool startCalled;
|
||||||
bool needCleanUp;
|
bool needCleanUp;
|
||||||
|
|
|
@ -691,7 +691,7 @@ void udfdProcessCallRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
|
||||||
convertDataBlockToUdfDataBlock(&call->block, &input);
|
convertDataBlockToUdfDataBlock(&call->block, &input);
|
||||||
code = udf->scriptPlugin->udfScalarProcFunc(&input, &output, udf->scriptUdfCtx);
|
code = udf->scriptPlugin->udfScalarProcFunc(&input, &output, udf->scriptUdfCtx);
|
||||||
freeUdfDataDataBlock(&input);
|
freeUdfDataDataBlock(&input);
|
||||||
convertUdfColumnToDataBlock(&output, &response.callRsp.resultData);
|
if(code == 0) convertUdfColumnToDataBlock(&output, &response.callRsp.resultData);
|
||||||
freeUdfColumn(&output);
|
freeUdfColumn(&output);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ DLL_EXPORT int32_t udf2_init() { return 0; }
|
||||||
DLL_EXPORT int32_t udf2_destroy() { return 0; }
|
DLL_EXPORT int32_t udf2_destroy() { return 0; }
|
||||||
|
|
||||||
DLL_EXPORT int32_t udf2_start(SUdfInterBuf* buf) {
|
DLL_EXPORT int32_t udf2_start(SUdfInterBuf* buf) {
|
||||||
|
if(buf->buf == NULL || buf->bufLen < (sizeof(int64_t))) return TSDB_CODE_UDF_INVALID_BUFSIZE;
|
||||||
*(int64_t*)(buf->buf) = 0;
|
*(int64_t*)(buf->buf) = 0;
|
||||||
buf->bufLen = sizeof(double);
|
buf->bufLen = sizeof(double);
|
||||||
buf->numOfResult = 1;
|
buf->numOfResult = 1;
|
||||||
|
@ -17,6 +18,7 @@ DLL_EXPORT int32_t udf2_start(SUdfInterBuf* buf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DLL_EXPORT int32_t udf2(SUdfDataBlock* block, SUdfInterBuf* interBuf, SUdfInterBuf* newInterBuf) {
|
DLL_EXPORT int32_t udf2(SUdfDataBlock* block, SUdfInterBuf* interBuf, SUdfInterBuf* newInterBuf) {
|
||||||
|
if(newInterBuf->buf == NULL || newInterBuf->bufLen < (sizeof(double))) return TSDB_CODE_UDF_INVALID_BUFSIZE;
|
||||||
double sumSquares = 0;
|
double sumSquares = 0;
|
||||||
if (interBuf->numOfResult == 1) {
|
if (interBuf->numOfResult == 1) {
|
||||||
sumSquares = *(double*)interBuf->buf;
|
sumSquares = *(double*)interBuf->buf;
|
||||||
|
|
|
@ -25,8 +25,10 @@
|
||||||
#include "tref.h"
|
#include "tref.h"
|
||||||
#include "tsched.h"
|
#include "tsched.h"
|
||||||
|
|
||||||
#define INDEX_NUM_OF_THREADS 5
|
#define INDEX_NUM_OF_THREADS 5
|
||||||
#define INDEX_QUEUE_SIZE 200
|
#define INDEX_MAX_NUM_OF_THREADS 10
|
||||||
|
|
||||||
|
#define INDEX_QUEUE_SIZE 200
|
||||||
|
|
||||||
#define INDEX_DATA_BOOL_NULL 0x02
|
#define INDEX_DATA_BOOL_NULL 0x02
|
||||||
#define INDEX_DATA_TINYINT_NULL 0x80
|
#define INDEX_DATA_TINYINT_NULL 0x80
|
||||||
|
@ -61,6 +63,7 @@ static void indexDestroy(void* sIdx);
|
||||||
void indexInit(int32_t threadNum) {
|
void indexInit(int32_t threadNum) {
|
||||||
indexThreads = threadNum;
|
indexThreads = threadNum;
|
||||||
if (indexThreads <= 1) indexThreads = INDEX_NUM_OF_THREADS;
|
if (indexThreads <= 1) indexThreads = INDEX_NUM_OF_THREADS;
|
||||||
|
if (indexThreads >= INDEX_MAX_NUM_OF_THREADS) indexThreads = INDEX_MAX_NUM_OF_THREADS;
|
||||||
}
|
}
|
||||||
void indexEnvInit() {
|
void indexEnvInit() {
|
||||||
// refactor later
|
// refactor later
|
||||||
|
|
|
@ -843,6 +843,7 @@ static int32_t selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) {
|
||||||
CLONE_NODE_FIELD_EX(pLimit, SLimitNode*);
|
CLONE_NODE_FIELD_EX(pLimit, SLimitNode*);
|
||||||
COPY_CHAR_ARRAY_FIELD(stmtName);
|
COPY_CHAR_ARRAY_FIELD(stmtName);
|
||||||
COPY_SCALAR_FIELD(precision);
|
COPY_SCALAR_FIELD(precision);
|
||||||
|
COPY_SCALAR_FIELD(isSubquery);
|
||||||
COPY_SCALAR_FIELD(isEmptyResult);
|
COPY_SCALAR_FIELD(isEmptyResult);
|
||||||
COPY_SCALAR_FIELD(timeLineResMode);
|
COPY_SCALAR_FIELD(timeLineResMode);
|
||||||
COPY_SCALAR_FIELD(timeLineFromOrderBy);
|
COPY_SCALAR_FIELD(timeLineFromOrderBy);
|
||||||
|
|
|
@ -963,12 +963,14 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_WHEN_THEN: {
|
case QUERY_NODE_WHEN_THEN: {
|
||||||
SWhenThenNode* pWhenThen = (SWhenThenNode*)pNode;
|
SWhenThenNode* pWhenThen = (SWhenThenNode*)pNode;
|
||||||
|
destroyExprNode((SExprNode*)pNode);
|
||||||
nodesDestroyNode(pWhenThen->pWhen);
|
nodesDestroyNode(pWhenThen->pWhen);
|
||||||
nodesDestroyNode(pWhenThen->pThen);
|
nodesDestroyNode(pWhenThen->pThen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_CASE_WHEN: {
|
case QUERY_NODE_CASE_WHEN: {
|
||||||
SCaseWhenNode* pCaseWhen = (SCaseWhenNode*)pNode;
|
SCaseWhenNode* pCaseWhen = (SCaseWhenNode*)pNode;
|
||||||
|
destroyExprNode((SExprNode*)pNode);
|
||||||
nodesDestroyNode(pCaseWhen->pCase);
|
nodesDestroyNode(pCaseWhen->pCase);
|
||||||
nodesDestroyNode(pCaseWhen->pElse);
|
nodesDestroyNode(pCaseWhen->pElse);
|
||||||
nodesDestroyList(pCaseWhen->pWhenThenList);
|
nodesDestroyList(pCaseWhen->pWhenThenList);
|
||||||
|
|
|
@ -3203,6 +3203,27 @@ static bool fromSingleTable(SNode* table) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool IsEqualTbNameFuncNode(SSelectStmt* pSelect, SNode* pFunc1, SNode* pFunc2) {
|
||||||
|
if (isTbnameFuction(pFunc1) && isTbnameFuction(pFunc2)) {
|
||||||
|
SValueNode* pVal1 = (SValueNode*)nodesListGetNode(((SFunctionNode*)pFunc1)->pParameterList, 0);
|
||||||
|
SValueNode* pVal2 = (SValueNode*)nodesListGetNode(((SFunctionNode*)pFunc1)->pParameterList, 0);
|
||||||
|
if (!pVal1 && !pVal2) {
|
||||||
|
return true;
|
||||||
|
} else if (pVal1 && pVal2) {
|
||||||
|
return strcmp(pVal1->literal, pVal2->literal) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pSelect->pFromTable &&
|
||||||
|
(pSelect->pFromTable->type == QUERY_NODE_REAL_TABLE || pSelect->pFromTable->type == QUERY_NODE_TEMP_TABLE)) {
|
||||||
|
STableNode* pTable = (STableNode*)pSelect->pFromTable;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
||||||
STranslateContext* pCxt = (STranslateContext*)pContext;
|
STranslateContext* pCxt = (STranslateContext*)pContext;
|
||||||
SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt;
|
SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt;
|
||||||
|
@ -3222,6 +3243,9 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
||||||
((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) {
|
((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) {
|
||||||
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
||||||
}
|
}
|
||||||
|
if (IsEqualTbNameFuncNode(pSelect, pActualNode, *pNode)) {
|
||||||
|
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SNode* pPartKey = NULL;
|
SNode* pPartKey = NULL;
|
||||||
bool partionByTbname = hasTbnameFunction(pSelect->pPartitionByList);
|
bool partionByTbname = hasTbnameFunction(pSelect->pPartitionByList);
|
||||||
|
@ -3233,6 +3257,9 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
||||||
((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) {
|
((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) {
|
||||||
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
||||||
}
|
}
|
||||||
|
if (IsEqualTbNameFuncNode(pSelect, pPartKey, *pNode)) {
|
||||||
|
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (NULL != pSelect->pWindow && QUERY_NODE_STATE_WINDOW == nodeType(pSelect->pWindow)) {
|
if (NULL != pSelect->pWindow && QUERY_NODE_STATE_WINDOW == nodeType(pSelect->pWindow)) {
|
||||||
if (nodesEqualNode(((SStateWindowNode*)pSelect->pWindow)->pExpr, *pNode)) {
|
if (nodesEqualNode(((SStateWindowNode*)pSelect->pWindow)->pExpr, *pNode)) {
|
||||||
|
@ -6578,8 +6605,8 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkRangeOption(STranslateContext* pCxt, int32_t code, const char* pName, int64_t val, int64_t minVal,
|
static int32_t checkRangeOption(STranslateContext* pCxt, int32_t code, const char* pName, int64_t val, int64_t minVal,
|
||||||
int64_t maxVal) {
|
int64_t maxVal, bool skipUndef) {
|
||||||
if (val >= 0 && (val < minVal || val > maxVal)) {
|
if (skipUndef ? ((val >= 0) && (val < minVal || val > maxVal)) : (val < minVal || val > maxVal)) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, code,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, code,
|
||||||
"Invalid option %s: %" PRId64 ", valid range: [%" PRId64 ", %" PRId64 "]", pName,
|
"Invalid option %s: %" PRId64 ", valid range: [%" PRId64 ", %" PRId64 "]", pName,
|
||||||
val, minVal, maxVal);
|
val, minVal, maxVal);
|
||||||
|
@ -6589,12 +6616,12 @@ static int32_t checkRangeOption(STranslateContext* pCxt, int32_t code, const cha
|
||||||
|
|
||||||
static int32_t checkDbRangeOption(STranslateContext* pCxt, const char* pName, int32_t val, int32_t minVal,
|
static int32_t checkDbRangeOption(STranslateContext* pCxt, const char* pName, int32_t val, int32_t minVal,
|
||||||
int32_t maxVal) {
|
int32_t maxVal) {
|
||||||
return checkRangeOption(pCxt, TSDB_CODE_PAR_INVALID_DB_OPTION, pName, val, minVal, maxVal);
|
return checkRangeOption(pCxt, TSDB_CODE_PAR_INVALID_DB_OPTION, pName, val, minVal, maxVal, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkTableRangeOption(STranslateContext* pCxt, const char* pName, int64_t val, int64_t minVal,
|
static int32_t checkTableRangeOption(STranslateContext* pCxt, const char* pName, int64_t val, int64_t minVal,
|
||||||
int64_t maxVal) {
|
int64_t maxVal) {
|
||||||
return checkRangeOption(pCxt, TSDB_CODE_PAR_INVALID_TABLE_OPTION, pName, val, minVal, maxVal);
|
return checkRangeOption(pCxt, TSDB_CODE_PAR_INVALID_TABLE_OPTION, pName, val, minVal, maxVal, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkDbS3KeepLocalOption(STranslateContext* pCxt, SDatabaseOptions* pOptions) {
|
static int32_t checkDbS3KeepLocalOption(STranslateContext* pCxt, SDatabaseOptions* pOptions) {
|
||||||
|
@ -8468,7 +8495,7 @@ static int32_t translateUseDatabase(STranslateContext* pCxt, SUseDatabaseStmt* p
|
||||||
static int32_t translateCreateUser(STranslateContext* pCxt, SCreateUserStmt* pStmt) {
|
static int32_t translateCreateUser(STranslateContext* pCxt, SCreateUserStmt* pStmt) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCreateUserReq createReq = {0};
|
SCreateUserReq createReq = {0};
|
||||||
if ((code = checkRangeOption(pCxt, TSDB_CODE_INVALID_OPTION, "sysinfo", pStmt->sysinfo, 0, 1))) {
|
if ((code = checkRangeOption(pCxt, TSDB_CODE_INVALID_OPTION, "sysinfo", pStmt->sysinfo, 0, 1, false))) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
strcpy(createReq.user, pStmt->userName);
|
strcpy(createReq.user, pStmt->userName);
|
||||||
|
@ -8492,13 +8519,13 @@ static int32_t checkAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
switch (pStmt->alterType) {
|
switch (pStmt->alterType) {
|
||||||
case TSDB_ALTER_USER_ENABLE:
|
case TSDB_ALTER_USER_ENABLE:
|
||||||
code = checkRangeOption(pCxt, TSDB_CODE_INVALID_OPTION, "enable", pStmt->enable, 0, 1);
|
code = checkRangeOption(pCxt, TSDB_CODE_INVALID_OPTION, "enable", pStmt->enable, 0, 1, false);
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_USER_SYSINFO:
|
case TSDB_ALTER_USER_SYSINFO:
|
||||||
code = checkRangeOption(pCxt, TSDB_CODE_INVALID_OPTION, "sysinfo", pStmt->sysinfo, 0, 1);
|
code = checkRangeOption(pCxt, TSDB_CODE_INVALID_OPTION, "sysinfo", pStmt->sysinfo, 0, 1, false);
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_USER_CREATEDB:
|
case TSDB_ALTER_USER_CREATEDB:
|
||||||
code = checkRangeOption(pCxt, TSDB_CODE_INVALID_OPTION, "createdb", pStmt->createdb, 0, 1);
|
code = checkRangeOption(pCxt, TSDB_CODE_INVALID_OPTION, "createdb", pStmt->createdb, 0, 1, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -3011,7 +3011,9 @@ static SNode* partTagsCreateWrapperFunc(const char* pFuncName, SNode* pNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(pFunc->functionName, sizeof(pFunc->functionName), "%s", pFuncName);
|
snprintf(pFunc->functionName, sizeof(pFunc->functionName), "%s", pFuncName);
|
||||||
if (QUERY_NODE_COLUMN == nodeType(pNode) && COLUMN_TYPE_TBNAME != ((SColumnNode*)pNode)->colType) {
|
if ((QUERY_NODE_COLUMN == nodeType(pNode) && COLUMN_TYPE_TBNAME != ((SColumnNode*)pNode)->colType) ||
|
||||||
|
(QUERY_NODE_COLUMN == nodeType(pNode) && COLUMN_TYPE_TBNAME == ((SColumnNode*)pNode)->colType &&
|
||||||
|
((SColumnNode*)pNode)->tableAlias[0] != '\0')){
|
||||||
SColumnNode* pCol = (SColumnNode*)pNode;
|
SColumnNode* pCol = (SColumnNode*)pNode;
|
||||||
partTagsSetAlias(pFunc->node.aliasName, pCol->tableAlias, pCol->colName);
|
partTagsSetAlias(pFunc->node.aliasName, pCol->tableAlias, pCol->colName);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3782,7 +3782,7 @@ int32_t fltSclBuildRangeFromBlockSma(SFltSclColumnRange *colRange, SColumnDataAg
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg **pDataStatis, int32_t numOfCols, int32_t numOfRows) {
|
bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t numOfCols, int32_t numOfRows) {
|
||||||
if (info->scalarMode) {
|
if (info->scalarMode) {
|
||||||
SArray *colRanges = info->sclCtx.fltSclRange;
|
SArray *colRanges = info->sclCtx.fltSclRange;
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(colRanges); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(colRanges); ++i) {
|
||||||
|
@ -3790,13 +3790,13 @@ bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg **pDataStatis, int32_t
|
||||||
bool foundCol = false;
|
bool foundCol = false;
|
||||||
int32_t j = 0;
|
int32_t j = 0;
|
||||||
for (; j < numOfCols; ++j) {
|
for (; j < numOfCols; ++j) {
|
||||||
if (pDataStatis[j] != NULL && pDataStatis[j]->colId == colRange->colNode->colId) {
|
if (pDataStatis[j].colId == colRange->colNode->colId) {
|
||||||
foundCol = true;
|
foundCol = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (foundCol) {
|
if (foundCol) {
|
||||||
SColumnDataAgg *pAgg = pDataStatis[j];
|
SColumnDataAgg *pAgg = &pDataStatis[j];
|
||||||
SArray *points = taosArrayInit(2, sizeof(SFltSclPoint));
|
SArray *points = taosArrayInit(2, sizeof(SFltSclPoint));
|
||||||
fltSclBuildRangeFromBlockSma(colRange, pAgg, numOfRows, points);
|
fltSclBuildRangeFromBlockSma(colRange, pAgg, numOfRows, points);
|
||||||
qDebug("column data agg: nulls %d, rows %d, max %" PRId64 " min %" PRId64, pAgg->numOfNull, numOfRows,
|
qDebug("column data agg: nulls %d, rows %d, max %" PRId64 " min %" PRId64, pAgg->numOfNull, numOfRows,
|
||||||
|
@ -3833,7 +3833,7 @@ bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg **pDataStatis, int32_t
|
||||||
int32_t index = -1;
|
int32_t index = -1;
|
||||||
SFilterRangeCtx *ctx = info->colRange[k];
|
SFilterRangeCtx *ctx = info->colRange[k];
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
if (pDataStatis[i] != NULL && pDataStatis[i]->colId == ctx->colId) {
|
if (pDataStatis[i].colId == ctx->colId) {
|
||||||
index = i;
|
index = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3849,13 +3849,13 @@ bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg **pDataStatis, int32_t
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDataStatis[index]->numOfNull <= 0) {
|
if (pDataStatis[index].numOfNull <= 0) {
|
||||||
if (ctx->isnull && !ctx->notnull && !ctx->isrange) {
|
if (ctx->isnull && !ctx->notnull && !ctx->isrange) {
|
||||||
ret = false;
|
ret = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (pDataStatis[index]->numOfNull > 0) {
|
} else if (pDataStatis[index].numOfNull > 0) {
|
||||||
if (pDataStatis[index]->numOfNull == numOfRows) {
|
if (pDataStatis[index].numOfNull == numOfRows) {
|
||||||
if ((ctx->notnull || ctx->isrange) && (!ctx->isnull)) {
|
if ((ctx->notnull || ctx->isrange) && (!ctx->isnull)) {
|
||||||
ret = false;
|
ret = false;
|
||||||
break;
|
break;
|
||||||
|
@ -3869,7 +3869,7 @@ bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg **pDataStatis, int32_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SColumnDataAgg *pDataBlockst = pDataStatis[index];
|
SColumnDataAgg *pDataBlockst = &pDataStatis[index];
|
||||||
|
|
||||||
SFilterRangeNode *r = ctx->rs;
|
SFilterRangeNode *r = ctx->rs;
|
||||||
float minv = 0;
|
float minv = 0;
|
||||||
|
|
|
@ -26,20 +26,16 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CHECK_RSP_CHECK_INTERVAL 300
|
#define CHECK_RSP_CHECK_INTERVAL 300
|
||||||
#define LAUNCH_HTASK_INTERVAL 100
|
#define LAUNCH_HTASK_INTERVAL 100
|
||||||
#define WAIT_FOR_MINIMAL_INTERVAL 100.00
|
#define WAIT_FOR_MINIMAL_INTERVAL 100.00
|
||||||
#define MAX_RETRY_LAUNCH_HISTORY_TASK 40
|
#define MAX_RETRY_LAUNCH_HISTORY_TASK 40
|
||||||
#define RETRY_LAUNCH_INTERVAL_INC_RATE 1.2
|
#define RETRY_LAUNCH_INTERVAL_INC_RATE 1.2
|
||||||
|
#define MAX_BLOCK_NAME_NUM 1024
|
||||||
#define MAX_BLOCK_NAME_NUM 1024
|
#define DISPATCH_RETRY_INTERVAL_MS 300
|
||||||
#define DISPATCH_RETRY_INTERVAL_MS 300
|
#define META_HB_CHECK_INTERVAL 200
|
||||||
#define MAX_CONTINUE_RETRY_COUNT 5
|
#define META_HB_SEND_IDLE_COUNTER 25 // send hb every 5 sec
|
||||||
|
#define STREAM_TASK_KEY_LEN ((sizeof(int64_t)) << 1)
|
||||||
#define META_HB_CHECK_INTERVAL 200
|
|
||||||
#define META_HB_SEND_IDLE_COUNTER 25 // send hb every 5 sec
|
|
||||||
#define STREAM_TASK_KEY_LEN ((sizeof(int64_t)) << 1)
|
|
||||||
|
|
||||||
#define STREAM_TASK_QUEUE_CAPACITY 20480
|
#define STREAM_TASK_QUEUE_CAPACITY 20480
|
||||||
#define STREAM_TASK_QUEUE_CAPACITY_IN_SIZE (30)
|
#define STREAM_TASK_QUEUE_CAPACITY_IN_SIZE (30)
|
||||||
|
|
||||||
|
@ -118,6 +114,14 @@ typedef struct {
|
||||||
int32_t taskId;
|
int32_t taskId;
|
||||||
} STaskTriggerSendInfo;
|
} STaskTriggerSendInfo;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t nodeId;
|
||||||
|
int32_t status;
|
||||||
|
int64_t sendTs;
|
||||||
|
int64_t rspTs;
|
||||||
|
int32_t retryCount;
|
||||||
|
} SDispatchEntry;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t streamId;
|
int64_t streamId;
|
||||||
int64_t recvTs;
|
int64_t recvTs;
|
||||||
|
@ -143,6 +147,12 @@ typedef enum {
|
||||||
EXEC_AFTER_IDLE = 0x1,
|
EXEC_AFTER_IDLE = 0x1,
|
||||||
} EExtractDataCode;
|
} EExtractDataCode;
|
||||||
|
|
||||||
|
typedef enum ECHECKPOINT_BACKUP_TYPE {
|
||||||
|
DATA_UPLOAD_DISABLE = -1,
|
||||||
|
DATA_UPLOAD_S3 = 0,
|
||||||
|
DATA_UPLOAD_RSYNC = 1,
|
||||||
|
} ECHECKPOINT_BACKUP_TYPE;
|
||||||
|
|
||||||
extern void* streamTimer;
|
extern void* streamTimer;
|
||||||
extern int32_t streamBackendId;
|
extern int32_t streamBackendId;
|
||||||
extern int32_t streamBackendCfWrapperId;
|
extern int32_t streamBackendCfWrapperId;
|
||||||
|
@ -153,10 +163,9 @@ void streamTimerCleanUp();
|
||||||
|
|
||||||
void initRpcMsg(SRpcMsg* pMsg, int32_t msgType, void* pCont, int32_t contLen);
|
void initRpcMsg(SRpcMsg* pMsg, int32_t msgType, void* pCont, int32_t contLen);
|
||||||
|
|
||||||
void streamRetryDispatchData(SStreamTask* pTask, int64_t waitDuration);
|
void streamStartMonitorDispatchData(SStreamTask* pTask, int64_t waitDuration);
|
||||||
int32_t streamDispatchStreamBlock(SStreamTask* pTask);
|
int32_t streamDispatchStreamBlock(SStreamTask* pTask);
|
||||||
void destroyDispatchMsg(SStreamDispatchReq* pReq, int32_t numOfVgroups);
|
void destroyDispatchMsg(SStreamDispatchReq* pReq, int32_t numOfVgroups);
|
||||||
int32_t getNumOfDispatchBranch(SStreamTask* pTask);
|
|
||||||
void clearBufferedDispatchMsg(SStreamTask* pTask);
|
void clearBufferedDispatchMsg(SStreamTask* pTask);
|
||||||
|
|
||||||
int32_t streamProcessCheckpointTriggerBlock(SStreamTask* pTask, SStreamDataBlock* pBlock);
|
int32_t streamProcessCheckpointTriggerBlock(SStreamTask* pTask, SStreamDataBlock* pBlock);
|
||||||
|
@ -165,7 +174,7 @@ SStreamDataBlock* createStreamBlockFromResults(SStreamQueueItem* pItem, SStreamT
|
||||||
SArray* pRes);
|
SArray* pRes);
|
||||||
void destroyStreamDataBlock(SStreamDataBlock* pBlock);
|
void destroyStreamDataBlock(SStreamDataBlock* pBlock);
|
||||||
|
|
||||||
int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock* pData);
|
int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock* pData, const char* idstr);
|
||||||
int32_t streamBroadcastToUpTasks(SStreamTask* pTask, const SSDataBlock* pBlock);
|
int32_t streamBroadcastToUpTasks(SStreamTask* pTask, const SSDataBlock* pBlock);
|
||||||
|
|
||||||
int32_t streamSendCheckMsg(SStreamTask* pTask, const SStreamTaskCheckReq* pReq, int32_t nodeId, SEpSet* pEpSet);
|
int32_t streamSendCheckMsg(SStreamTask* pTask, const SStreamTaskCheckReq* pReq, int32_t nodeId, SEpSet* pEpSet);
|
||||||
|
@ -204,12 +213,6 @@ int32_t streamQueueGetItemSize(const SStreamQueue* pQueue);
|
||||||
|
|
||||||
void streamMetaRemoveDB(void* arg, char* key);
|
void streamMetaRemoveDB(void* arg, char* key);
|
||||||
|
|
||||||
typedef enum ECHECKPOINT_BACKUP_TYPE {
|
|
||||||
DATA_UPLOAD_DISABLE = -1,
|
|
||||||
DATA_UPLOAD_S3 = 0,
|
|
||||||
DATA_UPLOAD_RSYNC = 1,
|
|
||||||
} ECHECKPOINT_BACKUP_TYPE;
|
|
||||||
|
|
||||||
ECHECKPOINT_BACKUP_TYPE streamGetCheckpointBackupType();
|
ECHECKPOINT_BACKUP_TYPE streamGetCheckpointBackupType();
|
||||||
|
|
||||||
int32_t streamTaskDownloadCheckpointData(const char* id, char* path);
|
int32_t streamTaskDownloadCheckpointData(const char* id, char* path);
|
||||||
|
|
|
@ -509,7 +509,7 @@ void doSendCheckMsg(SStreamTask* pTask, SDownstreamStatusInfo* p) {
|
||||||
STaskOutputInfo* pOutputInfo = &pTask->outputInfo;
|
STaskOutputInfo* pOutputInfo = &pTask->outputInfo;
|
||||||
if (pOutputInfo->type == TASK_OUTPUT__FIXED_DISPATCH) {
|
if (pOutputInfo->type == TASK_OUTPUT__FIXED_DISPATCH) {
|
||||||
STaskDispatcherFixed* pDispatch = &pOutputInfo->fixedDispatcher;
|
STaskDispatcherFixed* pDispatch = &pOutputInfo->fixedDispatcher;
|
||||||
setCheckDownstreamReqInfo(&req, p->reqId, pDispatch->taskId, pDispatch->taskId);
|
setCheckDownstreamReqInfo(&req, p->reqId, pDispatch->taskId, pDispatch->nodeId);
|
||||||
|
|
||||||
stDebug("s-task:%s (vgId:%d) stage:%" PRId64 " re-send check downstream task:0x%x(vgId:%d) reqId:0x%" PRIx64,
|
stDebug("s-task:%s (vgId:%d) stage:%" PRId64 " re-send check downstream task:0x%x(vgId:%d) reqId:0x%" PRIx64,
|
||||||
id, pTask->info.nodeId, req.stage, req.downstreamTaskId, req.downstreamNodeId, req.reqId);
|
id, pTask->info.nodeId, req.stage, req.downstreamTaskId, req.downstreamNodeId, req.reqId);
|
||||||
|
|
|
@ -40,26 +40,8 @@ static void checkpointTriggerMonitorFn(void* param, void* tmrId);
|
||||||
|
|
||||||
static SStreamDataBlock* createChkptTriggerBlock(SStreamTask* pTask, int32_t checkpointType, int64_t checkpointId, int32_t transId);
|
static SStreamDataBlock* createChkptTriggerBlock(SStreamTask* pTask, int32_t checkpointType, int64_t checkpointId, int32_t transId);
|
||||||
|
|
||||||
bool streamTaskIsAllUpstreamSendTrigger(SStreamTask* pTask) {
|
|
||||||
SActiveCheckpointInfo* pActiveInfo = pTask->chkInfo.pActiveInfo;
|
|
||||||
int32_t numOfUpstreams = taosArrayGetSize(pTask->upstreamInfo.pList);
|
|
||||||
bool allSend = true;
|
|
||||||
|
|
||||||
taosThreadMutexLock(&pActiveInfo->lock);
|
|
||||||
int32_t numOfRecv = taosArrayGetSize(pActiveInfo->pReadyMsgList);
|
|
||||||
|
|
||||||
if (numOfRecv < numOfUpstreams) {
|
|
||||||
stDebug("s-task:%s received checkpoint-trigger block, idx:%d, %d upstream tasks not send yet, total:%d",
|
|
||||||
pTask->id.idStr, pTask->info.selfChildId, (numOfUpstreams - numOfRecv), numOfUpstreams);
|
|
||||||
allSend = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosThreadMutexUnlock(&pActiveInfo->lock);
|
|
||||||
return allSend;
|
|
||||||
}
|
|
||||||
|
|
||||||
SStreamDataBlock* createChkptTriggerBlock(SStreamTask* pTask, int32_t checkpointType, int64_t checkpointId,
|
SStreamDataBlock* createChkptTriggerBlock(SStreamTask* pTask, int32_t checkpointType, int64_t checkpointId,
|
||||||
int32_t transId) {
|
int32_t transId) {
|
||||||
SStreamDataBlock* pChkpoint = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, sizeof(SSDataBlock));
|
SStreamDataBlock* pChkpoint = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, sizeof(SSDataBlock));
|
||||||
if (pChkpoint == NULL) {
|
if (pChkpoint == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -441,8 +423,10 @@ int32_t streamTaskUpdateTaskCheckpointInfo(SStreamTask* pTask, SVUpdateCheckpoin
|
||||||
|
|
||||||
if (pReq->checkpointId <= pInfo->checkpointId) {
|
if (pReq->checkpointId <= pInfo->checkpointId) {
|
||||||
stDebug("s-task:%s vgId:%d latest checkpointId:%" PRId64 " checkpointVer:%" PRId64
|
stDebug("s-task:%s vgId:%d latest checkpointId:%" PRId64 " checkpointVer:%" PRId64
|
||||||
" no need to update the checkpoint info, updated checkpointId:%" PRId64 " checkpointVer:%" PRId64 " ignored",
|
" no need to update the checkpoint info, updated checkpointId:%" PRId64 " checkpointVer:%" PRId64
|
||||||
id, vgId, pInfo->checkpointId, pInfo->checkpointVer, pReq->checkpointId, pReq->checkpointVer);
|
" transId:%d ignored",
|
||||||
|
id, vgId, pInfo->checkpointId, pInfo->checkpointVer, pReq->checkpointId, pReq->checkpointVer,
|
||||||
|
pReq->transId);
|
||||||
taosThreadMutexUnlock(&pTask->lock);
|
taosThreadMutexUnlock(&pTask->lock);
|
||||||
|
|
||||||
{ // destroy the related fill-history tasks
|
{ // destroy the related fill-history tasks
|
||||||
|
@ -454,7 +438,6 @@ int32_t streamTaskUpdateTaskCheckpointInfo(SStreamTask* pTask, SVUpdateCheckpoin
|
||||||
stDebug("s-task:%s vgId:%d related fill-history task:0x%x dropped in update checkpointInfo, remain tasks:%d",
|
stDebug("s-task:%s vgId:%d related fill-history task:0x%x dropped in update checkpointInfo, remain tasks:%d",
|
||||||
id, vgId, pReq->taskId, numOfTasks);
|
id, vgId, pReq->taskId, numOfTasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
streamMetaWLock(pMeta);
|
streamMetaWLock(pMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,7 +499,8 @@ int32_t streamTaskUpdateTaskCheckpointInfo(SStreamTask* pTask, SVUpdateCheckpoin
|
||||||
if (pReq->dropRelHTask) {
|
if (pReq->dropRelHTask) {
|
||||||
streamMetaUnregisterTask(pMeta, pReq->hStreamId, pReq->hTaskId);
|
streamMetaUnregisterTask(pMeta, pReq->hStreamId, pReq->hTaskId);
|
||||||
int32_t numOfTasks = streamMetaGetNumOfTasks(pMeta);
|
int32_t numOfTasks = streamMetaGetNumOfTasks(pMeta);
|
||||||
stDebug("s-task:%s vgId:%d related fill-history task:0x%x dropped, remain tasks:%d", id, vgId, (int32_t) pReq->hTaskId, numOfTasks);
|
stDebug("s-task:%s vgId:%d related fill-history task:0x%x dropped, remain tasks:%d", id, vgId,
|
||||||
|
(int32_t)pReq->hTaskId, numOfTasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
streamMetaWLock(pMeta);
|
streamMetaWLock(pMeta);
|
||||||
|
@ -703,9 +687,7 @@ int32_t streamTaskBuildCheckpoint(SStreamTask* pTask) {
|
||||||
|
|
||||||
// update the latest checkpoint info if all works are done successfully, for rsma, the pMsgCb is null.
|
// update the latest checkpoint info if all works are done successfully, for rsma, the pMsgCb is null.
|
||||||
if (code == TSDB_CODE_SUCCESS && (pTask->pMsgCb != NULL)) {
|
if (code == TSDB_CODE_SUCCESS && (pTask->pMsgCb != NULL)) {
|
||||||
STaskId* pHTaskId = &pTask->hTaskInfo.id;
|
code = streamSendChkptReportMsg(pTask, &pTask->chkInfo, dropRelHTask);
|
||||||
code = streamBuildAndSendCheckpointUpdateMsg(pTask->pMsgCb, pMeta->vgId, &pTask->id, pHTaskId, &pTask->chkInfo,
|
|
||||||
dropRelHTask);
|
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
code = streamTaskRemoteBackupCheckpoint(pTask, ckId, (char*)id);
|
code = streamTaskRemoteBackupCheckpoint(pTask, ckId, (char*)id);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -770,6 +752,18 @@ void checkpointTriggerMonitorFn(void* param, void* tmrId) {
|
||||||
streamMetaReleaseTask(pTask->pMeta, pTask);
|
streamMetaReleaseTask(pTask->pMeta, pTask);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// checkpoint-trigger recv flag is set, quit
|
||||||
|
if (pActiveInfo->allUpstreamTriggerRecv) {
|
||||||
|
int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1);
|
||||||
|
stDebug("s-task:%s vgId:%d all checkpoint-trigger recv, quit from monitor checkpoint-trigger, ref:%d",
|
||||||
|
pTask->id.idStr, vgId, ref);
|
||||||
|
|
||||||
|
taosThreadMutexUnlock(&pTask->lock);
|
||||||
|
streamMetaReleaseTask(pTask->pMeta, pTask);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
taosThreadMutexUnlock(&pTask->lock);
|
taosThreadMutexUnlock(&pTask->lock);
|
||||||
|
|
||||||
taosThreadMutexLock(&pActiveInfo->lock);
|
taosThreadMutexLock(&pActiveInfo->lock);
|
||||||
|
|
|
@ -104,10 +104,12 @@ void destroyStreamDataBlock(SStreamDataBlock* pBlock) {
|
||||||
taosFreeQitem(pBlock);
|
taosFreeQitem(pBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock* pData) {
|
int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock* pData, const char* id) {
|
||||||
SArray* pArray = taosArrayInit(1, sizeof(SSDataBlock));
|
SArray* pArray = taosArrayInit(1, sizeof(SSDataBlock));
|
||||||
if (pArray == NULL) {
|
if (pArray == NULL) {
|
||||||
return -1;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
stError("failed to prepare retrieve block, %s", id);
|
||||||
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayPush(pArray, &(SSDataBlock){0});
|
taosArrayPush(pArray, &(SSDataBlock){0});
|
||||||
|
@ -126,7 +128,7 @@ int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock
|
||||||
pData->reqId = pReq->reqId;
|
pData->reqId = pReq->reqId;
|
||||||
pData->blocks = pArray;
|
pData->blocks = pArray;
|
||||||
|
|
||||||
return 0;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SStreamDataSubmit* streamDataSubmitNew(SPackedData* pData, int32_t type) {
|
SStreamDataSubmit* streamDataSubmitNew(SPackedData* pData, int32_t type) {
|
||||||
|
|
|
@ -23,13 +23,16 @@ typedef struct SBlockName {
|
||||||
char parTbName[TSDB_TABLE_NAME_LEN];
|
char parTbName[TSDB_TABLE_NAME_LEN];
|
||||||
} SBlockName;
|
} SBlockName;
|
||||||
|
|
||||||
static void doRetryDispatchData(void* param, void* tmrId);
|
static void doMonitorDispatchData(void* param, void* tmrId);
|
||||||
static int32_t doSendDispatchMsg(SStreamTask* pTask, const SStreamDispatchReq* pReq, int32_t vgId, SEpSet* pEpSet);
|
static int32_t doSendDispatchMsg(SStreamTask* pTask, const SStreamDispatchReq* pReq, int32_t vgId, SEpSet* pEpSet);
|
||||||
static int32_t streamAddBlockIntoDispatchMsg(const SSDataBlock* pBlock, SStreamDispatchReq* pReq);
|
static int32_t streamAddBlockIntoDispatchMsg(const SSDataBlock* pBlock, SStreamDispatchReq* pReq);
|
||||||
static int32_t streamSearchAndAddBlock(SStreamTask* pTask, SStreamDispatchReq* pReqs, SSDataBlock* pDataBlock,
|
static int32_t streamSearchAndAddBlock(SStreamTask* pTask, SStreamDispatchReq* pReqs, SSDataBlock* pDataBlock,
|
||||||
int32_t vgSz, int64_t groupId);
|
int64_t groupId, int64_t now);
|
||||||
static int32_t tInitStreamDispatchReq(SStreamDispatchReq* pReq, const SStreamTask* pTask, int32_t vgId,
|
static int32_t tInitStreamDispatchReq(SStreamDispatchReq* pReq, const SStreamTask* pTask, int32_t vgId,
|
||||||
int32_t numOfBlocks, int64_t dstTaskId, int32_t type);
|
int32_t numOfBlocks, int64_t dstTaskId, int32_t type);
|
||||||
|
static int32_t getFailedDispatchInfo(SDispatchMsgInfo* pMsgInfo, int64_t now);
|
||||||
|
static bool isDispatchRspTimeout(SDispatchEntry* pEntry, int64_t now);
|
||||||
|
static void addDispatchEntry(SDispatchMsgInfo* pMsgInfo, int32_t nodeId, int64_t now, bool lock);
|
||||||
|
|
||||||
void initRpcMsg(SRpcMsg* pMsg, int32_t msgType, void* pCont, int32_t contLen) {
|
void initRpcMsg(SRpcMsg* pMsg, int32_t msgType, void* pCont, int32_t contLen) {
|
||||||
pMsg->msgType = msgType;
|
pMsg->msgType = msgType;
|
||||||
|
@ -42,7 +45,7 @@ static int32_t tInitStreamDispatchReq(SStreamDispatchReq* pReq, const SStreamTas
|
||||||
pReq->streamId = pTask->id.streamId;
|
pReq->streamId = pTask->id.streamId;
|
||||||
pReq->srcVgId = vgId;
|
pReq->srcVgId = vgId;
|
||||||
pReq->stage = pTask->pMeta->stage;
|
pReq->stage = pTask->pMeta->stage;
|
||||||
pReq->msgId = pTask->execInfo.dispatch;
|
pReq->msgId = pTask->msgInfo.msgId;
|
||||||
pReq->upstreamTaskId = pTask->id.taskId;
|
pReq->upstreamTaskId = pTask->id.taskId;
|
||||||
pReq->upstreamChildId = pTask->info.selfChildId;
|
pReq->upstreamChildId = pTask->info.selfChildId;
|
||||||
pReq->upstreamNodeId = pTask->info.nodeId;
|
pReq->upstreamNodeId = pTask->info.nodeId;
|
||||||
|
@ -65,6 +68,7 @@ static int32_t tInitStreamDispatchReq(SStreamDispatchReq* pReq, const SStreamTas
|
||||||
void streamTaskSendRetrieveRsp(SStreamRetrieveReq *pReq, SRpcMsg* pRsp){
|
void streamTaskSendRetrieveRsp(SStreamRetrieveReq *pReq, SRpcMsg* pRsp){
|
||||||
void* buf = rpcMallocCont(sizeof(SMsgHead) + sizeof(SStreamRetrieveRsp));
|
void* buf = rpcMallocCont(sizeof(SMsgHead) + sizeof(SStreamRetrieveRsp));
|
||||||
((SMsgHead*)buf)->vgId = htonl(pReq->srcNodeId);
|
((SMsgHead*)buf)->vgId = htonl(pReq->srcNodeId);
|
||||||
|
|
||||||
SStreamRetrieveRsp* pCont = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
SStreamRetrieveRsp* pCont = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
||||||
pCont->streamId = pReq->streamId;
|
pCont->streamId = pReq->streamId;
|
||||||
pCont->rspToTaskId = pReq->srcTaskId;
|
pCont->rspToTaskId = pReq->srcTaskId;
|
||||||
|
@ -216,26 +220,66 @@ void destroyDispatchMsg(SStreamDispatchReq* pReq, int32_t numOfVgroups) {
|
||||||
taosMemoryFree(pReq);
|
taosMemoryFree(pReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t getNumOfDispatchBranch(SStreamTask* pTask) {
|
|
||||||
return (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH)
|
|
||||||
? 1
|
|
||||||
: taosArrayGetSize(pTask->outputInfo.shuffleDispatcher.dbInfo.pVgroupInfos);
|
|
||||||
}
|
|
||||||
|
|
||||||
void clearBufferedDispatchMsg(SStreamTask* pTask) {
|
void clearBufferedDispatchMsg(SStreamTask* pTask) {
|
||||||
SDispatchMsgInfo* pMsgInfo = &pTask->msgInfo;
|
SDispatchMsgInfo* pMsgInfo = &pTask->msgInfo;
|
||||||
if (pMsgInfo->pData != NULL) {
|
if (pMsgInfo->pData != NULL) {
|
||||||
destroyDispatchMsg(pMsgInfo->pData, getNumOfDispatchBranch(pTask));
|
destroyDispatchMsg(pMsgInfo->pData, streamTaskGetNumOfDownstream(pTask));
|
||||||
}
|
}
|
||||||
|
|
||||||
pMsgInfo->checkpointId = -1;
|
pMsgInfo->checkpointId = -1;
|
||||||
pMsgInfo->transId = -1;
|
pMsgInfo->transId = -1;
|
||||||
pMsgInfo->pData = NULL;
|
pMsgInfo->pData = NULL;
|
||||||
pMsgInfo->dispatchMsgType = 0;
|
pMsgInfo->dispatchMsgType = 0;
|
||||||
|
|
||||||
|
taosThreadMutexLock(&pMsgInfo->lock);
|
||||||
|
taosArrayClear(pTask->msgInfo.pSendInfo);
|
||||||
|
taosThreadMutexUnlock(&pMsgInfo->lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SStreamDispatchReq* createDispatchDataReq(SStreamTask* pTask, const SStreamDataBlock* pData) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t type = pTask->outputInfo.type;
|
||||||
|
int32_t num = streamTaskGetNumOfDownstream(pTask);
|
||||||
|
|
||||||
|
ASSERT(type == TASK_OUTPUT__SHUFFLE_DISPATCH || type == TASK_OUTPUT__FIXED_DISPATCH);
|
||||||
|
|
||||||
|
SStreamDispatchReq* pReqs = taosMemoryCalloc(num, sizeof(SStreamDispatchReq));
|
||||||
|
if (pReqs == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
|
||||||
|
SArray* vgInfo = pTask->outputInfo.shuffleDispatcher.dbInfo.pVgroupInfos;
|
||||||
|
int32_t numOfVgroups = taosArrayGetSize(vgInfo);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfVgroups; i++) {
|
||||||
|
SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, i);
|
||||||
|
code = tInitStreamDispatchReq(&pReqs[i], pTask, pData->srcVgId, 0, pVgInfo->taskId, pData->type);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
destroyDispatchMsg(pReqs, numOfVgroups);
|
||||||
|
terrno = code;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int32_t numOfBlocks = taosArrayGetSize(pData->blocks);
|
||||||
|
int32_t downstreamTaskId = pTask->outputInfo.fixedDispatcher.taskId;
|
||||||
|
|
||||||
|
code = tInitStreamDispatchReq(pReqs, pTask, pData->srcVgId, numOfBlocks, downstreamTaskId, pData->type);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
taosMemoryFree(pReqs);
|
||||||
|
terrno = code;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pReqs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doBuildDispatchMsg(SStreamTask* pTask, const SStreamDataBlock* pData) {
|
static int32_t doBuildDispatchMsg(SStreamTask* pTask, const SStreamDataBlock* pData) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
int64_t now = taosGetTimestampMs();
|
||||||
int32_t numOfBlocks = taosArrayGetSize(pData->blocks);
|
int32_t numOfBlocks = taosArrayGetSize(pData->blocks);
|
||||||
ASSERT(numOfBlocks != 0 && pTask->msgInfo.pData == NULL);
|
ASSERT(numOfBlocks != 0 && pTask->msgInfo.pData == NULL);
|
||||||
|
|
||||||
|
@ -247,48 +291,29 @@ static int32_t doBuildDispatchMsg(SStreamTask* pTask, const SStreamDataBlock* pD
|
||||||
pTask->msgInfo.transId = p->info.window.ekey;
|
pTask->msgInfo.transId = p->info.window.ekey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SStreamDispatchReq* pReqs = createDispatchDataReq(pTask, pData);
|
||||||
|
if (pReqs == NULL) {
|
||||||
|
stError("s-task:%s failed to create dispatch req", pTask->id.idStr);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) {
|
if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) {
|
||||||
SStreamDispatchReq* pReq = taosMemoryCalloc(1, sizeof(SStreamDispatchReq));
|
|
||||||
|
|
||||||
int32_t downstreamTaskId = pTask->outputInfo.fixedDispatcher.taskId;
|
|
||||||
code = tInitStreamDispatchReq(pReq, pTask, pData->srcVgId, numOfBlocks, downstreamTaskId, pData->type);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
taosMemoryFree(pReq);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfBlocks; i++) {
|
for (int32_t i = 0; i < numOfBlocks; i++) {
|
||||||
SSDataBlock* pDataBlock = taosArrayGet(pData->blocks, i);
|
SSDataBlock* pDataBlock = taosArrayGet(pData->blocks, i);
|
||||||
code = streamAddBlockIntoDispatchMsg(pDataBlock, pReq);
|
code = streamAddBlockIntoDispatchMsg(pDataBlock, pReqs);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
destroyDispatchMsg(pReq, 1);
|
destroyDispatchMsg(pReqs, 1);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pTask->msgInfo.pData = pReq;
|
addDispatchEntry(&pTask->msgInfo, pTask->outputInfo.fixedDispatcher.nodeId, now, true);
|
||||||
|
pTask->msgInfo.pData = pReqs;
|
||||||
} else if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
|
} else if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
|
||||||
int32_t rspCnt = atomic_load_32(&pTask->outputInfo.shuffleDispatcher.waitingRspCnt);
|
|
||||||
ASSERT(rspCnt == 0);
|
|
||||||
|
|
||||||
SArray* vgInfo = pTask->outputInfo.shuffleDispatcher.dbInfo.pVgroupInfos;
|
SArray* vgInfo = pTask->outputInfo.shuffleDispatcher.dbInfo.pVgroupInfos;
|
||||||
int32_t numOfVgroups = taosArrayGetSize(vgInfo);
|
int32_t numOfVgroups = taosArrayGetSize(vgInfo);
|
||||||
|
|
||||||
SStreamDispatchReq* pReqs = taosMemoryCalloc(numOfVgroups, sizeof(SStreamDispatchReq));
|
|
||||||
if (pReqs == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfVgroups; i++) {
|
|
||||||
SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, i);
|
|
||||||
code = tInitStreamDispatchReq(&pReqs[i], pTask, pData->srcVgId, 0, pVgInfo->taskId, pData->type);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
destroyDispatchMsg(pReqs, numOfVgroups);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfBlocks; i++) {
|
for (int32_t i = 0; i < numOfBlocks; i++) {
|
||||||
SSDataBlock* pDataBlock = taosArrayGet(pData->blocks, i);
|
SSDataBlock* pDataBlock = taosArrayGet(pData->blocks, i);
|
||||||
|
|
||||||
|
@ -304,7 +329,8 @@ static int32_t doBuildDispatchMsg(SStreamTask* pTask, const SStreamDataBlock* pD
|
||||||
|
|
||||||
// it's a new vnode to receive dispatch msg, so add one
|
// it's a new vnode to receive dispatch msg, so add one
|
||||||
if (pReqs[j].blockNum == 0) {
|
if (pReqs[j].blockNum == 0) {
|
||||||
atomic_add_fetch_32(&pTask->outputInfo.shuffleDispatcher.waitingRspCnt, 1);
|
SVgroupInfo* pDstVgroupInfo = taosArrayGet(vgInfo, j);
|
||||||
|
addDispatchEntry(&pTask->msgInfo, pDstVgroupInfo->vgId, now, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
pReqs[j].blockNum++;
|
pReqs[j].blockNum++;
|
||||||
|
@ -313,7 +339,7 @@ static int32_t doBuildDispatchMsg(SStreamTask* pTask, const SStreamDataBlock* pD
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = streamSearchAndAddBlock(pTask, pReqs, pDataBlock, numOfVgroups, pDataBlock->info.id.groupId);
|
code = streamSearchAndAddBlock(pTask, pReqs, pDataBlock, pDataBlock->info.id.groupId, now);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
destroyDispatchMsg(pReqs, numOfVgroups);
|
destroyDispatchMsg(pReqs, numOfVgroups);
|
||||||
return code;
|
return code;
|
||||||
|
@ -327,9 +353,9 @@ static int32_t doBuildDispatchMsg(SStreamTask* pTask, const SStreamDataBlock* pD
|
||||||
stDebug("s-task:%s build dispatch msg success, msgId:%d, stage:%" PRId64 " %p", pTask->id.idStr,
|
stDebug("s-task:%s build dispatch msg success, msgId:%d, stage:%" PRId64 " %p", pTask->id.idStr,
|
||||||
pTask->execInfo.dispatch, pTask->pMeta->stage, pTask->msgInfo.pData);
|
pTask->execInfo.dispatch, pTask->pMeta->stage, pTask->msgInfo.pData);
|
||||||
} else {
|
} else {
|
||||||
|
int32_t numOfBranches = taosArrayGetSize(pTask->msgInfo.pSendInfo);
|
||||||
stDebug("s-task:%s build dispatch msg success, msgId:%d, stage:%" PRId64 " dstVgNum:%d %p", pTask->id.idStr,
|
stDebug("s-task:%s build dispatch msg success, msgId:%d, stage:%" PRId64 " dstVgNum:%d %p", pTask->id.idStr,
|
||||||
pTask->execInfo.dispatch, pTask->pMeta->stage, pTask->outputInfo.shuffleDispatcher.waitingRspCnt,
|
pTask->execInfo.dispatch, pTask->pMeta->stage, numOfBranches, pTask->msgInfo.pData);
|
||||||
pTask->msgInfo.pData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -337,8 +363,8 @@ static int32_t doBuildDispatchMsg(SStreamTask* pTask, const SStreamDataBlock* pD
|
||||||
|
|
||||||
static int32_t sendDispatchMsg(SStreamTask* pTask, SStreamDispatchReq* pDispatchMsg) {
|
static int32_t sendDispatchMsg(SStreamTask* pTask, SStreamDispatchReq* pDispatchMsg) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t msgId = pTask->execInfo.dispatch;
|
|
||||||
const char* id = pTask->id.idStr;
|
const char* id = pTask->id.idStr;
|
||||||
|
int32_t msgId = pTask->msgInfo.msgId;
|
||||||
|
|
||||||
if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) {
|
if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) {
|
||||||
int32_t vgId = pTask->outputInfo.fixedDispatcher.nodeId;
|
int32_t vgId = pTask->outputInfo.fixedDispatcher.nodeId;
|
||||||
|
@ -352,10 +378,10 @@ static int32_t sendDispatchMsg(SStreamTask* pTask, SStreamDispatchReq* pDispatch
|
||||||
} else {
|
} else {
|
||||||
SArray* vgInfo = pTask->outputInfo.shuffleDispatcher.dbInfo.pVgroupInfos;
|
SArray* vgInfo = pTask->outputInfo.shuffleDispatcher.dbInfo.pVgroupInfos;
|
||||||
int32_t numOfVgroups = taosArrayGetSize(vgInfo);
|
int32_t numOfVgroups = taosArrayGetSize(vgInfo);
|
||||||
|
int32_t numOfBranches = taosArrayGetSize(pTask->msgInfo.pSendInfo);
|
||||||
|
|
||||||
int32_t actualVgroups = pTask->outputInfo.shuffleDispatcher.waitingRspCnt;
|
|
||||||
stDebug("s-task:%s (child taskId:%d) start to shuffle-dispatch blocks to %d/%d vgroup(s), msgId:%d", id,
|
stDebug("s-task:%s (child taskId:%d) start to shuffle-dispatch blocks to %d/%d vgroup(s), msgId:%d", id,
|
||||||
pTask->info.selfChildId, actualVgroups, numOfVgroups, msgId);
|
pTask->info.selfChildId, numOfBranches, numOfVgroups, msgId);
|
||||||
|
|
||||||
int32_t numOfSend = 0;
|
int32_t numOfSend = 0;
|
||||||
for (int32_t i = 0; i < numOfVgroups; i++) {
|
for (int32_t i = 0; i < numOfVgroups; i++) {
|
||||||
|
@ -370,7 +396,7 @@ static int32_t sendDispatchMsg(SStreamTask* pTask, SStreamDispatchReq* pDispatch
|
||||||
}
|
}
|
||||||
|
|
||||||
// no need to try remain, all already send.
|
// no need to try remain, all already send.
|
||||||
if (++numOfSend == actualVgroups) {
|
if (++numOfSend == numOfBranches) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -382,102 +408,168 @@ static int32_t sendDispatchMsg(SStreamTask* pTask, SStreamDispatchReq* pDispatch
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doRetryDispatchData(void* param, void* tmrId) {
|
static void setNotInDispatchMonitor(SDispatchMsgInfo* pMsgInfo) {
|
||||||
SStreamTask* pTask = param;
|
taosThreadMutexLock(&pMsgInfo->lock);
|
||||||
const char* id = pTask->id.idStr;
|
pMsgInfo->inMonitor = 0;
|
||||||
int32_t msgId = pTask->execInfo.dispatch;
|
taosThreadMutexUnlock(&pMsgInfo->lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setResendInfo(SDispatchEntry* pEntry, int64_t now) {
|
||||||
|
pEntry->sendTs = now;
|
||||||
|
pEntry->rspTs = -1;
|
||||||
|
pEntry->retryCount += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void addDispatchEntry(SDispatchMsgInfo* pMsgInfo, int32_t nodeId, int64_t now, bool lock) {
|
||||||
|
SDispatchEntry entry = {.nodeId = nodeId, .rspTs = -1, .status = 0, .sendTs = now};
|
||||||
|
|
||||||
|
if (lock) {
|
||||||
|
taosThreadMutexLock(&pMsgInfo->lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayPush(pMsgInfo->pSendInfo, &entry);
|
||||||
|
|
||||||
|
if (lock) {
|
||||||
|
taosThreadMutexUnlock(&pMsgInfo->lock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void doSendFailedDispatch(SStreamTask* pTask, SDispatchEntry* pEntry, int64_t now, const char* pMsg) {
|
||||||
|
SStreamDispatchReq* pReq = pTask->msgInfo.pData;
|
||||||
|
|
||||||
|
int32_t msgId = pTask->msgInfo.msgId;
|
||||||
|
SArray* vgInfo = pTask->outputInfo.shuffleDispatcher.dbInfo.pVgroupInfos;
|
||||||
|
int32_t numOfVgroups = taosArrayGetSize(vgInfo);
|
||||||
|
|
||||||
|
setResendInfo(pEntry, now);
|
||||||
|
for (int32_t j = 0; j < numOfVgroups; ++j) {
|
||||||
|
SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, j);
|
||||||
|
if (pVgInfo->vgId == pEntry->nodeId) {
|
||||||
|
int32_t code = doSendDispatchMsg(pTask, &pReq[j], pVgInfo->vgId, &pVgInfo->epSet);
|
||||||
|
stDebug("s-task:%s (child taskId:%d) shuffle-dispatch blocks:%d to vgId:%d for %s, msgId:%d, code:%s",
|
||||||
|
pTask->id.idStr, pTask->info.selfChildId, pReq[j].blockNum, pVgInfo->vgId, pMsg, msgId, tstrerror(code));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void doMonitorDispatchData(void* param, void* tmrId) {
|
||||||
|
SStreamTask* pTask = param;
|
||||||
|
const char* id = pTask->id.idStr;
|
||||||
|
int32_t vgId = pTask->pMeta->vgId;
|
||||||
|
SDispatchMsgInfo* pMsgInfo = &pTask->msgInfo;
|
||||||
|
int32_t msgId = pMsgInfo->msgId;
|
||||||
|
int32_t code = 0;
|
||||||
|
int64_t now = taosGetTimestampMs();
|
||||||
|
|
||||||
|
stDebug("s-task:%s start monitor dispatch data", id);
|
||||||
|
|
||||||
if (streamTaskShouldStop(pTask)) {
|
if (streamTaskShouldStop(pTask)) {
|
||||||
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 should stop, abort from timer, ref:%d", pTask->id.idStr, ref);
|
stDebug("s-task:%s should stop, abort from timer, ref:%d", pTask->id.idStr, ref);
|
||||||
|
setNotInDispatchMonitor(pMsgInfo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(pTask->outputq.status == TASK_OUTPUT_STATUS__WAIT);
|
// slave task not handle the dispatch, downstream not ready will break the monitor timer
|
||||||
|
// follower not handle the dispatch rsp
|
||||||
|
if ((pTask->pMeta->role == NODE_ROLE_FOLLOWER) || (pTask->status.downstreamReady != 1)) {
|
||||||
|
int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1);
|
||||||
|
stError("s-task:%s vgId:%d follower or downstream not ready, jump out of monitor tmr, ref:%d", id, vgId, ref);
|
||||||
|
setNotInDispatchMonitor(pMsgInfo);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t code = 0;
|
taosThreadMutexLock(&pMsgInfo->lock);
|
||||||
|
if (pTask->outputq.status == TASK_OUTPUT_STATUS__NORMAL) {
|
||||||
|
int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1);
|
||||||
|
stDebug("s-task:%s not in dispatch procedure, abort from timer, ref:%d", pTask->id.idStr, ref);
|
||||||
|
|
||||||
|
pTask->msgInfo.inMonitor = 0;
|
||||||
|
taosThreadMutexUnlock(&pMsgInfo->lock);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
taosThreadMutexUnlock(&pMsgInfo->lock);
|
||||||
|
|
||||||
|
int32_t numOfFailed = getFailedDispatchInfo(pMsgInfo, now);
|
||||||
|
if (numOfFailed == 0) {
|
||||||
|
stDebug("s-task:%s no error occurs, check again in %dms", id, DISPATCH_RETRY_INTERVAL_MS);
|
||||||
|
streamStartMonitorDispatchData(pTask, DISPATCH_RETRY_INTERVAL_MS);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SArray* pList = taosArrayDup(pTask->msgInfo.pRetryList, NULL);
|
|
||||||
taosArrayClear(pTask->msgInfo.pRetryList);
|
|
||||||
|
|
||||||
SStreamDispatchReq* pReq = pTask->msgInfo.pData;
|
SStreamDispatchReq* pReq = pTask->msgInfo.pData;
|
||||||
|
|
||||||
if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
|
if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
|
||||||
SArray* vgInfo = pTask->outputInfo.shuffleDispatcher.dbInfo.pVgroupInfos;
|
stDebug("s-task:%s (child taskId:%d) retry shuffle-dispatch to down streams, msgId:%d", id,
|
||||||
int32_t numOfVgroups = taosArrayGetSize(vgInfo);
|
pTask->info.selfChildId, msgId);
|
||||||
|
|
||||||
int32_t numOfFailed = taosArrayGetSize(pList);
|
int32_t numOfRetry = 0;
|
||||||
stDebug("s-task:%s (child taskId:%d) retry shuffle-dispatch blocks to %d vgroup(s), msgId:%d", id,
|
for (int32_t i = 0; i < taosArrayGetSize(pTask->msgInfo.pSendInfo); ++i) {
|
||||||
pTask->info.selfChildId, numOfFailed, msgId);
|
SDispatchEntry* pEntry = taosArrayGet(pTask->msgInfo.pSendInfo, i);
|
||||||
|
if (pEntry->status == TSDB_CODE_SUCCESS && pEntry->rspTs > 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfFailed; i++) {
|
// downstream not rsp yet beyond threshold that is 10s
|
||||||
int32_t vgId = *(int32_t*)taosArrayGet(pList, i);
|
if (isDispatchRspTimeout(pEntry, now)) { // not respond yet beyonds 30s, re-send data
|
||||||
|
doSendFailedDispatch(pTask, pEntry, now, "timeout");
|
||||||
|
numOfRetry += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t j = 0; j < numOfVgroups; ++j) {
|
// downstream inputQ is closed
|
||||||
SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, j);
|
if (pEntry->status == TASK_INPUT_STATUS__BLOCKED) {
|
||||||
if (pVgInfo->vgId == vgId) {
|
doSendFailedDispatch(pTask, pEntry, now, "downstream inputQ blocked");
|
||||||
stDebug("s-task:%s (child taskId:%d) shuffle-dispatch blocks:%d to vgId:%d", pTask->id.idStr,
|
numOfRetry += 1;
|
||||||
pTask->info.selfChildId, pReq[j].blockNum, pVgInfo->vgId);
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
code = doSendDispatchMsg(pTask, &pReq[j], pVgInfo->vgId, &pVgInfo->epSet);
|
// handle other errors
|
||||||
if (code < 0) {
|
if (pEntry->status != TSDB_CODE_SUCCESS) {
|
||||||
break;
|
doSendFailedDispatch(pTask, pEntry, now, "downstream error");
|
||||||
}
|
numOfRetry += 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stDebug("s-task:%s complete retry shuffle-dispatch blocks to all %d vnodes, msgId:%d", pTask->id.idStr,
|
stDebug("s-task:%s complete retry shuffle-dispatch blocks to all %d vnodes, msgId:%d", pTask->id.idStr,
|
||||||
numOfFailed, msgId);
|
numOfRetry, msgId);
|
||||||
} else {
|
} else {
|
||||||
int32_t vgId = pTask->outputInfo.fixedDispatcher.nodeId;
|
int32_t dstVgId = pTask->outputInfo.fixedDispatcher.nodeId;
|
||||||
SEpSet* pEpSet = &pTask->outputInfo.fixedDispatcher.epSet;
|
SEpSet* pEpSet = &pTask->outputInfo.fixedDispatcher.epSet;
|
||||||
int32_t downstreamTaskId = pTask->outputInfo.fixedDispatcher.taskId;
|
int32_t downstreamTaskId = pTask->outputInfo.fixedDispatcher.taskId;
|
||||||
|
|
||||||
stDebug("s-task:%s (child taskId:%d) fix-dispatch %d block(s) to s-task:0x%x (vgId:%d), msgId:%d", id,
|
ASSERT(taosArrayGetSize(pTask->msgInfo.pSendInfo) == 1);
|
||||||
pTask->info.selfChildId, 1, downstreamTaskId, vgId, msgId);
|
SDispatchEntry* pEntry = taosArrayGet(pTask->msgInfo.pSendInfo, 0);
|
||||||
|
|
||||||
code = doSendDispatchMsg(pTask, pReq, vgId, pEpSet);
|
setResendInfo(pEntry, now);
|
||||||
|
code = doSendDispatchMsg(pTask, pReq, dstVgId, pEpSet);
|
||||||
|
|
||||||
|
stDebug("s-task:%s (child taskId:%d) fix-dispatch %d block(s) to s-task:0x%x (vgId:%d), msgId:%d, code:%s", id,
|
||||||
|
pTask->info.selfChildId, 1, downstreamTaskId, dstVgId, msgId, tstrerror(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (streamTaskShouldStop(pTask)) {
|
||||||
if (!streamTaskShouldStop(pTask)) {
|
|
||||||
// stDebug("s-task:%s reset the waitRspCnt to be 0 before launch retry dispatch", pTask->id.idStr);
|
|
||||||
// atomic_store_32(&pTask->outputInfo.shuffleDispatcher.waitingRspCnt, 0);
|
|
||||||
if (streamTaskShouldPause(pTask)) {
|
|
||||||
streamRetryDispatchData(pTask, DISPATCH_RETRY_INTERVAL_MS * 10);
|
|
||||||
} else {
|
|
||||||
streamRetryDispatchData(pTask, DISPATCH_RETRY_INTERVAL_MS);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1);
|
|
||||||
stDebug("s-task:%s should stop, abort from timer, ref:%d", pTask->id.idStr, ref);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
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 send success, jump out of timer, ref:%d", pTask->id.idStr, ref);
|
stDebug("s-task:%s should stop, abort from timer, ref:%d", pTask->id.idStr, ref);
|
||||||
}
|
setNotInDispatchMonitor(pMsgInfo);
|
||||||
}
|
|
||||||
|
|
||||||
void streamRetryDispatchData(SStreamTask* pTask, int64_t waitDuration) {
|
|
||||||
pTask->msgInfo.retryCount++;
|
|
||||||
|
|
||||||
stTrace("s-task:%s retry send dispatch data in %" PRId64 "ms, in timer msgId:%d, retryTimes:%d", pTask->id.idStr,
|
|
||||||
waitDuration, pTask->execInfo.dispatch, pTask->msgInfo.retryCount);
|
|
||||||
|
|
||||||
if (pTask->msgInfo.pRetryTmr != NULL) {
|
|
||||||
taosTmrReset(doRetryDispatchData, waitDuration, pTask, streamTimer, &pTask->msgInfo.pRetryTmr);
|
|
||||||
} else {
|
} else {
|
||||||
pTask->msgInfo.pRetryTmr = taosTmrStart(doRetryDispatchData, waitDuration, pTask, streamTimer);
|
streamStartMonitorDispatchData(pTask, DISPATCH_RETRY_INTERVAL_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t streamSearchAndAddBlock(SStreamTask* pTask, SStreamDispatchReq* pReqs, SSDataBlock* pDataBlock, int32_t vgSz,
|
void streamStartMonitorDispatchData(SStreamTask* pTask, int64_t waitDuration) {
|
||||||
int64_t groupId) {
|
if (pTask->msgInfo.pRetryTmr != NULL) {
|
||||||
|
taosTmrReset(doMonitorDispatchData, waitDuration, pTask, streamTimer, &pTask->msgInfo.pRetryTmr);
|
||||||
|
} else {
|
||||||
|
pTask->msgInfo.pRetryTmr = taosTmrStart(doMonitorDispatchData, waitDuration, pTask, streamTimer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t streamSearchAndAddBlock(SStreamTask* pTask, SStreamDispatchReq* pReqs, SSDataBlock* pDataBlock,
|
||||||
|
int64_t groupId, int64_t now) {
|
||||||
uint32_t hashValue = 0;
|
uint32_t hashValue = 0;
|
||||||
SArray* vgInfo = pTask->outputInfo.shuffleDispatcher.dbInfo.pVgroupInfos;
|
SArray* vgInfo = pTask->outputInfo.shuffleDispatcher.dbInfo.pVgroupInfos;
|
||||||
if (pTask->pNameMap == NULL) {
|
if (pTask->pNameMap == NULL) {
|
||||||
|
@ -495,23 +587,24 @@ int32_t streamSearchAndAddBlock(SStreamTask* pTask, SStreamDispatchReq* pReqs, S
|
||||||
} else {
|
} else {
|
||||||
char ctbName[TSDB_TABLE_FNAME_LEN] = {0};
|
char ctbName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
if (pDataBlock->info.parTbName[0]) {
|
if (pDataBlock->info.parTbName[0]) {
|
||||||
if(pTask->subtableWithoutMd5 != 1 &&
|
if (pTask->subtableWithoutMd5 != 1 && !isAutoTableName(pDataBlock->info.parTbName) &&
|
||||||
!isAutoTableName(pDataBlock->info.parTbName) &&
|
!alreadyAddGroupId(pDataBlock->info.parTbName, groupId) && groupId != 0) {
|
||||||
!alreadyAddGroupId(pDataBlock->info.parTbName, groupId) &&
|
if (pTask->ver == SSTREAM_TASK_SUBTABLE_CHANGED_VER) {
|
||||||
groupId != 0){
|
|
||||||
if(pTask->ver == SSTREAM_TASK_SUBTABLE_CHANGED_VER){
|
|
||||||
buildCtbNameAddGroupId(NULL, pDataBlock->info.parTbName, groupId);
|
buildCtbNameAddGroupId(NULL, pDataBlock->info.parTbName, groupId);
|
||||||
}else if(pTask->ver > SSTREAM_TASK_SUBTABLE_CHANGED_VER) {
|
} else if (pTask->ver > SSTREAM_TASK_SUBTABLE_CHANGED_VER) {
|
||||||
buildCtbNameAddGroupId(pTask->outputInfo.shuffleDispatcher.stbFullName, pDataBlock->info.parTbName, groupId);
|
buildCtbNameAddGroupId(pTask->outputInfo.shuffleDispatcher.stbFullName, pDataBlock->info.parTbName, groupId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buildCtbNameByGroupIdImpl(pTask->outputInfo.shuffleDispatcher.stbFullName, groupId, pDataBlock->info.parTbName);
|
buildCtbNameByGroupIdImpl(pTask->outputInfo.shuffleDispatcher.stbFullName, groupId, pDataBlock->info.parTbName);
|
||||||
}
|
}
|
||||||
snprintf(ctbName, TSDB_TABLE_NAME_LEN, "%s.%s", pTask->outputInfo.shuffleDispatcher.dbInfo.db, pDataBlock->info.parTbName);
|
|
||||||
|
snprintf(ctbName, TSDB_TABLE_NAME_LEN, "%s.%s", pTask->outputInfo.shuffleDispatcher.dbInfo.db,
|
||||||
|
pDataBlock->info.parTbName);
|
||||||
/*uint32_t hashValue = MurmurHash3_32(ctbName, strlen(ctbName));*/
|
/*uint32_t hashValue = MurmurHash3_32(ctbName, strlen(ctbName));*/
|
||||||
SUseDbRsp* pDbInfo = &pTask->outputInfo.shuffleDispatcher.dbInfo;
|
SUseDbRsp* pDbInfo = &pTask->outputInfo.shuffleDispatcher.dbInfo;
|
||||||
hashValue = taosGetTbHashVal(ctbName, strlen(ctbName), pDbInfo->hashMethod, pDbInfo->hashPrefix, pDbInfo->hashSuffix);
|
hashValue =
|
||||||
|
taosGetTbHashVal(ctbName, strlen(ctbName), pDbInfo->hashMethod, pDbInfo->hashPrefix, pDbInfo->hashSuffix);
|
||||||
SBlockName bln = {0};
|
SBlockName bln = {0};
|
||||||
bln.hashValue = hashValue;
|
bln.hashValue = hashValue;
|
||||||
memcpy(bln.parTbName, pDataBlock->info.parTbName, strlen(pDataBlock->info.parTbName));
|
memcpy(bln.parTbName, pDataBlock->info.parTbName, strlen(pDataBlock->info.parTbName));
|
||||||
|
@ -520,20 +613,24 @@ int32_t streamSearchAndAddBlock(SStreamTask* pTask, SStreamDispatchReq* pReqs, S
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
int32_t numOfVgroups = taosArrayGetSize(vgInfo);
|
||||||
|
|
||||||
// TODO: optimize search
|
// TODO: optimize search
|
||||||
int32_t j;
|
taosThreadMutexLock(&pTask->msgInfo.lock);
|
||||||
for (j = 0; j < vgSz; j++) {
|
|
||||||
|
for (int32_t j = 0; j < numOfVgroups; j++) {
|
||||||
SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, j);
|
SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, j);
|
||||||
ASSERT(pVgInfo->vgId > 0);
|
|
||||||
|
|
||||||
if (hashValue >= pVgInfo->hashBegin && hashValue <= pVgInfo->hashEnd) {
|
if (hashValue >= pVgInfo->hashBegin && hashValue <= pVgInfo->hashEnd) {
|
||||||
if (streamAddBlockIntoDispatchMsg(pDataBlock, &pReqs[j]) < 0) {
|
if (streamAddBlockIntoDispatchMsg(pDataBlock, &pReqs[j]) < 0) {
|
||||||
|
taosThreadMutexUnlock(&pTask->msgInfo.lock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pReqs[j].blockNum == 0) {
|
if (pReqs[j].blockNum == 0) {
|
||||||
atomic_add_fetch_32(&pTask->outputInfo.shuffleDispatcher.waitingRspCnt, 1);
|
SVgroupInfo* pDstVgroupInfo = taosArrayGet(vgInfo, j);
|
||||||
|
addDispatchEntry(&pTask->msgInfo, pDstVgroupInfo->vgId, now, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
pReqs[j].blockNum++;
|
pReqs[j].blockNum++;
|
||||||
|
@ -541,10 +638,28 @@ int32_t streamSearchAndAddBlock(SStreamTask* pTask, SStreamDispatchReq* pReqs, S
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosThreadMutexUnlock(&pTask->msgInfo.lock);
|
||||||
ASSERT(found);
|
ASSERT(found);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void initDispatchInfo(SDispatchMsgInfo* pInfo, int32_t msgId) {
|
||||||
|
pInfo->startTs = taosGetTimestampMs();
|
||||||
|
pInfo->rspTs = -1;
|
||||||
|
pInfo->msgId = msgId;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void clearDispatchInfo(SDispatchMsgInfo* pInfo) {
|
||||||
|
pInfo->startTs = -1;
|
||||||
|
pInfo->msgId = -1;
|
||||||
|
pInfo->rspTs = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void updateDispatchInfo(SDispatchMsgInfo* pInfo, int64_t recvTs) {
|
||||||
|
pInfo->rspTs = recvTs;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t streamDispatchStreamBlock(SStreamTask* pTask) {
|
int32_t streamDispatchStreamBlock(SStreamTask* pTask) {
|
||||||
ASSERT((pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH ||
|
ASSERT((pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH ||
|
||||||
pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH));
|
pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH));
|
||||||
|
@ -587,7 +702,7 @@ int32_t streamDispatchStreamBlock(SStreamTask* pTask) {
|
||||||
type == STREAM_INPUT__TRANS_STATE);
|
type == STREAM_INPUT__TRANS_STATE);
|
||||||
|
|
||||||
pTask->execInfo.dispatch += 1;
|
pTask->execInfo.dispatch += 1;
|
||||||
pTask->msgInfo.startTs = taosGetTimestampMs();
|
initDispatchInfo(&pTask->msgInfo, pTask->execInfo.dispatch);
|
||||||
|
|
||||||
int32_t code = doBuildDispatchMsg(pTask, pBlock);
|
int32_t code = doBuildDispatchMsg(pTask, pBlock);
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
|
@ -599,34 +714,21 @@ int32_t streamDispatchStreamBlock(SStreamTask* pTask) {
|
||||||
streamTaskInitTriggerDispatchInfo(pTask);
|
streamTaskInitTriggerDispatchInfo(pTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t retryCount = 0;
|
code = sendDispatchMsg(pTask, pTask->msgInfo.pData);
|
||||||
while (1) {
|
|
||||||
code = sendDispatchMsg(pTask, pTask->msgInfo.pData);
|
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
stDebug("s-task:%s failed to dispatch msg:%d to downstream, code:%s, output status:%d, retry cnt:%d", id,
|
taosThreadMutexLock(&pTask->msgInfo.lock);
|
||||||
pTask->execInfo.dispatch, tstrerror(terrno), pTask->outputq.status, retryCount);
|
if (pTask->msgInfo.inMonitor == 0) {
|
||||||
|
int32_t ref = atomic_add_fetch_32(&pTask->status.timerActive, 1);
|
||||||
// todo deal with only partially success dispatch case
|
stDebug("s-task:%s start dispatch monitor tmr in %dms, ref:%d, dispatch code:%s", id, DISPATCH_RETRY_INTERVAL_MS, ref,
|
||||||
atomic_store_32(&pTask->outputInfo.shuffleDispatcher.waitingRspCnt, 0);
|
tstrerror(code));
|
||||||
if (terrno == TSDB_CODE_APP_IS_STOPPING) { // in case of this error, do not retry anymore
|
streamStartMonitorDispatchData(pTask, DISPATCH_RETRY_INTERVAL_MS);
|
||||||
clearBufferedDispatchMsg(pTask);
|
pTask->msgInfo.inMonitor = 1;
|
||||||
return code;
|
} else {
|
||||||
}
|
stDebug("s-task:%s already in dispatch monitor tmr", id);
|
||||||
|
|
||||||
if (++retryCount > MAX_CONTINUE_RETRY_COUNT) { // add to timer to retry
|
|
||||||
int32_t ref = atomic_add_fetch_32(&pTask->status.timerActive, 1);
|
|
||||||
stDebug(
|
|
||||||
"s-task:%s failed to dispatch msg to downstream for %d times, code:%s, add timer to retry in %dms, ref:%d",
|
|
||||||
pTask->id.idStr, retryCount, tstrerror(terrno), DISPATCH_RETRY_INTERVAL_MS, ref);
|
|
||||||
|
|
||||||
streamRetryDispatchData(pTask, DISPATCH_RETRY_INTERVAL_MS);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosThreadMutexUnlock(&pTask->msgInfo.lock);
|
||||||
|
|
||||||
// this block can not be deleted until it has been sent to downstream task successfully.
|
// this block can not be deleted until it has been sent to downstream task successfully.
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -817,8 +919,10 @@ int32_t streamAddBlockIntoDispatchMsg(const SSDataBlock* pBlock, SStreamDispatch
|
||||||
int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock) + PAYLOAD_PREFIX_LEN;
|
int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock) + PAYLOAD_PREFIX_LEN;
|
||||||
ASSERT(dataStrLen > 0);
|
ASSERT(dataStrLen > 0);
|
||||||
|
|
||||||
void* buf = taosMemoryCalloc(1, dataStrLen);
|
void* buf = taosMemoryCalloc(1, dataStrLen);
|
||||||
if (buf == NULL) return -1;
|
if (buf == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)buf;
|
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)buf;
|
||||||
pRetrieve->useconds = 0;
|
pRetrieve->useconds = 0;
|
||||||
|
@ -1031,23 +1135,6 @@ static int32_t handleDispatchSuccessRsp(SStreamTask* pTask, int32_t downstreamId
|
||||||
stDebug("s-task:%s destroy dispatch msg:%p", pTask->id.idStr, pTask->msgInfo.pData);
|
stDebug("s-task:%s destroy dispatch msg:%p", pTask->id.idStr, pTask->msgInfo.pData);
|
||||||
|
|
||||||
bool delayDispatch = (pTask->msgInfo.dispatchMsgType == STREAM_INPUT__CHECKPOINT_TRIGGER);
|
bool delayDispatch = (pTask->msgInfo.dispatchMsgType == STREAM_INPUT__CHECKPOINT_TRIGGER);
|
||||||
if (delayDispatch) {
|
|
||||||
taosThreadMutexLock(&pTask->lock);
|
|
||||||
// we only set the dispatch msg info for current checkpoint trans
|
|
||||||
if (streamTaskGetStatus(pTask)->state == TASK_STATUS__CK &&
|
|
||||||
pTask->chkInfo.pActiveInfo->activeId == pTask->msgInfo.checkpointId) {
|
|
||||||
ASSERT(pTask->chkInfo.pActiveInfo->transId == pTask->msgInfo.transId);
|
|
||||||
stDebug("s-task:%s checkpoint-trigger msg to 0x%x rsp for checkpointId:%" PRId64 " transId:%d confirmed",
|
|
||||||
pTask->id.idStr, downstreamId, pTask->msgInfo.checkpointId, pTask->msgInfo.transId);
|
|
||||||
|
|
||||||
streamTaskSetTriggerDispatchConfirmed(pTask, downstreamNodeId);
|
|
||||||
} else {
|
|
||||||
stWarn("s-task:%s checkpoint-trigger msg rsp for checkpointId:%" PRId64 " transId:%d discard, since expired",
|
|
||||||
pTask->id.idStr, pTask->msgInfo.checkpointId, pTask->msgInfo.transId);
|
|
||||||
}
|
|
||||||
taosThreadMutexUnlock(&pTask->lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
clearBufferedDispatchMsg(pTask);
|
clearBufferedDispatchMsg(pTask);
|
||||||
|
|
||||||
int64_t el = taosGetTimestampMs() - pTask->msgInfo.startTs;
|
int64_t el = taosGetTimestampMs() - pTask->msgInfo.startTs;
|
||||||
|
@ -1074,17 +1161,59 @@ static int32_t handleDispatchSuccessRsp(SStreamTask* pTask, int32_t downstreamId
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp, int32_t code) {
|
static int32_t setDispatchRspInfo(SDispatchMsgInfo* pMsgInfo, int32_t vgId, int32_t code, int64_t now, const char* id) {
|
||||||
const char* id = pTask->id.idStr;
|
int32_t numOfRsp = 0;
|
||||||
int32_t vgId = pTask->pMeta->vgId;
|
bool alreadySet = false;
|
||||||
int32_t msgId = pTask->execInfo.dispatch;
|
bool updated = false;
|
||||||
|
|
||||||
#if 0
|
taosThreadMutexLock(&pMsgInfo->lock);
|
||||||
// for test purpose, build the failure case
|
for(int32_t j = 0; j < taosArrayGetSize(pMsgInfo->pSendInfo); ++j) {
|
||||||
if (pTask->msgInfo.dispatchMsgType == STREAM_INPUT__CHECKPOINT_TRIGGER) {
|
SDispatchEntry* pEntry = taosArrayGet(pMsgInfo->pSendInfo, j);
|
||||||
pRsp->inputStatus = TASK_INPUT_STATUS__REFUSED;
|
if (pEntry->nodeId == vgId) {
|
||||||
|
ASSERT(!alreadySet);
|
||||||
|
pEntry->rspTs = now;
|
||||||
|
pEntry->status = code;
|
||||||
|
alreadySet = true;
|
||||||
|
updated = true;
|
||||||
|
stDebug("s-task:%s record the rsp recv, ts:%"PRId64" code:%d, idx:%d", id, now, code, j);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pEntry->rspTs != -1) {
|
||||||
|
numOfRsp += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
taosThreadMutexUnlock(&pMsgInfo->lock);
|
||||||
|
ASSERT(updated);
|
||||||
|
|
||||||
|
return numOfRsp;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isDispatchRspTimeout(SDispatchEntry* pEntry, int64_t now) {
|
||||||
|
return (pEntry->rspTs == -1) && (now - pEntry->sendTs) > 30 * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t getFailedDispatchInfo(SDispatchMsgInfo* pMsgInfo, int64_t now) {
|
||||||
|
int32_t numOfFailed = 0;
|
||||||
|
taosThreadMutexLock(&pMsgInfo->lock);
|
||||||
|
|
||||||
|
for (int32_t j = 0; j < taosArrayGetSize(pMsgInfo->pSendInfo); ++j) {
|
||||||
|
SDispatchEntry* pEntry = taosArrayGet(pMsgInfo->pSendInfo, j);
|
||||||
|
if (pEntry->status != TSDB_CODE_SUCCESS || isDispatchRspTimeout(pEntry, now)) {
|
||||||
|
numOfFailed += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
taosThreadMutexUnlock(&pMsgInfo->lock);
|
||||||
|
return numOfFailed;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp, int32_t code) {
|
||||||
|
const char* id = pTask->id.idStr;
|
||||||
|
int32_t vgId = pTask->pMeta->vgId;
|
||||||
|
SDispatchMsgInfo* pMsgInfo = &pTask->msgInfo;
|
||||||
|
int32_t msgId = pMsgInfo->msgId;
|
||||||
|
int64_t now = taosGetTimestampMs();
|
||||||
|
int32_t totalRsp = 0;
|
||||||
|
|
||||||
// follower not handle the dispatch rsp
|
// follower not handle the dispatch rsp
|
||||||
if ((pTask->pMeta->role == NODE_ROLE_FOLLOWER) || (pTask->status.downstreamReady != 1)) {
|
if ((pTask->pMeta->role == NODE_ROLE_FOLLOWER) || (pTask->status.downstreamReady != 1)) {
|
||||||
|
@ -1109,53 +1238,61 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp, i
|
||||||
if (code == TSDB_CODE_STREAM_TASK_NOT_EXIST) { // destination task does not exist, not retry anymore
|
if (code == TSDB_CODE_STREAM_TASK_NOT_EXIST) { // destination task does not exist, not retry anymore
|
||||||
stError("s-task:%s failed to dispatch msg to task:0x%x(vgId:%d), msgId:%d no retry, since task destroyed already",
|
stError("s-task:%s failed to dispatch msg to task:0x%x(vgId:%d), msgId:%d no retry, since task destroyed already",
|
||||||
id, pRsp->downstreamTaskId, pRsp->downstreamNodeId, msgId);
|
id, pRsp->downstreamTaskId, pRsp->downstreamNodeId, msgId);
|
||||||
|
totalRsp = setDispatchRspInfo(pMsgInfo, pRsp->downstreamNodeId, TSDB_CODE_SUCCESS, now, id);
|
||||||
} else {
|
} else {
|
||||||
stError("s-task:%s failed to dispatch msgId:%d to task:0x%x(vgId:%d), code:%s, add to retry list", id, msgId,
|
stError("s-task:%s failed to dispatch msgId:%d to task:0x%x(vgId:%d), code:%s, add to retry list", id, msgId,
|
||||||
pRsp->downstreamTaskId, pRsp->downstreamNodeId, tstrerror(code));
|
pRsp->downstreamTaskId, pRsp->downstreamNodeId, tstrerror(code));
|
||||||
taosThreadMutexLock(&pTask->lock);
|
totalRsp = setDispatchRspInfo(pMsgInfo, pRsp->downstreamNodeId, code, now, id);
|
||||||
taosArrayPush(pTask->msgInfo.pRetryList, &pRsp->downstreamNodeId);
|
|
||||||
taosThreadMutexUnlock(&pTask->lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { // code == 0
|
} else { // code == 0
|
||||||
if (pRsp->inputStatus == TASK_INPUT_STATUS__BLOCKED) {
|
if (pRsp->inputStatus == TASK_INPUT_STATUS__BLOCKED) {
|
||||||
pTask->inputq.status = TASK_INPUT_STATUS__BLOCKED;
|
pTask->inputq.status = TASK_INPUT_STATUS__BLOCKED;
|
||||||
// block the input of current task, to push pressure to upstream
|
// block the input of current task, to push pressure to upstream
|
||||||
taosThreadMutexLock(&pTask->lock);
|
totalRsp = setDispatchRspInfo(pMsgInfo, pRsp->downstreamNodeId, pRsp->inputStatus, now, id);
|
||||||
taosArrayPush(pTask->msgInfo.pRetryList, &pRsp->downstreamNodeId);
|
stTrace("s-task:%s inputQ of downstream task:0x%x(vgId:%d) is full, wait for retry dispatch", id,
|
||||||
taosThreadMutexUnlock(&pTask->lock);
|
pRsp->downstreamTaskId, pRsp->downstreamNodeId);
|
||||||
|
} else {
|
||||||
|
if (pRsp->inputStatus == TASK_INPUT_STATUS__REFUSED) {
|
||||||
|
// todo handle the role-changed during checkpoint generation, add test case
|
||||||
|
stError(
|
||||||
|
"s-task:%s downstream task:0x%x(vgId:%d) refused the dispatch msg, downstream may become follower or "
|
||||||
|
"restart already, treat it as success",
|
||||||
|
id, pRsp->downstreamTaskId, pRsp->downstreamNodeId);
|
||||||
|
}
|
||||||
|
|
||||||
stTrace("s-task:%s inputQ of downstream task:0x%x(vgId:%d) is full, wait for %dms and retry dispatch", id,
|
totalRsp = setDispatchRspInfo(pMsgInfo, pRsp->downstreamNodeId, TSDB_CODE_SUCCESS, now, id);
|
||||||
pRsp->downstreamTaskId, pRsp->downstreamNodeId, DISPATCH_RETRY_INTERVAL_MS);
|
|
||||||
} else if (pRsp->inputStatus == TASK_INPUT_STATUS__REFUSED) {
|
{
|
||||||
// todo handle the agg task failure, add test case
|
bool delayDispatch = (pMsgInfo->dispatchMsgType == STREAM_INPUT__CHECKPOINT_TRIGGER);
|
||||||
if (pTask->msgInfo.dispatchMsgType == STREAM_INPUT__CHECKPOINT_TRIGGER &&
|
if (delayDispatch) {
|
||||||
pTask->info.taskLevel == TASK_LEVEL__SOURCE) {
|
taosThreadMutexLock(&pTask->lock);
|
||||||
stError("s-task:%s failed to dispatch checkpoint-trigger msg, checkpointId:%" PRId64
|
// we only set the dispatch msg info for current checkpoint trans
|
||||||
", set the current checkpoint failed, and send rsp to mnode",
|
if (streamTaskGetStatus(pTask)->state == TASK_STATUS__CK &&
|
||||||
id, pTask->chkInfo.pActiveInfo->activeId);
|
pTask->chkInfo.pActiveInfo->activeId == pMsgInfo->checkpointId) {
|
||||||
{ // send checkpoint failure msg to mnode directly
|
ASSERT(pTask->chkInfo.pActiveInfo->transId == pMsgInfo->transId);
|
||||||
pTask->chkInfo.pActiveInfo->failedId = pTask->chkInfo.pActiveInfo->activeId; // record the latest failed checkpoint id
|
stDebug("s-task:%s checkpoint-trigger msg to 0x%x rsp for checkpointId:%" PRId64 " transId:%d confirmed",
|
||||||
pTask->chkInfo.pActiveInfo->activeId = pTask->chkInfo.pActiveInfo->activeId;
|
pTask->id.idStr, pRsp->downstreamTaskId, pMsgInfo->checkpointId, pMsgInfo->transId);
|
||||||
streamTaskSendCheckpointSourceRsp(pTask);
|
|
||||||
|
streamTaskSetTriggerDispatchConfirmed(pTask, pRsp->downstreamNodeId);
|
||||||
|
} else {
|
||||||
|
stWarn("s-task:%s checkpoint-trigger msg rsp for checkpointId:%" PRId64
|
||||||
|
" transId:%d discard, since expired",
|
||||||
|
pTask->id.idStr, pMsgInfo->checkpointId, pMsgInfo->transId);
|
||||||
|
}
|
||||||
|
taosThreadMutexUnlock(&pTask->lock);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
stError("s-task:%s downstream task:0x%x(vgId:%d) refused the dispatch msg, treat it as success", id,
|
|
||||||
pRsp->downstreamTaskId, pRsp->downstreamNodeId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t leftRsp = 0;
|
int32_t notRsp = taosArrayGetSize(pMsgInfo->pSendInfo) - totalRsp;
|
||||||
if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
|
if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
|
||||||
leftRsp = atomic_sub_fetch_32(&pTask->outputInfo.shuffleDispatcher.waitingRspCnt, 1);
|
if (notRsp > 0) {
|
||||||
ASSERT(leftRsp >= 0);
|
|
||||||
|
|
||||||
if (leftRsp > 0) {
|
|
||||||
stDebug(
|
stDebug(
|
||||||
"s-task:%s recv dispatch rsp, msgId:%d from 0x%x(vgId:%d), downstream task input status:%d code:%s, waiting "
|
"s-task:%s recv dispatch rsp, msgId:%d from 0x%x(vgId:%d), downstream task input status:%d code:%s, waiting "
|
||||||
"for %d rsp",
|
"for %d rsp",
|
||||||
id, msgId, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->inputStatus, tstrerror(code), leftRsp);
|
id, msgId, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->inputStatus, tstrerror(code), notRsp);
|
||||||
} else {
|
} else {
|
||||||
stDebug(
|
stDebug(
|
||||||
"s-task:%s recv dispatch rsp, msgId:%d from 0x%x(vgId:%d), downstream task input status:%d code:%s, all rsp",
|
"s-task:%s recv dispatch rsp, msgId:%d from 0x%x(vgId:%d), downstream task input status:%d code:%s, all rsp",
|
||||||
|
@ -1166,31 +1303,17 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp, i
|
||||||
msgId, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->inputStatus, tstrerror(code));
|
msgId, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->inputStatus, tstrerror(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(leftRsp >= 0);
|
|
||||||
|
|
||||||
// all msg rsp already, continue
|
// all msg rsp already, continue
|
||||||
if (leftRsp == 0) {
|
if (notRsp == 0) {
|
||||||
ASSERT(pTask->outputq.status == TASK_OUTPUT_STATUS__WAIT);
|
ASSERT(pTask->outputq.status == TASK_OUTPUT_STATUS__WAIT);
|
||||||
|
|
||||||
// we need to re-try send dispatch msg to downstream tasks
|
// we need to re-try send dispatch msg to downstream tasks
|
||||||
int32_t numOfFailed = taosArrayGetSize(pTask->msgInfo.pRetryList);
|
int32_t numOfFailed = getFailedDispatchInfo(pMsgInfo, now);
|
||||||
if (numOfFailed > 0) {
|
if (numOfFailed == 0) { // this message has been sent successfully, let's try next one.
|
||||||
if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
|
|
||||||
atomic_store_32(&pTask->outputInfo.shuffleDispatcher.waitingRspCnt, numOfFailed);
|
|
||||||
stDebug("s-task:%s waiting rsp set to be %d", id, pTask->outputInfo.shuffleDispatcher.waitingRspCnt);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ref = atomic_add_fetch_32(&pTask->status.timerActive, 1);
|
|
||||||
stDebug("s-task:%s failed to dispatch msg to downstream, add into timer to retry in %dms, ref:%d",
|
|
||||||
pTask->id.idStr, DISPATCH_RETRY_INTERVAL_MS, ref);
|
|
||||||
|
|
||||||
streamRetryDispatchData(pTask, DISPATCH_RETRY_INTERVAL_MS);
|
|
||||||
} else { // this message has been sent successfully, let's try next one.
|
|
||||||
pTask->msgInfo.retryCount = 0;
|
|
||||||
|
|
||||||
// trans-state msg has been sent to downstream successfully. let's transfer the fill-history task state
|
// trans-state msg has been sent to downstream successfully. let's transfer the fill-history task state
|
||||||
if (pTask->msgInfo.dispatchMsgType == STREAM_INPUT__TRANS_STATE) {
|
if (pMsgInfo->dispatchMsgType == STREAM_INPUT__TRANS_STATE) {
|
||||||
stDebug("s-task:%s dispatch trans-state msgId:%d to downstream successfully, start to prepare transfer state", id, msgId);
|
stDebug("s-task:%s dispatch trans-state msgId:%d to downstream successfully, start to prepare transfer state",
|
||||||
|
id, msgId);
|
||||||
ASSERT(pTask->info.fillHistory == 1);
|
ASSERT(pTask->info.fillHistory == 1);
|
||||||
|
|
||||||
code = streamTransferStatePrepare(pTask);
|
code = streamTransferStatePrepare(pTask);
|
||||||
|
@ -1309,7 +1432,5 @@ int32_t streamProcessDispatchMsg(SStreamTask* pTask, SStreamDispatchReq* pReq, S
|
||||||
}
|
}
|
||||||
|
|
||||||
streamTrySchedExec(pTask);
|
streamTrySchedExec(pTask);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -541,14 +541,14 @@ int32_t streamProcessTransstateBlock(SStreamTask* pTask, SStreamDataBlock* pBloc
|
||||||
//static void streamTaskSetIdleInfo(SStreamTask* pTask, int32_t idleTime) { pTask->status.schedIdleTime = idleTime; }
|
//static void streamTaskSetIdleInfo(SStreamTask* pTask, int32_t idleTime) { pTask->status.schedIdleTime = idleTime; }
|
||||||
static void setLastExecTs(SStreamTask* pTask, int64_t ts) { pTask->status.lastExecTs = ts; }
|
static void setLastExecTs(SStreamTask* pTask, int64_t ts) { pTask->status.lastExecTs = ts; }
|
||||||
|
|
||||||
static void doStreamTaskExecImpl(SStreamTask* pTask, SStreamQueueItem* pBlock) {
|
static void doStreamTaskExecImpl(SStreamTask* pTask, SStreamQueueItem* pBlock, int32_t num) {
|
||||||
const char* id = pTask->id.idStr;
|
const char* id = pTask->id.idStr;
|
||||||
int32_t blockSize = 0;
|
int32_t blockSize = 0;
|
||||||
int64_t st = taosGetTimestampMs();
|
int64_t st = taosGetTimestampMs();
|
||||||
SCheckpointInfo* pInfo = &pTask->chkInfo;
|
SCheckpointInfo* pInfo = &pTask->chkInfo;
|
||||||
int64_t ver = pInfo->processedVer;
|
int64_t ver = pInfo->processedVer;
|
||||||
|
|
||||||
stDebug("s-task:%s start to process batch of blocks, num:%d, type:%s", id, 1, "checkpoint-trigger");
|
stDebug("s-task:%s start to process batch blocks, num:%d, type:%s", id, num, streamQueueItemGetTypeStr(pBlock->type));
|
||||||
|
|
||||||
doSetStreamInputBlock(pTask, pBlock, &ver, id);
|
doSetStreamInputBlock(pTask, pBlock, &ver, id);
|
||||||
|
|
||||||
|
@ -607,7 +607,7 @@ void flushStateDataInExecutor(SStreamTask* pTask, SStreamQueueItem* pCheckpointB
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. flush data in executor to K/V store, which should be completed before do checkpoint in the K/V.
|
// 2. flush data in executor to K/V store, which should be completed before do checkpoint in the K/V.
|
||||||
doStreamTaskExecImpl(pTask, pCheckpointBlock);
|
doStreamTaskExecImpl(pTask, pCheckpointBlock, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -615,7 +615,7 @@ void flushStateDataInExecutor(SStreamTask* pTask, SStreamQueueItem* pCheckpointB
|
||||||
* appropriate batch of blocks should be handled in 5 to 10 sec.
|
* appropriate batch of blocks should be handled in 5 to 10 sec.
|
||||||
*/
|
*/
|
||||||
static int32_t doStreamExecTask(SStreamTask* pTask) {
|
static int32_t doStreamExecTask(SStreamTask* pTask) {
|
||||||
const char* id = pTask->id.idStr;
|
const char* id = pTask->id.idStr;
|
||||||
|
|
||||||
// merge multiple input data if possible in the input queue.
|
// merge multiple input data if possible in the input queue.
|
||||||
stDebug("s-task:%s start to extract data block from inputQ", id);
|
stDebug("s-task:%s start to extract data block from inputQ", id);
|
||||||
|
@ -643,7 +643,7 @@ static int32_t doStreamExecTask(SStreamTask* pTask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosGetTimestampMs() - pTask->status.lastExecTs < MIN_INVOKE_INTERVAL) {
|
if (taosGetTimestampMs() - pTask->status.lastExecTs < MIN_INVOKE_INTERVAL) {
|
||||||
stDebug("s-task:%s invoke with high frequency, idle and retry exec in 50ms", id);
|
stDebug("s-task:%s invoke exec too fast, idle and retry in 50ms", id);
|
||||||
streamTaskSetIdleInfo(pTask, MIN_INVOKE_INTERVAL);
|
streamTaskSetIdleInfo(pTask, MIN_INVOKE_INTERVAL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -698,21 +698,16 @@ static int32_t doStreamExecTask(SStreamTask* pTask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != STREAM_INPUT__CHECKPOINT) {
|
if (type != STREAM_INPUT__CHECKPOINT) {
|
||||||
doStreamTaskExecImpl(pTask, pInput);
|
doStreamTaskExecImpl(pTask, pInput, numOfBlocks);
|
||||||
}
|
streamFreeQitem(pInput);
|
||||||
|
} else { // todo other thread may change the status
|
||||||
streamFreeQitem(pInput);
|
|
||||||
|
|
||||||
// todo other thread may change the status
|
|
||||||
// do nothing after sync executor state to storage backend, untill the vnode-level checkpoint is completed.
|
// do nothing after sync executor state to storage backend, untill the vnode-level checkpoint is completed.
|
||||||
if (type == STREAM_INPUT__CHECKPOINT) {
|
taosThreadMutexLock(&pTask->lock);
|
||||||
// todo add lock
|
|
||||||
SStreamTaskState* pState = streamTaskGetStatus(pTask);
|
SStreamTaskState* pState = streamTaskGetStatus(pTask);
|
||||||
if (pState->state == TASK_STATUS__CK) {
|
if (pState->state == TASK_STATUS__CK) {
|
||||||
stDebug("s-task:%s checkpoint block received, set status:%s", id, pState->name);
|
stDebug("s-task:%s checkpoint block received, set status:%s", id, pState->name);
|
||||||
streamTaskBuildCheckpoint(pTask);
|
streamTaskBuildCheckpoint(pTask);
|
||||||
} else {
|
} else { // todo refactor
|
||||||
// todo refactor
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) {
|
if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) {
|
||||||
code = streamTaskSendCheckpointSourceRsp(pTask);
|
code = streamTaskSendCheckpointSourceRsp(pTask);
|
||||||
|
@ -727,6 +722,8 @@ static int32_t doStreamExecTask(SStreamTask* pTask) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosThreadMutexUnlock(&pTask->lock);
|
||||||
|
streamFreeQitem(pInput);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,8 +299,8 @@ void streamMetaRemoveDB(void* arg, char* key) {
|
||||||
taosThreadMutexUnlock(&pMeta->backendMutex);
|
taosThreadMutexUnlock(&pMeta->backendMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandFunc, int32_t vgId, int64_t stage,
|
SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskBuild buildTaskFn, FTaskExpand expandTaskFn,
|
||||||
startComplete_fn_t fn) {
|
int32_t vgId, int64_t stage, startComplete_fn_t fn) {
|
||||||
SStreamMeta* pMeta = taosMemoryCalloc(1, sizeof(SStreamMeta));
|
SStreamMeta* pMeta = taosMemoryCalloc(1, sizeof(SStreamMeta));
|
||||||
if (pMeta == NULL) {
|
if (pMeta == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -369,9 +369,11 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF
|
||||||
pMeta->scanInfo.scanCounter = 0;
|
pMeta->scanInfo.scanCounter = 0;
|
||||||
pMeta->vgId = vgId;
|
pMeta->vgId = vgId;
|
||||||
pMeta->ahandle = ahandle;
|
pMeta->ahandle = ahandle;
|
||||||
pMeta->expandFunc = expandFunc;
|
pMeta->buildTaskFn = buildTaskFn;
|
||||||
|
pMeta->expandTaskFn = expandTaskFn;
|
||||||
pMeta->stage = stage;
|
pMeta->stage = stage;
|
||||||
pMeta->role = (vgId == SNODE_HANDLE) ? NODE_ROLE_LEADER : NODE_ROLE_UNINIT;
|
pMeta->role = (vgId == SNODE_HANDLE) ? NODE_ROLE_LEADER : NODE_ROLE_UNINIT;
|
||||||
|
pMeta->updateInfo.transId = -1;
|
||||||
|
|
||||||
pMeta->startInfo.completeFn = fn;
|
pMeta->startInfo.completeFn = fn;
|
||||||
pMeta->pTaskDbUnique = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
pMeta->pTaskDbUnique = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
||||||
|
@ -601,11 +603,12 @@ int32_t streamMetaRegisterTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTa
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMeta->expandFunc(pMeta->ahandle, pTask, ver) < 0) {
|
if (pMeta->buildTaskFn(pMeta->ahandle, pTask, ver) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayPush(pMeta->pTaskList, &pTask->id);
|
taosArrayPush(pMeta->pTaskList, &pTask->id);
|
||||||
|
taosHashPut(pMeta->pTasksMap, &id, sizeof(id), &pTask, POINTER_BYTES);
|
||||||
|
|
||||||
if (streamMetaSaveTask(pMeta, pTask) < 0) {
|
if (streamMetaSaveTask(pMeta, pTask) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -615,7 +618,6 @@ int32_t streamMetaRegisterTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTa
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashPut(pMeta->pTasksMap, &id, sizeof(id), &pTask, POINTER_BYTES);
|
|
||||||
if (pTask->info.fillHistory == 0) {
|
if (pTask->info.fillHistory == 0) {
|
||||||
atomic_add_fetch_32(&pMeta->numOfStreamTasks, 1);
|
atomic_add_fetch_32(&pMeta->numOfStreamTasks, 1);
|
||||||
}
|
}
|
||||||
|
@ -670,14 +672,17 @@ void streamMetaReleaseTask(SStreamMeta* UNUSED_PARAM(pMeta), SStreamTask* pTask)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doRemoveIdFromList(SStreamMeta* pMeta, int32_t num, SStreamTaskId* id) {
|
static void doRemoveIdFromList(SArray* pTaskList, int32_t num, SStreamTaskId* id) {
|
||||||
|
bool remove = false;
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
SStreamTaskId* pTaskId = taosArrayGet(pMeta->pTaskList, i);
|
SStreamTaskId* pTaskId = taosArrayGet(pTaskList, i);
|
||||||
if (pTaskId->streamId == id->streamId && pTaskId->taskId == id->taskId) {
|
if (pTaskId->streamId == id->streamId && pTaskId->taskId == id->taskId) {
|
||||||
taosArrayRemove(pMeta->pTaskList, i);
|
taosArrayRemove(pTaskList, i);
|
||||||
|
remove = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ASSERT(remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t streamTaskSendTransSuccessMsg(SStreamTask* pTask, void* param) {
|
static int32_t streamTaskSendTransSuccessMsg(SStreamTask* pTask, void* param) {
|
||||||
|
@ -713,7 +718,7 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t t
|
||||||
}
|
}
|
||||||
streamMetaWUnLock(pMeta);
|
streamMetaWUnLock(pMeta);
|
||||||
|
|
||||||
stDebug("s-task:0x%x set task status:dropping and start to unregister it", taskId);
|
stDebug("s-task:0x%x vgId:%d set task status:dropping and start to unregister it", taskId, pMeta->vgId);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
streamMetaRLock(pMeta);
|
streamMetaRLock(pMeta);
|
||||||
|
@ -740,18 +745,19 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t t
|
||||||
ppTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &id, sizeof(id));
|
ppTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &id, sizeof(id));
|
||||||
if (ppTask) {
|
if (ppTask) {
|
||||||
pTask = *ppTask;
|
pTask = *ppTask;
|
||||||
|
|
||||||
// it is an fill-history task, remove the related stream task's id that points to it
|
// it is an fill-history task, remove the related stream task's id that points to it
|
||||||
atomic_sub_fetch_32(&pMeta->numOfStreamTasks, 1);
|
if (pTask->info.fillHistory == 0) {
|
||||||
|
atomic_sub_fetch_32(&pMeta->numOfStreamTasks, 1);
|
||||||
|
}
|
||||||
|
|
||||||
taosHashRemove(pMeta->pTasksMap, &id, sizeof(id));
|
taosHashRemove(pMeta->pTasksMap, &id, sizeof(id));
|
||||||
doRemoveIdFromList(pMeta, (int32_t)taosArrayGetSize(pMeta->pTaskList), &pTask->id);
|
doRemoveIdFromList(pMeta->pTaskList, (int32_t)taosArrayGetSize(pMeta->pTaskList), &pTask->id);
|
||||||
streamMetaRemoveTask(pMeta, &id);
|
streamMetaRemoveTask(pMeta, &id);
|
||||||
|
|
||||||
|
ASSERT(taosHashGetSize(pMeta->pTasksMap) == taosArrayGetSize(pMeta->pTaskList));
|
||||||
streamMetaWUnLock(pMeta);
|
streamMetaWUnLock(pMeta);
|
||||||
|
|
||||||
ASSERT(pTask->status.timerActive == 0);
|
ASSERT(pTask->status.timerActive == 0);
|
||||||
|
|
||||||
if (pTask->info.delaySchedParam != 0 && pTask->info.fillHistory == 0) {
|
if (pTask->info.delaySchedParam != 0 && pTask->info.fillHistory == 0) {
|
||||||
stDebug("s-task:%s stop schedTimer, and (before) desc ref:%d", pTask->id.idStr, pTask->refCnt);
|
stDebug("s-task:%s stop schedTimer, and (before) desc ref:%d", pTask->id.idStr, pTask->refCnt);
|
||||||
taosTmrStop(pTask->schedInfo.pDelayTimer);
|
taosTmrStop(pTask->schedInfo.pDelayTimer);
|
||||||
|
@ -900,7 +906,7 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) {
|
||||||
STaskId id = {.streamId = pTask->id.streamId, .taskId = pTask->id.taskId};
|
STaskId id = {.streamId = pTask->id.streamId, .taskId = pTask->id.taskId};
|
||||||
void* p = taosHashGet(pMeta->pTasksMap, &id, sizeof(id));
|
void* p = taosHashGet(pMeta->pTasksMap, &id, sizeof(id));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
code = pMeta->expandFunc(pMeta->ahandle, pTask, pTask->chkInfo.checkpointVer + 1);
|
code = pMeta->buildTaskFn(pMeta->ahandle, pTask, pTask->chkInfo.checkpointVer + 1);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
stError("failed to expand s-task:0x%"PRIx64", code:%s, continue", id.taskId, tstrerror(terrno));
|
stError("failed to expand s-task:0x%"PRIx64", code:%s, continue", id.taskId, tstrerror(terrno));
|
||||||
tFreeStreamTask(pTask);
|
tFreeStreamTask(pTask);
|
||||||
|
@ -1005,9 +1011,10 @@ static int32_t metaHeartbeatToMnodeImpl(SStreamMeta* pMeta) {
|
||||||
hbMsg.pUpdateNodes = taosArrayInit(numOfTasks, sizeof(int32_t));
|
hbMsg.pUpdateNodes = taosArrayInit(numOfTasks, sizeof(int32_t));
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfTasks; ++i) {
|
for (int32_t i = 0; i < numOfTasks; ++i) {
|
||||||
STaskId* pId = taosArrayGet(pMeta->pTaskList, i);
|
SStreamTaskId* pId = taosArrayGet(pMeta->pTaskList, i);
|
||||||
|
|
||||||
SStreamTask** pTask = taosHashGet(pMeta->pTasksMap, pId, sizeof(*pId));
|
STaskId id = {.streamId = pId->streamId, .taskId = pId->taskId};
|
||||||
|
SStreamTask** pTask = taosHashGet(pMeta->pTasksMap, &id, sizeof(id));
|
||||||
if (pTask == NULL) {
|
if (pTask == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1018,7 +1025,7 @@ static int32_t metaHeartbeatToMnodeImpl(SStreamMeta* pMeta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
STaskStatusEntry entry = {
|
STaskStatusEntry entry = {
|
||||||
.id = *pId,
|
.id = id,
|
||||||
.status = streamTaskGetStatus(*pTask)->state,
|
.status = streamTaskGetStatus(*pTask)->state,
|
||||||
.nodeId = hbMsg.vgId,
|
.nodeId = hbMsg.vgId,
|
||||||
.stage = pMeta->stage,
|
.stage = pMeta->stage,
|
||||||
|
@ -1506,8 +1513,9 @@ int32_t streamMetaStopAllTasks(SStreamMeta* pMeta) {
|
||||||
bool streamMetaAllTasksReady(const SStreamMeta* pMeta) {
|
bool streamMetaAllTasksReady(const SStreamMeta* pMeta) {
|
||||||
int32_t num = taosArrayGetSize(pMeta->pTaskList);
|
int32_t num = taosArrayGetSize(pMeta->pTaskList);
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
STaskId* pTaskId = taosArrayGet(pMeta->pTaskList, i);
|
SStreamTaskId* pId = taosArrayGet(pMeta->pTaskList, i);
|
||||||
SStreamTask** ppTask = taosHashGet(pMeta->pTasksMap, pTaskId, sizeof(*pTaskId));
|
STaskId id = {.streamId = pId->streamId, .taskId = pId->taskId};
|
||||||
|
SStreamTask** ppTask = taosHashGet(pMeta->pTasksMap, &id, sizeof(id));
|
||||||
if (ppTask == NULL) {
|
if (ppTask == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1521,6 +1529,7 @@ bool streamMetaAllTasksReady(const SStreamMeta* pMeta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t streamMetaStartOneTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId, __stream_task_expand_fn expandFn) {
|
int32_t streamMetaStartOneTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId, __stream_task_expand_fn expandFn) {
|
||||||
|
int32_t code = 0;
|
||||||
int32_t vgId = pMeta->vgId;
|
int32_t vgId = pMeta->vgId;
|
||||||
stInfo("vgId:%d start task:0x%x by checking it's downstream status", vgId, taskId);
|
stInfo("vgId:%d start task:0x%x by checking it's downstream status", vgId, taskId);
|
||||||
|
|
||||||
|
@ -1540,40 +1549,22 @@ int32_t streamMetaStartOneTask(SStreamMeta* pMeta, int64_t streamId, int32_t tas
|
||||||
|
|
||||||
ASSERT(pTask->status.downstreamReady == 0);
|
ASSERT(pTask->status.downstreamReady == 0);
|
||||||
if (pTask->pBackend == NULL) {
|
if (pTask->pBackend == NULL) {
|
||||||
int32_t code = expandFn(pTask);
|
code = expandFn(pTask);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
streamMetaAddFailedTaskSelf(pTask, pInfo->readyTs);
|
streamMetaAddFailedTaskSelf(pTask, pInfo->readyTs);
|
||||||
streamMetaReleaseTask(pMeta, pTask);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HAS_RELATED_FILLHISTORY_TASK(pTask)) {
|
|
||||||
SStreamTask* pHTask = streamMetaAcquireTask(pMeta, pTask->hTaskInfo.id.streamId, pTask->hTaskInfo.id.taskId);
|
|
||||||
if (pHTask != NULL) {
|
|
||||||
if (pHTask->pBackend == NULL) {
|
|
||||||
code = expandFn(pHTask);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
streamMetaAddFailedTaskSelf(pHTask, pInfo->readyTs);
|
|
||||||
|
|
||||||
streamMetaReleaseTask(pMeta, pHTask);
|
|
||||||
streamMetaReleaseTask(pMeta, pTask);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
streamMetaReleaseTask(pMeta, pHTask);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ret = streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_INIT);
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
code = streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_INIT);
|
||||||
stError("s-task:%s vgId:%d failed to handle event:%d", pTask->id.idStr, pMeta->vgId, TASK_EVENT_INIT);
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
streamMetaAddFailedTaskSelf(pTask, pInfo->readyTs);
|
stError("s-task:%s vgId:%d failed to handle event:%d", pTask->id.idStr, pMeta->vgId, TASK_EVENT_INIT);
|
||||||
|
streamMetaAddFailedTaskSelf(pTask, pInfo->readyTs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
streamMetaReleaseTask(pMeta, pTask);
|
streamMetaReleaseTask(pMeta, pTask);
|
||||||
return ret;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void displayStatusInfo(SStreamMeta* pMeta, SHashObj* pTaskSet, bool succ) {
|
static void displayStatusInfo(SStreamMeta* pMeta, SHashObj* pTaskSet, bool succ) {
|
||||||
|
@ -1740,4 +1731,14 @@ void streamMetaAddIntoUpdateTaskList(SStreamMeta* pMeta, SStreamTask* pTask, SSt
|
||||||
stDebug("s-task:%s vgId:%d transId:%d task nodeEp update completed, streamTask closed, elapsed time:%" PRId64 "ms",
|
stDebug("s-task:%s vgId:%d transId:%d task nodeEp update completed, streamTask closed, elapsed time:%" PRId64 "ms",
|
||||||
id, vgId, transId, el);
|
id, vgId, transId, el);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void streamMetaClearUpdateTaskList(SStreamMeta* pMeta) {
|
||||||
|
taosHashClear(pMeta->updateInfo.pTasks);
|
||||||
|
pMeta->updateInfo.transId = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void streamMetaInitUpdateTaskList(SStreamMeta* pMeta, int32_t transId) {
|
||||||
|
taosHashClear(pMeta->updateInfo.pTasks);
|
||||||
|
pMeta->updateInfo.transId = transId;
|
||||||
}
|
}
|
|
@ -516,24 +516,25 @@ SStreamStateCur* countWinStateSeekKeyPrev(SStreamFileState* pFileState, const SS
|
||||||
return pBuffCur;
|
return pBuffCur;
|
||||||
}
|
}
|
||||||
winCount = *((COUNT_TYPE*) ((char*)pVal + (resSize - sizeof(COUNT_TYPE))));
|
winCount = *((COUNT_TYPE*) ((char*)pVal + (resSize - sizeof(COUNT_TYPE))));
|
||||||
|
taosMemoryFreeClear(pVal);
|
||||||
|
streamStateFreeCur(pBuffCur);
|
||||||
if (sessionRangeKeyCmpr(pWinKey, &key) != 0 && winCount == count) {
|
if (sessionRangeKeyCmpr(pWinKey, &key) != 0 && winCount == count) {
|
||||||
streamStateFreeCur(pCur);
|
streamStateCurNext(pFileStore, pCur);
|
||||||
return pBuffCur;
|
return pCur;
|
||||||
}
|
}
|
||||||
streamStateCurPrev(pFileStore, pCur);
|
streamStateCurPrev(pFileStore, pCur);
|
||||||
while (1) {
|
while (1) {
|
||||||
code = streamStateSessionGetKVByCur_rocksdb(pCur, &key, &pVal, &len);
|
code = streamStateSessionGetKVByCur_rocksdb(pCur, &key, &pVal, &len);
|
||||||
if (code == TSDB_CODE_FAILED) {
|
if (code == TSDB_CODE_FAILED) {
|
||||||
streamStateCurNext(pFileStore, pCur);
|
streamStateCurNext(pFileStore, pCur);
|
||||||
streamStateFreeCur(pBuffCur);
|
|
||||||
return pCur;
|
return pCur;
|
||||||
}
|
}
|
||||||
winCount = *((COUNT_TYPE*) ((char*)pVal + (resSize - sizeof(COUNT_TYPE))));
|
winCount = *((COUNT_TYPE*) ((char*)pVal + (resSize - sizeof(COUNT_TYPE))));
|
||||||
|
taosMemoryFreeClear(pVal);
|
||||||
if (sessionRangeKeyCmpr(pWinKey, &key) == 0 || winCount < count) {
|
if (sessionRangeKeyCmpr(pWinKey, &key) == 0 || winCount < count) {
|
||||||
streamStateCurPrev(pFileStore, pCur);
|
streamStateCurPrev(pFileStore, pCur);
|
||||||
} else {
|
} else {
|
||||||
streamStateCurNext(pFileStore, pCur);
|
streamStateCurNext(pFileStore, pCur);
|
||||||
streamStateFreeCur(pBuffCur);
|
|
||||||
return pCur;
|
return pCur;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -568,7 +569,7 @@ int32_t sessionWinStateGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, void
|
||||||
void* pData = NULL;
|
void* pData = NULL;
|
||||||
code = streamStateSessionGetKVByCur_rocksdb(pCur, pKey, &pData, pVLen);
|
code = streamStateSessionGetKVByCur_rocksdb(pCur, pKey, &pData, pVLen);
|
||||||
if (taosArrayGetSize(pWinStates) > 0 &&
|
if (taosArrayGetSize(pWinStates) > 0 &&
|
||||||
(code == TSDB_CODE_FAILED || sessionStateKeyCompare(pKey, pWinStates, 0) >= 0)) {
|
(code == TSDB_CODE_FAILED || sessionStateRangeKeyCompare(pKey, pWinStates, 0) >= 0)) {
|
||||||
transformCursor(pCur->pStreamFileState, pCur);
|
transformCursor(pCur->pStreamFileState, pCur);
|
||||||
SRowBuffPos* pPos = taosArrayGetP(pWinStates, pCur->buffIndex);
|
SRowBuffPos* pPos = taosArrayGetP(pWinStates, pCur->buffIndex);
|
||||||
if (pVal) {
|
if (pVal) {
|
||||||
|
@ -590,6 +591,7 @@ int32_t sessionWinStateGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, void
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sessionWinStateMoveToNext(SStreamStateCur* pCur) {
|
int32_t sessionWinStateMoveToNext(SStreamStateCur* pCur) {
|
||||||
|
qTrace("move cursor to next");
|
||||||
if (pCur && pCur->buffIndex >= 0) {
|
if (pCur && pCur->buffIndex >= 0) {
|
||||||
pCur->buffIndex++;
|
pCur->buffIndex++;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -197,6 +197,9 @@ int32_t streamLaunchFillHistoryTask(SStreamTask* pTask) {
|
||||||
const char* idStr = pTask->id.idStr;
|
const char* idStr = pTask->id.idStr;
|
||||||
int64_t hStreamId = pTask->hTaskInfo.id.streamId;
|
int64_t hStreamId = pTask->hTaskInfo.id.streamId;
|
||||||
int32_t hTaskId = pTask->hTaskInfo.id.taskId;
|
int32_t hTaskId = pTask->hTaskInfo.id.taskId;
|
||||||
|
int64_t now = taosGetTimestampMs();
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
ASSERT(hTaskId != 0);
|
ASSERT(hTaskId != 0);
|
||||||
|
|
||||||
// check stream task status in the first place.
|
// check stream task status in the first place.
|
||||||
|
@ -226,7 +229,18 @@ int32_t streamLaunchFillHistoryTask(SStreamTask* pTask) {
|
||||||
stDebug("s-task:%s fill-history task is ready, no need to check downstream", pHisTask->id.idStr);
|
stDebug("s-task:%s fill-history task is ready, no need to check downstream", pHisTask->id.idStr);
|
||||||
streamMetaAddTaskLaunchResult(pMeta, hStreamId, hTaskId, pExecInfo->checkTs, pExecInfo->readyTs, true);
|
streamMetaAddTaskLaunchResult(pMeta, hStreamId, hTaskId, pExecInfo->checkTs, pExecInfo->readyTs, true);
|
||||||
} else { // exist, but not ready, continue check downstream task status
|
} else { // exist, but not ready, continue check downstream task status
|
||||||
checkFillhistoryTaskStatus(pTask, pHisTask);
|
if (pHisTask->pBackend == NULL) {
|
||||||
|
code = pMeta->expandTaskFn(pHisTask);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
streamMetaAddFailedTaskSelf(pHisTask, now);
|
||||||
|
stError("s-task:%s failed to expand fill-history task, code:%s", pHisTask->id.idStr, tstrerror(code));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
checkFillhistoryTaskStatus(pTask, pHisTask);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
streamMetaReleaseTask(pMeta, pHisTask);
|
streamMetaReleaseTask(pMeta, pHisTask);
|
||||||
|
@ -306,6 +320,7 @@ void tryLaunchHistoryTask(void* param, void* tmrId) {
|
||||||
SLaunchHTaskInfo* pInfo = param;
|
SLaunchHTaskInfo* pInfo = param;
|
||||||
SStreamMeta* pMeta = pInfo->pMeta;
|
SStreamMeta* pMeta = pInfo->pMeta;
|
||||||
int64_t now = taosGetTimestampMs();
|
int64_t now = taosGetTimestampMs();
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
streamMetaWLock(pMeta);
|
streamMetaWLock(pMeta);
|
||||||
|
|
||||||
|
@ -362,13 +377,22 @@ void tryLaunchHistoryTask(void* param, void* tmrId) {
|
||||||
streamMetaReleaseTask(pMeta, pTask);
|
streamMetaReleaseTask(pMeta, pTask);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
checkFillhistoryTaskStatus(pTask, pHTask);
|
if (pHTask->pBackend == NULL) {
|
||||||
streamMetaReleaseTask(pMeta, pHTask);
|
code = pMeta->expandTaskFn(pHTask);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
streamMetaAddFailedTaskSelf(pHTask, now);
|
||||||
|
stError("failed to expand fill-history task:%s, code:%s", pHTask->id.idStr, tstrerror(code));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// not in timer anymore
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1);
|
checkFillhistoryTaskStatus(pTask, pHTask);
|
||||||
stDebug("s-task:0x%x fill-history task launch completed, retry times:%d, ref:%d", (int32_t)pInfo->id.taskId,
|
// not in timer anymore
|
||||||
pHTaskInfo->retryTimes, ref);
|
int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1);
|
||||||
|
stDebug("s-task:0x%x fill-history task launch completed, retry times:%d, ref:%d", (int32_t)pInfo->id.taskId,
|
||||||
|
pHTaskInfo->retryTimes, ref);
|
||||||
|
}
|
||||||
|
streamMetaReleaseTask(pMeta, pHTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,8 @@ int stateKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) {
|
||||||
return winKeyCmprImpl(&pWin1->key, &pWin2->key);
|
return winKeyCmprImpl(&pWin1->key, &pWin2->key);
|
||||||
}
|
}
|
||||||
|
|
||||||
SStreamState* streamStateOpen(const char* path, void* pTask, bool specPath, int32_t szPage, int32_t pages) {
|
SStreamState* streamStateOpen(const char* path, void* pTask, int64_t streamId, int32_t taskId, bool specPath,
|
||||||
|
int32_t szPage, int32_t pages) {
|
||||||
SStreamState* pState = taosMemoryCalloc(1, sizeof(SStreamState));
|
SStreamState* pState = taosMemoryCalloc(1, sizeof(SStreamState));
|
||||||
stDebug("open stream state %p, %s", pState, path);
|
stDebug("open stream state %p, %s", pState, path);
|
||||||
if (pState == NULL) {
|
if (pState == NULL) {
|
||||||
|
@ -114,8 +115,8 @@ SStreamState* streamStateOpen(const char* path, void* pTask, bool specPath, int3
|
||||||
}
|
}
|
||||||
|
|
||||||
SStreamTask* pStreamTask = pTask;
|
SStreamTask* pStreamTask = pTask;
|
||||||
pState->taskId = pStreamTask->id.taskId;
|
pState->streamId = streamId;
|
||||||
pState->streamId = pStreamTask->id.streamId;
|
pState->taskId = taskId;
|
||||||
sprintf(pState->pTdbState->idstr, "0x%" PRIx64 "-0x%x", pState->streamId, pState->taskId);
|
sprintf(pState->pTdbState->idstr, "0x%" PRIx64 "-0x%x", pState->streamId, pState->taskId);
|
||||||
|
|
||||||
streamTaskSetDb(pStreamTask->pMeta, pTask, pState->pTdbState->idstr);
|
streamTaskSetDb(pStreamTask->pMeta, pTask, pState->pTdbState->idstr);
|
||||||
|
@ -654,6 +655,7 @@ int32_t streamStateCurNext(SStreamState* pState, SStreamStateCur* pCur) {
|
||||||
|
|
||||||
int32_t streamStateCurPrev(SStreamState* pState, SStreamStateCur* pCur) {
|
int32_t streamStateCurPrev(SStreamState* pState, SStreamStateCur* pCur) {
|
||||||
#ifdef USE_ROCKSDB
|
#ifdef USE_ROCKSDB
|
||||||
|
qTrace("move cursor to next");
|
||||||
return streamStateCurPrev_rocksdb(pCur);
|
return streamStateCurPrev_rocksdb(pCur);
|
||||||
#else
|
#else
|
||||||
if (!pCur) {
|
if (!pCur) {
|
||||||
|
|
|
@ -283,10 +283,12 @@ void tFreeStreamTask(SStreamTask* pTask) {
|
||||||
pTask->status.pSM = streamDestroyStateMachine(pTask->status.pSM);
|
pTask->status.pSM = streamDestroyStateMachine(pTask->status.pSM);
|
||||||
streamTaskDestroyUpstreamInfo(&pTask->upstreamInfo);
|
streamTaskDestroyUpstreamInfo(&pTask->upstreamInfo);
|
||||||
|
|
||||||
pTask->msgInfo.pRetryList = taosArrayDestroy(pTask->msgInfo.pRetryList);
|
|
||||||
taosMemoryFree(pTask->outputInfo.pTokenBucket);
|
taosMemoryFree(pTask->outputInfo.pTokenBucket);
|
||||||
taosThreadMutexDestroy(&pTask->lock);
|
taosThreadMutexDestroy(&pTask->lock);
|
||||||
|
|
||||||
|
pTask->msgInfo.pSendInfo = taosArrayDestroy(pTask->msgInfo.pSendInfo);
|
||||||
|
taosThreadMutexDestroy(&pTask->msgInfo.lock);
|
||||||
|
|
||||||
pTask->outputInfo.pNodeEpsetUpdateList = taosArrayDestroy(pTask->outputInfo.pNodeEpsetUpdateList);
|
pTask->outputInfo.pNodeEpsetUpdateList = taosArrayDestroy(pTask->outputInfo.pNodeEpsetUpdateList);
|
||||||
|
|
||||||
if ((pTask->status.removeBackendFiles) && (pTask->pMeta != NULL)) {
|
if ((pTask->status.removeBackendFiles) && (pTask->pMeta != NULL)) {
|
||||||
|
@ -373,7 +375,13 @@ int32_t streamTaskInit(SStreamTask* pTask, SStreamMeta* pMeta, SMsgCb* pMsgCb, i
|
||||||
|
|
||||||
pTask->pMeta = pMeta;
|
pTask->pMeta = pMeta;
|
||||||
pTask->pMsgCb = pMsgCb;
|
pTask->pMsgCb = pMsgCb;
|
||||||
pTask->msgInfo.pRetryList = taosArrayInit(4, sizeof(int32_t));
|
pTask->msgInfo.pSendInfo = taosArrayInit(4, sizeof(SDispatchEntry));
|
||||||
|
if (pTask->msgInfo.pSendInfo == NULL) {
|
||||||
|
stError("s-task:%s failed to create sendInfo struct for stream task, code:Out of memory", pTask->id.idStr);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosThreadMutexInit(&pTask->msgInfo.lock, NULL);
|
||||||
|
|
||||||
TdThreadMutexAttr attr = {0};
|
TdThreadMutexAttr attr = {0};
|
||||||
|
|
||||||
|
@ -731,35 +739,50 @@ int32_t streamBuildAndSendDropTaskMsg(SMsgCb* pMsgCb, int32_t vgId, SStreamTaskI
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t streamBuildAndSendCheckpointUpdateMsg(SMsgCb* pMsgCb, int32_t vgId, SStreamTaskId* pTaskId, STaskId* pHTaskId,
|
int32_t streamSendChkptReportMsg(SStreamTask* pTask, SCheckpointInfo* pCheckpointInfo, int8_t dropRelHTask) {
|
||||||
SCheckpointInfo* pCheckpointInfo, int8_t dropRelHTask) {
|
int32_t code;
|
||||||
SVUpdateCheckpointInfoReq* pReq = rpcMallocCont(sizeof(SVUpdateCheckpointInfoReq));
|
int32_t tlen = 0;
|
||||||
if (pReq == NULL) {
|
int32_t vgId = pTask->pMeta->vgId;
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
const char* id = pTask->id.idStr;
|
||||||
|
SActiveCheckpointInfo* pActive = pCheckpointInfo->pActiveInfo;
|
||||||
|
|
||||||
|
SCheckpointReport req = {.streamId = pTask->id.streamId,
|
||||||
|
.taskId = pTask->id.taskId,
|
||||||
|
.nodeId = vgId,
|
||||||
|
.dropHTask = dropRelHTask,
|
||||||
|
.transId = pActive->transId,
|
||||||
|
.checkpointId = pActive->activeId,
|
||||||
|
.checkpointVer = pCheckpointInfo->processedVer,
|
||||||
|
.checkpointTs = pCheckpointInfo->startTs};
|
||||||
|
|
||||||
|
tEncodeSize(tEncodeStreamTaskChkptReport, &req, tlen, code);
|
||||||
|
if (code < 0) {
|
||||||
|
stError("s-task:%s vgId:%d encode stream task checkpoint-report failed, code:%s", id, vgId, tstrerror(code));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pReq->head.vgId = vgId;
|
void* buf = rpcMallocCont(tlen);
|
||||||
pReq->taskId = pTaskId->taskId;
|
if (buf == NULL) {
|
||||||
pReq->streamId = pTaskId->streamId;
|
stError("s-task:%s vgId:%d encode stream task checkpoint-report msg failed, code:%s", id, vgId,
|
||||||
pReq->dropRelHTask = dropRelHTask;
|
tstrerror(TSDB_CODE_OUT_OF_MEMORY));
|
||||||
pReq->hStreamId = pHTaskId->streamId;
|
return -1;
|
||||||
pReq->hTaskId = pHTaskId->taskId;
|
|
||||||
pReq->transId = pCheckpointInfo->pActiveInfo->transId;
|
|
||||||
|
|
||||||
pReq->checkpointId = pCheckpointInfo->pActiveInfo->activeId;
|
|
||||||
pReq->checkpointVer = pCheckpointInfo->processedVer;
|
|
||||||
pReq->checkpointTs = pCheckpointInfo->startTs;
|
|
||||||
|
|
||||||
SRpcMsg msg = {.msgType = TDMT_STREAM_TASK_UPDATE_CHKPT, .pCont = pReq, .contLen = sizeof(SVUpdateCheckpointInfoReq)};
|
|
||||||
int32_t code = tmsgPutToQueue(pMsgCb, WRITE_QUEUE, &msg);
|
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
stError("vgId:%d task:0x%x failed to send update checkpoint info msg, code:%s", vgId, pTaskId->taskId, tstrerror(code));
|
|
||||||
} else {
|
|
||||||
stDebug("vgId:%d task:0x%x build and send update checkpoint info msg msg", vgId, pTaskId->taskId);
|
|
||||||
}
|
}
|
||||||
return code;
|
|
||||||
|
SEncoder encoder;
|
||||||
|
tEncoderInit(&encoder, buf, tlen);
|
||||||
|
if ((code = tEncodeStreamTaskChkptReport(&encoder, &req)) < 0) {
|
||||||
|
rpcFreeCont(buf);
|
||||||
|
stError("s-task:%s vgId:%d encode stream task checkpoint-report msg failed, code:%s", id, vgId, tstrerror(code));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
|
SRpcMsg msg = {0};
|
||||||
|
initRpcMsg(&msg, TDMT_MND_STREAM_CHKPT_REPORT, buf, tlen);
|
||||||
|
stDebug("s-task:%s vgId:%d build and send task checkpoint-report to mnode", id, vgId);
|
||||||
|
|
||||||
|
tmsgSendReq(&pTask->info.mnodeEpset, &msg);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
STaskId streamTaskGetTaskId(const SStreamTask* pTask) {
|
STaskId streamTaskGetTaskId(const SStreamTask* pTask) {
|
||||||
|
@ -921,32 +944,36 @@ char* createStreamTaskIdStr(int64_t streamId, int32_t taskId) {
|
||||||
|
|
||||||
static int32_t streamTaskEnqueueRetrieve(SStreamTask* pTask, SStreamRetrieveReq* pReq) {
|
static int32_t streamTaskEnqueueRetrieve(SStreamTask* pTask, SStreamRetrieveReq* pReq) {
|
||||||
SStreamDataBlock* pData = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, sizeof(SStreamDataBlock));
|
SStreamDataBlock* pData = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, sizeof(SStreamDataBlock));
|
||||||
int8_t status = TASK_INPUT_STATUS__NORMAL;
|
if (pData == NULL) {
|
||||||
|
stError("s-task:%s failed to allocated retrieve-block", pTask->id.idStr);
|
||||||
// enqueue
|
return terrno;
|
||||||
if (pData != NULL) {
|
|
||||||
stDebug("s-task:%s (child %d) recv retrieve req from task:0x%x(vgId:%d), reqId:0x%" PRIx64, pTask->id.idStr,
|
|
||||||
pTask->info.selfChildId, pReq->srcTaskId, pReq->srcNodeId, pReq->reqId);
|
|
||||||
|
|
||||||
pData->type = STREAM_INPUT__DATA_RETRIEVE;
|
|
||||||
pData->srcVgId = 0;
|
|
||||||
streamRetrieveReqToData(pReq, pData);
|
|
||||||
if (streamTaskPutDataIntoInputQ(pTask, (SStreamQueueItem*)pData) == 0) {
|
|
||||||
status = TASK_INPUT_STATUS__NORMAL;
|
|
||||||
} else {
|
|
||||||
status = TASK_INPUT_STATUS__FAILED;
|
|
||||||
}
|
|
||||||
} else { // todo handle oom
|
|
||||||
/*streamTaskInputFail(pTask);*/
|
|
||||||
/*status = TASK_INPUT_STATUS__FAILED;*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return status == TASK_INPUT_STATUS__NORMAL ? 0 : -1;
|
// enqueue
|
||||||
|
stDebug("s-task:%s (vgId:%d level:%d) recv retrieve req from task:0x%x(vgId:%d), reqId:0x%" PRIx64, pTask->id.idStr,
|
||||||
|
pTask->pMeta->vgId, pTask->info.taskLevel, pReq->srcTaskId, pReq->srcNodeId, pReq->reqId);
|
||||||
|
|
||||||
|
pData->type = STREAM_INPUT__DATA_RETRIEVE;
|
||||||
|
pData->srcVgId = 0;
|
||||||
|
|
||||||
|
int32_t code = streamRetrieveReqToData(pReq, pData, pTask->id.idStr);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
taosFreeQitem(pData);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = streamTaskPutDataIntoInputQ(pTask, (SStreamQueueItem*)pData);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
stError("s-task:%s failed to put retrieve-block into inputQ, inputQ is full, discard the retrieve msg",
|
||||||
|
pTask->id.idStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq) {
|
int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq) {
|
||||||
int32_t code = streamTaskEnqueueRetrieve(pTask, pReq);
|
int32_t code = streamTaskEnqueueRetrieve(pTask, pReq);
|
||||||
if(code != 0){
|
if (code != 0) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
return streamTrySchedExec(pTask);
|
return streamTrySchedExec(pTask);
|
||||||
|
|
|
@ -594,6 +594,34 @@ int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
|
||||||
}
|
}
|
||||||
if (tDecodeCStrTo(pDecoder, pTask->reserve) < 0) return -1;
|
if (tDecodeCStrTo(pDecoder, pTask->reserve) < 0) return -1;
|
||||||
|
|
||||||
|
tEndDecode(pDecoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tEncodeStreamTaskChkptReport(SEncoder* pEncoder, const SCheckpointReport* pReq) {
|
||||||
|
if (tStartEncode(pEncoder) < 0) return -1;
|
||||||
|
if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1;
|
||||||
|
if (tEncodeI32(pEncoder, pReq->taskId) < 0) return -1;
|
||||||
|
if (tEncodeI32(pEncoder, pReq->nodeId) < 0) return -1;
|
||||||
|
if (tEncodeI64(pEncoder, pReq->checkpointId) < 0) return -1;
|
||||||
|
if (tEncodeI64(pEncoder, pReq->checkpointVer) < 0) return -1;
|
||||||
|
if (tEncodeI64(pEncoder, pReq->checkpointTs) < 0) return -1;
|
||||||
|
if (tEncodeI32(pEncoder, pReq->transId) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, pReq->dropHTask) < 0) return -1;
|
||||||
|
tEndEncode(pEncoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDecodeStreamTaskChkptReport(SDecoder* pDecoder, SCheckpointReport* pReq) {
|
||||||
|
if (tStartDecode(pDecoder) < 0) return -1;
|
||||||
|
if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1;
|
||||||
|
if (tDecodeI32(pDecoder, &pReq->taskId) < 0) return -1;
|
||||||
|
if (tDecodeI32(pDecoder, &pReq->nodeId) < 0) return -1;
|
||||||
|
if (tDecodeI64(pDecoder, &pReq->checkpointId) < 0) return -1;
|
||||||
|
if (tDecodeI64(pDecoder, &pReq->checkpointVer) < 0) return -1;
|
||||||
|
if (tDecodeI64(pDecoder, &pReq->checkpointTs) < 0) return -1;
|
||||||
|
if (tDecodeI32(pDecoder, &pReq->transId) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, &pReq->dropHTask) < 0) return -1;
|
||||||
tEndDecode(pDecoder);
|
tEndDecode(pDecoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -43,10 +43,10 @@ SStreamState *stateCreate(const char *path) {
|
||||||
pTask->ver = 1024;
|
pTask->ver = 1024;
|
||||||
pTask->id.streamId = 1023;
|
pTask->id.streamId = 1023;
|
||||||
pTask->id.taskId = 1111111;
|
pTask->id.taskId = 1111111;
|
||||||
SStreamMeta *pMeta = streamMetaOpen((path), NULL, NULL, 0, 0, NULL);
|
SStreamMeta *pMeta = streamMetaOpen((path), NULL, NULL, NULL, 0, 0, NULL);
|
||||||
pTask->pMeta = pMeta;
|
pTask->pMeta = pMeta;
|
||||||
|
|
||||||
SStreamState *p = streamStateOpen((char *)path, pTask, true, 32, 32 * 1024);
|
SStreamState *p = streamStateOpen((char *)path, pTask, 0, 0, true, 32, 32 * 1024);
|
||||||
ASSERT(p != NULL);
|
ASSERT(p != NULL);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,7 +363,7 @@ static bool uvHandleReq(SSvrConn* pConn) {
|
||||||
memcpy(pConn->user, pHead->user, strlen(pHead->user));
|
memcpy(pConn->user, pHead->user, strlen(pHead->user));
|
||||||
|
|
||||||
int8_t forbiddenIp = 0;
|
int8_t forbiddenIp = 0;
|
||||||
if (pThrd->enableIpWhiteList) {
|
if (pThrd->enableIpWhiteList && tsEnableWhiteList) {
|
||||||
forbiddenIp = !uvWhiteListCheckConn(pThrd->pWhiteList, pConn) ? 1 : 0;
|
forbiddenIp = !uvWhiteListCheckConn(pThrd->pWhiteList, pConn) ? 1 : 0;
|
||||||
if (forbiddenIp == 0) {
|
if (forbiddenIp == 0) {
|
||||||
uvWhiteListSetConnVer(pThrd->pWhiteList, pConn);
|
uvWhiteListSetConnVer(pThrd->pWhiteList, pConn);
|
||||||
|
|
|
@ -17,15 +17,6 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
#ifdef WINDOWS
|
|
||||||
#define THREAD_PTR_CHECK(p) \
|
|
||||||
do { \
|
|
||||||
if (!(p) || !(*(p))) return 0; \
|
|
||||||
} while (0);
|
|
||||||
#else
|
|
||||||
#define THREAD_PTR_CHECK(p)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int32_t taosThreadCreate(TdThread *tid, const TdThreadAttr *attr, void *(*start)(void *), void *arg) {
|
int32_t taosThreadCreate(TdThread *tid, const TdThreadAttr *attr, void *(*start)(void *), void *arg) {
|
||||||
return pthread_create(tid, attr, start, arg);
|
return pthread_create(tid, attr, start, arg);
|
||||||
}
|
}
|
||||||
|
@ -126,7 +117,6 @@ int32_t taosThreadCondWait(TdThreadCond *cond, TdThreadMutex *mutex) {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
THREAD_PTR_CHECK(mutex)
|
|
||||||
return pthread_cond_wait(cond, mutex);
|
return pthread_cond_wait(cond, mutex);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -140,7 +130,6 @@ int32_t taosThreadCondTimedWait(TdThreadCond *cond, TdThreadMutex *mutex, const
|
||||||
}
|
}
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
#else
|
#else
|
||||||
THREAD_PTR_CHECK(mutex)
|
|
||||||
return pthread_cond_timedwait(cond, mutex, abstime);
|
return pthread_cond_timedwait(cond, mutex, abstime);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -211,7 +200,6 @@ int32_t taosThreadKeyDelete(TdThreadKey key) { return pthread_key_delete(key); }
|
||||||
int32_t taosThreadKill(TdThread thread, int32_t sig) { return pthread_kill(thread, sig); }
|
int32_t taosThreadKill(TdThread thread, int32_t sig) { return pthread_kill(thread, sig); }
|
||||||
|
|
||||||
// int32_t taosThreadMutexConsistent(TdThreadMutex* mutex) {
|
// int32_t taosThreadMutexConsistent(TdThreadMutex* mutex) {
|
||||||
// THREAD_PTR_CHECK(mutex)
|
|
||||||
// return pthread_mutex_consistent(mutex);
|
// return pthread_mutex_consistent(mutex);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@ -220,7 +208,6 @@ int32_t taosThreadMutexDestroy(TdThreadMutex *mutex) {
|
||||||
DeleteCriticalSection(mutex);
|
DeleteCriticalSection(mutex);
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
THREAD_PTR_CHECK(mutex)
|
|
||||||
return pthread_mutex_destroy(mutex);
|
return pthread_mutex_destroy(mutex);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -244,7 +231,6 @@ int32_t taosThreadMutexLock(TdThreadMutex *mutex) {
|
||||||
EnterCriticalSection(mutex);
|
EnterCriticalSection(mutex);
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
THREAD_PTR_CHECK(mutex)
|
|
||||||
return pthread_mutex_lock(mutex);
|
return pthread_mutex_lock(mutex);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -258,7 +244,6 @@ int32_t taosThreadMutexTryLock(TdThreadMutex *mutex) {
|
||||||
if (TryEnterCriticalSection(mutex)) return 0;
|
if (TryEnterCriticalSection(mutex)) return 0;
|
||||||
return EBUSY;
|
return EBUSY;
|
||||||
#else
|
#else
|
||||||
THREAD_PTR_CHECK(mutex)
|
|
||||||
return pthread_mutex_trylock(mutex);
|
return pthread_mutex_trylock(mutex);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -268,7 +253,6 @@ int32_t taosThreadMutexUnlock(TdThreadMutex *mutex) {
|
||||||
LeaveCriticalSection(mutex);
|
LeaveCriticalSection(mutex);
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
THREAD_PTR_CHECK(mutex)
|
|
||||||
return pthread_mutex_unlock(mutex);
|
return pthread_mutex_unlock(mutex);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -461,7 +445,6 @@ int32_t taosThreadSetSchedParam(TdThread thread, int32_t policy, const struct sc
|
||||||
int32_t taosThreadSetSpecific(TdThreadKey key, const void *value) { return pthread_setspecific(key, value); }
|
int32_t taosThreadSetSpecific(TdThreadKey key, const void *value) { return pthread_setspecific(key, value); }
|
||||||
|
|
||||||
int32_t taosThreadSpinDestroy(TdThreadSpinlock *lock) {
|
int32_t taosThreadSpinDestroy(TdThreadSpinlock *lock) {
|
||||||
THREAD_PTR_CHECK(lock)
|
|
||||||
#ifdef TD_USE_SPINLOCK_AS_MUTEX
|
#ifdef TD_USE_SPINLOCK_AS_MUTEX
|
||||||
return pthread_mutex_destroy((pthread_mutex_t *)lock);
|
return pthread_mutex_destroy((pthread_mutex_t *)lock);
|
||||||
#else
|
#else
|
||||||
|
@ -480,7 +463,6 @@ int32_t taosThreadSpinInit(TdThreadSpinlock *lock, int32_t pshared) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosThreadSpinLock(TdThreadSpinlock *lock) {
|
int32_t taosThreadSpinLock(TdThreadSpinlock *lock) {
|
||||||
THREAD_PTR_CHECK(lock)
|
|
||||||
#ifdef TD_USE_SPINLOCK_AS_MUTEX
|
#ifdef TD_USE_SPINLOCK_AS_MUTEX
|
||||||
return pthread_mutex_lock((pthread_mutex_t *)lock);
|
return pthread_mutex_lock((pthread_mutex_t *)lock);
|
||||||
#else
|
#else
|
||||||
|
@ -489,7 +471,6 @@ int32_t taosThreadSpinLock(TdThreadSpinlock *lock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosThreadSpinTrylock(TdThreadSpinlock *lock) {
|
int32_t taosThreadSpinTrylock(TdThreadSpinlock *lock) {
|
||||||
THREAD_PTR_CHECK(lock)
|
|
||||||
#ifdef TD_USE_SPINLOCK_AS_MUTEX
|
#ifdef TD_USE_SPINLOCK_AS_MUTEX
|
||||||
return pthread_mutex_trylock((pthread_mutex_t *)lock);
|
return pthread_mutex_trylock((pthread_mutex_t *)lock);
|
||||||
#else
|
#else
|
||||||
|
@ -498,7 +479,6 @@ int32_t taosThreadSpinTrylock(TdThreadSpinlock *lock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosThreadSpinUnlock(TdThreadSpinlock *lock) {
|
int32_t taosThreadSpinUnlock(TdThreadSpinlock *lock) {
|
||||||
THREAD_PTR_CHECK(lock)
|
|
||||||
#ifdef TD_USE_SPINLOCK_AS_MUTEX
|
#ifdef TD_USE_SPINLOCK_AS_MUTEX
|
||||||
return pthread_mutex_unlock((pthread_mutex_t *)lock);
|
return pthread_mutex_unlock((pthread_mutex_t *)lock);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -86,8 +86,9 @@ static void taosDeleteTimer(void *tharg) {
|
||||||
static TdThread timerThread;
|
static TdThread timerThread;
|
||||||
static timer_t timerId;
|
static timer_t timerId;
|
||||||
static volatile bool stopTimer = false;
|
static volatile bool stopTimer = false;
|
||||||
static void *taosProcessAlarmSignal(void *tharg) {
|
|
||||||
// Block the signal
|
static void *taosProcessAlarmSignal(void *tharg) {
|
||||||
|
// Block the signal
|
||||||
sigset_t sigset;
|
sigset_t sigset;
|
||||||
sigemptyset(&sigset);
|
sigemptyset(&sigset);
|
||||||
sigaddset(&sigset, SIGALRM);
|
sigaddset(&sigset, SIGALRM);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue