Merge branch '3.0' into fix/TD-15257
This commit is contained in:
commit
9c2af3dd96
|
@ -130,6 +130,9 @@ def pre_test(){
|
||||||
def pre_test_win(){
|
def pre_test_win(){
|
||||||
bat '''
|
bat '''
|
||||||
hostname
|
hostname
|
||||||
|
taskkill /f /t /im python.exe
|
||||||
|
taskkill /f /t /im bash.exe
|
||||||
|
taskkill /f /t /im taosd.exe
|
||||||
ipconfig
|
ipconfig
|
||||||
set
|
set
|
||||||
date /t
|
date /t
|
||||||
|
|
|
@ -206,8 +206,8 @@ Note: InfluxDB token authorization is not supported at present. Only Basic autho
|
||||||
You can use any client that supports the http protocol to access the RESTful interface address `http://<fqdn>:6041/<APIEndPoint>` to write data in OpenTSDB compatible format to TDengine.
|
You can use any client that supports the http protocol to access the RESTful interface address `http://<fqdn>:6041/<APIEndPoint>` to write data in OpenTSDB compatible format to TDengine.
|
||||||
|
|
||||||
```text
|
```text
|
||||||
/opentsdb/v1/put/json/:db
|
/opentsdb/v1/put/json/<db>
|
||||||
/opentsdb/v1/put/telnet/:db
|
/opentsdb/v1/put/telnet/<db>
|
||||||
```
|
```
|
||||||
|
|
||||||
### collectd
|
### collectd
|
||||||
|
|
|
@ -207,8 +207,8 @@ AllowWebSockets
|
||||||
您可以使用任何支持 http 协议的客户端访问 Restful 接口地址 `http://<fqdn>:6041/<APIEndPoint>` 来写入 OpenTSDB 兼容格式的数据到 TDengine。EndPoint 如下:
|
您可以使用任何支持 http 协议的客户端访问 Restful 接口地址 `http://<fqdn>:6041/<APIEndPoint>` 来写入 OpenTSDB 兼容格式的数据到 TDengine。EndPoint 如下:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
/opentsdb/v1/put/json/:db
|
/opentsdb/v1/put/json/<db>
|
||||||
/opentsdb/v1/put/telnet/:db
|
/opentsdb/v1/put/telnet/<db>
|
||||||
```
|
```
|
||||||
|
|
||||||
### collectd
|
### collectd
|
||||||
|
|
|
@ -199,7 +199,7 @@ tmq_t* build_consumer() {
|
||||||
tmq_conf_set(conf, "msg.with.table.name", "true");
|
tmq_conf_set(conf, "msg.with.table.name", "true");
|
||||||
tmq_conf_set(conf, "enable.auto.commit", "true");
|
tmq_conf_set(conf, "enable.auto.commit", "true");
|
||||||
|
|
||||||
tmq_conf_set(conf, "experiment.use.snapshot", "false");
|
tmq_conf_set(conf, "experimental.snapshot.enable", "true");
|
||||||
|
|
||||||
tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL);
|
tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL);
|
||||||
tmq_t* tmq = tmq_consumer_new(conf, NULL, 0);
|
tmq_t* tmq = tmq_consumer_new(conf, NULL, 0);
|
||||||
|
|
|
@ -235,6 +235,7 @@ SColumnInfoData* bdGetColumnInfoData(SSDataBlock* pBlock, int32_t index);
|
||||||
void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols, int8_t needCompress);
|
void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols, int8_t needCompress);
|
||||||
const char* blockDecode(SSDataBlock* pBlock, int32_t numOfCols, int32_t numOfRows, const char* pData);
|
const char* blockDecode(SSDataBlock* pBlock, int32_t numOfCols, int32_t numOfRows, const char* pData);
|
||||||
|
|
||||||
|
void blockDebugShowDataBlock(SSDataBlock* pBlock, const char* flag);
|
||||||
void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag);
|
void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag);
|
||||||
// for debug
|
// for debug
|
||||||
char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** dumpBuf);
|
char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** dumpBuf);
|
||||||
|
|
|
@ -436,15 +436,16 @@ typedef struct {
|
||||||
int32_t ttl;
|
int32_t ttl;
|
||||||
int32_t numOfColumns;
|
int32_t numOfColumns;
|
||||||
int32_t numOfTags;
|
int32_t numOfTags;
|
||||||
|
int32_t numOfFuncs;
|
||||||
int32_t commentLen;
|
int32_t commentLen;
|
||||||
int32_t ast1Len;
|
int32_t ast1Len;
|
||||||
int32_t ast2Len;
|
int32_t ast2Len;
|
||||||
SArray* pColumns; // array of SField
|
SArray* pColumns; // array of SField
|
||||||
SArray* pTags; // array of SField
|
SArray* pTags; // array of SField
|
||||||
char* comment;
|
SArray* pFuncs;
|
||||||
|
char* pComment;
|
||||||
char* pAst1;
|
char* pAst1;
|
||||||
char* pAst2;
|
char* pAst2;
|
||||||
SArray* pFuncs;
|
|
||||||
} SMCreateStbReq;
|
} SMCreateStbReq;
|
||||||
|
|
||||||
int32_t tSerializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq);
|
int32_t tSerializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq);
|
||||||
|
@ -1495,6 +1496,7 @@ typedef struct SSubQueryMsg {
|
||||||
uint64_t queryId;
|
uint64_t queryId;
|
||||||
uint64_t taskId;
|
uint64_t taskId;
|
||||||
int64_t refId;
|
int64_t refId;
|
||||||
|
int32_t execId;
|
||||||
int8_t taskType;
|
int8_t taskType;
|
||||||
int8_t explain;
|
int8_t explain;
|
||||||
uint32_t sqlLen; // the query sql,
|
uint32_t sqlLen; // the query sql,
|
||||||
|
@ -1514,6 +1516,7 @@ typedef struct {
|
||||||
uint64_t sId;
|
uint64_t sId;
|
||||||
uint64_t queryId;
|
uint64_t queryId;
|
||||||
uint64_t taskId;
|
uint64_t taskId;
|
||||||
|
int32_t execId;
|
||||||
} SQueryContinueReq;
|
} SQueryContinueReq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -1535,6 +1538,7 @@ typedef struct {
|
||||||
uint64_t sId;
|
uint64_t sId;
|
||||||
uint64_t queryId;
|
uint64_t queryId;
|
||||||
uint64_t taskId;
|
uint64_t taskId;
|
||||||
|
int32_t execId;
|
||||||
} SResFetchReq;
|
} SResFetchReq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -1546,6 +1550,7 @@ typedef struct {
|
||||||
uint64_t queryId;
|
uint64_t queryId;
|
||||||
uint64_t taskId;
|
uint64_t taskId;
|
||||||
int64_t refId;
|
int64_t refId;
|
||||||
|
int32_t execId;
|
||||||
int8_t status;
|
int8_t status;
|
||||||
} STaskStatus;
|
} STaskStatus;
|
||||||
|
|
||||||
|
@ -1591,6 +1596,7 @@ typedef struct {
|
||||||
uint64_t queryId;
|
uint64_t queryId;
|
||||||
uint64_t taskId;
|
uint64_t taskId;
|
||||||
int64_t refId;
|
int64_t refId;
|
||||||
|
int32_t execId;
|
||||||
} STaskCancelReq;
|
} STaskCancelReq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -1603,6 +1609,7 @@ typedef struct {
|
||||||
uint64_t queryId;
|
uint64_t queryId;
|
||||||
uint64_t taskId;
|
uint64_t taskId;
|
||||||
int64_t refId;
|
int64_t refId;
|
||||||
|
int32_t execId;
|
||||||
} STaskDropReq;
|
} STaskDropReq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -1623,6 +1630,7 @@ typedef struct {
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t maxDelay;
|
int64_t maxDelay;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
|
int8_t igExpired;
|
||||||
} SCMCreateStreamReq;
|
} SCMCreateStreamReq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -167,10 +167,6 @@ enum {
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_VND_MSG)
|
TD_NEW_MSG_SEG(TDMT_VND_MSG)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_QUERY, "query", NULL, NULL)
|
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_QUERY_CONTINUE, "query-continue", NULL, NULL)
|
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_QUERY_HEARTBEAT, "query-heartbeat", NULL, NULL)
|
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_FETCH, "fetch", NULL, NULL)
|
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_TABLE, "create-table", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_TABLE, "create-table", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_TABLE, "alter-table", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_TABLE, "alter-table", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_TABLE, "drop-table", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_DROP_TABLE, "drop-table", NULL, NULL)
|
||||||
|
@ -184,12 +180,9 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_MQ_VG_CHANGE, "vnode-mq-vg-change", SMqRebVgReq, SMqRebVgRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_MQ_VG_CHANGE, "vnode-mq-vg-change", SMqRebVgReq, SMqRebVgRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_MQ_VG_DELETE, "vnode-mq-vg-delete", SMqVDeleteReq, SMqVDeleteRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_MQ_VG_DELETE, "vnode-mq-vg-delete", SMqVDeleteReq, SMqVDeleteRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_MQ_COMMIT_OFFSET, "vnode-commit-offset", STqOffset, STqOffset)
|
TD_DEF_MSG_TYPE(TDMT_VND_MQ_COMMIT_OFFSET, "vnode-commit-offset", STqOffset, STqOffset)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_TASK, "vnode-cancel-task", NULL, NULL)
|
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_TASK, "vnode-drop-task", NULL, NULL)
|
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_TOPIC, "vnode-create-topic", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_TOPIC, "vnode-create-topic", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_TOPIC, "vnode-alter-topic", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_TOPIC, "vnode-alter-topic", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_TOPIC, "vnode-drop-topic", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_DROP_TOPIC, "vnode-drop-topic", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_EXPLAIN, "vnode-explain", NULL, NULL)
|
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_SUBSCRIBE, "vnode-subscribe", SMVSubscribeReq, SMVSubscribeRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_SUBSCRIBE, "vnode-subscribe", SMVSubscribeReq, SMVSubscribeRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CONSUME, "vnode-consume", SMqPollReq, SMqDataBlkRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_CONSUME, "vnode-consume", SMqPollReq, SMqDataBlkRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TRIGGER, "vnode-stream-trigger", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TRIGGER, "vnode-stream-trigger", NULL, NULL)
|
||||||
|
@ -206,6 +199,17 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_COMPACT, "compact", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_COMPACT, "compact", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_TTL_TABLE, "drop-ttl-stb", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_DROP_TTL_TABLE, "drop-ttl-stb", NULL, NULL)
|
||||||
|
|
||||||
|
TD_NEW_MSG_SEG(TDMT_SCH_MSG)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SCH_QUERY, "query", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SCH_MERGE_QUERY, "merge-query", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SCH_QUERY_CONTINUE, "query-continue", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SCH_QUERY_HEARTBEAT, "query-heartbeat", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SCH_FETCH, "fetch", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SCH_CANCEL_TASK, "cancel-task", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SCH_DROP_TASK, "drop-task", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SCH_EXPLAIN, "explain", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SCH_LINK_BROKEN, "link-broken", NULL, NULL)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_STREAM_MSG)
|
TD_NEW_MSG_SEG(TDMT_STREAM_MSG)
|
||||||
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_DEPLOY, "stream-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp)
|
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_DEPLOY, "stream-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_DROP, "stream-task-drop", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_DROP, "stream-task-drop", NULL, NULL)
|
||||||
|
@ -214,9 +218,6 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_RECOVER, "stream-task-recover", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_RECOVER, "stream-task-recover", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_STREAM_RETRIEVE, "stream-retrieve", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_STREAM_RETRIEVE, "stream-retrieve", NULL, NULL)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_SCH_MSG)
|
|
||||||
TD_DEF_MSG_TYPE(TDMT_SCH_LINK_BROKEN, "link-broken", NULL, NULL)
|
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_MON_MSG)
|
TD_NEW_MSG_SEG(TDMT_MON_MSG)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MON_MM_INFO, "monitor-minfo", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MON_MM_INFO, "monitor-minfo", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MON_VM_INFO, "monitor-vinfo", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MON_VM_INFO, "monitor-vinfo", NULL, NULL)
|
||||||
|
@ -232,10 +233,12 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_PING, "sync-ping", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_PING, "sync-ping", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_PING_REPLY, "sync-ping-reply", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_PING_REPLY, "sync-ping-reply", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST, "sync-client-request", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST, "sync-client-request", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST_BATCH, "sync-client-request-batch", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST_REPLY, "sync-client-request-reply", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST_REPLY, "sync-client-request-reply", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_REQUEST_VOTE, "sync-request-vote", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_REQUEST_VOTE, "sync-request-vote", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_REQUEST_VOTE_REPLY, "sync-request-vote-reply", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_REQUEST_VOTE_REPLY, "sync-request-vote-reply", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_APPEND_ENTRIES, "sync-append-entries", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_APPEND_ENTRIES, "sync-append-entries", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SYNC_APPEND_ENTRIES_BATCH, "sync-append-entries-batch", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_APPEND_ENTRIES_REPLY, "sync-append-entries-reply", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_APPEND_ENTRIES_REPLY, "sync-append-entries-reply", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_NOOP, "sync-noop", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_NOOP, "sync-noop", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_UNKNOWN, "sync-unknown", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_UNKNOWN, "sync-unknown", NULL, NULL)
|
||||||
|
|
|
@ -192,79 +192,81 @@
|
||||||
#define TK_TRIGGER 174
|
#define TK_TRIGGER 174
|
||||||
#define TK_AT_ONCE 175
|
#define TK_AT_ONCE 175
|
||||||
#define TK_WINDOW_CLOSE 176
|
#define TK_WINDOW_CLOSE 176
|
||||||
#define TK_KILL 177
|
#define TK_IGNORE 177
|
||||||
#define TK_CONNECTION 178
|
#define TK_EXPIRED 178
|
||||||
#define TK_TRANSACTION 179
|
#define TK_KILL 179
|
||||||
#define TK_BALANCE 180
|
#define TK_CONNECTION 180
|
||||||
#define TK_VGROUP 181
|
#define TK_TRANSACTION 181
|
||||||
#define TK_MERGE 182
|
#define TK_BALANCE 182
|
||||||
#define TK_REDISTRIBUTE 183
|
#define TK_VGROUP 183
|
||||||
#define TK_SPLIT 184
|
#define TK_MERGE 184
|
||||||
#define TK_SYNCDB 185
|
#define TK_REDISTRIBUTE 185
|
||||||
#define TK_DELETE 186
|
#define TK_SPLIT 186
|
||||||
#define TK_NULL 187
|
#define TK_SYNCDB 187
|
||||||
#define TK_NK_QUESTION 188
|
#define TK_DELETE 188
|
||||||
#define TK_NK_ARROW 189
|
#define TK_NULL 189
|
||||||
#define TK_ROWTS 190
|
#define TK_NK_QUESTION 190
|
||||||
#define TK_TBNAME 191
|
#define TK_NK_ARROW 191
|
||||||
#define TK_QSTARTTS 192
|
#define TK_ROWTS 192
|
||||||
#define TK_QENDTS 193
|
#define TK_TBNAME 193
|
||||||
#define TK_WSTARTTS 194
|
#define TK_QSTARTTS 194
|
||||||
#define TK_WENDTS 195
|
#define TK_QENDTS 195
|
||||||
#define TK_WDURATION 196
|
#define TK_WSTARTTS 196
|
||||||
#define TK_CAST 197
|
#define TK_WENDTS 197
|
||||||
#define TK_NOW 198
|
#define TK_WDURATION 198
|
||||||
#define TK_TODAY 199
|
#define TK_CAST 199
|
||||||
#define TK_TIMEZONE 200
|
#define TK_NOW 200
|
||||||
#define TK_CLIENT_VERSION 201
|
#define TK_TODAY 201
|
||||||
#define TK_SERVER_VERSION 202
|
#define TK_TIMEZONE 202
|
||||||
#define TK_SERVER_STATUS 203
|
#define TK_CLIENT_VERSION 203
|
||||||
#define TK_CURRENT_USER 204
|
#define TK_SERVER_VERSION 204
|
||||||
#define TK_COUNT 205
|
#define TK_SERVER_STATUS 205
|
||||||
#define TK_LAST_ROW 206
|
#define TK_CURRENT_USER 206
|
||||||
#define TK_BETWEEN 207
|
#define TK_COUNT 207
|
||||||
#define TK_IS 208
|
#define TK_LAST_ROW 208
|
||||||
#define TK_NK_LT 209
|
#define TK_BETWEEN 209
|
||||||
#define TK_NK_GT 210
|
#define TK_IS 210
|
||||||
#define TK_NK_LE 211
|
#define TK_NK_LT 211
|
||||||
#define TK_NK_GE 212
|
#define TK_NK_GT 212
|
||||||
#define TK_NK_NE 213
|
#define TK_NK_LE 213
|
||||||
#define TK_MATCH 214
|
#define TK_NK_GE 214
|
||||||
#define TK_NMATCH 215
|
#define TK_NK_NE 215
|
||||||
#define TK_CONTAINS 216
|
#define TK_MATCH 216
|
||||||
#define TK_JOIN 217
|
#define TK_NMATCH 217
|
||||||
#define TK_INNER 218
|
#define TK_CONTAINS 218
|
||||||
#define TK_SELECT 219
|
#define TK_JOIN 219
|
||||||
#define TK_DISTINCT 220
|
#define TK_INNER 220
|
||||||
#define TK_WHERE 221
|
#define TK_SELECT 221
|
||||||
#define TK_PARTITION 222
|
#define TK_DISTINCT 222
|
||||||
#define TK_BY 223
|
#define TK_WHERE 223
|
||||||
#define TK_SESSION 224
|
#define TK_PARTITION 224
|
||||||
#define TK_STATE_WINDOW 225
|
#define TK_BY 225
|
||||||
#define TK_SLIDING 226
|
#define TK_SESSION 226
|
||||||
#define TK_FILL 227
|
#define TK_STATE_WINDOW 227
|
||||||
#define TK_VALUE 228
|
#define TK_SLIDING 228
|
||||||
#define TK_NONE 229
|
#define TK_FILL 229
|
||||||
#define TK_PREV 230
|
#define TK_VALUE 230
|
||||||
#define TK_LINEAR 231
|
#define TK_NONE 231
|
||||||
#define TK_NEXT 232
|
#define TK_PREV 232
|
||||||
#define TK_HAVING 233
|
#define TK_LINEAR 233
|
||||||
#define TK_RANGE 234
|
#define TK_NEXT 234
|
||||||
#define TK_EVERY 235
|
#define TK_HAVING 235
|
||||||
#define TK_ORDER 236
|
#define TK_RANGE 236
|
||||||
#define TK_SLIMIT 237
|
#define TK_EVERY 237
|
||||||
#define TK_SOFFSET 238
|
#define TK_ORDER 238
|
||||||
#define TK_LIMIT 239
|
#define TK_SLIMIT 239
|
||||||
#define TK_OFFSET 240
|
#define TK_SOFFSET 240
|
||||||
#define TK_ASC 241
|
#define TK_LIMIT 241
|
||||||
#define TK_NULLS 242
|
#define TK_OFFSET 242
|
||||||
#define TK_ID 243
|
#define TK_ASC 243
|
||||||
#define TK_NK_BITNOT 244
|
#define TK_NULLS 244
|
||||||
#define TK_INSERT 245
|
#define TK_ID 245
|
||||||
#define TK_VALUES 246
|
#define TK_NK_BITNOT 246
|
||||||
#define TK_IMPORT 247
|
#define TK_INSERT 247
|
||||||
#define TK_NK_SEMI 248
|
#define TK_VALUES 248
|
||||||
#define TK_FILE 249
|
#define TK_IMPORT 249
|
||||||
|
#define TK_NK_SEMI 250
|
||||||
|
#define TK_FILE 251
|
||||||
|
|
||||||
#define TK_NK_SPACE 300
|
#define TK_NK_SPACE 300
|
||||||
#define TK_NK_COMMENT 301
|
#define TK_NK_COMMENT 301
|
||||||
|
|
|
@ -36,6 +36,7 @@ typedef struct SReadHandle {
|
||||||
void* vnode;
|
void* vnode;
|
||||||
void* mnd;
|
void* mnd;
|
||||||
SMsgCb* pMsgCb;
|
SMsgCb* pMsgCb;
|
||||||
|
bool tqReader;
|
||||||
} SReadHandle;
|
} SReadHandle;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -133,7 +134,6 @@ int32_t qKillTask(qTaskInfo_t tinfo);
|
||||||
*/
|
*/
|
||||||
int32_t qAsyncKillTask(qTaskInfo_t tinfo);
|
int32_t qAsyncKillTask(qTaskInfo_t tinfo);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* destroy query info structure
|
* destroy query info structure
|
||||||
* @param qHandle
|
* @param qHandle
|
||||||
|
@ -172,6 +172,8 @@ int32_t qDeserializeTaskStatus(qTaskInfo_t tinfo, const char* pInput, int32_t le
|
||||||
*/
|
*/
|
||||||
int32_t qGetStreamScanStatus(qTaskInfo_t tinfo, uint64_t* uid, int64_t* ts);
|
int32_t qGetStreamScanStatus(qTaskInfo_t tinfo, uint64_t* uid, int64_t* ts);
|
||||||
|
|
||||||
|
int32_t qStreamPrepareScan(qTaskInfo_t tinfo, uint64_t uid, int64_t ts);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -34,6 +34,7 @@ typedef enum EFunctionType {
|
||||||
FUNCTION_TYPE_ELAPSED,
|
FUNCTION_TYPE_ELAPSED,
|
||||||
FUNCTION_TYPE_IRATE,
|
FUNCTION_TYPE_IRATE,
|
||||||
FUNCTION_TYPE_LAST_ROW,
|
FUNCTION_TYPE_LAST_ROW,
|
||||||
|
FUNCTION_TYPE_LAST_ROWT, //TODO: removed
|
||||||
FUNCTION_TYPE_MAX,
|
FUNCTION_TYPE_MAX,
|
||||||
FUNCTION_TYPE_MIN,
|
FUNCTION_TYPE_MIN,
|
||||||
FUNCTION_TYPE_MODE,
|
FUNCTION_TYPE_MODE,
|
||||||
|
|
|
@ -338,6 +338,7 @@ typedef struct SStreamOptions {
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
SNode* pDelay;
|
SNode* pDelay;
|
||||||
SNode* pWatermark;
|
SNode* pWatermark;
|
||||||
|
bool ignoreExpired;
|
||||||
} SStreamOptions;
|
} SStreamOptions;
|
||||||
|
|
||||||
typedef struct SCreateStreamStmt {
|
typedef struct SCreateStreamStmt {
|
||||||
|
|
|
@ -73,8 +73,7 @@ typedef struct SScanLogicNode {
|
||||||
SNode* pTagIndexCond;
|
SNode* pTagIndexCond;
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
int16_t tsColId;
|
int8_t igExpired;
|
||||||
double filesFactor;
|
|
||||||
SArray* pSmaIndexes;
|
SArray* pSmaIndexes;
|
||||||
SNodeList* pGroupTags;
|
SNodeList* pGroupTags;
|
||||||
bool groupSort;
|
bool groupSort;
|
||||||
|
@ -175,7 +174,7 @@ typedef struct SWindowLogicNode {
|
||||||
SNode* pStateExpr;
|
SNode* pStateExpr;
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
double filesFactor;
|
int8_t igExpired;
|
||||||
EWindowAlgorithm windowAlgo;
|
EWindowAlgorithm windowAlgo;
|
||||||
} SWindowLogicNode;
|
} SWindowLogicNode;
|
||||||
|
|
||||||
|
@ -296,8 +295,7 @@ typedef struct STableScanPhysiNode {
|
||||||
int8_t slidingUnit;
|
int8_t slidingUnit;
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
int16_t tsColId;
|
int8_t igExpired;
|
||||||
double filesFactor;
|
|
||||||
} STableScanPhysiNode;
|
} STableScanPhysiNode;
|
||||||
|
|
||||||
typedef STableScanPhysiNode STableSeqScanPhysiNode;
|
typedef STableScanPhysiNode STableSeqScanPhysiNode;
|
||||||
|
@ -347,6 +345,7 @@ typedef struct SDownstreamSourceNode {
|
||||||
SQueryNodeAddr addr;
|
SQueryNodeAddr addr;
|
||||||
uint64_t taskId;
|
uint64_t taskId;
|
||||||
uint64_t schedId;
|
uint64_t schedId;
|
||||||
|
int32_t execId;
|
||||||
} SDownstreamSourceNode;
|
} SDownstreamSourceNode;
|
||||||
|
|
||||||
typedef struct SExchangePhysiNode {
|
typedef struct SExchangePhysiNode {
|
||||||
|
@ -373,7 +372,7 @@ typedef struct SWinodwPhysiNode {
|
||||||
SNode* pTsEnd; // window end timestamp
|
SNode* pTsEnd; // window end timestamp
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
double filesFactor;
|
int8_t igExpired;
|
||||||
} SWinodwPhysiNode;
|
} SWinodwPhysiNode;
|
||||||
|
|
||||||
typedef struct SIntervalPhysiNode {
|
typedef struct SIntervalPhysiNode {
|
||||||
|
|
|
@ -34,6 +34,7 @@ typedef struct SPlanContext {
|
||||||
bool showRewrite;
|
bool showRewrite;
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
|
int8_t igExpired;
|
||||||
char* pMsg;
|
char* pMsg;
|
||||||
int32_t msgLen;
|
int32_t msgLen;
|
||||||
const char* pUser;
|
const char* pUser;
|
||||||
|
|
|
@ -135,9 +135,11 @@ typedef struct STableMetaOutput {
|
||||||
} STableMetaOutput;
|
} STableMetaOutput;
|
||||||
|
|
||||||
typedef struct SDataBuf {
|
typedef struct SDataBuf {
|
||||||
|
int32_t msgType;
|
||||||
void* pData;
|
void* pData;
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
void* handle;
|
void* handle;
|
||||||
|
SEpSet* pEpSet;
|
||||||
} SDataBuf;
|
} SDataBuf;
|
||||||
|
|
||||||
typedef struct STargetInfo {
|
typedef struct STargetInfo {
|
||||||
|
@ -146,7 +148,7 @@ typedef struct STargetInfo {
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
} STargetInfo;
|
} STargetInfo;
|
||||||
|
|
||||||
typedef int32_t (*__async_send_cb_fn_t)(void* param, const SDataBuf* pMsg, int32_t code);
|
typedef int32_t (*__async_send_cb_fn_t)(void* param, SDataBuf* pMsg, int32_t code);
|
||||||
typedef int32_t (*__async_exec_fn_t)(void* param);
|
typedef int32_t (*__async_exec_fn_t)(void* param);
|
||||||
|
|
||||||
typedef struct SRequestConnInfo {
|
typedef struct SRequestConnInfo {
|
||||||
|
@ -234,13 +236,25 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
||||||
#define NEED_CLIENT_HANDLE_ERROR(_code) \
|
#define NEED_CLIENT_HANDLE_ERROR(_code) \
|
||||||
(NEED_CLIENT_RM_TBLMETA_ERROR(_code) || NEED_CLIENT_REFRESH_VG_ERROR(_code) || \
|
(NEED_CLIENT_RM_TBLMETA_ERROR(_code) || NEED_CLIENT_REFRESH_VG_ERROR(_code) || \
|
||||||
NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code))
|
NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code))
|
||||||
|
#define NEED_REDIRECT_ERROR(_code) \
|
||||||
|
((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || \
|
||||||
|
(_code) == TSDB_CODE_NODE_NOT_DEPLOYED || (_code) == TSDB_CODE_SYN_NOT_LEADER || \
|
||||||
|
(_code) == TSDB_CODE_APP_NOT_READY || (_code) == TSDB_CODE_RPC_BROKEN_LINK)
|
||||||
|
|
||||||
#define NEED_CLIENT_RM_TBLMETA_REQ(_type) \
|
#define NEED_CLIENT_RM_TBLMETA_REQ(_type) \
|
||||||
((_type) == TDMT_VND_CREATE_TABLE || (_type) == TDMT_VND_CREATE_STB || (_type) == TDMT_VND_DROP_TABLE || \
|
((_type) == TDMT_VND_CREATE_TABLE || (_type) == TDMT_VND_CREATE_STB || (_type) == TDMT_VND_DROP_TABLE || \
|
||||||
(_type) == TDMT_VND_DROP_STB)
|
(_type) == TDMT_VND_DROP_STB)
|
||||||
|
|
||||||
#define NEED_SCHEDULER_RETRY_ERROR(_code) \
|
#define NEED_SCHEDULER_REDIRECT_ERROR(_code) \
|
||||||
((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || \
|
((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_NODE_NOT_DEPLOYED || \
|
||||||
(_code) == TSDB_CODE_SCH_TIMEOUT_ERROR)
|
(_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_APP_NOT_READY)
|
||||||
|
|
||||||
|
#define NEED_SCHEDULER_RETRY_ERROR(_code) \
|
||||||
|
(NEED_SCHEDULER_REDIRECT_ERROR(_code) || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || \
|
||||||
|
(_code) == TSDB_CODE_SCH_TIMEOUT_ERROR || (_code) == TSDB_CODE_RPC_BROKEN_LINK)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define REQUEST_TOTAL_EXEC_TIMES 2
|
#define REQUEST_TOTAL_EXEC_TIMES 2
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ extern "C" {
|
||||||
|
|
||||||
extern bool gRaftDetailLog;
|
extern bool gRaftDetailLog;
|
||||||
|
|
||||||
|
#define SYNC_MAX_BATCH_SIZE 100
|
||||||
#define SYNC_INDEX_BEGIN 0
|
#define SYNC_INDEX_BEGIN 0
|
||||||
#define SYNC_INDEX_INVALID -1
|
#define SYNC_INDEX_INVALID -1
|
||||||
#define SYNC_TERM_INVALID 0xFFFFFFFFFFFFFFFF
|
#define SYNC_TERM_INVALID 0xFFFFFFFFFFFFFFFF
|
||||||
|
@ -120,7 +121,7 @@ typedef struct SSyncFSM {
|
||||||
int32_t (*FpGetSnapshot)(struct SSyncFSM* pFsm, SSnapshot* pSnapshot, void* pReaderParam, void** ppReader);
|
int32_t (*FpGetSnapshot)(struct SSyncFSM* pFsm, SSnapshot* pSnapshot, void* pReaderParam, void** ppReader);
|
||||||
int32_t (*FpGetSnapshotInfo)(struct SSyncFSM* pFsm, SSnapshot* pSnapshot);
|
int32_t (*FpGetSnapshotInfo)(struct SSyncFSM* pFsm, SSnapshot* pSnapshot);
|
||||||
|
|
||||||
int32_t (*FpSnapshotStartRead)(struct SSyncFSM* pFsm, void** ppReader);
|
int32_t (*FpSnapshotStartRead)(struct SSyncFSM* pFsm, void* pReaderParam, void** ppReader);
|
||||||
int32_t (*FpSnapshotStopRead)(struct SSyncFSM* pFsm, void* pReader);
|
int32_t (*FpSnapshotStopRead)(struct SSyncFSM* pFsm, void* pReader);
|
||||||
int32_t (*FpSnapshotDoRead)(struct SSyncFSM* pFsm, void* pReader, void** ppBuf, int32_t* len);
|
int32_t (*FpSnapshotDoRead)(struct SSyncFSM* pFsm, void* pReader, void** ppBuf, int32_t* len);
|
||||||
|
|
||||||
|
@ -164,6 +165,7 @@ typedef struct SSyncLogStore {
|
||||||
bool (*syncLogIsEmpty)(struct SSyncLogStore* pLogStore);
|
bool (*syncLogIsEmpty)(struct SSyncLogStore* pLogStore);
|
||||||
int32_t (*syncLogEntryCount)(struct SSyncLogStore* pLogStore);
|
int32_t (*syncLogEntryCount)(struct SSyncLogStore* pLogStore);
|
||||||
int32_t (*syncLogRestoreFromSnapshot)(struct SSyncLogStore* pLogStore, SyncIndex index);
|
int32_t (*syncLogRestoreFromSnapshot)(struct SSyncLogStore* pLogStore, SyncIndex index);
|
||||||
|
bool (*syncLogExist)(struct SSyncLogStore* pLogStore, SyncIndex index);
|
||||||
|
|
||||||
SyncIndex (*syncLogWriteIndex)(struct SSyncLogStore* pLogStore);
|
SyncIndex (*syncLogWriteIndex)(struct SSyncLogStore* pLogStore);
|
||||||
SyncIndex (*syncLogLastIndex)(struct SSyncLogStore* pLogStore);
|
SyncIndex (*syncLogLastIndex)(struct SSyncLogStore* pLogStore);
|
||||||
|
@ -179,6 +181,7 @@ typedef struct SSyncInfo {
|
||||||
bool isStandBy;
|
bool isStandBy;
|
||||||
bool snapshotEnable;
|
bool snapshotEnable;
|
||||||
SyncGroupId vgId;
|
SyncGroupId vgId;
|
||||||
|
int32_t batchSize;
|
||||||
SSyncCfg syncCfg;
|
SSyncCfg syncCfg;
|
||||||
char path[TSDB_FILENAME_LEN];
|
char path[TSDB_FILENAME_LEN];
|
||||||
SWal* pWal;
|
SWal* pWal;
|
||||||
|
@ -202,6 +205,7 @@ SyncGroupId syncGetVgId(int64_t rid);
|
||||||
void syncGetEpSet(int64_t rid, SEpSet* pEpSet);
|
void syncGetEpSet(int64_t rid, SEpSet* pEpSet);
|
||||||
void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet);
|
void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet);
|
||||||
int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak);
|
int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak);
|
||||||
|
// int32_t syncProposeBatch(int64_t rid, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize);
|
||||||
bool syncEnvIsStart();
|
bool syncEnvIsStart();
|
||||||
const char* syncStr(ESyncState state);
|
const char* syncStr(ESyncState state);
|
||||||
bool syncIsRestoreFinish(int64_t rid);
|
bool syncIsRestoreFinish(int64_t rid);
|
||||||
|
|
|
@ -219,6 +219,34 @@ void syncClientRequestPrint2(char* s, const SyncClientRequest* pMsg);
|
||||||
void syncClientRequestLog(const SyncClientRequest* pMsg);
|
void syncClientRequestLog(const SyncClientRequest* pMsg);
|
||||||
void syncClientRequestLog2(char* s, const SyncClientRequest* pMsg);
|
void syncClientRequestLog2(char* s, const SyncClientRequest* pMsg);
|
||||||
|
|
||||||
|
// ---------------------------------------------
|
||||||
|
typedef struct SOffsetAndContLen {
|
||||||
|
int32_t offset;
|
||||||
|
int32_t contLen;
|
||||||
|
} SOffsetAndContLen;
|
||||||
|
|
||||||
|
typedef struct SRaftMeta {
|
||||||
|
uint64_t seqNum;
|
||||||
|
bool isWeak;
|
||||||
|
} SRaftMeta;
|
||||||
|
|
||||||
|
// block1:
|
||||||
|
// block2: SRaftMeta array
|
||||||
|
// block3: rpc msg array (with pCont)
|
||||||
|
|
||||||
|
typedef struct SyncClientRequestBatch {
|
||||||
|
uint32_t bytes;
|
||||||
|
int32_t vgId;
|
||||||
|
uint32_t msgType; // SyncClientRequestBatch msgType
|
||||||
|
uint32_t dataCount;
|
||||||
|
uint32_t dataLen; // user RpcMsg.contLen
|
||||||
|
char data[]; // user RpcMsg.pCont
|
||||||
|
} SyncClientRequestBatch;
|
||||||
|
|
||||||
|
SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg* rpcMsgArr, SRaftMeta* raftArr, int32_t arrSize,
|
||||||
|
int32_t vgId);
|
||||||
|
void syncClientRequestBatch2RpcMsg(const SyncClientRequestBatch* pSyncMsg, SRpcMsg* pRpcMsg);
|
||||||
|
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
typedef struct SyncClientRequestReply {
|
typedef struct SyncClientRequestReply {
|
||||||
uint32_t bytes;
|
uint32_t bytes;
|
||||||
|
@ -325,22 +353,53 @@ void syncAppendEntriesLog(const SyncAppendEntries* pMsg);
|
||||||
void syncAppendEntriesLog2(char* s, const SyncAppendEntries* pMsg);
|
void syncAppendEntriesLog2(char* s, const SyncAppendEntries* pMsg);
|
||||||
|
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
|
|
||||||
|
// define ahead
|
||||||
|
/*
|
||||||
|
typedef struct SOffsetAndContLen {
|
||||||
|
int32_t offset;
|
||||||
|
int32_t contLen;
|
||||||
|
} SOffsetAndContLen;
|
||||||
|
*/
|
||||||
|
|
||||||
typedef struct SyncAppendEntriesBatch {
|
typedef struct SyncAppendEntriesBatch {
|
||||||
uint32_t bytes;
|
uint32_t bytes;
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
uint32_t msgType;
|
uint32_t msgType;
|
||||||
SRaftId srcId;
|
SRaftId srcId;
|
||||||
SRaftId destId;
|
SRaftId destId;
|
||||||
|
|
||||||
// private data
|
// private data
|
||||||
SyncTerm term;
|
SyncTerm term;
|
||||||
SyncIndex prevLogIndex;
|
SyncIndex prevLogIndex;
|
||||||
SyncTerm prevLogTerm;
|
SyncTerm prevLogTerm;
|
||||||
SyncIndex commitIndex;
|
SyncIndex commitIndex;
|
||||||
SyncTerm privateTerm;
|
SyncTerm privateTerm;
|
||||||
|
int32_t dataCount;
|
||||||
uint32_t dataLen;
|
uint32_t dataLen;
|
||||||
char data[];
|
char data[];
|
||||||
} SyncAppendEntriesBatch;
|
} SyncAppendEntriesBatch;
|
||||||
|
|
||||||
|
SyncAppendEntriesBatch* syncAppendEntriesBatchBuild(SRpcMsg* rpcMsgArr, int32_t arrSize, int32_t vgId);
|
||||||
|
void syncAppendEntriesBatchDestroy(SyncAppendEntriesBatch* pMsg);
|
||||||
|
void syncAppendEntriesBatchSerialize(const SyncAppendEntriesBatch* pMsg, char* buf, uint32_t bufLen);
|
||||||
|
void syncAppendEntriesBatchDeserialize(const char* buf, uint32_t len, SyncAppendEntriesBatch* pMsg);
|
||||||
|
char* syncAppendEntriesBatchSerialize2(const SyncAppendEntriesBatch* pMsg, uint32_t* len);
|
||||||
|
SyncAppendEntriesBatch* syncAppendEntriesBatchDeserialize2(const char* buf, uint32_t len);
|
||||||
|
void syncAppendEntriesBatch2RpcMsg(const SyncAppendEntriesBatch* pMsg, SRpcMsg* pRpcMsg);
|
||||||
|
void syncAppendEntriesBatchFromRpcMsg(const SRpcMsg* pRpcMsg, SyncAppendEntriesBatch* pMsg);
|
||||||
|
SyncAppendEntriesBatch* syncAppendEntriesBatchFromRpcMsg2(const SRpcMsg* pRpcMsg);
|
||||||
|
cJSON* syncAppendEntriesBatch2Json(const SyncAppendEntriesBatch* pMsg);
|
||||||
|
char* syncAppendEntriesBatch2Str(const SyncAppendEntriesBatch* pMsg);
|
||||||
|
void syncAppendEntriesBatch2RpcMsgArray(SyncAppendEntriesBatch* pSyncMsg, SRpcMsg* rpcMsgArr, int32_t maxArrSize,
|
||||||
|
int32_t* pRetArrSize);
|
||||||
|
|
||||||
|
// for debug ----------------------
|
||||||
|
void syncAppendEntriesBatchPrint(const SyncAppendEntriesBatch* pMsg);
|
||||||
|
void syncAppendEntriesBatchPrint2(char* s, const SyncAppendEntriesBatch* pMsg);
|
||||||
|
void syncAppendEntriesBatchLog(const SyncAppendEntriesBatch* pMsg);
|
||||||
|
void syncAppendEntriesBatchLog2(char* s, const SyncAppendEntriesBatch* pMsg);
|
||||||
|
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
typedef struct SyncAppendEntriesReply {
|
typedef struct SyncAppendEntriesReply {
|
||||||
uint32_t bytes;
|
uint32_t bytes;
|
||||||
|
@ -542,6 +601,7 @@ int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg);
|
||||||
int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg);
|
int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg);
|
||||||
int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg);
|
int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg);
|
||||||
int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg, SyncIndex* pRetIndex);
|
int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg, SyncIndex* pRetIndex);
|
||||||
|
int32_t syncNodeOnClientRequestBatchCb(SSyncNode* ths, SyncClientRequestBatch* pMsg);
|
||||||
int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg);
|
int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg);
|
||||||
int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg);
|
int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg);
|
||||||
int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg);
|
int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg);
|
||||||
|
|
|
@ -61,45 +61,23 @@ extern "C" {
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define WAL_HEAD_VER 0
|
#define WAL_PROTO_VER 0
|
||||||
#define WAL_NOSUFFIX_LEN 20
|
#define WAL_NOSUFFIX_LEN 20
|
||||||
#define WAL_SUFFIX_AT (WAL_NOSUFFIX_LEN + 1)
|
#define WAL_SUFFIX_AT (WAL_NOSUFFIX_LEN + 1)
|
||||||
#define WAL_LOG_SUFFIX "log"
|
#define WAL_LOG_SUFFIX "log"
|
||||||
#define WAL_INDEX_SUFFIX "idx"
|
#define WAL_INDEX_SUFFIX "idx"
|
||||||
#define WAL_REFRESH_MS 1000
|
#define WAL_REFRESH_MS 1000
|
||||||
#define WAL_MAX_SIZE (TSDB_MAX_WAL_SIZE + sizeof(SWalHead))
|
#define WAL_MAX_SIZE (TSDB_MAX_WAL_SIZE + sizeof(SWalCkHead))
|
||||||
#define WAL_PATH_LEN (TSDB_FILENAME_LEN + 12)
|
#define WAL_PATH_LEN (TSDB_FILENAME_LEN + 12)
|
||||||
#define WAL_FILE_LEN (WAL_PATH_LEN + 32)
|
#define WAL_FILE_LEN (WAL_PATH_LEN + 32)
|
||||||
#define WAL_MAGIC 0xFAFBFCFDULL
|
#define WAL_MAGIC 0xFAFBFCFDULL
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TAOS_WAL_NOLOG = 0,
|
TAOS_WAL_NOLOG = 0,
|
||||||
TAOS_WAL_WRITE = 1,
|
TAOS_WAL_WRITE = 1,
|
||||||
TAOS_WAL_FSYNC = 2,
|
TAOS_WAL_FSYNC = 2,
|
||||||
} EWalType;
|
} EWalType;
|
||||||
|
|
||||||
// used by sync module
|
|
||||||
typedef struct {
|
|
||||||
int8_t isWeek;
|
|
||||||
uint64_t seqNum;
|
|
||||||
uint64_t term;
|
|
||||||
} SSyncLogMeta;
|
|
||||||
|
|
||||||
typedef struct SWalReadHead {
|
|
||||||
int8_t headVer;
|
|
||||||
int8_t reserved;
|
|
||||||
int16_t msgType;
|
|
||||||
int32_t bodyLen;
|
|
||||||
int64_t ingestTs; // not implemented
|
|
||||||
int64_t version;
|
|
||||||
|
|
||||||
// sync meta
|
|
||||||
SSyncLogMeta syncMeta;
|
|
||||||
|
|
||||||
char body[];
|
|
||||||
} SWalReadHead;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
int32_t fsyncPeriod; // millisecond
|
int32_t fsyncPeriod; // millisecond
|
||||||
|
@ -110,13 +88,6 @@ typedef struct {
|
||||||
EWalType level; // wal level
|
EWalType level; // wal level
|
||||||
} SWalCfg;
|
} SWalCfg;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint64_t magic;
|
|
||||||
uint32_t cksumHead;
|
|
||||||
uint32_t cksumBody;
|
|
||||||
SWalReadHead head;
|
|
||||||
} SWalHead;
|
|
||||||
|
|
||||||
typedef struct SWalVer {
|
typedef struct SWalVer {
|
||||||
int64_t firstVer;
|
int64_t firstVer;
|
||||||
int64_t verInSnapshotting;
|
int64_t verInSnapshotting;
|
||||||
|
@ -125,6 +96,35 @@ typedef struct SWalVer {
|
||||||
int64_t lastVer;
|
int64_t lastVer;
|
||||||
} SWalVer;
|
} SWalVer;
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
// used by sync module
|
||||||
|
typedef struct {
|
||||||
|
int8_t isWeek;
|
||||||
|
uint64_t seqNum;
|
||||||
|
uint64_t term;
|
||||||
|
} SSyncLogMeta;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t protoVer;
|
||||||
|
int64_t version;
|
||||||
|
int16_t msgType;
|
||||||
|
int32_t bodyLen;
|
||||||
|
int64_t ingestTs; // not implemented
|
||||||
|
|
||||||
|
// sync meta
|
||||||
|
SSyncLogMeta syncMeta;
|
||||||
|
|
||||||
|
char body[];
|
||||||
|
} SWalCont;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint64_t magic;
|
||||||
|
uint32_t cksumHead;
|
||||||
|
uint32_t cksumBody;
|
||||||
|
SWalCont head;
|
||||||
|
} SWalCkHead;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
typedef struct SWal {
|
typedef struct SWal {
|
||||||
// cfg
|
// cfg
|
||||||
SWalCfg cfg;
|
SWalCfg cfg;
|
||||||
|
@ -134,7 +134,7 @@ typedef struct SWal {
|
||||||
TdFilePtr pWriteLogTFile;
|
TdFilePtr pWriteLogTFile;
|
||||||
TdFilePtr pWriteIdxTFile;
|
TdFilePtr pWriteIdxTFile;
|
||||||
int32_t writeCur;
|
int32_t writeCur;
|
||||||
SArray *fileInfoSet;
|
SArray *fileInfoSet; // SArray<SWalFileInfo>
|
||||||
// status
|
// status
|
||||||
int64_t totSize;
|
int64_t totSize;
|
||||||
int64_t lastRollSeq;
|
int64_t lastRollSeq;
|
||||||
|
@ -146,7 +146,7 @@ typedef struct SWal {
|
||||||
// path
|
// path
|
||||||
char path[WAL_PATH_LEN];
|
char path[WAL_PATH_LEN];
|
||||||
// reusable write head
|
// reusable write head
|
||||||
SWalHead writeHead;
|
SWalCkHead writeHead;
|
||||||
} SWal; // WAL HANDLE
|
} SWal; // WAL HANDLE
|
||||||
|
|
||||||
typedef struct SWalReadHandle {
|
typedef struct SWalReadHandle {
|
||||||
|
@ -158,11 +158,8 @@ typedef struct SWalReadHandle {
|
||||||
int64_t capacity;
|
int64_t capacity;
|
||||||
int64_t status; // if cursor valid
|
int64_t status; // if cursor valid
|
||||||
TdThreadMutex mutex;
|
TdThreadMutex mutex;
|
||||||
SWalHead *pHead;
|
SWalCkHead *pHead;
|
||||||
} SWalReadHandle;
|
} SWalReadHandle;
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
// typedef int32_t (*FWalWrite)(void *ahandle, void *pHead);
|
|
||||||
|
|
||||||
// module initialization
|
// module initialization
|
||||||
int32_t walInit();
|
int32_t walInit();
|
||||||
|
@ -174,9 +171,9 @@ int32_t walAlter(SWal *, SWalCfg *pCfg);
|
||||||
void walClose(SWal *);
|
void walClose(SWal *);
|
||||||
|
|
||||||
// write
|
// write
|
||||||
int64_t walWriteWithSyncInfo(SWal *, int64_t index, tmsg_t msgType, SSyncLogMeta syncMeta, const void *body,
|
int32_t walWriteWithSyncInfo(SWal *, int64_t index, tmsg_t msgType, SSyncLogMeta syncMeta, const void *body,
|
||||||
int32_t bodyLen);
|
int32_t bodyLen);
|
||||||
int64_t walWrite(SWal *, int64_t index, tmsg_t msgType, const void *body, int32_t bodyLen);
|
int32_t walWrite(SWal *, int64_t index, tmsg_t msgType, const void *body, int32_t bodyLen);
|
||||||
void walFsync(SWal *, bool force);
|
void walFsync(SWal *, bool force);
|
||||||
|
|
||||||
// apis for lifecycle management
|
// apis for lifecycle management
|
||||||
|
@ -196,9 +193,9 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver);
|
||||||
|
|
||||||
// only for tq usage
|
// only for tq usage
|
||||||
void walSetReaderCapacity(SWalReadHandle *pRead, int32_t capacity);
|
void walSetReaderCapacity(SWalReadHandle *pRead, int32_t capacity);
|
||||||
int32_t walFetchHead(SWalReadHandle *pRead, int64_t ver, SWalHead *pHead);
|
int32_t walFetchHead(SWalReadHandle *pRead, int64_t ver, SWalCkHead *pHead);
|
||||||
int32_t walFetchBody(SWalReadHandle *pRead, SWalHead **ppHead);
|
int32_t walFetchBody(SWalReadHandle *pRead, SWalCkHead **ppHead);
|
||||||
int32_t walSkipFetchBody(SWalReadHandle *pRead, const SWalHead *pHead);
|
int32_t walSkipFetchBody(SWalReadHandle *pRead, const SWalCkHead *pHead);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t refId;
|
int64_t refId;
|
||||||
|
@ -210,6 +207,8 @@ void walCloseRef(SWalRef *);
|
||||||
int32_t walRefVer(SWalRef *, int64_t ver);
|
int32_t walRefVer(SWalRef *, int64_t ver);
|
||||||
int32_t walUnrefVer(SWal *);
|
int32_t walUnrefVer(SWal *);
|
||||||
|
|
||||||
|
bool walLogExist(SWal *, int64_t ver);
|
||||||
|
|
||||||
// lifecycle check
|
// lifecycle check
|
||||||
bool walIsEmpty(SWal *);
|
bool walIsEmpty(SWal *);
|
||||||
int64_t walGetFirstVer(SWal *);
|
int64_t walGetFirstVer(SWal *);
|
||||||
|
|
|
@ -25,17 +25,17 @@ extern "C" {
|
||||||
// If the error is in a third-party library, place this header file under the third-party library header file.
|
// If the error is in a third-party library, place this header file under the third-party library header file.
|
||||||
// When you want to use this feature, you should find or add the same function in the following sectio
|
// When you want to use this feature, you should find or add the same function in the following sectio
|
||||||
#ifndef ALLOW_FORBID_FUNC
|
#ifndef ALLOW_FORBID_FUNC
|
||||||
#define open OPEN_FUNC_TAOS_FORBID
|
#define open OPEN_FUNC_TAOS_FORBID
|
||||||
#define fopen FOPEN_FUNC_TAOS_FORBID
|
#define fopen FOPEN_FUNC_TAOS_FORBID
|
||||||
#define access ACCESS_FUNC_TAOS_FORBID
|
#define access ACCESS_FUNC_TAOS_FORBID
|
||||||
#define stat STAT_FUNC_TAOS_FORBID
|
#define stat STAT_FUNC_TAOS_FORBID
|
||||||
#define lstat LSTAT_FUNC_TAOS_FORBID
|
#define lstat LSTAT_FUNC_TAOS_FORBID
|
||||||
#define fstat FSTAT_FUNC_TAOS_FORBID
|
#define fstat FSTAT_FUNC_TAOS_FORBID
|
||||||
#define close CLOSE_FUNC_TAOS_FORBID
|
#define close CLOSE_FUNC_TAOS_FORBID
|
||||||
#define fclose FCLOSE_FUNC_TAOS_FORBID
|
#define fclose FCLOSE_FUNC_TAOS_FORBID
|
||||||
#define fsync FSYNC_FUNC_TAOS_FORBID
|
#define fsync FSYNC_FUNC_TAOS_FORBID
|
||||||
#define getline GETLINE_FUNC_TAOS_FORBID
|
#define getline GETLINE_FUNC_TAOS_FORBID
|
||||||
// #define fflush FFLUSH_FUNC_TAOS_FORBID
|
// #define fflush FFLUSH_FUNC_TAOS_FORBID
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PATH_MAX
|
#ifndef PATH_MAX
|
||||||
|
@ -43,54 +43,54 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct TdFile *TdFilePtr;
|
typedef struct TdFile *TdFilePtr;
|
||||||
|
|
||||||
#define TD_FILE_CREATE 0x0001
|
#define TD_FILE_CREATE 0x0001
|
||||||
#define TD_FILE_WRITE 0x0002
|
#define TD_FILE_WRITE 0x0002
|
||||||
#define TD_FILE_READ 0x0004
|
#define TD_FILE_READ 0x0004
|
||||||
#define TD_FILE_TRUNC 0x0008
|
#define TD_FILE_TRUNC 0x0008
|
||||||
#define TD_FILE_APPEND 0x0010
|
#define TD_FILE_APPEND 0x0010
|
||||||
#define TD_FILE_TEXT 0x0020
|
#define TD_FILE_TEXT 0x0020
|
||||||
#define TD_FILE_AUTO_DEL 0x0040
|
#define TD_FILE_AUTO_DEL 0x0040
|
||||||
#define TD_FILE_EXCL 0x0080
|
#define TD_FILE_EXCL 0x0080
|
||||||
#define TD_FILE_STREAM 0x0100 // Only support taosFprintfFile, taosGetLineFile, taosEOFFile
|
#define TD_FILE_STREAM 0x0100 // Only support taosFprintfFile, taosGetLineFile, taosEOFFile
|
||||||
TdFilePtr taosOpenFile(const char *path,int32_t tdFileOptions);
|
TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions);
|
||||||
|
|
||||||
#define TD_FILE_ACCESS_EXIST_OK 0x1
|
#define TD_FILE_ACCESS_EXIST_OK 0x1
|
||||||
#define TD_FILE_ACCESS_READ_OK 0x2
|
#define TD_FILE_ACCESS_READ_OK 0x2
|
||||||
#define TD_FILE_ACCESS_WRITE_OK 0x4
|
#define TD_FILE_ACCESS_WRITE_OK 0x4
|
||||||
bool taosCheckAccessFile(const char *pathname, int mode);
|
bool taosCheckAccessFile(const char *pathname, int mode);
|
||||||
|
|
||||||
int32_t taosLockFile(TdFilePtr pFile);
|
int32_t taosLockFile(TdFilePtr pFile);
|
||||||
int32_t taosUnLockFile(TdFilePtr pFile);
|
int32_t taosUnLockFile(TdFilePtr pFile);
|
||||||
|
|
||||||
int32_t taosUmaskFile(int32_t maskVal);
|
int32_t taosUmaskFile(int32_t maskVal);
|
||||||
|
|
||||||
int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime);
|
int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime);
|
||||||
int32_t taosDevInoFile(TdFilePtr pFile, int64_t *stDev, int64_t *stIno);
|
int32_t taosDevInoFile(TdFilePtr pFile, int64_t *stDev, int64_t *stIno);
|
||||||
int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime);
|
int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime);
|
||||||
bool taosCheckExistFile(const char *pathname);
|
bool taosCheckExistFile(const char *pathname);
|
||||||
|
|
||||||
int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence);
|
int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence);
|
||||||
int32_t taosFtruncateFile(TdFilePtr pFile, int64_t length);
|
int32_t taosFtruncateFile(TdFilePtr pFile, int64_t length);
|
||||||
int32_t taosFsyncFile(TdFilePtr pFile);
|
int32_t taosFsyncFile(TdFilePtr pFile);
|
||||||
|
|
||||||
int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count);
|
int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count);
|
||||||
int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset);
|
int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset);
|
||||||
int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count);
|
int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count);
|
||||||
void taosFprintfFile(TdFilePtr pFile, const char *format, ...);
|
void taosFprintfFile(TdFilePtr pFile, const char *format, ...);
|
||||||
|
|
||||||
int64_t taosGetLineFile(TdFilePtr pFile, char ** __restrict ptrBuf);
|
int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf);
|
||||||
int64_t taosGetsFile(TdFilePtr pFile, int32_t maxSize, char *__restrict buf);
|
int64_t taosGetsFile(TdFilePtr pFile, int32_t maxSize, char *__restrict buf);
|
||||||
|
|
||||||
int32_t taosEOFFile(TdFilePtr pFile);
|
int32_t taosEOFFile(TdFilePtr pFile);
|
||||||
|
|
||||||
int64_t taosCloseFile(TdFilePtr *ppFile);
|
int32_t taosCloseFile(TdFilePtr *ppFile);
|
||||||
|
|
||||||
int32_t taosRenameFile(const char *oldName, const char *newName);
|
int32_t taosRenameFile(const char *oldName, const char *newName);
|
||||||
int64_t taosCopyFile(const char *from, const char *to);
|
int64_t taosCopyFile(const char *from, const char *to);
|
||||||
int32_t taosRemoveFile(const char *path);
|
int32_t taosRemoveFile(const char *path);
|
||||||
|
|
||||||
void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath);
|
void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath);
|
||||||
|
|
||||||
int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, int64_t size);
|
int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, int64_t size);
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,13 @@ extern "C" {
|
||||||
})
|
})
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __COMPAR_FN_T
|
||||||
|
#define __COMPAR_FN_T
|
||||||
|
typedef int32_t (*__compar_fn_t)(const void *, const void *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void taosSort(void* arr, int64_t sz, int64_t width, __compar_fn_t compar);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -86,6 +86,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_RPC_NETWORK_UNAVAIL TAOS_DEF_ERROR_CODE(0, 0x0102)
|
#define TSDB_CODE_RPC_NETWORK_UNAVAIL TAOS_DEF_ERROR_CODE(0, 0x0102)
|
||||||
#define TSDB_CODE_RPC_FQDN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0103)
|
#define TSDB_CODE_RPC_FQDN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0103)
|
||||||
#define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0104)
|
#define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0104)
|
||||||
|
#define TSDB_CODE_RPC_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0105)
|
||||||
|
|
||||||
//client
|
//client
|
||||||
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)
|
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)
|
||||||
|
@ -422,6 +423,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_SYN_RECONFIG_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0910)
|
#define TSDB_CODE_SYN_RECONFIG_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0910)
|
||||||
#define TSDB_CODE_SYN_PROPOSE_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0911)
|
#define TSDB_CODE_SYN_PROPOSE_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0911)
|
||||||
#define TSDB_CODE_SYN_STANDBY_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0912)
|
#define TSDB_CODE_SYN_STANDBY_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0912)
|
||||||
|
#define TSDB_CODE_SYN_BATCH_ERROR TAOS_DEF_ERROR_CODE(0, 0x0913)
|
||||||
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
|
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
|
||||||
|
|
||||||
// tq
|
// tq
|
||||||
|
|
|
@ -44,6 +44,8 @@ uint32_t ip2uint(const char *const ip_addr);
|
||||||
void taosIp2String(uint32_t ip, char *str);
|
void taosIp2String(uint32_t ip, char *str);
|
||||||
void taosIpPort2String(uint32_t ip, uint16_t port, char *str);
|
void taosIpPort2String(uint32_t ip, uint16_t port, char *str);
|
||||||
|
|
||||||
|
void *tmemmem(const char *haystack, int hlen, const char *needle, int nlen);
|
||||||
|
|
||||||
static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) {
|
static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) {
|
||||||
T_MD5_CTX context;
|
T_MD5_CTX context;
|
||||||
tMD5Init(&context);
|
tMD5Init(&context);
|
||||||
|
@ -59,10 +61,10 @@ static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *tar
|
||||||
tMD5Final(&context);
|
tMD5Final(&context);
|
||||||
char buf[TSDB_PASSWORD_LEN + 1];
|
char buf[TSDB_PASSWORD_LEN + 1];
|
||||||
|
|
||||||
sprintf(buf, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0],
|
sprintf(buf, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], context.digest[1],
|
||||||
context.digest[1], context.digest[2], context.digest[3], context.digest[4], context.digest[5],
|
context.digest[2], context.digest[3], context.digest[4], context.digest[5], context.digest[6],
|
||||||
context.digest[6], context.digest[7], context.digest[8], context.digest[9], context.digest[10],
|
context.digest[7], context.digest[8], context.digest[9], context.digest[10], context.digest[11],
|
||||||
context.digest[11], context.digest[12], context.digest[13], context.digest[14], context.digest[15]);
|
context.digest[12], context.digest[13], context.digest[14], context.digest[15]);
|
||||||
memcpy(target, buf, TSDB_PASSWORD_LEN);
|
memcpy(target, buf, TSDB_PASSWORD_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,8 +89,10 @@ void closeTransporter(SAppInstInfo *pAppInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool clientRpcRfp(int32_t code, tmsg_t msgType) {
|
static bool clientRpcRfp(int32_t code, tmsg_t msgType) {
|
||||||
if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_NODE_NOT_DEPLOYED ||
|
if (NEED_REDIRECT_ERROR(code)) {
|
||||||
code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY) {
|
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -262,7 +262,7 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t hbAsyncCallBack(void *param, const SDataBuf *pMsg, int32_t code) {
|
static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
static int32_t emptyRspNum = 0;
|
static int32_t emptyRspNum = 0;
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
taosMemoryFreeClear(param);
|
taosMemoryFreeClear(param);
|
||||||
|
|
|
@ -769,7 +769,8 @@ int32_t handleQueryExecRsp(SRequestObj* pRequest) {
|
||||||
code = handleSubmitExecRes(pRequest, pRes->res, pCatalog, &epset);
|
code = handleSubmitExecRes(pRequest, pRes->res, pCatalog, &epset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_VND_QUERY: {
|
case TDMT_SCH_QUERY:
|
||||||
|
case TDMT_SCH_MERGE_QUERY: {
|
||||||
code = handleQueryExecRes(pRequest, pRes->res, pCatalog, &epset);
|
code = handleQueryExecRes(pRequest, pRes->res, pCatalog, &epset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1255,10 +1256,10 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
||||||
*/
|
*/
|
||||||
int32_t elapsed = pRequest->metric.rsp - pRequest->metric.start;
|
int32_t elapsed = pRequest->metric.rsp - pRequest->metric.start;
|
||||||
if (pMsg->code == TSDB_CODE_SUCCESS) {
|
if (pMsg->code == TSDB_CODE_SUCCESS) {
|
||||||
tscDebug("0x%" PRIx64 " message:%s, code:%s rspLen:%d, elapsed:%d ms, reqId:0x%" PRIx64, pRequest->self,
|
tscDebug("0x%" PRIx64 " rsp msg:%s, code:%s rspLen:%d, elapsed:%d ms, reqId:0x%" PRIx64, pRequest->self,
|
||||||
TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), pMsg->contLen, elapsed / 1000, pRequest->requestId);
|
TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), pMsg->contLen, elapsed / 1000, pRequest->requestId);
|
||||||
} else {
|
} else {
|
||||||
tscError("0x%" PRIx64 " SQL cmd:%s, code:%s rspLen:%d, elapsed time:%d ms, reqId:0x%" PRIx64, pRequest->self,
|
tscError("0x%" PRIx64 " rsp msg:%s, code:%s rspLen:%d, elapsed time:%d ms, reqId:0x%" PRIx64, pRequest->self,
|
||||||
TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), pMsg->contLen, elapsed / 1000, pRequest->requestId);
|
TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), pMsg->contLen, elapsed / 1000, pRequest->requestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1268,7 +1269,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
||||||
|
|
||||||
updateTargetEpSet(pSendInfo, pTscObj, pMsg, pEpSet);
|
updateTargetEpSet(pSendInfo, pTscObj, pMsg, pEpSet);
|
||||||
|
|
||||||
SDataBuf buf = {.len = pMsg->contLen, .pData = NULL, .handle = pMsg->info.handle};
|
SDataBuf buf = {.msgType = pMsg->msgType, .len = pMsg->contLen, .pData = NULL, .handle = pMsg->info.handle, .pEpSet = pEpSet};
|
||||||
|
|
||||||
if (pMsg->contLen > 0) {
|
if (pMsg->contLen > 0) {
|
||||||
buf.pData = taosMemoryCalloc(1, pMsg->contLen);
|
buf.pData = taosMemoryCalloc(1, pMsg->contLen);
|
||||||
|
|
|
@ -26,7 +26,7 @@ static void setErrno(SRequestObj* pRequest, int32_t code) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
SRequestObj* pRequest = param;
|
SRequestObj* pRequest = param;
|
||||||
setErrno(pRequest, code);
|
setErrno(pRequest, code);
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ int32_t genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
SRequestObj* pRequest = param;
|
SRequestObj* pRequest = param;
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
|
@ -116,7 +116,7 @@ SMsgSendInfo* buildMsgInfoImpl(SRequestObj* pRequest) {
|
||||||
return pMsgSendInfo;
|
return pMsgSendInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t processCreateDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t processCreateDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
// todo rsp with the vnode id list
|
// todo rsp with the vnode id list
|
||||||
SRequestObj* pRequest = param;
|
SRequestObj* pRequest = param;
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
|
@ -132,7 +132,7 @@ int32_t processCreateDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
SRequestObj* pRequest = param;
|
SRequestObj* pRequest = param;
|
||||||
|
|
||||||
if (TSDB_CODE_MND_DB_NOT_EXIST == code) {
|
if (TSDB_CODE_MND_DB_NOT_EXIST == code) {
|
||||||
|
@ -211,7 +211,7 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t processCreateSTableRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
assert(pMsg != NULL && param != NULL);
|
assert(pMsg != NULL && param != NULL);
|
||||||
SRequestObj* pRequest = param;
|
SRequestObj* pRequest = param;
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ int32_t processCreateSTableRsp(void* param, const SDataBuf* pMsg, int32_t code)
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t processDropDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
SRequestObj* pRequest = param;
|
SRequestObj* pRequest = param;
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
setErrno(pRequest, code);
|
setErrno(pRequest, code);
|
||||||
|
@ -250,7 +250,7 @@ int32_t processDropDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t processAlterStbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
SRequestObj* pRequest = param;
|
SRequestObj* pRequest = param;
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
setErrno(pRequest, code);
|
setErrno(pRequest, code);
|
||||||
|
@ -356,7 +356,7 @@ static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t processShowVariablesRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
SRequestObj* pRequest = param;
|
SRequestObj* pRequest = param;
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
setErrno(pRequest, code);
|
setErrno(pRequest, code);
|
||||||
|
|
|
@ -54,7 +54,8 @@ struct tmq_conf_t {
|
||||||
int8_t autoCommit;
|
int8_t autoCommit;
|
||||||
int8_t resetOffset;
|
int8_t resetOffset;
|
||||||
int8_t withTbName;
|
int8_t withTbName;
|
||||||
int8_t useSnapshot;
|
int8_t spEnable;
|
||||||
|
int32_t spBatchSize;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
int32_t autoCommitInterval;
|
int32_t autoCommitInterval;
|
||||||
char* ip;
|
char* ip;
|
||||||
|
@ -288,18 +289,23 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(key, "experiment.use.snapshot") == 0) {
|
if (strcmp(key, "experimental.snapshot.enable") == 0) {
|
||||||
if (strcmp(value, "true") == 0) {
|
if (strcmp(value, "true") == 0) {
|
||||||
conf->useSnapshot = true;
|
conf->spEnable = true;
|
||||||
return TMQ_CONF_OK;
|
return TMQ_CONF_OK;
|
||||||
} else if (strcmp(value, "false") == 0) {
|
} else if (strcmp(value, "false") == 0) {
|
||||||
conf->useSnapshot = false;
|
conf->spEnable = false;
|
||||||
return TMQ_CONF_OK;
|
return TMQ_CONF_OK;
|
||||||
} else {
|
} else {
|
||||||
return TMQ_CONF_INVALID;
|
return TMQ_CONF_INVALID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcmp(key, "experimental.snapshot.batch.size") == 0) {
|
||||||
|
conf->spBatchSize = atoi(value);
|
||||||
|
return TMQ_CONF_OK;
|
||||||
|
}
|
||||||
|
|
||||||
if (strcmp(key, "td.connect.ip") == 0) {
|
if (strcmp(key, "td.connect.ip") == 0) {
|
||||||
conf->ip = strdup(value);
|
conf->ip = strdup(value);
|
||||||
return TMQ_CONF_OK;
|
return TMQ_CONF_OK;
|
||||||
|
@ -378,7 +384,7 @@ int32_t tmqCommitCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t tmqCommitCb2(void* param, const SDataBuf* pBuf, int32_t code) {
|
int32_t tmqCommitCb2(void* param, SDataBuf* pBuf, int32_t code) {
|
||||||
SMqCommitCbParam2* pParam = (SMqCommitCbParam2*)param;
|
SMqCommitCbParam2* pParam = (SMqCommitCbParam2*)param;
|
||||||
SMqCommitCbParamSet* pParamSet = (SMqCommitCbParamSet*)pParam->params;
|
SMqCommitCbParamSet* pParamSet = (SMqCommitCbParamSet*)pParam->params;
|
||||||
// push into array
|
// push into array
|
||||||
|
@ -813,7 +819,7 @@ void tmqClearUnhandleMsg(tmq_t* tmq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tmqSubscribeCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t tmqSubscribeCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
SMqSubscribeCbParam* pParam = (SMqSubscribeCbParam*)param;
|
SMqSubscribeCbParam* pParam = (SMqSubscribeCbParam*)param;
|
||||||
pParam->rspErr = code;
|
pParam->rspErr = code;
|
||||||
/*tmq_t* tmq = pParam->tmq;*/
|
/*tmq_t* tmq = pParam->tmq;*/
|
||||||
|
@ -918,7 +924,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
||||||
strcpy(pTmq->clientId, conf->clientId);
|
strcpy(pTmq->clientId, conf->clientId);
|
||||||
strcpy(pTmq->groupId, conf->groupId);
|
strcpy(pTmq->groupId, conf->groupId);
|
||||||
pTmq->withTbName = conf->withTbName;
|
pTmq->withTbName = conf->withTbName;
|
||||||
pTmq->useSnapshot = conf->useSnapshot;
|
pTmq->useSnapshot = conf->spEnable;
|
||||||
pTmq->autoCommit = conf->autoCommit;
|
pTmq->autoCommit = conf->autoCommit;
|
||||||
pTmq->autoCommitInterval = conf->autoCommitInterval;
|
pTmq->autoCommitInterval = conf->autoCommitInterval;
|
||||||
pTmq->commitCb = conf->commitCb;
|
pTmq->commitCb = conf->commitCb;
|
||||||
|
@ -1067,7 +1073,7 @@ int32_t tmqGetSkipLogNum(tmq_message_t* tmq_message) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
SMqPollCbParam* pParam = (SMqPollCbParam*)param;
|
SMqPollCbParam* pParam = (SMqPollCbParam*)param;
|
||||||
SMqClientVg* pVg = pParam->pVg;
|
SMqClientVg* pVg = pParam->pVg;
|
||||||
SMqClientTopic* pTopic = pParam->pTopic;
|
SMqClientTopic* pTopic = pParam->pTopic;
|
||||||
|
@ -1324,7 +1330,7 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t tmqAskEpCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t tmqAskEpCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
SMqAskEpCbParam* pParam = (SMqAskEpCbParam*)param;
|
SMqAskEpCbParam* pParam = (SMqAskEpCbParam*)param;
|
||||||
tmq_t* tmq = pParam->tmq;
|
tmq_t* tmq = pParam->tmq;
|
||||||
int8_t async = pParam->async;
|
int8_t async = pParam->async;
|
||||||
|
@ -1541,7 +1547,7 @@ SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) {
|
int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) {
|
||||||
/*printf("call poll\n");*/
|
/*tscDebug("call poll");*/
|
||||||
for (int i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) {
|
for (int i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) {
|
||||||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
||||||
for (int j = 0; j < taosArrayGetSize(pTopic->vgs); j++) {
|
for (int j = 0; j < taosArrayGetSize(pTopic->vgs); j++) {
|
||||||
|
@ -1603,8 +1609,8 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) {
|
||||||
int64_t transporterId = 0;
|
int64_t transporterId = 0;
|
||||||
/*printf("send poll\n");*/
|
/*printf("send poll\n");*/
|
||||||
|
|
||||||
char offsetFormatBuf[50];
|
char offsetFormatBuf[80];
|
||||||
tFormatOffset(offsetFormatBuf, 50, &pVg->currentOffsetNew);
|
tFormatOffset(offsetFormatBuf, 80, &pVg->currentOffsetNew);
|
||||||
tscDebug("consumer %ld send poll to %s : vg %d, epoch %d, req offset %s, reqId %lu", tmq->consumerId,
|
tscDebug("consumer %ld send poll to %s : vg %d, epoch %d, req offset %s, reqId %lu", tmq->consumerId,
|
||||||
pTopic->topicName, pVg->vgId, tmq->epoch, offsetFormatBuf, pReq->reqId);
|
pTopic->topicName, pVg->vgId, tmq->epoch, offsetFormatBuf, pReq->reqId);
|
||||||
/*printf("send vg %d %ld\n", pVg->vgId, pVg->currentOffset);*/
|
/*printf("send vg %d %ld\n", pVg->vgId, pVg->currentOffset);*/
|
||||||
|
@ -1702,6 +1708,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
|
TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
|
||||||
|
/*tscDebug("call poll1");*/
|
||||||
void* rspObj;
|
void* rspObj;
|
||||||
int64_t startTime = taosGetTimestampMs();
|
int64_t startTime = taosGetTimestampMs();
|
||||||
|
|
||||||
|
|
|
@ -892,7 +892,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) {
|
||||||
int64_t p0 = taosGetTimestampUs();
|
int64_t p0 = taosGetTimestampUs();
|
||||||
|
|
||||||
__compar_fn_t fn = getKeyComparFunc(pColInfoData->info.type, pOrder->order);
|
__compar_fn_t fn = getKeyComparFunc(pColInfoData->info.type, pOrder->order);
|
||||||
qsort(pColInfoData->pData, pDataBlock->info.rows, pColInfoData->info.bytes, fn);
|
taosSort(pColInfoData->pData, pDataBlock->info.rows, pColInfoData->info.bytes, fn);
|
||||||
|
|
||||||
int64_t p1 = taosGetTimestampUs();
|
int64_t p1 = taosGetTimestampUs();
|
||||||
uDebug("blockDataSort easy cost:%" PRId64 ", rows:%d\n", p1 - p0, pDataBlock->info.rows);
|
uDebug("blockDataSort easy cost:%" PRId64 ", rows:%d\n", p1 - p0, pDataBlock->info.rows);
|
||||||
|
@ -1218,7 +1218,7 @@ int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src) {
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SColumnInfoData* pDst = taosArrayGet(dst->pDataBlock, i);
|
SColumnInfoData* pDst = taosArrayGet(dst->pDataBlock, i);
|
||||||
SColumnInfoData* pSrc = taosArrayGet(src->pDataBlock, i);
|
SColumnInfoData* pSrc = taosArrayGet(src->pDataBlock, i);
|
||||||
if (pSrc->pData == NULL) {
|
if (pSrc->pData == NULL && (!IS_VAR_DATA_TYPE(pSrc->info.type))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1605,6 +1605,13 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void blockDebugShowDataBlock(SSDataBlock* pBlock, const char* flag) {
|
||||||
|
SArray* dataBlocks = taosArrayInit(1, sizeof(SSDataBlock));
|
||||||
|
taosArrayPush(dataBlocks, pBlock);
|
||||||
|
blockDebugShowDataBlocks(dataBlocks, flag);
|
||||||
|
taosArrayDestroy(dataBlocks);
|
||||||
|
}
|
||||||
|
|
||||||
void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) {
|
void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) {
|
||||||
char pBuf[128] = {0};
|
char pBuf[128] = {0};
|
||||||
int32_t sz = taosArrayGetSize(dataBlocks);
|
int32_t sz = taosArrayGetSize(dataBlocks);
|
||||||
|
|
|
@ -931,9 +931,9 @@ int32_t tTagNew(SArray *pArray, int32_t version, int8_t isJson, STag **ppTag) {
|
||||||
|
|
||||||
// sort
|
// sort
|
||||||
if (isJson) {
|
if (isJson) {
|
||||||
qsort(pArray->pData, nTag, sizeof(STagVal), tTagValJsonCmprFn);
|
taosSort(pArray->pData, nTag, sizeof(STagVal), tTagValJsonCmprFn);
|
||||||
} else {
|
} else {
|
||||||
qsort(pArray->pData, nTag, sizeof(STagVal), tTagValCmprFn);
|
taosSort(pArray->pData, nTag, sizeof(STagVal), tTagValCmprFn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get size
|
// get size
|
||||||
|
|
|
@ -503,6 +503,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
|
||||||
if (tEncodeI32(&encoder, pReq->ttl) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->ttl) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->numOfColumns) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->numOfColumns) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->numOfTags) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->numOfTags) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->numOfFuncs) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->commentLen) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->commentLen) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->ast1Len) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->ast1Len) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->ast2Len) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->ast2Len) < 0) return -1;
|
||||||
|
@ -510,21 +511,26 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
|
||||||
for (int32_t i = 0; i < pReq->numOfColumns; ++i) {
|
for (int32_t i = 0; i < pReq->numOfColumns; ++i) {
|
||||||
SField *pField = taosArrayGet(pReq->pColumns, i);
|
SField *pField = taosArrayGet(pReq->pColumns, i);
|
||||||
if (tEncodeI8(&encoder, pField->type) < 0) return -1;
|
if (tEncodeI8(&encoder, pField->type) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pField->flags) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pField->bytes) < 0) return -1;
|
if (tEncodeI32(&encoder, pField->bytes) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pField->name) < 0) return -1;
|
if (tEncodeCStr(&encoder, pField->name) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pField->flags) < 0) return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < pReq->numOfTags; ++i) {
|
for (int32_t i = 0; i < pReq->numOfTags; ++i) {
|
||||||
SField *pField = taosArrayGet(pReq->pTags, i);
|
SField *pField = taosArrayGet(pReq->pTags, i);
|
||||||
if (tEncodeI8(&encoder, pField->type) < 0) return -1;
|
if (tEncodeI8(&encoder, pField->type) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pField->flags) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pField->bytes) < 0) return -1;
|
if (tEncodeI32(&encoder, pField->bytes) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pField->name) < 0) return -1;
|
if (tEncodeCStr(&encoder, pField->name) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pField->flags) < 0) return -1;
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pReq->numOfFuncs; ++i) {
|
||||||
|
const char *pFunc = taosArrayGet(pReq->pFuncs, i);
|
||||||
|
if (tEncodeCStr(&encoder, pFunc) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pReq->commentLen > 0) {
|
if (pReq->commentLen > 0) {
|
||||||
if (tEncodeCStr(&encoder, pReq->comment) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->pComment) < 0) return -1;
|
||||||
}
|
}
|
||||||
if (pReq->ast1Len > 0) {
|
if (pReq->ast1Len > 0) {
|
||||||
if (tEncodeBinary(&encoder, pReq->pAst1, pReq->ast1Len) < 0) return -1;
|
if (tEncodeBinary(&encoder, pReq->pAst1, pReq->ast1Len) < 0) return -1;
|
||||||
|
@ -533,13 +539,6 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
|
||||||
if (tEncodeBinary(&encoder, pReq->pAst2, pReq->ast2Len) < 0) return -1;
|
if (tEncodeBinary(&encoder, pReq->pAst2, pReq->ast2Len) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfFuncs = taosArrayGetSize(pReq->pFuncs);
|
|
||||||
if (tEncodeI32(&encoder, numOfFuncs) < 0) return -1;
|
|
||||||
for (int32_t i = 0; i < numOfFuncs; ++i) {
|
|
||||||
const char *pFunc = taosArrayGet(pReq->pFuncs, i);
|
|
||||||
if (tEncodeCStr(&encoder, pFunc) < 0) return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -561,13 +560,15 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
|
||||||
if (tDecodeI32(&decoder, &pReq->ttl) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->ttl) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->numOfColumns) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->numOfColumns) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->numOfTags) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->numOfTags) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->numOfFuncs) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->commentLen) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->commentLen) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->ast1Len) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->ast1Len) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->ast2Len) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->ast2Len) < 0) return -1;
|
||||||
|
|
||||||
pReq->pColumns = taosArrayInit(pReq->numOfColumns, sizeof(SField));
|
pReq->pColumns = taosArrayInit(pReq->numOfColumns, sizeof(SField));
|
||||||
pReq->pTags = taosArrayInit(pReq->numOfTags, sizeof(SField));
|
pReq->pTags = taosArrayInit(pReq->numOfTags, sizeof(SField));
|
||||||
if (pReq->pColumns == NULL || pReq->pTags == NULL) {
|
pReq->pFuncs = taosArrayInit(pReq->numOfFuncs, TSDB_FUNC_NAME_LEN);
|
||||||
|
if (pReq->pColumns == NULL || pReq->pTags == NULL || pReq->pFuncs == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -575,9 +576,9 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
|
||||||
for (int32_t i = 0; i < pReq->numOfColumns; ++i) {
|
for (int32_t i = 0; i < pReq->numOfColumns; ++i) {
|
||||||
SField field = {0};
|
SField field = {0};
|
||||||
if (tDecodeI8(&decoder, &field.type) < 0) return -1;
|
if (tDecodeI8(&decoder, &field.type) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &field.flags) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &field.bytes) < 0) return -1;
|
if (tDecodeI32(&decoder, &field.bytes) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, field.name) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, field.name) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &field.flags) < 0) return -1;
|
|
||||||
if (taosArrayPush(pReq->pColumns, &field) == NULL) {
|
if (taosArrayPush(pReq->pColumns, &field) == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -587,19 +588,28 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
|
||||||
for (int32_t i = 0; i < pReq->numOfTags; ++i) {
|
for (int32_t i = 0; i < pReq->numOfTags; ++i) {
|
||||||
SField field = {0};
|
SField field = {0};
|
||||||
if (tDecodeI8(&decoder, &field.type) < 0) return -1;
|
if (tDecodeI8(&decoder, &field.type) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &field.flags) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &field.bytes) < 0) return -1;
|
if (tDecodeI32(&decoder, &field.bytes) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, field.name) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, field.name) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &field.flags) < 0) return -1;
|
|
||||||
if (taosArrayPush(pReq->pTags, &field) == NULL) {
|
if (taosArrayPush(pReq->pTags, &field) == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pReq->numOfFuncs; ++i) {
|
||||||
|
char pFunc[TSDB_FUNC_NAME_LEN] = {0};
|
||||||
|
if (tDecodeCStrTo(&decoder, pFunc) < 0) return -1;
|
||||||
|
if (taosArrayPush(pReq->pFuncs, pFunc) == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (pReq->commentLen > 0) {
|
if (pReq->commentLen > 0) {
|
||||||
pReq->comment = taosMemoryMalloc(pReq->commentLen + 1);
|
pReq->pComment = taosMemoryMalloc(pReq->commentLen + 1);
|
||||||
if (pReq->comment == NULL) return -1;
|
if (pReq->pComment == NULL) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->comment) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->pComment) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pReq->ast1Len > 0) {
|
if (pReq->ast1Len > 0) {
|
||||||
|
@ -614,23 +624,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
|
||||||
if (tDecodeCStrTo(&decoder, pReq->pAst2) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->pAst2) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfFuncs = 0;
|
|
||||||
if (tDecodeI32(&decoder, &numOfFuncs) < 0) return -1;
|
|
||||||
if (numOfFuncs > 0) {
|
|
||||||
pReq->pFuncs = taosArrayInit(numOfFuncs, TSDB_FUNC_NAME_LEN);
|
|
||||||
if (NULL == pReq->pFuncs) return -1;
|
|
||||||
}
|
|
||||||
for (int32_t i = 0; i < numOfFuncs; ++i) {
|
|
||||||
char pFunc[TSDB_FUNC_NAME_LEN] = {0};
|
|
||||||
if (tDecodeCStrTo(&decoder, pFunc) < 0) return -1;
|
|
||||||
if (taosArrayPush(pReq->pFuncs, pFunc) == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -638,10 +632,10 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
|
||||||
void tFreeSMCreateStbReq(SMCreateStbReq *pReq) {
|
void tFreeSMCreateStbReq(SMCreateStbReq *pReq) {
|
||||||
taosArrayDestroy(pReq->pColumns);
|
taosArrayDestroy(pReq->pColumns);
|
||||||
taosArrayDestroy(pReq->pTags);
|
taosArrayDestroy(pReq->pTags);
|
||||||
taosMemoryFreeClear(pReq->comment);
|
taosArrayDestroy(pReq->pFuncs);
|
||||||
|
taosMemoryFreeClear(pReq->pComment);
|
||||||
taosMemoryFreeClear(pReq->pAst1);
|
taosMemoryFreeClear(pReq->pAst1);
|
||||||
taosMemoryFreeClear(pReq->pAst2);
|
taosMemoryFreeClear(pReq->pAst2);
|
||||||
taosArrayDestroy(pReq->pFuncs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSMDropStbReq(void *buf, int32_t bufLen, SMDropStbReq *pReq) {
|
int32_t tSerializeSMDropStbReq(void *buf, int32_t bufLen, SMDropStbReq *pReq) {
|
||||||
|
@ -4309,6 +4303,7 @@ int32_t tSerializeSSchedulerHbRsp(void *buf, int32_t bufLen, SSchedulerHbRsp *pR
|
||||||
if (tEncodeU64(&encoder, status->queryId) < 0) return -1;
|
if (tEncodeU64(&encoder, status->queryId) < 0) return -1;
|
||||||
if (tEncodeU64(&encoder, status->taskId) < 0) return -1;
|
if (tEncodeU64(&encoder, status->taskId) < 0) return -1;
|
||||||
if (tEncodeI64(&encoder, status->refId) < 0) return -1;
|
if (tEncodeI64(&encoder, status->refId) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, status->execId) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, status->status) < 0) return -1;
|
if (tEncodeI8(&encoder, status->status) < 0) return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -4339,6 +4334,7 @@ int32_t tDeserializeSSchedulerHbRsp(void *buf, int32_t bufLen, SSchedulerHbRsp *
|
||||||
if (tDecodeU64(&decoder, &status.queryId) < 0) return -1;
|
if (tDecodeU64(&decoder, &status.queryId) < 0) return -1;
|
||||||
if (tDecodeU64(&decoder, &status.taskId) < 0) return -1;
|
if (tDecodeU64(&decoder, &status.taskId) < 0) return -1;
|
||||||
if (tDecodeI64(&decoder, &status.refId) < 0) return -1;
|
if (tDecodeI64(&decoder, &status.refId) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &status.execId) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &status.status) < 0) return -1;
|
if (tDecodeI8(&decoder, &status.status) < 0) return -1;
|
||||||
taosArrayPush(pRsp->taskStatus, &status);
|
taosArrayPush(pRsp->taskStatus, &status);
|
||||||
}
|
}
|
||||||
|
@ -4641,6 +4637,7 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
|
||||||
if (tEncodeI8(&encoder, pReq->triggerType) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->triggerType) < 0) return -1;
|
||||||
if (tEncodeI64(&encoder, pReq->maxDelay) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->maxDelay) < 0) return -1;
|
||||||
if (tEncodeI64(&encoder, pReq->watermark) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->watermark) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->igExpired) < 0) return -1;
|
||||||
if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1;
|
if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1;
|
||||||
if (astLen > 0 && tEncodeCStr(&encoder, pReq->ast) < 0) return -1;
|
if (astLen > 0 && tEncodeCStr(&encoder, pReq->ast) < 0) return -1;
|
||||||
|
|
||||||
|
@ -4668,6 +4665,7 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
|
||||||
if (tDecodeI8(&decoder, &pReq->triggerType) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->triggerType) < 0) return -1;
|
||||||
if (tDecodeI64(&decoder, &pReq->maxDelay) < 0) return -1;
|
if (tDecodeI64(&decoder, &pReq->maxDelay) < 0) return -1;
|
||||||
if (tDecodeI64(&decoder, &pReq->watermark) < 0) return -1;
|
if (tDecodeI64(&decoder, &pReq->watermark) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->igExpired) < 0) return -1;
|
||||||
|
|
||||||
if (sqlLen > 0) {
|
if (sqlLen > 0) {
|
||||||
pReq->sql = taosMemoryCalloc(1, sqlLen + 1);
|
pReq->sql = taosMemoryCalloc(1, sqlLen + 1);
|
||||||
|
@ -5398,9 +5396,9 @@ int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) {
|
||||||
} else if (pVal->type == TMQ_OFFSET__LOG) {
|
} else if (pVal->type == TMQ_OFFSET__LOG) {
|
||||||
snprintf(buf, maxLen, "offset(log) ver:%ld", pVal->version);
|
snprintf(buf, maxLen, "offset(log) ver:%ld", pVal->version);
|
||||||
} else if (pVal->type == TMQ_OFFSET__SNAPSHOT_DATA) {
|
} else if (pVal->type == TMQ_OFFSET__SNAPSHOT_DATA) {
|
||||||
snprintf(buf, maxLen, "offset(snapshot data) uid:%ld, ts:%ld", pVal->uid, pVal->ts);
|
snprintf(buf, maxLen, "offset(ss data) uid:%ld, ts:%ld", pVal->uid, pVal->ts);
|
||||||
} else if (pVal->type == TMQ_OFFSET__SNAPSHOT_META) {
|
} else if (pVal->type == TMQ_OFFSET__SNAPSHOT_META) {
|
||||||
snprintf(buf, maxLen, "offset(snapshot meta) uid:%ld, ts:%ld", pVal->uid, pVal->ts);
|
snprintf(buf, maxLen, "offset(ss meta) uid:%ld, ts:%ld", pVal->uid, pVal->ts);
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
@ -5502,4 +5500,3 @@ int32_t tDecodeSMqDataRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -209,10 +209,11 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SHOW_VARIABLES, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_SHOW_VARIABLES, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SERVER_VERSION, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_SERVER_VERSION, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_CONTINUE, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_MERGE_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, mmPutMsgToFetchQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY_CONTINUE, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH, mmPutMsgToFetchQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY_HEARTBEAT, mmPutMsgToFetchQueue, 1) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_FETCH, mmPutMsgToFetchQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
@ -220,7 +221,7 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_SMA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_SMA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_CHANGE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_CHANGE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TASK, mmPutMsgToFetchQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_DROP_TASK, mmPutMsgToFetchQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -107,14 +107,15 @@ SArray *qmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MON_QM_INFO, qmPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MON_QM_INFO, qmPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
// Requests handled by VNODE
|
// Requests handled by VNODE
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY, qmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, qmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_CONTINUE, qmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_MERGE_QUERY, qmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY_CONTINUE, qmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH_RSP, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_FETCH, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_FETCH_RSP, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY_HEARTBEAT, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CANCEL_TASK, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_CANCEL_TASK, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TASK, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_DROP_TASK, qmPutNodeMsgToFetchQueue, 1) == NULL) goto _OVER;
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
_OVER:
|
_OVER:
|
||||||
|
|
|
@ -324,16 +324,17 @@ SArray *vmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MON_VM_LOAD, vmPutMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MON_VM_LOAD, vmPutMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SUBMIT, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_SUBMIT, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_CONTINUE, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_MERGE_QUERY, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY_CONTINUE, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_FETCH, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_TABLE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_TABLE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_UPDATE_TAG_VAL, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_UPDATE_TAG_VAL, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLE_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLE_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLE_CFG, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLE_CFG, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLES_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLES_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CANCEL_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_CANCEL_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_DROP_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TTL_TABLE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TTL_TABLE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
@ -349,7 +350,7 @@ SArray *vmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_COMMIT_OFFSET, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_COMMIT_OFFSET, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CONSUME, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_CONSUME, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DELETE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_DELETE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY_HEARTBEAT, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TRIGGER, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TRIGGER, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -41,6 +41,7 @@ static inline void dmBuildMnodeRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet) {
|
static inline void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet) {
|
||||||
|
pMsg->info.hasEpSet = 1;
|
||||||
SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info};
|
SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info};
|
||||||
int32_t contLen = tSerializeSEpSet(NULL, 0, pNewEpSet);
|
int32_t contLen = tSerializeSEpSet(NULL, 0, pNewEpSet);
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
return;
|
return;
|
||||||
case TDMT_MND_SYSTABLE_RETRIEVE_RSP:
|
case TDMT_MND_SYSTABLE_RETRIEVE_RSP:
|
||||||
case TDMT_DND_SYSTABLE_RETRIEVE_RSP:
|
case TDMT_DND_SYSTABLE_RETRIEVE_RSP:
|
||||||
case TDMT_VND_FETCH_RSP:
|
case TDMT_SCH_FETCH_RSP:
|
||||||
qWorkerProcessFetchRsp(NULL, NULL, pRpc, 0);
|
qWorkerProcessFetchRsp(NULL, NULL, pRpc, 0);
|
||||||
return;
|
return;
|
||||||
case TDMT_MND_STATUS_RSP:
|
case TDMT_MND_STATUS_RSP:
|
||||||
|
@ -250,7 +251,10 @@ static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) {
|
||||||
|
|
||||||
static bool rpcRfp(int32_t code, tmsg_t msgType) {
|
static bool rpcRfp(int32_t code, tmsg_t msgType) {
|
||||||
if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_NODE_NOT_DEPLOYED ||
|
if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_NODE_NOT_DEPLOYED ||
|
||||||
code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY) {
|
code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY || code == TSDB_CODE_RPC_BROKEN_LINK) {
|
||||||
|
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -341,11 +341,12 @@ typedef struct {
|
||||||
int32_t colVer;
|
int32_t colVer;
|
||||||
int32_t smaVer;
|
int32_t smaVer;
|
||||||
int32_t nextColId;
|
int32_t nextColId;
|
||||||
int64_t watermark[2];
|
|
||||||
int64_t maxdelay[2];
|
int64_t maxdelay[2];
|
||||||
|
int64_t watermark[2];
|
||||||
int32_t ttl;
|
int32_t ttl;
|
||||||
int32_t numOfColumns;
|
int32_t numOfColumns;
|
||||||
int32_t numOfTags;
|
int32_t numOfTags;
|
||||||
|
int32_t numOfFuncs;
|
||||||
int32_t commentLen;
|
int32_t commentLen;
|
||||||
int32_t ast1Len;
|
int32_t ast1Len;
|
||||||
int32_t ast2Len;
|
int32_t ast2Len;
|
||||||
|
|
|
@ -58,7 +58,7 @@ static void *mndBuildTimerMsg(int32_t *pContLen) {
|
||||||
|
|
||||||
static void mndPullupTrans(SMnode *pMnode) {
|
static void mndPullupTrans(SMnode *pMnode) {
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pReq = mndBuildTimerMsg(&contLen);
|
void * pReq = mndBuildTimerMsg(&contLen);
|
||||||
if (pReq != NULL) {
|
if (pReq != NULL) {
|
||||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TRANS_TIMER, .pCont = pReq, .contLen = contLen};
|
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TRANS_TIMER, .pCont = pReq, .contLen = contLen};
|
||||||
tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||||
|
@ -67,14 +67,14 @@ static void mndPullupTrans(SMnode *pMnode) {
|
||||||
|
|
||||||
static void mndTtlTimer(SMnode *pMnode) {
|
static void mndTtlTimer(SMnode *pMnode) {
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pReq = mndBuildTimerMsg(&contLen);
|
void * pReq = mndBuildTimerMsg(&contLen);
|
||||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TTL_TIMER, .pCont = pReq, .contLen = contLen};
|
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TTL_TIMER, .pCont = pReq, .contLen = contLen};
|
||||||
tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndCalMqRebalance(SMnode *pMnode) {
|
static void mndCalMqRebalance(SMnode *pMnode) {
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pReq = mndBuildTimerMsg(&contLen);
|
void * pReq = mndBuildTimerMsg(&contLen);
|
||||||
if (pReq != NULL) {
|
if (pReq != NULL) {
|
||||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_MQ_TIMER, .pCont = pReq, .contLen = contLen};
|
SRpcMsg rpcMsg = {.msgType = TDMT_MND_MQ_TIMER, .pCont = pReq, .contLen = contLen};
|
||||||
tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg);
|
tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg);
|
||||||
|
@ -83,7 +83,7 @@ static void mndCalMqRebalance(SMnode *pMnode) {
|
||||||
|
|
||||||
static void mndPullupTelem(SMnode *pMnode) {
|
static void mndPullupTelem(SMnode *pMnode) {
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pReq = mndBuildTimerMsg(&contLen);
|
void * pReq = mndBuildTimerMsg(&contLen);
|
||||||
if (pReq != NULL) {
|
if (pReq != NULL) {
|
||||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TELEM_TIMER, .pCont = pReq, .contLen = contLen};
|
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TELEM_TIMER, .pCont = pReq, .contLen = contLen};
|
||||||
tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg);
|
tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg);
|
||||||
|
@ -395,7 +395,7 @@ void mndStop(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
||||||
SMnode *pMnode = pMsg->info.node;
|
SMnode * pMnode = pMsg->info.node;
|
||||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
char *syncNodeStr = sync2SimpleStr(pMgmt->sync);
|
char * syncNodeStr = sync2SimpleStr(pMgmt->sync);
|
||||||
static int64_t mndTick = 0;
|
static int64_t mndTick = 0;
|
||||||
if (++mndTick % 10 == 1) {
|
if (++mndTick % 10 == 1) {
|
||||||
mTrace("vgId:%d, sync trace msg:%s, %s", syncGetVgId(pMgmt->sync), TMSG_INFO(pMsg->msgType), syncNodeStr);
|
mTrace("vgId:%d, sync trace msg:%s, %s", syncGetVgId(pMgmt->sync), TMSG_INFO(pMsg->msgType), syncNodeStr);
|
||||||
|
@ -527,9 +527,9 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
||||||
|
|
||||||
static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
|
static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
|
||||||
if (!IsReq(pMsg)) return 0;
|
if (!IsReq(pMsg)) return 0;
|
||||||
if (pMsg->msgType == TDMT_VND_QUERY || pMsg->msgType == TDMT_VND_QUERY_CONTINUE ||
|
if (pMsg->msgType == TDMT_SCH_QUERY || pMsg->msgType == TDMT_SCH_MERGE_QUERY ||
|
||||||
pMsg->msgType == TDMT_VND_QUERY_HEARTBEAT || pMsg->msgType == TDMT_VND_FETCH ||
|
pMsg->msgType == TDMT_SCH_QUERY_CONTINUE || pMsg->msgType == TDMT_SCH_QUERY_HEARTBEAT ||
|
||||||
pMsg->msgType == TDMT_VND_DROP_TASK) {
|
pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_SCH_DROP_TASK) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (mndAcquireRpcRef(pMsg->info.node) == 0) return 0;
|
if (mndAcquireRpcRef(pMsg->info.node) == 0) return 0;
|
||||||
|
@ -552,6 +552,7 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
|
||||||
|
|
||||||
int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet);
|
int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet);
|
||||||
pMsg->info.rsp = rpcMallocCont(contLen);
|
pMsg->info.rsp = rpcMallocCont(contLen);
|
||||||
|
pMsg->info.hasEpSet = 1;
|
||||||
if (pMsg->info.rsp != NULL) {
|
if (pMsg->info.rsp != NULL) {
|
||||||
tSerializeSEpSet(pMsg->info.rsp, contLen, &epSet);
|
tSerializeSEpSet(pMsg->info.rsp, contLen, &epSet);
|
||||||
pMsg->info.rspLen = contLen;
|
pMsg->info.rspLen = contLen;
|
||||||
|
@ -578,7 +579,7 @@ static int32_t mndCheckMsgContent(SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndProcessRpcMsg(SRpcMsg *pMsg) {
|
int32_t mndProcessRpcMsg(SRpcMsg *pMsg) {
|
||||||
SMnode *pMnode = pMsg->info.node;
|
SMnode * pMnode = pMsg->info.node;
|
||||||
const STraceId *trace = &pMsg->info.traceId;
|
const STraceId *trace = &pMsg->info.traceId;
|
||||||
|
|
||||||
MndMsgFp fp = pMnode->msgFp[TMSG_INDEX(pMsg->msgType)];
|
MndMsgFp fp = pMnode->msgFp[TMSG_INDEX(pMsg->msgType)];
|
||||||
|
@ -631,7 +632,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
|
||||||
SMonStbInfo *pStbInfo, SMonGrantInfo *pGrantInfo) {
|
SMonStbInfo *pStbInfo, SMonGrantInfo *pGrantInfo) {
|
||||||
if (mndAcquireRpcRef(pMnode) != 0) return -1;
|
if (mndAcquireRpcRef(pMnode) != 0) return -1;
|
||||||
|
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb * pSdb = pMnode->pSdb;
|
||||||
int64_t ms = taosGetTimestampMs();
|
int64_t ms = taosGetTimestampMs();
|
||||||
|
|
||||||
pClusterInfo->dnodes = taosArrayInit(sdbGetSize(pSdb, SDB_DNODE), sizeof(SMonDnodeDesc));
|
pClusterInfo->dnodes = taosArrayInit(sdbGetSize(pSdb, SDB_DNODE), sizeof(SMonDnodeDesc));
|
||||||
|
@ -712,7 +713,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
|
||||||
pGrantInfo->timeseries_used += pVgroup->numOfTimeSeries;
|
pGrantInfo->timeseries_used += pVgroup->numOfTimeSeries;
|
||||||
tstrncpy(desc.status, "unsynced", sizeof(desc.status));
|
tstrncpy(desc.status, "unsynced", sizeof(desc.status));
|
||||||
for (int32_t i = 0; i < pVgroup->replica; ++i) {
|
for (int32_t i = 0; i < pVgroup->replica; ++i) {
|
||||||
SVnodeGid *pVgid = &pVgroup->vnodeGid[i];
|
SVnodeGid * pVgid = &pVgroup->vnodeGid[i];
|
||||||
SMonVnodeDesc *pVnDesc = &desc.vnodes[i];
|
SMonVnodeDesc *pVnDesc = &desc.vnodes[i];
|
||||||
pVnDesc->dnode_id = pVgid->dnodeId;
|
pVnDesc->dnode_id = pVgid->dnodeId;
|
||||||
tstrncpy(pVnDesc->vnode_role, syncStr(pVgid->role), sizeof(pVnDesc->vnode_role));
|
tstrncpy(pVnDesc->vnode_role, syncStr(pVgid->role), sizeof(pVnDesc->vnode_role));
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
#include "qworker.h"
|
#include "qworker.h"
|
||||||
|
|
||||||
int32_t mndPreProcessQueryMsg(SRpcMsg *pMsg) {
|
int32_t mndPreProcessQueryMsg(SRpcMsg *pMsg) {
|
||||||
if (TDMT_VND_QUERY != pMsg->msgType) return 0;
|
if (TDMT_SCH_QUERY != pMsg->msgType && TDMT_SCH_MERGE_QUERY != pMsg->msgType) return 0;
|
||||||
SMnode *pMnode = pMsg->info.node;
|
SMnode *pMnode = pMsg->info.node;
|
||||||
return qWorkerPreprocessQueryMsg(pMnode->pQuery, pMsg);
|
return qWorkerPreprocessQueryMsg(pMnode->pQuery, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mndPostProcessQueryMsg(SRpcMsg *pMsg) {
|
void mndPostProcessQueryMsg(SRpcMsg *pMsg) {
|
||||||
if (TDMT_VND_QUERY != pMsg->msgType) return;
|
if (TDMT_SCH_QUERY != pMsg->msgType && TDMT_SCH_MERGE_QUERY != pMsg->msgType) return;
|
||||||
SMnode *pMnode = pMsg->info.node;
|
SMnode *pMnode = pMsg->info.node;
|
||||||
qWorkerAbortPreprocessQueryMsg(pMnode->pQuery, pMsg);
|
qWorkerAbortPreprocessQueryMsg(pMnode->pQuery, pMsg);
|
||||||
}
|
}
|
||||||
|
@ -37,19 +37,20 @@ int32_t mndProcessQueryMsg(SRpcMsg *pMsg) {
|
||||||
|
|
||||||
mTrace("msg:%p, in query queue is processing", pMsg);
|
mTrace("msg:%p, in query queue is processing", pMsg);
|
||||||
switch (pMsg->msgType) {
|
switch (pMsg->msgType) {
|
||||||
case TDMT_VND_QUERY:
|
case TDMT_SCH_QUERY:
|
||||||
|
case TDMT_SCH_MERGE_QUERY:
|
||||||
code = qWorkerProcessQueryMsg(&handle, pMnode->pQuery, pMsg, 0);
|
code = qWorkerProcessQueryMsg(&handle, pMnode->pQuery, pMsg, 0);
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_QUERY_CONTINUE:
|
case TDMT_SCH_QUERY_CONTINUE:
|
||||||
code = qWorkerProcessCQueryMsg(&handle, pMnode->pQuery, pMsg, 0);
|
code = qWorkerProcessCQueryMsg(&handle, pMnode->pQuery, pMsg, 0);
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_FETCH:
|
case TDMT_SCH_FETCH:
|
||||||
code = qWorkerProcessFetchMsg(pMnode, pMnode->pQuery, pMsg, 0);
|
code = qWorkerProcessFetchMsg(pMnode, pMnode->pQuery, pMsg, 0);
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_DROP_TASK:
|
case TDMT_SCH_DROP_TASK:
|
||||||
code = qWorkerProcessDropMsg(pMnode, pMnode->pQuery, pMsg, 0);
|
code = qWorkerProcessDropMsg(pMnode, pMnode->pQuery, pMsg, 0);
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_QUERY_HEARTBEAT:
|
case TDMT_SCH_QUERY_HEARTBEAT:
|
||||||
code = qWorkerProcessHbMsg(pMnode, pMnode->pQuery, pMsg, 0);
|
code = qWorkerProcessHbMsg(pMnode, pMnode->pQuery, pMsg, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -67,11 +68,12 @@ int32_t mndInitQuery(SMnode *pMnode) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_QUERY, mndProcessQueryMsg);
|
mndSetMsgHandle(pMnode, TDMT_SCH_QUERY, mndProcessQueryMsg);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_QUERY_CONTINUE, mndProcessQueryMsg);
|
mndSetMsgHandle(pMnode, TDMT_SCH_MERGE_QUERY, mndProcessQueryMsg);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_FETCH, mndProcessQueryMsg);
|
mndSetMsgHandle(pMnode, TDMT_SCH_QUERY_CONTINUE, mndProcessQueryMsg);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_DROP_TASK, mndProcessQueryMsg);
|
mndSetMsgHandle(pMnode, TDMT_SCH_FETCH, mndProcessQueryMsg);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_QUERY_HEARTBEAT, mndProcessQueryMsg);
|
mndSetMsgHandle(pMnode, TDMT_SCH_DROP_TASK, mndProcessQueryMsg);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_SCH_QUERY_HEARTBEAT, mndProcessQueryMsg);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -396,6 +396,8 @@ static int32_t mndSetUpdateSmaStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStb
|
||||||
stbObj.pColumns = NULL;
|
stbObj.pColumns = NULL;
|
||||||
stbObj.numOfTags = 0;
|
stbObj.numOfTags = 0;
|
||||||
stbObj.pTags = NULL;
|
stbObj.pTags = NULL;
|
||||||
|
stbObj.numOfFuncs = 0;
|
||||||
|
stbObj.pFuncs = NULL;
|
||||||
stbObj.updateTime = taosGetTimestampMs();
|
stbObj.updateTime = taosGetTimestampMs();
|
||||||
stbObj.lock = 0;
|
stbObj.lock = 0;
|
||||||
stbObj.smaVer++;
|
stbObj.smaVer++;
|
||||||
|
@ -408,47 +410,6 @@ static int32_t mndSetUpdateSmaStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStb
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
static int32_t mndSetCreateSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SSmaObj *pSma) {
|
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
|
||||||
SVgObj *pVgroup = NULL;
|
|
||||||
void *pIter = NULL;
|
|
||||||
int32_t contLen;
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
|
|
||||||
if (pIter == NULL) break;
|
|
||||||
if (pVgroup->dbUid != pDb->uid) {
|
|
||||||
sdbRelease(pSdb, pVgroup);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *pReq = mndBuildVCreateSmaReq(pMnode, pVgroup, pSma, &contLen);
|
|
||||||
if (pReq == NULL) {
|
|
||||||
sdbCancelFetch(pSdb, pIter);
|
|
||||||
sdbRelease(pSdb, pVgroup);
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
STransAction action = {0};
|
|
||||||
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
|
||||||
action.pCont = pReq;
|
|
||||||
action.contLen = contLen;
|
|
||||||
action.msgType = TDMT_VND_CREATE_SMA;
|
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
|
||||||
taosMemoryFree(pReq);
|
|
||||||
sdbCancelFetch(pSdb, pIter);
|
|
||||||
sdbRelease(pSdb, pVgroup);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
sdbRelease(pSdb, pVgroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int32_t mndSetCreateSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup,
|
static int32_t mndSetCreateSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup,
|
||||||
SSmaObj *pSma) {
|
SSmaObj *pSma) {
|
||||||
SVnodeGid *pVgid = pVgroup->vnodeGid + 0;
|
SVnodeGid *pVgid = pVgroup->vnodeGid + 0;
|
||||||
|
@ -621,7 +582,6 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
if (mndSetCreateSmaCommitLogs(pMnode, pTrans, &smaObj) != 0) goto _OVER;
|
if (mndSetCreateSmaCommitLogs(pMnode, pTrans, &smaObj) != 0) goto _OVER;
|
||||||
if (mndSetCreateSmaVgroupCommitLogs(pMnode, pTrans, &streamObj.fixedSinkVg) != 0) goto _OVER;
|
if (mndSetCreateSmaVgroupCommitLogs(pMnode, pTrans, &streamObj.fixedSinkVg) != 0) goto _OVER;
|
||||||
if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
||||||
// if (mndSetCreateSmaRedoActions(pMnode, pTrans, pDb, &smaObj) != 0) goto _OVER;
|
|
||||||
if (mndSetCreateSmaVgroupRedoActions(pMnode, pTrans, pDb, &streamObj.fixedSinkVg, &smaObj) != 0) goto _OVER;
|
if (mndSetCreateSmaVgroupRedoActions(pMnode, pTrans, pDb, &streamObj.fixedSinkVg, &smaObj) != 0) goto _OVER;
|
||||||
if (mndScheduleStream(pMnode, &streamObj) != 0) goto _OVER;
|
if (mndScheduleStream(pMnode, &streamObj) != 0) goto _OVER;
|
||||||
if (mndPersistStream(pMnode, pTrans, &streamObj) != 0) goto _OVER;
|
if (mndPersistStream(pMnode, pTrans, &streamObj) != 0) goto _OVER;
|
||||||
|
@ -770,49 +730,6 @@ static int32_t mndSetDropSmaVgroupCommitLogs(SMnode *pMnode, STrans *pTrans, SVg
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
static int32_t mndSetDropSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SSmaObj *pSma) {
|
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
|
||||||
SVgObj *pVgroup = NULL;
|
|
||||||
void *pIter = NULL;
|
|
||||||
int32_t contLen;
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
|
|
||||||
if (pIter == NULL) break;
|
|
||||||
if (pVgroup->dbUid != pDb->uid) {
|
|
||||||
sdbRelease(pSdb, pVgroup);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t contLen = 0;
|
|
||||||
void *pReq = mndBuildVDropSmaReq(pMnode, pVgroup, pSma, &contLen);
|
|
||||||
if (pReq == NULL) {
|
|
||||||
sdbCancelFetch(pSdb, pIter);
|
|
||||||
sdbRelease(pSdb, pVgroup);
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
STransAction action = {0};
|
|
||||||
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
|
||||||
action.pCont = pReq;
|
|
||||||
action.contLen = contLen;
|
|
||||||
action.msgType = TDMT_VND_DROP_SMA;
|
|
||||||
action.acceptableCode = TSDB_CODE_VND_SMA_NOT_EXIST;
|
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
|
||||||
taosMemoryFree(pReq);
|
|
||||||
sdbCancelFetch(pSdb, pIter);
|
|
||||||
sdbRelease(pSdb, pVgroup);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
sdbRelease(pSdb, pVgroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int32_t mndSetDropSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup) {
|
static int32_t mndSetDropSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup) {
|
||||||
SVnodeGid *pVgid = pVgroup->vnodeGid + 0;
|
SVnodeGid *pVgid = pVgroup->vnodeGid + 0;
|
||||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId);
|
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId);
|
||||||
|
@ -879,7 +796,6 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p
|
||||||
if (mndSetDropSmaCommitLogs(pMnode, pTrans, pSma) != 0) goto _OVER;
|
if (mndSetDropSmaCommitLogs(pMnode, pTrans, pSma) != 0) goto _OVER;
|
||||||
if (mndSetDropSmaVgroupCommitLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER;
|
if (mndSetDropSmaVgroupCommitLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER;
|
||||||
if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
||||||
// if (mndSetDropSmaRedoActions(pMnode, pTrans, pDb, pSma) != 0) goto _OVER;
|
|
||||||
if (mndSetDropSmaVgroupRedoActions(pMnode, pTrans, pDb, pVgroup) != 0) goto _OVER;
|
if (mndSetDropSmaVgroupRedoActions(pMnode, pTrans, pDb, pVgroup) != 0) goto _OVER;
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
|
@ -909,7 +825,6 @@ int32_t mndDropSmasByStb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *p
|
||||||
if (mndSetDropSmaVgroupCommitLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER;
|
if (mndSetDropSmaVgroupCommitLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER;
|
||||||
if (mndSetDropSmaVgroupRedoActions(pMnode, pTrans, pDb, pVgroup) != 0) goto _OVER;
|
if (mndSetDropSmaVgroupRedoActions(pMnode, pTrans, pDb, pVgroup) != 0) goto _OVER;
|
||||||
if (mndSetDropSmaCommitLogs(pMnode, pTrans, pSma) != 0) goto _OVER;
|
if (mndSetDropSmaCommitLogs(pMnode, pTrans, pSma) != 0) goto _OVER;
|
||||||
// if (mndSetDropSmaRedoActions(pMnode, pTrans, pDb, pSma) != 0) goto _OVER;
|
|
||||||
mndReleaseVgroup(pMnode, pVgroup);
|
mndReleaseVgroup(pMnode, pVgroup);
|
||||||
pVgroup = NULL;
|
pVgroup = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ void mndCleanupStb(SMnode *pMnode) {}
|
||||||
SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
|
SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
int32_t size = sizeof(SStbObj) + (pStb->numOfColumns + pStb->numOfTags) * sizeof(SSchema) + +pStb->commentLen +
|
int32_t size = sizeof(SStbObj) + (pStb->numOfColumns + pStb->numOfTags) * sizeof(SSchema) + pStb->commentLen +
|
||||||
pStb->ast1Len + pStb->ast2Len + STB_RESERVE_SIZE + taosArrayGetSize(pStb->pFuncs) * TSDB_FUNC_NAME_LEN;
|
pStb->ast1Len + pStb->ast2Len + STB_RESERVE_SIZE + taosArrayGetSize(pStb->pFuncs) * TSDB_FUNC_NAME_LEN;
|
||||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_STB, STB_VER_NUMBER, size);
|
SSdbRaw *pRaw = sdbAllocRaw(SDB_STB, STB_VER_NUMBER, size);
|
||||||
if (pRaw == NULL) goto _OVER;
|
if (pRaw == NULL) goto _OVER;
|
||||||
|
@ -92,6 +92,7 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
|
||||||
SDB_SET_INT64(pRaw, dataPos, pStb->dbUid, _OVER)
|
SDB_SET_INT64(pRaw, dataPos, pStb->dbUid, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pStb->tagVer, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pStb->tagVer, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pStb->colVer, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pStb->colVer, _OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, pStb->smaVer, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pStb->nextColId, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pStb->nextColId, _OVER)
|
||||||
SDB_SET_INT64(pRaw, dataPos, pStb->maxdelay[0], _OVER)
|
SDB_SET_INT64(pRaw, dataPos, pStb->maxdelay[0], _OVER)
|
||||||
SDB_SET_INT64(pRaw, dataPos, pStb->maxdelay[1], _OVER)
|
SDB_SET_INT64(pRaw, dataPos, pStb->maxdelay[1], _OVER)
|
||||||
|
@ -100,17 +101,11 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
|
||||||
SDB_SET_INT32(pRaw, dataPos, pStb->ttl, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pStb->ttl, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pStb->numOfColumns, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pStb->numOfColumns, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pStb->numOfTags, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pStb->numOfTags, _OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, pStb->numOfFuncs, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pStb->commentLen, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pStb->commentLen, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pStb->ast1Len, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pStb->ast1Len, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pStb->ast2Len, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pStb->ast2Len, _OVER)
|
||||||
|
|
||||||
int32_t funcNum = taosArrayGetSize(pStb->pFuncs);
|
|
||||||
SDB_SET_INT32(pRaw, dataPos, funcNum, _OVER)
|
|
||||||
for (int32_t i = 0; i < funcNum; ++i) {
|
|
||||||
char *func = taosArrayGet(pStb->pFuncs, i);
|
|
||||||
SDB_SET_BINARY(pRaw, dataPos, func, TSDB_FUNC_NAME_LEN, _OVER)
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < pStb->numOfColumns; ++i) {
|
for (int32_t i = 0; i < pStb->numOfColumns; ++i) {
|
||||||
SSchema *pSchema = &pStb->pColumns[i];
|
SSchema *pSchema = &pStb->pColumns[i];
|
||||||
SDB_SET_INT8(pRaw, dataPos, pSchema->type, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pSchema->type, _OVER)
|
||||||
|
@ -129,15 +124,23 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pStb->numOfFuncs; ++i) {
|
||||||
|
char *func = taosArrayGet(pStb->pFuncs, i);
|
||||||
|
SDB_SET_BINARY(pRaw, dataPos, func, TSDB_FUNC_NAME_LEN, _OVER)
|
||||||
|
}
|
||||||
|
|
||||||
if (pStb->commentLen > 0) {
|
if (pStb->commentLen > 0) {
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pStb->comment, pStb->commentLen + 1, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pStb->comment, pStb->commentLen + 1, _OVER)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStb->ast1Len > 0) {
|
if (pStb->ast1Len > 0) {
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pStb->pAst1, pStb->ast1Len, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pStb->pAst1, pStb->ast1Len, _OVER)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStb->ast2Len > 0) {
|
if (pStb->ast2Len > 0) {
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pStb->pAst2, pStb->ast2Len, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pStb->pAst2, pStb->ast2Len, _OVER)
|
||||||
}
|
}
|
||||||
|
|
||||||
SDB_SET_RESERVE(pRaw, dataPos, STB_RESERVE_SIZE, _OVER)
|
SDB_SET_RESERVE(pRaw, dataPos, STB_RESERVE_SIZE, _OVER)
|
||||||
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
|
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
|
||||||
|
|
||||||
|
@ -180,6 +183,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pStb->dbUid, _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pStb->dbUid, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pStb->tagVer, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pStb->tagVer, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pStb->colVer, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pStb->colVer, _OVER)
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &pStb->smaVer, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pStb->nextColId, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pStb->nextColId, _OVER)
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pStb->maxdelay[0], _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pStb->maxdelay[0], _OVER)
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pStb->maxdelay[1], _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pStb->maxdelay[1], _OVER)
|
||||||
|
@ -188,27 +192,15 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pStb->ttl, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pStb->ttl, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pStb->numOfColumns, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pStb->numOfColumns, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pStb->numOfTags, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pStb->numOfTags, _OVER)
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &pStb->numOfFuncs, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pStb->commentLen, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pStb->commentLen, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pStb->ast1Len, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pStb->ast1Len, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pStb->ast2Len, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pStb->ast2Len, _OVER)
|
||||||
|
|
||||||
int32_t funcNum = 0;
|
|
||||||
SDB_GET_INT32(pRaw, dataPos, &funcNum, _OVER)
|
|
||||||
if (funcNum > 0) {
|
|
||||||
pStb->pFuncs = taosArrayInit(funcNum, TSDB_FUNC_NAME_LEN);
|
|
||||||
if (NULL == pStb->pFuncs) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
char funcName[TSDB_FUNC_NAME_LEN];
|
|
||||||
for (int32_t i = 0; i < funcNum; ++i) {
|
|
||||||
SDB_GET_BINARY(pRaw, dataPos, funcName, TSDB_FUNC_NAME_LEN, _OVER)
|
|
||||||
taosArrayPush(pStb->pFuncs, funcName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pStb->pColumns = taosMemoryCalloc(pStb->numOfColumns, sizeof(SSchema));
|
pStb->pColumns = taosMemoryCalloc(pStb->numOfColumns, sizeof(SSchema));
|
||||||
pStb->pTags = taosMemoryCalloc(pStb->numOfTags, sizeof(SSchema));
|
pStb->pTags = taosMemoryCalloc(pStb->numOfTags, sizeof(SSchema));
|
||||||
if (pStb->pColumns == NULL || pStb->pTags == NULL) {
|
pStb->pFuncs = taosArrayInit(pStb->numOfFuncs, TSDB_FUNC_NAME_LEN);
|
||||||
|
if (pStb->pColumns == NULL || pStb->pTags == NULL || pStb->pFuncs == NULL) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,16 +222,24 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER)
|
SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pStb->numOfFuncs; ++i) {
|
||||||
|
char funcName[TSDB_FUNC_NAME_LEN] = {0};
|
||||||
|
SDB_GET_BINARY(pRaw, dataPos, funcName, TSDB_FUNC_NAME_LEN, _OVER)
|
||||||
|
taosArrayPush(pStb->pFuncs, funcName);
|
||||||
|
}
|
||||||
|
|
||||||
if (pStb->commentLen > 0) {
|
if (pStb->commentLen > 0) {
|
||||||
pStb->comment = taosMemoryCalloc(pStb->commentLen + 1, 1);
|
pStb->comment = taosMemoryCalloc(pStb->commentLen + 1, 1);
|
||||||
if (pStb->comment == NULL) goto _OVER;
|
if (pStb->comment == NULL) goto _OVER;
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pStb->comment, pStb->commentLen + 1, _OVER)
|
SDB_GET_BINARY(pRaw, dataPos, pStb->comment, pStb->commentLen + 1, _OVER)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStb->ast1Len > 0) {
|
if (pStb->ast1Len > 0) {
|
||||||
pStb->pAst1 = taosMemoryCalloc(pStb->ast1Len, 1);
|
pStb->pAst1 = taosMemoryCalloc(pStb->ast1Len, 1);
|
||||||
if (pStb->pAst1 == NULL) goto _OVER;
|
if (pStb->pAst1 == NULL) goto _OVER;
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pStb->pAst1, pStb->ast1Len, _OVER)
|
SDB_GET_BINARY(pRaw, dataPos, pStb->pAst1, pStb->ast1Len, _OVER)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStb->ast2Len > 0) {
|
if (pStb->ast2Len > 0) {
|
||||||
pStb->pAst2 = taosMemoryCalloc(pStb->ast2Len, 1);
|
pStb->pAst2 = taosMemoryCalloc(pStb->ast2Len, 1);
|
||||||
if (pStb->pAst2 == NULL) goto _OVER;
|
if (pStb->pAst2 == NULL) goto _OVER;
|
||||||
|
@ -273,6 +273,7 @@ static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb) {
|
||||||
taosMemoryFreeClear(pStb->pColumns);
|
taosMemoryFreeClear(pStb->pColumns);
|
||||||
taosMemoryFreeClear(pStb->pTags);
|
taosMemoryFreeClear(pStb->pTags);
|
||||||
taosMemoryFreeClear(pStb->comment);
|
taosMemoryFreeClear(pStb->comment);
|
||||||
|
taosMemoryFreeClear(pStb->pFuncs);
|
||||||
taosMemoryFreeClear(pStb->pAst1);
|
taosMemoryFreeClear(pStb->pAst1);
|
||||||
taosMemoryFreeClear(pStb->pAst2);
|
taosMemoryFreeClear(pStb->pAst2);
|
||||||
taosArrayDestroy(pStb->pFuncs);
|
taosArrayDestroy(pStb->pFuncs);
|
||||||
|
@ -322,7 +323,7 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
|
||||||
pOld->commentLen = pNew->commentLen;
|
pOld->commentLen = pNew->commentLen;
|
||||||
|
|
||||||
if (pOld->ast1Len < pNew->ast1Len) {
|
if (pOld->ast1Len < pNew->ast1Len) {
|
||||||
void *pAst1 = taosMemoryMalloc(pNew->ast1Len);
|
void *pAst1 = taosMemoryMalloc(pNew->ast1Len + 1);
|
||||||
if (pAst1 != NULL) {
|
if (pAst1 != NULL) {
|
||||||
taosMemoryFree(pOld->pAst1);
|
taosMemoryFree(pOld->pAst1);
|
||||||
pOld->pAst1 = pAst1;
|
pOld->pAst1 = pAst1;
|
||||||
|
@ -334,7 +335,7 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pOld->ast2Len < pNew->ast2Len) {
|
if (pOld->ast2Len < pNew->ast2Len) {
|
||||||
void *pAst2 = taosMemoryMalloc(pNew->ast2Len);
|
void *pAst2 = taosMemoryMalloc(pNew->ast2Len + 1);
|
||||||
if (pAst2 != NULL) {
|
if (pAst2 != NULL) {
|
||||||
taosMemoryFree(pOld->pAst2);
|
taosMemoryFree(pOld->pAst2);
|
||||||
pOld->pAst2 = pAst2;
|
pOld->pAst2 = pAst2;
|
||||||
|
@ -361,12 +362,15 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
|
||||||
}
|
}
|
||||||
if (pNew->commentLen > 0) {
|
if (pNew->commentLen > 0) {
|
||||||
memcpy(pOld->comment, pNew->comment, pNew->commentLen + 1);
|
memcpy(pOld->comment, pNew->comment, pNew->commentLen + 1);
|
||||||
|
pOld->commentLen = pNew->commentLen;
|
||||||
}
|
}
|
||||||
if (pNew->ast1Len != 0) {
|
if (pNew->ast1Len != 0) {
|
||||||
memcpy(pOld->pAst1, pNew->pAst1, pNew->ast1Len);
|
memcpy(pOld->pAst1, pNew->pAst1, pNew->ast1Len);
|
||||||
|
pOld->ast1Len = pNew->ast1Len;
|
||||||
}
|
}
|
||||||
if (pNew->ast2Len != 0) {
|
if (pNew->ast2Len != 0) {
|
||||||
memcpy(pOld->pAst2, pNew->pAst2, pNew->ast2Len);
|
memcpy(pOld->pAst2, pNew->pAst2, pNew->ast2Len);
|
||||||
|
pOld->ast2Len = pNew->ast2Len;
|
||||||
}
|
}
|
||||||
taosWUnLockLatch(&pOld->lock);
|
taosWUnLockLatch(&pOld->lock);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -575,7 +579,10 @@ int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate) {
|
||||||
static int32_t mndSetCreateStbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
static int32_t mndSetCreateStbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
||||||
SSdbRaw *pRedoRaw = mndStbActionEncode(pStb);
|
SSdbRaw *pRedoRaw = mndStbActionEncode(pStb);
|
||||||
if (pRedoRaw == NULL) return -1;
|
if (pRedoRaw == NULL) return -1;
|
||||||
if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) return -1;
|
if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) {
|
||||||
|
sdbFreeRaw(pRedoRaw);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING) != 0) return -1;
|
if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING) != 0) return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -584,7 +591,10 @@ static int32_t mndSetCreateStbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *p
|
||||||
static int32_t mndSetCreateStbUndoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
static int32_t mndSetCreateStbUndoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
||||||
SSdbRaw *pUndoRaw = mndStbActionEncode(pStb);
|
SSdbRaw *pUndoRaw = mndStbActionEncode(pStb);
|
||||||
if (pUndoRaw == NULL) return -1;
|
if (pUndoRaw == NULL) return -1;
|
||||||
if (mndTransAppendUndolog(pTrans, pUndoRaw) != 0) return -1;
|
if (mndTransAppendUndolog(pTrans, pUndoRaw) != 0) {
|
||||||
|
sdbFreeRaw(pUndoRaw);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED) != 0) return -1;
|
if (sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED) != 0) return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -593,7 +603,10 @@ static int32_t mndSetCreateStbUndoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *p
|
||||||
static int32_t mndSetCreateStbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
static int32_t mndSetCreateStbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
||||||
SSdbRaw *pCommitRaw = mndStbActionEncode(pStb);
|
SSdbRaw *pCommitRaw = mndStbActionEncode(pStb);
|
||||||
if (pCommitRaw == NULL) return -1;
|
if (pCommitRaw == NULL) return -1;
|
||||||
if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1;
|
if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) {
|
||||||
|
sdbFreeRaw(pCommitRaw);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) return -1;
|
if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -613,6 +626,11 @@ static int32_t mndSetCreateStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pVgroup->isTsma) {
|
||||||
|
sdbRelease(pSdb, pVgroup);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
void *pReq = mndBuildVCreateStbReq(pMnode, pVgroup, pStb, &contLen);
|
void *pReq = mndBuildVCreateStbReq(pMnode, pVgroup, pStb, &contLen);
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
|
@ -651,6 +669,11 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pVgroup->isTsma) {
|
||||||
|
sdbRelease(pSdb, pVgroup);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pReq = mndBuildVDropStbReq(pMnode, pVgroup, pStb, &contLen);
|
void *pReq = mndBuildVDropStbReq(pMnode, pVgroup, pStb, &contLen);
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
|
@ -697,6 +720,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
|
||||||
pDst->dbUid = pDb->uid;
|
pDst->dbUid = pDb->uid;
|
||||||
pDst->tagVer = 1;
|
pDst->tagVer = 1;
|
||||||
pDst->colVer = 1;
|
pDst->colVer = 1;
|
||||||
|
pDst->smaVer = 1;
|
||||||
pDst->nextColId = 1;
|
pDst->nextColId = 1;
|
||||||
pDst->maxdelay[0] = pCreate->delay1;
|
pDst->maxdelay[0] = pCreate->delay1;
|
||||||
pDst->maxdelay[1] = pCreate->delay2;
|
pDst->maxdelay[1] = pCreate->delay2;
|
||||||
|
@ -705,6 +729,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
|
||||||
pDst->ttl = pCreate->ttl;
|
pDst->ttl = pCreate->ttl;
|
||||||
pDst->numOfColumns = pCreate->numOfColumns;
|
pDst->numOfColumns = pCreate->numOfColumns;
|
||||||
pDst->numOfTags = pCreate->numOfTags;
|
pDst->numOfTags = pCreate->numOfTags;
|
||||||
|
pDst->numOfFuncs = pCreate->numOfFuncs;
|
||||||
pDst->commentLen = pCreate->commentLen;
|
pDst->commentLen = pCreate->commentLen;
|
||||||
pDst->pFuncs = pCreate->pFuncs;
|
pDst->pFuncs = pCreate->pFuncs;
|
||||||
pCreate->pFuncs = NULL;
|
pCreate->pFuncs = NULL;
|
||||||
|
@ -715,7 +740,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memcpy(pDst->comment, pCreate->comment, pDst->commentLen + 1);
|
memcpy(pDst->comment, pCreate->pComment, pDst->commentLen + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pDst->ast1Len = pCreate->ast1Len;
|
pDst->ast1Len = pCreate->ast1Len;
|
||||||
|
@ -770,20 +795,15 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
|
||||||
|
|
||||||
static int32_t mndCreateStb(SMnode *pMnode, SRpcMsg *pReq, SMCreateStbReq *pCreate, SDbObj *pDb) {
|
static int32_t mndCreateStb(SMnode *pMnode, SRpcMsg *pReq, SMCreateStbReq *pCreate, SDbObj *pDb) {
|
||||||
SStbObj stbObj = {0};
|
SStbObj stbObj = {0};
|
||||||
|
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
|
||||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq);
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq);
|
||||||
if (pTrans == NULL) goto _OVER;
|
if (pTrans == NULL) goto _OVER;
|
||||||
|
|
||||||
mDebug("trans:%d, used to create stb:%s", pTrans->id, pCreate->name);
|
mDebug("trans:%d, used to create stb:%s", pTrans->id, pCreate->name);
|
||||||
|
|
||||||
if (mndBuildStbFromReq(pMnode, &stbObj, pCreate, pDb) != 0) goto _OVER;
|
if (mndBuildStbFromReq(pMnode, &stbObj, pCreate, pDb) != 0) goto _OVER;
|
||||||
|
|
||||||
if (mndAddStbToTrans(pMnode, pTrans, pDb, &stbObj) < 0) goto _OVER;
|
if (mndAddStbToTrans(pMnode, pTrans, pDb, &stbObj) < 0) goto _OVER;
|
||||||
|
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
|
@ -906,7 +926,8 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndCheckAlterStbReq(SMAlterStbReq *pAlter) {
|
static int32_t mndCheckAlterStbReq(SMAlterStbReq *pAlter) {
|
||||||
if (pAlter->commentLen >= 0 || pAlter->ttl != 0) return 0;
|
if (pAlter->commentLen >= 0) return 0;
|
||||||
|
if (pAlter->ttl != 0) return 0;
|
||||||
|
|
||||||
if (pAlter->numOfFields < 1 || pAlter->numOfFields != (int32_t)taosArrayGetSize(pAlter->pFields)) {
|
if (pAlter->numOfFields < 1 || pAlter->numOfFields != (int32_t)taosArrayGetSize(pAlter->pFields)) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||||
|
@ -969,6 +990,7 @@ static int32_t mndUpdateStbCommentAndTTL(const SStbObj *pOld, SStbObj *pNew, cha
|
||||||
memcpy(pNew->comment, pComment, commentLen + 1);
|
memcpy(pNew->comment, pComment, commentLen + 1);
|
||||||
} else if (commentLen == 0) {
|
} else if (commentLen == 0) {
|
||||||
pNew->commentLen = 0;
|
pNew->commentLen = 0;
|
||||||
|
} else {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ttl >= 0) {
|
if (ttl >= 0) {
|
||||||
|
@ -1245,7 +1267,10 @@ static int32_t mndAlterStbColumnBytes(SMnode *pMnode, const SStbObj *pOld, SStbO
|
||||||
static int32_t mndSetAlterStbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
static int32_t mndSetAlterStbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
||||||
SSdbRaw *pRedoRaw = mndStbActionEncode(pStb);
|
SSdbRaw *pRedoRaw = mndStbActionEncode(pStb);
|
||||||
if (pRedoRaw == NULL) return -1;
|
if (pRedoRaw == NULL) return -1;
|
||||||
if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) return -1;
|
if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) {
|
||||||
|
sdbFreeRaw(pRedoRaw);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY) != 0) return -1;
|
if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY) != 0) return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1254,7 +1279,10 @@ static int32_t mndSetAlterStbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pD
|
||||||
static int32_t mndSetAlterStbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
static int32_t mndSetAlterStbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
||||||
SSdbRaw *pCommitRaw = mndStbActionEncode(pStb);
|
SSdbRaw *pCommitRaw = mndStbActionEncode(pStb);
|
||||||
if (pCommitRaw == NULL) return -1;
|
if (pCommitRaw == NULL) return -1;
|
||||||
if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1;
|
if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) {
|
||||||
|
sdbFreeRaw(pCommitRaw);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) return -1;
|
if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1274,6 +1302,11 @@ static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pVgroup->isTsma) {
|
||||||
|
sdbRelease(pSdb, pVgroup);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
void *pReq = mndBuildVCreateStbReq(pMnode, pVgroup, pStb, &contLen);
|
void *pReq = mndBuildVCreateStbReq(pMnode, pVgroup, pStb, &contLen);
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
|
@ -1388,7 +1421,7 @@ static int32_t mndBuildStbCfgImp(SDbObj *pDb, SStbObj *pStb, const char *tbName,
|
||||||
pSchema->bytes = pSrcSchema->bytes;
|
pSchema->bytes = pSrcSchema->bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStb->pFuncs) {
|
if (pStb->numOfFuncs > 0) {
|
||||||
pRsp->pFuncs = taosArrayDup(pStb->pFuncs);
|
pRsp->pFuncs = taosArrayDup(pStb->pFuncs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1626,7 +1659,10 @@ _OVER:
|
||||||
static int32_t mndSetDropStbRedoLogs(SMnode *pMnode, STrans *pTrans, SStbObj *pStb) {
|
static int32_t mndSetDropStbRedoLogs(SMnode *pMnode, STrans *pTrans, SStbObj *pStb) {
|
||||||
SSdbRaw *pRedoRaw = mndStbActionEncode(pStb);
|
SSdbRaw *pRedoRaw = mndStbActionEncode(pStb);
|
||||||
if (pRedoRaw == NULL) return -1;
|
if (pRedoRaw == NULL) return -1;
|
||||||
if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) return -1;
|
if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) {
|
||||||
|
sdbFreeRaw(pRedoRaw);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING) != 0) return -1;
|
if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING) != 0) return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1635,7 +1671,10 @@ static int32_t mndSetDropStbRedoLogs(SMnode *pMnode, STrans *pTrans, SStbObj *pS
|
||||||
static int32_t mndSetDropStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStbObj *pStb) {
|
static int32_t mndSetDropStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStbObj *pStb) {
|
||||||
SSdbRaw *pCommitRaw = mndStbActionEncode(pStb);
|
SSdbRaw *pCommitRaw = mndStbActionEncode(pStb);
|
||||||
if (pCommitRaw == NULL) return -1;
|
if (pCommitRaw == NULL) return -1;
|
||||||
if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1;
|
if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) {
|
||||||
|
sdbFreeRaw(pCommitRaw);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED) != 0) return -1;
|
if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED) != 0) return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1654,6 +1693,11 @@ static int32_t mndSetDropStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pVgroup->isTsma) {
|
||||||
|
sdbRelease(pSdb, pVgroup);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pReq = mndBuildVDropStbReq(pMnode, pVgroup, pStb, &contLen);
|
void *pReq = mndBuildVDropStbReq(pMnode, pVgroup, pStb, &contLen);
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
|
@ -1683,7 +1727,7 @@ static int32_t mndSetDropStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *
|
||||||
|
|
||||||
static int32_t mndDropStb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb) {
|
static int32_t mndDropStb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq);
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq);
|
||||||
if (pTrans == NULL) goto _OVER;
|
if (pTrans == NULL) goto _OVER;
|
||||||
|
|
||||||
mDebug("trans:%d, used to drop stb:%s", pTrans->id, pStb->name);
|
mDebug("trans:%d, used to drop stb:%s", pTrans->id, pStb->name);
|
||||||
|
|
|
@ -117,7 +117,7 @@ void mndReConfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta cbM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndSnapshotStartRead(struct SSyncFSM *pFsm, void **ppReader) {
|
int32_t mndSnapshotStartRead(struct SSyncFSM *pFsm, void *pParam, void **ppReader) {
|
||||||
mDebug("start to read snapshot from sdb");
|
mDebug("start to read snapshot from sdb");
|
||||||
SMnode *pMnode = pFsm->data;
|
SMnode *pMnode = pFsm->data;
|
||||||
return sdbStartRead(pMnode->pSdb, (SSdbIter **)ppReader, NULL, NULL, NULL);
|
return sdbStartRead(pMnode->pSdb, (SSdbIter **)ppReader, NULL, NULL, NULL);
|
||||||
|
|
|
@ -426,7 +426,15 @@ static int32_t mndCompareDnodeId(int32_t *dnode1Id, int32_t *dnode2Id) { return
|
||||||
static int32_t mndCompareDnodeVnodes(SDnodeObj *pDnode1, SDnodeObj *pDnode2) {
|
static int32_t mndCompareDnodeVnodes(SDnodeObj *pDnode1, SDnodeObj *pDnode2) {
|
||||||
float d1Score = (float)pDnode1->numOfVnodes / pDnode1->numOfSupportVnodes;
|
float d1Score = (float)pDnode1->numOfVnodes / pDnode1->numOfSupportVnodes;
|
||||||
float d2Score = (float)pDnode2->numOfVnodes / pDnode2->numOfSupportVnodes;
|
float d2Score = (float)pDnode2->numOfVnodes / pDnode2->numOfSupportVnodes;
|
||||||
|
#if 0
|
||||||
|
if (d1Score == d2Score) {
|
||||||
|
return pDnode2->id - pDnode1->id;
|
||||||
|
} else {
|
||||||
|
return d1Score >= d2Score ? 1 : 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
return d1Score >= d2Score ? 1 : 0;
|
return d1Score >= d2Score ? 1 : 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void mndSortVnodeGid(SVgObj *pVgroup) {
|
void mndSortVnodeGid(SVgObj *pVgroup) {
|
||||||
|
|
|
@ -65,7 +65,7 @@ int32_t qndGetLoad(SQnode *pQnode, SQnodeLoad *pLoad) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qndPreprocessQueryMsg(SQnode *pQnode, SRpcMsg * pMsg) {
|
int32_t qndPreprocessQueryMsg(SQnode *pQnode, SRpcMsg * pMsg) {
|
||||||
if (TDMT_VND_QUERY != pMsg->msgType) {
|
if (TDMT_SCH_QUERY != pMsg->msgType && TDMT_SCH_MERGE_QUERY != pMsg->msgType) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,28 +78,29 @@ int32_t qndProcessQueryMsg(SQnode *pQnode, int64_t ts, SRpcMsg *pMsg) {
|
||||||
qTrace("message in qnode queue is processing");
|
qTrace("message in qnode queue is processing");
|
||||||
|
|
||||||
switch (pMsg->msgType) {
|
switch (pMsg->msgType) {
|
||||||
case TDMT_VND_QUERY:
|
case TDMT_SCH_QUERY:
|
||||||
|
case TDMT_SCH_MERGE_QUERY:
|
||||||
code = qWorkerProcessQueryMsg(&handle, pQnode->pQuery, pMsg, ts);
|
code = qWorkerProcessQueryMsg(&handle, pQnode->pQuery, pMsg, ts);
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_QUERY_CONTINUE:
|
case TDMT_SCH_QUERY_CONTINUE:
|
||||||
code = qWorkerProcessCQueryMsg(&handle, pQnode->pQuery, pMsg, ts);
|
code = qWorkerProcessCQueryMsg(&handle, pQnode->pQuery, pMsg, ts);
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_FETCH:
|
case TDMT_SCH_FETCH:
|
||||||
code = qWorkerProcessFetchMsg(pQnode, pQnode->pQuery, pMsg, ts);
|
code = qWorkerProcessFetchMsg(pQnode, pQnode->pQuery, pMsg, ts);
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_FETCH_RSP:
|
case TDMT_SCH_FETCH_RSP:
|
||||||
code = qWorkerProcessFetchRsp(pQnode, pQnode->pQuery, pMsg, ts);
|
code = qWorkerProcessFetchRsp(pQnode, pQnode->pQuery, pMsg, ts);
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_CANCEL_TASK:
|
case TDMT_SCH_CANCEL_TASK:
|
||||||
code = qWorkerProcessCancelMsg(pQnode, pQnode->pQuery, pMsg, ts);
|
code = qWorkerProcessCancelMsg(pQnode, pQnode->pQuery, pMsg, ts);
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_DROP_TASK:
|
case TDMT_SCH_DROP_TASK:
|
||||||
code = qWorkerProcessDropMsg(pQnode, pQnode->pQuery, pMsg, ts);
|
code = qWorkerProcessDropMsg(pQnode, pQnode->pQuery, pMsg, ts);
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_CONSUME:
|
case TDMT_VND_CONSUME:
|
||||||
// code = tqProcessConsumeReq(pQnode->pTq, pMsg);
|
// code = tqProcessConsumeReq(pQnode->pTq, pMsg);
|
||||||
// break;
|
// break;
|
||||||
case TDMT_VND_QUERY_HEARTBEAT:
|
case TDMT_SCH_QUERY_HEARTBEAT:
|
||||||
code = qWorkerProcessHbMsg(pQnode, pQnode->pQuery, pMsg, ts);
|
code = qWorkerProcessHbMsg(pQnode, pQnode->pQuery, pMsg, ts);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -116,6 +116,7 @@ typedef void *tsdbReaderT;
|
||||||
#define BLOCK_LOAD_TABLE_SEQ_ORDER 2
|
#define BLOCK_LOAD_TABLE_SEQ_ORDER 2
|
||||||
#define BLOCK_LOAD_TABLE_RR_ORDER 3
|
#define BLOCK_LOAD_TABLE_RR_ORDER 3
|
||||||
|
|
||||||
|
int32_t tsdbSetTableId(tsdbReaderT reader, int64_t uid);
|
||||||
int32_t tsdbSetTableList(tsdbReaderT reader, SArray *tableList);
|
int32_t tsdbSetTableList(tsdbReaderT reader, SArray *tableList);
|
||||||
tsdbReaderT tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, SArray *tableList, uint64_t qId,
|
tsdbReaderT tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, SArray *tableList, uint64_t qId,
|
||||||
uint64_t taskId);
|
uint64_t taskId);
|
||||||
|
|
|
@ -157,11 +157,11 @@ typedef struct {
|
||||||
static STqMgmt tqMgmt = {0};
|
static STqMgmt tqMgmt = {0};
|
||||||
|
|
||||||
// tqRead
|
// tqRead
|
||||||
int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalHead** pHeadWithCkSum);
|
int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** pHeadWithCkSum);
|
||||||
|
|
||||||
// tqExec
|
// tqExec
|
||||||
int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataRsp* pRsp, int32_t workerId);
|
int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataRsp* pRsp, int32_t workerId);
|
||||||
int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, int32_t workerId);
|
int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal offset, int32_t workerId);
|
||||||
int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp);
|
int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp);
|
||||||
|
|
||||||
// tqMeta
|
// tqMeta
|
||||||
|
@ -178,11 +178,23 @@ STqOffsetStore* tqOffsetOpen();
|
||||||
void tqOffsetClose(STqOffsetStore*);
|
void tqOffsetClose(STqOffsetStore*);
|
||||||
STqOffset* tqOffsetRead(STqOffsetStore* pStore, const char* subscribeKey);
|
STqOffset* tqOffsetRead(STqOffsetStore* pStore, const char* subscribeKey);
|
||||||
int32_t tqOffsetWrite(STqOffsetStore* pStore, const STqOffset* pOffset);
|
int32_t tqOffsetWrite(STqOffsetStore* pStore, const STqOffset* pOffset);
|
||||||
|
int32_t tqOffsetDelete(STqOffsetStore* pStore, const char* subscribeKey);
|
||||||
int32_t tqOffsetSnapshot(STqOffsetStore* pStore);
|
int32_t tqOffsetSnapshot(STqOffsetStore* pStore);
|
||||||
|
|
||||||
// tqSink
|
// tqSink
|
||||||
void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data);
|
void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data);
|
||||||
|
|
||||||
|
static FORCE_INLINE void tqOffsetResetToData(STqOffsetVal* pOffsetVal, int64_t uid, int64_t ts) {
|
||||||
|
pOffsetVal->type = TMQ_OFFSET__SNAPSHOT_DATA;
|
||||||
|
pOffsetVal->uid = uid;
|
||||||
|
pOffsetVal->ts = ts;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void tqOffsetResetToLog(STqOffsetVal* pOffsetVal, int64_t ver) {
|
||||||
|
pOffsetVal->type = TMQ_OFFSET__LOG;
|
||||||
|
pOffsetVal->version = ver;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -113,7 +113,7 @@ int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) {
|
||||||
if (!pDataBlocks) {
|
if (!pDataBlocks) {
|
||||||
terrno = TSDB_CODE_TSMA_INVALID_PTR;
|
terrno = TSDB_CODE_TSMA_INVALID_PTR;
|
||||||
smaWarn("vgId:%d, insert tsma data failed since pDataBlocks is NULL", SMA_VID(pSma));
|
smaWarn("vgId:%d, insert tsma data failed since pDataBlocks is NULL", SMA_VID(pSma));
|
||||||
return terrno;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosArrayGetSize(pDataBlocks) <= 0) {
|
if (taosArrayGetSize(pDataBlocks) <= 0) {
|
||||||
|
@ -127,9 +127,9 @@ int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSmaEnv *pEnv = SMA_TSMA_ENV(pSma);
|
SSmaEnv *pEnv = SMA_TSMA_ENV(pSma);
|
||||||
SSmaStat *pStat = NULL;
|
SSmaStat *pStat = NULL;
|
||||||
STSmaStat *pItem = NULL;
|
STSmaStat *pTsmaStat = NULL;
|
||||||
|
|
||||||
if (!pEnv || !(pStat = SMA_ENV_STAT(pEnv))) {
|
if (!pEnv || !(pStat = SMA_ENV_STAT(pEnv))) {
|
||||||
terrno = TSDB_CODE_TSMA_INVALID_STAT;
|
terrno = TSDB_CODE_TSMA_INVALID_STAT;
|
||||||
|
@ -137,32 +137,43 @@ int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tdRefSmaStat(pSma, pStat);
|
tdRefSmaStat(pSma, pStat);
|
||||||
pItem = &pStat->tsmaStat;
|
pTsmaStat = SMA_TSMA_STAT(pStat);
|
||||||
|
|
||||||
ASSERT(pItem);
|
if (!pTsmaStat->pTSma) {
|
||||||
|
|
||||||
if (!pItem->pTSma) {
|
|
||||||
STSma *pTSma = metaGetSmaInfoByIndex(SMA_META(pSma), indexUid);
|
STSma *pTSma = metaGetSmaInfoByIndex(SMA_META(pSma), indexUid);
|
||||||
if (!pTSma) {
|
if (!pTSma) {
|
||||||
terrno = TSDB_CODE_TSMA_NO_INDEX_IN_META;
|
smaError("vgId:%d, failed to get STSma while tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma),
|
||||||
smaWarn("vgId:%d, tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma), indexUid, tstrerror(terrno));
|
indexUid, tstrerror(terrno));
|
||||||
return TSDB_CODE_FAILED;
|
goto _err;
|
||||||
|
}
|
||||||
|
pTsmaStat->pTSma = pTSma;
|
||||||
|
pTsmaStat->pTSchema = metaGetTbTSchema(SMA_META(pSma), pTSma->dstTbUid, -1);
|
||||||
|
if (!pTsmaStat->pTSchema) {
|
||||||
|
smaError("vgId:%d, failed to get STSchema while tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma),
|
||||||
|
indexUid, tstrerror(terrno));
|
||||||
|
goto _err;
|
||||||
}
|
}
|
||||||
pItem->pTSma = pTSma;
|
|
||||||
pItem->pTSchema = metaGetTbTSchema(SMA_META(pSma), pTSma->dstTbUid, -1);
|
|
||||||
ASSERT(pItem->pTSchema); // TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(pItem->pTSma->indexUid == indexUid);
|
if (pTsmaStat->pTSma->indexUid != indexUid) {
|
||||||
|
terrno = TSDB_CODE_VND_APP_ERROR;
|
||||||
|
smaError("vgId:%d, tsma insert for smaIndex %" PRIi64 "(!=%" PRIi64 ") failed since %s", SMA_VID(pSma), indexUid,
|
||||||
|
pTsmaStat->pTSma->indexUid, tstrerror(terrno));
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
SSubmitReq *pSubmitReq = NULL;
|
SSubmitReq *pSubmitReq = tdBlockToSubmit((const SArray *)msg, pTsmaStat->pTSchema, true, pTsmaStat->pTSma->dstTbUid,
|
||||||
|
pTsmaStat->pTSma->dstTbName, pTsmaStat->pTSma->dstVgId);
|
||||||
|
|
||||||
pSubmitReq = tdBlockToSubmit((const SArray *)msg, pItem->pTSchema, true, pItem->pTSma->dstTbUid,
|
if (!pSubmitReq) {
|
||||||
pItem->pTSma->dstTbName, pItem->pTSma->dstVgId);
|
smaError("vgId:%d, failed to gen submit blk while tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma),
|
||||||
|
indexUid, tstrerror(terrno));
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
ASSERT(pSubmitReq); // TODO
|
#if 0
|
||||||
|
ASSERT(!strncasecmp("td.tsma.rst.tb", pTsmaStat->pTSma->dstTbName, 14));
|
||||||
ASSERT(!strncasecmp("td.tsma.rst.tb", pItem->pTSma->dstTbName, 14));
|
#endif
|
||||||
|
|
||||||
SRpcMsg submitReqMsg = {
|
SRpcMsg submitReqMsg = {
|
||||||
.msgType = TDMT_VND_SUBMIT,
|
.msgType = TDMT_VND_SUBMIT,
|
||||||
|
@ -170,9 +181,15 @@ int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) {
|
||||||
.contLen = ntohl(pSubmitReq->length),
|
.contLen = ntohl(pSubmitReq->length),
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSERT(tmsgPutToQueue(&pSma->pVnode->msgCb, WRITE_QUEUE, &submitReqMsg) == 0);
|
if (tmsgPutToQueue(&pSma->pVnode->msgCb, WRITE_QUEUE, &submitReqMsg) < 0) {
|
||||||
|
smaError("vgId:%d, failed to put SubmitReq msg while tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma),
|
||||||
|
indexUid, tstrerror(terrno));
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
tdUnRefSmaStat(pSma, pStat);
|
tdUnRefSmaStat(pSma, pStat);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
_err:
|
||||||
|
tdUnRefSmaStat(pSma, pStat);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
|
@ -154,10 +154,10 @@ int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, con
|
||||||
};
|
};
|
||||||
tmsgSendRsp(&rsp);
|
tmsgSendRsp(&rsp);
|
||||||
|
|
||||||
char buf1[50];
|
char buf1[80];
|
||||||
char buf2[50];
|
char buf2[80];
|
||||||
tFormatOffset(buf1, 50, &pRsp->reqOffset);
|
tFormatOffset(buf1, 80, &pRsp->reqOffset);
|
||||||
tFormatOffset(buf2, 50, &pRsp->rspOffset);
|
tFormatOffset(buf2, 80, &pRsp->rspOffset);
|
||||||
tqDebug("vg %d from consumer %ld (epoch %d) send rsp, block num: %d, reqOffset: %s, rspOffset: %s",
|
tqDebug("vg %d from consumer %ld (epoch %d) send rsp, block num: %d, reqOffset: %s, rspOffset: %s",
|
||||||
TD_VID(pTq->pVnode), pReq->consumerId, pReq->epoch, pRsp->blockNum, buf1, buf2);
|
TD_VID(pTq->pVnode), pReq->consumerId, pReq->epoch, pRsp->blockNum, buf1, buf2);
|
||||||
|
|
||||||
|
@ -228,17 +228,6 @@ static int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq, int8_t su
|
||||||
|
|
||||||
static int32_t tqInitMetaRsp(SMqMetaRsp* pRsp, const SMqPollReq* pReq) { return 0; }
|
static int32_t tqInitMetaRsp(SMqMetaRsp* pRsp, const SMqPollReq* pReq) { return 0; }
|
||||||
|
|
||||||
static FORCE_INLINE void tqOffsetResetToData(STqOffsetVal* pOffsetVal, int64_t uid, int64_t ts) {
|
|
||||||
pOffsetVal->type = TMQ_OFFSET__SNAPSHOT_DATA;
|
|
||||||
pOffsetVal->uid = uid;
|
|
||||||
pOffsetVal->ts = ts;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE void tqOffsetResetToLog(STqOffsetVal* pOffsetVal, int64_t ver) {
|
|
||||||
pOffsetVal->type = TMQ_OFFSET__LOG;
|
|
||||||
pOffsetVal->version = ver;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
SMqPollReq* pReq = pMsg->pCont;
|
SMqPollReq* pReq = pMsg->pCont;
|
||||||
int64_t consumerId = pReq->consumerId;
|
int64_t consumerId = pReq->consumerId;
|
||||||
|
@ -249,8 +238,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
STqOffsetVal fetchOffsetNew;
|
STqOffsetVal fetchOffsetNew;
|
||||||
|
|
||||||
// 1.find handle
|
// 1.find handle
|
||||||
char buf[50];
|
char buf[80];
|
||||||
tFormatOffset(buf, 50, &reqOffset);
|
tFormatOffset(buf, 80, &reqOffset);
|
||||||
tqDebug("tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req offset %s", consumerId, pReq->epoch,
|
tqDebug("tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req offset %s", consumerId, pReq->epoch,
|
||||||
TD_VID(pTq->pVnode), buf);
|
TD_VID(pTq->pVnode), buf);
|
||||||
|
|
||||||
|
@ -282,12 +271,12 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, pReq->subKey);
|
STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, pReq->subKey);
|
||||||
if (pOffset != NULL) {
|
if (pOffset != NULL) {
|
||||||
fetchOffsetNew = pOffset->val;
|
fetchOffsetNew = pOffset->val;
|
||||||
char formatBuf[50];
|
char formatBuf[80];
|
||||||
tFormatOffset(formatBuf, 50, &fetchOffsetNew);
|
tFormatOffset(formatBuf, 80, &fetchOffsetNew);
|
||||||
tqDebug("tmq poll: consumer %ld, offset reset to %s", consumerId, formatBuf);
|
tqDebug("tmq poll: consumer %ld, offset reset to %s", consumerId, formatBuf);
|
||||||
} else {
|
} else {
|
||||||
if (reqOffset.type == TMQ_OFFSET__RESET_EARLIEAST) {
|
if (reqOffset.type == TMQ_OFFSET__RESET_EARLIEAST) {
|
||||||
if (pReq->useSnapshot) {
|
if (pReq->useSnapshot && pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||||
if (!pHandle->fetchMeta) {
|
if (!pHandle->fetchMeta) {
|
||||||
tqOffsetResetToData(&fetchOffsetNew, 0, 0);
|
tqOffsetResetToData(&fetchOffsetNew, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -313,9 +302,9 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
tqInitDataRsp(&dataRsp, pReq, pHandle->execHandle.subType);
|
tqInitDataRsp(&dataRsp, pReq, pHandle->execHandle.subType);
|
||||||
|
|
||||||
if (fetchOffsetNew.type == TMQ_OFFSET__LOG) {
|
if (fetchOffsetNew.type == TMQ_OFFSET__LOG) {
|
||||||
int64_t fetchVer = fetchOffsetNew.version + 1;
|
int64_t fetchVer = fetchOffsetNew.version + 1;
|
||||||
SWalHead* pHeadWithCkSum = taosMemoryMalloc(sizeof(SWalHead) + 2048);
|
SWalCkHead* pCkHead = taosMemoryMalloc(sizeof(SWalCkHead) + 2048);
|
||||||
if (pHeadWithCkSum == NULL) {
|
if (pCkHead == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +318,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tqFetchLog(pTq, pHandle, &fetchVer, &pHeadWithCkSum) < 0) {
|
if (tqFetchLog(pTq, pHandle, &fetchVer, &pCkHead) < 0) {
|
||||||
// TODO add push mgr
|
// TODO add push mgr
|
||||||
|
|
||||||
tqOffsetResetToLog(&dataRsp.rspOffset, fetchVer);
|
tqOffsetResetToLog(&dataRsp.rspOffset, fetchVer);
|
||||||
|
@ -340,7 +329,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
goto OVER;
|
goto OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWalReadHead* pHead = &pHeadWithCkSum->head;
|
SWalCont* pHead = &pCkHead->head;
|
||||||
|
|
||||||
tqDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d", consumerId, pReq->epoch,
|
tqDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d", consumerId, pReq->epoch,
|
||||||
TD_VID(pTq->pVnode), fetchVer, pHead->msgType);
|
TD_VID(pTq->pVnode), fetchVer, pHead->msgType);
|
||||||
|
@ -371,7 +360,6 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
tqInfo("fetch meta msg, ver: %ld, type: %d", pHead->version, pHead->msgType);
|
tqInfo("fetch meta msg, ver: %ld, type: %d", pHead->version, pHead->msgType);
|
||||||
SMqMetaRsp metaRsp = {0};
|
SMqMetaRsp metaRsp = {0};
|
||||||
metaRsp.reqOffset = pReq->reqOffset.version;
|
metaRsp.reqOffset = pReq->reqOffset.version;
|
||||||
/*tqOffsetResetToLog(&metaR)*/
|
|
||||||
metaRsp.rspOffset = fetchVer;
|
metaRsp.rspOffset = fetchVer;
|
||||||
metaRsp.resMsgType = pHead->msgType;
|
metaRsp.resMsgType = pHead->msgType;
|
||||||
metaRsp.metaRspLen = pHead->bodyLen;
|
metaRsp.metaRspLen = pHead->bodyLen;
|
||||||
|
@ -385,25 +373,17 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(pHeadWithCkSum);
|
taosMemoryFree(pCkHead);
|
||||||
} else if (fetchOffsetNew.type == TMQ_OFFSET__SNAPSHOT_DATA) {
|
} else if (fetchOffsetNew.type == TMQ_OFFSET__SNAPSHOT_DATA) {
|
||||||
// 1. set uid and ts
|
tqInfo("retrieve using snapshot req offset: uid %ld ts %ld, actual offset: uid %ld ts %ld", dataRsp.reqOffset.uid,
|
||||||
// 2. get data (rebuild reader if needed)
|
dataRsp.reqOffset.ts, fetchOffsetNew.uid, fetchOffsetNew.ts);
|
||||||
// 3. get new uid and ts
|
if (tqScanSnapshot(pTq, &pHandle->execHandle, &dataRsp, fetchOffsetNew, workerId) < 0) {
|
||||||
|
|
||||||
char formatBuf[50];
|
|
||||||
tFormatOffset(formatBuf, 50, &dataRsp.reqOffset);
|
|
||||||
tqInfo("retrieve using snapshot req offset %s", formatBuf);
|
|
||||||
if (tqScanSnapshot(pTq, &pHandle->execHandle, &dataRsp, workerId) < 0) {
|
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. send rsp
|
// 4. send rsp
|
||||||
if (dataRsp.blockNum != 0) {
|
if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) {
|
||||||
tqOffsetResetToData(&dataRsp.rspOffset, 0, 0);
|
code = -1;
|
||||||
if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) {
|
|
||||||
code = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (fetchOffsetNew.type == TMQ_OFFSET__SNAPSHOT_META) {
|
} else if (fetchOffsetNew.type == TMQ_OFFSET__SNAPSHOT_META) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
|
@ -543,7 +523,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWalReadHead* pHead = &pHeadWithCkSum->head;
|
SWalCont* pHead = &pHeadWithCkSum->head;
|
||||||
|
|
||||||
tqDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d", consumerId, pReq->epoch,
|
tqDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d", consumerId, pReq->epoch,
|
||||||
TD_VID(pTq->pVnode), fetchOffset, pHead->msgType);
|
TD_VID(pTq->pVnode), fetchOffset, pHead->msgType);
|
||||||
|
@ -618,6 +598,8 @@ int32_t tqProcessVgDeleteReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
int32_t code = taosHashRemove(pTq->handles, pReq->subKey, strlen(pReq->subKey));
|
int32_t code = taosHashRemove(pTq->handles, pReq->subKey, strlen(pReq->subKey));
|
||||||
ASSERT(code == 0);
|
ASSERT(code == 0);
|
||||||
|
|
||||||
|
tqOffsetDelete(pTq->pOffsetStore, pReq->subKey);
|
||||||
|
|
||||||
if (tqMetaDeleteHandle(pTq, pReq->subKey) < 0) {
|
if (tqMetaDeleteHandle(pTq, pReq->subKey) < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
@ -655,6 +637,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
.reader = pHandle->execHandle.pExecReader[i],
|
.reader = pHandle->execHandle.pExecReader[i],
|
||||||
.meta = pTq->pVnode->pMeta,
|
.meta = pTq->pVnode->pMeta,
|
||||||
.vnode = pTq->pVnode,
|
.vnode = pTq->pVnode,
|
||||||
|
.tqReader = true,
|
||||||
};
|
};
|
||||||
pHandle->execHandle.execCol.task[i] = qCreateStreamExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle);
|
pHandle->execHandle.execCol.task[i] = qCreateStreamExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle);
|
||||||
ASSERT(pHandle->execHandle.execCol.task[i]);
|
ASSERT(pHandle->execHandle.execCol.task[i]);
|
||||||
|
|
|
@ -59,13 +59,19 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp, i
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, int32_t workerId) {
|
int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal offset, int32_t workerId) {
|
||||||
ASSERT(pExec->subType == TOPIC_SUB_TYPE__COLUMN);
|
ASSERT(pExec->subType == TOPIC_SUB_TYPE__COLUMN);
|
||||||
qTaskInfo_t task = pExec->execCol.task[workerId];
|
qTaskInfo_t task = pExec->execCol.task[workerId];
|
||||||
// TODO set uid and ts
|
|
||||||
if (qStreamScanSnapshot(task) < 0) {
|
/*if (qStreamScanSnapshot(task) < 0) {*/
|
||||||
|
/*ASSERT(0);*/
|
||||||
|
/*}*/
|
||||||
|
|
||||||
|
if (qStreamPrepareScan(task, offset.uid, offset.ts) < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t rowCnt = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
SSDataBlock* pDataBlock = NULL;
|
SSDataBlock* pDataBlock = NULL;
|
||||||
uint64_t ts = 0;
|
uint64_t ts = 0;
|
||||||
|
@ -80,13 +86,27 @@ int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, i
|
||||||
tqAddBlockDataToRsp(pDataBlock, pRsp);
|
tqAddBlockDataToRsp(pDataBlock, pRsp);
|
||||||
|
|
||||||
if (pRsp->withTbName) {
|
if (pRsp->withTbName) {
|
||||||
// TODO
|
|
||||||
pRsp->withTbName = 0;
|
pRsp->withTbName = 0;
|
||||||
/*int64_t uid = 0;*/
|
#if 0
|
||||||
/*tqAddTbNameToRsp(pTq, uid, pRsp, workerId);*/
|
int64_t uid;
|
||||||
|
int64_t ts;
|
||||||
|
if (qGetStreamScanStatus(task, &uid, &ts) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
tqAddTbNameToRsp(pTq, uid, pRsp, workerId);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
pRsp->blockNum++;
|
pRsp->blockNum++;
|
||||||
|
|
||||||
|
rowCnt += pDataBlock->info.rows;
|
||||||
|
if (rowCnt >= 4096) break;
|
||||||
}
|
}
|
||||||
|
int64_t uid;
|
||||||
|
int64_t ts;
|
||||||
|
if (qGetStreamScanStatus(task, &uid, &ts) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
tqOffsetResetToData(&pRsp->rspOffset, uid, ts);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,10 @@ int32_t tqOffsetWrite(STqOffsetStore* pStore, const STqOffset* pOffset) {
|
||||||
return taosHashPut(pStore->pHash, pOffset->subKey, strlen(pOffset->subKey), pOffset, sizeof(STqOffset));
|
return taosHashPut(pStore->pHash, pOffset->subKey, strlen(pOffset->subKey), pOffset, sizeof(STqOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tqOffsetDelete(STqOffsetStore* pStore, const char* subscribeKey) {
|
||||||
|
return taosHashRemove(pStore->pHash, subscribeKey, strlen(subscribeKey));
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tqOffsetSnapshot(STqOffsetStore* pStore) {
|
int32_t tqOffsetSnapshot(STqOffsetStore* pStore) {
|
||||||
// open file
|
// open file
|
||||||
// TODO file name should be with a version
|
// TODO file name should be with a version
|
||||||
|
|
|
@ -15,13 +15,13 @@
|
||||||
|
|
||||||
#include "tq.h"
|
#include "tq.h"
|
||||||
|
|
||||||
int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalHead** ppHeadWithCkSum) {
|
int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** ppCkHead) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
taosThreadMutexLock(&pHandle->pWalReader->mutex);
|
taosThreadMutexLock(&pHandle->pWalReader->mutex);
|
||||||
int64_t offset = *fetchOffset;
|
int64_t offset = *fetchOffset;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (walFetchHead(pHandle->pWalReader, offset, *ppHeadWithCkSum) < 0) {
|
if (walFetchHead(pHandle->pWalReader, offset, *ppCkHead) < 0) {
|
||||||
tqDebug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, no more log to return", pHandle->consumerId,
|
tqDebug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, no more log to return", pHandle->consumerId,
|
||||||
pHandle->epoch, TD_VID(pTq->pVnode), offset);
|
pHandle->epoch, TD_VID(pTq->pVnode), offset);
|
||||||
*fetchOffset = offset - 1;
|
*fetchOffset = offset - 1;
|
||||||
|
@ -29,8 +29,8 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalHead*
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*ppHeadWithCkSum)->head.msgType == TDMT_VND_SUBMIT) {
|
if ((*ppCkHead)->head.msgType == TDMT_VND_SUBMIT) {
|
||||||
code = walFetchBody(pHandle->pWalReader, ppHeadWithCkSum);
|
code = walFetchBody(pHandle->pWalReader, ppCkHead);
|
||||||
|
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
|
@ -43,9 +43,9 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalHead*
|
||||||
goto END;
|
goto END;
|
||||||
} else {
|
} else {
|
||||||
if (pHandle->fetchMeta) {
|
if (pHandle->fetchMeta) {
|
||||||
SWalReadHead* pHead = &((*ppHeadWithCkSum)->head);
|
SWalCont* pHead = &((*ppCkHead)->head);
|
||||||
if (IS_META_MSG(pHead->msgType)) {
|
if (IS_META_MSG(pHead->msgType)) {
|
||||||
code = walFetchBody(pHandle->pWalReader, ppHeadWithCkSum);
|
code = walFetchBody(pHandle->pWalReader, ppCkHead);
|
||||||
|
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
|
@ -58,7 +58,7 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalHead*
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
code = walSkipFetchBody(pHandle->pWalReader, *ppHeadWithCkSum);
|
code = walSkipFetchBody(pHandle->pWalReader, *ppCkHead);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
*fetchOffset = offset;
|
*fetchOffset = offset;
|
||||||
|
|
|
@ -112,9 +112,9 @@ typedef struct STsdbReadHandle {
|
||||||
STimeWindow window; // the primary query time window that applies to all queries
|
STimeWindow window; // the primary query time window that applies to all queries
|
||||||
// SColumnDataAgg* statis; // query level statistics, only one table block statistics info exists at any time
|
// SColumnDataAgg* statis; // query level statistics, only one table block statistics info exists at any time
|
||||||
// SColumnDataAgg** pstatis;// the ptr array list to return to caller
|
// SColumnDataAgg** pstatis;// the ptr array list to return to caller
|
||||||
int32_t numOfBlocks;
|
int32_t numOfBlocks;
|
||||||
SSDataBlock* pResBlock;
|
SSDataBlock* pResBlock;
|
||||||
// SArray* pColumns; // column list, SColumnInfoData array list
|
// SArray* pColumns; // column list, SColumnInfoData array list
|
||||||
bool locateStart;
|
bool locateStart;
|
||||||
int32_t outputCapacity;
|
int32_t outputCapacity;
|
||||||
int32_t realNumOfRows;
|
int32_t realNumOfRows;
|
||||||
|
@ -223,6 +223,22 @@ int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT* pHandle) {
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SArray* createCheckInfoFromUid(STsdbReadHandle* pTsdbReadHandle, int64_t uid) {
|
||||||
|
SArray* pTableCheckInfo = taosArrayInit(1, sizeof(STableCheckInfo));
|
||||||
|
if (pTableCheckInfo == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
STableCheckInfo info = {
|
||||||
|
.tableId = uid,
|
||||||
|
};
|
||||||
|
info.suid = pTsdbReadHandle->suid;
|
||||||
|
|
||||||
|
taosArrayPush(pTableCheckInfo, &info);
|
||||||
|
tsdbDebug("%p check table uid:%" PRId64 " from lastKey:%" PRId64 " %s", pTsdbReadHandle, info.tableId, info.lastKey,
|
||||||
|
pTsdbReadHandle->idStr);
|
||||||
|
return pTableCheckInfo;
|
||||||
|
}
|
||||||
|
|
||||||
static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, SArray* pTableList) {
|
static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, SArray* pTableList) {
|
||||||
size_t tableSize = taosArrayGetSize(pTableList);
|
size_t tableSize = taosArrayGetSize(pTableList);
|
||||||
|
|
||||||
|
@ -428,8 +444,8 @@ static STsdbReadHandle* tsdbQueryTablesImpl(SVnode* pVnode, SQueryTableDataCond*
|
||||||
|
|
||||||
for (int32_t i = 0; i < pCond->numOfCols; ++i) {
|
for (int32_t i = 0; i < pCond->numOfCols; ++i) {
|
||||||
SColumnInfoData colInfo = {.info = pCond->colList[i], 0};
|
SColumnInfoData colInfo = {.info = pCond->colList[i], 0};
|
||||||
int32_t code = blockDataAppendColInfo(pReadHandle->pResBlock, &colInfo);
|
int32_t code = blockDataAppendColInfo(pReadHandle->pResBlock, &colInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS){
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -494,9 +510,19 @@ static int32_t setCurrentSchema(SVnode* pVnode, STsdbReadHandle* pTsdbReadHandle
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbSetTableList(tsdbReaderT reader, SArray* tableList){
|
int32_t tsdbSetTableId(tsdbReaderT reader, int64_t uid) {
|
||||||
STsdbReadHandle* pTsdbReadHandle = reader;
|
STsdbReadHandle* pTsdbReadHandle = reader;
|
||||||
if(pTsdbReadHandle->pTableCheckInfo) taosArrayDestroy(pTsdbReadHandle->pTableCheckInfo);
|
if (pTsdbReadHandle->pTableCheckInfo) taosArrayDestroy(pTsdbReadHandle->pTableCheckInfo);
|
||||||
|
pTsdbReadHandle->pTableCheckInfo = createCheckInfoFromUid(pTsdbReadHandle, uid);
|
||||||
|
if (pTsdbReadHandle->pTableCheckInfo == NULL) {
|
||||||
|
return TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
return TDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tsdbSetTableList(tsdbReaderT reader, SArray* tableList) {
|
||||||
|
STsdbReadHandle* pTsdbReadHandle = reader;
|
||||||
|
if (pTsdbReadHandle->pTableCheckInfo) taosArrayDestroy(pTsdbReadHandle->pTableCheckInfo);
|
||||||
pTsdbReadHandle->pTableCheckInfo = createCheckInfoFromTableGroup(pTsdbReadHandle, tableList);
|
pTsdbReadHandle->pTableCheckInfo = createCheckInfoFromTableGroup(pTsdbReadHandle, tableList);
|
||||||
if (pTsdbReadHandle->pTableCheckInfo == NULL) {
|
if (pTsdbReadHandle->pTableCheckInfo == NULL) {
|
||||||
return TSDB_CODE_TDB_OUT_OF_MEMORY;
|
return TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
|
@ -505,8 +531,8 @@ int32_t tsdbSetTableList(tsdbReaderT reader, SArray* tableList){
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* tableList, uint64_t qId,
|
tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* tableList, uint64_t qId,
|
||||||
uint64_t taskId) {
|
uint64_t taskId) {
|
||||||
if(taosArrayGetSize(tableList) == 0){
|
if (taosArrayGetSize(tableList) == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
STsdbReadHandle* pTsdbReadHandle = tsdbQueryTablesImpl(pVnode, pCond, qId, taskId);
|
STsdbReadHandle* pTsdbReadHandle = tsdbQueryTablesImpl(pVnode, pCond, qId, taskId);
|
||||||
|
@ -553,8 +579,7 @@ tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* t
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbDebug("%p total numOfTable:%" PRIzu " in this query, table %" PRIzu " %s", pTsdbReadHandle,
|
tsdbDebug("%p total numOfTable:%" PRIzu " in this query, table %" PRIzu " %s", pTsdbReadHandle,
|
||||||
taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo), taosArrayGetSize(tableList),
|
taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo), taosArrayGetSize(tableList), pTsdbReadHandle->idStr);
|
||||||
pTsdbReadHandle->idStr);
|
|
||||||
|
|
||||||
return (tsdbReaderT)pTsdbReadHandle;
|
return (tsdbReaderT)pTsdbReadHandle;
|
||||||
}
|
}
|
||||||
|
@ -1073,7 +1098,7 @@ static int32_t getFileIdFromKey(TSKEY key, int32_t daysPerFile, int32_t precisio
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t fid = (int64_t)(key / (daysPerFile * tsTickPerMin[precision])); // set the starting fileId
|
int64_t fid = (int64_t)(key / (daysPerFile * tsTickPerMin[precision])); // set the starting fileId
|
||||||
if (fid < 0LL && llabs(fid) > INT32_MAX) { // data value overflow for INT32
|
if (fid < 0LL && llabs(fid) > INT32_MAX) { // data value overflow for INT32
|
||||||
fid = INT32_MIN;
|
fid = INT32_MIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2612,7 +2637,7 @@ int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT* queryHandle, STableBlockDistInfo*
|
||||||
tsdbGetFidKeyRange(pCfg->days, pCfg->precision, pTsdbReadHandle->pFileGroup->fid, &win.skey, &win.ekey);
|
tsdbGetFidKeyRange(pCfg->days, pCfg->precision, pTsdbReadHandle->pFileGroup->fid, &win.skey, &win.ekey);
|
||||||
|
|
||||||
// current file are not overlapped with query time window, ignore remain files
|
// current file are not overlapped with query time window, ignore remain files
|
||||||
if ((win.skey > pTsdbReadHandle->window.ekey)/* || (!ascTraverse && win.ekey < pTsdbReadHandle->window.ekey)*/) {
|
if ((win.skey > pTsdbReadHandle->window.ekey) /* || (!ascTraverse && win.ekey < pTsdbReadHandle->window.ekey)*/) {
|
||||||
tsdbUnLockFS(REPO_FS(pTsdbReadHandle->pTsdb));
|
tsdbUnLockFS(REPO_FS(pTsdbReadHandle->pTsdb));
|
||||||
tsdbDebug("%p remain files are not qualified for qrange:%" PRId64 "-%" PRId64 ", ignore, %s", pTsdbReadHandle,
|
tsdbDebug("%p remain files are not qualified for qrange:%" PRId64 "-%" PRId64 ", ignore, %s", pTsdbReadHandle,
|
||||||
pTsdbReadHandle->window.skey, pTsdbReadHandle->window.ekey, pTsdbReadHandle->idStr);
|
pTsdbReadHandle->window.skey, pTsdbReadHandle->window.ekey, pTsdbReadHandle->idStr);
|
||||||
|
@ -2886,7 +2911,7 @@ int32_t tsdbGetCtbIdList(SMeta* pMeta, int64_t suid, SArray* list) {
|
||||||
*/
|
*/
|
||||||
int32_t tsdbGetStbIdList(SMeta* pMeta, int64_t suid, SArray* list) {
|
int32_t tsdbGetStbIdList(SMeta* pMeta, int64_t suid, SArray* list) {
|
||||||
SMStbCursor* pCur = metaOpenStbCursor(pMeta, suid);
|
SMStbCursor* pCur = metaOpenStbCursor(pMeta, suid);
|
||||||
if(!pCur) {
|
if (!pCur) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -266,6 +266,8 @@ int vnodeCommit(SVnode *pVnode) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pVnode->state.committed = info.state.committed;
|
||||||
|
|
||||||
// apply the commit (TODO)
|
// apply the commit (TODO)
|
||||||
vnodeBufPoolReset(pVnode->onCommit);
|
vnodeBufPoolReset(pVnode->onCommit);
|
||||||
|
|
|
@ -216,7 +216,7 @@ _err:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vnodePreprocessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
int32_t vnodePreprocessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
if (TDMT_VND_QUERY != pMsg->msgType) {
|
if (TDMT_SCH_QUERY != pMsg->msgType && TDMT_SCH_MERGE_QUERY != pMsg->msgType) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,9 +227,10 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
vTrace("message in vnode query queue is processing");
|
vTrace("message in vnode query queue is processing");
|
||||||
SReadHandle handle = {.meta = pVnode->pMeta, .config = &pVnode->config, .vnode = pVnode, .pMsgCb = &pVnode->msgCb};
|
SReadHandle handle = {.meta = pVnode->pMeta, .config = &pVnode->config, .vnode = pVnode, .pMsgCb = &pVnode->msgCb};
|
||||||
switch (pMsg->msgType) {
|
switch (pMsg->msgType) {
|
||||||
case TDMT_VND_QUERY:
|
case TDMT_SCH_QUERY:
|
||||||
|
case TDMT_SCH_MERGE_QUERY:
|
||||||
return qWorkerProcessQueryMsg(&handle, pVnode->pQuery, pMsg, 0);
|
return qWorkerProcessQueryMsg(&handle, pVnode->pQuery, pMsg, 0);
|
||||||
case TDMT_VND_QUERY_CONTINUE:
|
case TDMT_SCH_QUERY_CONTINUE:
|
||||||
return qWorkerProcessCQueryMsg(&handle, pVnode->pQuery, pMsg, 0);
|
return qWorkerProcessCQueryMsg(&handle, pVnode->pQuery, pMsg, 0);
|
||||||
default:
|
default:
|
||||||
vError("unknown msg type:%d in query queue", pMsg->msgType);
|
vError("unknown msg type:%d in query queue", pMsg->msgType);
|
||||||
|
@ -243,15 +244,15 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
||||||
int32_t msgLen = pMsg->contLen - sizeof(SMsgHead);
|
int32_t msgLen = pMsg->contLen - sizeof(SMsgHead);
|
||||||
|
|
||||||
switch (pMsg->msgType) {
|
switch (pMsg->msgType) {
|
||||||
case TDMT_VND_FETCH:
|
case TDMT_SCH_FETCH:
|
||||||
return qWorkerProcessFetchMsg(pVnode, pVnode->pQuery, pMsg, 0);
|
return qWorkerProcessFetchMsg(pVnode, pVnode->pQuery, pMsg, 0);
|
||||||
case TDMT_VND_FETCH_RSP:
|
case TDMT_SCH_FETCH_RSP:
|
||||||
return qWorkerProcessFetchRsp(pVnode, pVnode->pQuery, pMsg, 0);
|
return qWorkerProcessFetchRsp(pVnode, pVnode->pQuery, pMsg, 0);
|
||||||
case TDMT_VND_CANCEL_TASK:
|
case TDMT_SCH_CANCEL_TASK:
|
||||||
return qWorkerProcessCancelMsg(pVnode, pVnode->pQuery, pMsg, 0);
|
return qWorkerProcessCancelMsg(pVnode, pVnode->pQuery, pMsg, 0);
|
||||||
case TDMT_VND_DROP_TASK:
|
case TDMT_SCH_DROP_TASK:
|
||||||
return qWorkerProcessDropMsg(pVnode, pVnode->pQuery, pMsg, 0);
|
return qWorkerProcessDropMsg(pVnode, pVnode->pQuery, pMsg, 0);
|
||||||
case TDMT_VND_QUERY_HEARTBEAT:
|
case TDMT_SCH_QUERY_HEARTBEAT:
|
||||||
return qWorkerProcessHbMsg(pVnode, pVnode->pQuery, pMsg, 0);
|
return qWorkerProcessHbMsg(pVnode, pVnode->pQuery, pMsg, 0);
|
||||||
case TDMT_VND_TABLE_META:
|
case TDMT_VND_TABLE_META:
|
||||||
return vnodeGetTableMeta(pVnode, pMsg);
|
return vnodeGetTableMeta(pVnode, pMsg);
|
||||||
|
|
|
@ -178,7 +178,7 @@ void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
for (int32_t i = 0; i < newEpSet.numOfEps; ++i) {
|
for (int32_t i = 0; i < newEpSet.numOfEps; ++i) {
|
||||||
vGTrace("vgId:%d, msg:%p redirect:%d ep:%s:%u", vgId, pMsg, i, newEpSet.eps[i].fqdn, newEpSet.eps[i].port);
|
vGTrace("vgId:%d, msg:%p redirect:%d ep:%s:%u", vgId, pMsg, i, newEpSet.eps[i].fqdn, newEpSet.eps[i].port);
|
||||||
}
|
}
|
||||||
|
pMsg->info.hasEpSet = 1;
|
||||||
SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info};
|
SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info};
|
||||||
tmsgSendRedirectRsp(&rsp, &newEpSet);
|
tmsgSendRedirectRsp(&rsp, &newEpSet);
|
||||||
} else {
|
} else {
|
||||||
|
@ -409,7 +409,7 @@ static void vnodeSyncRollBackMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta
|
||||||
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vnodeSnapshotStartRead(struct SSyncFSM *pFsm, void **ppReader) { return 0; }
|
static int32_t vnodeSnapshotStartRead(struct SSyncFSM *pFsm, void *pParam, void **ppReader) { return 0; }
|
||||||
|
|
||||||
static int32_t vnodeSnapshotStopRead(struct SSyncFSM *pFsm, void *pReader) { return 0; }
|
static int32_t vnodeSnapshotStopRead(struct SSyncFSM *pFsm, void *pReader) { return 0; }
|
||||||
|
|
||||||
|
|
|
@ -241,7 +241,7 @@ int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgHandleMsgCallback(void *param, const SDataBuf *pMsg, int32_t rspCode) {
|
int32_t ctgHandleMsgCallback(void *param, SDataBuf *pMsg, int32_t rspCode) {
|
||||||
SCtgTaskCallbackParam* cbParam = (SCtgTaskCallbackParam*)param;
|
SCtgTaskCallbackParam* cbParam = (SCtgTaskCallbackParam*)param;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
|
|
@ -248,6 +248,11 @@ typedef struct SSampleExecInfo {
|
||||||
uint32_t seed; // random seed value
|
uint32_t seed; // random seed value
|
||||||
} SSampleExecInfo;
|
} SSampleExecInfo;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
TABLE_SCAN__TABLE_ORDER = 1,
|
||||||
|
TABLE_SCAN__BLOCK_ORDER = 2,
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct STableScanInfo {
|
typedef struct STableScanInfo {
|
||||||
void* dataReader;
|
void* dataReader;
|
||||||
SReadHandle readHandle;
|
SReadHandle readHandle;
|
||||||
|
@ -272,13 +277,17 @@ typedef struct STableScanInfo {
|
||||||
int32_t curTWinIdx;
|
int32_t curTWinIdx;
|
||||||
|
|
||||||
int32_t currentGroupId;
|
int32_t currentGroupId;
|
||||||
|
int32_t currentTable;
|
||||||
uint64_t queryId; // todo remove it
|
uint64_t queryId; // todo remove it
|
||||||
uint64_t taskId; // todo remove it
|
uint64_t taskId; // todo remove it
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
int64_t t;
|
int64_t ts;
|
||||||
} scanStatus;
|
} lastStatus;
|
||||||
|
|
||||||
|
int8_t scanMode;
|
||||||
|
int8_t noTable;
|
||||||
} STableScanInfo;
|
} STableScanInfo;
|
||||||
|
|
||||||
typedef struct STagScanInfo {
|
typedef struct STagScanInfo {
|
||||||
|
@ -713,6 +722,7 @@ void destroyBasicOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle);
|
void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle);
|
||||||
void setTbNameColData(void* pMeta, const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId);
|
void setTbNameColData(void* pMeta, const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId);
|
||||||
|
|
||||||
|
int32_t doPrepareScan(SOperatorInfo* pOperator, uint64_t uid, int64_t ts);
|
||||||
int32_t doGetScanStatus(SOperatorInfo* pOperator, uint64_t* uid, int64_t* ts);
|
int32_t doGetScanStatus(SOperatorInfo* pOperator, uint64_t* uid, int64_t* ts);
|
||||||
|
|
||||||
SSDataBlock* loadNextDataBlock(void* param);
|
SSDataBlock* loadNextDataBlock(void* param);
|
||||||
|
|
|
@ -118,7 +118,7 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SHashObj* pHashmap, int
|
||||||
|
|
||||||
if (order == TSDB_ORDER_ASC || order == TSDB_ORDER_DESC) {
|
if (order == TSDB_ORDER_ASC || order == TSDB_ORDER_DESC) {
|
||||||
__compar_fn_t fn = (order == TSDB_ORDER_ASC) ? resultrowComparAsc : resultrowComparDesc;
|
__compar_fn_t fn = (order == TSDB_ORDER_ASC) ? resultrowComparAsc : resultrowComparDesc;
|
||||||
qsort(pGroupResInfo->pRows->pData, taosArrayGetSize(pGroupResInfo->pRows), POINTER_BYTES, fn);
|
taosSort(pGroupResInfo->pRows->pData, taosArrayGetSize(pGroupResInfo->pRows), POINTER_BYTES, fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
pGroupResInfo->index = 0;
|
pGroupResInfo->index = 0;
|
||||||
|
|
|
@ -222,7 +222,7 @@ int32_t qSerializeTaskStatus(qTaskInfo_t tinfo, char** pOutput, int32_t* len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qDeserializeTaskStatus(qTaskInfo_t tinfo, const char* pInput, int32_t len) {
|
int32_t qDeserializeTaskStatus(qTaskInfo_t tinfo, const char* pInput, int32_t len) {
|
||||||
SExecTaskInfo* pTaskInfo = (struct SExecTaskInfo*) tinfo;
|
SExecTaskInfo* pTaskInfo = (struct SExecTaskInfo*)tinfo;
|
||||||
|
|
||||||
if (pTaskInfo == NULL || pInput == NULL || len == 0) {
|
if (pTaskInfo == NULL || pInput == NULL || len == 0) {
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
@ -231,11 +231,22 @@ int32_t qDeserializeTaskStatus(qTaskInfo_t tinfo, const char* pInput, int32_t le
|
||||||
return decodeOperator(pTaskInfo->pRoot, pInput, len);
|
return decodeOperator(pTaskInfo->pRoot, pInput, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t qStreamPrepareScan(qTaskInfo_t tinfo, uint64_t uid, int64_t ts) {
|
||||||
|
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||||
|
|
||||||
int32_t qGetStreamScanStatus(qTaskInfo_t tinfo, uint64_t* uid, int64_t* ts) {
|
if (uid == 0) {
|
||||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*) tinfo;
|
if (taosArrayGetSize(pTaskInfo->tableqinfoList.pTableList) != 0) {
|
||||||
|
STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, 0);
|
||||||
|
uid = pTableInfo->uid;
|
||||||
|
ts = INT64_MIN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return doPrepareScan(pTaskInfo->pRoot, uid, ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t qGetStreamScanStatus(qTaskInfo_t tinfo, uint64_t* uid, int64_t* ts) {
|
||||||
|
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||||
|
|
||||||
|
return doGetScanStatus(pTaskInfo->pRoot, uid, ts);
|
||||||
|
}
|
||||||
|
|
|
@ -1033,7 +1033,7 @@ static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSData
|
||||||
SqlFunctionCtx* pCtx = pTableScanInfo->pCtx;
|
SqlFunctionCtx* pCtx = pTableScanInfo->pCtx;
|
||||||
uint32_t status = BLK_DATA_NOT_LOAD;
|
uint32_t status = BLK_DATA_NOT_LOAD;
|
||||||
|
|
||||||
int32_t numOfOutput = 0;//pTableScanInfo->numOfOutput;
|
int32_t numOfOutput = 0; // pTableScanInfo->numOfOutput;
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||||
int32_t functionId = pCtx[i].functionId;
|
int32_t functionId = pCtx[i].functionId;
|
||||||
int32_t colId = pTableScanInfo->pExpr[i].base.pParam[0].pCol->colId;
|
int32_t colId = pTableScanInfo->pExpr[i].base.pParam[0].pCol->colId;
|
||||||
|
@ -1348,7 +1348,7 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR
|
||||||
SColumnInfoData* pSrc = taosArrayGet(px->pDataBlock, i);
|
SColumnInfoData* pSrc = taosArrayGet(px->pDataBlock, i);
|
||||||
SColumnInfoData* pDst = taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* pDst = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
// it is a reserved column for scalar function, and no data in this column yet.
|
// it is a reserved column for scalar function, and no data in this column yet.
|
||||||
if (pDst->pData == NULL) {
|
if (pDst->pData == NULL || pSrc->pData == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1933,7 +1933,7 @@ typedef struct SFetchRspHandleWrapper {
|
||||||
int32_t sourceIndex;
|
int32_t sourceIndex;
|
||||||
} SFetchRspHandleWrapper;
|
} SFetchRspHandleWrapper;
|
||||||
|
|
||||||
int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
SFetchRspHandleWrapper* pWrapper = (SFetchRspHandleWrapper*)param;
|
SFetchRspHandleWrapper* pWrapper = (SFetchRspHandleWrapper*)param;
|
||||||
|
|
||||||
SExchangeInfo* pExchangeInfo = taosAcquireRef(exchangeObjRefPool, pWrapper->exchangeId);
|
SExchangeInfo* pExchangeInfo = taosAcquireRef(exchangeObjRefPool, pWrapper->exchangeId);
|
||||||
|
@ -2010,13 +2010,14 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf
|
||||||
|
|
||||||
ASSERT(pDataInfo->status == EX_SOURCE_DATA_NOT_READY);
|
ASSERT(pDataInfo->status == EX_SOURCE_DATA_NOT_READY);
|
||||||
|
|
||||||
qDebug("%s build fetch msg and send to vgId:%d, ep:%s, taskId:0x%" PRIx64 ", %d/%" PRIzu, GET_TASKID(pTaskInfo),
|
qDebug("%s build fetch msg and send to vgId:%d, ep:%s, taskId:0x%" PRIx64 ", execId:%d, %d/%" PRIzu, GET_TASKID(pTaskInfo),
|
||||||
pSource->addr.nodeId, pSource->addr.epSet.eps[0].fqdn, pSource->taskId, sourceIndex, totalSources);
|
pSource->addr.nodeId, pSource->addr.epSet.eps[0].fqdn, pSource->taskId, pSource->execId, sourceIndex, totalSources);
|
||||||
|
|
||||||
pMsg->header.vgId = htonl(pSource->addr.nodeId);
|
pMsg->header.vgId = htonl(pSource->addr.nodeId);
|
||||||
pMsg->sId = htobe64(pSource->schedId);
|
pMsg->sId = htobe64(pSource->schedId);
|
||||||
pMsg->taskId = htobe64(pSource->taskId);
|
pMsg->taskId = htobe64(pSource->taskId);
|
||||||
pMsg->queryId = htobe64(pTaskInfo->id.queryId);
|
pMsg->queryId = htobe64(pTaskInfo->id.queryId);
|
||||||
|
pMsg->execId = htonl(pSource->execId);
|
||||||
|
|
||||||
// send the fetch remote task result reques
|
// send the fetch remote task result reques
|
||||||
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||||
|
@ -2034,7 +2035,7 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf
|
||||||
pMsgSendInfo->param = pWrapper;
|
pMsgSendInfo->param = pWrapper;
|
||||||
pMsgSendInfo->msgInfo.pData = pMsg;
|
pMsgSendInfo->msgInfo.pData = pMsg;
|
||||||
pMsgSendInfo->msgInfo.len = sizeof(SResFetchReq);
|
pMsgSendInfo->msgInfo.len = sizeof(SResFetchReq);
|
||||||
pMsgSendInfo->msgType = TDMT_VND_FETCH;
|
pMsgSendInfo->msgType = TDMT_SCH_FETCH;
|
||||||
pMsgSendInfo->fp = loadRemoteDataCallback;
|
pMsgSendInfo->fp = loadRemoteDataCallback;
|
||||||
|
|
||||||
int64_t transporterId = 0;
|
int64_t transporterId = 0;
|
||||||
|
@ -2145,9 +2146,9 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
|
||||||
SSDataBlock* pRes = pExchangeInfo->pResult;
|
SSDataBlock* pRes = pExchangeInfo->pResult;
|
||||||
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
||||||
if (pRsp->numOfRows == 0) {
|
if (pRsp->numOfRows == 0) {
|
||||||
qDebug("%s vgId:%d, taskId:0x%" PRIx64 " index:%d completed, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64
|
qDebug("%s vgId:%d, taskId:0x%" PRIx64 " execId:%d index:%d completed, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64
|
||||||
", completed:%d try next %d/%" PRIzu,
|
", completed:%d try next %d/%" PRIzu,
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, i, pDataInfo->totalRows,
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, i, pDataInfo->totalRows,
|
||||||
pExchangeInfo->loadInfo.totalRows, completed + 1, i + 1, totalSources);
|
pExchangeInfo->loadInfo.totalRows, completed + 1, i + 1, totalSources);
|
||||||
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||||
completed += 1;
|
completed += 1;
|
||||||
|
@ -2165,17 +2166,17 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRsp->completed == 1) {
|
if (pRsp->completed == 1) {
|
||||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64
|
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d"
|
||||||
" index:%d completed, numOfRows:%d, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64 ", totalBytes:%" PRIu64
|
" index:%d completed, numOfRows:%d, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64 ", totalBytes:%" PRIu64
|
||||||
", completed:%d try next %d/%" PRIzu,
|
", completed:%d try next %d/%" PRIzu,
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, i, pRes->info.rows, pDataInfo->totalRows,
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, i, pRes->info.rows, pDataInfo->totalRows,
|
||||||
pLoadInfo->totalRows, pLoadInfo->totalSize, completed + 1, i + 1, totalSources);
|
pLoadInfo->totalRows, pLoadInfo->totalSize, completed + 1, i + 1, totalSources);
|
||||||
completed += 1;
|
completed += 1;
|
||||||
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||||
} else {
|
} else {
|
||||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " numOfRows:%d, totalRows:%" PRIu64
|
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%d, totalRows:%" PRIu64
|
||||||
", totalBytes:%" PRIu64,
|
", totalBytes:%" PRIu64,
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pRes->info.rows, pLoadInfo->totalRows,
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRes->info.rows, pLoadInfo->totalRows,
|
||||||
pLoadInfo->totalSize);
|
pLoadInfo->totalSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2249,8 +2250,8 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
|
||||||
SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, pExchangeInfo->current);
|
SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, pExchangeInfo->current);
|
||||||
|
|
||||||
if (pDataInfo->code != TSDB_CODE_SUCCESS) {
|
if (pDataInfo->code != TSDB_CODE_SUCCESS) {
|
||||||
qError("%s vgId:%d, taskID:0x%" PRIx64 " error happens, code:%s", GET_TASKID(pTaskInfo), pSource->addr.nodeId,
|
qError("%s vgId:%d, taskID:0x%" PRIx64 " execId:%d error happens, code:%s", GET_TASKID(pTaskInfo), pSource->addr.nodeId,
|
||||||
pSource->taskId, tstrerror(pDataInfo->code));
|
pSource->taskId, pSource->execId, tstrerror(pDataInfo->code));
|
||||||
pOperator->pTaskInfo->code = pDataInfo->code;
|
pOperator->pTaskInfo->code = pDataInfo->code;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2258,9 +2259,9 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
|
||||||
SRetrieveTableRsp* pRsp = pDataInfo->pRsp;
|
SRetrieveTableRsp* pRsp = pDataInfo->pRsp;
|
||||||
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
||||||
if (pRsp->numOfRows == 0) {
|
if (pRsp->numOfRows == 0) {
|
||||||
qDebug("%s vgId:%d, taskID:0x%" PRIx64 " %d of total completed, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64
|
qDebug("%s vgId:%d, taskID:0x%" PRIx64 " execId:%d %d of total completed, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64
|
||||||
" try next",
|
" try next",
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pExchangeInfo->current + 1,
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pExchangeInfo->current + 1,
|
||||||
pDataInfo->totalRows, pLoadInfo->totalRows);
|
pDataInfo->totalRows, pLoadInfo->totalRows);
|
||||||
|
|
||||||
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||||
|
@ -2276,17 +2277,17 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
|
||||||
pTableRsp->compLen, pTableRsp->numOfCols, startTs, &pDataInfo->totalRows, NULL);
|
pTableRsp->compLen, pTableRsp->numOfCols, startTs, &pDataInfo->totalRows, NULL);
|
||||||
|
|
||||||
if (pRsp->completed == 1) {
|
if (pRsp->completed == 1) {
|
||||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " numOfRows:%d, rowsOfSource:%" PRIu64
|
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%d, rowsOfSource:%" PRIu64
|
||||||
", totalRows:%" PRIu64 ", totalBytes:%" PRIu64 " try next %d/%" PRIzu,
|
", totalRows:%" PRIu64 ", totalBytes:%" PRIu64 " try next %d/%" PRIzu,
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pRes->info.rows, pDataInfo->totalRows,
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRes->info.rows, pDataInfo->totalRows,
|
||||||
pLoadInfo->totalRows, pLoadInfo->totalSize, pExchangeInfo->current + 1, totalSources);
|
pLoadInfo->totalRows, pLoadInfo->totalSize, pExchangeInfo->current + 1, totalSources);
|
||||||
|
|
||||||
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||||
pExchangeInfo->current += 1;
|
pExchangeInfo->current += 1;
|
||||||
} else {
|
} else {
|
||||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " numOfRows:%d, totalRows:%" PRIu64
|
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%d, totalRows:%" PRIu64
|
||||||
", totalBytes:%" PRIu64,
|
", totalBytes:%" PRIu64,
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pRes->info.rows, pLoadInfo->totalRows,
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRes->info.rows, pLoadInfo->totalRows,
|
||||||
pLoadInfo->totalSize);
|
pLoadInfo->totalSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2378,7 +2379,7 @@ static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo*
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfSources; ++i) {
|
for (int32_t i = 0; i < numOfSources; ++i) {
|
||||||
SNodeListNode* pNode = (SNodeListNode*)nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i);
|
SDownstreamSourceNode* pNode = (SDownstreamSourceNode*)nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i);
|
||||||
taosArrayPush(pInfo->pSources, pNode);
|
taosArrayPush(pInfo->pSources, pNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2821,13 +2822,56 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t doPrepareScan(SOperatorInfo* pOperator, uint64_t uid, int64_t ts) {
|
||||||
|
int32_t type = pOperator->operatorType;
|
||||||
|
if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
||||||
|
SStreamBlockScanInfo* pScanInfo = pOperator->info;
|
||||||
|
pScanInfo->blockType = STREAM_INPUT__DATA_SCAN;
|
||||||
|
|
||||||
|
STableScanInfo* pInfo = pScanInfo->pSnapshotReadOp->info;
|
||||||
|
if (uid == 0) {
|
||||||
|
pInfo->noTable = 1;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*if (pSnapShotScanInfo->dataReader == NULL) {*/
|
||||||
|
/*pSnapShotScanInfo->dataReader = tsdbReaderOpen(pHandle->vnode, &pSTInfo->cond, tableList, 0, 0);*/
|
||||||
|
/*pSnapShotScanInfo->scanMode = TABLE_SCAN__TABLE_ORDER;*/
|
||||||
|
/*}*/
|
||||||
|
|
||||||
|
pInfo->noTable = 0;
|
||||||
|
|
||||||
|
if (pInfo->lastStatus.uid != uid || pInfo->lastStatus.ts != ts) {
|
||||||
|
tsdbSetTableId(pInfo->dataReader, uid);
|
||||||
|
int64_t oldSkey = pInfo->cond.twindows[0].skey;
|
||||||
|
pInfo->cond.twindows[0].skey = ts + 1;
|
||||||
|
tsdbResetReadHandle(pInfo->dataReader, &pInfo->cond, 0);
|
||||||
|
pInfo->cond.twindows[0].skey = oldSkey;
|
||||||
|
pInfo->scanTimes = 0;
|
||||||
|
pInfo->curTWinIdx = 0;
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (pOperator->numOfDownstream == 1) {
|
||||||
|
return doPrepareScan(pOperator->pDownstream[0], uid, ts);
|
||||||
|
} else if (pOperator->numOfDownstream == 0) {
|
||||||
|
qError("failed to find stream scan operator to set the input data block");
|
||||||
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
|
} else {
|
||||||
|
qError("join not supported for stream block scan");
|
||||||
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t doGetScanStatus(SOperatorInfo* pOperator, uint64_t* uid, int64_t* ts) {
|
int32_t doGetScanStatus(SOperatorInfo* pOperator, uint64_t* uid, int64_t* ts) {
|
||||||
int32_t type = pOperator->operatorType;
|
int32_t type = pOperator->operatorType;
|
||||||
if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
||||||
SStreamBlockScanInfo* pScanInfo = pOperator->info;
|
SStreamBlockScanInfo* pScanInfo = pOperator->info;
|
||||||
STableScanInfo* pSnapShotScanInfo = pScanInfo->pSnapshotReadOp->info;
|
STableScanInfo* pSnapShotScanInfo = pScanInfo->pSnapshotReadOp->info;
|
||||||
*uid = pSnapShotScanInfo->scanStatus.uid;
|
*uid = pSnapShotScanInfo->lastStatus.uid;
|
||||||
*ts = pSnapShotScanInfo->scanStatus.t;
|
*ts = pSnapShotScanInfo->lastStatus.ts;
|
||||||
} else {
|
} else {
|
||||||
if (pOperator->pDownstream[0] == NULL) {
|
if (pOperator->pDownstream[0] == NULL) {
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
@ -3196,8 +3240,6 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
|
||||||
longjmp(pTaskInfo->env, code);
|
longjmp(pTaskInfo->env, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
doFilter(pProjectInfo->pFilterNode, pBlock);
|
|
||||||
|
|
||||||
setInputDataBlock(pOperator, pSup->pCtx, pBlock, order, scanFlag, false);
|
setInputDataBlock(pOperator, pSup->pCtx, pBlock, order, scanFlag, false);
|
||||||
blockDataEnsureCapacity(pInfo->pRes, pInfo->pRes->info.rows + pBlock->info.rows);
|
blockDataEnsureCapacity(pInfo->pRes, pInfo->pRes->info.rows + pBlock->info.rows);
|
||||||
|
|
||||||
|
@ -3208,6 +3250,10 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t status = handleLimitOffset(pOperator, pBlock);
|
int32_t status = handleLimitOffset(pOperator, pBlock);
|
||||||
|
|
||||||
|
// filter shall be applied after apply functions and limit/offset on the result
|
||||||
|
doFilter(pProjectInfo->pFilterNode, pInfo->pRes);
|
||||||
|
|
||||||
if (status == PROJECT_RETRIEVE_CONTINUE) {
|
if (status == PROJECT_RETRIEVE_CONTINUE) {
|
||||||
continue;
|
continue;
|
||||||
} else if (status == PROJECT_RETRIEVE_DONE) {
|
} else if (status == PROJECT_RETRIEVE_DONE) {
|
||||||
|
|
|
@ -392,6 +392,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
|
||||||
binfo.capacity = binfo.rows;
|
binfo.capacity = binfo.rows;
|
||||||
blockDataEnsureCapacity(pBlock, binfo.rows);
|
blockDataEnsureCapacity(pBlock, binfo.rows);
|
||||||
pBlock->info = binfo;
|
pBlock->info = binfo;
|
||||||
|
ASSERT(binfo.uid != 0);
|
||||||
|
|
||||||
uint32_t status = 0;
|
uint32_t status = 0;
|
||||||
int32_t code = loadDataBlock(pOperator, pTableScanInfo, pBlock, &status);
|
int32_t code = loadDataBlock(pOperator, pTableScanInfo, pBlock, &status);
|
||||||
|
@ -416,9 +417,10 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
|
||||||
pOperator->cost.totalCost = pTableScanInfo->readRecorder.elapsedTime;
|
pOperator->cost.totalCost = pTableScanInfo->readRecorder.elapsedTime;
|
||||||
|
|
||||||
// todo refactor
|
// todo refactor
|
||||||
pTableScanInfo->scanStatus.uid = pBlock->info.uid;
|
pTableScanInfo->lastStatus.uid = pBlock->info.uid;
|
||||||
pTableScanInfo->scanStatus.t = pBlock->info.window.ekey;
|
pTableScanInfo->lastStatus.ts = pBlock->info.window.ekey;
|
||||||
|
|
||||||
|
ASSERT(pBlock->info.uid != 0);
|
||||||
return pBlock;
|
return pBlock;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -438,6 +440,7 @@ static SSDataBlock* doTableScanGroup(SOperatorInfo* pOperator) {
|
||||||
while (pTableScanInfo->curTWinIdx < pTableScanInfo->cond.numOfTWindows) {
|
while (pTableScanInfo->curTWinIdx < pTableScanInfo->cond.numOfTWindows) {
|
||||||
SSDataBlock* p = doTableScanImpl(pOperator);
|
SSDataBlock* p = doTableScanImpl(pOperator);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
|
ASSERT(p->info.uid != 0);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
pTableScanInfo->curTWinIdx += 1;
|
pTableScanInfo->curTWinIdx += 1;
|
||||||
|
@ -513,6 +516,27 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
|
||||||
STableScanInfo* pInfo = pOperator->info;
|
STableScanInfo* pInfo = pOperator->info;
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
|
// if scan table by table
|
||||||
|
if (pInfo->scanMode == TABLE_SCAN__TABLE_ORDER) {
|
||||||
|
if (pInfo->noTable) return NULL;
|
||||||
|
while (1) {
|
||||||
|
SSDataBlock* result = doTableScanGroup(pOperator);
|
||||||
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
// if no data, switch to next table and continue scan
|
||||||
|
pInfo->currentTable++;
|
||||||
|
if (pInfo->currentTable >= taosArrayGetSize(pTaskInfo->tableqinfoList.pTableList)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, pInfo->currentTable);
|
||||||
|
tsdbSetTableId(pInfo->dataReader, pTableInfo->uid);
|
||||||
|
tsdbResetReadHandle(pInfo->dataReader, &pInfo->cond, 0);
|
||||||
|
pInfo->scanTimes = 0;
|
||||||
|
pInfo->curTWinIdx = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (pInfo->currentGroupId == -1) {
|
if (pInfo->currentGroupId == -1) {
|
||||||
pInfo->currentGroupId++;
|
pInfo->currentGroupId++;
|
||||||
if (pInfo->currentGroupId >= taosArrayGetSize(pTaskInfo->tableqinfoList.pGroupList)) {
|
if (pInfo->currentGroupId >= taosArrayGetSize(pTaskInfo->tableqinfoList.pGroupList)) {
|
||||||
|
@ -1188,7 +1212,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
|
|
||||||
int16_t colId = id->colId;
|
int16_t colId = id->colId;
|
||||||
taosArrayPush(pColIds, &colId);
|
taosArrayPush(pColIds, &colId);
|
||||||
if (id->colId == pTableScanNode->tsColId) {
|
if (id->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||||
pInfo->primaryTsIndex = id->targetSlotId;
|
pInfo->primaryTsIndex = id->targetSlotId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1207,6 +1231,13 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
if (pHandle) {
|
if (pHandle) {
|
||||||
SOperatorInfo* pTableScanDummy = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo, queryId, taskId);
|
SOperatorInfo* pTableScanDummy = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo, queryId, taskId);
|
||||||
STableScanInfo* pSTInfo = (STableScanInfo*)pTableScanDummy->info;
|
STableScanInfo* pSTInfo = (STableScanInfo*)pTableScanDummy->info;
|
||||||
|
|
||||||
|
SArray* tableList = taosArrayGetP(pTaskInfo->tableqinfoList.pGroupList, 0);
|
||||||
|
if (pHandle->tqReader) {
|
||||||
|
pSTInfo->scanMode = TABLE_SCAN__TABLE_ORDER;
|
||||||
|
pSTInfo->dataReader = tsdbReaderOpen(pHandle->vnode, &pSTInfo->cond, tableList, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (pSTInfo->interval.interval > 0) {
|
if (pSTInfo->interval.interval > 0) {
|
||||||
pInfo->pUpdateInfo = updateInfoInitP(&pSTInfo->interval, pTwSup->waterMark);
|
pInfo->pUpdateInfo = updateInfoInitP(&pSTInfo->interval, pTwSup->waterMark);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1330,7 +1361,7 @@ static void getDBNameFromCondition(SNode* pCondition, const char* dbName) {
|
||||||
nodesWalkExpr(pCondition, getDBNameFromConditionWalker, (char*)dbName);
|
nodesWalkExpr(pCondition, getDBNameFromConditionWalker, (char*)dbName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t loadSysTableCallback(void* param, const SDataBuf* pMsg, int32_t code) {
|
static int32_t loadSysTableCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
SOperatorInfo* operator=(SOperatorInfo*) param;
|
SOperatorInfo* operator=(SOperatorInfo*) param;
|
||||||
SSysTableScanInfo* pScanResInfo = (SSysTableScanInfo*)operator->info;
|
SSysTableScanInfo* pScanResInfo = (SSysTableScanInfo*)operator->info;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
|
|
@ -1246,6 +1246,9 @@ void doClearWindowImpl(SResultRowPosition* p1, SDiskbasedBuf* pResultBuf, SExprS
|
||||||
pCtx[i].fpSet.init(&pCtx[i], pResInfo);
|
pCtx[i].fpSet.init(&pCtx[i], pResInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SFilePage* bufPage = getBufPage(pResultBuf, p1->pageId);
|
||||||
|
setBufPageDirty(bufPage, true);
|
||||||
|
releaseBufPage(pResultBuf, bufPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool doClearWindow(SAggSupporter* pAggSup, SExprSupp* pSup, char* pData, int16_t bytes, uint64_t groupId,
|
bool doClearWindow(SAggSupporter* pAggSup, SExprSupp* pSup, char* pData, int16_t bytes, uint64_t groupId,
|
||||||
|
@ -3171,6 +3174,10 @@ static void doClearSessionWindows(SStreamAggSupporter* pAggSup, SExprSupp* pSup,
|
||||||
getSessionTimeWindow(pAggSup, tsCols[i], INT64_MIN, pBlock->info.groupId, gap, &winIndex);
|
getSessionTimeWindow(pAggSup, tsCols[i], INT64_MIN, pBlock->info.groupId, gap, &winIndex);
|
||||||
step = updateSessionWindowInfo(pCurWin, tsCols, NULL, pBlock->info.rows, i, gap, NULL);
|
step = updateSessionWindowInfo(pCurWin, tsCols, NULL, pBlock->info.rows, i, gap, NULL);
|
||||||
ASSERT(isInWindow(pCurWin, tsCols[i], gap));
|
ASSERT(isInWindow(pCurWin, tsCols[i], gap));
|
||||||
|
if (pCurWin->pos.pageId == -1) {
|
||||||
|
// window has been closed.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
doClearWindowImpl(&pCurWin->pos, pAggSup->pResultBuf, pSup, numOfOutput);
|
doClearWindowImpl(&pCurWin->pos, pAggSup->pResultBuf, pSup, numOfOutput);
|
||||||
if (result) {
|
if (result) {
|
||||||
taosArrayPush(result, pCurWin);
|
taosArrayPush(result, pCurWin);
|
||||||
|
@ -3246,12 +3253,12 @@ static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWin
|
||||||
setWindowOutputBuf(pChWin, &pChResult, pChild->exprSupp.pCtx, groupId, numOfOutput,
|
setWindowOutputBuf(pChWin, &pChResult, pChild->exprSupp.pCtx, groupId, numOfOutput,
|
||||||
pChild->exprSupp.rowEntryInfoOffset, &pChInfo->streamAggSup, pTaskInfo);
|
pChild->exprSupp.rowEntryInfoOffset, &pChInfo->streamAggSup, pTaskInfo);
|
||||||
compactFunctions(pSup->pCtx, pChild->exprSupp.pCtx, numOfOutput, pTaskInfo);
|
compactFunctions(pSup->pCtx, pChild->exprSupp.pCtx, numOfOutput, pTaskInfo);
|
||||||
SFilePage* bufPage = getBufPage(pInfo->streamAggSup.pResultBuf, pChWin->pos.pageId);
|
SFilePage* bufPage = getBufPage(pChInfo->streamAggSup.pResultBuf, pChWin->pos.pageId);
|
||||||
setBufPageDirty(bufPage, true);
|
releaseBufPage(pChInfo->streamAggSup.pResultBuf, bufPage);
|
||||||
releaseBufPage(pInfo->streamAggSup.pResultBuf, bufPage);
|
|
||||||
continue;
|
continue;
|
||||||
|
} else if (!pChWin->isClosed) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SFilePage* bufPage = getBufPage(pInfo->streamAggSup.pResultBuf, pParentWin->pos.pageId);
|
SFilePage* bufPage = getBufPage(pInfo->streamAggSup.pResultBuf, pParentWin->pos.pageId);
|
||||||
|
@ -3265,7 +3272,8 @@ typedef SResultWindowInfo* (*__get_win_info_)(void*);
|
||||||
SResultWindowInfo* getResWinForSession(void* pData) { return (SResultWindowInfo*)pData; }
|
SResultWindowInfo* getResWinForSession(void* pData) { return (SResultWindowInfo*)pData; }
|
||||||
SResultWindowInfo* getResWinForState(void* pData) { return &((SStateWindowInfo*)pData)->winInfo; }
|
SResultWindowInfo* getResWinForState(void* pData) { return &((SStateWindowInfo*)pData)->winInfo; }
|
||||||
|
|
||||||
int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArray* pClosed, __get_win_info_ fn) {
|
int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup,
|
||||||
|
SArray* pClosed, __get_win_info_ fn, bool delete) {
|
||||||
// Todo(liuyao) save window to tdb
|
// Todo(liuyao) save window to tdb
|
||||||
void** pIte = NULL;
|
void** pIte = NULL;
|
||||||
size_t keyLen = 0;
|
size_t keyLen = 0;
|
||||||
|
@ -3279,10 +3287,18 @@ int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArra
|
||||||
if (isCloseWindow(&pSeWin->win, pTwSup)) {
|
if (isCloseWindow(&pSeWin->win, pTwSup)) {
|
||||||
if (!pSeWin->isClosed) {
|
if (!pSeWin->isClosed) {
|
||||||
pSeWin->isClosed = true;
|
pSeWin->isClosed = true;
|
||||||
if (pTwSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
if (pTwSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE && pClosed) {
|
||||||
int32_t code = saveResult(pSeWin->win.skey, pSeWin->pos.pageId, pSeWin->pos.offset, *pGroupId, pClosed);
|
int32_t code = saveResult(pSeWin->win.skey, pSeWin->pos.pageId, pSeWin->pos.offset, *pGroupId, pClosed);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
pSeWin->isOutput = true;
|
pSeWin->isOutput = true;
|
||||||
}
|
}
|
||||||
|
if (delete) {
|
||||||
|
taosArrayRemove(pWins, i);
|
||||||
|
i--;
|
||||||
|
size = taosArrayGetSize(pWins);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -3292,6 +3308,16 @@ int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArra
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void closeChildSessionWindow(SArray* pChildren, TSKEY maxTs, bool delete) {
|
||||||
|
int32_t size = taosArrayGetSize(pChildren);
|
||||||
|
for (int32_t i = 0; i < size; i++) {
|
||||||
|
SOperatorInfo* pChildOp = taosArrayGetP(pChildren, i);
|
||||||
|
SStreamSessionAggOperatorInfo* pChInfo = pChildOp->info;
|
||||||
|
pChInfo->twAggSup.maxTs = TMAX(pChInfo->twAggSup.maxTs, maxTs);
|
||||||
|
closeSessionWindow(pChInfo->streamAggSup.pResultRows, &pChInfo->twAggSup, NULL, getResWinForSession, delete);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t getAllSessionWindow(SHashObj* pHashMap, SArray* pClosed, __get_win_info_ fn) {
|
int32_t getAllSessionWindow(SHashObj* pHashMap, SArray* pClosed, __get_win_info_ fn) {
|
||||||
void** pIte = NULL;
|
void** pIte = NULL;
|
||||||
while ((pIte = taosHashIterate(pHashMap, pIte)) != NULL) {
|
while ((pIte = taosHashIterate(pHashMap, pIte)) != NULL) {
|
||||||
|
@ -3339,6 +3365,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
printDataBlock(pBlock, IS_FINAL_OP(pInfo) ? "Final Session Recv" : "Single Session Recv");
|
||||||
|
|
||||||
if (pBlock->info.type == STREAM_CLEAR) {
|
if (pBlock->info.type == STREAM_CLEAR) {
|
||||||
SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo));
|
SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo));
|
||||||
|
@ -3385,7 +3412,9 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
||||||
// restore the value
|
// restore the value
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
pOperator->status = OP_RES_TO_RETURN;
|
||||||
|
|
||||||
closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, getResWinForSession);
|
closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated,
|
||||||
|
getResWinForSession, pInfo->ignoreCloseWindow);
|
||||||
|
closeChildSessionWindow(pInfo->pChildren, pInfo->twAggSup.maxTs, pInfo->ignoreCloseWindow);
|
||||||
copyUpdateResult(pStUpdated, pUpdated);
|
copyUpdateResult(pStUpdated, pUpdated);
|
||||||
taosHashCleanup(pStUpdated);
|
taosHashCleanup(pStUpdated);
|
||||||
|
|
||||||
|
@ -3437,10 +3466,11 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
|
||||||
} else if (pOperator->status == OP_RES_TO_RETURN) {
|
} else if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
||||||
if (pInfo->pDelRes->info.rows > 0) {
|
if (pInfo->pDelRes->info.rows > 0) {
|
||||||
|
printDataBlock(pInfo->pDelRes, "Semi Session");
|
||||||
return pInfo->pDelRes;
|
return pInfo->pDelRes;
|
||||||
}
|
}
|
||||||
doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf);
|
doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf);
|
||||||
if (pInfo->binfo.pRes->info.rows == 0) {
|
if (pBInfo->pRes->info.rows == 0) {
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
if (pInfo->pUpdateRes->info.rows == 0) {
|
if (pInfo->pUpdateRes->info.rows == 0) {
|
||||||
// semi interval operator clear disk buffer
|
// semi interval operator clear disk buffer
|
||||||
|
@ -3449,9 +3479,11 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
// process the rest of the data
|
// process the rest of the data
|
||||||
pOperator->status = OP_OPENED;
|
pOperator->status = OP_OPENED;
|
||||||
|
printDataBlock(pInfo->pUpdateRes, "Semi Session");
|
||||||
return pInfo->pUpdateRes;
|
return pInfo->pUpdateRes;
|
||||||
}
|
}
|
||||||
return pInfo->binfo.pRes;
|
printDataBlock(pBInfo->pRes, "Semi Session");
|
||||||
|
return pBInfo->pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
|
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
|
||||||
|
@ -3495,21 +3527,24 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
|
||||||
finalizeUpdatedResult(pOperator->exprSupp.numOfExprs, pInfo->streamAggSup.pResultBuf, pUpdated,
|
finalizeUpdatedResult(pOperator->exprSupp.numOfExprs, pInfo->streamAggSup.pResultBuf, pUpdated,
|
||||||
pSup->rowEntryInfoOffset);
|
pSup->rowEntryInfoOffset);
|
||||||
initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated);
|
initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated);
|
||||||
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pBInfo->pRes, pOperator->resultInfo.capacity);
|
||||||
doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
|
||||||
if (pInfo->pDelRes->info.rows > 0) {
|
if (pInfo->pDelRes->info.rows > 0) {
|
||||||
|
printDataBlock(pInfo->pDelRes, "Semi Session");
|
||||||
return pInfo->pDelRes;
|
return pInfo->pDelRes;
|
||||||
}
|
}
|
||||||
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf);
|
doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf);
|
||||||
if (pInfo->binfo.pRes->info.rows == 0) {
|
if (pBInfo->pRes->info.rows == 0) {
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
if (pInfo->pUpdateRes->info.rows == 0) {
|
if (pInfo->pUpdateRes->info.rows == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
// process the rest of the data
|
// process the rest of the data
|
||||||
pOperator->status = OP_OPENED;
|
pOperator->status = OP_OPENED;
|
||||||
|
printDataBlock(pInfo->pUpdateRes, "Semi Session");
|
||||||
return pInfo->pUpdateRes;
|
return pInfo->pUpdateRes;
|
||||||
}
|
}
|
||||||
|
printDataBlock(pBInfo->pRes, "Semi Session");
|
||||||
return pBInfo->pRes->info.rows == 0 ? NULL : pBInfo->pRes;
|
return pBInfo->pRes->info.rows == 0 ? NULL : pBInfo->pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3867,7 +3902,9 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
|
||||||
// restore the value
|
// restore the value
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
pOperator->status = OP_RES_TO_RETURN;
|
||||||
|
|
||||||
closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, getResWinForState);
|
closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated,
|
||||||
|
getResWinForState, pInfo->ignoreCloseWindow);
|
||||||
|
closeChildSessionWindow(pInfo->pChildren, pInfo->twAggSup.maxTs, pInfo->ignoreCloseWindow);
|
||||||
copyUpdateResult(pSeUpdated, pUpdated);
|
copyUpdateResult(pSeUpdated, pUpdated);
|
||||||
taosHashCleanup(pSeUpdated);
|
taosHashCleanup(pSeUpdated);
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,9 @@ int32_t firstCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||||
int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||||
int32_t getFirstLastInfoSize(int32_t resBytes);
|
int32_t getFirstLastInfoSize(int32_t resBytes);
|
||||||
|
|
||||||
|
int32_t lastRowFunction(SqlFunctionCtx *pCtx);
|
||||||
|
int32_t lastRowFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||||
|
|
||||||
bool getTopBotFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv);
|
bool getTopBotFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv);
|
||||||
bool getTopBotMergeFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv);
|
bool getTopBotMergeFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv);
|
||||||
bool topBotFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
bool topBotFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
||||||
|
|
|
@ -2016,16 +2016,13 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "last_row",
|
.name = "last_row",
|
||||||
.type = FUNCTION_TYPE_LAST_ROW,
|
.type = FUNCTION_TYPE_LAST_ROWT,
|
||||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC,
|
||||||
.translateFunc = translateFirstLast,
|
.translateFunc = translateFirstLast,
|
||||||
.getEnvFunc = getFirstLastFuncEnv,
|
.getEnvFunc = getFirstLastFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
.processFunc = lastFunction,
|
.processFunc = lastRowFunction,
|
||||||
.finalizeFunc = firstLastFinalize,
|
.finalizeFunc = lastRowFinalize,
|
||||||
.pPartialFunc = "_last_partial",
|
|
||||||
.pMergeFunc = "_last_merge",
|
|
||||||
.combineFunc = lastCombine,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "_cache_last_row",
|
.name = "_cache_last_row",
|
||||||
|
|
|
@ -80,6 +80,7 @@ typedef struct STopBotRes {
|
||||||
|
|
||||||
typedef struct SFirstLastRes {
|
typedef struct SFirstLastRes {
|
||||||
bool hasResult;
|
bool hasResult;
|
||||||
|
bool isNull; //used for last_row function only
|
||||||
int32_t bytes;
|
int32_t bytes;
|
||||||
char buf[];
|
char buf[];
|
||||||
} SFirstLastRes;
|
} SFirstLastRes;
|
||||||
|
@ -2763,6 +2764,113 @@ int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t lastRowFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
int32_t numOfElems = 0;
|
||||||
|
|
||||||
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
|
SFirstLastRes* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
|
||||||
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
|
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||||
|
|
||||||
|
int32_t type = pInputCol->info.type;
|
||||||
|
int32_t bytes = pInputCol->info.bytes;
|
||||||
|
pInfo->bytes = bytes;
|
||||||
|
|
||||||
|
SColumnDataAgg* pColAgg = (pInput->colDataAggIsSet) ? pInput->pColumnDataAgg[0] : NULL;
|
||||||
|
|
||||||
|
TSKEY startKey = getRowPTs(pInput->pPTS, 0);
|
||||||
|
TSKEY endKey = getRowPTs(pInput->pPTS, pInput->totalRows - 1);
|
||||||
|
|
||||||
|
int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||||
|
|
||||||
|
if (blockDataOrder == TSDB_ORDER_ASC) {
|
||||||
|
for (int32_t i = pInput->numOfRows + pInput->startRowIndex - 1; i >= pInput->startRowIndex; --i) {
|
||||||
|
char* data = colDataGetData(pInputCol, i);
|
||||||
|
TSKEY cts = getRowPTs(pInput->pPTS, i);
|
||||||
|
if (pResInfo->numOfRes == 0 || *(TSKEY*)(pInfo->buf) < cts) {
|
||||||
|
if (pInputCol->hasNull && colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) {
|
||||||
|
pInfo->isNull = true;
|
||||||
|
} else {
|
||||||
|
pInfo->isNull = false;
|
||||||
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
|
bytes = varDataTLen(data);
|
||||||
|
pInfo->bytes = bytes;
|
||||||
|
}
|
||||||
|
memcpy(pInfo->buf + sizeof(TSKEY), data, bytes);
|
||||||
|
}
|
||||||
|
*(TSKEY*)(pInfo->buf) = cts;
|
||||||
|
numOfElems++;
|
||||||
|
//handle selectivity
|
||||||
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
|
STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY));
|
||||||
|
if (!pInfo->hasResult) {
|
||||||
|
saveTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos);
|
||||||
|
} else {
|
||||||
|
copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pInfo->hasResult = true;
|
||||||
|
//DO_UPDATE_TAG_COLUMNS(pCtx, ts);
|
||||||
|
pResInfo->numOfRes = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else { // descending order
|
||||||
|
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||||
|
char* data = colDataGetData(pInputCol, i);
|
||||||
|
TSKEY cts = getRowPTs(pInput->pPTS, i);
|
||||||
|
if (pResInfo->numOfRes == 0 || *(TSKEY*)(pInfo->buf) < cts) {
|
||||||
|
if (pInputCol->hasNull && colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) {
|
||||||
|
pInfo->isNull = true;
|
||||||
|
} else {
|
||||||
|
pInfo->isNull = false;
|
||||||
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
|
bytes = varDataTLen(data);
|
||||||
|
pInfo->bytes = bytes;
|
||||||
|
}
|
||||||
|
memcpy(pInfo->buf + sizeof(TSKEY), data, bytes);
|
||||||
|
}
|
||||||
|
*(TSKEY*)(pInfo->buf) = cts;
|
||||||
|
numOfElems++;
|
||||||
|
//handle selectivity
|
||||||
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
|
STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY));
|
||||||
|
if (!pInfo->hasResult) {
|
||||||
|
saveTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos);
|
||||||
|
} else {
|
||||||
|
copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pInfo->hasResult = true;
|
||||||
|
pResInfo->numOfRes = 1;
|
||||||
|
//DO_UPDATE_TAG_COLUMNS(pCtx, ts);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SET_VAL(pResInfo, numOfElems, 1);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t lastRowFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
|
int32_t slotId = pCtx->pExpr->base.resSchema.slotId;
|
||||||
|
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
|
|
||||||
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
|
|
||||||
|
SFirstLastRes* pRes = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
colDataAppend(pCol, pBlock->info.rows, pRes->buf + sizeof(TSKEY), pRes->isNull);
|
||||||
|
//handle selectivity
|
||||||
|
STuplePos* pTuplePos = (STuplePos*)(pRes->buf + pRes->bytes + sizeof(TSKEY));
|
||||||
|
setSelectivityValue(pCtx, pBlock, pTuplePos, pBlock->info.rows);
|
||||||
|
|
||||||
|
return pResInfo->numOfRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool getDiffFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
|
bool getDiffFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
|
||||||
pEnv->calcMemSize = sizeof(SDiffInfo);
|
pEnv->calcMemSize = sizeof(SDiffInfo);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1887,10 +1887,10 @@ static void top_bottom_func_finalizer(SqlFunctionCtx *pCtx) {
|
||||||
// user specify the order of output by sort the result according to timestamp
|
// user specify the order of output by sort the result according to timestamp
|
||||||
if (pCtx->param[1].param.i == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
if (pCtx->param[1].param.i == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||||
__compar_fn_t comparator = (pCtx->param[2].param.i == TSDB_ORDER_ASC) ? resAscComparFn : resDescComparFn;
|
__compar_fn_t comparator = (pCtx->param[2].param.i == TSDB_ORDER_ASC) ? resAscComparFn : resDescComparFn;
|
||||||
qsort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator);
|
taosSort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator);
|
||||||
} else /*if (pCtx->param[1].param.i > PRIMARYKEY_TIMESTAMP_COL_ID)*/ {
|
} else /*if (pCtx->param[1].param.i > PRIMARYKEY_TIMESTAMP_COL_ID)*/ {
|
||||||
__compar_fn_t comparator = (pCtx->param[2].param.i == TSDB_ORDER_ASC) ? resDataAscComparFn : resDataDescComparFn;
|
__compar_fn_t comparator = (pCtx->param[2].param.i == TSDB_ORDER_ASC) ? resDataAscComparFn : resDataDescComparFn;
|
||||||
qsort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator);
|
taosSort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
GET_TRUE_DATA_TYPE();
|
GET_TRUE_DATA_TYPE();
|
||||||
|
|
|
@ -44,7 +44,7 @@ static SFilePage *loadDataFromFilePage(tMemBucket *pMemBucket, int32_t slotIdx)
|
||||||
offset += (int32_t)(pg->num * pMemBucket->bytes);
|
offset += (int32_t)(pg->num * pMemBucket->bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
qsort(buffer->data, pMemBucket->pSlots[slotIdx].info.size, pMemBucket->bytes, pMemBucket->comparFn);
|
taosSort(buffer->data, pMemBucket->pSlots[slotIdx].info.size, pMemBucket->bytes, pMemBucket->comparFn);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -548,8 +548,8 @@ int32_t udfdLoadUdf(char *udfName, SUdf *udf) {
|
||||||
}
|
}
|
||||||
static bool udfdRpcRfp(int32_t code, tmsg_t msgType) {
|
static bool udfdRpcRfp(int32_t code, tmsg_t msgType) {
|
||||||
if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_NODE_NOT_DEPLOYED ||
|
if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_NODE_NOT_DEPLOYED ||
|
||||||
code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY) {
|
code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY || code == TSDB_CODE_RPC_BROKEN_LINK) {
|
||||||
if (msgType == TDMT_VND_QUERY || msgType == TDMT_VND_FETCH) {
|
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -350,9 +350,9 @@ static int32_t logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
|
||||||
CLONE_NODE_FIELD(pTagIndexCond);
|
CLONE_NODE_FIELD(pTagIndexCond);
|
||||||
COPY_SCALAR_FIELD(triggerType);
|
COPY_SCALAR_FIELD(triggerType);
|
||||||
COPY_SCALAR_FIELD(watermark);
|
COPY_SCALAR_FIELD(watermark);
|
||||||
COPY_SCALAR_FIELD(tsColId);
|
COPY_SCALAR_FIELD(igExpired);
|
||||||
COPY_SCALAR_FIELD(filesFactor);
|
|
||||||
CLONE_NODE_LIST_FIELD(pGroupTags);
|
CLONE_NODE_LIST_FIELD(pGroupTags);
|
||||||
|
COPY_SCALAR_FIELD(groupSort);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ static int32_t logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* p
|
||||||
CLONE_NODE_FIELD(pStateExpr);
|
CLONE_NODE_FIELD(pStateExpr);
|
||||||
COPY_SCALAR_FIELD(triggerType);
|
COPY_SCALAR_FIELD(triggerType);
|
||||||
COPY_SCALAR_FIELD(watermark);
|
COPY_SCALAR_FIELD(watermark);
|
||||||
COPY_SCALAR_FIELD(filesFactor);
|
COPY_SCALAR_FIELD(igExpired);
|
||||||
COPY_SCALAR_FIELD(windowAlgo);
|
COPY_SCALAR_FIELD(windowAlgo);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -511,8 +511,7 @@ static int32_t physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhy
|
||||||
COPY_SCALAR_FIELD(slidingUnit);
|
COPY_SCALAR_FIELD(slidingUnit);
|
||||||
COPY_SCALAR_FIELD(triggerType);
|
COPY_SCALAR_FIELD(triggerType);
|
||||||
COPY_SCALAR_FIELD(watermark);
|
COPY_SCALAR_FIELD(watermark);
|
||||||
COPY_SCALAR_FIELD(tsColId);
|
COPY_SCALAR_FIELD(igExpired);
|
||||||
COPY_SCALAR_FIELD(filesFactor);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,7 +531,7 @@ static int32_t physiWindowCopy(const SWinodwPhysiNode* pSrc, SWinodwPhysiNode* p
|
||||||
CLONE_NODE_FIELD(pTsEnd);
|
CLONE_NODE_FIELD(pTsEnd);
|
||||||
COPY_SCALAR_FIELD(triggerType);
|
COPY_SCALAR_FIELD(triggerType);
|
||||||
COPY_SCALAR_FIELD(watermark);
|
COPY_SCALAR_FIELD(watermark);
|
||||||
COPY_SCALAR_FIELD(filesFactor);
|
COPY_SCALAR_FIELD(igExpired);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -582,6 +581,7 @@ static int32_t downstreamSourceCopy(const SDownstreamSourceNode* pSrc, SDownstre
|
||||||
COPY_OBJECT_FIELD(addr, sizeof(SQueryNodeAddr));
|
COPY_OBJECT_FIELD(addr, sizeof(SQueryNodeAddr));
|
||||||
COPY_SCALAR_FIELD(taskId);
|
COPY_SCALAR_FIELD(taskId);
|
||||||
COPY_SCALAR_FIELD(schedId);
|
COPY_SCALAR_FIELD(schedId);
|
||||||
|
COPY_SCALAR_FIELD(execId);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1426,12 +1426,11 @@ static const char* jkTableScanPhysiPlanDynamicScanFuncs = "DynamicScanFuncs";
|
||||||
static const char* jkTableScanPhysiPlanInterval = "Interval";
|
static const char* jkTableScanPhysiPlanInterval = "Interval";
|
||||||
static const char* jkTableScanPhysiPlanOffset = "Offset";
|
static const char* jkTableScanPhysiPlanOffset = "Offset";
|
||||||
static const char* jkTableScanPhysiPlanSliding = "Sliding";
|
static const char* jkTableScanPhysiPlanSliding = "Sliding";
|
||||||
static const char* jkTableScanPhysiPlanIntervalUnit = "intervalUnit";
|
static const char* jkTableScanPhysiPlanIntervalUnit = "IntervalUnit";
|
||||||
static const char* jkTableScanPhysiPlanSlidingUnit = "slidingUnit";
|
static const char* jkTableScanPhysiPlanSlidingUnit = "SlidingUnit";
|
||||||
static const char* jkTableScanPhysiPlanTriggerType = "triggerType";
|
static const char* jkTableScanPhysiPlanTriggerType = "TriggerType";
|
||||||
static const char* jkTableScanPhysiPlanWatermark = "watermark";
|
static const char* jkTableScanPhysiPlanWatermark = "Watermark";
|
||||||
static const char* jkTableScanPhysiPlanTsColId = "tsColId";
|
static const char* jkTableScanPhysiPlanIgnoreExpired = "IgnoreExpired";
|
||||||
static const char* jkTableScanPhysiPlanFilesFactor = "FilesFactor";
|
|
||||||
static const char* jkTableScanPhysiPlanGroupTags = "GroupTags";
|
static const char* jkTableScanPhysiPlanGroupTags = "GroupTags";
|
||||||
static const char* jkTableScanPhysiPlanGroupSort = "GroupSort";
|
static const char* jkTableScanPhysiPlanGroupSort = "GroupSort";
|
||||||
|
|
||||||
|
@ -1482,10 +1481,7 @@ static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanWatermark, pNode->watermark);
|
code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanWatermark, pNode->watermark);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanTsColId, pNode->tsColId);
|
code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanIgnoreExpired, pNode->igExpired);
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonAddDoubleToObject(pJson, jkTableScanPhysiPlanFilesFactor, pNode->filesFactor);
|
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodeListToJson(pJson, jkTableScanPhysiPlanGroupTags, pNode->pGroupTags);
|
code = nodeListToJson(pJson, jkTableScanPhysiPlanGroupTags, pNode->pGroupTags);
|
||||||
|
@ -1517,37 +1513,34 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) {
|
||||||
code = tjsonGetDoubleValue(pJson, jkTableScanPhysiPlanRatio, &pNode->ratio);
|
code = tjsonGetDoubleValue(pJson, jkTableScanPhysiPlanRatio, &pNode->ratio);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanDataRequired, pNode->dataRequired, code);
|
code = tjsonGetIntValue(pJson, jkTableScanPhysiPlanDataRequired, &pNode->dataRequired);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeList(pJson, jkTableScanPhysiPlanDynamicScanFuncs, &pNode->pDynamicScanFuncs);
|
code = jsonToNodeList(pJson, jkTableScanPhysiPlanDynamicScanFuncs, &pNode->pDynamicScanFuncs);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanInterval, pNode->interval, code);
|
code = tjsonGetBigIntValue(pJson, jkTableScanPhysiPlanInterval, &pNode->interval);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanOffset, pNode->offset, code);
|
code = tjsonGetBigIntValue(pJson, jkTableScanPhysiPlanOffset, &pNode->offset);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSliding, pNode->sliding, code);
|
code = tjsonGetBigIntValue(pJson, jkTableScanPhysiPlanSliding, &pNode->sliding);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanIntervalUnit, pNode->intervalUnit, code);
|
code = tjsonGetTinyIntValue(pJson, jkTableScanPhysiPlanIntervalUnit, &pNode->intervalUnit);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSlidingUnit, pNode->slidingUnit, code);
|
code = tjsonGetTinyIntValue(pJson, jkTableScanPhysiPlanSlidingUnit, &pNode->slidingUnit);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanTriggerType, pNode->triggerType, code);
|
code = tjsonGetTinyIntValue(pJson, jkTableScanPhysiPlanTriggerType, &pNode->triggerType);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanWatermark, pNode->watermark, code);
|
code = tjsonGetBigIntValue(pJson, jkTableScanPhysiPlanWatermark, &pNode->watermark);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanTsColId, pNode->tsColId, code);
|
code = tjsonGetTinyIntValue(pJson, jkTableScanPhysiPlanIgnoreExpired, &pNode->igExpired);
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonGetDoubleValue(pJson, jkTableScanPhysiPlanFilesFactor, &pNode->filesFactor);
|
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeList(pJson, jkTableScanPhysiPlanGroupTags, &pNode->pGroupTags);
|
code = jsonToNodeList(pJson, jkTableScanPhysiPlanGroupTags, &pNode->pGroupTags);
|
||||||
|
@ -1826,7 +1819,7 @@ static const char* jkWindowPhysiPlanTsPk = "TsPk";
|
||||||
static const char* jkWindowPhysiPlanTsEnd = "TsEnd";
|
static const char* jkWindowPhysiPlanTsEnd = "TsEnd";
|
||||||
static const char* jkWindowPhysiPlanTriggerType = "TriggerType";
|
static const char* jkWindowPhysiPlanTriggerType = "TriggerType";
|
||||||
static const char* jkWindowPhysiPlanWatermark = "Watermark";
|
static const char* jkWindowPhysiPlanWatermark = "Watermark";
|
||||||
static const char* jkWindowPhysiPlanFilesFactor = "FilesFactor";
|
static const char* jkWindowPhysiPlanIgnoreExpired = "IgnoreExpired";
|
||||||
|
|
||||||
static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
const SWinodwPhysiNode* pNode = (const SWinodwPhysiNode*)pObj;
|
const SWinodwPhysiNode* pNode = (const SWinodwPhysiNode*)pObj;
|
||||||
|
@ -1851,7 +1844,7 @@ static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkWindowPhysiPlanWatermark, pNode->watermark);
|
code = tjsonAddIntegerToObject(pJson, jkWindowPhysiPlanWatermark, pNode->watermark);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddDoubleToObject(pJson, jkWindowPhysiPlanFilesFactor, pNode->filesFactor);
|
code = tjsonAddIntegerToObject(pJson, jkWindowPhysiPlanIgnoreExpired, pNode->igExpired);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1874,15 +1867,13 @@ static int32_t jsonToPhysiWindowNode(const SJson* pJson, void* pObj) {
|
||||||
code = jsonToNodeObject(pJson, jkWindowPhysiPlanTsEnd, (SNode**)&pNode->pTsEnd);
|
code = jsonToNodeObject(pJson, jkWindowPhysiPlanTsEnd, (SNode**)&pNode->pTsEnd);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkWindowPhysiPlanTriggerType, pNode->triggerType, code);
|
code = tjsonGetTinyIntValue(pJson, jkWindowPhysiPlanTriggerType, &pNode->triggerType);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkWindowPhysiPlanWatermark, pNode->watermark, code);
|
code = tjsonGetBigIntValue(pJson, jkWindowPhysiPlanWatermark, &pNode->watermark);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetDoubleValue(pJson, jkWindowPhysiPlanFilesFactor, &pNode->filesFactor);
|
code = tjsonGetTinyIntValue(pJson, jkWindowPhysiPlanIgnoreExpired, &pNode->igExpired);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -3430,6 +3421,7 @@ static int32_t jsonToSlotDescNode(const SJson* pJson, void* pObj) {
|
||||||
static const char* jkDownstreamSourceAddr = "Addr";
|
static const char* jkDownstreamSourceAddr = "Addr";
|
||||||
static const char* jkDownstreamSourceTaskId = "TaskId";
|
static const char* jkDownstreamSourceTaskId = "TaskId";
|
||||||
static const char* jkDownstreamSourceSchedId = "SchedId";
|
static const char* jkDownstreamSourceSchedId = "SchedId";
|
||||||
|
static const char* jkDownstreamSourceExecId = "ExecId";
|
||||||
|
|
||||||
static int32_t downstreamSourceNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t downstreamSourceNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
const SDownstreamSourceNode* pNode = (const SDownstreamSourceNode*)pObj;
|
const SDownstreamSourceNode* pNode = (const SDownstreamSourceNode*)pObj;
|
||||||
|
@ -3441,6 +3433,9 @@ static int32_t downstreamSourceNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkDownstreamSourceSchedId, pNode->schedId);
|
code = tjsonAddIntegerToObject(pJson, jkDownstreamSourceSchedId, pNode->schedId);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkDownstreamSourceExecId, pNode->execId);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -3455,6 +3450,9 @@ static int32_t jsonToDownstreamSourceNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetUBigIntValue(pJson, jkDownstreamSourceSchedId, &pNode->schedId);
|
code = tjsonGetUBigIntValue(pJson, jkDownstreamSourceSchedId, &pNode->schedId);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetIntValue(pJson, jkDownstreamSourceExecId, &pNode->execId);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1728,7 +1728,6 @@ static EDealRes classifyConditionImpl(SNode* pNode, void* pContext) {
|
||||||
} else {
|
} else {
|
||||||
pCxt->hasOtherCol = true;
|
pCxt->hasOtherCol = true;
|
||||||
}
|
}
|
||||||
return *((bool*)pContext) ? DEAL_RES_CONTINUE : DEAL_RES_END;
|
|
||||||
}
|
}
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -488,6 +488,7 @@ stream_options(A) ::= stream_options(B) TRIGGER AT_ONCE.
|
||||||
stream_options(A) ::= stream_options(B) TRIGGER WINDOW_CLOSE. { ((SStreamOptions*)B)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; A = B; }
|
stream_options(A) ::= stream_options(B) TRIGGER WINDOW_CLOSE. { ((SStreamOptions*)B)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; A = B; }
|
||||||
stream_options(A) ::= stream_options(B) TRIGGER MAX_DELAY duration_literal(C). { ((SStreamOptions*)B)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)B)->pDelay = releaseRawExprNode(pCxt, C); A = B; }
|
stream_options(A) ::= stream_options(B) TRIGGER MAX_DELAY duration_literal(C). { ((SStreamOptions*)B)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)B)->pDelay = releaseRawExprNode(pCxt, C); A = B; }
|
||||||
stream_options(A) ::= stream_options(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; }
|
stream_options(A) ::= stream_options(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; }
|
||||||
|
stream_options(A) ::= stream_options(B) IGNORE EXPIRED. { ((SStreamOptions*)B)->ignoreExpired = true; A = B; }
|
||||||
|
|
||||||
/************************************************ kill connection/query ***********************************************/
|
/************************************************ kill connection/query ***********************************************/
|
||||||
cmd ::= KILL CONNECTION NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &A); }
|
cmd ::= KILL CONNECTION NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &A); }
|
||||||
|
@ -848,14 +849,10 @@ set_quantifier_opt(A) ::= ALL.
|
||||||
|
|
||||||
%type select_list { SNodeList* }
|
%type select_list { SNodeList* }
|
||||||
%destructor select_list { nodesDestroyList($$); }
|
%destructor select_list { nodesDestroyList($$); }
|
||||||
select_list(A) ::= NK_STAR. { A = NULL; }
|
select_list(A) ::= select_item(B). { A = createNodeList(pCxt, B); }
|
||||||
select_list(A) ::= select_sublist(B). { A = B; }
|
select_list(A) ::= select_list(B) NK_COMMA select_item(C). { A = addNodeToList(pCxt, B, C); }
|
||||||
|
|
||||||
%type select_sublist { SNodeList* }
|
|
||||||
%destructor select_sublist { nodesDestroyList($$); }
|
|
||||||
select_sublist(A) ::= select_item(B). { A = createNodeList(pCxt, B); }
|
|
||||||
select_sublist(A) ::= select_sublist(B) NK_COMMA select_item(C). { A = addNodeToList(pCxt, B, C); }
|
|
||||||
|
|
||||||
|
select_item(A) ::= NK_STAR(B). { A = createColumnNode(pCxt, NULL, &B); }
|
||||||
select_item(A) ::= common_expression(B). { A = releaseRawExprNode(pCxt, B); }
|
select_item(A) ::= common_expression(B). { A = releaseRawExprNode(pCxt, B); }
|
||||||
select_item(A) ::= common_expression(B) column_alias(C). { A = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, B), &C); }
|
select_item(A) ::= common_expression(B) column_alias(C). { A = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, B), &C); }
|
||||||
select_item(A) ::= common_expression(B) AS column_alias(C). { A = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, B), &C); }
|
select_item(A) ::= common_expression(B) AS column_alias(C). { A = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, B), &C); }
|
||||||
|
|
|
@ -790,11 +790,11 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo*
|
||||||
pColIdx[i].schemaColIdx = pColList->boundColumns[i];
|
pColIdx[i].schemaColIdx = pColList->boundColumns[i];
|
||||||
pColIdx[i].boundIdx = i;
|
pColIdx[i].boundIdx = i;
|
||||||
}
|
}
|
||||||
qsort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), schemaIdxCompar);
|
taosSort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), schemaIdxCompar);
|
||||||
for (col_id_t i = 0; i < pColList->numOfBound; ++i) {
|
for (col_id_t i = 0; i < pColList->numOfBound; ++i) {
|
||||||
pColIdx[i].finalIdx = i;
|
pColIdx[i].finalIdx = i;
|
||||||
}
|
}
|
||||||
qsort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), boundIdxCompar);
|
taosSort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), boundIdxCompar);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pColList->numOfCols > pColList->numOfBound) {
|
if (pColList->numOfCols > pColList->numOfBound) {
|
||||||
|
@ -1302,6 +1302,74 @@ static int32_t parseValuesClause(SInsertParseContext* pCxt, STableDataBlocks* da
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t parseCsvFile(SInsertParseContext* pCxt, TdFilePtr fp, STableDataBlocks* pDataBlock, int maxRows,
|
||||||
|
int32_t* numOfRows) {
|
||||||
|
STableComInfo tinfo = getTableInfo(pDataBlock->pTableMeta);
|
||||||
|
int32_t extendedRowSize = getExtendedRowSize(pDataBlock);
|
||||||
|
CHECK_CODE(initRowBuilder(&pDataBlock->rowBuilder, pDataBlock->pTableMeta->sversion, &pDataBlock->boundColumnInfo));
|
||||||
|
|
||||||
|
(*numOfRows) = 0;
|
||||||
|
char tmpTokenBuf[TSDB_MAX_BYTES_PER_ROW] = {0}; // used for deleting Escape character: \\, \', \"
|
||||||
|
char* pLine = NULL;
|
||||||
|
int64_t readLen = 0;
|
||||||
|
while ((readLen = taosGetLineFile(fp, &pLine)) != -1) {
|
||||||
|
if (('\r' == pLine[readLen - 1]) || ('\n' == pLine[readLen - 1])) {
|
||||||
|
pLine[--readLen] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (readLen == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((*numOfRows) >= maxRows || pDataBlock->size + extendedRowSize >= pDataBlock->nAllocSize) {
|
||||||
|
int32_t tSize;
|
||||||
|
CHECK_CODE(allocateMemIfNeed(pDataBlock, extendedRowSize, &tSize));
|
||||||
|
ASSERT(tSize >= maxRows);
|
||||||
|
maxRows = tSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
strtolower(pLine, pLine);
|
||||||
|
char* pRawSql = pCxt->pSql;
|
||||||
|
pCxt->pSql = pLine;
|
||||||
|
bool gotRow = false;
|
||||||
|
CHECK_CODE(parseOneRow(pCxt, pDataBlock, tinfo.precision, &gotRow, tmpTokenBuf));
|
||||||
|
if (gotRow) {
|
||||||
|
pDataBlock->size += extendedRowSize; // len;
|
||||||
|
(*numOfRows)++;
|
||||||
|
}
|
||||||
|
pCxt->pSql = pRawSql;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 == (*numOfRows) && (!TSDB_QUERY_HAS_TYPE(pCxt->pOutput->insertType, TSDB_QUERY_TYPE_STMT_INSERT))) {
|
||||||
|
return buildSyntaxErrMsg(&pCxt->msg, "no any data points", NULL);
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t parseDataFromFile(SInsertParseContext* pCxt, SToken filePath, STableDataBlocks* dataBuf) {
|
||||||
|
char filePathStr[TSDB_FILENAME_LEN] = {0};
|
||||||
|
strncpy(filePathStr, filePath.z, filePath.n);
|
||||||
|
TdFilePtr fp = taosOpenFile(filePathStr, TD_FILE_READ | TD_FILE_STREAM);
|
||||||
|
if (NULL == fp) {
|
||||||
|
return TAOS_SYSTEM_ERROR(errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t maxNumOfRows;
|
||||||
|
CHECK_CODE(allocateMemIfNeed(dataBuf, getExtendedRowSize(dataBuf), &maxNumOfRows));
|
||||||
|
|
||||||
|
int32_t numOfRows = 0;
|
||||||
|
CHECK_CODE(parseCsvFile(pCxt, fp, dataBuf, maxNumOfRows, &numOfRows));
|
||||||
|
|
||||||
|
SSubmitBlk* pBlocks = (SSubmitBlk*)(dataBuf->pData);
|
||||||
|
if (TSDB_CODE_SUCCESS != setBlockInfo(pBlocks, dataBuf, numOfRows)) {
|
||||||
|
return buildInvalidOperationMsg(&pCxt->msg, "too many rows in sql, total number of rows should be less than 32767");
|
||||||
|
}
|
||||||
|
|
||||||
|
dataBuf->numOfTables = 1;
|
||||||
|
pCxt->totalNum += numOfRows;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
void destroyCreateSubTbReq(SVCreateTbReq* pReq) {
|
void destroyCreateSubTbReq(SVCreateTbReq* pReq) {
|
||||||
taosMemoryFreeClear(pReq->name);
|
taosMemoryFreeClear(pReq->name);
|
||||||
taosMemoryFreeClear(pReq->ctb.pTag);
|
taosMemoryFreeClear(pReq->ctb.pTag);
|
||||||
|
@ -1421,7 +1489,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
|
||||||
if (0 == sToken.n || (TK_NK_STRING != sToken.type && TK_NK_ID != sToken.type)) {
|
if (0 == sToken.n || (TK_NK_STRING != sToken.type && TK_NK_ID != sToken.type)) {
|
||||||
return buildSyntaxErrMsg(&pCxt->msg, "file path is required following keyword FILE", sToken.z);
|
return buildSyntaxErrMsg(&pCxt->msg, "file path is required following keyword FILE", sToken.z);
|
||||||
}
|
}
|
||||||
// todo
|
CHECK_CODE(parseDataFromFile(pCxt, sToken, dataBuf));
|
||||||
pCxt->pOutput->insertType = TSDB_QUERY_TYPE_FILE_INSERT;
|
pCxt->pOutput->insertType = TSDB_QUERY_TYPE_FILE_INSERT;
|
||||||
|
|
||||||
tbNum++;
|
tbNum++;
|
||||||
|
@ -2164,11 +2232,11 @@ static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SS
|
||||||
pColIdx[i].schemaColIdx = pColList->boundColumns[i];
|
pColIdx[i].schemaColIdx = pColList->boundColumns[i];
|
||||||
pColIdx[i].boundIdx = i;
|
pColIdx[i].boundIdx = i;
|
||||||
}
|
}
|
||||||
qsort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), schemaIdxCompar);
|
taosSort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), schemaIdxCompar);
|
||||||
for (col_id_t i = 0; i < pColList->numOfBound; ++i) {
|
for (col_id_t i = 0; i < pColList->numOfBound; ++i) {
|
||||||
pColIdx[i].finalIdx = i;
|
pColIdx[i].finalIdx = i;
|
||||||
}
|
}
|
||||||
qsort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), boundIdxCompar);
|
taosSort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), boundIdxCompar);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pColList->numOfCols > pColList->numOfBound) {
|
if (pColList->numOfCols > pColList->numOfBound) {
|
||||||
|
|
|
@ -295,7 +295,7 @@ void sortRemoveDataBlockDupRowsRaw(STableDataBlocks* dataBuf) {
|
||||||
char* pBlockData = pBlocks->data;
|
char* pBlockData = pBlocks->data;
|
||||||
|
|
||||||
// todo. qsort is unstable, if timestamp is same, should get the last one
|
// todo. qsort is unstable, if timestamp is same, should get the last one
|
||||||
qsort(pBlockData, pBlocks->numOfRows, dataBuf->rowSize, rowDataCompar);
|
taosSort(pBlockData, pBlocks->numOfRows, dataBuf->rowSize, rowDataCompar);
|
||||||
|
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
int32_t j = 1;
|
int32_t j = 1;
|
||||||
|
@ -365,7 +365,7 @@ int sortRemoveDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* pBlkKey
|
||||||
pBlkKeyTuple = pBlkKeyInfo->pKeyTuple;
|
pBlkKeyTuple = pBlkKeyInfo->pKeyTuple;
|
||||||
|
|
||||||
// todo. qsort is unstable, if timestamp is same, should get the last one
|
// todo. qsort is unstable, if timestamp is same, should get the last one
|
||||||
qsort(pBlkKeyTuple, nRows, sizeof(SBlockKeyTuple), rowDataComparStable);
|
taosSort(pBlkKeyTuple, nRows, sizeof(SBlockKeyTuple), rowDataComparStable);
|
||||||
|
|
||||||
pBlkKeyTuple = pBlkKeyInfo->pKeyTuple;
|
pBlkKeyTuple = pBlkKeyInfo->pKeyTuple;
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
|
|
|
@ -84,8 +84,10 @@ static SKeyword keywordTable[] = {
|
||||||
{"DURATION", TK_DURATION},
|
{"DURATION", TK_DURATION},
|
||||||
{"ENABLE", TK_ENABLE},
|
{"ENABLE", TK_ENABLE},
|
||||||
{"EXISTS", TK_EXISTS},
|
{"EXISTS", TK_EXISTS},
|
||||||
|
{"EXPIRED", TK_EXPIRED},
|
||||||
{"EXPLAIN", TK_EXPLAIN},
|
{"EXPLAIN", TK_EXPLAIN},
|
||||||
{"EVERY", TK_EVERY},
|
{"EVERY", TK_EVERY},
|
||||||
|
{"FILE", TK_FILE},
|
||||||
{"FILL", TK_FILL},
|
{"FILL", TK_FILL},
|
||||||
{"FIRST", TK_FIRST},
|
{"FIRST", TK_FIRST},
|
||||||
{"FLOAT", TK_FLOAT},
|
{"FLOAT", TK_FLOAT},
|
||||||
|
@ -98,6 +100,7 @@ static SKeyword keywordTable[] = {
|
||||||
{"GROUP", TK_GROUP},
|
{"GROUP", TK_GROUP},
|
||||||
{"HAVING", TK_HAVING},
|
{"HAVING", TK_HAVING},
|
||||||
{"IF", TK_IF},
|
{"IF", TK_IF},
|
||||||
|
{"IGNORE", TK_IGNORE},
|
||||||
{"IMPORT", TK_IMPORT},
|
{"IMPORT", TK_IMPORT},
|
||||||
{"IN", TK_IN},
|
{"IN", TK_IN},
|
||||||
{"INDEX", TK_INDEX},
|
{"INDEX", TK_INDEX},
|
||||||
|
@ -289,7 +292,6 @@ static SKeyword keywordTable[] = {
|
||||||
// {"END", TK_END},
|
// {"END", TK_END},
|
||||||
// {"FAIL", TK_FAIL},
|
// {"FAIL", TK_FAIL},
|
||||||
// {"FOR", TK_FOR},
|
// {"FOR", TK_FOR},
|
||||||
// {"IGNORE", TK_IGNORE},
|
|
||||||
// {"IMMEDIATE", TK_IMMEDIATE},
|
// {"IMMEDIATE", TK_IMMEDIATE},
|
||||||
// {"INITIALLY", TK_INITIALLY},
|
// {"INITIALLY", TK_INITIALLY},
|
||||||
// {"INSTEAD", TK_INSTEAD},
|
// {"INSTEAD", TK_INSTEAD},
|
||||||
|
|
|
@ -783,6 +783,13 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
|
||||||
if (pVal->placeholderNo > 0 || pVal->isNull) {
|
if (pVal->placeholderNo > 0 || pVal->isNull) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
if (TSDB_DATA_TYPE_NULL == pVal->node.resType.type) {
|
||||||
|
// TODO
|
||||||
|
// pVal->node.resType = targetDt;
|
||||||
|
pVal->translate = true;
|
||||||
|
pVal->isNull = true;
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
if (pVal->isDuration) {
|
if (pVal->isDuration) {
|
||||||
if (parseNatualDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit, precision) !=
|
if (parseNatualDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit, precision) !=
|
||||||
TSDB_CODE_SUCCESS) {
|
TSDB_CODE_SUCCESS) {
|
||||||
|
@ -1984,34 +1991,38 @@ static int32_t createMultiResFuncsFromStar(STranslateContext* pCxt, SFunctionNod
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
if (NULL == pSelect->pProjectionList) { // select * ...
|
SNode* pNode = NULL;
|
||||||
return createAllColumns(pCxt, &pSelect->pProjectionList);
|
WHERE_EACH(pNode, pSelect->pProjectionList) {
|
||||||
} else {
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SNode* pNode = NULL;
|
if (isStar(pNode)) {
|
||||||
WHERE_EACH(pNode, pSelect->pProjectionList) {
|
SNodeList* pCols = NULL;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
code = createAllColumns(pCxt, &pCols);
|
||||||
if (isMultiResFunc(pNode)) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
SNodeList* pFuncs = NULL;
|
INSERT_LIST(pSelect->pProjectionList, pCols);
|
||||||
code = createMultiResFuncsFromStar(pCxt, (SFunctionNode*)pNode, &pFuncs);
|
ERASE_NODE(pSelect->pProjectionList);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
continue;
|
||||||
INSERT_LIST(pSelect->pProjectionList, pFuncs);
|
|
||||||
ERASE_NODE(pSelect->pProjectionList);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else if (isTableStar(pNode)) {
|
|
||||||
SNodeList* pCols = NULL;
|
|
||||||
code = createTableAllCols(pCxt, (SColumnNode*)pNode, &pCols);
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
INSERT_LIST(pSelect->pProjectionList, pCols);
|
|
||||||
ERASE_NODE(pSelect->pProjectionList);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
} else if (isMultiResFunc(pNode)) {
|
||||||
return code;
|
SNodeList* pFuncs = NULL;
|
||||||
|
code = createMultiResFuncsFromStar(pCxt, (SFunctionNode*)pNode, &pFuncs);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
INSERT_LIST(pSelect->pProjectionList, pFuncs);
|
||||||
|
ERASE_NODE(pSelect->pProjectionList);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else if (isTableStar(pNode)) {
|
||||||
|
SNodeList* pCols = NULL;
|
||||||
|
code = createTableAllCols(pCxt, (SColumnNode*)pNode, &pCols);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
INSERT_LIST(pSelect->pProjectionList, pCols);
|
||||||
|
ERASE_NODE(pSelect->pProjectionList);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
WHERE_NEXT;
|
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
WHERE_NEXT;
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -3610,8 +3621,8 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
|
||||||
pReq->numOfColumns = LIST_LENGTH(pStmt->pCols);
|
pReq->numOfColumns = LIST_LENGTH(pStmt->pCols);
|
||||||
pReq->numOfTags = LIST_LENGTH(pStmt->pTags);
|
pReq->numOfTags = LIST_LENGTH(pStmt->pTags);
|
||||||
if (pStmt->pOptions->commentNull == false) {
|
if (pStmt->pOptions->commentNull == false) {
|
||||||
pReq->comment = strdup(pStmt->pOptions->comment);
|
pReq->pComment = strdup(pStmt->pOptions->comment);
|
||||||
if (NULL == pReq->comment) {
|
if (NULL == pReq->pComment) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
pReq->commentLen = strlen(pStmt->pOptions->comment);
|
pReq->commentLen = strlen(pStmt->pOptions->comment);
|
||||||
|
@ -3619,6 +3630,7 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
|
||||||
pReq->commentLen = -1;
|
pReq->commentLen = -1;
|
||||||
}
|
}
|
||||||
buildRollupFuncs(pStmt->pOptions->pRollupFuncs, &pReq->pFuncs);
|
buildRollupFuncs(pStmt->pOptions->pRollupFuncs, &pReq->pFuncs);
|
||||||
|
pReq->numOfFuncs = taosArrayGetSize(pReq->pFuncs);
|
||||||
|
|
||||||
SName tableName;
|
SName tableName;
|
||||||
tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName), pReq->name);
|
tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName), pReq->name);
|
||||||
|
@ -4204,6 +4216,7 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt*
|
||||||
pReq->triggerType = pStmt->pOptions->triggerType;
|
pReq->triggerType = pStmt->pOptions->triggerType;
|
||||||
pReq->maxDelay = (NULL != pStmt->pOptions->pDelay ? ((SValueNode*)pStmt->pOptions->pDelay)->datum.i : 0);
|
pReq->maxDelay = (NULL != pStmt->pOptions->pDelay ? ((SValueNode*)pStmt->pOptions->pDelay)->datum.i : 0);
|
||||||
pReq->watermark = (NULL != pStmt->pOptions->pWatermark ? ((SValueNode*)pStmt->pOptions->pWatermark)->datum.i : 0);
|
pReq->watermark = (NULL != pStmt->pOptions->pWatermark ? ((SValueNode*)pStmt->pOptions->pWatermark)->datum.i : 0);
|
||||||
|
pReq->igExpired = pStmt->pOptions->ignoreExpired;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -4794,6 +4807,15 @@ static const char* getSysTableName(ENodeType type) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SNode* createStarCol() {
|
||||||
|
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||||
|
if (NULL == pCol) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
strcpy(pCol->colName, "*");
|
||||||
|
return (SNode*)pCol;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t createSimpleSelectStmt(const char* pDb, const char* pTable, SSelectStmt** pStmt) {
|
static int32_t createSimpleSelectStmt(const char* pDb, const char* pTable, SSelectStmt** pStmt) {
|
||||||
SSelectStmt* pSelect = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT);
|
SSelectStmt* pSelect = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT);
|
||||||
if (NULL == pSelect) {
|
if (NULL == pSelect) {
|
||||||
|
@ -4811,6 +4833,11 @@ static int32_t createSimpleSelectStmt(const char* pDb, const char* pTable, SSele
|
||||||
strcpy(pRealTable->table.tableAlias, pTable);
|
strcpy(pRealTable->table.tableAlias, pTable);
|
||||||
pSelect->pFromTable = (SNode*)pRealTable;
|
pSelect->pFromTable = (SNode*)pRealTable;
|
||||||
|
|
||||||
|
if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pSelect->pProjectionList, createStarCol())) {
|
||||||
|
nodesDestroyNode((SNode*)pSelect);
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
*pStmt = pSelect;
|
*pStmt = pSelect;
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -4959,6 +4986,7 @@ static int32_t rewriteShowTableDist(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
SSelectStmt* pStmt = NULL;
|
SSelectStmt* pStmt = NULL;
|
||||||
int32_t code = createSelectStmtForShowTableDist((SShowTableDistributedStmt*)pQuery->pRoot, &pStmt);
|
int32_t code = createSelectStmtForShowTableDist((SShowTableDistributedStmt*)pQuery->pRoot, &pStmt);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
NODES_DESTORY_LIST(pStmt->pProjectionList);
|
||||||
code = nodesListMakeStrictAppend(&pStmt->pProjectionList, createBlockDistFunc());
|
code = nodesListMakeStrictAppend(&pStmt->pProjectionList, createBlockDistFunc());
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -5335,7 +5363,7 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
} else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) {
|
} else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL && !pVal->isNull) {
|
||||||
char* tmpVal = nodesGetValueFromNode(pVal);
|
char* tmpVal = nodesGetValueFromNode(pVal);
|
||||||
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
|
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
|
||||||
if (IS_VAR_DATA_TYPE(pTagSchema->type)) {
|
if (IS_VAR_DATA_TYPE(pTagSchema->type)) {
|
||||||
|
@ -5602,8 +5630,8 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEAL_RES_ERROR ==
|
SDataType targetDt = schemaToDataType(pTableMeta->tableInfo.precision, pSchema);
|
||||||
translateValueImpl(pCxt, pStmt->pVal, schemaToDataType(pTableMeta->tableInfo.precision, pSchema))) {
|
if (DEAL_RES_ERROR == translateValueImpl(pCxt, pStmt->pVal, targetDt)) {
|
||||||
return pCxt->errCode;
|
return pCxt->errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5612,7 +5640,8 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
|
||||||
}
|
}
|
||||||
|
|
||||||
pReq->isNull = (TSDB_DATA_TYPE_NULL == pStmt->pVal->node.resType.type);
|
pReq->isNull = (TSDB_DATA_TYPE_NULL == pStmt->pVal->node.resType.type);
|
||||||
if (pStmt->pVal->node.resType.type == TSDB_DATA_TYPE_JSON) {
|
if (targetDt.type == TSDB_DATA_TYPE_JSON) {
|
||||||
|
pReq->isNull = 0;
|
||||||
if (pStmt->pVal->literal &&
|
if (pStmt->pVal->literal &&
|
||||||
strlen(pStmt->pVal->literal) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) {
|
strlen(pStmt->pVal->literal) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) {
|
||||||
return buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pStmt->pVal->literal);
|
return buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pStmt->pVal->literal);
|
||||||
|
@ -6011,7 +6040,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
case QUERY_NODE_EXPLAIN_STMT:
|
case QUERY_NODE_EXPLAIN_STMT:
|
||||||
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||||
pQuery->haveResultSet = true;
|
pQuery->haveResultSet = true;
|
||||||
pQuery->msgType = TDMT_VND_QUERY;
|
pQuery->msgType = TDMT_SCH_QUERY;
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_DELETE_STMT:
|
case QUERY_NODE_DELETE_STMT:
|
||||||
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -372,7 +372,7 @@ TEST_F(ParserInitialCTest, createStable) {
|
||||||
expect.watermark2 = watermark2;
|
expect.watermark2 = watermark2;
|
||||||
// expect.ttl = ttl;
|
// expect.ttl = ttl;
|
||||||
if (nullptr != pComment) {
|
if (nullptr != pComment) {
|
||||||
expect.comment = strdup(pComment);
|
expect.pComment = strdup(pComment);
|
||||||
expect.commentLen = strlen(pComment);
|
expect.commentLen = strlen(pComment);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -443,7 +443,7 @@ TEST_F(ParserInitialCTest, createStable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (expect.commentLen > 0) {
|
if (expect.commentLen > 0) {
|
||||||
ASSERT_EQ(std::string(req.comment), std::string(expect.comment));
|
ASSERT_EQ(std::string(req.pComment), std::string(expect.pComment));
|
||||||
}
|
}
|
||||||
if (expect.ast1Len > 0) {
|
if (expect.ast1Len > 0) {
|
||||||
ASSERT_EQ(std::string(req.pAst1), std::string(expect.pAst1));
|
ASSERT_EQ(std::string(req.pAst1), std::string(expect.pAst1));
|
||||||
|
@ -526,20 +526,22 @@ TEST_F(ParserInitialCTest, createStream) {
|
||||||
memset(&expect, 0, sizeof(SCMCreateStreamReq));
|
memset(&expect, 0, sizeof(SCMCreateStreamReq));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto setCreateStreamReqFunc =
|
auto setCreateStreamReqFunc = [&](const char* pStream, const char* pSrcDb, const char* pSql,
|
||||||
[&](const char* pStream, const char* pSrcDb, const char* pSql, const char* pDstStb = nullptr, int8_t igExists = 0,
|
const char* pDstStb = nullptr, int8_t igExists = 0,
|
||||||
int8_t triggerType = STREAM_TRIGGER_AT_ONCE, int64_t maxDelay = 0, int64_t watermark = 0) {
|
int8_t triggerType = STREAM_TRIGGER_AT_ONCE, int64_t maxDelay = 0,
|
||||||
snprintf(expect.name, sizeof(expect.name), "0.%s", pStream);
|
int64_t watermark = 0, int8_t igExpired = 0) {
|
||||||
snprintf(expect.sourceDB, sizeof(expect.sourceDB), "0.%s", pSrcDb);
|
snprintf(expect.name, sizeof(expect.name), "0.%s", pStream);
|
||||||
if (NULL != pDstStb) {
|
snprintf(expect.sourceDB, sizeof(expect.sourceDB), "0.%s", pSrcDb);
|
||||||
snprintf(expect.targetStbFullName, sizeof(expect.targetStbFullName), "0.test.%s", pDstStb);
|
if (NULL != pDstStb) {
|
||||||
}
|
snprintf(expect.targetStbFullName, sizeof(expect.targetStbFullName), "0.test.%s", pDstStb);
|
||||||
expect.igExists = igExists;
|
}
|
||||||
expect.sql = strdup(pSql);
|
expect.igExists = igExists;
|
||||||
expect.triggerType = triggerType;
|
expect.sql = strdup(pSql);
|
||||||
expect.maxDelay = maxDelay;
|
expect.triggerType = triggerType;
|
||||||
expect.watermark = watermark;
|
expect.maxDelay = maxDelay;
|
||||||
};
|
expect.watermark = watermark;
|
||||||
|
expect.igExpired = igExpired;
|
||||||
|
};
|
||||||
|
|
||||||
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||||
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_CREATE_STREAM_STMT);
|
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_CREATE_STREAM_STMT);
|
||||||
|
@ -555,6 +557,7 @@ TEST_F(ParserInitialCTest, createStream) {
|
||||||
ASSERT_EQ(req.triggerType, expect.triggerType);
|
ASSERT_EQ(req.triggerType, expect.triggerType);
|
||||||
ASSERT_EQ(req.maxDelay, expect.maxDelay);
|
ASSERT_EQ(req.maxDelay, expect.maxDelay);
|
||||||
ASSERT_EQ(req.watermark, expect.watermark);
|
ASSERT_EQ(req.watermark, expect.watermark);
|
||||||
|
ASSERT_EQ(req.igExpired, expect.igExpired);
|
||||||
tFreeSCMCreateStreamReq(&req);
|
tFreeSCMCreateStreamReq(&req);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -571,9 +574,10 @@ TEST_F(ParserInitialCTest, createStream) {
|
||||||
clearCreateStreamReq();
|
clearCreateStreamReq();
|
||||||
|
|
||||||
setCreateStreamReqFunc(
|
setCreateStreamReqFunc(
|
||||||
"s1", "test", "create stream if not exists s1 trigger max_delay 20s watermark 10s into st1 as select * from t1",
|
"s1", "test",
|
||||||
"st1", 1, STREAM_TRIGGER_MAX_DELAY, 20 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_SECOND);
|
"create stream if not exists s1 trigger max_delay 20s watermark 10s ignore expired into st1 as select * from t1",
|
||||||
run("CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s INTO st1 AS SELECT * FROM t1");
|
"st1", 1, STREAM_TRIGGER_MAX_DELAY, 20 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_SECOND, 1);
|
||||||
|
run("CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s IGNORE EXPIRED INTO st1 AS SELECT * FROM t1");
|
||||||
clearCreateStreamReq();
|
clearCreateStreamReq();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -614,10 +614,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
|
||||||
if (pCxt->pPlanCxt->streamQuery) {
|
if (pCxt->pPlanCxt->streamQuery) {
|
||||||
pWindow->triggerType = pCxt->pPlanCxt->triggerType;
|
pWindow->triggerType = pCxt->pPlanCxt->triggerType;
|
||||||
pWindow->watermark = pCxt->pPlanCxt->watermark;
|
pWindow->watermark = pCxt->pPlanCxt->watermark;
|
||||||
}
|
pWindow->igExpired = pCxt->pPlanCxt->igExpired;
|
||||||
|
|
||||||
if (pCxt->pPlanCxt->rSmaQuery) {
|
|
||||||
/*pWindow->filesFactor = pCxt->pPlanCxt->filesFactor;*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
|
|
@ -227,8 +227,7 @@ static void scanPathOptSetScanWin(SScanLogicNode* pScan) {
|
||||||
pScan->slidingUnit = ((SWindowLogicNode*)pParent)->slidingUnit;
|
pScan->slidingUnit = ((SWindowLogicNode*)pParent)->slidingUnit;
|
||||||
pScan->triggerType = ((SWindowLogicNode*)pParent)->triggerType;
|
pScan->triggerType = ((SWindowLogicNode*)pParent)->triggerType;
|
||||||
pScan->watermark = ((SWindowLogicNode*)pParent)->watermark;
|
pScan->watermark = ((SWindowLogicNode*)pParent)->watermark;
|
||||||
pScan->tsColId = ((SColumnNode*)((SWindowLogicNode*)pParent)->pTspk)->colId;
|
pScan->igExpired = ((SWindowLogicNode*)pParent)->igExpired;
|
||||||
pScan->filesFactor = ((SWindowLogicNode*)pParent)->filesFactor;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,10 +476,16 @@ static int32_t pushDownCondOptPushCondToScan(SOptimizeContext* pCxt, SScanLogicN
|
||||||
return pushDownCondOptAppendCond(&pScan->node.pConditions, pCond);
|
return pushDownCondOptAppendCond(&pScan->node.pConditions, pCond);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t pushDownCondOptPushCondToProject(SOptimizeContext* pCxt, SProjectLogicNode* pProject, SNode** pCond) {
|
||||||
|
return pushDownCondOptAppendCond(&pProject->node.pConditions, pCond);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t pushDownCondOptPushCondToChild(SOptimizeContext* pCxt, SLogicNode* pChild, SNode** pCond) {
|
static int32_t pushDownCondOptPushCondToChild(SOptimizeContext* pCxt, SLogicNode* pChild, SNode** pCond) {
|
||||||
switch (nodeType(pChild)) {
|
switch (nodeType(pChild)) {
|
||||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||||
return pushDownCondOptPushCondToScan(pCxt, (SScanLogicNode*)pChild, pCond);
|
return pushDownCondOptPushCondToScan(pCxt, (SScanLogicNode*)pChild, pCond);
|
||||||
|
case QUERY_NODE_LOGIC_PLAN_PROJECT:
|
||||||
|
return pushDownCondOptPushCondToProject(pCxt, (SProjectLogicNode*)pChild, pCond);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -587,11 +592,161 @@ static int32_t pushDownCondOptDealJoin(SOptimizeContext* pCxt, SJoinLogicNode* p
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t pushDownCondOptDealAgg(SOptimizeContext* pCxt, SAggLogicNode* pAgg) {
|
typedef struct SPartAggCondContext {
|
||||||
// todo
|
SAggLogicNode* pAgg;
|
||||||
|
bool hasAggFunc;
|
||||||
|
} SPartAggCondContext;
|
||||||
|
|
||||||
|
static EDealRes partAggCondHasAggFuncImpl(SNode* pNode, void* pContext) {
|
||||||
|
SPartAggCondContext* pCxt = pContext;
|
||||||
|
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||||
|
SNode* pAggFunc = NULL;
|
||||||
|
FOREACH(pAggFunc, pCxt->pAgg->pAggFuncs) {
|
||||||
|
if (strcmp(((SColumnNode*)pNode)->colName, ((SFunctionNode*)pAggFunc)->node.aliasName) == 0) {
|
||||||
|
pCxt->hasAggFunc = true;
|
||||||
|
return DEAL_RES_END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t partitionAggCondHasAggFunc(SAggLogicNode* pAgg, SNode* pCond) {
|
||||||
|
SPartAggCondContext cxt = {.pAgg = pAgg, .hasAggFunc = false};
|
||||||
|
nodesWalkExpr(pCond, partAggCondHasAggFuncImpl, &cxt);
|
||||||
|
return cxt.hasAggFunc;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t partitionAggCondConj(SAggLogicNode* pAgg, SNode** ppAggFuncCond, SNode** ppGroupKeyCond) {
|
||||||
|
SLogicConditionNode* pLogicCond = (SLogicConditionNode*)pAgg->node.pConditions;
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
SNodeList* pAggFuncConds = NULL;
|
||||||
|
SNodeList* pGroupKeyConds = NULL;
|
||||||
|
SNode* pCond = NULL;
|
||||||
|
FOREACH(pCond, pLogicCond->pParameterList) {
|
||||||
|
if (partitionAggCondHasAggFunc(pAgg, pCond)) {
|
||||||
|
code = nodesListMakeAppend(&pAggFuncConds, nodesCloneNode(pCond));
|
||||||
|
} else {
|
||||||
|
code = nodesListMakeAppend(&pGroupKeyConds, nodesCloneNode(pCond));
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SNode* pTempAggFuncCond = NULL;
|
||||||
|
SNode* pTempGroupKeyCond = NULL;
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = nodesMergeConds(&pTempAggFuncCond, &pAggFuncConds);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = nodesMergeConds(&pTempGroupKeyCond, &pGroupKeyConds);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
*ppAggFuncCond = pTempAggFuncCond;
|
||||||
|
*ppGroupKeyCond = pTempGroupKeyCond;
|
||||||
|
} else {
|
||||||
|
nodesDestroyList(pAggFuncConds);
|
||||||
|
nodesDestroyList(pGroupKeyConds);
|
||||||
|
nodesDestroyNode(pTempAggFuncCond);
|
||||||
|
nodesDestroyNode(pTempGroupKeyCond);
|
||||||
|
}
|
||||||
|
pAgg->node.pConditions = NULL;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t partitionAggCond(SAggLogicNode* pAgg, SNode** ppAggFunCond, SNode** ppGroupKeyCond) {
|
||||||
|
SNode* pAggNodeCond = pAgg->node.pConditions;
|
||||||
|
if (QUERY_NODE_LOGIC_CONDITION == nodeType(pAggNodeCond) &&
|
||||||
|
LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)(pAggNodeCond))->condType) {
|
||||||
|
return partitionAggCondConj(pAgg, ppAggFunCond, ppGroupKeyCond);
|
||||||
|
}
|
||||||
|
if (partitionAggCondHasAggFunc(pAgg, pAggNodeCond)) {
|
||||||
|
*ppAggFunCond = pAggNodeCond;
|
||||||
|
} else {
|
||||||
|
*ppGroupKeyCond = pAggNodeCond;
|
||||||
|
}
|
||||||
|
pAgg->node.pConditions = NULL;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t pushCondToAggCond(SOptimizeContext* pCxt, SAggLogicNode* pAgg, SNode** pAggFuncCond) {
|
||||||
|
pushDownCondOptAppendCond(&pAgg->node.pConditions, pAggFuncCond);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct SRewriteAggGroupKeyCondContext{
|
||||||
|
SAggLogicNode *pAgg;
|
||||||
|
int32_t errCode;
|
||||||
|
} SRewriteAggGroupKeyCondContext;
|
||||||
|
|
||||||
|
static EDealRes rewriteAggGroupKeyCondForPushDownImpl(SNode** pNode, void* pContext) {
|
||||||
|
SRewriteAggGroupKeyCondContext* pCxt = pContext;
|
||||||
|
SAggLogicNode* pAgg = pCxt->pAgg;
|
||||||
|
if (QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
||||||
|
SNode* pGroupKey = NULL;
|
||||||
|
FOREACH(pGroupKey, pAgg->pGroupKeys) {
|
||||||
|
SNode* pGroup = NULL;
|
||||||
|
FOREACH(pGroup, ((SGroupingSetNode*)pGroupKey)->pParameterList) {
|
||||||
|
if (0 == strcmp(((SExprNode*)pGroup)->aliasName, ((SColumnNode*)(*pNode))->colName)) {
|
||||||
|
SNode* pExpr = nodesCloneNode(pGroup);
|
||||||
|
if (pExpr == NULL) {
|
||||||
|
pCxt->errCode = terrno;
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
}
|
||||||
|
nodesDestroyNode(*pNode);
|
||||||
|
*pNode = pExpr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
|
}
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t rewriteAggGroupKeyCondForPushDown(SOptimizeContext* pCxt, SAggLogicNode* pAgg, SNode* pGroupKeyCond) {
|
||||||
|
SRewriteAggGroupKeyCondContext cxt = {.pAgg = pAgg, .errCode = TSDB_CODE_SUCCESS};
|
||||||
|
nodesRewriteExpr(&pGroupKeyCond, rewriteAggGroupKeyCondForPushDownImpl, &cxt);
|
||||||
|
return cxt.errCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t pushDownCondOptDealAgg(SOptimizeContext* pCxt, SAggLogicNode* pAgg) {
|
||||||
|
if (NULL == pAgg->node.pConditions ||
|
||||||
|
OPTIMIZE_FLAG_TEST_MASK(pAgg->node.optimizedFlag, OPTIMIZE_FLAG_PUSH_DOWN_CONDE)) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
//TODO: remove it after full implementation of pushing down to child
|
||||||
|
if (1 != LIST_LENGTH(pAgg->node.pChildren) ||
|
||||||
|
QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(nodesListGetNode(pAgg->node.pChildren, 0)) &&
|
||||||
|
QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(nodesListGetNode(pAgg->node.pChildren, 0))) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
SNode* pAggFuncCond = NULL;
|
||||||
|
SNode* pGroupKeyCond = NULL;
|
||||||
|
int32_t code = partitionAggCond(pAgg, &pAggFuncCond, &pGroupKeyCond);
|
||||||
|
if (TSDB_CODE_SUCCESS == code && NULL != pAggFuncCond) {
|
||||||
|
code = pushCondToAggCond(pCxt, pAgg, &pAggFuncCond);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code && NULL != pGroupKeyCond) {
|
||||||
|
code = rewriteAggGroupKeyCondForPushDown(pCxt, pAgg, pGroupKeyCond);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code && NULL != pGroupKeyCond) {
|
||||||
|
SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pAgg->node.pChildren, 0);
|
||||||
|
code = pushDownCondOptPushCondToChild(pCxt, pChild, &pGroupKeyCond);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
OPTIMIZE_FLAG_SET_MASK(pAgg->node.optimizedFlag, OPTIMIZE_FLAG_PUSH_DOWN_CONDE);
|
||||||
|
pCxt->optimized = true;
|
||||||
|
} else {
|
||||||
|
nodesDestroyNode(pGroupKeyCond);
|
||||||
|
nodesDestroyNode(pAggFuncCond);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t pushDownCondOptimizeImpl(SOptimizeContext* pCxt, SLogicNode* pLogicNode) {
|
static int32_t pushDownCondOptimizeImpl(SOptimizeContext* pCxt, SLogicNode* pLogicNode) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
switch (nodeType(pLogicNode)) {
|
switch (nodeType(pLogicNode)) {
|
||||||
|
@ -1708,8 +1863,8 @@ static EDealRes mergeProjectionsExpr(SNode** pNode, void* pContext) {
|
||||||
|
|
||||||
static int32_t mergeProjectsOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SLogicNode* pSelfNode) {
|
static int32_t mergeProjectsOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SLogicNode* pSelfNode) {
|
||||||
SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pSelfNode->pChildren, 0);
|
SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pSelfNode->pChildren, 0);
|
||||||
SMergeProjectionsContext cxt = {.pChildProj = (SProjectLogicNode*)pChild, .errCode = TSDB_CODE_SUCCESS};
|
|
||||||
|
|
||||||
|
SMergeProjectionsContext cxt = {.pChildProj = (SProjectLogicNode*)pChild, .errCode = TSDB_CODE_SUCCESS};
|
||||||
nodesRewriteExprs(((SProjectLogicNode*)pSelfNode)->pProjections, mergeProjectionsExpr, &cxt);
|
nodesRewriteExprs(((SProjectLogicNode*)pSelfNode)->pProjections, mergeProjectionsExpr, &cxt);
|
||||||
int32_t code = cxt.errCode;
|
int32_t code = cxt.errCode;
|
||||||
|
|
||||||
|
|
|
@ -534,8 +534,7 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp
|
||||||
pTableScan->slidingUnit = pScanLogicNode->slidingUnit;
|
pTableScan->slidingUnit = pScanLogicNode->slidingUnit;
|
||||||
pTableScan->triggerType = pScanLogicNode->triggerType;
|
pTableScan->triggerType = pScanLogicNode->triggerType;
|
||||||
pTableScan->watermark = pScanLogicNode->watermark;
|
pTableScan->watermark = pScanLogicNode->watermark;
|
||||||
pTableScan->tsColId = pScanLogicNode->tsColId;
|
pTableScan->igExpired = pScanLogicNode->igExpired;
|
||||||
pTableScan->filesFactor = pScanLogicNode->filesFactor;
|
|
||||||
|
|
||||||
return createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, (SScanPhysiNode*)pTableScan, pPhyNode);
|
return createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, (SScanPhysiNode*)pTableScan, pPhyNode);
|
||||||
}
|
}
|
||||||
|
@ -1054,7 +1053,7 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList*
|
||||||
|
|
||||||
pWindow->triggerType = pWindowLogicNode->triggerType;
|
pWindow->triggerType = pWindowLogicNode->triggerType;
|
||||||
pWindow->watermark = pWindowLogicNode->watermark;
|
pWindow->watermark = pWindowLogicNode->watermark;
|
||||||
pWindow->filesFactor = pWindowLogicNode->filesFactor;
|
pWindow->igExpired = pWindowLogicNode->igExpired;
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
*pPhyNode = (SPhysiNode*)pWindow;
|
*pPhyNode = (SPhysiNode*)pWindow;
|
||||||
|
@ -1555,7 +1554,11 @@ static int32_t createPhysiSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogic
|
||||||
if (SUBPLAN_TYPE_MODIFY == pLogicSubplan->subplanType) {
|
if (SUBPLAN_TYPE_MODIFY == pLogicSubplan->subplanType) {
|
||||||
code = buildVnodeModifySubplan(pCxt, pLogicSubplan, pSubplan);
|
code = buildVnodeModifySubplan(pCxt, pLogicSubplan, pSubplan);
|
||||||
} else {
|
} else {
|
||||||
pSubplan->msgType = TDMT_VND_QUERY;
|
if (SUBPLAN_TYPE_SCAN == pSubplan->subplanType) {
|
||||||
|
pSubplan->msgType = TDMT_SCH_QUERY;
|
||||||
|
} else {
|
||||||
|
pSubplan->msgType = TDMT_SCH_MERGE_QUERY;
|
||||||
|
}
|
||||||
code = createPhysiNode(pCxt, pLogicSubplan->pNode, pSubplan, &pSubplan->pNode);
|
code = createPhysiNode(pCxt, pLogicSubplan->pNode, pSubplan, &pSubplan->pNode);
|
||||||
if (TSDB_CODE_SUCCESS == code && !pCxt->pPlanCxt->streamQuery && !pCxt->pPlanCxt->topicQuery) {
|
if (TSDB_CODE_SUCCESS == code && !pCxt->pPlanCxt->streamQuery && !pCxt->pPlanCxt->topicQuery) {
|
||||||
code = createDataDispatcher(pCxt, pSubplan->pNode, &pSubplan->pDataSink);
|
code = createDataDispatcher(pCxt, pSubplan->pNode, &pSubplan->pDataSink);
|
||||||
|
|
|
@ -216,7 +216,8 @@ void destroyQueryExecRes(SQueryExecRes* pRes) {
|
||||||
tFreeSSubmitRsp((SSubmitRsp*)pRes->res);
|
tFreeSSubmitRsp((SSubmitRsp*)pRes->res);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_VND_QUERY: {
|
case TDMT_SCH_QUERY:
|
||||||
|
case TDMT_SCH_MERGE_QUERY: {
|
||||||
taosArrayDestroy((SArray*)pRes->res);
|
taosArrayDestroy((SArray*)pRes->res);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ typedef struct SQWDebug {
|
||||||
bool lockEnable;
|
bool lockEnable;
|
||||||
bool statusEnable;
|
bool statusEnable;
|
||||||
bool dumpEnable;
|
bool dumpEnable;
|
||||||
|
bool tmp;
|
||||||
} SQWDebug;
|
} SQWDebug;
|
||||||
|
|
||||||
extern SQWDebug gQWDebug;
|
extern SQWDebug gQWDebug;
|
||||||
|
@ -82,6 +83,7 @@ extern SQWDebug gQWDebug;
|
||||||
typedef struct SQWMsg {
|
typedef struct SQWMsg {
|
||||||
void *node;
|
void *node;
|
||||||
int32_t code;
|
int32_t code;
|
||||||
|
int32_t msgType;
|
||||||
char *msg;
|
char *msg;
|
||||||
int32_t msgLen;
|
int32_t msgLen;
|
||||||
SRpcHandleInfo connInfo;
|
SRpcHandleInfo connInfo;
|
||||||
|
@ -100,6 +102,7 @@ typedef struct SQWHbInfo {
|
||||||
|
|
||||||
typedef struct SQWPhaseInput {
|
typedef struct SQWPhaseInput {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
|
int32_t msgType;
|
||||||
} SQWPhaseInput;
|
} SQWPhaseInput;
|
||||||
|
|
||||||
typedef struct SQWPhaseOutput {
|
typedef struct SQWPhaseOutput {
|
||||||
|
@ -119,6 +122,8 @@ typedef struct SQWTaskCtx {
|
||||||
int8_t phase;
|
int8_t phase;
|
||||||
int8_t taskType;
|
int8_t taskType;
|
||||||
int8_t explain;
|
int8_t explain;
|
||||||
|
int32_t queryType;
|
||||||
|
int32_t execId;
|
||||||
|
|
||||||
bool queryFetched;
|
bool queryFetched;
|
||||||
bool queryEnd;
|
bool queryEnd;
|
||||||
|
@ -197,8 +202,8 @@ typedef struct SQWorkerMgmt {
|
||||||
int32_t paramIdx;
|
int32_t paramIdx;
|
||||||
} SQWorkerMgmt;
|
} SQWorkerMgmt;
|
||||||
|
|
||||||
#define QW_FPARAMS_DEF SQWorker *mgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId
|
#define QW_FPARAMS_DEF SQWorker *mgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId
|
||||||
#define QW_IDS() sId, qId, tId, rId
|
#define QW_IDS() sId, qId, tId, rId, eId
|
||||||
#define QW_FPARAMS() mgmt, QW_IDS()
|
#define QW_FPARAMS() mgmt, QW_IDS()
|
||||||
|
|
||||||
#define QW_STAT_INC(_item, _n) atomic_add_fetch_64(&(_item), _n)
|
#define QW_STAT_INC(_item, _n) atomic_add_fetch_64(&(_item), _n)
|
||||||
|
@ -223,15 +228,18 @@ typedef struct SQWorkerMgmt {
|
||||||
#define QW_TASK_READY(status) \
|
#define QW_TASK_READY(status) \
|
||||||
(status == JOB_TASK_STATUS_SUCCEED || status == JOB_TASK_STATUS_FAILED || status == JOB_TASK_STATUS_CANCELLED || \
|
(status == JOB_TASK_STATUS_SUCCEED || status == JOB_TASK_STATUS_FAILED || status == JOB_TASK_STATUS_CANCELLED || \
|
||||||
status == JOB_TASK_STATUS_PARTIAL_SUCCEED)
|
status == JOB_TASK_STATUS_PARTIAL_SUCCEED)
|
||||||
#define QW_SET_QTID(id, qId, tId) \
|
#define QW_SET_QTID(id, qId, tId, eId) \
|
||||||
do { \
|
do { \
|
||||||
*(uint64_t *)(id) = (qId); \
|
*(uint64_t *)(id) = (qId); \
|
||||||
*(uint64_t *)((char *)(id) + sizeof(qId)) = (tId); \
|
*(uint64_t *)((char *)(id) + sizeof(qId)) = (tId); \
|
||||||
|
*(int32_t *)((char *)(id) + sizeof(qId) + sizeof(tId)) = (eId); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define QW_GET_QTID(id, qId, tId) \
|
|
||||||
do { \
|
#define QW_GET_QTID(id, qId, tId, eId) \
|
||||||
(qId) = *(uint64_t *)(id); \
|
do { \
|
||||||
(tId) = *(uint64_t *)((char *)(id) + sizeof(qId)); \
|
(qId) = *(uint64_t *)(id); \
|
||||||
|
(tId) = *(uint64_t *)((char *)(id) + sizeof(qId)); \
|
||||||
|
(eId) = *(int32_t *)((char *)(id) + sizeof(qId) + sizeof(tId)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define QW_ERR_RET(c) \
|
#define QW_ERR_RET(c) \
|
||||||
|
@ -273,22 +281,22 @@ typedef struct SQWorkerMgmt {
|
||||||
#define QW_SCH_ELOG(param, ...) qError("QW:%p SID:%" PRIx64 " " param, mgmt, sId, __VA_ARGS__)
|
#define QW_SCH_ELOG(param, ...) qError("QW:%p SID:%" PRIx64 " " param, mgmt, sId, __VA_ARGS__)
|
||||||
#define QW_SCH_DLOG(param, ...) qDebug("QW:%p SID:%" PRIx64 " " param, mgmt, sId, __VA_ARGS__)
|
#define QW_SCH_DLOG(param, ...) qDebug("QW:%p SID:%" PRIx64 " " param, mgmt, sId, __VA_ARGS__)
|
||||||
|
|
||||||
#define QW_TASK_ELOG(param, ...) qError("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId, __VA_ARGS__)
|
#define QW_TASK_ELOG(param, ...) qError("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId, __VA_ARGS__)
|
||||||
#define QW_TASK_WLOG(param, ...) qWarn("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId, __VA_ARGS__)
|
#define QW_TASK_WLOG(param, ...) qWarn("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId, __VA_ARGS__)
|
||||||
#define QW_TASK_DLOG(param, ...) qDebug("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId, __VA_ARGS__)
|
#define QW_TASK_DLOG(param, ...) qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId, __VA_ARGS__)
|
||||||
#define QW_TASK_DLOGL(param, ...) \
|
#define QW_TASK_DLOGL(param, ...) \
|
||||||
qDebugL("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId, __VA_ARGS__)
|
qDebugL("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId, __VA_ARGS__)
|
||||||
|
|
||||||
#define QW_TASK_ELOG_E(param) qError("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId)
|
#define QW_TASK_ELOG_E(param) qError("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId)
|
||||||
#define QW_TASK_WLOG_E(param) qWarn("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId)
|
#define QW_TASK_WLOG_E(param) qWarn("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId)
|
||||||
#define QW_TASK_DLOG_E(param) qDebug("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId)
|
#define QW_TASK_DLOG_E(param) qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId)
|
||||||
|
|
||||||
#define QW_SCH_TASK_ELOG(param, ...) \
|
#define QW_SCH_TASK_ELOG(param, ...) \
|
||||||
qError("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, sId, qId, tId, __VA_ARGS__)
|
qError("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, __VA_ARGS__)
|
||||||
#define QW_SCH_TASK_WLOG(param, ...) \
|
#define QW_SCH_TASK_WLOG(param, ...) \
|
||||||
qWarn("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, sId, qId, tId, __VA_ARGS__)
|
qWarn("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, __VA_ARGS__)
|
||||||
#define QW_SCH_TASK_DLOG(param, ...) \
|
#define QW_SCH_TASK_DLOG(param, ...) \
|
||||||
qDebug("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, sId, qId, tId, __VA_ARGS__)
|
qDebug("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, __VA_ARGS__)
|
||||||
|
|
||||||
#define QW_LOCK_DEBUG(...) \
|
#define QW_LOCK_DEBUG(...) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -362,6 +370,8 @@ void qwFreeTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx *ctx);
|
||||||
|
|
||||||
void qwDbgDumpMgmtInfo(SQWorker *mgmt);
|
void qwDbgDumpMgmtInfo(SQWorker *mgmt);
|
||||||
int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore);
|
int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore);
|
||||||
|
int32_t qwDbgBuildAndSendRedirectRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SEpSet *pEpSet);
|
||||||
|
int32_t qwAddTaskCtx(QW_FPARAMS_DEF);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -39,7 +39,7 @@ int32_t qwBuildAndSendFetchRsp(SRpcHandleInfo *pConn, SRetrieveTableRsp *pRsp, i
|
||||||
int32_t code);
|
int32_t code);
|
||||||
void qwBuildFetchRsp(void *msg, SOutputData *input, int32_t len, bool qComplete);
|
void qwBuildFetchRsp(void *msg, SOutputData *input, int32_t len, bool qComplete);
|
||||||
int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn);
|
int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn);
|
||||||
int32_t qwBuildAndSendQueryRsp(SRpcHandleInfo *pConn, int32_t code, STbVerInfo* tbInfo);
|
int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, STbVerInfo* tbInfo);
|
||||||
int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SExplainExecInfo *execInfo, int32_t num);
|
int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SExplainExecInfo *execInfo, int32_t num);
|
||||||
void qwFreeFetchRsp(void *msg);
|
void qwFreeFetchRsp(void *msg);
|
||||||
int32_t qwMallocFetchRsp(int32_t length, SRetrieveTableRsp **rsp);
|
int32_t qwMallocFetchRsp(int32_t length, SRetrieveTableRsp **rsp);
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
|
|
||||||
SQWDebug gQWDebug = {.statusEnable = true, .dumpEnable = false};
|
SQWDebug gQWDebug = {.statusEnable = true, .dumpEnable = false, .tmp = false};
|
||||||
|
|
||||||
int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore) {
|
int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore) {
|
||||||
if (!gQWDebug.statusEnable) {
|
if (!gQWDebug.statusEnable) {
|
||||||
|
@ -121,3 +121,90 @@ void qwDbgDumpMgmtInfo(SQWorker *mgmt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t qwDbgBuildAndSendRedirectRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SEpSet *pEpSet) {
|
||||||
|
int32_t contLen = 0;
|
||||||
|
char* rsp = NULL;
|
||||||
|
|
||||||
|
if (pEpSet) {
|
||||||
|
contLen = tSerializeSEpSet(NULL, 0, pEpSet);
|
||||||
|
rsp = rpcMallocCont(contLen);
|
||||||
|
tSerializeSEpSet(rsp, contLen, pEpSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
SRpcMsg rpcRsp = {
|
||||||
|
.msgType = rspType,
|
||||||
|
.pCont = rsp,
|
||||||
|
.contLen = contLen,
|
||||||
|
.code = code,
|
||||||
|
.info = *pConn,
|
||||||
|
};
|
||||||
|
rpcRsp.info.hasEpSet = 1;
|
||||||
|
|
||||||
|
tmsgSendRsp(&rpcRsp);
|
||||||
|
|
||||||
|
qDebug("response %s msg, code: %s", TMSG_INFO(rspType), tstrerror(code));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t qwDbgResponseREdirect(SQWMsg *qwMsg, SQWTaskCtx *ctx) {
|
||||||
|
if (gQWDebug.tmp) {
|
||||||
|
if (TDMT_SCH_QUERY == qwMsg->msgType) {
|
||||||
|
SEpSet epSet = {0};
|
||||||
|
epSet.inUse = 1;
|
||||||
|
epSet.numOfEps = 3;
|
||||||
|
strcpy(epSet.eps[0].fqdn, "localhost");
|
||||||
|
epSet.eps[0].port = 7100;
|
||||||
|
strcpy(epSet.eps[1].fqdn, "localhost");
|
||||||
|
epSet.eps[1].port = 7200;
|
||||||
|
strcpy(epSet.eps[2].fqdn, "localhost");
|
||||||
|
epSet.eps[2].port = 7300;
|
||||||
|
|
||||||
|
qwDbgBuildAndSendRedirectRsp(qwMsg->msgType + 1, &qwMsg->connInfo, TSDB_CODE_RPC_REDIRECT, &epSet);
|
||||||
|
gQWDebug.tmp = false;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TDMT_SCH_MERGE_QUERY == qwMsg->msgType) {
|
||||||
|
ctx->phase = QW_PHASE_POST_QUERY;
|
||||||
|
qwDbgBuildAndSendRedirectRsp(qwMsg->msgType + 1, &qwMsg->connInfo, TSDB_CODE_RPC_REDIRECT, NULL);
|
||||||
|
gQWDebug.tmp = false;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t qwDbgEnableDebug(char *option) {
|
||||||
|
if (0 == strcasecmp(option, "lock")) {
|
||||||
|
gQWDebug.lockEnable = true;
|
||||||
|
qDebug("qw lock debug enabled");
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 == strcasecmp(option, "status")) {
|
||||||
|
gQWDebug.statusEnable = true;
|
||||||
|
qDebug("qw status debug enabled");
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 == strcasecmp(option, "dump")) {
|
||||||
|
gQWDebug.dumpEnable = true;
|
||||||
|
qDebug("qw dump debug enabled");
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 == strcasecmp(option, "tmp")) {
|
||||||
|
gQWDebug.tmp = true;
|
||||||
|
qDebug("qw tmp debug enabled");
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
qError("invalid qw debug option:%s", option);
|
||||||
|
|
||||||
|
return TSDB_CODE_APP_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ void qwFreeFetchRsp(void *msg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwBuildAndSendQueryRsp(SRpcHandleInfo *pConn, int32_t code, STbVerInfo* tbInfo) {
|
int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, STbVerInfo* tbInfo) {
|
||||||
SQueryTableRsp *pRsp = (SQueryTableRsp *)rpcMallocCont(sizeof(SQueryTableRsp));
|
SQueryTableRsp *pRsp = (SQueryTableRsp *)rpcMallocCont(sizeof(SQueryTableRsp));
|
||||||
pRsp->code = code;
|
pRsp->code = code;
|
||||||
if (tbInfo) {
|
if (tbInfo) {
|
||||||
|
@ -53,7 +53,7 @@ int32_t qwBuildAndSendQueryRsp(SRpcHandleInfo *pConn, int32_t code, STbVerInfo*
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg rpcRsp = {
|
SRpcMsg rpcRsp = {
|
||||||
.msgType = TDMT_VND_QUERY_RSP,
|
.msgType = rspType,
|
||||||
.pCont = pRsp,
|
.pCont = pRsp,
|
||||||
.contLen = sizeof(*pRsp),
|
.contLen = sizeof(*pRsp),
|
||||||
.code = code,
|
.code = code,
|
||||||
|
@ -73,7 +73,7 @@ int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SExplainExecInfo *execIn
|
||||||
tSerializeSExplainRsp(pRsp, contLen, &rsp);
|
tSerializeSExplainRsp(pRsp, contLen, &rsp);
|
||||||
|
|
||||||
SRpcMsg rpcRsp = {
|
SRpcMsg rpcRsp = {
|
||||||
.msgType = TDMT_VND_EXPLAIN_RSP,
|
.msgType = TDMT_SCH_EXPLAIN_RSP,
|
||||||
.pCont = pRsp,
|
.pCont = pRsp,
|
||||||
.contLen = contLen,
|
.contLen = contLen,
|
||||||
.code = 0,
|
.code = 0,
|
||||||
|
@ -92,7 +92,7 @@ int32_t qwBuildAndSendHbRsp(SRpcHandleInfo *pConn, SSchedulerHbRsp *pStatus, int
|
||||||
tSerializeSSchedulerHbRsp(pRsp, contLen, pStatus);
|
tSerializeSSchedulerHbRsp(pRsp, contLen, pStatus);
|
||||||
|
|
||||||
SRpcMsg rpcRsp = {
|
SRpcMsg rpcRsp = {
|
||||||
.msgType = TDMT_VND_QUERY_HEARTBEAT_RSP,
|
.msgType = TDMT_SCH_QUERY_HEARTBEAT_RSP,
|
||||||
.contLen = contLen,
|
.contLen = contLen,
|
||||||
.pCont = pRsp,
|
.pCont = pRsp,
|
||||||
.code = code,
|
.code = code,
|
||||||
|
@ -112,7 +112,7 @@ int32_t qwBuildAndSendFetchRsp(SRpcHandleInfo *pConn, SRetrieveTableRsp *pRsp, i
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg rpcRsp = {
|
SRpcMsg rpcRsp = {
|
||||||
.msgType = TDMT_VND_FETCH_RSP,
|
.msgType = TDMT_SCH_FETCH_RSP,
|
||||||
.pCont = pRsp,
|
.pCont = pRsp,
|
||||||
.contLen = sizeof(*pRsp) + dataLength,
|
.contLen = sizeof(*pRsp) + dataLength,
|
||||||
.code = code,
|
.code = code,
|
||||||
|
@ -129,7 +129,7 @@ int32_t qwBuildAndSendCancelRsp(SRpcHandleInfo *pConn, int32_t code) {
|
||||||
pRsp->code = code;
|
pRsp->code = code;
|
||||||
|
|
||||||
SRpcMsg rpcRsp = {
|
SRpcMsg rpcRsp = {
|
||||||
.msgType = TDMT_VND_CANCEL_TASK_RSP,
|
.msgType = TDMT_SCH_CANCEL_TASK_RSP,
|
||||||
.pCont = pRsp,
|
.pCont = pRsp,
|
||||||
.contLen = sizeof(*pRsp),
|
.contLen = sizeof(*pRsp),
|
||||||
.code = code,
|
.code = code,
|
||||||
|
@ -145,7 +145,7 @@ int32_t qwBuildAndSendDropRsp(SRpcHandleInfo *pConn, int32_t code) {
|
||||||
pRsp->code = code;
|
pRsp->code = code;
|
||||||
|
|
||||||
SRpcMsg rpcRsp = {
|
SRpcMsg rpcRsp = {
|
||||||
.msgType = TDMT_VND_DROP_TASK_RSP,
|
.msgType = TDMT_SCH_DROP_TASK_RSP,
|
||||||
.pCont = pRsp,
|
.pCont = pRsp,
|
||||||
.contLen = sizeof(*pRsp),
|
.contLen = sizeof(*pRsp),
|
||||||
.code = code,
|
.code = code,
|
||||||
|
@ -156,6 +156,41 @@ int32_t qwBuildAndSendDropRsp(SRpcHandleInfo *pConn, int32_t code) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t qwBuildAndSendDropMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) {
|
||||||
|
STaskDropReq *req = (STaskDropReq *)rpcMallocCont(sizeof(STaskDropReq));
|
||||||
|
if (NULL == req) {
|
||||||
|
QW_SCH_TASK_ELOG("rpcMallocCont %d failed", (int32_t)sizeof(STaskDropReq));
|
||||||
|
QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
req->header.vgId = mgmt->nodeId;
|
||||||
|
req->sId = sId;
|
||||||
|
req->queryId = qId;
|
||||||
|
req->taskId = tId;
|
||||||
|
req->refId = rId;
|
||||||
|
req->execId = eId;
|
||||||
|
|
||||||
|
SRpcMsg pNewMsg = {
|
||||||
|
.msgType = TDMT_SCH_DROP_TASK,
|
||||||
|
.pCont = req,
|
||||||
|
.contLen = sizeof(STaskDropReq),
|
||||||
|
.code = 0,
|
||||||
|
.info = *pConn,
|
||||||
|
};
|
||||||
|
|
||||||
|
int32_t code = tmsgPutToQueue(&mgmt->msgCb, FETCH_QUEUE, &pNewMsg);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
QW_SCH_TASK_ELOG("put drop task msg to queue failed, vgId:%d, code:%s", mgmt->nodeId, tstrerror(code));
|
||||||
|
rpcFreeCont(req);
|
||||||
|
QW_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
QW_SCH_TASK_DLOG("drop task msg put to queue, vgId:%d", mgmt->nodeId);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) {
|
int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) {
|
||||||
SQueryContinueReq *req = (SQueryContinueReq *)rpcMallocCont(sizeof(SQueryContinueReq));
|
SQueryContinueReq *req = (SQueryContinueReq *)rpcMallocCont(sizeof(SQueryContinueReq));
|
||||||
if (NULL == req) {
|
if (NULL == req) {
|
||||||
|
@ -167,9 +202,10 @@ int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) {
|
||||||
req->sId = sId;
|
req->sId = sId;
|
||||||
req->queryId = qId;
|
req->queryId = qId;
|
||||||
req->taskId = tId;
|
req->taskId = tId;
|
||||||
|
req->execId = eId;
|
||||||
|
|
||||||
SRpcMsg pNewMsg = {
|
SRpcMsg pNewMsg = {
|
||||||
.msgType = TDMT_VND_QUERY_CONTINUE,
|
.msgType = TDMT_SCH_QUERY_CONTINUE,
|
||||||
.pCont = req,
|
.pCont = req,
|
||||||
.contLen = sizeof(SQueryContinueReq),
|
.contLen = sizeof(SQueryContinueReq),
|
||||||
.code = 0,
|
.code = 0,
|
||||||
|
@ -202,10 +238,10 @@ int32_t qwRegisterQueryBrokenLinkArg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) {
|
||||||
req->refId = htobe64(rId);
|
req->refId = htobe64(rId);
|
||||||
|
|
||||||
SRpcMsg brokenMsg = {
|
SRpcMsg brokenMsg = {
|
||||||
.msgType = TDMT_VND_DROP_TASK,
|
.msgType = TDMT_SCH_DROP_TASK,
|
||||||
.pCont = req,
|
.pCont = req,
|
||||||
.contLen = sizeof(STaskDropReq),
|
.contLen = sizeof(STaskDropReq),
|
||||||
.code = TSDB_CODE_RPC_NETWORK_UNAVAIL,
|
.code = TSDB_CODE_RPC_BROKEN_LINK,
|
||||||
.info = *pConn,
|
.info = *pConn,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -236,10 +272,10 @@ int32_t qwRegisterHbBrokenLinkArg(SQWorker *mgmt, uint64_t sId, SRpcHandleInfo *
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg brokenMsg = {
|
SRpcMsg brokenMsg = {
|
||||||
.msgType = TDMT_VND_QUERY_HEARTBEAT,
|
.msgType = TDMT_SCH_QUERY_HEARTBEAT,
|
||||||
.pCont = msg,
|
.pCont = msg,
|
||||||
.contLen = msgSize,
|
.contLen = msgSize,
|
||||||
.code = TSDB_CODE_RPC_NETWORK_UNAVAIL,
|
.code = TSDB_CODE_RPC_BROKEN_LINK,
|
||||||
.info = *pConn,
|
.info = *pConn,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -266,6 +302,7 @@ int32_t qWorkerPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg) {
|
||||||
msg->queryId = be64toh(msg->queryId);
|
msg->queryId = be64toh(msg->queryId);
|
||||||
msg->taskId = be64toh(msg->taskId);
|
msg->taskId = be64toh(msg->taskId);
|
||||||
msg->refId = be64toh(msg->refId);
|
msg->refId = be64toh(msg->refId);
|
||||||
|
msg->execId = ntohl(msg->execId);
|
||||||
msg->phyLen = ntohl(msg->phyLen);
|
msg->phyLen = ntohl(msg->phyLen);
|
||||||
msg->sqlLen = ntohl(msg->sqlLen);
|
msg->sqlLen = ntohl(msg->sqlLen);
|
||||||
|
|
||||||
|
@ -273,6 +310,7 @@ int32_t qWorkerPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg) {
|
||||||
uint64_t qId = msg->queryId;
|
uint64_t qId = msg->queryId;
|
||||||
uint64_t tId = msg->taskId;
|
uint64_t tId = msg->taskId;
|
||||||
int64_t rId = msg->refId;
|
int64_t rId = msg->refId;
|
||||||
|
int32_t eId = msg->execId;
|
||||||
|
|
||||||
SQWMsg qwMsg = {.msg = msg->msg + msg->sqlLen, .msgLen = msg->phyLen, .connInfo = pMsg->info};
|
SQWMsg qwMsg = {.msg = msg->msg + msg->sqlLen, .msgLen = msg->phyLen, .connInfo = pMsg->info};
|
||||||
|
|
||||||
|
@ -295,6 +333,7 @@ int32_t qWorkerAbortPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg) {
|
||||||
uint64_t qId = msg->queryId;
|
uint64_t qId = msg->queryId;
|
||||||
uint64_t tId = msg->taskId;
|
uint64_t tId = msg->taskId;
|
||||||
int64_t rId = msg->refId;
|
int64_t rId = msg->refId;
|
||||||
|
int32_t eId = msg->execId;
|
||||||
|
|
||||||
QW_SCH_TASK_DLOG("Abort prerocessQuery start, handle:%p", pMsg->info.handle);
|
QW_SCH_TASK_DLOG("Abort prerocessQuery start, handle:%p", pMsg->info.handle);
|
||||||
qwAbortPrerocessQuery(QW_FPARAMS());
|
qwAbortPrerocessQuery(QW_FPARAMS());
|
||||||
|
@ -324,10 +363,11 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int
|
||||||
uint64_t qId = msg->queryId;
|
uint64_t qId = msg->queryId;
|
||||||
uint64_t tId = msg->taskId;
|
uint64_t tId = msg->taskId;
|
||||||
int64_t rId = msg->refId;
|
int64_t rId = msg->refId;
|
||||||
|
int32_t eId = msg->execId;
|
||||||
|
|
||||||
SQWMsg qwMsg = {.node = node, .msg = msg->msg + msg->sqlLen, .msgLen = msg->phyLen, .connInfo = pMsg->info};
|
SQWMsg qwMsg = {.node = node, .msg = msg->msg + msg->sqlLen, .msgLen = msg->phyLen, .connInfo = pMsg->info, .msgType = pMsg->msgType};
|
||||||
char * sql = strndup(msg->msg, msg->sqlLen);
|
char * sql = strndup(msg->msg, msg->sqlLen);
|
||||||
QW_SCH_TASK_DLOG("processQuery start, node:%p, handle:%p, sql:%s", node, pMsg->info.handle, sql);
|
QW_SCH_TASK_DLOG("processQuery start, node:%p, type:%s, handle:%p, sql:%s", node, TMSG_INFO(pMsg->msgType), pMsg->info.handle, sql);
|
||||||
|
|
||||||
QW_ERR_RET(qwProcessQuery(QW_FPARAMS(), &qwMsg, msg->taskType, msg->explain, sql));
|
QW_ERR_RET(qwProcessQuery(QW_FPARAMS(), &qwMsg, msg->taskType, msg->explain, sql));
|
||||||
QW_SCH_TASK_DLOG("processQuery end, node:%p", node);
|
QW_SCH_TASK_DLOG("processQuery end, node:%p", node);
|
||||||
|
@ -356,6 +396,7 @@ int32_t qWorkerProcessCQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, in
|
||||||
uint64_t qId = msg->queryId;
|
uint64_t qId = msg->queryId;
|
||||||
uint64_t tId = msg->taskId;
|
uint64_t tId = msg->taskId;
|
||||||
int64_t rId = 0;
|
int64_t rId = 0;
|
||||||
|
int32_t eId = msg->execId;
|
||||||
|
|
||||||
SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .connInfo = pMsg->info};
|
SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .connInfo = pMsg->info};
|
||||||
|
|
||||||
|
@ -387,11 +428,13 @@ int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int
|
||||||
msg->sId = be64toh(msg->sId);
|
msg->sId = be64toh(msg->sId);
|
||||||
msg->queryId = be64toh(msg->queryId);
|
msg->queryId = be64toh(msg->queryId);
|
||||||
msg->taskId = be64toh(msg->taskId);
|
msg->taskId = be64toh(msg->taskId);
|
||||||
|
msg->execId = ntohl(msg->execId);
|
||||||
|
|
||||||
uint64_t sId = msg->sId;
|
uint64_t sId = msg->sId;
|
||||||
uint64_t qId = msg->queryId;
|
uint64_t qId = msg->queryId;
|
||||||
uint64_t tId = msg->taskId;
|
uint64_t tId = msg->taskId;
|
||||||
int64_t rId = 0;
|
int64_t rId = 0;
|
||||||
|
int32_t eId = msg->execId;
|
||||||
|
|
||||||
SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .connInfo = pMsg->info};
|
SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .connInfo = pMsg->info};
|
||||||
|
|
||||||
|
@ -437,11 +480,13 @@ int32_t qWorkerProcessCancelMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, in
|
||||||
msg->queryId = be64toh(msg->queryId);
|
msg->queryId = be64toh(msg->queryId);
|
||||||
msg->taskId = be64toh(msg->taskId);
|
msg->taskId = be64toh(msg->taskId);
|
||||||
msg->refId = be64toh(msg->refId);
|
msg->refId = be64toh(msg->refId);
|
||||||
|
msg->execId = ntohl(msg->execId);
|
||||||
|
|
||||||
uint64_t sId = msg->sId;
|
uint64_t sId = msg->sId;
|
||||||
uint64_t qId = msg->queryId;
|
uint64_t qId = msg->queryId;
|
||||||
uint64_t tId = msg->taskId;
|
uint64_t tId = msg->taskId;
|
||||||
int64_t rId = msg->refId;
|
int64_t rId = msg->refId;
|
||||||
|
int32_t eId = msg->execId;
|
||||||
|
|
||||||
SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .connInfo = pMsg->info};
|
SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .connInfo = pMsg->info};
|
||||||
|
|
||||||
|
@ -476,15 +521,17 @@ int32_t qWorkerProcessDropMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int6
|
||||||
msg->queryId = be64toh(msg->queryId);
|
msg->queryId = be64toh(msg->queryId);
|
||||||
msg->taskId = be64toh(msg->taskId);
|
msg->taskId = be64toh(msg->taskId);
|
||||||
msg->refId = be64toh(msg->refId);
|
msg->refId = be64toh(msg->refId);
|
||||||
|
msg->execId = ntohl(msg->execId);
|
||||||
|
|
||||||
uint64_t sId = msg->sId;
|
uint64_t sId = msg->sId;
|
||||||
uint64_t qId = msg->queryId;
|
uint64_t qId = msg->queryId;
|
||||||
uint64_t tId = msg->taskId;
|
uint64_t tId = msg->taskId;
|
||||||
int64_t rId = msg->refId;
|
int64_t rId = msg->refId;
|
||||||
|
int32_t eId = msg->execId;
|
||||||
|
|
||||||
SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .code = pMsg->code, .connInfo = pMsg->info};
|
SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .code = pMsg->code, .connInfo = pMsg->info};
|
||||||
|
|
||||||
if (TSDB_CODE_RPC_NETWORK_UNAVAIL == pMsg->code) {
|
if (TSDB_CODE_RPC_BROKEN_LINK == pMsg->code) {
|
||||||
QW_SCH_TASK_DLOG("receive drop task due to network broken, error:%s", tstrerror(pMsg->code));
|
QW_SCH_TASK_DLOG("receive drop task due to network broken, error:%s", tstrerror(pMsg->code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,7 +569,7 @@ int32_t qWorkerProcessHbMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_
|
||||||
|
|
||||||
uint64_t sId = req.sId;
|
uint64_t sId = req.sId;
|
||||||
SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .code = pMsg->code, .connInfo = pMsg->info};
|
SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .code = pMsg->code, .connInfo = pMsg->info};
|
||||||
if (TSDB_CODE_RPC_NETWORK_UNAVAIL == pMsg->code) {
|
if (TSDB_CODE_RPC_BROKEN_LINK == pMsg->code) {
|
||||||
QW_SCH_DLOG("receive Hb msg due to network broken, error:%s", tstrerror(pMsg->code));
|
QW_SCH_DLOG("receive Hb msg due to network broken, error:%s", tstrerror(pMsg->code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,6 +600,7 @@ int32_t qWorkerProcessDeleteMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, SR
|
||||||
uint64_t qId = req.queryId;
|
uint64_t qId = req.queryId;
|
||||||
uint64_t tId = req.taskId;
|
uint64_t tId = req.taskId;
|
||||||
int64_t rId = 0;
|
int64_t rId = 0;
|
||||||
|
int32_t eId = -1;
|
||||||
|
|
||||||
SQWMsg qwMsg = {.node = node, .msg = req.msg, .msgLen = req.phyLen, .connInfo = pMsg->info};
|
SQWMsg qwMsg = {.node = node, .msg = req.msg, .msgLen = req.phyLen, .connInfo = pMsg->info};
|
||||||
QW_SCH_TASK_DLOG("processDelete start, node:%p, handle:%p, sql:%s", node, pMsg->info.handle, req.sql);
|
QW_SCH_TASK_DLOG("processDelete start, node:%p, handle:%p, sql:%s", node, pMsg->info.handle, req.sql);
|
||||||
|
|
|
@ -135,8 +135,8 @@ int32_t qwAcquireScheduler(SQWorker *mgmt, uint64_t sId, int32_t rwType, SQWSchS
|
||||||
void qwReleaseScheduler(int32_t rwType, SQWorker *mgmt) { QW_UNLOCK(rwType, &mgmt->schLock); }
|
void qwReleaseScheduler(int32_t rwType, SQWorker *mgmt) { QW_UNLOCK(rwType, &mgmt->schLock); }
|
||||||
|
|
||||||
int32_t qwAcquireTaskStatus(QW_FPARAMS_DEF, int32_t rwType, SQWSchStatus *sch, SQWTaskStatus **task) {
|
int32_t qwAcquireTaskStatus(QW_FPARAMS_DEF, int32_t rwType, SQWSchStatus *sch, SQWTaskStatus **task) {
|
||||||
char id[sizeof(qId) + sizeof(tId)] = {0};
|
char id[sizeof(qId) + sizeof(tId) + sizeof(eId)] = {0};
|
||||||
QW_SET_QTID(id, qId, tId);
|
QW_SET_QTID(id, qId, tId, eId);
|
||||||
|
|
||||||
QW_LOCK(rwType, &sch->tasksLock);
|
QW_LOCK(rwType, &sch->tasksLock);
|
||||||
*task = taosHashGet(sch->tasksHash, id, sizeof(id));
|
*task = taosHashGet(sch->tasksHash, id, sizeof(id));
|
||||||
|
@ -151,8 +151,8 @@ int32_t qwAcquireTaskStatus(QW_FPARAMS_DEF, int32_t rwType, SQWSchStatus *sch, S
|
||||||
int32_t qwAddTaskStatusImpl(QW_FPARAMS_DEF, SQWSchStatus *sch, int32_t rwType, int32_t status, SQWTaskStatus **task) {
|
int32_t qwAddTaskStatusImpl(QW_FPARAMS_DEF, SQWSchStatus *sch, int32_t rwType, int32_t status, SQWTaskStatus **task) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
char id[sizeof(qId) + sizeof(tId)] = {0};
|
char id[sizeof(qId) + sizeof(tId) + sizeof(eId)] = {0};
|
||||||
QW_SET_QTID(id, qId, tId);
|
QW_SET_QTID(id, qId, tId, eId);
|
||||||
|
|
||||||
SQWTaskStatus ntask = {0};
|
SQWTaskStatus ntask = {0};
|
||||||
ntask.status = status;
|
ntask.status = status;
|
||||||
|
@ -207,8 +207,8 @@ int32_t qwAddAcquireTaskStatus(QW_FPARAMS_DEF, int32_t rwType, SQWSchStatus *sch
|
||||||
void qwReleaseTaskStatus(int32_t rwType, SQWSchStatus *sch) { QW_UNLOCK(rwType, &sch->tasksLock); }
|
void qwReleaseTaskStatus(int32_t rwType, SQWSchStatus *sch) { QW_UNLOCK(rwType, &sch->tasksLock); }
|
||||||
|
|
||||||
int32_t qwAcquireTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx) {
|
int32_t qwAcquireTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx) {
|
||||||
char id[sizeof(qId) + sizeof(tId)] = {0};
|
char id[sizeof(qId) + sizeof(tId) + sizeof(eId)] = {0};
|
||||||
QW_SET_QTID(id, qId, tId);
|
QW_SET_QTID(id, qId, tId, eId);
|
||||||
|
|
||||||
*ctx = taosHashAcquire(mgmt->ctxHash, id, sizeof(id));
|
*ctx = taosHashAcquire(mgmt->ctxHash, id, sizeof(id));
|
||||||
if (NULL == (*ctx)) {
|
if (NULL == (*ctx)) {
|
||||||
|
@ -220,8 +220,8 @@ int32_t qwAcquireTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwGetTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx) {
|
int32_t qwGetTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx) {
|
||||||
char id[sizeof(qId) + sizeof(tId)] = {0};
|
char id[sizeof(qId) + sizeof(tId) + sizeof(eId)] = {0};
|
||||||
QW_SET_QTID(id, qId, tId);
|
QW_SET_QTID(id, qId, tId, eId);
|
||||||
|
|
||||||
*ctx = taosHashGet(mgmt->ctxHash, id, sizeof(id));
|
*ctx = taosHashGet(mgmt->ctxHash, id, sizeof(id));
|
||||||
if (NULL == (*ctx)) {
|
if (NULL == (*ctx)) {
|
||||||
|
@ -233,8 +233,8 @@ int32_t qwGetTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwAddTaskCtxImpl(QW_FPARAMS_DEF, bool acquire, SQWTaskCtx **ctx) {
|
int32_t qwAddTaskCtxImpl(QW_FPARAMS_DEF, bool acquire, SQWTaskCtx **ctx) {
|
||||||
char id[sizeof(qId) + sizeof(tId)] = {0};
|
char id[sizeof(qId) + sizeof(tId) + sizeof(eId)] = {0};
|
||||||
QW_SET_QTID(id, qId, tId);
|
QW_SET_QTID(id, qId, tId, eId);
|
||||||
|
|
||||||
SQWTaskCtx nctx = {0};
|
SQWTaskCtx nctx = {0};
|
||||||
|
|
||||||
|
@ -314,8 +314,8 @@ void qwFreeTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwDropTaskCtx(QW_FPARAMS_DEF) {
|
int32_t qwDropTaskCtx(QW_FPARAMS_DEF) {
|
||||||
char id[sizeof(qId) + sizeof(tId)] = {0};
|
char id[sizeof(qId) + sizeof(tId) + sizeof(eId)] = {0};
|
||||||
QW_SET_QTID(id, qId, tId);
|
QW_SET_QTID(id, qId, tId, eId);
|
||||||
SQWTaskCtx octx;
|
SQWTaskCtx octx;
|
||||||
|
|
||||||
SQWTaskCtx *ctx = taosHashGet(mgmt->ctxHash, id, sizeof(id));
|
SQWTaskCtx *ctx = taosHashGet(mgmt->ctxHash, id, sizeof(id));
|
||||||
|
@ -348,8 +348,8 @@ int32_t qwDropTaskStatus(QW_FPARAMS_DEF) {
|
||||||
SQWTaskStatus *task = NULL;
|
SQWTaskStatus *task = NULL;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
char id[sizeof(qId) + sizeof(tId)] = {0};
|
char id[sizeof(qId) + sizeof(tId) + sizeof(eId)] = {0};
|
||||||
QW_SET_QTID(id, qId, tId);
|
QW_SET_QTID(id, qId, tId, eId);
|
||||||
|
|
||||||
if (qwAcquireScheduler(mgmt, sId, QW_WRITE, &sch)) {
|
if (qwAcquireScheduler(mgmt, sId, QW_WRITE, &sch)) {
|
||||||
QW_TASK_WLOG_E("scheduler does not exist");
|
QW_TASK_WLOG_E("scheduler does not exist");
|
||||||
|
|
|
@ -168,7 +168,7 @@ int32_t qwGenerateSchHbRsp(SQWorker *mgmt, SQWSchStatus *sch, SQWHbInfo *hbInfo)
|
||||||
|
|
||||||
// TODO GET EXECUTOR API TO GET MORE INFO
|
// TODO GET EXECUTOR API TO GET MORE INFO
|
||||||
|
|
||||||
QW_GET_QTID(key, status.queryId, status.taskId);
|
QW_GET_QTID(key, status.queryId, status.taskId, status.execId);
|
||||||
status.status = taskStatus->status;
|
status.status = taskStatus->status;
|
||||||
status.refId = taskStatus->refId;
|
status.refId = taskStatus->refId;
|
||||||
|
|
||||||
|
@ -417,17 +417,10 @@ int32_t qwHandlePostPhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inp
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QW_PHASE_POST_QUERY == phase) {
|
if (QW_PHASE_POST_QUERY == phase) {
|
||||||
#if 0
|
|
||||||
if (QW_IS_EVENT_RECEIVED(ctx, QW_EVENT_READY)) {
|
|
||||||
readyConnection = &ctx->connInfo;
|
|
||||||
QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_READY);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
connInfo = ctx->ctrlConnInfo;
|
connInfo = ctx->ctrlConnInfo;
|
||||||
rspConnection = &connInfo;
|
rspConnection = &connInfo;
|
||||||
|
|
||||||
QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_READY);
|
QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_READY);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QW_IS_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) {
|
if (QW_IS_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) {
|
||||||
|
@ -458,8 +451,8 @@ _return:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rspConnection) {
|
if (rspConnection) {
|
||||||
qwBuildAndSendQueryRsp(rspConnection, code, ctx ? &ctx->tbInfo : NULL);
|
qwBuildAndSendQueryRsp(input->msgType + 1, rspConnection, code, ctx ? &ctx->tbInfo : NULL);
|
||||||
QW_TASK_DLOG("ready msg rsped, handle:%p, code:%x - %s", rspConnection->handle, code, tstrerror(code));
|
QW_TASK_DLOG("query msg rsped, handle:%p, code:%x - %s", rspConnection->handle, code, tstrerror(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
|
@ -500,7 +493,9 @@ int32_t qwPrerocessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
||||||
|
|
||||||
QW_ERR_JRET(qwRegisterQueryBrokenLinkArg(QW_FPARAMS(), &qwMsg->connInfo));
|
QW_ERR_JRET(qwRegisterQueryBrokenLinkArg(QW_FPARAMS(), &qwMsg->connInfo));
|
||||||
|
|
||||||
QW_ERR_JRET(qwAddAcquireTaskCtx(QW_FPARAMS(), &ctx));
|
QW_ERR_JRET(qwAddTaskCtx(QW_FPARAMS()));
|
||||||
|
|
||||||
|
QW_ERR_JRET(qwAcquireTaskCtx(QW_FPARAMS(), &ctx));
|
||||||
|
|
||||||
ctx->ctrlConnInfo = qwMsg->connInfo;
|
ctx->ctrlConnInfo = qwMsg->connInfo;
|
||||||
|
|
||||||
|
@ -530,8 +525,9 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType, int8_t ex
|
||||||
|
|
||||||
QW_ERR_JRET(qwGetTaskCtx(QW_FPARAMS(), &ctx));
|
QW_ERR_JRET(qwGetTaskCtx(QW_FPARAMS(), &ctx));
|
||||||
|
|
||||||
atomic_store_8(&ctx->taskType, taskType);
|
ctx->taskType = taskType;
|
||||||
atomic_store_8(&ctx->explain, explain);
|
ctx->explain = explain;
|
||||||
|
ctx->queryType = qwMsg->msgType;
|
||||||
|
|
||||||
QW_TASK_DLOGL("subplan json string, len:%d, %s", qwMsg->msgLen, qwMsg->msg);
|
QW_TASK_DLOGL("subplan json string, len:%d, %s", qwMsg->msgLen, qwMsg->msg);
|
||||||
|
|
||||||
|
@ -571,6 +567,7 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType, int8_t ex
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
input.code = code;
|
input.code = code;
|
||||||
|
input.msgType = qwMsg->msgType;
|
||||||
code = qwHandlePostPhaseEvents(QW_FPARAMS(), QW_PHASE_POST_QUERY, &input, NULL);
|
code = qwHandlePostPhaseEvents(QW_FPARAMS(), QW_PHASE_POST_QUERY, &input, NULL);
|
||||||
|
|
||||||
// if (!queryRsped) {
|
// if (!queryRsped) {
|
||||||
|
@ -739,8 +736,6 @@ int32_t qwProcessDrop(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
||||||
SQWTaskCtx *ctx = NULL;
|
SQWTaskCtx *ctx = NULL;
|
||||||
bool locked = false;
|
bool locked = false;
|
||||||
|
|
||||||
// TODO : TASK ALREADY REMOVED AND A NEW DROP MSG RECEIVED
|
|
||||||
|
|
||||||
QW_ERR_JRET(qwAcquireTaskCtx(QW_FPARAMS(), &ctx));
|
QW_ERR_JRET(qwAcquireTaskCtx(QW_FPARAMS(), &ctx));
|
||||||
|
|
||||||
QW_LOCK(QW_WRITE, &ctx->lock);
|
QW_LOCK(QW_WRITE, &ctx->lock);
|
||||||
|
|
|
@ -122,7 +122,7 @@ void qwtBuildQueryReqMsg(SRpcMsg *queryRpc) {
|
||||||
qwtqueryMsg.taskId = htobe64(1);
|
qwtqueryMsg.taskId = htobe64(1);
|
||||||
qwtqueryMsg.phyLen = htonl(100);
|
qwtqueryMsg.phyLen = htonl(100);
|
||||||
qwtqueryMsg.sqlLen = 0;
|
qwtqueryMsg.sqlLen = 0;
|
||||||
queryRpc->msgType = TDMT_VND_QUERY;
|
queryRpc->msgType = TDMT_SCH_QUERY;
|
||||||
queryRpc->pCont = &qwtqueryMsg;
|
queryRpc->pCont = &qwtqueryMsg;
|
||||||
queryRpc->contLen = sizeof(SSubQueryMsg) + 100;
|
queryRpc->contLen = sizeof(SSubQueryMsg) + 100;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ void qwtBuildFetchReqMsg(SResFetchReq *fetchMsg, SRpcMsg *fetchRpc) {
|
||||||
fetchMsg->sId = htobe64(1);
|
fetchMsg->sId = htobe64(1);
|
||||||
fetchMsg->queryId = htobe64(atomic_load_64(&qwtTestQueryId));
|
fetchMsg->queryId = htobe64(atomic_load_64(&qwtTestQueryId));
|
||||||
fetchMsg->taskId = htobe64(1);
|
fetchMsg->taskId = htobe64(1);
|
||||||
fetchRpc->msgType = TDMT_VND_FETCH;
|
fetchRpc->msgType = TDMT_SCH_FETCH;
|
||||||
fetchRpc->pCont = fetchMsg;
|
fetchRpc->pCont = fetchMsg;
|
||||||
fetchRpc->contLen = sizeof(SResFetchReq);
|
fetchRpc->contLen = sizeof(SResFetchReq);
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ void qwtBuildDropReqMsg(STaskDropReq *dropMsg, SRpcMsg *dropRpc) {
|
||||||
dropMsg->sId = htobe64(1);
|
dropMsg->sId = htobe64(1);
|
||||||
dropMsg->queryId = htobe64(atomic_load_64(&qwtTestQueryId));
|
dropMsg->queryId = htobe64(atomic_load_64(&qwtTestQueryId));
|
||||||
dropMsg->taskId = htobe64(1);
|
dropMsg->taskId = htobe64(1);
|
||||||
dropRpc->msgType = TDMT_VND_DROP_TASK;
|
dropRpc->msgType = TDMT_SCH_DROP_TASK;
|
||||||
dropRpc->pCont = dropMsg;
|
dropRpc->pCont = dropMsg;
|
||||||
dropRpc->contLen = sizeof(STaskDropReq);
|
dropRpc->contLen = sizeof(STaskDropReq);
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,8 @@ void qwtSendReqToDnode(void* pVnode, struct SEpSet* epSet, struct SRpcMsg* pReq)
|
||||||
void qwtRpcSendResponse(const SRpcMsg *pRsp) {
|
void qwtRpcSendResponse(const SRpcMsg *pRsp) {
|
||||||
|
|
||||||
switch (pRsp->msgType) {
|
switch (pRsp->msgType) {
|
||||||
case TDMT_VND_QUERY_RSP: {
|
case TDMT_SCH_QUERY_RSP:
|
||||||
|
case TDMT_SCH_MERGE_QUERY_RSP: {
|
||||||
SQueryTableRsp *rsp = (SQueryTableRsp *)pRsp->pCont;
|
SQueryTableRsp *rsp = (SQueryTableRsp *)pRsp->pCont;
|
||||||
|
|
||||||
if (pRsp->code) {
|
if (pRsp->code) {
|
||||||
|
@ -213,7 +214,7 @@ void qwtRpcSendResponse(const SRpcMsg *pRsp) {
|
||||||
rpcFreeCont(rsp);
|
rpcFreeCont(rsp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_VND_FETCH_RSP: {
|
case TDMT_SCH_FETCH_RSP: {
|
||||||
SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)pRsp->pCont;
|
SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)pRsp->pCont;
|
||||||
|
|
||||||
if (0 == pRsp->code && 0 == rsp->completed) {
|
if (0 == pRsp->code && 0 == rsp->completed) {
|
||||||
|
@ -229,7 +230,7 @@ void qwtRpcSendResponse(const SRpcMsg *pRsp) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_VND_DROP_TASK_RSP: {
|
case TDMT_SCH_DROP_TASK_RSP: {
|
||||||
STaskDropRsp *rsp = (STaskDropRsp *)pRsp->pCont;
|
STaskDropRsp *rsp = (STaskDropRsp *)pRsp->pCont;
|
||||||
rpcFreeCont(rsp);
|
rpcFreeCont(rsp);
|
||||||
|
|
||||||
|
@ -756,9 +757,9 @@ void *queryQueueThread(void *param) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TDMT_VND_QUERY == queryRpc->msgType) {
|
if (TDMT_SCH_QUERY == queryRpc->msgType) {
|
||||||
qWorkerProcessQueryMsg(mockPointer, mgmt, queryRpc, 0);
|
qWorkerProcessQueryMsg(mockPointer, mgmt, queryRpc, 0);
|
||||||
} else if (TDMT_VND_QUERY_CONTINUE == queryRpc->msgType) {
|
} else if (TDMT_SCH_QUERY_CONTINUE == queryRpc->msgType) {
|
||||||
qWorkerProcessCQueryMsg(mockPointer, mgmt, queryRpc, 0);
|
qWorkerProcessCQueryMsg(mockPointer, mgmt, queryRpc, 0);
|
||||||
} else {
|
} else {
|
||||||
printf("unknown msg in query queue, type:%d\n", queryRpc->msgType);
|
printf("unknown msg in query queue, type:%d\n", queryRpc->msgType);
|
||||||
|
@ -813,13 +814,13 @@ void *fetchQueueThread(void *param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (fetchRpc->msgType) {
|
switch (fetchRpc->msgType) {
|
||||||
case TDMT_VND_FETCH:
|
case TDMT_SCH_FETCH:
|
||||||
qWorkerProcessFetchMsg(mockPointer, mgmt, fetchRpc, 0);
|
qWorkerProcessFetchMsg(mockPointer, mgmt, fetchRpc, 0);
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_CANCEL_TASK:
|
case TDMT_SCH_CANCEL_TASK:
|
||||||
qWorkerProcessCancelMsg(mockPointer, mgmt, fetchRpc, 0);
|
qWorkerProcessCancelMsg(mockPointer, mgmt, fetchRpc, 0);
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_DROP_TASK:
|
case TDMT_SCH_DROP_TASK:
|
||||||
qWorkerProcessDropMsg(mockPointer, mgmt, fetchRpc, 0);
|
qWorkerProcessDropMsg(mockPointer, mgmt, fetchRpc, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -2059,7 +2059,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colIdxi > 1) {
|
if (colIdxi > 1) {
|
||||||
qsort(colIdx, colIdxi, sizeof(uint32_t), getComparFunc(TSDB_DATA_TYPE_USMALLINT, 0));
|
taosSort(colIdx, colIdxi, sizeof(uint32_t), getComparFunc(TSDB_DATA_TYPE_USMALLINT, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t l = 0; l < colIdxi; ++l) {
|
for (uint32_t l = 0; l < colIdxi; ++l) {
|
||||||
|
@ -2294,7 +2294,7 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t *gR
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
qsort(gRes, *gResNum, POINTER_BYTES, filterCompareGroupCtx);
|
taosSort(gRes, *gResNum, POINTER_BYTES, filterCompareGroupCtx);
|
||||||
|
|
||||||
int32_t pEnd = 0, cStart = 0, cEnd = 0;
|
int32_t pEnd = 0, cStart = 0, cEnd = 0;
|
||||||
uint32_t pColNum = 0, cColNum = 0;
|
uint32_t pColNum = 0, cColNum = 0;
|
||||||
|
|
|
@ -287,7 +287,7 @@ int32_t sclInitParamList(SScalarParam **pParams, SNodeList* pParamList, SScalarC
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
if (NULL == pParamList) {
|
if (NULL == pParamList) {
|
||||||
if (ctx->pBlockList) {
|
if (ctx->pBlockList) {
|
||||||
SSDataBlock *pBlock = taosArrayGet(ctx->pBlockList, 0);
|
SSDataBlock *pBlock = taosArrayGetP(ctx->pBlockList, 0);
|
||||||
*rowNum = pBlock->info.rows;
|
*rowNum = pBlock->info.rows;
|
||||||
} else {
|
} else {
|
||||||
*rowNum = 1;
|
*rowNum = 1;
|
||||||
|
|
|
@ -125,7 +125,7 @@ typedef struct SSchTaskCallbackParam {
|
||||||
uint64_t queryId;
|
uint64_t queryId;
|
||||||
int64_t refId;
|
int64_t refId;
|
||||||
uint64_t taskId;
|
uint64_t taskId;
|
||||||
int32_t execIdx;
|
int32_t execId;
|
||||||
void *pTrans;
|
void *pTrans;
|
||||||
} SSchTaskCallbackParam;
|
} SSchTaskCallbackParam;
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ typedef struct SSchTask {
|
||||||
uint64_t taskId; // task id
|
uint64_t taskId; // task id
|
||||||
SRWLatch lock; // task lock
|
SRWLatch lock; // task lock
|
||||||
int32_t maxExecTimes; // task may exec times
|
int32_t maxExecTimes; // task may exec times
|
||||||
int32_t execIdx; // task current execute try index
|
int32_t execId; // task current execute try index
|
||||||
SSchLevel *level; // level
|
SSchLevel *level; // level
|
||||||
SRWLatch planLock; // task update plan lock
|
SRWLatch planLock; // task update plan lock
|
||||||
SSubplan *plan; // subplan
|
SSubplan *plan; // subplan
|
||||||
|
@ -244,9 +244,9 @@ extern SSchedulerMgmt schMgmt;
|
||||||
#define SCH_LOG_TASK_START_TS(_task) \
|
#define SCH_LOG_TASK_START_TS(_task) \
|
||||||
do { \
|
do { \
|
||||||
int64_t us = taosGetTimestampUs(); \
|
int64_t us = taosGetTimestampUs(); \
|
||||||
int32_t idx = (_task)->execIdx % SCH_TASK_MAX_EXEC_TIMES; \
|
int32_t idx = (_task)->execId % SCH_TASK_MAX_EXEC_TIMES; \
|
||||||
(_task)->profile.execUseTime[idx] = us; \
|
(_task)->profile.execUseTime[idx] = us; \
|
||||||
if (0 == (_task)->execIdx) { \
|
if (0 == (_task)->execId) { \
|
||||||
(_task)->profile.startTs = us; \
|
(_task)->profile.startTs = us; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
@ -254,7 +254,7 @@ extern SSchedulerMgmt schMgmt;
|
||||||
#define SCH_LOG_TASK_WAIT_TS(_task) \
|
#define SCH_LOG_TASK_WAIT_TS(_task) \
|
||||||
do { \
|
do { \
|
||||||
int64_t us = taosGetTimestampUs(); \
|
int64_t us = taosGetTimestampUs(); \
|
||||||
int32_t idx = (_task)->execIdx % SCH_TASK_MAX_EXEC_TIMES; \
|
int32_t idx = (_task)->execId % SCH_TASK_MAX_EXEC_TIMES; \
|
||||||
(_task)->profile.waitTime += us - (_task)->profile.execUseTime[idx]; \
|
(_task)->profile.waitTime += us - (_task)->profile.execUseTime[idx]; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -262,12 +262,12 @@ extern SSchedulerMgmt schMgmt;
|
||||||
#define SCH_LOG_TASK_END_TS(_task) \
|
#define SCH_LOG_TASK_END_TS(_task) \
|
||||||
do { \
|
do { \
|
||||||
int64_t us = taosGetTimestampUs(); \
|
int64_t us = taosGetTimestampUs(); \
|
||||||
int32_t idx = (_task)->execIdx % SCH_TASK_MAX_EXEC_TIMES; \
|
int32_t idx = (_task)->execId % SCH_TASK_MAX_EXEC_TIMES; \
|
||||||
(_task)->profile.execUseTime[idx] = us - (_task)->profile.execUseTime[idx]; \
|
(_task)->profile.execUseTime[idx] = us - (_task)->profile.execUseTime[idx]; \
|
||||||
(_task)->profile.endTs = us; \
|
(_task)->profile.endTs = us; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define SCH_TASK_TIMEOUT(_task) ((taosGetTimestampUs() - (_task)->profile.execUseTime[(_task)->execIdx % SCH_TASK_MAX_EXEC_TIMES]) > (_task)->timeoutUsec)
|
#define SCH_TASK_TIMEOUT(_task) ((taosGetTimestampUs() - (_task)->profile.execUseTime[(_task)->execId % SCH_TASK_MAX_EXEC_TIMES]) > (_task)->timeoutUsec)
|
||||||
|
|
||||||
#define SCH_TASK_READY_FOR_LAUNCH(readyNum, task) ((readyNum) >= taosArrayGetSize((task)->children))
|
#define SCH_TASK_READY_FOR_LAUNCH(readyNum, task) ((readyNum) >= taosArrayGetSize((task)->children))
|
||||||
|
|
||||||
|
@ -275,6 +275,7 @@ extern SSchedulerMgmt schMgmt;
|
||||||
#define SCH_UNLOCK_TASK(_task) SCH_UNLOCK(SCH_WRITE, &(_task)->lock)
|
#define SCH_UNLOCK_TASK(_task) SCH_UNLOCK(SCH_WRITE, &(_task)->lock)
|
||||||
|
|
||||||
#define SCH_TASK_ID(_task) ((_task) ? (_task)->taskId : -1)
|
#define SCH_TASK_ID(_task) ((_task) ? (_task)->taskId : -1)
|
||||||
|
#define SCH_TASK_EID(_task) ((_task) ? (_task)->execId : -1)
|
||||||
#define SCH_SET_TASK_LASTMSG_TYPE(_task, _type) do { if(_task) { atomic_store_32(&(_task)->lastMsgType, _type); } } while (0)
|
#define SCH_SET_TASK_LASTMSG_TYPE(_task, _type) do { if(_task) { atomic_store_32(&(_task)->lastMsgType, _type); } } while (0)
|
||||||
#define SCH_GET_TASK_LASTMSG_TYPE(_task) ((_task) ? atomic_load_32(&(_task)->lastMsgType) : -1)
|
#define SCH_GET_TASK_LASTMSG_TYPE(_task) ((_task) ? atomic_load_32(&(_task)->lastMsgType) : -1)
|
||||||
|
|
||||||
|
@ -307,6 +308,8 @@ extern SSchedulerMgmt schMgmt;
|
||||||
#define SCH_IS_WAIT_ALL_JOB(_job) (!SCH_IS_QUERY_JOB(_job))
|
#define SCH_IS_WAIT_ALL_JOB(_job) (!SCH_IS_QUERY_JOB(_job))
|
||||||
#define SCH_IS_NEED_DROP_JOB(_job) (SCH_IS_QUERY_JOB(_job))
|
#define SCH_IS_NEED_DROP_JOB(_job) (SCH_IS_QUERY_JOB(_job))
|
||||||
#define SCH_IS_EXPLAIN_JOB(_job) (EXPLAIN_MODE_ANALYZE == (_job)->attr.explainMode)
|
#define SCH_IS_EXPLAIN_JOB(_job) (EXPLAIN_MODE_ANALYZE == (_job)->attr.explainMode)
|
||||||
|
#define SCH_NETWORK_ERR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL)
|
||||||
|
#define SCH_SUB_TASK_NETWORK_ERR(_code, _len) (((_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || (_code) == TSDB_CODE_RPC_BROKEN_LINK) && ((_len) > 0))
|
||||||
|
|
||||||
#define SCH_IS_LEVEL_UNFINISHED(_level) ((_level)->taskLaunchedNum < (_level)->taskNum)
|
#define SCH_IS_LEVEL_UNFINISHED(_level) ((_level)->taskLaunchedNum < (_level)->taskNum)
|
||||||
#define SCH_GET_CUR_EP(_addr) (&(_addr)->epSet.eps[(_addr)->epSet.inUse])
|
#define SCH_GET_CUR_EP(_addr) (&(_addr)->epSet.eps[(_addr)->epSet.inUse])
|
||||||
|
@ -317,13 +320,13 @@ extern SSchedulerMgmt schMgmt;
|
||||||
#define SCH_JOB_DLOG(param, ...) qDebug("QID:0x%" PRIx64 " " param, pJob->queryId, __VA_ARGS__)
|
#define SCH_JOB_DLOG(param, ...) qDebug("QID:0x%" PRIx64 " " param, pJob->queryId, __VA_ARGS__)
|
||||||
|
|
||||||
#define SCH_TASK_ELOG(param, ...) \
|
#define SCH_TASK_ELOG(param, ...) \
|
||||||
qError("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, pJob->queryId, SCH_TASK_ID(pTask), __VA_ARGS__)
|
qError("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__)
|
||||||
#define SCH_TASK_DLOG(param, ...) \
|
#define SCH_TASK_DLOG(param, ...) \
|
||||||
qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, pJob->queryId, SCH_TASK_ID(pTask), __VA_ARGS__)
|
qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__)
|
||||||
#define SCH_TASK_DLOGL(param, ...) \
|
#define SCH_TASK_DLOGL(param, ...) \
|
||||||
qDebugL("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, pJob->queryId, SCH_TASK_ID(pTask), __VA_ARGS__)
|
qDebugL("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__)
|
||||||
#define SCH_TASK_WLOG(param, ...) \
|
#define SCH_TASK_WLOG(param, ...) \
|
||||||
qWarn("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, pJob->queryId, SCH_TASK_ID(pTask), __VA_ARGS__)
|
qWarn("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__)
|
||||||
|
|
||||||
#define SCH_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
|
#define SCH_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
|
||||||
#define SCH_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
|
#define SCH_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
|
||||||
|
@ -354,7 +357,7 @@ void schFreeJobImpl(void *job);
|
||||||
int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx);
|
int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx);
|
||||||
int32_t schEnsureHbConnection(SSchJob *pJob, SSchTask *pTask);
|
int32_t schEnsureHbConnection(SSchJob *pJob, SSchTask *pTask);
|
||||||
int32_t schUpdateHbConnection(SQueryNodeEpId *epId, SSchTrans *trans);
|
int32_t schUpdateHbConnection(SQueryNodeEpId *epId, SSchTrans *trans);
|
||||||
int32_t schHandleHbCallback(void *param, const SDataBuf *pMsg, int32_t code);
|
int32_t schHandleHbCallback(void *param, SDataBuf *pMsg, int32_t code);
|
||||||
void schFreeRpcCtx(SRpcCtx *pCtx);
|
void schFreeRpcCtx(SRpcCtx *pCtx);
|
||||||
int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp);
|
int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp);
|
||||||
bool schJobNeedToStop(SSchJob *pJob, int8_t *pStatus);
|
bool schJobNeedToStop(SSchJob *pJob, int8_t *pStatus);
|
||||||
|
@ -365,7 +368,7 @@ void schProcessOnDataFetched(SSchJob *job);
|
||||||
int32_t schGetTaskInJob(SSchJob *pJob, uint64_t taskId, SSchTask **pTask);
|
int32_t schGetTaskInJob(SSchJob *pJob, uint64_t taskId, SSchTask **pTask);
|
||||||
void schFreeRpcCtxVal(const void *arg);
|
void schFreeRpcCtxVal(const void *arg);
|
||||||
int32_t schMakeBrokenLinkVal(SSchJob *pJob, SSchTask *pTask, SRpcBrokenlinkVal *brokenVal, bool isHb);
|
int32_t schMakeBrokenLinkVal(SSchJob *pJob, SSchTask *pTask, SRpcBrokenlinkVal *brokenVal, bool isHb);
|
||||||
int32_t schAppendTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, int32_t execIdx);
|
int32_t schAppendTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, int32_t execId);
|
||||||
int32_t schExecStaticExplainJob(SSchedulerReq *pReq, int64_t *job, bool sync);
|
int32_t schExecStaticExplainJob(SSchedulerReq *pReq, int64_t *job, bool sync);
|
||||||
int32_t schExecJobImpl(SSchedulerReq *pReq, SSchJob *pJob, bool sync);
|
int32_t schExecJobImpl(SSchedulerReq *pReq, SSchJob *pJob, bool sync);
|
||||||
int32_t schUpdateJobStatus(SSchJob *pJob, int8_t newStatus);
|
int32_t schUpdateJobStatus(SSchJob *pJob, int8_t newStatus);
|
||||||
|
@ -377,13 +380,15 @@ int32_t schExecJob(SSchedulerReq *pReq, int64_t *pJob, SQueryResult *pRes);
|
||||||
int32_t schAsyncExecJob(SSchedulerReq *pReq, int64_t *pJob);
|
int32_t schAsyncExecJob(SSchedulerReq *pReq, int64_t *pJob);
|
||||||
int32_t schFetchRows(SSchJob *pJob);
|
int32_t schFetchRows(SSchJob *pJob);
|
||||||
int32_t schAsyncFetchRows(SSchJob *pJob);
|
int32_t schAsyncFetchRows(SSchJob *pJob);
|
||||||
int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, void *handle, int32_t execIdx);
|
int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, void *handle, int32_t execId);
|
||||||
int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList);
|
int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList);
|
||||||
void schFreeSMsgSendInfo(SMsgSendInfo *msgSendInfo);
|
void schFreeSMsgSendInfo(SMsgSendInfo *msgSendInfo);
|
||||||
char* schGetOpStr(SCH_OP_TYPE type);
|
char* schGetOpStr(SCH_OP_TYPE type);
|
||||||
int32_t schBeginOperation(SSchJob *pJob, SCH_OP_TYPE type, bool sync);
|
int32_t schBeginOperation(SSchJob *pJob, SCH_OP_TYPE type, bool sync);
|
||||||
int32_t schInitJob(SSchedulerReq *pReq, SSchJob **pSchJob);
|
int32_t schInitJob(SSchedulerReq *pReq, SSchJob **pSchJob);
|
||||||
int32_t schSetJobQueryRes(SSchJob* pJob, SQueryResult* pRes);
|
int32_t schSetJobQueryRes(SSchJob* pJob, SQueryResult* pRes);
|
||||||
|
int32_t schUpdateTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask, SEpSet* pEpSet);
|
||||||
|
int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf* pData, int32_t rspCode);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -28,7 +28,7 @@ FORCE_INLINE int32_t schReleaseJob(int64_t refId) { qDebug("sch release jobId:0x
|
||||||
int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *pLevel) {
|
int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *pLevel) {
|
||||||
pTask->plan = pPlan;
|
pTask->plan = pPlan;
|
||||||
pTask->level = pLevel;
|
pTask->level = pLevel;
|
||||||
pTask->execIdx = -1;
|
pTask->execId = -1;
|
||||||
pTask->maxExecTimes = SCH_TASK_MAX_EXEC_TIMES;
|
pTask->maxExecTimes = SCH_TASK_MAX_EXEC_TIMES;
|
||||||
pTask->timeoutUsec = SCH_DEFAULT_TASK_TIMEOUT_USEC;
|
pTask->timeoutUsec = SCH_DEFAULT_TASK_TIMEOUT_USEC;
|
||||||
SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_NOT_START);
|
SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_NOT_START);
|
||||||
|
@ -429,59 +429,59 @@ int32_t schRecordTaskSucceedNode(SSchJob *pJob, SSchTask *pTask) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schAppendTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, int32_t execIdx) {
|
int32_t schAppendTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, int32_t execId) {
|
||||||
SSchNodeInfo nodeInfo = {.addr = *addr, .handle = NULL};
|
SSchNodeInfo nodeInfo = {.addr = *addr, .handle = NULL};
|
||||||
|
|
||||||
if (taosHashPut(pTask->execNodes, &execIdx, sizeof(execIdx), &nodeInfo, sizeof(nodeInfo))) {
|
if (taosHashPut(pTask->execNodes, &execId, sizeof(execId), &nodeInfo, sizeof(nodeInfo))) {
|
||||||
SCH_TASK_ELOG("taosHashPut nodeInfo to execNodes failed, errno:%d", errno);
|
SCH_TASK_ELOG("taosHashPut nodeInfo to execNodes failed, errno:%d", errno);
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_TASK_DLOG("task execNode added, execIdx:%d", execIdx);
|
SCH_TASK_DLOG("task execNode added, execId:%d", execId);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schDropTaskExecNode(SSchJob *pJob, SSchTask *pTask, void *handle, int32_t execIdx) {
|
int32_t schDropTaskExecNode(SSchJob *pJob, SSchTask *pTask, void *handle, int32_t execId) {
|
||||||
if (NULL == pTask->execNodes) {
|
if (NULL == pTask->execNodes) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosHashRemove(pTask->execNodes, &execIdx, sizeof(execIdx))) {
|
if (taosHashRemove(pTask->execNodes, &execId, sizeof(execId))) {
|
||||||
SCH_TASK_ELOG("fail to remove execIdx %d from execNodeList", execIdx);
|
SCH_TASK_ELOG("fail to remove execId %d from execNodeList", execId);
|
||||||
} else {
|
} else {
|
||||||
SCH_TASK_DLOG("execIdx %d removed from execNodeList", execIdx);
|
SCH_TASK_DLOG("execId %d removed from execNodeList", execId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (execIdx != pTask->execIdx) { // ignore it
|
if (execId != pTask->execId) { // ignore it
|
||||||
SCH_TASK_DLOG("execIdx %d is not current execIdx %d", execIdx, pTask->execIdx);
|
SCH_TASK_DLOG("execId %d is not current execId %d", execId, pTask->execId);
|
||||||
SCH_RET(TSDB_CODE_SCH_IGNORE_ERROR);
|
SCH_RET(TSDB_CODE_SCH_IGNORE_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schUpdateTaskExecNode(SSchJob *pJob, SSchTask *pTask, void *handle, int32_t execIdx) {
|
int32_t schUpdateTaskExecNode(SSchJob *pJob, SSchTask *pTask, void *handle, int32_t execId) {
|
||||||
if (taosHashGetSize(pTask->execNodes) <= 0) {
|
if (taosHashGetSize(pTask->execNodes) <= 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchNodeInfo *nodeInfo = taosHashGet(pTask->execNodes, &execIdx, sizeof(execIdx));
|
SSchNodeInfo *nodeInfo = taosHashGet(pTask->execNodes, &execId, sizeof(execId));
|
||||||
nodeInfo->handle = handle;
|
nodeInfo->handle = handle;
|
||||||
|
|
||||||
SCH_TASK_DLOG("handle updated to %p for execIdx %d", handle, execIdx);
|
SCH_TASK_DLOG("handle updated to %p for execId %d", handle, execId);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, void *handle, int32_t execIdx) {
|
int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, void *handle, int32_t execId) {
|
||||||
if (dropExecNode) {
|
if (dropExecNode) {
|
||||||
SCH_RET(schDropTaskExecNode(pJob, pTask, handle, execIdx));
|
SCH_RET(schDropTaskExecNode(pJob, pTask, handle, execId));
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_SET_TASK_HANDLE(pTask, handle);
|
SCH_SET_TASK_HANDLE(pTask, handle);
|
||||||
|
|
||||||
schUpdateTaskExecNode(pJob, pTask, handle, execIdx);
|
schUpdateTaskExecNode(pJob, pTask, handle, execId);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -683,6 +683,25 @@ int32_t schSetTaskCandidateAddrs(SSchJob *pJob, SSchTask *pTask) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t schUpdateTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask, SEpSet* pEpSet) {
|
||||||
|
if (NULL == pTask->candidateAddrs || 1 != taosArrayGetSize(pTask->candidateAddrs)) {
|
||||||
|
SCH_TASK_ELOG("not able to update cndidate addr, addr num %d", (int32_t)(pTask->candidateAddrs ? taosArrayGetSize(pTask->candidateAddrs): 0));
|
||||||
|
SCH_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
SQueryNodeAddr* pAddr = taosArrayGet(pTask->candidateAddrs, 0);
|
||||||
|
|
||||||
|
SEp* pOld = &pAddr->epSet.eps[pAddr->epSet.inUse];
|
||||||
|
SEp* pNew = &pEpSet->eps[pEpSet->inUse];
|
||||||
|
|
||||||
|
SCH_TASK_DLOG("update task ep from %s:%d to %s:%d", pOld->fqdn, pOld->port, pNew->fqdn, pNew->port);
|
||||||
|
|
||||||
|
memcpy(&pAddr->epSet, pEpSet, sizeof(pAddr->epSet));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t schRemoveTaskFromExecList(SSchJob *pJob, SSchTask *pTask) {
|
int32_t schRemoveTaskFromExecList(SSchJob *pJob, SSchTask *pTask) {
|
||||||
int32_t code = taosHashRemove(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId));
|
int32_t code = taosHashRemove(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId));
|
||||||
if (code) {
|
if (code) {
|
||||||
|
@ -810,9 +829,9 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pTask->execIdx + 1) >= pTask->maxExecTimes) {
|
if ((pTask->execId + 1) >= pTask->maxExecTimes) {
|
||||||
*needRetry = false;
|
*needRetry = false;
|
||||||
SCH_TASK_DLOG("task no more retry since reach max try times, execIdx:%d", pTask->execIdx);
|
SCH_TASK_DLOG("task no more retry since reach max try times, execId:%d", pTask->execId);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -822,11 +841,10 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO CHECK epList/condidateList
|
|
||||||
if (SCH_IS_DATA_SRC_TASK(pTask)) {
|
if (SCH_IS_DATA_SRC_TASK(pTask)) {
|
||||||
if ((pTask->execIdx + 1) >= SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)) {
|
if ((pTask->execId + 1) >= SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)) {
|
||||||
*needRetry = false;
|
*needRetry = false;
|
||||||
SCH_TASK_DLOG("task no more retry since all ep tried, execIdx:%d, epNum:%d", pTask->execIdx,
|
SCH_TASK_DLOG("task no more retry since all ep tried, execId:%d, epNum:%d", pTask->execId,
|
||||||
SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode));
|
SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode));
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -842,7 +860,7 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
|
||||||
}
|
}
|
||||||
|
|
||||||
*needRetry = true;
|
*needRetry = true;
|
||||||
SCH_TASK_DLOG("task need the %dth retry, errCode:%x - %s", pTask->execIdx + 1, errCode, tstrerror(errCode));
|
SCH_TASK_DLOG("task need the %dth retry, errCode:%x - %s", pTask->execId + 1, errCode, tstrerror(errCode));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -854,7 +872,6 @@ int32_t schHandleTaskRetry(SSchJob *pJob, SSchTask *pTask) {
|
||||||
SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_NOT_START);
|
SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_NOT_START);
|
||||||
|
|
||||||
if (SCH_TASK_NEED_FLOW_CTRL(pJob, pTask)) {
|
if (SCH_TASK_NEED_FLOW_CTRL(pJob, pTask)) {
|
||||||
SCH_ERR_RET(schDecTaskFlowQuota(pJob, pTask));
|
|
||||||
SCH_ERR_RET(schLaunchTasksInFlowCtrlList(pJob, pTask));
|
SCH_ERR_RET(schLaunchTasksInFlowCtrlList(pJob, pTask));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1155,6 +1172,7 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
|
||||||
SDownstreamSourceNode source = {.type = QUERY_NODE_DOWNSTREAM_SOURCE,
|
SDownstreamSourceNode source = {.type = QUERY_NODE_DOWNSTREAM_SOURCE,
|
||||||
.taskId = pTask->taskId,
|
.taskId = pTask->taskId,
|
||||||
.schedId = schMgmt.sId,
|
.schedId = schMgmt.sId,
|
||||||
|
.execId = pTask->execId,
|
||||||
.addr = pTask->succeedAddr};
|
.addr = pTask->succeedAddr};
|
||||||
qSetSubplanExecutionNode(parent->plan, pTask->plan->id.groupId, &source);
|
qSetSubplanExecutionNode(parent->plan, pTask->plan->id.groupId, &source);
|
||||||
SCH_UNLOCK(SCH_WRITE, &parent->lock);
|
SCH_UNLOCK(SCH_WRITE, &parent->lock);
|
||||||
|
@ -1184,7 +1202,7 @@ int32_t schFetchFromRemote(SSchJob *pJob) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_ERR_JRET(schBuildAndSendMsg(pJob, pJob->fetchTask, &pJob->resNode, TDMT_VND_FETCH));
|
SCH_ERR_JRET(schBuildAndSendMsg(pJob, pJob->fetchTask, &pJob->resNode, TDMT_SCH_FETCH));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
@ -1223,7 +1241,7 @@ void schDropTaskOnExecNode(SSchJob *pJob, SSchTask *pTask) {
|
||||||
while (nodeInfo) {
|
while (nodeInfo) {
|
||||||
SCH_SET_TASK_HANDLE(pTask, nodeInfo->handle);
|
SCH_SET_TASK_HANDLE(pTask, nodeInfo->handle);
|
||||||
|
|
||||||
schBuildAndSendMsg(pJob, pTask, &nodeInfo->addr, TDMT_VND_DROP_TASK);
|
schBuildAndSendMsg(pJob, pTask, &nodeInfo->addr, TDMT_SCH_DROP_TASK);
|
||||||
|
|
||||||
nodeInfo = taosHashIterate(pTask->execNodes, nodeInfo);
|
nodeInfo = taosHashIterate(pTask->execNodes, nodeInfo);
|
||||||
}
|
}
|
||||||
|
@ -1238,8 +1256,9 @@ int32_t schRescheduleTask(SSchJob *pJob, SSchTask *pTask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_LOCK_TASK(pTask);
|
SCH_LOCK_TASK(pTask);
|
||||||
if (JOB_TASK_STATUS_EXECUTING == pTask->status && pJob->fetchTask != pTask && taosArrayGetSize(pTask->candidateAddrs) > 1) {
|
if (SCH_TASK_TIMEOUT(pTask) && JOB_TASK_STATUS_EXECUTING == pTask->status &&
|
||||||
SCH_TASK_DLOG("task execIdx %d will be rescheduled now", pTask->execIdx);
|
pJob->fetchTask != pTask && taosArrayGetSize(pTask->candidateAddrs) > 1) {
|
||||||
|
SCH_TASK_DLOG("task execId %d will be rescheduled now", pTask->execId);
|
||||||
schDropTaskOnExecNode(pJob, pTask);
|
schDropTaskOnExecNode(pJob, pTask);
|
||||||
taosHashClear(pTask->execNodes);
|
taosHashClear(pTask->execNodes);
|
||||||
schProcessOnTaskFailure(pJob, pTask, TSDB_CODE_SCH_TIMEOUT_ERROR);
|
schProcessOnTaskFailure(pJob, pTask, TSDB_CODE_SCH_TIMEOUT_ERROR);
|
||||||
|
@ -1258,6 +1277,9 @@ int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList) {
|
||||||
for (int32_t i = 0; i < taskNum; ++i) {
|
for (int32_t i = 0; i < taskNum; ++i) {
|
||||||
STaskStatus *taskStatus = taosArrayGet(pStatusList, i);
|
STaskStatus *taskStatus = taosArrayGet(pStatusList, i);
|
||||||
|
|
||||||
|
qDebug("QID:%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d task status in server: %s",
|
||||||
|
taskStatus->queryId, taskStatus->taskId, taskStatus->execId, jobTaskStatusStr(taskStatus->status));
|
||||||
|
|
||||||
SSchJob *pJob = schAcquireJob(taskStatus->refId);
|
SSchJob *pJob = schAcquireJob(taskStatus->refId);
|
||||||
if (NULL == pJob) {
|
if (NULL == pJob) {
|
||||||
qWarn("job not found, refId:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64, taskStatus->refId,
|
qWarn("job not found, refId:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64, taskStatus->refId,
|
||||||
|
@ -1266,8 +1288,6 @@ int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_JOB_DLOG("TID:0x%" PRIx64 " task status in server: %s", taskStatus->taskId, jobTaskStatusStr(taskStatus->status));
|
|
||||||
|
|
||||||
pTask = NULL;
|
pTask = NULL;
|
||||||
schGetTaskInJob(pJob, taskStatus->taskId, &pTask);
|
schGetTaskInJob(pJob, taskStatus->taskId, &pTask);
|
||||||
if (NULL == pTask) {
|
if (NULL == pTask) {
|
||||||
|
@ -1275,6 +1295,13 @@ int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList) {
|
||||||
schReleaseJob(taskStatus->refId);
|
schReleaseJob(taskStatus->refId);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (taskStatus->execId != pTask->execId) {
|
||||||
|
// TODO DROP TASK FROM SERVER!!!!
|
||||||
|
SCH_TASK_DLOG("EID %d in hb rsp mis-match", taskStatus->execId);
|
||||||
|
schReleaseJob(taskStatus->refId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (taskStatus->status == JOB_TASK_STATUS_FAILED) {
|
if (taskStatus->status == JOB_TASK_STATUS_FAILED) {
|
||||||
// RECORD AND HANDLE ERROR!!!!
|
// RECORD AND HANDLE ERROR!!!!
|
||||||
|
@ -1282,7 +1309,7 @@ int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taskStatus->status == JOB_TASK_STATUS_NOT_START && SCH_TASK_TIMEOUT(pTask)) {
|
if (taskStatus->status == JOB_TASK_STATUS_NOT_START) {
|
||||||
schRescheduleTask(pJob, pTask);
|
schRescheduleTask(pJob, pTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1308,7 +1335,7 @@ int32_t schSaveJobQueryRes(SSchJob *pJob, SQueryTableRsp *rsp) {
|
||||||
tbInfo.tversion = rsp->tversion;
|
tbInfo.tversion = rsp->tversion;
|
||||||
|
|
||||||
taosArrayPush((SArray *)pJob->execRes.res, &tbInfo);
|
taosArrayPush((SArray *)pJob->execRes.res, &tbInfo);
|
||||||
pJob->execRes.msgType = TDMT_VND_QUERY;
|
pJob->execRes.msgType = TDMT_SCH_QUERY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -1345,9 +1372,9 @@ int32_t schLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
atomic_add_fetch_32(&pTask->level->taskLaunchedNum, 1);
|
atomic_add_fetch_32(&pTask->level->taskLaunchedNum, 1);
|
||||||
pTask->execIdx++;
|
pTask->execId++;
|
||||||
|
|
||||||
SCH_TASK_DLOG("start to launch task's %dth exec", pTask->execIdx);
|
SCH_TASK_DLOG("start to launch task's %dth exec", pTask->execId);
|
||||||
|
|
||||||
SCH_LOG_TASK_START_TS(pTask);
|
SCH_LOG_TASK_START_TS(pTask);
|
||||||
|
|
||||||
|
@ -1658,5 +1685,94 @@ _return:
|
||||||
SCH_RET(code);
|
SCH_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf* pData, int32_t rspCode) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int8_t status = 0;
|
||||||
|
if (schJobNeedToStop(pJob, &status)) {
|
||||||
|
SCH_TASK_ELOG("redirect will no continue cause of job status %s", jobTaskStatusStr(status));
|
||||||
|
SCH_RET(atomic_load_32(&pJob->errCode));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((pTask->execId + 1) >= pTask->maxExecTimes) {
|
||||||
|
SCH_TASK_DLOG("task no more retry since reach max try times, execId:%d", pTask->execId);
|
||||||
|
schProcessOnJobFailure(pJob, rspCode);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCH_TASK_DLOG("task will be redirected now, status:%s", SCH_GET_TASK_STATUS_STR(pTask));
|
||||||
|
|
||||||
|
schDropTaskOnExecNode(pJob, pTask);
|
||||||
|
taosHashClear(pTask->execNodes);
|
||||||
|
SCH_ERR_JRET(schRemoveTaskFromExecList(pJob, pTask));
|
||||||
|
schDeregisterTaskHb(pJob, pTask);
|
||||||
|
atomic_sub_fetch_32(&pTask->level->taskLaunchedNum, 1);
|
||||||
|
taosMemoryFreeClear(pTask->msg);
|
||||||
|
pTask->msgLen = 0;
|
||||||
|
pTask->lastMsgType = 0;
|
||||||
|
memset(&pTask->succeedAddr, 0, sizeof(pTask->succeedAddr));
|
||||||
|
|
||||||
|
if (SCH_IS_DATA_SRC_QRY_TASK(pTask)) {
|
||||||
|
if (pData) {
|
||||||
|
SCH_ERR_JRET(schUpdateTaskCandidateAddr(pJob, pTask, pData->pEpSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SCH_TASK_NEED_FLOW_CTRL(pJob, pTask)) {
|
||||||
|
if (JOB_TASK_STATUS_EXECUTING == SCH_GET_TASK_STATUS(pTask)) {
|
||||||
|
SCH_ERR_JRET(schLaunchTasksInFlowCtrlList(pJob, pTask));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_NOT_START);
|
||||||
|
|
||||||
|
SCH_ERR_JRET(schLaunchTask(pJob, pTask));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// merge plan
|
||||||
|
|
||||||
|
pTask->childReady = 0;
|
||||||
|
|
||||||
|
qClearSubplanExecutionNode(pTask->plan);
|
||||||
|
|
||||||
|
SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_NOT_START);
|
||||||
|
|
||||||
|
int32_t childrenNum = taosArrayGetSize(pTask->children);
|
||||||
|
for (int32_t i = 0; i < childrenNum; ++i) {
|
||||||
|
SSchTask* pChild = taosArrayGetP(pTask->children, i);
|
||||||
|
SCH_LOCK_TASK(pChild);
|
||||||
|
schDoTaskRedirect(pJob, pChild, NULL, rspCode);
|
||||||
|
SCH_UNLOCK_TASK(pChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
code = schProcessOnTaskFailure(pJob, pTask, code);
|
||||||
|
|
||||||
|
SCH_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf* pData, int32_t rspCode) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
if (SCH_IS_DATA_SRC_QRY_TASK(pTask)) {
|
||||||
|
if (NULL == pData->pEpSet) {
|
||||||
|
SCH_TASK_ELOG("no epset updated while got error %s", tstrerror(rspCode));
|
||||||
|
SCH_ERR_JRET(rspCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SCH_RET(schDoTaskRedirect(pJob, pTask, pData, rspCode));
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
schProcessOnTaskFailure(pJob, pTask, code);
|
||||||
|
|
||||||
|
SCH_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,10 @@ int32_t schValidateReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgTy
|
||||||
int32_t reqMsgType = msgType - 1;
|
int32_t reqMsgType = msgType - 1;
|
||||||
switch (msgType) {
|
switch (msgType) {
|
||||||
case TDMT_SCH_LINK_BROKEN:
|
case TDMT_SCH_LINK_BROKEN:
|
||||||
case TDMT_VND_EXPLAIN_RSP:
|
case TDMT_SCH_EXPLAIN_RSP:
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
case TDMT_VND_QUERY_RSP: // query_rsp may be processed later than ready_rsp
|
case TDMT_SCH_MERGE_QUERY_RSP:
|
||||||
|
case TDMT_SCH_QUERY_RSP: // query_rsp may be processed later than ready_rsp
|
||||||
if (lastMsgType != reqMsgType && -1 != lastMsgType) {
|
if (lastMsgType != reqMsgType && -1 != lastMsgType) {
|
||||||
SCH_TASK_DLOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType),
|
SCH_TASK_DLOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType),
|
||||||
TMSG_INFO(msgType));
|
TMSG_INFO(msgType));
|
||||||
|
@ -43,7 +44,7 @@ int32_t schValidateReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgTy
|
||||||
|
|
||||||
SCH_SET_TASK_LASTMSG_TYPE(pTask, -1);
|
SCH_SET_TASK_LASTMSG_TYPE(pTask, -1);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
case TDMT_VND_FETCH_RSP:
|
case TDMT_SCH_FETCH_RSP:
|
||||||
if (lastMsgType != reqMsgType && -1 != lastMsgType) {
|
if (lastMsgType != reqMsgType && -1 != lastMsgType) {
|
||||||
SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType),
|
SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType),
|
||||||
TMSG_INFO(msgType));
|
TMSG_INFO(msgType));
|
||||||
|
@ -90,15 +91,6 @@ int32_t schValidateReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgTy
|
||||||
int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, char *msg, int32_t msgSize,
|
int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, char *msg, int32_t msgSize,
|
||||||
int32_t rspCode) {
|
int32_t rspCode) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int8_t status = 0;
|
|
||||||
|
|
||||||
if (schJobNeedToStop(pJob, &status)) {
|
|
||||||
SCH_TASK_ELOG("rsp not processed cause of job status, job status:%s, rspCode:0x%x", jobTaskStatusStr(status), rspCode);
|
|
||||||
taosMemoryFreeClear(msg);
|
|
||||||
SCH_RET(atomic_load_32(&pJob->errCode));
|
|
||||||
}
|
|
||||||
|
|
||||||
SCH_ERR_JRET(schValidateReceivedMsgType(pJob, pTask, msgType));
|
|
||||||
|
|
||||||
switch (msgType) {
|
switch (msgType) {
|
||||||
case TDMT_VND_CREATE_TABLE_RSP: {
|
case TDMT_VND_CREATE_TABLE_RSP: {
|
||||||
|
@ -247,7 +239,8 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_VND_QUERY_RSP: {
|
case TDMT_SCH_QUERY_RSP:
|
||||||
|
case TDMT_SCH_MERGE_QUERY_RSP: {
|
||||||
SQueryTableRsp *rsp = (SQueryTableRsp *)msg;
|
SQueryTableRsp *rsp = (SQueryTableRsp *)msg;
|
||||||
|
|
||||||
SCH_ERR_JRET(rspCode);
|
SCH_ERR_JRET(rspCode);
|
||||||
|
@ -264,7 +257,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_VND_EXPLAIN_RSP: {
|
case TDMT_SCH_EXPLAIN_RSP: {
|
||||||
SCH_ERR_JRET(rspCode);
|
SCH_ERR_JRET(rspCode);
|
||||||
if (NULL == msg) {
|
if (NULL == msg) {
|
||||||
SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
|
SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
@ -294,7 +287,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_VND_FETCH_RSP: {
|
case TDMT_SCH_FETCH_RSP: {
|
||||||
SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)msg;
|
SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)msg;
|
||||||
|
|
||||||
SCH_ERR_JRET(rspCode);
|
SCH_ERR_JRET(rspCode);
|
||||||
|
@ -342,8 +335,8 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
|
||||||
schProcessOnDataFetched(pJob);
|
schProcessOnDataFetched(pJob);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_VND_DROP_TASK_RSP: {
|
case TDMT_SCH_DROP_TASK_RSP: {
|
||||||
// SHOULD NEVER REACH HERE
|
// NEVER REACH HERE
|
||||||
SCH_TASK_ELOG("invalid status to handle drop task rsp, refId:0x%" PRIx64, pJob->refId);
|
SCH_TASK_ELOG("invalid status to handle drop task rsp, refId:0x%" PRIx64, pJob->refId);
|
||||||
SCH_ERR_JRET(TSDB_CODE_SCH_INTERNAL_ERROR);
|
SCH_ERR_JRET(TSDB_CODE_SCH_INTERNAL_ERROR);
|
||||||
break;
|
break;
|
||||||
|
@ -367,8 +360,9 @@ _return:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, int32_t rspCode) {
|
int32_t schHandleCallback(void *param, SDataBuf *pMsg, int32_t rspCode) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
int32_t msgType = pMsg->msgType;
|
||||||
SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param;
|
SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param;
|
||||||
SSchTask *pTask = NULL;
|
SSchTask *pTask = NULL;
|
||||||
|
|
||||||
|
@ -385,15 +379,30 @@ int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, in
|
||||||
|
|
||||||
SCH_TASK_DLOG("rsp msg received, type:%s, handle:%p, code:%s", TMSG_INFO(msgType), pMsg->handle, tstrerror(rspCode));
|
SCH_TASK_DLOG("rsp msg received, type:%s, handle:%p, code:%s", TMSG_INFO(msgType), pMsg->handle, tstrerror(rspCode));
|
||||||
|
|
||||||
if (pParam->execIdx != pTask->execIdx) {
|
if (pParam->execId != pTask->execId) {
|
||||||
SCH_TASK_DLOG("execIdx %d mis-match current execIdx %d", pParam->execIdx, pTask->execIdx);
|
SCH_TASK_DLOG("execId %d mis-match current execId %d", pParam->execId, pTask->execId);
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dropExecNode = (msgType == TDMT_SCH_LINK_BROKEN || rspCode == TSDB_CODE_RPC_NETWORK_UNAVAIL);
|
bool dropExecNode = (msgType == TDMT_SCH_LINK_BROKEN || SCH_NETWORK_ERR(rspCode));
|
||||||
SCH_ERR_JRET(schUpdateTaskHandle(pJob, pTask, dropExecNode, pMsg->handle, pParam->execIdx));
|
SCH_ERR_JRET(schUpdateTaskHandle(pJob, pTask, dropExecNode, pMsg->handle, pParam->execId));
|
||||||
|
|
||||||
|
int8_t status = 0;
|
||||||
|
if (schJobNeedToStop(pJob, &status)) {
|
||||||
|
SCH_TASK_ELOG("rsp will not be processed cause of job status %s, rspCode:0x%x", jobTaskStatusStr(status), rspCode);
|
||||||
|
code = atomic_load_32(&pJob->errCode);
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCH_ERR_JRET(schValidateReceivedMsgType(pJob, pTask, msgType));
|
||||||
|
|
||||||
|
if (NEED_SCHEDULER_REDIRECT_ERROR(rspCode) || SCH_SUB_TASK_NETWORK_ERR(rspCode, pMsg->len > 0)) {
|
||||||
|
code = schHandleRedirect(pJob, pTask, (SDataBuf *)pMsg, rspCode);
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
SCH_ERR_JRET(schHandleResponseMsg(pJob, pTask, msgType, pMsg->pData, pMsg->len, rspCode));
|
code = schHandleResponseMsg(pJob, pTask, msgType, pMsg->pData, pMsg->len, rspCode);
|
||||||
|
pMsg->pData = NULL;
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
|
@ -405,50 +414,19 @@ _return:
|
||||||
schReleaseJob(pParam->refId);
|
schReleaseJob(pParam->refId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosMemoryFreeClear(pMsg->pData);
|
||||||
taosMemoryFreeClear(param);
|
taosMemoryFreeClear(param);
|
||||||
SCH_RET(code);
|
SCH_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schHandleSubmitCallback(void *param, const SDataBuf *pMsg, int32_t code) {
|
int32_t schHandleDropCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
return schHandleCallback(param, pMsg, TDMT_VND_SUBMIT_RSP, code);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t schHandleCreateTbCallback(void *param, const SDataBuf *pMsg, int32_t code) {
|
|
||||||
return schHandleCallback(param, pMsg, TDMT_VND_CREATE_TABLE_RSP, code);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t schHandleDropTbCallback(void *param, const SDataBuf *pMsg, int32_t code) {
|
|
||||||
return schHandleCallback(param, pMsg, TDMT_VND_DROP_TABLE_RSP, code);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t schHandleAlterTbCallback(void *param, const SDataBuf *pMsg, int32_t code) {
|
|
||||||
return schHandleCallback(param, pMsg, TDMT_VND_ALTER_TABLE_RSP, code);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t schHandleQueryCallback(void *param, const SDataBuf *pMsg, int32_t code) {
|
|
||||||
return schHandleCallback(param, pMsg, TDMT_VND_QUERY_RSP, code);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t schHandleDeleteCallback(void *param, const SDataBuf *pMsg, int32_t code) {
|
|
||||||
return schHandleCallback(param, pMsg, TDMT_VND_DELETE_RSP, code);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t schHandleFetchCallback(void *param, const SDataBuf *pMsg, int32_t code) {
|
|
||||||
return schHandleCallback(param, pMsg, TDMT_VND_FETCH_RSP, code);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t schHandleExplainCallback(void *param, const SDataBuf *pMsg, int32_t code) {
|
|
||||||
return schHandleCallback(param, pMsg, TDMT_VND_EXPLAIN_RSP, code);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t schHandleDropCallback(void *param, const SDataBuf *pMsg, int32_t code) {
|
|
||||||
SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param;
|
SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param;
|
||||||
qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " drop task rsp received, code:0x%x", pParam->queryId, pParam->taskId, code);
|
qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " drop task rsp received, code:0x%x", pParam->queryId, pParam->taskId, code);
|
||||||
taosMemoryFreeClear(param);
|
taosMemoryFreeClear(param);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schHandleLinkBrokenCallback(void *param, const SDataBuf *pMsg, int32_t code) {
|
int32_t schHandleLinkBrokenCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
SSchCallbackParamHeader *head = (SSchCallbackParamHeader *)param;
|
SSchCallbackParamHeader *head = (SSchCallbackParamHeader *)param;
|
||||||
rpcReleaseHandle(pMsg->handle, TAOS_CONN_CLIENT);
|
rpcReleaseHandle(pMsg->handle, TAOS_CONN_CLIENT);
|
||||||
|
|
||||||
|
@ -461,7 +439,7 @@ int32_t schHandleLinkBrokenCallback(void *param, const SDataBuf *pMsg, int32_t c
|
||||||
|
|
||||||
SCH_ERR_RET(schBuildAndSendHbMsg(&hbParam->nodeEpId, NULL));
|
SCH_ERR_RET(schBuildAndSendHbMsg(&hbParam->nodeEpId, NULL));
|
||||||
} else {
|
} else {
|
||||||
SCH_ERR_RET(schHandleCallback(param, pMsg, TDMT_SCH_LINK_BROKEN, code));
|
SCH_ERR_RET(schHandleCallback(param, pMsg, code));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -480,7 +458,7 @@ int32_t schMakeCallbackParam(SSchJob *pJob, SSchTask *pTask, int32_t msgType, bo
|
||||||
param->refId = pJob->refId;
|
param->refId = pJob->refId;
|
||||||
param->taskId = SCH_TASK_ID(pTask);
|
param->taskId = SCH_TASK_ID(pTask);
|
||||||
param->pTrans = pJob->conn.pTrans;
|
param->pTrans = pJob->conn.pTrans;
|
||||||
param->execIdx = pTask->execIdx;
|
param->execId = pTask->execId;
|
||||||
*pParam = param;
|
*pParam = param;
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -557,33 +535,20 @@ _return:
|
||||||
int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp) {
|
int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp) {
|
||||||
switch (msgType) {
|
switch (msgType) {
|
||||||
case TDMT_VND_CREATE_TABLE:
|
case TDMT_VND_CREATE_TABLE:
|
||||||
*fp = schHandleCreateTbCallback;
|
|
||||||
break;
|
|
||||||
case TDMT_VND_DROP_TABLE:
|
case TDMT_VND_DROP_TABLE:
|
||||||
*fp = schHandleDropTbCallback;
|
|
||||||
break;
|
|
||||||
case TDMT_VND_ALTER_TABLE:
|
case TDMT_VND_ALTER_TABLE:
|
||||||
*fp = schHandleAlterTbCallback;
|
|
||||||
break;
|
|
||||||
case TDMT_VND_SUBMIT:
|
case TDMT_VND_SUBMIT:
|
||||||
*fp = schHandleSubmitCallback;
|
case TDMT_SCH_QUERY:
|
||||||
break;
|
case TDMT_SCH_MERGE_QUERY:
|
||||||
case TDMT_VND_QUERY:
|
|
||||||
*fp = schHandleQueryCallback;
|
|
||||||
break;
|
|
||||||
case TDMT_VND_DELETE:
|
case TDMT_VND_DELETE:
|
||||||
*fp = schHandleDeleteCallback;
|
case TDMT_SCH_EXPLAIN:
|
||||||
|
case TDMT_SCH_FETCH:
|
||||||
|
*fp = schHandleCallback;
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_EXPLAIN:
|
case TDMT_SCH_DROP_TASK:
|
||||||
*fp = schHandleExplainCallback;
|
|
||||||
break;
|
|
||||||
case TDMT_VND_FETCH:
|
|
||||||
*fp = schHandleFetchCallback;
|
|
||||||
break;
|
|
||||||
case TDMT_VND_DROP_TASK:
|
|
||||||
*fp = schHandleDropCallback;
|
*fp = schHandleDropCallback;
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_QUERY_HEARTBEAT:
|
case TDMT_SCH_QUERY_HEARTBEAT:
|
||||||
*fp = schHandleHbCallback;
|
*fp = schHandleHbCallback;
|
||||||
break;
|
break;
|
||||||
case TDMT_SCH_LINK_BROKEN:
|
case TDMT_SCH_LINK_BROKEN:
|
||||||
|
@ -692,9 +657,9 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
|
||||||
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t msgType = TDMT_VND_QUERY_HEARTBEAT_RSP;
|
int32_t msgType = TDMT_SCH_QUERY_HEARTBEAT_RSP;
|
||||||
__async_send_cb_fn_t fp = NULL;
|
__async_send_cb_fn_t fp = NULL;
|
||||||
SCH_ERR_JRET(schGetCallbackFp(TDMT_VND_QUERY_HEARTBEAT, &fp));
|
SCH_ERR_JRET(schGetCallbackFp(TDMT_SCH_QUERY_HEARTBEAT, &fp));
|
||||||
|
|
||||||
param->nodeEpId = epId;
|
param->nodeEpId = epId;
|
||||||
param->pTrans = pJob->conn.pTrans;
|
param->pTrans = pJob->conn.pTrans;
|
||||||
|
@ -722,7 +687,7 @@ _return:
|
||||||
SCH_RET(code);
|
SCH_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schHandleHbCallback(void *param, const SDataBuf *pMsg, int32_t code) {
|
int32_t schHandleHbCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
SSchedulerHbRsp rsp = {0};
|
SSchedulerHbRsp rsp = {0};
|
||||||
SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param;
|
SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param;
|
||||||
|
|
||||||
|
@ -784,9 +749,9 @@ int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchTrans trans = {.pTrans = pJob->conn.pTrans, .pHandle = SCH_GET_TASK_HANDLE(pTask)};
|
SSchTrans trans = {.pTrans = pJob->conn.pTrans, .pHandle = SCH_GET_TASK_HANDLE(pTask)};
|
||||||
SCH_ERR_JRET(schGenerateCallBackInfo(pJob, pTask, NULL, 0, TDMT_VND_EXPLAIN, &trans, false, &pExplainMsgSendInfo));
|
SCH_ERR_JRET(schGenerateCallBackInfo(pJob, pTask, NULL, 0, TDMT_SCH_EXPLAIN, &trans, false, &pExplainMsgSendInfo));
|
||||||
|
|
||||||
int32_t msgType = TDMT_VND_EXPLAIN_RSP;
|
int32_t msgType = TDMT_SCH_EXPLAIN_RSP;
|
||||||
SRpcCtxVal ctxVal = {.val = pExplainMsgSendInfo, .clone = schCloneSMsgSendInfo};
|
SRpcCtxVal ctxVal = {.val = pExplainMsgSendInfo, .clone = schCloneSMsgSendInfo};
|
||||||
if (taosHashPut(pCtx->args, &msgType, sizeof(msgType), &ctxVal, sizeof(ctxVal))) {
|
if (taosHashPut(pCtx->args, &msgType, sizeof(msgType), &ctxVal, sizeof(ctxVal))) {
|
||||||
SCH_TASK_ELOG("taosHashPut msg %d to rpcCtx failed", msgType);
|
SCH_TASK_ELOG("taosHashPut msg %d to rpcCtx failed", msgType);
|
||||||
|
@ -882,7 +847,7 @@ int32_t schAsyncSendMsg(SSchJob *pJob, SSchTask *pTask, SSchTrans *trans, SQuery
|
||||||
SEpSet *epSet = &addr->epSet;
|
SEpSet *epSet = &addr->epSet;
|
||||||
|
|
||||||
SMsgSendInfo *pMsgSendInfo = NULL;
|
SMsgSendInfo *pMsgSendInfo = NULL;
|
||||||
bool isHb = (TDMT_VND_QUERY_HEARTBEAT == msgType);
|
bool isHb = (TDMT_SCH_QUERY_HEARTBEAT == msgType);
|
||||||
SCH_ERR_JRET(schGenerateCallBackInfo(pJob, pTask, msg, msgSize, msgType, trans, isHb, &pMsgSendInfo));
|
SCH_ERR_JRET(schGenerateCallBackInfo(pJob, pTask, msg, msgSize, msgType, trans, isHb, &pMsgSendInfo));
|
||||||
SCH_ERR_JRET(schUpdateSendTargetInfo(pMsgSendInfo, addr, pTask));
|
SCH_ERR_JRET(schUpdateSendTargetInfo(pMsgSendInfo, addr, pTask));
|
||||||
|
|
||||||
|
@ -926,7 +891,7 @@ int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId, SArray* taskAction) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SRpcCtx rpcCtx = {0};
|
SRpcCtx rpcCtx = {0};
|
||||||
SSchTrans trans = {0};
|
SSchTrans trans = {0};
|
||||||
int32_t msgType = TDMT_VND_QUERY_HEARTBEAT;
|
int32_t msgType = TDMT_SCH_QUERY_HEARTBEAT;
|
||||||
|
|
||||||
req.header.vgId = nodeEpId->nodeId;
|
req.header.vgId = nodeEpId->nodeId;
|
||||||
req.sId = schMgmt.sId;
|
req.sId = schMgmt.sId;
|
||||||
|
@ -1032,7 +997,8 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
||||||
tSerializeSVDeleteReq(msg, msgSize, &req);
|
tSerializeSVDeleteReq(msg, msgSize, &req);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_VND_QUERY: {
|
case TDMT_SCH_QUERY:
|
||||||
|
case TDMT_SCH_MERGE_QUERY: {
|
||||||
SCH_ERR_RET(schMakeQueryRpcCtx(pJob, pTask, &rpcCtx));
|
SCH_ERR_RET(schMakeQueryRpcCtx(pJob, pTask, &rpcCtx));
|
||||||
|
|
||||||
uint32_t len = strlen(pJob->sql);
|
uint32_t len = strlen(pJob->sql);
|
||||||
|
@ -1049,6 +1015,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
||||||
pMsg->queryId = htobe64(pJob->queryId);
|
pMsg->queryId = htobe64(pJob->queryId);
|
||||||
pMsg->taskId = htobe64(pTask->taskId);
|
pMsg->taskId = htobe64(pTask->taskId);
|
||||||
pMsg->refId = htobe64(pJob->refId);
|
pMsg->refId = htobe64(pJob->refId);
|
||||||
|
pMsg->execId = htonl(pTask->execId);
|
||||||
pMsg->taskType = TASK_TYPE_TEMP;
|
pMsg->taskType = TASK_TYPE_TEMP;
|
||||||
pMsg->explain = SCH_IS_EXPLAIN_JOB(pJob);
|
pMsg->explain = SCH_IS_EXPLAIN_JOB(pJob);
|
||||||
pMsg->phyLen = htonl(pTask->msgLen);
|
pMsg->phyLen = htonl(pTask->msgLen);
|
||||||
|
@ -1060,7 +1027,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
||||||
persistHandle = true;
|
persistHandle = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_VND_FETCH: {
|
case TDMT_SCH_FETCH: {
|
||||||
msgSize = sizeof(SResFetchReq);
|
msgSize = sizeof(SResFetchReq);
|
||||||
msg = taosMemoryCalloc(1, msgSize);
|
msg = taosMemoryCalloc(1, msgSize);
|
||||||
if (NULL == msg) {
|
if (NULL == msg) {
|
||||||
|
@ -1075,10 +1042,11 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
||||||
pMsg->sId = htobe64(schMgmt.sId);
|
pMsg->sId = htobe64(schMgmt.sId);
|
||||||
pMsg->queryId = htobe64(pJob->queryId);
|
pMsg->queryId = htobe64(pJob->queryId);
|
||||||
pMsg->taskId = htobe64(pTask->taskId);
|
pMsg->taskId = htobe64(pTask->taskId);
|
||||||
|
pMsg->execId = htonl(pTask->execId);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_VND_DROP_TASK: {
|
case TDMT_SCH_DROP_TASK: {
|
||||||
msgSize = sizeof(STaskDropReq);
|
msgSize = sizeof(STaskDropReq);
|
||||||
msg = taosMemoryCalloc(1, msgSize);
|
msg = taosMemoryCalloc(1, msgSize);
|
||||||
if (NULL == msg) {
|
if (NULL == msg) {
|
||||||
|
@ -1094,9 +1062,10 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
||||||
pMsg->queryId = htobe64(pJob->queryId);
|
pMsg->queryId = htobe64(pJob->queryId);
|
||||||
pMsg->taskId = htobe64(pTask->taskId);
|
pMsg->taskId = htobe64(pTask->taskId);
|
||||||
pMsg->refId = htobe64(pJob->refId);
|
pMsg->refId = htobe64(pJob->refId);
|
||||||
|
pMsg->execId = htonl(pTask->execId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_VND_QUERY_HEARTBEAT: {
|
case TDMT_SCH_QUERY_HEARTBEAT: {
|
||||||
SCH_ERR_RET(schMakeHbRpcCtx(pJob, pTask, &rpcCtx));
|
SCH_ERR_RET(schMakeHbRpcCtx(pJob, pTask, &rpcCtx));
|
||||||
|
|
||||||
SSchedulerHbReq req = {0};
|
SSchedulerHbReq req = {0};
|
||||||
|
@ -1135,8 +1104,8 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
||||||
SCH_ERR_JRET(schAsyncSendMsg(pJob, pTask, &trans, addr, msgType, msg, msgSize, persistHandle,
|
SCH_ERR_JRET(schAsyncSendMsg(pJob, pTask, &trans, addr, msgType, msg, msgSize, persistHandle,
|
||||||
(rpcCtx.args ? &rpcCtx : NULL)));
|
(rpcCtx.args ? &rpcCtx : NULL)));
|
||||||
|
|
||||||
if (msgType == TDMT_VND_QUERY) {
|
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY) {
|
||||||
SCH_ERR_RET(schAppendTaskExecNode(pJob, pTask, addr, pTask->execIdx));
|
SCH_ERR_RET(schAppendTaskExecNode(pJob, pTask, addr, pTask->execId));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -118,7 +118,7 @@ void schtBuildQueryDag(SQueryPlan *dag) {
|
||||||
scanPlan->level = 1;
|
scanPlan->level = 1;
|
||||||
scanPlan->pParents = nodesMakeList();
|
scanPlan->pParents = nodesMakeList();
|
||||||
scanPlan->pNode = (SPhysiNode*)taosMemoryCalloc(1, sizeof(SPhysiNode));
|
scanPlan->pNode = (SPhysiNode*)taosMemoryCalloc(1, sizeof(SPhysiNode));
|
||||||
scanPlan->msgType = TDMT_VND_QUERY;
|
scanPlan->msgType = TDMT_SCH_QUERY;
|
||||||
|
|
||||||
mergePlan->id.queryId = qId;
|
mergePlan->id.queryId = qId;
|
||||||
mergePlan->id.groupId = schtMergeTemplateId;
|
mergePlan->id.groupId = schtMergeTemplateId;
|
||||||
|
@ -130,7 +130,7 @@ void schtBuildQueryDag(SQueryPlan *dag) {
|
||||||
mergePlan->pChildren = nodesMakeList();
|
mergePlan->pChildren = nodesMakeList();
|
||||||
mergePlan->pParents = NULL;
|
mergePlan->pParents = NULL;
|
||||||
mergePlan->pNode = (SPhysiNode*)taosMemoryCalloc(1, sizeof(SPhysiNode));
|
mergePlan->pNode = (SPhysiNode*)taosMemoryCalloc(1, sizeof(SPhysiNode));
|
||||||
mergePlan->msgType = TDMT_VND_QUERY;
|
mergePlan->msgType = TDMT_SCH_QUERY;
|
||||||
|
|
||||||
merge->pNodeList = nodesMakeList();
|
merge->pNodeList = nodesMakeList();
|
||||||
scan->pNodeList = nodesMakeList();
|
scan->pNodeList = nodesMakeList();
|
||||||
|
@ -181,7 +181,7 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) {
|
||||||
scanPlan[i].level = 1;
|
scanPlan[i].level = 1;
|
||||||
scanPlan[i].pParents = nodesMakeList();
|
scanPlan[i].pParents = nodesMakeList();
|
||||||
scanPlan[i].pNode = (SPhysiNode*)taosMemoryCalloc(1, sizeof(SPhysiNode));
|
scanPlan[i].pNode = (SPhysiNode*)taosMemoryCalloc(1, sizeof(SPhysiNode));
|
||||||
scanPlan[i].msgType = TDMT_VND_QUERY;
|
scanPlan[i].msgType = TDMT_SCH_QUERY;
|
||||||
|
|
||||||
nodesListAppend(scanPlan[i].pParents, (SNode*)mergePlan);
|
nodesListAppend(scanPlan[i].pParents, (SNode*)mergePlan);
|
||||||
nodesListAppend(mergePlan->pChildren, (SNode*)(scanPlan + i));
|
nodesListAppend(mergePlan->pChildren, (SNode*)(scanPlan + i));
|
||||||
|
@ -198,7 +198,7 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) {
|
||||||
|
|
||||||
mergePlan->pParents = NULL;
|
mergePlan->pParents = NULL;
|
||||||
mergePlan->pNode = (SPhysiNode*)taosMemoryCalloc(1, sizeof(SPhysiNode));
|
mergePlan->pNode = (SPhysiNode*)taosMemoryCalloc(1, sizeof(SPhysiNode));
|
||||||
mergePlan->msgType = TDMT_VND_QUERY;
|
mergePlan->msgType = TDMT_SCH_QUERY;
|
||||||
|
|
||||||
nodesListAppend(merge->pNodeList, (SNode*)mergePlan);
|
nodesListAppend(merge->pNodeList, (SNode*)mergePlan);
|
||||||
|
|
||||||
|
@ -412,7 +412,7 @@ void *schtCreateFetchRspThread(void *param) {
|
||||||
rsp->completed = 1;
|
rsp->completed = 1;
|
||||||
rsp->numOfRows = 10;
|
rsp->numOfRows = 10;
|
||||||
|
|
||||||
code = schHandleResponseMsg(pJob, pJob->fetchTask, TDMT_VND_FETCH_RSP, (char *)rsp, sizeof(*rsp), 0);
|
code = schHandleResponseMsg(pJob, pJob->fetchTask, TDMT_SCH_FETCH_RSP, (char *)rsp, sizeof(*rsp), 0);
|
||||||
|
|
||||||
schReleaseJob(job);
|
schReleaseJob(job);
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ void *schtFetchRspThread(void *aa) {
|
||||||
dataBuf.pData = rsp;
|
dataBuf.pData = rsp;
|
||||||
dataBuf.len = sizeof(*rsp);
|
dataBuf.len = sizeof(*rsp);
|
||||||
|
|
||||||
code = schHandleCallback(param, &dataBuf, TDMT_VND_FETCH_RSP, 0);
|
code = schHandleCallback(param, &dataBuf, TDMT_SCH_FETCH_RSP, 0);
|
||||||
|
|
||||||
assert(code == 0 || code);
|
assert(code == 0 || code);
|
||||||
}
|
}
|
||||||
|
@ -547,7 +547,7 @@ void* schtRunJobThread(void *aa) {
|
||||||
dataBuf.pData = &rsp;
|
dataBuf.pData = &rsp;
|
||||||
dataBuf.len = sizeof(rsp);
|
dataBuf.len = sizeof(rsp);
|
||||||
|
|
||||||
code = schHandleCallback(param, &dataBuf, TDMT_VND_QUERY_RSP, 0);
|
code = schHandleCallback(param, &dataBuf, TDMT_SCH_QUERY_RSP, 0);
|
||||||
assert(code == 0 || code);
|
assert(code == 0 || code);
|
||||||
|
|
||||||
pIter = taosHashIterate(execTasks, pIter);
|
pIter = taosHashIterate(execTasks, pIter);
|
||||||
|
@ -566,7 +566,7 @@ void* schtRunJobThread(void *aa) {
|
||||||
dataBuf.pData = &rsp;
|
dataBuf.pData = &rsp;
|
||||||
dataBuf.len = sizeof(rsp);
|
dataBuf.len = sizeof(rsp);
|
||||||
|
|
||||||
code = schHandleCallback(param, &dataBuf, TDMT_VND_QUERY_RSP, 0);
|
code = schHandleCallback(param, &dataBuf, TDMT_SCH_QUERY_RSP, 0);
|
||||||
assert(code == 0 || code);
|
assert(code == 0 || code);
|
||||||
|
|
||||||
pIter = taosHashIterate(execTasks, pIter);
|
pIter = taosHashIterate(execTasks, pIter);
|
||||||
|
@ -677,7 +677,7 @@ TEST(queryTest, normalCase) {
|
||||||
SSchTask *task = *(SSchTask **)pIter;
|
SSchTask *task = *(SSchTask **)pIter;
|
||||||
|
|
||||||
SQueryTableRsp rsp = {0};
|
SQueryTableRsp rsp = {0};
|
||||||
code = schHandleResponseMsg(pJob, task, TDMT_VND_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0);
|
code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0);
|
||||||
|
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
pIter = taosHashIterate(pJob->execTasks, pIter);
|
pIter = taosHashIterate(pJob->execTasks, pIter);
|
||||||
|
@ -688,7 +688,7 @@ TEST(queryTest, normalCase) {
|
||||||
SSchTask *task = *(SSchTask **)pIter;
|
SSchTask *task = *(SSchTask **)pIter;
|
||||||
|
|
||||||
SQueryTableRsp rsp = {0};
|
SQueryTableRsp rsp = {0};
|
||||||
code = schHandleResponseMsg(pJob, task, TDMT_VND_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0);
|
code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0);
|
||||||
|
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
pIter = taosHashIterate(pJob->execTasks, pIter);
|
pIter = taosHashIterate(pJob->execTasks, pIter);
|
||||||
|
@ -780,7 +780,7 @@ TEST(queryTest, readyFirstCase) {
|
||||||
SSchTask *task = *(SSchTask **)pIter;
|
SSchTask *task = *(SSchTask **)pIter;
|
||||||
|
|
||||||
SQueryTableRsp rsp = {0};
|
SQueryTableRsp rsp = {0};
|
||||||
code = schHandleResponseMsg(pJob, task, TDMT_VND_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0);
|
code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0);
|
||||||
|
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
pIter = taosHashIterate(pJob->execTasks, pIter);
|
pIter = taosHashIterate(pJob->execTasks, pIter);
|
||||||
|
@ -791,7 +791,7 @@ TEST(queryTest, readyFirstCase) {
|
||||||
SSchTask *task = *(SSchTask **)pIter;
|
SSchTask *task = *(SSchTask **)pIter;
|
||||||
|
|
||||||
SQueryTableRsp rsp = {0};
|
SQueryTableRsp rsp = {0};
|
||||||
code = schHandleResponseMsg(pJob, task, TDMT_VND_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0);
|
code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0);
|
||||||
|
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
pIter = taosHashIterate(pJob->execTasks, pIter);
|
pIter = taosHashIterate(pJob->execTasks, pIter);
|
||||||
|
@ -896,9 +896,9 @@ TEST(queryTest, flowCtrlCase) {
|
||||||
|
|
||||||
taosHashCancelIterate(pJob->execTasks, pIter);
|
taosHashCancelIterate(pJob->execTasks, pIter);
|
||||||
|
|
||||||
if (task->lastMsgType == TDMT_VND_QUERY) {
|
if (task->lastMsgType == TDMT_SCH_QUERY) {
|
||||||
SQueryTableRsp rsp = {0};
|
SQueryTableRsp rsp = {0};
|
||||||
code = schHandleResponseMsg(pJob, task, TDMT_VND_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0);
|
code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0);
|
||||||
|
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -88,3 +88,12 @@ SStreamDataSubmit* streamSubmitRefClone(SStreamDataSubmit* pSubmit) {
|
||||||
memcpy(pSubmitClone, pSubmit, sizeof(SStreamDataSubmit));
|
memcpy(pSubmitClone, pSubmit, sizeof(SStreamDataSubmit));
|
||||||
return pSubmitClone;
|
return pSubmitClone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void streamDataSubmitRefDec(SStreamDataSubmit* pDataSubmit) {
|
||||||
|
int32_t ref = atomic_sub_fetch_32(pDataSubmit->dataRef, 1);
|
||||||
|
ASSERT(ref >= 0);
|
||||||
|
if (ref == 0) {
|
||||||
|
taosMemoryFree(pDataSubmit->data);
|
||||||
|
taosMemoryFree(pDataSubmit->dataRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -63,7 +63,6 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: do we need free memory?
|
|
||||||
SSDataBlock block = {0};
|
SSDataBlock block = {0};
|
||||||
assignOneDataBlock(&block, output);
|
assignOneDataBlock(&block, output);
|
||||||
block.info.childId = pTask->selfChildId;
|
block.info.childId = pTask->selfChildId;
|
||||||
|
|
|
@ -41,12 +41,3 @@ void streamQueueClose(SStreamQueue* queue) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void streamDataSubmitRefDec(SStreamDataSubmit* pDataSubmit) {
|
|
||||||
int32_t ref = atomic_sub_fetch_32(pDataSubmit->dataRef, 1);
|
|
||||||
ASSERT(ref >= 0);
|
|
||||||
if (ref == 0) {
|
|
||||||
taosMemoryFree(pDataSubmit->data);
|
|
||||||
taosMemoryFree(pDataSubmit->dataRef);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ extern "C" {
|
||||||
//
|
//
|
||||||
int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg);
|
int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg);
|
||||||
int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMsg);
|
int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMsg);
|
||||||
|
int32_t syncNodeOnAppendEntriesSnapshot2Cb(SSyncNode* ths, SyncAppendEntriesBatch* pMsg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,12 @@ extern "C" {
|
||||||
//
|
//
|
||||||
int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* pMsg);
|
int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* pMsg);
|
||||||
int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntriesReply* pMsg);
|
int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntriesReply* pMsg);
|
||||||
|
int32_t syncNodeOnAppendEntriesReplySnapshot2Cb(SSyncNode* ths, SyncAppendEntriesReply* pMsg);
|
||||||
|
|
||||||
|
typedef struct SReaderParam {
|
||||||
|
SyncIndex start;
|
||||||
|
SyncIndex end;
|
||||||
|
} SReaderParam;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ typedef struct SSyncNode {
|
||||||
char path[TSDB_FILENAME_LEN];
|
char path[TSDB_FILENAME_LEN];
|
||||||
char raftStorePath[TSDB_FILENAME_LEN * 2];
|
char raftStorePath[TSDB_FILENAME_LEN * 2];
|
||||||
char configPath[TSDB_FILENAME_LEN * 2];
|
char configPath[TSDB_FILENAME_LEN * 2];
|
||||||
|
int32_t batchSize;
|
||||||
|
|
||||||
// sync io
|
// sync io
|
||||||
SWal* pWal;
|
SWal* pWal;
|
||||||
|
@ -170,6 +171,7 @@ void syncNodeStart(SSyncNode* pSyncNode);
|
||||||
void syncNodeStartStandBy(SSyncNode* pSyncNode);
|
void syncNodeStartStandBy(SSyncNode* pSyncNode);
|
||||||
void syncNodeClose(SSyncNode* pSyncNode);
|
void syncNodeClose(SSyncNode* pSyncNode);
|
||||||
int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak);
|
int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak);
|
||||||
|
int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize);
|
||||||
|
|
||||||
// option
|
// option
|
||||||
bool syncNodeSnapshotEnable(SSyncNode* pSyncNode);
|
bool syncNodeSnapshotEnable(SSyncNode* pSyncNode);
|
||||||
|
|
|
@ -53,8 +53,10 @@ extern "C" {
|
||||||
//
|
//
|
||||||
int32_t syncNodeAppendEntriesPeers(SSyncNode* pSyncNode);
|
int32_t syncNodeAppendEntriesPeers(SSyncNode* pSyncNode);
|
||||||
int32_t syncNodeAppendEntriesPeersSnapshot(SSyncNode* pSyncNode);
|
int32_t syncNodeAppendEntriesPeersSnapshot(SSyncNode* pSyncNode);
|
||||||
|
int32_t syncNodeAppendEntriesPeersSnapshot2(SSyncNode* pSyncNode);
|
||||||
int32_t syncNodeReplicate(SSyncNode* pSyncNode);
|
int32_t syncNodeReplicate(SSyncNode* pSyncNode);
|
||||||
int32_t syncNodeAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, const SyncAppendEntries* pMsg);
|
int32_t syncNodeAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, const SyncAppendEntries* pMsg);
|
||||||
|
int32_t syncNodeAppendEntriesBatch(SSyncNode* pSyncNode, const SRaftId* destRaftId, const SyncAppendEntriesBatch* pMsg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,8 @@ typedef struct SSyncSnapshotSender {
|
||||||
bool start;
|
bool start;
|
||||||
int32_t seq;
|
int32_t seq;
|
||||||
int32_t ack;
|
int32_t ack;
|
||||||
void *pReader;
|
void * pReader;
|
||||||
void *pCurrentBlock;
|
void * pCurrentBlock;
|
||||||
int32_t blockLen;
|
int32_t blockLen;
|
||||||
SSnapshot snapshot;
|
SSnapshot snapshot;
|
||||||
SSyncCfg lastConfig;
|
SSyncCfg lastConfig;
|
||||||
|
@ -62,14 +62,14 @@ int32_t snapshotSend(SSyncSnapshotSender *pSender);
|
||||||
int32_t snapshotReSend(SSyncSnapshotSender *pSender);
|
int32_t snapshotReSend(SSyncSnapshotSender *pSender);
|
||||||
|
|
||||||
cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender);
|
cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender);
|
||||||
char *snapshotSender2Str(SSyncSnapshotSender *pSender);
|
char * snapshotSender2Str(SSyncSnapshotSender *pSender);
|
||||||
char *snapshotSender2SimpleStr(SSyncSnapshotSender *pSender, char *event);
|
char * snapshotSender2SimpleStr(SSyncSnapshotSender *pSender, char *event);
|
||||||
|
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
typedef struct SSyncSnapshotReceiver {
|
typedef struct SSyncSnapshotReceiver {
|
||||||
bool start;
|
bool start;
|
||||||
int32_t ack;
|
int32_t ack;
|
||||||
void *pWriter;
|
void * pWriter;
|
||||||
SyncTerm term;
|
SyncTerm term;
|
||||||
SyncTerm privateTerm;
|
SyncTerm privateTerm;
|
||||||
SSnapshot snapshot;
|
SSnapshot snapshot;
|
||||||
|
@ -85,8 +85,8 @@ bool snapshotReceiverIsStart(SSyncSnapshotReceiver *pReceiver);
|
||||||
void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver);
|
void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver);
|
||||||
|
|
||||||
cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver);
|
cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver);
|
||||||
char *snapshotReceiver2Str(SSyncSnapshotReceiver *pReceiver);
|
char * snapshotReceiver2Str(SSyncSnapshotReceiver *pReceiver);
|
||||||
char *snapshotReceiver2SimpleStr(SSyncSnapshotReceiver *pReceiver, char *event);
|
char * snapshotReceiver2SimpleStr(SSyncSnapshotReceiver *pReceiver, char *event);
|
||||||
|
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
// on message
|
// on message
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue