Merge branch '3.0' of https://github.com/taosdata/TDengine into test/TD-20160
This commit is contained in:
commit
be6efade2b
|
@ -175,6 +175,7 @@ def pre_test_build_mac() {
|
|||
cd ${WK}/debug
|
||||
cmake .. -DBUILD_TEST=true -DBUILD_HTTPS=false
|
||||
make -j10
|
||||
ctest -j10 || exit 7
|
||||
'''
|
||||
sh '''
|
||||
date
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
IF (DEFINED VERNUMBER)
|
||||
SET(TD_VER_NUMBER ${VERNUMBER})
|
||||
ELSE ()
|
||||
SET(TD_VER_NUMBER "3.0.1.5")
|
||||
SET(TD_VER_NUMBER "3.0.1.6")
|
||||
ENDIF ()
|
||||
|
||||
IF (DEFINED VERCOMPATIBLE)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taos-tools
|
||||
ExternalProject_Add(taos-tools
|
||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||
GIT_TAG 7321fbb
|
||||
GIT_TAG 16eb34f
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -218,9 +218,9 @@ After compiling your function into a DLL, you add it to TDengine. For more infor
|
|||
|
||||
## Sample Code
|
||||
|
||||
### Sample scalar function: [bit_and](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/bit_and.c)
|
||||
### Sample scalar function: [bit_and](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/bit_and.c)
|
||||
|
||||
The bit_add function implements bitwise addition for multiple columns. If there is only one column, the column is returned. The bit_add function ignores null values.
|
||||
The bit_and function implements bitwise addition for multiple columns. If there is only one column, the column is returned. The bit_and function ignores null values.
|
||||
|
||||
<details>
|
||||
<summary>bit_and.c</summary>
|
||||
|
@ -231,7 +231,7 @@ The bit_add function implements bitwise addition for multiple columns. If there
|
|||
|
||||
</details>
|
||||
|
||||
### Sample aggregate function: [l2norm](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/l2norm.c)
|
||||
### Sample aggregate function: [l2norm](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/l2norm.c)
|
||||
|
||||
The l2norm function finds the second-order norm for all data in the input column. This squares the values, takes a cumulative sum, and finds the square root.
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ title: Table
|
|||
You create standard tables and subtables with the `CREATE TABLE` statement.
|
||||
|
||||
```sql
|
||||
CREATE TABLE [IF NOT EXISTS] [db_name.]tb_name (create_definition [, create_definitionn] ...) [table_options]
|
||||
CREATE TABLE [IF NOT EXISTS] [db_name.]tb_name (create_definition [, create_definition] ...) [table_options]
|
||||
|
||||
CREATE TABLE create_subtable_clause
|
||||
|
||||
CREATE TABLE [IF NOT EXISTS] [db_name.]tb_name (create_definition [, create_definitionn] ...)
|
||||
[TAGS (create_definition [, create_definitionn] ...)]
|
||||
CREATE TABLE [IF NOT EXISTS] [db_name.]tb_name (create_definition [, create_definition] ...)
|
||||
[TAGS (create_definition [, create_definition] ...)]
|
||||
[table_options]
|
||||
|
||||
create_subtable_clause: {
|
||||
|
@ -195,4 +195,4 @@ This command is useful in migrating data from one TDengine cluster to another be
|
|||
|
||||
```
|
||||
DESCRIBE [db_name.]tb_name;
|
||||
```
|
||||
```
|
||||
|
|
|
@ -6,7 +6,7 @@ title: Supertable
|
|||
## Create a Supertable
|
||||
|
||||
```sql
|
||||
CREATE STABLE [IF NOT EXISTS] stb_name (create_definition [, create_definitionn] ...) TAGS (create_definition [, create_definition] ...) [table_options]
|
||||
CREATE STABLE [IF NOT EXISTS] stb_name (create_definition [, create_definition] ...) TAGS (create_definition [, create_definition] ...) [table_options]
|
||||
|
||||
create_definition:
|
||||
col_name column_definition
|
||||
|
|
|
@ -374,7 +374,11 @@ The configuration parameters for specifying super table tag columns and data col
|
|||
|
||||
### Query scenario configuration parameters
|
||||
|
||||
`filetype` must be set to `query` in the query scenario. See [General Configuration Parameters](#General Configuration Parameters) for details of this parameter and other general parameters
|
||||
`filetype` must be set to `query` in the query scenario.
|
||||
|
||||
To control the query scenario by setting `kill_slow_query_threshold` and `kill_slow_query_interval` parameters to kill the execution of slow query statements. Threshold controls exec_usec of query command will be killed by taosBenchmark after the specified time, in seconds; interval controls sleep time to avoid continuous querying of slow queries consuming CPU in seconds.
|
||||
|
||||
See [General Configuration Parameters](#General Configuration Parameters) for details of other general parameters.
|
||||
|
||||
#### Configuration parameters for executing the specified query statement
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ The parameters described in this document by the effect that they have on the sy
|
|||
| Applicable | Server only |
|
||||
| Meaning | The switch for monitoring inside server. The main object of monitoring is to collect information about load on physical nodes, including CPU usage, memory usage, disk usage, and network bandwidth. Monitoring information is sent over HTTP to the taosKeeper service specified by `monitorFqdn` and `monitorProt`.
|
||||
| Value Range | 0: monitoring disabled, 1: monitoring enabled |
|
||||
| Default | 1 |
|
||||
| Default | 0 |
|
||||
|
||||
### monitorFqdn
|
||||
|
||||
|
|
|
@ -9,12 +9,12 @@ description: 对表的各种管理操作
|
|||
`CREATE TABLE` 语句用于创建普通表和以超级表为模板创建子表。
|
||||
|
||||
```sql
|
||||
CREATE TABLE [IF NOT EXISTS] [db_name.]tb_name (create_definition [, create_definitionn] ...) [table_options]
|
||||
CREATE TABLE [IF NOT EXISTS] [db_name.]tb_name (create_definition [, create_definition] ...) [table_options]
|
||||
|
||||
CREATE TABLE create_subtable_clause
|
||||
|
||||
CREATE TABLE [IF NOT EXISTS] [db_name.]tb_name (create_definition [, create_definitionn] ...)
|
||||
[TAGS (create_definition [, create_definitionn] ...)]
|
||||
CREATE TABLE [IF NOT EXISTS] [db_name.]tb_name (create_definition [, create_definition] ...)
|
||||
[TAGS (create_definition [, create_definition] ...)]
|
||||
[table_options]
|
||||
|
||||
create_subtable_clause: {
|
||||
|
|
|
@ -7,7 +7,7 @@ description: 对超级表的各种管理操作
|
|||
## 创建超级表
|
||||
|
||||
```sql
|
||||
CREATE STABLE [IF NOT EXISTS] stb_name (create_definition [, create_definitionn] ...) TAGS (create_definition [, create_definition] ...) [table_options]
|
||||
CREATE STABLE [IF NOT EXISTS] stb_name (create_definition [, create_definition] ...) TAGS (create_definition [, create_definition] ...) [table_options]
|
||||
|
||||
create_definition:
|
||||
col_name column_definition
|
||||
|
|
|
@ -224,7 +224,7 @@ GROUP BY 子句中的表达式可以包含表或视图中的任何列,这些
|
|||
该子句对行进行分组,但不保证结果集的顺序。若要对分组进行排序,请使用 ORDER BY 子句
|
||||
|
||||
|
||||
## PARTITON BY
|
||||
## PARTITION BY
|
||||
|
||||
PARTITION BY 子句是 TDengine 特色语法,按 part_list 对数据进行切分,在每个切分的分片中进行计算。
|
||||
|
||||
|
|
|
@ -211,10 +211,10 @@ SHOW USERS;
|
|||
|
||||
显示当前系统中所有用户的信息。包括用户自定义的用户和系统默认用户。
|
||||
|
||||
## SHOW VARIABLES
|
||||
## SHOW CLUSTER VARIABLES(3.0.1.6 之前为 SHOW VARIABLES)
|
||||
|
||||
```sql
|
||||
SHOW VARIABLES;
|
||||
SHOW CLUSTER VARIABLES;
|
||||
SHOW DNODE dnode_id VARIABLES;
|
||||
```
|
||||
|
||||
|
|
|
@ -374,7 +374,11 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\)
|
|||
|
||||
### 查询场景配置参数
|
||||
|
||||
查询场景下 `filetype` 必须设置为 `query`,该参数及其它通用参数详见[通用配置参数](#通用配置参数)
|
||||
查询场景下 `filetype` 必须设置为 `query`。
|
||||
|
||||
查询场景可以通过设置 `kill_slow_query_threshold` 和 `kill_slow_query_interval` 参数来控制杀掉慢查询语句的执行,threshold 控制如果 exec_usec 超过指定时间的查询将被 taosBenchmark 杀掉,单位为秒;interval 控制休眠时间,避免持续查询慢查询消耗 CPU ,单位为秒。
|
||||
|
||||
其它通用参数详见[通用配置参数](#通用配置参数)。
|
||||
|
||||
#### 执行指定查询语句的配置参数
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ taos --dump-config
|
|||
| 适用范围 | 仅服务端适用 |
|
||||
| 含义 | 服务器内部的系统监控开关。监控主要负责收集物理节点的负载状况,包括 CPU、内存、硬盘、网络带宽的监控记录,监控信息将通过 HTTP 协议发送给由 `monitorFqdn` 和 `monitorProt` 指定的 TaosKeeper 监控服务 |
|
||||
| 取值范围 | 0:关闭监控服务, 1:激活监控服务。 |
|
||||
| 缺省值 | 1 |
|
||||
| 缺省值 | 0 |
|
||||
|
||||
### monitorFqdn
|
||||
|
||||
|
|
|
@ -119,12 +119,16 @@ extern SDiskCfg tsDiskCfg[];
|
|||
// udf
|
||||
extern bool tsStartUdfd;
|
||||
extern char tsUdfdResFuncs[];
|
||||
extern char tsUdfdLdLibPath[];
|
||||
|
||||
// schemaless
|
||||
extern char tsSmlChildTableName[];
|
||||
extern char tsSmlTagName[];
|
||||
extern bool tsSmlDataFormat;
|
||||
|
||||
// wal
|
||||
extern int64_t tsWalFsyncDataSizeLimit;
|
||||
|
||||
// internal
|
||||
extern int32_t tsTransPullupInterval;
|
||||
extern int32_t tsMqRebalanceInterval;
|
||||
|
|
|
@ -57,9 +57,11 @@ extern int32_t tMsgDict[];
|
|||
#define TMSG_SEG_SEQ(TYPE) ((TYPE)&0xff)
|
||||
#define TMSG_INFO(TYPE) \
|
||||
((TYPE) < TDMT_DND_MAX_MSG || (TYPE) < TDMT_MND_MAX_MSG || (TYPE) < TDMT_VND_MAX_MSG || (TYPE) < TDMT_SCH_MAX_MSG || \
|
||||
(TYPE) < TDMT_STREAM_MAX_MSG || (TYPE) < TDMT_MON_MAX_MSG || (TYPE) < TDMT_SYNC_MAX_MSG) \
|
||||
(TYPE) < TDMT_STREAM_MAX_MSG || (TYPE) < TDMT_MON_MAX_MSG || (TYPE) < TDMT_SYNC_MAX_MSG) || \
|
||||
(TYPE) < TDMT_VND_STREAM_MSG || (TYPE) < TDMT_VND_TMQ_MSG \
|
||||
? tMsgInfo[tMsgDict[TMSG_SEG_CODE(TYPE)] + TMSG_SEG_SEQ(TYPE)] \
|
||||
: 0
|
||||
|
||||
#define TMSG_INDEX(TYPE) (tMsgDict[TMSG_SEG_CODE(TYPE)] + TMSG_SEG_SEQ(TYPE))
|
||||
|
||||
typedef uint16_t tmsg_t;
|
||||
|
@ -295,7 +297,6 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
int32_t code;
|
||||
int8_t hashMeta;
|
||||
int64_t uid;
|
||||
char* tblFName;
|
||||
int32_t numOfRows;
|
||||
|
@ -1126,6 +1127,7 @@ typedef struct {
|
|||
SQnodeLoad qload;
|
||||
SClusterCfg clusterCfg;
|
||||
SArray* pVloads; // array of SVnodeLoad
|
||||
int32_t statusSeq;
|
||||
} SStatusReq;
|
||||
|
||||
int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
|
||||
|
@ -1147,6 +1149,7 @@ typedef struct {
|
|||
int64_t dnodeVer;
|
||||
SDnodeCfg dnodeCfg;
|
||||
SArray* pDnodeEps; // Array of SDnodeEp
|
||||
int32_t statusSeq;
|
||||
} SStatusRsp;
|
||||
|
||||
int32_t tSerializeSStatusRsp(void* buf, int32_t bufLen, SStatusRsp* pRsp);
|
||||
|
@ -1478,6 +1481,7 @@ typedef struct {
|
|||
int32_t dnodeId;
|
||||
char fqdn[TSDB_FQDN_LEN];
|
||||
int32_t port;
|
||||
int8_t force;
|
||||
} SDropDnodeReq;
|
||||
|
||||
int32_t tSerializeSDropDnodeReq(void* buf, int32_t bufLen, SDropDnodeReq* pReq);
|
||||
|
|
|
@ -138,18 +138,18 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_MND_GET_TABLE_INDEX, "get-table-index", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_BATCH_META, "batch-meta", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TABLE_CFG, "table-cfg", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_TOPIC, "create-topic", SMCreateTopicReq, SMCreateTopicRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_TOPIC, "alter-topic", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_TOPIC, "drop-topic", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_SUBSCRIBE, "subscribe", SCMSubscribeReq, SCMSubscribeRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_ASK_EP, "ask-ep", SMqAskEpReq, SMqAskEpRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_CONSUMER_LOST, "consumer-lost", SMqConsumerLostMsg, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_CONSUMER_RECOVER, "consumer-recover", SMqConsumerRecoverMsg, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_HB, "consumer-hb", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_DO_REBALANCE, "do-rebalance", SMqDoRebalanceMsg, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_DROP_CGROUP, "drop-cgroup", SMqDropCGroupReq, SMqDropCGroupRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_COMMIT_OFFSET, "mnode-commit-offset", SMqCMCommitOffsetReq, SMqCMCommitOffsetRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_TIMER, "mq-tmr", SMTimerReq, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_CREATE_TOPIC, "create-topic", SMCreateTopicReq, SMCreateTopicRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_UNUSED1, "unused", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_DROP_TOPIC, "drop-topic", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_SUBSCRIBE, "subscribe", SCMSubscribeReq, SCMSubscribeRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_ASK_EP, "ask-ep", SMqAskEpReq, SMqAskEpRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_CONSUMER_LOST, "consumer-lost", SMqConsumerLostMsg, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_CONSUMER_RECOVER, "consumer-recover", SMqConsumerRecoverMsg, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_HB, "consumer-hb", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_DO_REBALANCE, "do-rebalance", SMqDoRebalanceMsg, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_DROP_CGROUP, "drop-cgroup", SMqDropCGroupReq, SMqDropCGroupRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_UNUSED2, "unused2", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_TIMER, "mq-tmr", SMTimerReq, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TELEM_TIMER, "telem-tmr", SMTimerReq, SMTimerReq)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TRANS_TIMER, "trans-tmr", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TTL_TIMER, "ttl-tmr", NULL, NULL)
|
||||
|
@ -186,21 +186,21 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_STB, "vnode-create-stb", SVCreateStbReq, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_STB, "vnode-alter-stb", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_STB, "vnode-drop-stb", SVDropStbReq, NULL)
|
||||
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_COMMIT_OFFSET, "vnode-commit-offset", STqOffset, STqOffset)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_ADD_CHECK_INFO, "vnode-add-check-info", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_DELETE_CHECK_INFO, "vnode-delete-check-info", 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_DROP_TOPIC, "vnode-drop-topic", NULL, NULL)
|
||||
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_STREAM_TRIGGER, "vnode-stream-trigger", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_DISPATCH_WRITE, "vnode-stream-task-dispatch-write", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_RECOVER_STEP1, "vnode-stream-recover1", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_RECOVER_STEP2, "vnode-stream-recover2", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_RECOVER_FINISH, "vnode-stream-finish", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_UNUSED1, "vnode-unused1", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_UNUSED2, "vnode-unused2", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_UNUSED3, "vnode-unused3", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_UNUSED4, "vnode-unused4", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_UNUSED5, "vnode-unused5", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_UNUSED6, "vnode-unused6", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_UNUSED7, "vnode-unused7", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_UNUSED8, "vnode-unused8", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_UNUSED9, "vnode-unused9", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_UNUSED10, "vnode-unused10", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_UNUSED11, "vnode-unused11", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_UNUSED12, "vnode-unused12", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_UNUSED13, "vnode-unused13", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_UNUSED14, "vnode-unused14", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_UNUSED15, "vnode-unused15", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_SMA, "vnode-create-sma", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_SMA, "vnode-cancel-sma", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_SMA, "vnode-drop-sma", NULL, NULL)
|
||||
|
@ -232,13 +232,16 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_SCH_LINK_BROKEN, "link-broken", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SCH_MAX_MSG, "sch-max", NULL, NULL)
|
||||
|
||||
|
||||
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_DROP, "stream-task-drop", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_RUN, "stream-task-run", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_DISPATCH, "stream-task-dispatch", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_RECOVER, "stream-task-recover", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_STREAM_UNUSED1, "stream-unused1", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_STREAM_RETRIEVE, "stream-retrieve", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_STREAM_RECOVER_FINISH, "vnode-stream-finish", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_CHECK, "vnode-stream-task-check", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_STREAM_MAX_MSG, "stream-max", NULL, NULL)
|
||||
|
||||
TD_NEW_MSG_SEG(TDMT_MON_MSG)
|
||||
|
@ -270,8 +273,26 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_SYNC_HEARTBEAT, "sync-heartbeat", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_HEARTBEAT_REPLY, "sync-heartbeat-reply", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_LOCAL_CMD, "sync-local-cmd", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_PRE_SNAPSHOT, "sync-pre-snapshot", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_PRE_SNAPSHOT_REPLY, "sync-pre-snapshot-reply", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_SYNC_MAX_MSG, "sync-max", NULL, NULL)
|
||||
|
||||
TD_NEW_MSG_SEG(TDMT_VND_STREAM_MSG)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TRIGGER, "vnode-stream-trigger", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_RECOVER_STEP1, "vnode-stream-recover1", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_RECOVER_STEP2, "vnode-stream-recover2", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_MAX_MSG, "vnd-stream-max", NULL, NULL)
|
||||
|
||||
TD_NEW_MSG_SEG(TDMT_VND_TMQ_MSG)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_SUBSCRIBE, "vnode-tmq-subscribe", SMqRebVgReq, SMqRebVgRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_DELETE_SUB, "vnode-tmq-delete-sub", SMqVDeleteReq, SMqVDeleteRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_COMMIT_OFFSET, "vnode-tmq-commit-offset", STqOffset, STqOffset)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_ADD_CHECKINFO, "vnode-tmq-add-checkinfo", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_DEL_CHECKINFO, "vnode-del-checkinfo", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_CONSUME, "vnode-tmq-consume", SMqPollReq, SMqDataBlkRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_MAX_MSG, "vnd-tmq-max", NULL, NULL)
|
||||
|
||||
|
||||
#if defined(TD_MSG_NUMBER_)
|
||||
TDMT_MAX
|
||||
#endif
|
||||
|
|
|
@ -72,13 +72,13 @@ bool tNameTbNameEqual(SName* left, SName* right);
|
|||
|
||||
typedef struct {
|
||||
// input
|
||||
SArray* tags; // element is SSmlKv
|
||||
const char* sTableName; // super table name
|
||||
uint8_t sTableNameLen; // the length of super table name
|
||||
SArray* tags; // element is SSmlKv
|
||||
const char* stbFullName; // super table name
|
||||
uint8_t stbFullNameLen; // the length of super table name
|
||||
|
||||
// output
|
||||
char* childTableName; // must have size of TSDB_TABLE_NAME_LEN;
|
||||
uint64_t uid; // child table uid, may be useful
|
||||
char* ctbShortName; // must have size of TSDB_TABLE_NAME_LEN;
|
||||
uint64_t uid; // child table uid, may be useful
|
||||
} RandTableName;
|
||||
|
||||
void buildChildTableName(RandTableName* rName);
|
||||
|
|
|
@ -66,280 +66,281 @@
|
|||
#define TK_PORT 48
|
||||
#define TK_DNODES 49
|
||||
#define TK_NK_IPTOKEN 50
|
||||
#define TK_LOCAL 51
|
||||
#define TK_QNODE 52
|
||||
#define TK_BNODE 53
|
||||
#define TK_SNODE 54
|
||||
#define TK_MNODE 55
|
||||
#define TK_DATABASE 56
|
||||
#define TK_USE 57
|
||||
#define TK_FLUSH 58
|
||||
#define TK_TRIM 59
|
||||
#define TK_IF 60
|
||||
#define TK_NOT 61
|
||||
#define TK_EXISTS 62
|
||||
#define TK_BUFFER 63
|
||||
#define TK_CACHEMODEL 64
|
||||
#define TK_CACHESIZE 65
|
||||
#define TK_COMP 66
|
||||
#define TK_DURATION 67
|
||||
#define TK_NK_VARIABLE 68
|
||||
#define TK_MAXROWS 69
|
||||
#define TK_MINROWS 70
|
||||
#define TK_KEEP 71
|
||||
#define TK_PAGES 72
|
||||
#define TK_PAGESIZE 73
|
||||
#define TK_TSDB_PAGESIZE 74
|
||||
#define TK_PRECISION 75
|
||||
#define TK_REPLICA 76
|
||||
#define TK_STRICT 77
|
||||
#define TK_VGROUPS 78
|
||||
#define TK_SINGLE_STABLE 79
|
||||
#define TK_RETENTIONS 80
|
||||
#define TK_SCHEMALESS 81
|
||||
#define TK_WAL_LEVEL 82
|
||||
#define TK_WAL_FSYNC_PERIOD 83
|
||||
#define TK_WAL_RETENTION_PERIOD 84
|
||||
#define TK_WAL_RETENTION_SIZE 85
|
||||
#define TK_WAL_ROLL_PERIOD 86
|
||||
#define TK_WAL_SEGMENT_SIZE 87
|
||||
#define TK_STT_TRIGGER 88
|
||||
#define TK_TABLE_PREFIX 89
|
||||
#define TK_TABLE_SUFFIX 90
|
||||
#define TK_NK_COLON 91
|
||||
#define TK_MAX_SPEED 92
|
||||
#define TK_TABLE 93
|
||||
#define TK_NK_LP 94
|
||||
#define TK_NK_RP 95
|
||||
#define TK_STABLE 96
|
||||
#define TK_ADD 97
|
||||
#define TK_COLUMN 98
|
||||
#define TK_MODIFY 99
|
||||
#define TK_RENAME 100
|
||||
#define TK_TAG 101
|
||||
#define TK_SET 102
|
||||
#define TK_NK_EQ 103
|
||||
#define TK_USING 104
|
||||
#define TK_TAGS 105
|
||||
#define TK_COMMENT 106
|
||||
#define TK_BOOL 107
|
||||
#define TK_TINYINT 108
|
||||
#define TK_SMALLINT 109
|
||||
#define TK_INT 110
|
||||
#define TK_INTEGER 111
|
||||
#define TK_BIGINT 112
|
||||
#define TK_FLOAT 113
|
||||
#define TK_DOUBLE 114
|
||||
#define TK_BINARY 115
|
||||
#define TK_TIMESTAMP 116
|
||||
#define TK_NCHAR 117
|
||||
#define TK_UNSIGNED 118
|
||||
#define TK_JSON 119
|
||||
#define TK_VARCHAR 120
|
||||
#define TK_MEDIUMBLOB 121
|
||||
#define TK_BLOB 122
|
||||
#define TK_VARBINARY 123
|
||||
#define TK_DECIMAL 124
|
||||
#define TK_MAX_DELAY 125
|
||||
#define TK_WATERMARK 126
|
||||
#define TK_ROLLUP 127
|
||||
#define TK_TTL 128
|
||||
#define TK_SMA 129
|
||||
#define TK_FIRST 130
|
||||
#define TK_LAST 131
|
||||
#define TK_SHOW 132
|
||||
#define TK_DATABASES 133
|
||||
#define TK_TABLES 134
|
||||
#define TK_STABLES 135
|
||||
#define TK_MNODES 136
|
||||
#define TK_QNODES 137
|
||||
#define TK_FUNCTIONS 138
|
||||
#define TK_INDEXES 139
|
||||
#define TK_ACCOUNTS 140
|
||||
#define TK_APPS 141
|
||||
#define TK_CONNECTIONS 142
|
||||
#define TK_LICENCES 143
|
||||
#define TK_GRANTS 144
|
||||
#define TK_QUERIES 145
|
||||
#define TK_SCORES 146
|
||||
#define TK_TOPICS 147
|
||||
#define TK_VARIABLES 148
|
||||
#define TK_CLUSTER 149
|
||||
#define TK_BNODES 150
|
||||
#define TK_SNODES 151
|
||||
#define TK_TRANSACTIONS 152
|
||||
#define TK_DISTRIBUTED 153
|
||||
#define TK_CONSUMERS 154
|
||||
#define TK_SUBSCRIPTIONS 155
|
||||
#define TK_VNODES 156
|
||||
#define TK_LIKE 157
|
||||
#define TK_INDEX 158
|
||||
#define TK_FUNCTION 159
|
||||
#define TK_INTERVAL 160
|
||||
#define TK_TOPIC 161
|
||||
#define TK_AS 162
|
||||
#define TK_WITH 163
|
||||
#define TK_META 164
|
||||
#define TK_CONSUMER 165
|
||||
#define TK_GROUP 166
|
||||
#define TK_DESC 167
|
||||
#define TK_DESCRIBE 168
|
||||
#define TK_RESET 169
|
||||
#define TK_QUERY 170
|
||||
#define TK_CACHE 171
|
||||
#define TK_EXPLAIN 172
|
||||
#define TK_ANALYZE 173
|
||||
#define TK_VERBOSE 174
|
||||
#define TK_NK_BOOL 175
|
||||
#define TK_RATIO 176
|
||||
#define TK_NK_FLOAT 177
|
||||
#define TK_OUTPUTTYPE 178
|
||||
#define TK_AGGREGATE 179
|
||||
#define TK_BUFSIZE 180
|
||||
#define TK_STREAM 181
|
||||
#define TK_INTO 182
|
||||
#define TK_TRIGGER 183
|
||||
#define TK_AT_ONCE 184
|
||||
#define TK_WINDOW_CLOSE 185
|
||||
#define TK_IGNORE 186
|
||||
#define TK_EXPIRED 187
|
||||
#define TK_FILL_HISTORY 188
|
||||
#define TK_SUBTABLE 189
|
||||
#define TK_KILL 190
|
||||
#define TK_CONNECTION 191
|
||||
#define TK_TRANSACTION 192
|
||||
#define TK_BALANCE 193
|
||||
#define TK_VGROUP 194
|
||||
#define TK_MERGE 195
|
||||
#define TK_REDISTRIBUTE 196
|
||||
#define TK_SPLIT 197
|
||||
#define TK_DELETE 198
|
||||
#define TK_INSERT 199
|
||||
#define TK_NULL 200
|
||||
#define TK_NK_QUESTION 201
|
||||
#define TK_NK_ARROW 202
|
||||
#define TK_ROWTS 203
|
||||
#define TK_TBNAME 204
|
||||
#define TK_QSTART 205
|
||||
#define TK_QEND 206
|
||||
#define TK_QDURATION 207
|
||||
#define TK_WSTART 208
|
||||
#define TK_WEND 209
|
||||
#define TK_WDURATION 210
|
||||
#define TK_IROWTS 211
|
||||
#define TK_QTAGS 212
|
||||
#define TK_CAST 213
|
||||
#define TK_NOW 214
|
||||
#define TK_TODAY 215
|
||||
#define TK_TIMEZONE 216
|
||||
#define TK_CLIENT_VERSION 217
|
||||
#define TK_SERVER_VERSION 218
|
||||
#define TK_SERVER_STATUS 219
|
||||
#define TK_CURRENT_USER 220
|
||||
#define TK_COUNT 221
|
||||
#define TK_LAST_ROW 222
|
||||
#define TK_CASE 223
|
||||
#define TK_END 224
|
||||
#define TK_WHEN 225
|
||||
#define TK_THEN 226
|
||||
#define TK_ELSE 227
|
||||
#define TK_BETWEEN 228
|
||||
#define TK_IS 229
|
||||
#define TK_NK_LT 230
|
||||
#define TK_NK_GT 231
|
||||
#define TK_NK_LE 232
|
||||
#define TK_NK_GE 233
|
||||
#define TK_NK_NE 234
|
||||
#define TK_MATCH 235
|
||||
#define TK_NMATCH 236
|
||||
#define TK_CONTAINS 237
|
||||
#define TK_IN 238
|
||||
#define TK_JOIN 239
|
||||
#define TK_INNER 240
|
||||
#define TK_SELECT 241
|
||||
#define TK_DISTINCT 242
|
||||
#define TK_WHERE 243
|
||||
#define TK_PARTITION 244
|
||||
#define TK_BY 245
|
||||
#define TK_SESSION 246
|
||||
#define TK_STATE_WINDOW 247
|
||||
#define TK_SLIDING 248
|
||||
#define TK_FILL 249
|
||||
#define TK_VALUE 250
|
||||
#define TK_NONE 251
|
||||
#define TK_PREV 252
|
||||
#define TK_LINEAR 253
|
||||
#define TK_NEXT 254
|
||||
#define TK_HAVING 255
|
||||
#define TK_RANGE 256
|
||||
#define TK_EVERY 257
|
||||
#define TK_ORDER 258
|
||||
#define TK_SLIMIT 259
|
||||
#define TK_SOFFSET 260
|
||||
#define TK_LIMIT 261
|
||||
#define TK_OFFSET 262
|
||||
#define TK_ASC 263
|
||||
#define TK_NULLS 264
|
||||
#define TK_ABORT 265
|
||||
#define TK_AFTER 266
|
||||
#define TK_ATTACH 267
|
||||
#define TK_BEFORE 268
|
||||
#define TK_BEGIN 269
|
||||
#define TK_BITAND 270
|
||||
#define TK_BITNOT 271
|
||||
#define TK_BITOR 272
|
||||
#define TK_BLOCKS 273
|
||||
#define TK_CHANGE 274
|
||||
#define TK_COMMA 275
|
||||
#define TK_COMPACT 276
|
||||
#define TK_CONCAT 277
|
||||
#define TK_CONFLICT 278
|
||||
#define TK_COPY 279
|
||||
#define TK_DEFERRED 280
|
||||
#define TK_DELIMITERS 281
|
||||
#define TK_DETACH 282
|
||||
#define TK_DIVIDE 283
|
||||
#define TK_DOT 284
|
||||
#define TK_EACH 285
|
||||
#define TK_FAIL 286
|
||||
#define TK_FILE 287
|
||||
#define TK_FOR 288
|
||||
#define TK_GLOB 289
|
||||
#define TK_ID 290
|
||||
#define TK_IMMEDIATE 291
|
||||
#define TK_IMPORT 292
|
||||
#define TK_INITIALLY 293
|
||||
#define TK_INSTEAD 294
|
||||
#define TK_ISNULL 295
|
||||
#define TK_KEY 296
|
||||
#define TK_MODULES 297
|
||||
#define TK_NK_BITNOT 298
|
||||
#define TK_NK_SEMI 299
|
||||
#define TK_NOTNULL 300
|
||||
#define TK_OF 301
|
||||
#define TK_PLUS 302
|
||||
#define TK_PRIVILEGE 303
|
||||
#define TK_RAISE 304
|
||||
#define TK_REPLACE 305
|
||||
#define TK_RESTRICT 306
|
||||
#define TK_ROW 307
|
||||
#define TK_SEMI 308
|
||||
#define TK_STAR 309
|
||||
#define TK_STATEMENT 310
|
||||
#define TK_STRING 311
|
||||
#define TK_TIMES 312
|
||||
#define TK_UPDATE 313
|
||||
#define TK_VALUES 314
|
||||
#define TK_VARIABLE 315
|
||||
#define TK_VIEW 316
|
||||
#define TK_WAL 317
|
||||
#define TK_FORCE 51
|
||||
#define TK_LOCAL 52
|
||||
#define TK_QNODE 53
|
||||
#define TK_BNODE 54
|
||||
#define TK_SNODE 55
|
||||
#define TK_MNODE 56
|
||||
#define TK_DATABASE 57
|
||||
#define TK_USE 58
|
||||
#define TK_FLUSH 59
|
||||
#define TK_TRIM 60
|
||||
#define TK_IF 61
|
||||
#define TK_NOT 62
|
||||
#define TK_EXISTS 63
|
||||
#define TK_BUFFER 64
|
||||
#define TK_CACHEMODEL 65
|
||||
#define TK_CACHESIZE 66
|
||||
#define TK_COMP 67
|
||||
#define TK_DURATION 68
|
||||
#define TK_NK_VARIABLE 69
|
||||
#define TK_MAXROWS 70
|
||||
#define TK_MINROWS 71
|
||||
#define TK_KEEP 72
|
||||
#define TK_PAGES 73
|
||||
#define TK_PAGESIZE 74
|
||||
#define TK_TSDB_PAGESIZE 75
|
||||
#define TK_PRECISION 76
|
||||
#define TK_REPLICA 77
|
||||
#define TK_STRICT 78
|
||||
#define TK_VGROUPS 79
|
||||
#define TK_SINGLE_STABLE 80
|
||||
#define TK_RETENTIONS 81
|
||||
#define TK_SCHEMALESS 82
|
||||
#define TK_WAL_LEVEL 83
|
||||
#define TK_WAL_FSYNC_PERIOD 84
|
||||
#define TK_WAL_RETENTION_PERIOD 85
|
||||
#define TK_WAL_RETENTION_SIZE 86
|
||||
#define TK_WAL_ROLL_PERIOD 87
|
||||
#define TK_WAL_SEGMENT_SIZE 88
|
||||
#define TK_STT_TRIGGER 89
|
||||
#define TK_TABLE_PREFIX 90
|
||||
#define TK_TABLE_SUFFIX 91
|
||||
#define TK_NK_COLON 92
|
||||
#define TK_MAX_SPEED 93
|
||||
#define TK_TABLE 94
|
||||
#define TK_NK_LP 95
|
||||
#define TK_NK_RP 96
|
||||
#define TK_STABLE 97
|
||||
#define TK_ADD 98
|
||||
#define TK_COLUMN 99
|
||||
#define TK_MODIFY 100
|
||||
#define TK_RENAME 101
|
||||
#define TK_TAG 102
|
||||
#define TK_SET 103
|
||||
#define TK_NK_EQ 104
|
||||
#define TK_USING 105
|
||||
#define TK_TAGS 106
|
||||
#define TK_COMMENT 107
|
||||
#define TK_BOOL 108
|
||||
#define TK_TINYINT 109
|
||||
#define TK_SMALLINT 110
|
||||
#define TK_INT 111
|
||||
#define TK_INTEGER 112
|
||||
#define TK_BIGINT 113
|
||||
#define TK_FLOAT 114
|
||||
#define TK_DOUBLE 115
|
||||
#define TK_BINARY 116
|
||||
#define TK_TIMESTAMP 117
|
||||
#define TK_NCHAR 118
|
||||
#define TK_UNSIGNED 119
|
||||
#define TK_JSON 120
|
||||
#define TK_VARCHAR 121
|
||||
#define TK_MEDIUMBLOB 122
|
||||
#define TK_BLOB 123
|
||||
#define TK_VARBINARY 124
|
||||
#define TK_DECIMAL 125
|
||||
#define TK_MAX_DELAY 126
|
||||
#define TK_WATERMARK 127
|
||||
#define TK_ROLLUP 128
|
||||
#define TK_TTL 129
|
||||
#define TK_SMA 130
|
||||
#define TK_FIRST 131
|
||||
#define TK_LAST 132
|
||||
#define TK_SHOW 133
|
||||
#define TK_DATABASES 134
|
||||
#define TK_TABLES 135
|
||||
#define TK_STABLES 136
|
||||
#define TK_MNODES 137
|
||||
#define TK_QNODES 138
|
||||
#define TK_FUNCTIONS 139
|
||||
#define TK_INDEXES 140
|
||||
#define TK_ACCOUNTS 141
|
||||
#define TK_APPS 142
|
||||
#define TK_CONNECTIONS 143
|
||||
#define TK_LICENCES 144
|
||||
#define TK_GRANTS 145
|
||||
#define TK_QUERIES 146
|
||||
#define TK_SCORES 147
|
||||
#define TK_TOPICS 148
|
||||
#define TK_VARIABLES 149
|
||||
#define TK_CLUSTER 150
|
||||
#define TK_BNODES 151
|
||||
#define TK_SNODES 152
|
||||
#define TK_TRANSACTIONS 153
|
||||
#define TK_DISTRIBUTED 154
|
||||
#define TK_CONSUMERS 155
|
||||
#define TK_SUBSCRIPTIONS 156
|
||||
#define TK_VNODES 157
|
||||
#define TK_LIKE 158
|
||||
#define TK_INDEX 159
|
||||
#define TK_FUNCTION 160
|
||||
#define TK_INTERVAL 161
|
||||
#define TK_TOPIC 162
|
||||
#define TK_AS 163
|
||||
#define TK_WITH 164
|
||||
#define TK_META 165
|
||||
#define TK_CONSUMER 166
|
||||
#define TK_GROUP 167
|
||||
#define TK_DESC 168
|
||||
#define TK_DESCRIBE 169
|
||||
#define TK_RESET 170
|
||||
#define TK_QUERY 171
|
||||
#define TK_CACHE 172
|
||||
#define TK_EXPLAIN 173
|
||||
#define TK_ANALYZE 174
|
||||
#define TK_VERBOSE 175
|
||||
#define TK_NK_BOOL 176
|
||||
#define TK_RATIO 177
|
||||
#define TK_NK_FLOAT 178
|
||||
#define TK_OUTPUTTYPE 179
|
||||
#define TK_AGGREGATE 180
|
||||
#define TK_BUFSIZE 181
|
||||
#define TK_STREAM 182
|
||||
#define TK_INTO 183
|
||||
#define TK_TRIGGER 184
|
||||
#define TK_AT_ONCE 185
|
||||
#define TK_WINDOW_CLOSE 186
|
||||
#define TK_IGNORE 187
|
||||
#define TK_EXPIRED 188
|
||||
#define TK_FILL_HISTORY 189
|
||||
#define TK_SUBTABLE 190
|
||||
#define TK_KILL 191
|
||||
#define TK_CONNECTION 192
|
||||
#define TK_TRANSACTION 193
|
||||
#define TK_BALANCE 194
|
||||
#define TK_VGROUP 195
|
||||
#define TK_MERGE 196
|
||||
#define TK_REDISTRIBUTE 197
|
||||
#define TK_SPLIT 198
|
||||
#define TK_DELETE 199
|
||||
#define TK_INSERT 200
|
||||
#define TK_NULL 201
|
||||
#define TK_NK_QUESTION 202
|
||||
#define TK_NK_ARROW 203
|
||||
#define TK_ROWTS 204
|
||||
#define TK_TBNAME 205
|
||||
#define TK_QSTART 206
|
||||
#define TK_QEND 207
|
||||
#define TK_QDURATION 208
|
||||
#define TK_WSTART 209
|
||||
#define TK_WEND 210
|
||||
#define TK_WDURATION 211
|
||||
#define TK_IROWTS 212
|
||||
#define TK_QTAGS 213
|
||||
#define TK_CAST 214
|
||||
#define TK_NOW 215
|
||||
#define TK_TODAY 216
|
||||
#define TK_TIMEZONE 217
|
||||
#define TK_CLIENT_VERSION 218
|
||||
#define TK_SERVER_VERSION 219
|
||||
#define TK_SERVER_STATUS 220
|
||||
#define TK_CURRENT_USER 221
|
||||
#define TK_COUNT 222
|
||||
#define TK_LAST_ROW 223
|
||||
#define TK_CASE 224
|
||||
#define TK_END 225
|
||||
#define TK_WHEN 226
|
||||
#define TK_THEN 227
|
||||
#define TK_ELSE 228
|
||||
#define TK_BETWEEN 229
|
||||
#define TK_IS 230
|
||||
#define TK_NK_LT 231
|
||||
#define TK_NK_GT 232
|
||||
#define TK_NK_LE 233
|
||||
#define TK_NK_GE 234
|
||||
#define TK_NK_NE 235
|
||||
#define TK_MATCH 236
|
||||
#define TK_NMATCH 237
|
||||
#define TK_CONTAINS 238
|
||||
#define TK_IN 239
|
||||
#define TK_JOIN 240
|
||||
#define TK_INNER 241
|
||||
#define TK_SELECT 242
|
||||
#define TK_DISTINCT 243
|
||||
#define TK_WHERE 244
|
||||
#define TK_PARTITION 245
|
||||
#define TK_BY 246
|
||||
#define TK_SESSION 247
|
||||
#define TK_STATE_WINDOW 248
|
||||
#define TK_SLIDING 249
|
||||
#define TK_FILL 250
|
||||
#define TK_VALUE 251
|
||||
#define TK_NONE 252
|
||||
#define TK_PREV 253
|
||||
#define TK_LINEAR 254
|
||||
#define TK_NEXT 255
|
||||
#define TK_HAVING 256
|
||||
#define TK_RANGE 257
|
||||
#define TK_EVERY 258
|
||||
#define TK_ORDER 259
|
||||
#define TK_SLIMIT 260
|
||||
#define TK_SOFFSET 261
|
||||
#define TK_LIMIT 262
|
||||
#define TK_OFFSET 263
|
||||
#define TK_ASC 264
|
||||
#define TK_NULLS 265
|
||||
#define TK_ABORT 266
|
||||
#define TK_AFTER 267
|
||||
#define TK_ATTACH 268
|
||||
#define TK_BEFORE 269
|
||||
#define TK_BEGIN 270
|
||||
#define TK_BITAND 271
|
||||
#define TK_BITNOT 272
|
||||
#define TK_BITOR 273
|
||||
#define TK_BLOCKS 274
|
||||
#define TK_CHANGE 275
|
||||
#define TK_COMMA 276
|
||||
#define TK_COMPACT 277
|
||||
#define TK_CONCAT 278
|
||||
#define TK_CONFLICT 279
|
||||
#define TK_COPY 280
|
||||
#define TK_DEFERRED 281
|
||||
#define TK_DELIMITERS 282
|
||||
#define TK_DETACH 283
|
||||
#define TK_DIVIDE 284
|
||||
#define TK_DOT 285
|
||||
#define TK_EACH 286
|
||||
#define TK_FAIL 287
|
||||
#define TK_FILE 288
|
||||
#define TK_FOR 289
|
||||
#define TK_GLOB 290
|
||||
#define TK_ID 291
|
||||
#define TK_IMMEDIATE 292
|
||||
#define TK_IMPORT 293
|
||||
#define TK_INITIALLY 294
|
||||
#define TK_INSTEAD 295
|
||||
#define TK_ISNULL 296
|
||||
#define TK_KEY 297
|
||||
#define TK_MODULES 298
|
||||
#define TK_NK_BITNOT 299
|
||||
#define TK_NK_SEMI 300
|
||||
#define TK_NOTNULL 301
|
||||
#define TK_OF 302
|
||||
#define TK_PLUS 303
|
||||
#define TK_PRIVILEGE 304
|
||||
#define TK_RAISE 305
|
||||
#define TK_REPLACE 306
|
||||
#define TK_RESTRICT 307
|
||||
#define TK_ROW 308
|
||||
#define TK_SEMI 309
|
||||
#define TK_STAR 310
|
||||
#define TK_STATEMENT 311
|
||||
#define TK_STRING 312
|
||||
#define TK_TIMES 313
|
||||
#define TK_UPDATE 314
|
||||
#define TK_VALUES 315
|
||||
#define TK_VARIABLE 316
|
||||
#define TK_VIEW 317
|
||||
#define TK_WAL 318
|
||||
|
||||
#define TK_NK_SPACE 300
|
||||
#define TK_NK_COMMENT 301
|
||||
#define TK_NK_ILLEGAL 302
|
||||
#define TK_NK_HEX 303 // hex number 0x123
|
||||
#define TK_NK_OCT 304 // oct number
|
||||
#define TK_NK_BIN 305 // bin format data 0b111
|
||||
#define TK_NK_SPACE 600
|
||||
#define TK_NK_COMMENT 601
|
||||
#define TK_NK_ILLEGAL 602
|
||||
#define TK_NK_HEX 603 // hex number 0x123
|
||||
#define TK_NK_OCT 604 // oct number
|
||||
#define TK_NK_BIN 605 // bin format data 0b111
|
||||
|
||||
#define TK_NK_NIL 65535
|
||||
|
||||
|
|
|
@ -99,7 +99,6 @@ int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
|
|||
*/
|
||||
int32_t mndProcessRpcMsg(SRpcMsg *pMsg);
|
||||
int32_t mndProcessSyncMsg(SRpcMsg *pMsg);
|
||||
int32_t mndProcessSyncCtrlMsg(SRpcMsg *pMsg);
|
||||
int32_t mndPreProcessQueryMsg(SRpcMsg *pMsg);
|
||||
void mndPostProcessQueryMsg(SRpcMsg *pMsg);
|
||||
|
||||
|
|
|
@ -203,13 +203,11 @@ int32_t catalogUpdateTableMeta(SCatalog* pCatalog, STableMetaRsp* rspMsg);
|
|||
|
||||
int32_t catalogUpdateTableMeta(SCatalog* pCatalog, STableMetaRsp* rspMsg);
|
||||
|
||||
int32_t catalogGetCachedTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableMeta** pTableMeta);
|
||||
int32_t catalogGetCachedTableMeta(SCatalog* pCtg, const SName* pTableName, STableMeta** pTableMeta);
|
||||
|
||||
int32_t catalogGetCachedSTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName,
|
||||
STableMeta** pTableMeta);
|
||||
int32_t catalogGetCachedSTableMeta(SCatalog* pCtg, const SName* pTableName, STableMeta** pTableMeta);
|
||||
|
||||
int32_t catalogGetCachedTableHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName,
|
||||
SVgroupInfo* pVgroup, bool* exists);
|
||||
int32_t catalogGetCachedTableHashVgroup(SCatalog* pCtg, const SName* pTableName, SVgroupInfo* pVgroup, bool* exists);
|
||||
|
||||
/**
|
||||
* Force refresh DB's local cached vgroup info.
|
||||
|
@ -309,6 +307,9 @@ int32_t catalogGetUdfInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char* f
|
|||
int32_t catalogChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, const char* dbFName, AUTH_TYPE type,
|
||||
bool* pass);
|
||||
|
||||
int32_t catalogChkAuthFromCache(SCatalog* pCtg, const char* user, const char* dbFName, AUTH_TYPE type,
|
||||
bool* pass, bool* exists);
|
||||
|
||||
int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth);
|
||||
|
||||
int32_t catalogUpdateVgEpSet(SCatalog* pCtg, const char* dbFName, int32_t vgId, SEpSet* epSet);
|
||||
|
@ -323,6 +324,10 @@ SMetaData* catalogCloneMetaData(SMetaData* pData);
|
|||
|
||||
void catalogFreeMetaData(SMetaData* pData);
|
||||
|
||||
int32_t ctgdEnableDebug(char *option, bool enable);
|
||||
|
||||
int32_t ctgdHandleDbgCommand(char *command);
|
||||
|
||||
/**
|
||||
* Destroy catalog and relase all resources
|
||||
*/
|
||||
|
|
|
@ -79,6 +79,7 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers);
|
|||
*/
|
||||
qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols, SSchemaWrapper** pSchema);
|
||||
|
||||
int32_t qSetStreamOpOpen(qTaskInfo_t tinfo);
|
||||
/**
|
||||
* Set multiple input data blocks for the stream scan.
|
||||
* @param tinfo
|
||||
|
|
|
@ -216,6 +216,7 @@ bool fmIsMultiRowsFunc(int32_t funcId);
|
|||
bool fmIsKeepOrderFunc(int32_t funcId);
|
||||
bool fmIsCumulativeFunc(int32_t funcId);
|
||||
bool fmIsInterpPseudoColumnFunc(int32_t funcId);
|
||||
bool fmIsGroupKeyFunc(int32_t funcId);
|
||||
|
||||
void getLastCacheDataType(SDataType* pType);
|
||||
|
||||
|
|
|
@ -235,6 +235,7 @@ typedef struct SDropDnodeStmt {
|
|||
int32_t dnodeId;
|
||||
char fqdn[TSDB_FQDN_LEN];
|
||||
int32_t port;
|
||||
bool force;
|
||||
} SDropDnodeStmt;
|
||||
|
||||
typedef struct SAlterDnodeStmt {
|
||||
|
|
|
@ -242,13 +242,13 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
|||
#define SET_META_TYPE_BOTH_TABLE(t) (t) = META_TYPE_BOTH_TABLE
|
||||
|
||||
#define NEED_CLIENT_RM_TBLMETA_ERROR(_code) \
|
||||
((_code) == TSDB_CODE_PAR_TABLE_NOT_EXIST || (_code) == TSDB_CODE_VND_TB_NOT_EXIST || \
|
||||
((_code) == TSDB_CODE_PAR_TABLE_NOT_EXIST || (_code) == TSDB_CODE_TDB_TABLE_NOT_EXIST || \
|
||||
(_code) == TSDB_CODE_PAR_INVALID_COLUMNS_NUM || (_code) == TSDB_CODE_PAR_INVALID_COLUMN || \
|
||||
(_code) == TSDB_CODE_PAR_TAGS_NOT_MATCHED || (_code) == TSDB_CODE_PAR_VALUE_TOO_LONG || \
|
||||
(_code) == TSDB_CODE_PAR_INVALID_DROP_COL || ((_code) == TSDB_CODE_TDB_INVALID_TABLE_ID))
|
||||
#define NEED_CLIENT_REFRESH_VG_ERROR(_code) \
|
||||
((_code) == TSDB_CODE_VND_HASH_MISMATCH || (_code) == TSDB_CODE_VND_INVALID_VGROUP_ID)
|
||||
#define NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code) ((_code) == TSDB_CODE_TDB_TABLE_RECREATED)
|
||||
#define NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code) ((_code) == TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER)
|
||||
#define NEED_CLIENT_HANDLE_ERROR(_code) \
|
||||
(NEED_CLIENT_RM_TBLMETA_ERROR(_code) || NEED_CLIENT_REFRESH_VG_ERROR(_code) || \
|
||||
NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code))
|
||||
|
|
|
@ -46,7 +46,7 @@ enum {
|
|||
TASK_STATUS__DROPPING,
|
||||
TASK_STATUS__FAIL,
|
||||
TASK_STATUS__STOP,
|
||||
TASK_STATUS__RECOVER_DOWNSTREAM,
|
||||
TASK_STATUS__WAIT_DOWNSTREAM,
|
||||
TASK_STATUS__RECOVER_PREPARE,
|
||||
TASK_STATUS__RECOVER1,
|
||||
TASK_STATUS__RECOVER2,
|
||||
|
@ -332,7 +332,10 @@ typedef struct SStreamTask {
|
|||
SStreamState* pState;
|
||||
|
||||
// do not serialize
|
||||
int32_t recoverWaitingChild;
|
||||
int32_t recoverTryingDownstream;
|
||||
int32_t recoverWaitingUpstream;
|
||||
int64_t checkReqId;
|
||||
SArray* checkReqIds; // shuffle
|
||||
|
||||
} SStreamTask;
|
||||
|
||||
|
@ -418,7 +421,10 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
int64_t streamId;
|
||||
int32_t taskId;
|
||||
int32_t upstreamNodeId;
|
||||
int32_t upstreamTaskId;
|
||||
int32_t downstreamNodeId;
|
||||
int32_t downstreamTaskId;
|
||||
int8_t inputStatus;
|
||||
} SStreamDispatchRsp;
|
||||
|
||||
|
@ -441,8 +447,30 @@ typedef struct {
|
|||
} SStreamRetrieveRsp;
|
||||
|
||||
typedef struct {
|
||||
int64_t reqId;
|
||||
int64_t streamId;
|
||||
int32_t taskId;
|
||||
int32_t upstreamNodeId;
|
||||
int32_t upstreamTaskId;
|
||||
int32_t downstreamNodeId;
|
||||
int32_t downstreamTaskId;
|
||||
int32_t childId;
|
||||
} SStreamTaskCheckReq;
|
||||
|
||||
typedef struct {
|
||||
int64_t reqId;
|
||||
int64_t streamId;
|
||||
int32_t upstreamNodeId;
|
||||
int32_t upstreamTaskId;
|
||||
int32_t downstreamNodeId;
|
||||
int32_t downstreamTaskId;
|
||||
int32_t childId;
|
||||
int8_t status;
|
||||
} SStreamTaskCheckRsp;
|
||||
|
||||
typedef struct {
|
||||
SMsgHead msgHead;
|
||||
int64_t streamId;
|
||||
int32_t taskId;
|
||||
} SStreamRecoverStep1Req, SStreamRecoverStep2Req;
|
||||
|
||||
typedef struct {
|
||||
|
@ -454,47 +482,6 @@ typedef struct {
|
|||
int32_t tEncodeSStreamRecoverFinishReq(SEncoder* pEncoder, const SStreamRecoverFinishReq* pReq);
|
||||
int32_t tDecodeSStreamRecoverFinishReq(SDecoder* pDecoder, SStreamRecoverFinishReq* pReq);
|
||||
|
||||
#if 0
|
||||
typedef struct {
|
||||
int64_t streamId;
|
||||
int32_t taskId;
|
||||
int32_t upstreamTaskId;
|
||||
int32_t upstreamNodeId;
|
||||
} SStreamTaskRecoverReq;
|
||||
|
||||
typedef struct {
|
||||
int64_t streamId;
|
||||
int32_t rspTaskId;
|
||||
int32_t reqTaskId;
|
||||
int8_t inputStatus;
|
||||
} SStreamTaskRecoverRsp;
|
||||
|
||||
int32_t tEncodeStreamTaskRecoverReq(SEncoder* pEncoder, const SStreamTaskRecoverReq* pReq);
|
||||
int32_t tDecodeStreamTaskRecoverReq(SDecoder* pDecoder, SStreamTaskRecoverReq* pReq);
|
||||
|
||||
int32_t tEncodeStreamTaskRecoverRsp(SEncoder* pEncoder, const SStreamTaskRecoverRsp* pRsp);
|
||||
int32_t tDecodeStreamTaskRecoverRsp(SDecoder* pDecoder, SStreamTaskRecoverRsp* pRsp);
|
||||
|
||||
typedef struct {
|
||||
int64_t streamId;
|
||||
int32_t taskId;
|
||||
} SMStreamTaskRecoverReq;
|
||||
|
||||
typedef struct {
|
||||
int64_t streamId;
|
||||
int32_t taskId;
|
||||
} SMStreamTaskRecoverRsp;
|
||||
|
||||
int32_t tEncodeSMStreamTaskRecoverReq(SEncoder* pEncoder, const SMStreamTaskRecoverReq* pReq);
|
||||
int32_t tDecodeSMStreamTaskRecoverReq(SDecoder* pDecoder, SMStreamTaskRecoverReq* pReq);
|
||||
|
||||
int32_t tEncodeSMStreamTaskRecoverRsp(SEncoder* pEncoder, const SMStreamTaskRecoverRsp* pRsp);
|
||||
int32_t tDecodeSMStreamTaskRecoverRsp(SDecoder* pDecoder, SMStreamTaskRecoverRsp* pRsp);
|
||||
|
||||
int32_t streamProcessRecoverReq(SStreamTask* pTask, SStreamTaskRecoverReq* pReq, SRpcMsg* pMsg);
|
||||
int32_t streamProcessRecoverRsp(SStreamTask* pTask, SStreamTaskRecoverRsp* pRsp);
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int64_t streamId;
|
||||
int32_t downstreamTaskId;
|
||||
|
@ -508,20 +495,18 @@ typedef struct {
|
|||
SArray* checkpointVer; // SArray<SStreamCheckpointInfo>
|
||||
} SStreamRecoverDownstreamRsp;
|
||||
|
||||
int32_t tEncodeSStreamTaskCheckReq(SEncoder* pEncoder, const SStreamTaskCheckReq* pReq);
|
||||
int32_t tDecodeSStreamTaskCheckReq(SDecoder* pDecoder, SStreamTaskCheckReq* pReq);
|
||||
|
||||
int32_t tEncodeSStreamTaskCheckRsp(SEncoder* pEncoder, const SStreamTaskCheckRsp* pRsp);
|
||||
int32_t tDecodeSStreamTaskCheckRsp(SDecoder* pDecoder, SStreamTaskCheckRsp* pRsp);
|
||||
|
||||
int32_t tEncodeSStreamTaskRecoverReq(SEncoder* pEncoder, const SStreamRecoverDownstreamReq* pReq);
|
||||
int32_t tDecodeSStreamTaskRecoverReq(SDecoder* pDecoder, SStreamRecoverDownstreamReq* pReq);
|
||||
|
||||
int32_t tEncodeSStreamTaskRecoverRsp(SEncoder* pEncoder, const SStreamRecoverDownstreamRsp* pRsp);
|
||||
int32_t tDecodeSStreamTaskRecoverRsp(SDecoder* pDecoder, SStreamRecoverDownstreamRsp* pRsp);
|
||||
|
||||
typedef struct {
|
||||
int64_t streamId;
|
||||
int32_t taskId;
|
||||
int32_t waitingRspCnt;
|
||||
int32_t totReq;
|
||||
SArray* info; // SArray<SArray<SStreamCheckpointInfo>*>
|
||||
} SStreamRecoverStatus;
|
||||
|
||||
int32_t tDecodeStreamDispatchReq(SDecoder* pDecoder, SStreamDispatchReq* pReq);
|
||||
int32_t tDecodeStreamRetrieveReq(SDecoder* pDecoder, SStreamRetrieveReq* pReq);
|
||||
void tDeleteStreamRetrieveReq(SStreamRetrieveReq* pReq);
|
||||
|
@ -532,7 +517,7 @@ int32_t streamSetupTrigger(SStreamTask* pTask);
|
|||
|
||||
int32_t streamProcessRunReq(SStreamTask* pTask);
|
||||
int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, SRpcMsg* pMsg, bool exec);
|
||||
int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp);
|
||||
int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp, int32_t code);
|
||||
|
||||
int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq, SRpcMsg* pMsg);
|
||||
int32_t streamProcessRetrieveRsp(SStreamTask* pTask, SStreamRetrieveRsp* pRsp);
|
||||
|
@ -543,6 +528,10 @@ int32_t streamSchedExec(SStreamTask* pTask);
|
|||
int32_t streamScanExec(SStreamTask* pTask, int32_t batchSz);
|
||||
|
||||
// recover and fill history
|
||||
int32_t streamTaskCheckDownstream(SStreamTask* pTask, int64_t version);
|
||||
int32_t streamTaskLaunchRecover(SStreamTask* pTask, int64_t version);
|
||||
int32_t streamProcessTaskCheckReq(SStreamTask* pTask, const SStreamTaskCheckReq* pReq);
|
||||
int32_t streamProcessTaskCheckRsp(SStreamTask* pTask, const SStreamTaskCheckRsp* pRsp, int64_t version);
|
||||
// common
|
||||
int32_t streamSetParamForRecover(SStreamTask* pTask);
|
||||
int32_t streamRestoreParam(SStreamTask* pTask);
|
||||
|
|
|
@ -25,8 +25,6 @@ extern "C" {
|
|||
#include "tlrucache.h"
|
||||
#include "tmsgcb.h"
|
||||
|
||||
extern bool gRaftDetailLog;
|
||||
|
||||
#define SYNC_RESP_TTL_MS 10000000
|
||||
#define SYNC_SPEED_UP_HB_TIMER 400
|
||||
#define SYNC_SPEED_UP_AFTER_MS (1000 * 20)
|
||||
|
@ -39,6 +37,7 @@ extern bool gRaftDetailLog;
|
|||
#define SYNC_ADD_QUORUM_COUNT 3
|
||||
#define SYNC_MNODE_LOG_RETENTION 10000
|
||||
#define SYNC_VNODE_LOG_RETENTION 100
|
||||
#define SNAPSHOT_MAX_CLOCK_SKEW_MS 1000 * 10
|
||||
|
||||
#define SYNC_APPEND_ENTRIES_TIMEOUT_MS 10000
|
||||
|
||||
|
@ -132,27 +131,27 @@ typedef struct SSnapshotMeta {
|
|||
typedef struct SSyncFSM {
|
||||
void* data;
|
||||
|
||||
void (*FpCommitCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta);
|
||||
void (*FpPreCommitCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta);
|
||||
void (*FpRollBackCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta);
|
||||
void (*FpCommitCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
||||
void (*FpPreCommitCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
||||
void (*FpRollBackCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
||||
|
||||
void (*FpRestoreFinishCb)(struct SSyncFSM* pFsm);
|
||||
void (*FpReConfigCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta* cbMeta);
|
||||
void (*FpLeaderTransferCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta);
|
||||
void (*FpRestoreFinishCb)(const struct SSyncFSM* pFsm);
|
||||
void (*FpReConfigCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SReConfigCbMeta* pMeta);
|
||||
void (*FpLeaderTransferCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
||||
|
||||
void (*FpBecomeLeaderCb)(struct SSyncFSM* pFsm);
|
||||
void (*FpBecomeFollowerCb)(struct SSyncFSM* pFsm);
|
||||
void (*FpBecomeLeaderCb)(const struct SSyncFSM* pFsm);
|
||||
void (*FpBecomeFollowerCb)(const struct SSyncFSM* pFsm);
|
||||
|
||||
int32_t (*FpGetSnapshot)(struct SSyncFSM* pFsm, SSnapshot* pSnapshot, void* pReaderParam, void** ppReader);
|
||||
int32_t (*FpGetSnapshotInfo)(struct SSyncFSM* pFsm, SSnapshot* pSnapshot);
|
||||
int32_t (*FpGetSnapshot)(const struct SSyncFSM* pFsm, SSnapshot* pSnapshot, void* pReaderParam, void** ppReader);
|
||||
int32_t (*FpGetSnapshotInfo)(const struct SSyncFSM* pFsm, SSnapshot* pSnapshot);
|
||||
|
||||
int32_t (*FpSnapshotStartRead)(struct SSyncFSM* pFsm, void* pReaderParam, void** ppReader);
|
||||
int32_t (*FpSnapshotStopRead)(struct SSyncFSM* pFsm, void* pReader);
|
||||
int32_t (*FpSnapshotDoRead)(struct SSyncFSM* pFsm, void* pReader, void** ppBuf, int32_t* len);
|
||||
int32_t (*FpSnapshotStartRead)(const struct SSyncFSM* pFsm, void* pReaderParam, void** ppReader);
|
||||
int32_t (*FpSnapshotStopRead)(const struct SSyncFSM* pFsm, void* pReader);
|
||||
int32_t (*FpSnapshotDoRead)(const struct SSyncFSM* pFsm, void* pReader, void** ppBuf, int32_t* len);
|
||||
|
||||
int32_t (*FpSnapshotStartWrite)(struct SSyncFSM* pFsm, void* pWriterParam, void** ppWriter);
|
||||
int32_t (*FpSnapshotStopWrite)(struct SSyncFSM* pFsm, void* pWriter, bool isApply, SSnapshot* pSnapshot);
|
||||
int32_t (*FpSnapshotDoWrite)(struct SSyncFSM* pFsm, void* pWriter, void* pBuf, int32_t len);
|
||||
int32_t (*FpSnapshotStartWrite)(const struct SSyncFSM* pFsm, void* pWriterParam, void** ppWriter);
|
||||
int32_t (*FpSnapshotStopWrite)(const struct SSyncFSM* pFsm, void* pWriter, bool isApply, SSnapshot* pSnapshot);
|
||||
int32_t (*FpSnapshotDoWrite)(const struct SSyncFSM* pFsm, void* pWriter, void* pBuf, int32_t len);
|
||||
|
||||
} SSyncFSM;
|
||||
|
||||
|
@ -193,44 +192,38 @@ typedef struct SSyncInfo {
|
|||
SWal* pWal;
|
||||
SSyncFSM* pFsm;
|
||||
SMsgCb* msgcb;
|
||||
int32_t (*FpSendMsg)(const SEpSet* pEpSet, SRpcMsg* pMsg);
|
||||
int32_t (*FpEqMsg)(const SMsgCb* msgcb, SRpcMsg* pMsg);
|
||||
int32_t (*FpEqCtrlMsg)(const SMsgCb* msgcb, SRpcMsg* pMsg);
|
||||
int32_t pingMs;
|
||||
int32_t electMs;
|
||||
int32_t heartbeatMs;
|
||||
|
||||
int32_t (*syncSendMSg)(const SEpSet* pEpSet, SRpcMsg* pMsg);
|
||||
int32_t (*syncEqMsg)(const SMsgCb* msgcb, SRpcMsg* pMsg);
|
||||
int32_t (*syncEqCtrlMsg)(const SMsgCb* msgcb, SRpcMsg* pMsg);
|
||||
} SSyncInfo;
|
||||
|
||||
int32_t syncInit();
|
||||
void syncCleanUp();
|
||||
int64_t syncOpen(SSyncInfo* pSyncInfo);
|
||||
void syncStart(int64_t rid);
|
||||
void syncStop(int64_t rid);
|
||||
int32_t syncSetStandby(int64_t rid);
|
||||
ESyncState syncGetMyRole(int64_t rid);
|
||||
bool syncIsReady(int64_t rid);
|
||||
const char* syncGetMyRoleStr(int64_t rid);
|
||||
bool syncRestoreFinish(int64_t rid);
|
||||
SyncTerm syncGetMyTerm(int64_t rid);
|
||||
SyncIndex syncGetLastIndex(int64_t rid);
|
||||
SyncIndex syncGetCommitIndex(int64_t rid);
|
||||
SyncGroupId syncGetVgId(int64_t rid);
|
||||
void syncGetEpSet(int64_t rid, SEpSet* pEpSet);
|
||||
void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet);
|
||||
int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak);
|
||||
// int32_t syncProposeBatch(int64_t rid, SRpcMsg** pMsgPArr, bool* pIsWeakArr, int32_t arrSize);
|
||||
bool syncEnvIsStart();
|
||||
const char* syncStr(ESyncState state);
|
||||
bool syncIsRestoreFinish(int64_t rid);
|
||||
int32_t syncGetSnapshotByIndex(int64_t rid, SyncIndex index, SSnapshot* pSnapshot);
|
||||
|
||||
int32_t syncReconfig(int64_t rid, SSyncCfg* pNewCfg);
|
||||
|
||||
// build SRpcMsg, need to call syncPropose with SRpcMsg
|
||||
int32_t syncReconfigBuild(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg);
|
||||
|
||||
int32_t syncLeaderTransfer(int64_t rid);
|
||||
int32_t syncLeaderTransferTo(int64_t rid, SNodeInfo newLeader);
|
||||
typedef struct SSyncState {
|
||||
ESyncState state;
|
||||
bool restored;
|
||||
} SSyncState;
|
||||
|
||||
int32_t syncInit();
|
||||
void syncCleanUp();
|
||||
int64_t syncOpen(SSyncInfo* pSyncInfo);
|
||||
void syncStart(int64_t rid);
|
||||
void syncStop(int64_t rid);
|
||||
void syncPreStop(int64_t rid);
|
||||
int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak);
|
||||
int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg);
|
||||
int32_t syncReconfig(int64_t rid, SSyncCfg* pCfg);
|
||||
int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex);
|
||||
int32_t syncEndSnapshot(int64_t rid);
|
||||
int32_t syncLeaderTransfer(int64_t rid);
|
||||
int32_t syncStepDown(int64_t rid, SyncTerm newTerm);
|
||||
bool syncIsReadyForRead(int64_t rid);
|
||||
|
||||
SSyncState syncGetState(int64_t rid);
|
||||
void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet);
|
||||
const char* syncStr(ESyncState state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@ extern "C" {
|
|||
#define WAL_FILE_LEN (WAL_PATH_LEN + 32)
|
||||
#define WAL_MAGIC 0xFAFBFCFDF4F3F2F1ULL
|
||||
#define WAL_SCAN_BUF_SIZE (1024 * 1024 * 3)
|
||||
#define WAL_RECOV_SIZE_LIMIT (100 * WAL_SCAN_BUF_SIZE)
|
||||
|
||||
typedef enum {
|
||||
TAOS_WAL_WRITE = 1,
|
||||
|
@ -159,6 +158,7 @@ void walCleanUp();
|
|||
// handle open and ctl
|
||||
SWal *walOpen(const char *path, SWalCfg *pCfg);
|
||||
int32_t walAlter(SWal *, SWalCfg *pCfg);
|
||||
int32_t walPersist(SWal *);
|
||||
void walClose(SWal *);
|
||||
|
||||
// write interfaces
|
||||
|
|
|
@ -244,6 +244,16 @@ void syslog(int unused, const char *format, ...);
|
|||
#define TD_CHARSET_LEN 64
|
||||
#define TD_TIMEZONE_LEN 96
|
||||
|
||||
#ifdef WINDOWS
|
||||
#define TD_PATH_MAX 260
|
||||
#elif defined(PATH_MAX)
|
||||
#define TD_PATH_MAX PATH_MAX
|
||||
#elif defined(_XOPEN_PATH_MAX)
|
||||
#define TD_PATH_MAX _XOPEN_PATH_MAX
|
||||
#else
|
||||
#define TD_PATH_MAX _POSIX_PATH_MAX
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -36,6 +36,7 @@ void *taosMemoryStrDup(const char *ptr);
|
|||
void taosMemoryFree(void *ptr);
|
||||
int64_t taosMemorySize(void *ptr);
|
||||
void taosPrintBackTrace();
|
||||
void taosMemoryTrim(int32_t size);
|
||||
|
||||
#define taosMemoryFreeClear(ptr) \
|
||||
do { \
|
||||
|
|
|
@ -91,6 +91,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_MSG_DECODE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0128)
|
||||
#define TSDB_CODE_NO_AVAIL_DISK TAOS_DEF_ERROR_CODE(0, 0x0129)
|
||||
#define TSDB_CODE_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x012A)
|
||||
#define TSDB_CODE_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x012B)
|
||||
|
||||
//client
|
||||
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)
|
||||
|
@ -106,7 +107,6 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH TAOS_DEF_ERROR_CODE(0, 0x020A)
|
||||
#define TSDB_CODE_TSC_INVALID_CONNECTION TAOS_DEF_ERROR_CODE(0, 0x020B)
|
||||
#define TSDB_CODE_TSC_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x020C)
|
||||
#define TSDB_CODE_TSC_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x020D)
|
||||
#define TSDB_CODE_TSC_QUERY_CACHE_ERASED TAOS_DEF_ERROR_CODE(0, 0x020E)
|
||||
#define TSDB_CODE_TSC_QUERY_CANCELLED TAOS_DEF_ERROR_CODE(0, 0x020F)
|
||||
#define TSDB_CODE_TSC_SORTED_RES_TOO_MANY TAOS_DEF_ERROR_CODE(0, 0x0210)
|
||||
|
@ -305,34 +305,14 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_NODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x040A)
|
||||
|
||||
// vnode
|
||||
#define TSDB_CODE_VND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0500)
|
||||
#define TSDB_CODE_VND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0501)
|
||||
#define TSDB_CODE_VND_ACTION_NEED_REPROCESSED TAOS_DEF_ERROR_CODE(0, 0x0502)
|
||||
#define TSDB_CODE_VND_INVALID_VGROUP_ID TAOS_DEF_ERROR_CODE(0, 0x0503)
|
||||
#define TSDB_CODE_VND_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0504)
|
||||
#define TSDB_CODE_VND_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0505)
|
||||
#define TSDB_CODE_VND_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0506)
|
||||
#define TSDB_CODE_VND_NO_SUCH_FILE_OR_DIR TAOS_DEF_ERROR_CODE(0, 0x0507)
|
||||
#define TSDB_CODE_VND_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0508)
|
||||
#define TSDB_CODE_VND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0509)
|
||||
#define TSDB_CODE_VND_IS_FLOWCTRL TAOS_DEF_ERROR_CODE(0, 0x050C)
|
||||
#define TSDB_CODE_VND_IS_DROPPING TAOS_DEF_ERROR_CODE(0, 0x050D)
|
||||
#define TSDB_CODE_VND_IS_UPDATING TAOS_DEF_ERROR_CODE(0, 0x050E)
|
||||
#define TSDB_CODE_VND_IS_CLOSING TAOS_DEF_ERROR_CODE(0, 0x0510)
|
||||
#define TSDB_CODE_VND_NOT_SYNCED TAOS_DEF_ERROR_CODE(0, 0x0511)
|
||||
#define TSDB_CODE_VND_NO_WRITE_AUTH TAOS_DEF_ERROR_CODE(0, 0x0512)
|
||||
#define TSDB_CODE_VND_IS_SYNCING TAOS_DEF_ERROR_CODE(0, 0x0513)
|
||||
#define TSDB_CODE_VND_INVALID_TSDB_STATE TAOS_DEF_ERROR_CODE(0, 0x0514)
|
||||
#define TSDB_CODE_VND_TB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0520)
|
||||
#define TSDB_CODE_VND_SMA_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0521)
|
||||
#define TSDB_CODE_VND_HASH_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x0522)
|
||||
#define TSDB_CODE_VND_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0523)
|
||||
#define TSDB_CODE_VND_INVALID_TABLE_ACTION TAOS_DEF_ERROR_CODE(0, 0x0524)
|
||||
#define TSDB_CODE_VND_COL_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0525)
|
||||
#define TSDB_CODE_VND_TABLE_COL_NOT_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0526)
|
||||
#define TSDB_CODE_VND_COL_NOT_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0526)
|
||||
#define TSDB_CODE_VND_COL_SUBSCRIBED TAOS_DEF_ERROR_CODE(0, 0x0527)
|
||||
#define TSDB_CODE_VND_INVALID_CFG_FILE TAOS_DEF_ERROR_CODE(0, 0x0528)
|
||||
#define TSDB_CODE_VND_INVALID_TERM_FILE TAOS_DEF_ERROR_CODE(0, 0x0529)
|
||||
#define TSDB_CODE_VND_NO_AVAIL_BUFPOOL TAOS_DEF_ERROR_CODE(0, 0x0528)
|
||||
|
||||
// tsdb
|
||||
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
|
||||
|
@ -341,7 +321,6 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_TDB_TABLE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0603)
|
||||
#define TSDB_CODE_TDB_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0604)
|
||||
#define TSDB_CODE_TDB_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0605)
|
||||
#define TSDB_CODE_TDB_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0606)
|
||||
#define TSDB_CODE_TDB_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0607)
|
||||
#define TSDB_CODE_TDB_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0608)
|
||||
#define TSDB_CODE_TDB_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0609)
|
||||
|
@ -361,13 +340,12 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_TDB_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0618)
|
||||
#define TSDB_CODE_TDB_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0619)
|
||||
#define TSDB_CODE_TDB_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x061A)
|
||||
#define TSDB_CODE_TDB_TABLE_RECREATED TAOS_DEF_ERROR_CODE(0, 0x061B)
|
||||
#define TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER TAOS_DEF_ERROR_CODE(0, 0x061B)
|
||||
#define TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR TAOS_DEF_ERROR_CODE(0, 0x061C)
|
||||
|
||||
// query
|
||||
#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700)
|
||||
#define TSDB_CODE_QRY_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0701)
|
||||
#define TSDB_CODE_QRY_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0702)
|
||||
#define TSDB_CODE_QRY_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0703)
|
||||
#define TSDB_CODE_QRY_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0704)
|
||||
#define TSDB_CODE_QRY_DUP_JOIN_KEY TAOS_DEF_ERROR_CODE(0, 0x0705)
|
||||
|
@ -430,7 +408,6 @@ int32_t* taosGetErrno();
|
|||
// tq
|
||||
#define TSDB_CODE_TQ_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0A00)
|
||||
#define TSDB_CODE_TQ_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0A01)
|
||||
#define TSDB_CODE_TQ_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0A02)
|
||||
#define TSDB_CODE_TQ_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0A03)
|
||||
#define TSDB_CODE_TQ_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0A04)
|
||||
#define TSDB_CODE_TQ_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0A05)
|
||||
|
@ -451,6 +428,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_WAL_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1004)
|
||||
#define TSDB_CODE_WAL_LOG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x1005)
|
||||
#define TSDB_CODE_WAL_CHKSUM_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x1006)
|
||||
#define TSDB_CODE_WAL_LOG_INCOMPLETE TAOS_DEF_ERROR_CODE(0, 0x1007)
|
||||
|
||||
// tfs
|
||||
#define TSDB_CODE_FS_INVLD_CFG TAOS_DEF_ERROR_CODE(0, 0x2201)
|
||||
|
@ -634,9 +612,12 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_TMQ_CONSUMER_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x4001)
|
||||
#define TSDB_CODE_TMQ_CONSUMER_CLOSED TAOS_DEF_ERROR_CODE(0, 0x4002)
|
||||
|
||||
// stream
|
||||
#define TSDB_CODE_STREAM_TASK_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x4100)
|
||||
|
||||
// TDLite
|
||||
#define TSDB_CODE_TDLITE_IVLD_OPEN_FLAGS TAOS_DEF_ERROR_CODE(0, 0x4100)
|
||||
#define TSDB_CODE_TDLITE_IVLD_OPEN_DIR TAOS_DEF_ERROR_CODE(0, 0x4101)
|
||||
#define TSDB_CODE_TDLITE_IVLD_OPEN_FLAGS TAOS_DEF_ERROR_CODE(0, 0x5100)
|
||||
#define TSDB_CODE_TDLITE_IVLD_OPEN_DIR TAOS_DEF_ERROR_CODE(0, 0x5101)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -25,7 +25,8 @@ extern "C" {
|
|||
|
||||
// open a reference set, max is the mod used by hash, fp is the pointer to free resource function
|
||||
// return rsetId which will be used by other APIs. On error, -1 is returned, and terrno is set appropriately
|
||||
int32_t taosOpenRef(int32_t max, void (*fp)(void *));
|
||||
typedef void (*RefFp)(void *);
|
||||
int32_t taosOpenRef(int32_t max, RefFp fp);
|
||||
|
||||
// close the reference set, refId is the return value by taosOpenRef
|
||||
// return 0 if success. On error, -1 is returned, and terrno is set appropriately
|
||||
|
|
|
@ -40,7 +40,7 @@ if not exist %work_dir%\debug\ver-%2-x86 (
|
|||
)
|
||||
cd %work_dir%\debug\ver-%2-x64
|
||||
call vcvarsall.bat x64
|
||||
cmake ../../ -G "NMake Makefiles JOM" -DCMAKE_MAKE_PROGRAM=jom -DBUILD_TOOLS=true -DBUILD_HTTP=false -DBUILD_TEST=false -DVERNUMBER=%2 -DCPUTYPE=x64
|
||||
cmake ../../ -G "NMake Makefiles JOM" -DCMAKE_MAKE_PROGRAM=jom -DBUILD_TOOLS=true -DWEBSOCKET=true -DBUILD_HTTP=false -DBUILD_TEST=false -DVERNUMBER=%2 -DCPUTYPE=x64
|
||||
cmake --build .
|
||||
rd /s /Q C:\TDengine
|
||||
cmake --install .
|
||||
|
@ -63,4 +63,4 @@ exit /b
|
|||
:RUNFAILED
|
||||
echo %*
|
||||
cd %package_dir%
|
||||
goto :eof
|
||||
goto :eof
|
||||
|
|
|
@ -285,10 +285,14 @@ if [[ $dbName == "taos" ]]; then
|
|||
fi
|
||||
|
||||
# Add web files
|
||||
if [ -d "${web_dir}/admin" ]; then
|
||||
mkdir -p ${install_dir}/share/
|
||||
cp ${web_dir}/admin ${install_dir}/share/ -r
|
||||
cp ${web_dir}/png/taos.png ${install_dir}/share/admin/images/taos.png
|
||||
if [ "$verMode" == "cluster" ] || [ "$verMode" == "cloud" ]; then
|
||||
if [ -d "${web_dir}/admin" ] ; then
|
||||
mkdir -p ${install_dir}/share/
|
||||
cp ${web_dir}/admin ${install_dir}/share/ -r
|
||||
cp ${web_dir}/png/taos.png ${install_dir}/share/admin/images/taos.png
|
||||
else
|
||||
echo "directory not found for enterprise release: ${web_dir}/admin"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -375,4 +379,4 @@ if [ -n "${taostools_bin_files}" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
cd ${curr_dir}
|
||||
cd ${curr_dir}
|
|
@ -318,6 +318,7 @@ void* createTscObj(const char* user, const char* auth, const char* db, int32_
|
|||
void destroyTscObj(void* pObj);
|
||||
STscObj* acquireTscObj(int64_t rid);
|
||||
int32_t releaseTscObj(int64_t rid);
|
||||
void destroyAppInst(SAppInstInfo *pAppInfo);
|
||||
|
||||
uint64_t generateRequestId();
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ typedef enum {
|
|||
STMT_BIND_COL,
|
||||
STMT_ADD_BATCH,
|
||||
STMT_EXECUTE,
|
||||
STMT_MAX,
|
||||
} STMT_STATUS;
|
||||
|
||||
typedef struct SStmtTableCache {
|
||||
|
@ -94,12 +95,18 @@ typedef struct STscStmt {
|
|||
STscObj *taos;
|
||||
SCatalog *pCatalog;
|
||||
int32_t affectedRows;
|
||||
uint32_t seqId;
|
||||
uint32_t seqIds[STMT_MAX];
|
||||
|
||||
SStmtSQLInfo sql;
|
||||
SStmtExecInfo exec;
|
||||
SStmtBindInfo bInfo;
|
||||
} STscStmt;
|
||||
|
||||
extern char *gStmtStatusStr[];
|
||||
|
||||
#define STMT_LOG_SEQ(n) do { (pStmt)->seqId++; (pStmt)->seqIds[n]++; STMT_DLOG("the %dth:%d %s", (pStmt)->seqIds[n], (pStmt)->seqId, gStmtStatusStr[n]); } while (0)
|
||||
|
||||
#define STMT_STATUS_NE(S) (pStmt->sql.status != STMT_##S)
|
||||
#define STMT_STATUS_EQ(S) (pStmt->sql.status == STMT_##S)
|
||||
|
||||
|
@ -128,6 +135,12 @@ typedef struct STscStmt {
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define STMT_ELOG(param, ...) qError("stmt:%p " param, pStmt, __VA_ARGS__)
|
||||
#define STMT_DLOG(param, ...) qDebug("stmt:%p " param, pStmt, __VA_ARGS__)
|
||||
|
||||
#define STMT_ELOG_E(param) qError("stmt:%p " param, pStmt)
|
||||
#define STMT_DLOG_E(param) qDebug("stmt:%p " param, pStmt)
|
||||
|
||||
TAOS_STMT *stmtInit(STscObj *taos);
|
||||
int stmtClose(TAOS_STMT *stmt);
|
||||
int stmtExec(TAOS_STMT *stmt);
|
||||
|
|
|
@ -133,6 +133,12 @@ STscObj* taos_connect_internal(const char* ip, const char* user, const char* pas
|
|||
taosThreadMutexInit(&p->qnodeMutex, NULL);
|
||||
p->pTransporter = openTransporter(user, secretEncrypt, tsNumOfCores);
|
||||
p->pAppHbMgr = appHbMgrInit(p, key);
|
||||
if (NULL == p->pAppHbMgr) {
|
||||
destroyAppInst(p);
|
||||
taosThreadMutexUnlock(&appInfo.mutex);
|
||||
taosMemoryFreeClear(key);
|
||||
return NULL;
|
||||
}
|
||||
taosHashPut(appInfo.pInstMap, key, strlen(key), &p, POINTER_BYTES);
|
||||
p->instKey = key;
|
||||
key = NULL;
|
||||
|
@ -1266,7 +1272,9 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
|
|||
pMsgSendInfo->requestObjRefId = pRequest->self;
|
||||
pMsgSendInfo->requestId = pRequest->requestId;
|
||||
pMsgSendInfo->fp = getMsgRspHandle(pMsgSendInfo->msgType);
|
||||
pMsgSendInfo->param = pRequest;
|
||||
pMsgSendInfo->param = taosMemoryCalloc(1, sizeof(pRequest->self));
|
||||
|
||||
*(int64_t*)pMsgSendInfo->param = pRequest->self;
|
||||
|
||||
SConnectReq connectReq = {0};
|
||||
STscObj* pObj = pRequest->pTscObj;
|
||||
|
|
|
@ -286,7 +286,8 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
|||
return NULL;
|
||||
} else {
|
||||
// assert to avoid un-initialization error
|
||||
ASSERT(0);
|
||||
tscError("invalid result passed to taos_fetch_row");
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -45,8 +45,13 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
}
|
||||
|
||||
int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||
SRequestObj* pRequest = param;
|
||||
|
||||
SRequestObj *pRequest = acquireRequest(*(int64_t*)param);
|
||||
if (NULL == pRequest) {
|
||||
setErrno(pRequest, TSDB_CODE_TSC_DISCONNECTED);
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
goto End;
|
||||
}
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
setErrno(pRequest, code);
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
|
@ -55,6 +60,12 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
|
||||
STscObj* pTscObj = pRequest->pTscObj;
|
||||
|
||||
if (NULL == pTscObj->pAppInfo || NULL == pTscObj->pAppInfo->pAppHbMgr) {
|
||||
setErrno(pRequest, TSDB_CODE_TSC_DISCONNECTED);
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
goto End;
|
||||
}
|
||||
|
||||
SConnectRsp connectRsp = {0};
|
||||
if (tDeserializeSConnectRsp(pMsg->pData, pMsg->len, &connectRsp) != 0) {
|
||||
code = TSDB_CODE_TSC_INVALID_VERSION;
|
||||
|
@ -115,10 +126,15 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
|
||||
tscDebug("0x%" PRIx64 " clusterId:%" PRId64 ", totalConn:%" PRId64, pRequest->requestId, connectRsp.clusterId,
|
||||
pTscObj->pAppInfo->numOfConns);
|
||||
|
||||
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
End:
|
||||
|
||||
if (pRequest) {
|
||||
releaseRequest(pRequest->self);
|
||||
}
|
||||
|
||||
taosMemoryFree(param);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
taosMemoryFree(pMsg->pData);
|
||||
return code;
|
||||
|
|
|
@ -1181,7 +1181,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
pVgData = NULL;
|
||||
pArray = NULL;
|
||||
code = pRequest->code;
|
||||
if (code == TSDB_CODE_VND_TABLE_NOT_EXIST) {
|
||||
if (code == TSDB_CODE_TDB_TABLE_NOT_EXIST) {
|
||||
code = TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include "clientStmt.h"
|
||||
|
||||
char *gStmtStatusStr[] = {"unknown", "init", "prepare", "settbname", "settags", "fetchFields", "bind", "bindCol", "addBatch", "exec"};
|
||||
|
||||
static int32_t stmtCreateRequest(STscStmt* pStmt) {
|
||||
int32_t code = 0;
|
||||
|
||||
|
@ -21,6 +23,10 @@ static int32_t stmtCreateRequest(STscStmt* pStmt) {
|
|||
int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) {
|
||||
int32_t code = 0;
|
||||
|
||||
if (newStatus >= STMT_INIT && newStatus < STMT_MAX) {
|
||||
STMT_LOG_SEQ(newStatus);
|
||||
}
|
||||
|
||||
switch (newStatus) {
|
||||
case STMT_PREPARE:
|
||||
break;
|
||||
|
@ -528,13 +534,17 @@ TAOS_STMT* stmtInit(STscObj* taos) {
|
|||
pStmt->bInfo.needParse = true;
|
||||
pStmt->sql.status = STMT_INIT;
|
||||
|
||||
STMT_LOG_SEQ(STMT_INIT);
|
||||
|
||||
tscDebug("stmt:%p initialized", pStmt);
|
||||
|
||||
return pStmt;
|
||||
}
|
||||
|
||||
int stmtPrepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
|
||||
tscDebug("stmt start to prepare");
|
||||
STMT_DLOG_E("start to prepare");
|
||||
|
||||
if (pStmt->sql.status >= STMT_PREPARE) {
|
||||
STMT_ERR_RET(stmtResetStmt(pStmt));
|
||||
|
@ -555,7 +565,7 @@ int stmtPrepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
|
|||
int stmtSetTbName(TAOS_STMT* stmt, const char* tbName) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
|
||||
tscDebug("stmt start to set tbName: %s", tbName);
|
||||
STMT_DLOG("start to set tbName: %s", tbName);
|
||||
|
||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_SETTBNAME));
|
||||
|
||||
|
@ -587,7 +597,7 @@ int stmtSetTbName(TAOS_STMT* stmt, const char* tbName) {
|
|||
int stmtSetTbTags(TAOS_STMT* stmt, TAOS_MULTI_BIND* tags) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
|
||||
tscDebug("stmt start to set tbTags");
|
||||
STMT_DLOG_E("start to set tbTags");
|
||||
|
||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_SETTAGS));
|
||||
|
||||
|
@ -649,7 +659,7 @@ int stmtFetchColFields(STscStmt* pStmt, int32_t* fieldNum, TAOS_FIELD_E** fields
|
|||
int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
|
||||
tscDebug("start to bind stmt data, colIdx: %d", colIdx);
|
||||
STMT_DLOG("start to bind stmt data, colIdx: %d", colIdx);
|
||||
|
||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_BIND));
|
||||
|
||||
|
@ -743,7 +753,7 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
|
|||
int stmtAddBatch(TAOS_STMT* stmt) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
|
||||
tscDebug("stmt start to add batch");
|
||||
STMT_DLOG_E("start to add batch");
|
||||
|
||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_ADD_BATCH));
|
||||
|
||||
|
@ -756,8 +766,7 @@ int stmtUpdateTableUid(STscStmt* pStmt, SSubmitRsp* pRsp) {
|
|||
tscDebug("stmt start to update tbUid, blockNum: %d", pRsp->nBlocks);
|
||||
|
||||
if (pRsp->nBlocks <= 0) {
|
||||
tscError("invalid submit resp block number %d", pRsp->nBlocks);
|
||||
STMT_ERR_RET(TSDB_CODE_TSC_APP_ERROR);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
size_t keyLen = 0;
|
||||
|
@ -810,7 +819,7 @@ int stmtExec(TAOS_STMT* stmt) {
|
|||
SSubmitRsp* pRsp = NULL;
|
||||
bool autoCreateTbl = pStmt->exec.autoCreateTbl;
|
||||
|
||||
tscDebug("stmt start to exec");
|
||||
STMT_DLOG_E("start to exec");
|
||||
|
||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_EXECUTE));
|
||||
|
||||
|
@ -885,6 +894,8 @@ int stmtAffectedRowsOnce(TAOS_STMT* stmt) { return ((STscStmt*)stmt)->exec.affec
|
|||
int stmtIsInsert(TAOS_STMT* stmt, int* insert) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
|
||||
STMT_DLOG_E("start is insert");
|
||||
|
||||
if (pStmt->sql.type) {
|
||||
*insert = (STMT_TYPE_INSERT == pStmt->sql.type || STMT_TYPE_MULTI_INSERT == pStmt->sql.type);
|
||||
} else {
|
||||
|
@ -897,6 +908,8 @@ int stmtIsInsert(TAOS_STMT* stmt, int* insert) {
|
|||
int stmtGetTagFields(TAOS_STMT* stmt, int* nums, TAOS_FIELD_E** fields) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
|
||||
STMT_DLOG_E("start to get tag fields");
|
||||
|
||||
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
||||
STMT_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
||||
}
|
||||
|
@ -927,6 +940,8 @@ int stmtGetTagFields(TAOS_STMT* stmt, int* nums, TAOS_FIELD_E** fields) {
|
|||
int stmtGetColFields(TAOS_STMT* stmt, int* nums, TAOS_FIELD_E** fields) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
|
||||
STMT_DLOG_E("start to get col fields");
|
||||
|
||||
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
||||
STMT_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
||||
}
|
||||
|
@ -957,6 +972,8 @@ int stmtGetColFields(TAOS_STMT* stmt, int* nums, TAOS_FIELD_E** fields) {
|
|||
int stmtGetParamNum(TAOS_STMT* stmt, int* nums) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
|
||||
STMT_DLOG_E("start to get param num");
|
||||
|
||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_FETCH_FIELDS));
|
||||
|
||||
if (pStmt->bInfo.needParse && pStmt->sql.runTimes && pStmt->sql.type > 0 &&
|
||||
|
@ -986,6 +1003,8 @@ int stmtGetParamNum(TAOS_STMT* stmt, int* nums) {
|
|||
int stmtGetParam(TAOS_STMT* stmt, int idx, int* type, int* bytes) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
|
||||
STMT_DLOG_E("start to get param");
|
||||
|
||||
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
||||
STMT_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
||||
}
|
||||
|
@ -1028,6 +1047,8 @@ int stmtGetParam(TAOS_STMT* stmt, int idx, int* type, int* bytes) {
|
|||
TAOS_RES* stmtUseResult(TAOS_STMT* stmt) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
|
||||
STMT_DLOG_E("start to use result");
|
||||
|
||||
if (STMT_TYPE_QUERY != pStmt->sql.type) {
|
||||
tscError("useResult only for query statement");
|
||||
return NULL;
|
||||
|
|
|
@ -508,7 +508,7 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT
|
|||
pMsgSendInfo->param = pParam;
|
||||
pMsgSendInfo->paramFreeFp = taosMemoryFree;
|
||||
pMsgSendInfo->fp = tmqCommitCb;
|
||||
pMsgSendInfo->msgType = TDMT_VND_MQ_COMMIT_OFFSET;
|
||||
pMsgSendInfo->msgType = TDMT_VND_TMQ_COMMIT_OFFSET;
|
||||
// send msg
|
||||
|
||||
atomic_add_fetch_32(&pParamSet->waitingRspNum, 1);
|
||||
|
@ -750,7 +750,7 @@ void tmqSendHbReq(void* param, void* tmrId) {
|
|||
sendInfo->requestObjRefId = 0;
|
||||
sendInfo->param = NULL;
|
||||
sendInfo->fp = tmqHbCb;
|
||||
sendInfo->msgType = TDMT_MND_MQ_HB;
|
||||
sendInfo->msgType = TDMT_MND_TMQ_HB;
|
||||
|
||||
SEpSet epSet = getEpSet_s(&tmq->pTscObj->pAppInfo->mgmtEp);
|
||||
|
||||
|
@ -1038,7 +1038,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
|||
sendInfo->requestObjRefId = 0;
|
||||
sendInfo->param = ¶m;
|
||||
sendInfo->fp = tmqSubscribeCb;
|
||||
sendInfo->msgType = TDMT_MND_SUBSCRIBE;
|
||||
sendInfo->msgType = TDMT_MND_TMQ_SUBSCRIBE;
|
||||
|
||||
SEpSet epSet = getEpSet_s(&tmq->pTscObj->pAppInfo->mgmtEp);
|
||||
|
||||
|
@ -1420,7 +1420,7 @@ int32_t tmqAskEp(tmq_t* tmq, bool async) {
|
|||
sendInfo->requestObjRefId = 0;
|
||||
sendInfo->param = pParam;
|
||||
sendInfo->fp = tmqAskEpCb;
|
||||
sendInfo->msgType = TDMT_MND_MQ_ASK_EP;
|
||||
sendInfo->msgType = TDMT_MND_TMQ_ASK_EP;
|
||||
|
||||
SEpSet epSet = getEpSet_s(&tmq->pTscObj->pAppInfo->mgmtEp);
|
||||
|
||||
|
@ -1573,7 +1573,7 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) {
|
|||
sendInfo->requestObjRefId = 0;
|
||||
sendInfo->param = pParam;
|
||||
sendInfo->fp = tmqPollCb;
|
||||
sendInfo->msgType = TDMT_VND_CONSUME;
|
||||
sendInfo->msgType = TDMT_VND_TMQ_CONSUME;
|
||||
|
||||
int64_t transporterId = 0;
|
||||
/*printf("send poll\n");*/
|
||||
|
@ -1756,7 +1756,7 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
|
|||
|
||||
rspObj = tmqHandleAllRsp(tmq, timeout, false);
|
||||
if (rspObj) {
|
||||
tscDebug("consumer:%" PRId64 ", return rsp", tmq->consumerId);
|
||||
tscDebug("consumer:%" PRId64 ", return rsp %p", tmq->consumerId, rspObj);
|
||||
return (TAOS_RES*)rspObj;
|
||||
} else if (terrno == TSDB_CODE_TQ_NO_COMMITTED_OFFSET) {
|
||||
tscDebug("consumer:%" PRId64 ", return null since no committed offset", tmq->consumerId);
|
||||
|
|
|
@ -285,7 +285,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int
|
|||
// ASSERT(finalNumOfRows * pColumnInfoData->info.bytes);
|
||||
char* tmp = taosMemoryRealloc(pColumnInfoData->pData, finalNumOfRows * pColumnInfoData->info.bytes);
|
||||
if (tmp == NULL) {
|
||||
return TSDB_CODE_VND_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pColumnInfoData->pData = tmp;
|
||||
|
@ -1132,6 +1132,10 @@ void blockDataCleanup(SSDataBlock* pDataBlock) {
|
|||
pDataBlock->info.window.ekey = 0;
|
||||
pDataBlock->info.window.skey = 0;
|
||||
|
||||
if (pDataBlock->info.capacity == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
SColumnInfoData* p = taosArrayGet(pDataBlock->pDataBlock, i);
|
||||
|
@ -1186,6 +1190,7 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo*
|
|||
}
|
||||
|
||||
void colInfoDataCleanup(SColumnInfoData* pColumn, uint32_t numOfRows) {
|
||||
pColumn->hasNull = false;
|
||||
if (IS_VAR_DATA_TYPE(pColumn->info.type)) {
|
||||
pColumn->varmeta.length = 0;
|
||||
if (pColumn->varmeta.offset != NULL) {
|
||||
|
@ -1908,6 +1913,22 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
|
|||
len += snprintf(dumpBuf + len, size - len, " %25s |", pBuf);
|
||||
if (len >= size - 1) return dumpBuf;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int8_t*)var);
|
||||
if (len >= size - 1) return dumpBuf;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(uint8_t*)var);
|
||||
if (len >= size - 1) return dumpBuf;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int16_t*)var);
|
||||
if (len >= size - 1) return dumpBuf;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(uint16_t*)var);
|
||||
if (len >= size - 1) return dumpBuf;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int32_t*)var);
|
||||
if (len >= size - 1) return dumpBuf;
|
||||
|
@ -2063,8 +2084,8 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB
|
|||
default:
|
||||
if (pColInfoData->info.type < TSDB_DATA_TYPE_MAX && pColInfoData->info.type > TSDB_DATA_TYPE_NULL) {
|
||||
if (colDataIsNull_s(pColInfoData, j)) {
|
||||
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, pCol->type, TD_VTYPE_NULL, NULL, false, offset,
|
||||
k);
|
||||
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, pCol->type, TD_VTYPE_NULL, NULL, false,
|
||||
offset, k);
|
||||
} else if (pCol->type == pColInfoData->info.type) {
|
||||
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, pCol->type, TD_VTYPE_NORM, var, true, offset,
|
||||
k);
|
||||
|
@ -2137,10 +2158,26 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId) {
|
||||
ASSERT(stbName[0] != 0);
|
||||
char* buildCtbNameByGroupId(const char* stbFullName, uint64_t groupId) {
|
||||
ASSERT(stbFullName[0] != 0);
|
||||
SArray* tags = taosArrayInit(0, sizeof(void*));
|
||||
if (tags == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SSmlKv* pTag = taosMemoryCalloc(1, sizeof(SSmlKv));
|
||||
if (pTag == NULL) {
|
||||
taosArrayDestroy(tags);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* cname = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN + 1);
|
||||
if (cname == NULL) {
|
||||
taosArrayDestroy(tags);
|
||||
taosMemoryFree(pTag);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pTag->key = "group_id";
|
||||
pTag->keyLen = strlen(pTag->key);
|
||||
pTag->type = TSDB_DATA_TYPE_UBIGINT;
|
||||
|
@ -2148,13 +2185,11 @@ char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId) {
|
|||
pTag->length = sizeof(uint64_t);
|
||||
taosArrayPush(tags, &pTag);
|
||||
|
||||
void* cname = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN + 1);
|
||||
|
||||
RandTableName rname = {
|
||||
.tags = tags,
|
||||
.sTableName = stbName,
|
||||
.sTableNameLen = strlen(stbName),
|
||||
.childTableName = cname,
|
||||
.stbFullName = stbFullName,
|
||||
.stbFullNameLen = strlen(stbFullName),
|
||||
.ctbShortName = cname,
|
||||
};
|
||||
|
||||
buildChildTableName(&rname);
|
||||
|
@ -2162,8 +2197,8 @@ char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId) {
|
|||
taosMemoryFree(pTag);
|
||||
taosArrayDestroy(tags);
|
||||
|
||||
ASSERT(rname.childTableName && rname.childTableName[0]);
|
||||
return rname.childTableName;
|
||||
ASSERT(rname.ctbShortName && rname.ctbShortName[0]);
|
||||
return rname.ctbShortName;
|
||||
}
|
||||
|
||||
void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols, int8_t needCompress) {
|
||||
|
|
|
@ -156,6 +156,9 @@ char tsCompressor[32] = "ZSTD_COMPRESSOR"; // ZSTD_COMPRESSOR or GZIP_COMPR
|
|||
// udf
|
||||
bool tsStartUdfd = true;
|
||||
|
||||
// wal
|
||||
int64_t tsWalFsyncDataSizeLimit = (100 * 1024 * 1024L);
|
||||
|
||||
// internal
|
||||
int32_t tsTransPullupInterval = 2;
|
||||
int32_t tsMqRebalanceInterval = 2;
|
||||
|
@ -163,7 +166,8 @@ int32_t tsTtlUnit = 86400;
|
|||
int32_t tsTtlPushInterval = 86400;
|
||||
int32_t tsGrantHBInterval = 60;
|
||||
int32_t tsUptimeInterval = 300; // seconds
|
||||
char tsUdfdResFuncs[1024] = ""; // udfd resident funcs that teardown when udfd exits
|
||||
char tsUdfdResFuncs[512] = ""; // udfd resident funcs that teardown when udfd exits
|
||||
char tsUdfdLdLibPath[512] = "";
|
||||
|
||||
#ifndef _STORAGE
|
||||
int32_t taosSetTfsCfg(SConfig *pCfg) {
|
||||
|
@ -422,8 +426,12 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
if (cfgAddInt32(pCfg, "uptimeInterval", tsUptimeInterval, 1, 100000, 1) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "queryRsmaTolerance", tsQueryRsmaTolerance, 0, 900000, 0) != 0) return -1;
|
||||
|
||||
if (cfgAddInt64(pCfg, "walFsyncDataSizeLimit", tsWalFsyncDataSizeLimit, 100 * 1024 * 1024, INT64_MAX, 0) != 0)
|
||||
return -1;
|
||||
|
||||
if (cfgAddBool(pCfg, "udf", tsStartUdfd, 0) != 0) return -1;
|
||||
if (cfgAddString(pCfg, "udfdResFuncs", tsUdfdResFuncs, 0) != 0) return -1;
|
||||
if (cfgAddString(pCfg, "udfdLdLibPath", tsUdfdLdLibPath, 0) != 0) return -1;
|
||||
GRANT_CFG_ADD;
|
||||
return 0;
|
||||
}
|
||||
|
@ -720,9 +728,11 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
tsUptimeInterval = cfgGetItem(pCfg, "uptimeInterval")->i32;
|
||||
tsQueryRsmaTolerance = cfgGetItem(pCfg, "queryRsmaTolerance")->i32;
|
||||
|
||||
tsWalFsyncDataSizeLimit = cfgGetItem(pCfg, "walFsyncDataSizeLimit")->i64;
|
||||
|
||||
tsStartUdfd = cfgGetItem(pCfg, "udf")->bval;
|
||||
tstrncpy(tsUdfdResFuncs, cfgGetItem(pCfg, "udfdResFuncs")->str, sizeof(tsUdfdResFuncs));
|
||||
|
||||
tstrncpy(tsUdfdLdLibPath, cfgGetItem(pCfg, "udfdLdLibPath")->str, sizeof(tsUdfdLdLibPath));
|
||||
if (tsQueryBufferSize >= 0) {
|
||||
tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
|
||||
}
|
||||
|
|
|
@ -1020,6 +1020,7 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
|||
if (tEncodeI64(&encoder, pReq->qload.timeInQueryQueue) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->qload.timeInFetchQueue) < 0) return -1;
|
||||
|
||||
if (tEncodeI32(&encoder, pReq->statusSeq) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
|
@ -1095,6 +1096,7 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
|||
if (tDecodeI64(&decoder, &pReq->qload.timeInQueryQueue) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->qload.timeInFetchQueue) < 0) return -1;
|
||||
|
||||
if (tDecodeI32(&decoder, &pReq->statusSeq) < 0) return -1;
|
||||
tEndDecode(&decoder);
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
|
@ -1126,6 +1128,7 @@ int32_t tSerializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) {
|
|||
if (tEncodeU16(&encoder, pDnodeEp->ep.port) < 0) return -1;
|
||||
}
|
||||
|
||||
if (tEncodeI32(&encoder, pRsp->statusSeq) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
|
@ -1167,6 +1170,7 @@ int32_t tDeserializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) {
|
|||
}
|
||||
}
|
||||
|
||||
if (tDecodeI32(&decoder, &pRsp->statusSeq) < 0) return -1;
|
||||
tEndDecode(&decoder);
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
|
@ -1485,6 +1489,7 @@ int32_t tSerializeSDropDnodeReq(void *buf, int32_t bufLen, SDropDnodeReq *pReq)
|
|||
if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->fqdn) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->port) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->force) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
|
@ -1500,6 +1505,7 @@ int32_t tDeserializeSDropDnodeReq(void *buf, int32_t bufLen, SDropDnodeReq *pReq
|
|||
if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->fqdn) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->port) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->force) < 0) return -1;
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
|
@ -5430,9 +5436,12 @@ static int32_t tEncodeSSubmitBlkRsp(SEncoder *pEncoder, const SSubmitBlkRsp *pBl
|
|||
if (tStartEncode(pEncoder) < 0) return -1;
|
||||
|
||||
if (tEncodeI32(pEncoder, pBlock->code) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pBlock->hashMeta) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pBlock->uid) < 0) return -1;
|
||||
if (tEncodeCStr(pEncoder, pBlock->tblFName) < 0) return -1;
|
||||
if (pBlock->tblFName) {
|
||||
if (tEncodeCStr(pEncoder, pBlock->tblFName) < 0) return -1;
|
||||
} else {
|
||||
if (tEncodeCStr(pEncoder, "") < 0) return -1;
|
||||
}
|
||||
if (tEncodeI32v(pEncoder, pBlock->numOfRows) < 0) return -1;
|
||||
if (tEncodeI32v(pEncoder, pBlock->affectedRows) < 0) return -1;
|
||||
if (tEncodeI64v(pEncoder, pBlock->sver) < 0) return -1;
|
||||
|
@ -5449,7 +5458,6 @@ static int32_t tDecodeSSubmitBlkRsp(SDecoder *pDecoder, SSubmitBlkRsp *pBlock) {
|
|||
if (tStartDecode(pDecoder) < 0) return -1;
|
||||
|
||||
if (tDecodeI32(pDecoder, &pBlock->code) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pBlock->hashMeta) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pBlock->uid) < 0) return -1;
|
||||
pBlock->tblFName = taosMemoryCalloc(TSDB_TABLE_FNAME_LEN, 1);
|
||||
if (NULL == pBlock->tblFName) return -1;
|
||||
|
|
|
@ -315,7 +315,7 @@ static int compareKv(const void* p1, const void* p2) {
|
|||
*/
|
||||
void buildChildTableName(RandTableName* rName) {
|
||||
SStringBuilder sb = {0};
|
||||
taosStringBuilderAppendStringLen(&sb, rName->sTableName, rName->sTableNameLen);
|
||||
taosStringBuilderAppendStringLen(&sb, rName->stbFullName, rName->stbFullNameLen);
|
||||
taosArraySort(rName->tags, compareKv);
|
||||
for (int j = 0; j < taosArrayGetSize(rName->tags); ++j) {
|
||||
taosStringBuilderAppendChar(&sb, ',');
|
||||
|
@ -336,11 +336,11 @@ void buildChildTableName(RandTableName* rName) {
|
|||
tMD5Final(&context);
|
||||
|
||||
char temp[8] = {0};
|
||||
rName->childTableName[0] = 't';
|
||||
rName->childTableName[1] = '_';
|
||||
rName->ctbShortName[0] = 't';
|
||||
rName->ctbShortName[1] = '_';
|
||||
for (int i = 0; i < 16; i++) {
|
||||
sprintf(temp, "%02x", context.digest[i]);
|
||||
strcat(rName->childTableName, temp);
|
||||
strcat(rName->ctbShortName, temp);
|
||||
}
|
||||
taosStringBuilderDestroy(&sb);
|
||||
rName->uid = *(uint64_t*)(context.digest);
|
||||
|
|
|
@ -31,7 +31,7 @@ static int32_t STSBufUpdateHeader(STSBuf* pTSBuf, STSBufFileHeader* pHeader);
|
|||
*/
|
||||
STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
|
||||
if (!osTempSpaceAvailable()) {
|
||||
terrno = TSDB_CODE_TSC_NO_DISKSPACE;
|
||||
terrno = TSDB_CODE_NO_DISKSPACE;
|
||||
// tscError("tmp file created failed since %s", terrstr());
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -13,4 +13,18 @@ target_include_directories(
|
|||
taosd
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/node_mgmt/inc"
|
||||
)
|
||||
target_link_libraries(taosd dnode)
|
||||
|
||||
IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
|
||||
ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc)
|
||||
SET(LINK_JEMALLOC "-L${CMAKE_BINARY_DIR}/build/lib -ljemalloc")
|
||||
ELSE ()
|
||||
SET(LINK_JEMALLOC "")
|
||||
ENDIF ()
|
||||
|
||||
IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
|
||||
ADD_DEPENDENCIES(taosd jemalloc)
|
||||
target_link_libraries(taosd dnode ${LINK_JEMALLOC})
|
||||
ELSE ()
|
||||
target_link_libraries(taosd dnode)
|
||||
ENDIF ()
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ typedef struct SDnodeMgmt {
|
|||
GetVnodeLoadsFp getVnodeLoadsFp;
|
||||
GetMnodeLoadsFp getMnodeLoadsFp;
|
||||
GetQnodeLoadsFp getQnodeLoadsFp;
|
||||
int32_t statusSeq;
|
||||
} SDnodeMgmt;
|
||||
|
||||
// dmHandle.c
|
||||
|
|
|
@ -32,9 +32,13 @@ static void dmUpdateDnodeCfg(SDnodeMgmt *pMgmt, SDnodeCfg *pCfg) {
|
|||
}
|
||||
|
||||
static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
||||
const STraceId *trace = &pRsp->info.traceId;
|
||||
dGTrace("status rsp received from mnode, statusSeq:%d code:0x%x", pMgmt->statusSeq, pRsp->code);
|
||||
|
||||
if (pRsp->code != 0) {
|
||||
if (pRsp->code == TSDB_CODE_MND_DNODE_NOT_EXIST && !pMgmt->pData->dropped && pMgmt->pData->dnodeId > 0) {
|
||||
dInfo("dnode:%d, set to dropped since not exist in mnode", pMgmt->pData->dnodeId);
|
||||
dGInfo("dnode:%d, set to dropped since not exist in mnode, statusSeq:%d", pMgmt->pData->dnodeId,
|
||||
pMgmt->statusSeq);
|
||||
pMgmt->pData->dropped = 1;
|
||||
dmWriteEps(pMgmt->pData);
|
||||
}
|
||||
|
@ -42,9 +46,9 @@ static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
|||
SStatusRsp statusRsp = {0};
|
||||
if (pRsp->pCont != NULL && pRsp->contLen > 0 &&
|
||||
tDeserializeSStatusRsp(pRsp->pCont, pRsp->contLen, &statusRsp) == 0) {
|
||||
dTrace("status msg received from mnode, dnodeVer:%" PRId64 " saved:%" PRId64, statusRsp.dnodeVer,
|
||||
pMgmt->pData->dnodeVer);
|
||||
if (pMgmt->pData->dnodeVer != statusRsp.dnodeVer) {
|
||||
dGInfo("status rsp received from mnode, statusSeq:%d:%d dnodeVer:%" PRId64 ":%" PRId64, pMgmt->statusSeq,
|
||||
statusRsp.statusSeq, pMgmt->pData->dnodeVer, statusRsp.dnodeVer);
|
||||
pMgmt->pData->dnodeVer = statusRsp.dnodeVer;
|
||||
dmUpdateDnodeCfg(pMgmt, &statusRsp.dnodeCfg);
|
||||
dmUpdateEps(pMgmt->pData, statusRsp.pDnodeEps);
|
||||
|
@ -91,6 +95,9 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
|||
|
||||
(*pMgmt->getQnodeLoadsFp)(&req.qload);
|
||||
|
||||
pMgmt->statusSeq++;
|
||||
req.statusSeq = pMgmt->statusSeq;
|
||||
|
||||
int32_t contLen = tSerializeSStatusReq(NULL, 0, &req);
|
||||
void *pHead = rpcMallocCont(contLen);
|
||||
tSerializeSStatusReq(pHead, contLen, &req);
|
||||
|
@ -99,13 +106,13 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
|||
SRpcMsg rpcMsg = {.pCont = pHead, .contLen = contLen, .msgType = TDMT_MND_STATUS, .info.ahandle = (void *)0x9527};
|
||||
SRpcMsg rpcRsp = {0};
|
||||
|
||||
dTrace("send status msg to mnode, dnodeVer:%" PRId64, req.dnodeVer);
|
||||
dTrace("send status req to mnode, dnodeVer:%" PRId64 " statusSeq:%d", req.dnodeVer, req.statusSeq);
|
||||
|
||||
SEpSet epSet = {0};
|
||||
dmGetMnodeEpSet(pMgmt->pData, &epSet);
|
||||
rpcSendRecv(pMgmt->msgCb.clientRpc, &epSet, &rpcMsg, &rpcRsp);
|
||||
if (rpcRsp.code != 0) {
|
||||
dError("failed to send status msg since %s, numOfEps:%d inUse:%d", tstrerror(rpcRsp.code), epSet.numOfEps,
|
||||
dError("failed to send status req since %s, numOfEps:%d inUse:%d", tstrerror(rpcRsp.code), epSet.numOfEps,
|
||||
epSet.inUse);
|
||||
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
||||
dDebug("index:%d, mnode ep:%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port);
|
||||
|
|
|
@ -20,7 +20,7 @@ static void *dmStatusThreadFp(void *param) {
|
|||
SDnodeMgmt *pMgmt = param;
|
||||
int64_t lastTime = taosGetTimestampMs();
|
||||
setThreadName("dnode-status");
|
||||
|
||||
|
||||
while (1) {
|
||||
taosMsleep(200);
|
||||
if (pMgmt->pData->dropped || pMgmt->pData->stopped) break;
|
||||
|
@ -28,6 +28,7 @@ static void *dmStatusThreadFp(void *param) {
|
|||
int64_t curTime = taosGetTimestampMs();
|
||||
float interval = (curTime - lastTime) / 1000.0f;
|
||||
if (interval >= tsStatusInterval) {
|
||||
taosMemoryTrim(0);
|
||||
dmSendStatusReq(pMgmt);
|
||||
lastTime = curTime;
|
||||
}
|
||||
|
|
|
@ -141,15 +141,13 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_INDEX, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_TABLE_INDEX, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_TOPIC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_TOPIC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TOPIC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SUBSCRIBE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_ASK_EP, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_HB, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_DROP_CGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_DROP_CGROUP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_COMMIT_OFFSET, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_TMQ_CREATE_TOPIC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_TMQ_DROP_TOPIC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_TMQ_SUBSCRIBE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_TMQ_ASK_EP, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_TMQ_HB, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_TMQ_DROP_CGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_TMQ_DROP_CGROUP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_TRANS, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_QUERY, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_CONN, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
@ -171,10 +169,10 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_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_DELETE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ADD_CHECK_INFO_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DELETE_CHECK_INFO_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_SUBSCRIBE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_DELETE_SUB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_ADD_CHECKINFO_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_DEL_CHECKINFO_RSP, mmPutMsgToWriteQueue, 0) == 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_DROP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
@ -197,6 +195,8 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, mmPutMsgToSyncCtrlQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, mmPutMsgToSyncCtrlQueue, 1) == NULL) goto _OVER;
|
||||
|
|
|
@ -67,24 +67,6 @@ static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
||||
static void mmProcessSyncCtrlMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||
SMnodeMgmt *pMgmt = pInfo->ahandle;
|
||||
pMsg->info.node = pMgmt->pMnode;
|
||||
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
dGTrace("msg:%p, get from mnode-sync-ctrl queue", pMsg);
|
||||
|
||||
SMsgHead *pHead = pMsg->pCont;
|
||||
pHead->contLen = ntohl(pHead->contLen);
|
||||
pHead->vgId = ntohl(pHead->vgId);
|
||||
|
||||
int32_t code = mndProcessSyncCtrlMsg(pMsg);
|
||||
|
||||
dGTrace("msg:%p, is freed, code:0x%x", pMsg, code);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
||||
static void mmProcessSyncMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||
SMnodeMgmt *pMgmt = pInfo->ahandle;
|
||||
pMsg->info.node = pMgmt->pMnode;
|
||||
|
@ -252,7 +234,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
|||
.min = 1,
|
||||
.max = 1,
|
||||
.name = "mnode-sync-ctrl",
|
||||
.fp = (FItem)mmProcessSyncCtrlMsg,
|
||||
.fp = (FItem)mmProcessSyncMsg,
|
||||
.param = pMgmt,
|
||||
};
|
||||
if (tSingleWorkerInit(&pMgmt->syncCtrlWorker, &scCfg) != 0) {
|
||||
|
|
|
@ -72,8 +72,6 @@ SArray *smGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RUN, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RECOVER, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RECOVER_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER;
|
||||
|
||||
|
|
|
@ -58,7 +58,11 @@ static void smProcessStreamQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
dTrace("msg:%p, get from snode-stream queue", pMsg);
|
||||
int32_t code = sndProcessStreamMsg(pMgmt->pSnode, pMsg);
|
||||
if (code < 0) {
|
||||
dGError("snd, msg:%p failed to process stream since %s", pMsg, terrstr(code));
|
||||
if (pMsg) {
|
||||
dGError("snd, msg:%p failed to process stream msg %s since %s", pMsg, TMSG_INFO(pMsg->msgType), terrstr(code));
|
||||
} else {
|
||||
dGError("snd, msg:%p failed to process stream empty msg since %s", pMsg, terrstr(code));
|
||||
}
|
||||
smSendRsp(pMsg, terrno);
|
||||
}
|
||||
|
||||
|
|
|
@ -392,27 +392,28 @@ SArray *vmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_VND_CANCEL_SMA, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_SMA, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SUBMIT_RSMA, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_CHANGE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_COMMIT_OFFSET, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ADD_CHECK_INFO, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DELETE_CHECK_INFO, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CONSUME, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_SUBSCRIBE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_DELETE_SUB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_COMMIT_OFFSET, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_ADD_CHECKINFO, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_DEL_CHECKINFO, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_CONSUME, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DELETE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_BATCH_DEL, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_COMMIT, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY_HEARTBEAT, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TRIGGER, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RUN, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH_RSP, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RECOVER, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RECOVER_RSP, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE_RSP, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_RECOVER_FINISH, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_CHECK, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_CHECK_RSP, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TRIGGER, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
@ -436,6 +437,9 @@ SArray *vmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
|
|
|
@ -86,7 +86,12 @@ static void vmProcessStreamQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
int32_t code = vnodeProcessFetchMsg(pVnode->pImpl, pMsg, pInfo);
|
||||
if (code != 0) {
|
||||
if (terrno != 0) code = terrno;
|
||||
dGError("vgId:%d, msg:%p failed to process stream since %s", pVnode->vgId, pMsg, terrstr(code));
|
||||
if (pMsg) {
|
||||
dGError("vgId:%d, msg:%p failed to process stream msg %s since %s", pVnode->vgId, pMsg, TMSG_INFO(pMsg->msgType),
|
||||
terrstr(code));
|
||||
} else {
|
||||
dGError("vgId:%d, msg:%p failed to process stream empty msg since %s", pVnode->vgId, pMsg, terrstr(code));
|
||||
}
|
||||
vmSendRsp(pMsg, code);
|
||||
}
|
||||
|
||||
|
@ -133,22 +138,6 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf
|
|||
}
|
||||
}
|
||||
|
||||
static void vmProcessSyncCtrlQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||
SVnodeObj *pVnode = pInfo->ahandle;
|
||||
SRpcMsg *pMsg = NULL;
|
||||
|
||||
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
||||
if (taosGetQitem(qall, (void **)&pMsg) == 0) continue;
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
dGTrace("vgId:%d, msg:%p get from vnode-sync queue", pVnode->vgId, pMsg);
|
||||
|
||||
int32_t code = vnodeProcessSyncCtrlMsg(pVnode->pImpl, pMsg, NULL); // no response here
|
||||
dGTrace("vgId:%d, msg:%p is freed, code:0x%x", pVnode->vgId, pMsg, code);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtype) {
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
SMsgHead *pHead = pMsg->pCont;
|
||||
|
@ -190,7 +179,7 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
|
|||
break;
|
||||
case WRITE_QUEUE:
|
||||
if (!osDataSpaceAvailable()) {
|
||||
terrno = TSDB_CODE_VND_NO_DISKSPACE;
|
||||
terrno = TSDB_CODE_NO_DISKSPACE;
|
||||
code = terrno;
|
||||
dError("vgId:%d, msg:%p put into vnode-write queue failed since %s", pVnode->vgId, pMsg, terrstr(code));
|
||||
} else if ((pMsg->msgType == TDMT_VND_SUBMIT) && (grantCheck(TSDB_GRANT_STORAGE) != TSDB_CODE_SUCCESS)) {
|
||||
|
@ -234,7 +223,9 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t vmPutMsgToSyncCtrlQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return vmPutMsgToQueue(pMgmt, pMsg, SYNC_CTRL_QUEUE); }
|
||||
int32_t vmPutMsgToSyncCtrlQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
return vmPutMsgToQueue(pMgmt, pMsg, SYNC_CTRL_QUEUE);
|
||||
}
|
||||
|
||||
int32_t vmPutMsgToSyncQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return vmPutMsgToQueue(pMgmt, pMsg, SYNC_QUEUE); }
|
||||
|
||||
|
@ -317,7 +308,7 @@ int32_t vmGetQueueSize(SVnodeMgmt *pMgmt, int32_t vgId, EQueueType qtype) {
|
|||
int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||
pVnode->pWriteQ = tWWorkerAllocQueue(&pMgmt->writePool, pVnode->pImpl, (FItems)vnodeProposeWriteMsg);
|
||||
pVnode->pSyncQ = tWWorkerAllocQueue(&pMgmt->syncPool, pVnode, (FItems)vmProcessSyncQueue);
|
||||
pVnode->pSyncCtrlQ = tWWorkerAllocQueue(&pMgmt->syncCtrlPool, pVnode, (FItems)vmProcessSyncCtrlQueue);
|
||||
pVnode->pSyncCtrlQ = tWWorkerAllocQueue(&pMgmt->syncCtrlPool, pVnode, (FItems)vmProcessSyncQueue);
|
||||
pVnode->pApplyQ = tWWorkerAllocQueue(&pMgmt->applyPool, pVnode->pImpl, (FItems)vnodeApplyWriteMsg);
|
||||
pVnode->pQueryQ = tQWorkerAllocQueue(&pMgmt->queryPool, pVnode, (FItem)vmProcessQueryQueue);
|
||||
pVnode->pStreamQ = tQWorkerAllocQueue(&pMgmt->streamPool, pVnode, (FItem)vmProcessStreamQueue);
|
||||
|
|
|
@ -71,17 +71,17 @@ static bool dmCheckDiskSpace() {
|
|||
bool ret = true;
|
||||
if (!osDataSpaceAvailable()) {
|
||||
dError("data disk space unavailable, i.e. %s", tsDataDir);
|
||||
terrno = TSDB_CODE_VND_NO_DISKSPACE;
|
||||
terrno = TSDB_CODE_NO_DISKSPACE;
|
||||
ret = false;
|
||||
}
|
||||
if (!osLogSpaceAvailable()) {
|
||||
dError("log disk space unavailable, i.e. %s", tsLogDir);
|
||||
terrno = TSDB_CODE_VND_NO_DISKSPACE;
|
||||
terrno = TSDB_CODE_NO_DISKSPACE;
|
||||
ret = false;
|
||||
}
|
||||
if (!osTempSpaceAvailable()) {
|
||||
dError("temp disk space unavailable, i.e. %s", tsTempDir);
|
||||
terrno = TSDB_CODE_VND_NO_DISKSPACE;
|
||||
terrno = TSDB_CODE_NO_DISKSPACE;
|
||||
ret = false;
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -105,6 +105,7 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
|||
}
|
||||
|
||||
if (IsReq(pRpc) && pRpc->pCont == NULL) {
|
||||
dGError("msg:%p, type:%s pCont is NULL", pRpc, TMSG_INFO(pRpc->msgType));
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -133,6 +134,7 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
dGError("msg:%p, type:%s contLen is 0", pRpc, TMSG_INFO(pRpc->msgType));
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -155,7 +157,11 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
|||
_OVER:
|
||||
if (code != 0) {
|
||||
if (terrno != 0) code = terrno;
|
||||
dGTrace("msg:%p, failed to process since %s", pMsg, terrstr());
|
||||
if (pMsg) {
|
||||
dGTrace("msg:%p, failed to process %s since %s", pMsg, TMSG_INFO(pMsg->msgType), terrstr());
|
||||
} else {
|
||||
dGTrace("msg:%p, failed to process empty msg since %s", pMsg, terrstr());
|
||||
}
|
||||
|
||||
if (IsReq(pRpc)) {
|
||||
SRpcMsg rsp = {.code = code, .info = pRpc->info};
|
||||
|
|
|
@ -55,7 +55,7 @@ void *dmSetMgmtHandle(SArray *pArray, tmsg_t msgType, void *nodeMsgFp, bool need
|
|||
}
|
||||
|
||||
void dmGetMonitorSystemInfo(SMonSysInfo *pInfo) {
|
||||
taosGetCpuUsage(&pInfo->cpu_engine, &pInfo->cpu_system);
|
||||
taosGetCpuUsage(&pInfo->cpu_system, &pInfo->cpu_engine);
|
||||
taosGetCpuCores(&pInfo->cpu_cores);
|
||||
taosGetProcMemory(&pInfo->mem_engine);
|
||||
taosGetSysMemory(&pInfo->mem_system);
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include "sdb.h"
|
||||
#include "sync.h"
|
||||
#include "syncTools.h"
|
||||
#include "tcache.h"
|
||||
#include "tdatablock.h"
|
||||
#include "tglobal.h"
|
||||
|
@ -90,7 +89,6 @@ typedef struct {
|
|||
int32_t errCode;
|
||||
int32_t transId;
|
||||
SRWLatch lock;
|
||||
int8_t leaderTransferFinish;
|
||||
int8_t selfIndex;
|
||||
int8_t numOfReplicas;
|
||||
SReplica replicas[TSDB_MAX_REPLICA];
|
||||
|
|
|
@ -28,7 +28,7 @@ SMnodeObj *mndAcquireMnode(SMnode *pMnode, int32_t mnodeId);
|
|||
void mndReleaseMnode(SMnode *pMnode, SMnodeObj *pObj);
|
||||
bool mndIsMnode(SMnode *pMnode, int32_t dnodeId);
|
||||
void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet);
|
||||
int32_t mndSetDropMnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj);
|
||||
int32_t mndSetDropMnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj, bool force);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ void mndCleanupQnode(SMnode *pMnode);
|
|||
SQnodeObj *mndAcquireQnode(SMnode *pMnode, int32_t qnodeId);
|
||||
void mndReleaseQnode(SMnode *pMnode, SQnodeObj *pObj);
|
||||
int32_t mndCreateQnodeList(SMnode *pMnode, SArray **pList, int32_t limit);
|
||||
int32_t mndSetDropQnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SQnodeObj *pObj);
|
||||
int32_t mndSetDropQnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SQnodeObj *pObj, bool force);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ void mndCleanupSnode(SMnode *pMnode);
|
|||
SSnodeObj *mndAcquireSnode(SMnode *pMnode, int32_t qnodeId);
|
||||
void mndReleaseSnode(SMnode *pMnode, SSnodeObj *pObj);
|
||||
SEpSet mndAcquireEpFromSnode(SMnode *pMnode, const SSnodeObj *pSnode);
|
||||
int32_t mndSetDropSnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SSnodeObj *pObj);
|
||||
int32_t mndSetDropSnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SSnodeObj *pObj, bool force);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -42,8 +42,7 @@ int32_t mndAddCreateVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *p
|
|||
int32_t mndAddAlterVnodeConfirmAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup);
|
||||
int32_t mndAddAlterVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, tmsg_t msgType);
|
||||
int32_t mndAddDropVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid, bool isRedo);
|
||||
int32_t mndSetMoveVgroupInfoToTrans(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, int32_t vn, SArray *pArray);
|
||||
int32_t mndSetMoveVgroupsInfoToTrans(SMnode *, STrans *pTrans, int32_t dropDnodeId);
|
||||
int32_t mndSetMoveVgroupsInfoToTrans(SMnode *, STrans *pTrans, int32_t dropDnodeId, bool force);
|
||||
int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb, SDbObj *pNewDb, SVgObj *pVgroup,
|
||||
SArray *pArray);
|
||||
|
||||
|
|
|
@ -63,12 +63,12 @@ int32_t mndInitConsumer(SMnode *pMnode) {
|
|||
.deleteFp = (SdbDeleteFp)mndConsumerActionDelete,
|
||||
};
|
||||
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_SUBSCRIBE, mndProcessSubscribeReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_MQ_HB, mndProcessMqHbReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_MQ_ASK_EP, mndProcessAskEpReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_MQ_TIMER, mndProcessMqTimerMsg);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_MQ_CONSUMER_LOST, mndProcessConsumerLostMsg);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_MQ_CONSUMER_RECOVER, mndProcessConsumerRecoverMsg);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_SUBSCRIBE, mndProcessSubscribeReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_HB, mndProcessMqHbReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_ASK_EP, mndProcessAskEpReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_TIMER, mndProcessMqTimerMsg);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_CONSUMER_LOST, mndProcessConsumerLostMsg);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_CONSUMER_RECOVER, mndProcessConsumerRecoverMsg);
|
||||
|
||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONSUMERS, mndRetrieveConsumer);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONSUMERS, mndCancelGetNextConsumer);
|
||||
|
@ -207,7 +207,7 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) {
|
|||
|
||||
pLostMsg->consumerId = pConsumer->consumerId;
|
||||
SRpcMsg pRpcMsg = {
|
||||
.msgType = TDMT_MND_MQ_CONSUMER_LOST,
|
||||
.msgType = TDMT_MND_TMQ_CONSUMER_LOST,
|
||||
.pCont = pLostMsg,
|
||||
.contLen = sizeof(SMqConsumerLostMsg),
|
||||
};
|
||||
|
@ -256,7 +256,7 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) {
|
|||
if (taosHashGetSize(pRebMsg->rebSubHash) != 0) {
|
||||
mInfo("mq rebalance will be triggered");
|
||||
SRpcMsg rpcMsg = {
|
||||
.msgType = TDMT_MND_MQ_DO_REBALANCE,
|
||||
.msgType = TDMT_MND_TMQ_DO_REBALANCE,
|
||||
.pCont = pRebMsg,
|
||||
.contLen = sizeof(SMqDoRebalanceMsg),
|
||||
};
|
||||
|
@ -292,7 +292,7 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
|
|||
|
||||
pRecoverMsg->consumerId = consumerId;
|
||||
SRpcMsg pRpcMsg = {
|
||||
.msgType = TDMT_MND_MQ_CONSUMER_RECOVER,
|
||||
.msgType = TDMT_MND_TMQ_CONSUMER_RECOVER,
|
||||
.pCont = pRecoverMsg,
|
||||
.contLen = sizeof(SMqConsumerRecoverMsg),
|
||||
};
|
||||
|
@ -331,7 +331,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) {
|
|||
|
||||
pRecoverMsg->consumerId = consumerId;
|
||||
SRpcMsg pRpcMsg = {
|
||||
.msgType = TDMT_MND_MQ_CONSUMER_RECOVER,
|
||||
.msgType = TDMT_MND_TMQ_CONSUMER_RECOVER,
|
||||
.pCont = pRecoverMsg,
|
||||
.contLen = sizeof(SMqConsumerRecoverMsg),
|
||||
};
|
||||
|
|
|
@ -345,6 +345,19 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
}
|
||||
}
|
||||
|
||||
int64_t dnodeVer = sdbGetTableVer(pMnode->pSdb, SDB_DNODE) + sdbGetTableVer(pMnode->pSdb, SDB_MNODE);
|
||||
int64_t curMs = taosGetTimestampMs();
|
||||
bool online = mndIsDnodeOnline(pDnode, curMs);
|
||||
bool dnodeChanged = (statusReq.dnodeVer == 0) || (statusReq.dnodeVer != dnodeVer);
|
||||
bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
|
||||
bool needCheck = !online || dnodeChanged || reboot;
|
||||
|
||||
pDnode->accessTimes++;
|
||||
pDnode->lastAccessTime = curMs;
|
||||
const STraceId *trace = &pReq->info.traceId;
|
||||
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
||||
pDnode->accessTimes, needCheck, online, reboot, dnodeChanged, statusReq.statusSeq);
|
||||
|
||||
for (int32_t v = 0; v < taosArrayGetSize(statusReq.pVloads); ++v) {
|
||||
SVnodeLoad *pVload = taosArrayGet(statusReq.pVloads, v);
|
||||
|
||||
|
@ -396,13 +409,6 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
mndReleaseQnode(pMnode, pQnode);
|
||||
}
|
||||
|
||||
int64_t dnodeVer = sdbGetTableVer(pMnode->pSdb, SDB_DNODE) + sdbGetTableVer(pMnode->pSdb, SDB_MNODE);
|
||||
int64_t curMs = taosGetTimestampMs();
|
||||
bool online = mndIsDnodeOnline(pDnode, curMs);
|
||||
bool dnodeChanged = (statusReq.dnodeVer == 0) || (statusReq.dnodeVer != dnodeVer);
|
||||
bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
|
||||
bool needCheck = !online || dnodeChanged || reboot;
|
||||
|
||||
if (needCheck) {
|
||||
if (statusReq.sver != tsVersion) {
|
||||
if (pDnode != NULL) {
|
||||
|
@ -424,9 +430,6 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
pMnode->clusterId);
|
||||
terrno = TSDB_CODE_MND_INVALID_CLUSTER_ID;
|
||||
goto _OVER;
|
||||
} else {
|
||||
pDnode->accessTimes++;
|
||||
mDebug("dnode:%d, status received, access times %d", pDnode->id, pDnode->accessTimes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,6 +456,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
pDnode->memTotal = statusReq.memTotal;
|
||||
|
||||
SStatusRsp statusRsp = {0};
|
||||
statusRsp.statusSeq++;
|
||||
statusRsp.dnodeVer = dnodeVer;
|
||||
statusRsp.dnodeCfg.dnodeId = pDnode->id;
|
||||
statusRsp.dnodeCfg.clusterId = pMnode->clusterId;
|
||||
|
@ -473,8 +477,6 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
pReq->info.rsp = pHead;
|
||||
}
|
||||
|
||||
pDnode->lastAccessTime = curMs;
|
||||
pDnode->accessTimes++;
|
||||
code = 0;
|
||||
|
||||
_OVER:
|
||||
|
@ -670,7 +672,7 @@ _OVER:
|
|||
}
|
||||
|
||||
static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SMnodeObj *pMObj, SQnodeObj *pQObj,
|
||||
SSnodeObj *pSObj, int32_t numOfVnodes) {
|
||||
SSnodeObj *pSObj, int32_t numOfVnodes, bool force) {
|
||||
int32_t code = -1;
|
||||
SSdbRaw *pRaw = NULL;
|
||||
STrans *pTrans = NULL;
|
||||
|
@ -678,7 +680,7 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
|
|||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "drop-dnode");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
mndTransSetSerial(pTrans);
|
||||
mInfo("trans:%d, used to drop dnode:%d", pTrans->id, pDnode->id);
|
||||
mInfo("trans:%d, used to drop dnode:%d, force:%d", pTrans->id, pDnode->id, force);
|
||||
|
||||
pRaw = mndDnodeActionEncode(pDnode);
|
||||
if (pRaw == NULL) goto _OVER;
|
||||
|
@ -694,22 +696,22 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
|
|||
|
||||
if (pMObj != NULL) {
|
||||
mInfo("trans:%d, mnode on dnode:%d will be dropped", pTrans->id, pDnode->id);
|
||||
if (mndSetDropMnodeInfoToTrans(pMnode, pTrans, pMObj) != 0) goto _OVER;
|
||||
if (mndSetDropMnodeInfoToTrans(pMnode, pTrans, pMObj, force) != 0) goto _OVER;
|
||||
}
|
||||
|
||||
if (pQObj != NULL) {
|
||||
mInfo("trans:%d, qnode on dnode:%d will be dropped", pTrans->id, pDnode->id);
|
||||
if (mndSetDropQnodeInfoToTrans(pMnode, pTrans, pQObj) != 0) goto _OVER;
|
||||
if (mndSetDropQnodeInfoToTrans(pMnode, pTrans, pQObj, force) != 0) goto _OVER;
|
||||
}
|
||||
|
||||
if (pSObj != NULL) {
|
||||
mInfo("trans:%d, snode on dnode:%d will be dropped", pTrans->id, pDnode->id);
|
||||
if (mndSetDropSnodeInfoToTrans(pMnode, pTrans, pSObj) != 0) goto _OVER;
|
||||
if (mndSetDropSnodeInfoToTrans(pMnode, pTrans, pSObj, force) != 0) goto _OVER;
|
||||
}
|
||||
|
||||
if (numOfVnodes > 0) {
|
||||
mInfo("trans:%d, %d vnodes on dnode:%d will be dropped", pTrans->id, numOfVnodes, pDnode->id);
|
||||
if (mndSetMoveVgroupsInfoToTrans(pMnode, pTrans, pDnode->id) != 0) goto _OVER;
|
||||
if (mndSetMoveVgroupsInfoToTrans(pMnode, pTrans, pDnode->id, force) != 0) goto _OVER;
|
||||
}
|
||||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
@ -767,16 +769,16 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
int32_t numOfVnodes = mndGetVnodesNum(pMnode, pDnode->id);
|
||||
if (numOfVnodes > 0 || pMObj != NULL) {
|
||||
if ((numOfVnodes > 0 || pMObj != NULL || pSObj != NULL || pQObj != NULL) && !dropReq.force) {
|
||||
if (!mndIsDnodeOnline(pDnode, taosGetTimestampMs())) {
|
||||
terrno = TSDB_CODE_NODE_OFFLINE;
|
||||
mError("dnode:%d, failed to drop since %s, has_mnode:%d numOfVnodes:%d", pDnode->id, terrstr(), pMObj != NULL,
|
||||
numOfVnodes);
|
||||
mError("dnode:%d, failed to drop since %s, vnodes:%d mnode:%d qnode:%d snode:%d", pDnode->id, terrstr(),
|
||||
numOfVnodes, pMObj != NULL, pQObj != NULL, pSObj != NULL);
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
|
||||
code = mndDropDnode(pMnode, pReq, pDnode, pMObj, pQObj, pSObj, numOfVnodes);
|
||||
code = mndDropDnode(pMnode, pReq, pDnode, pMObj, pQObj, pSObj, numOfVnodes, dropReq.force);
|
||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
|
||||
_OVER:
|
||||
|
|
|
@ -105,7 +105,7 @@ static void mndCalMqRebalance(SMnode *pMnode) {
|
|||
int32_t contLen = 0;
|
||||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
if (pReq != NULL) {
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_MQ_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TMQ_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg);
|
||||
}
|
||||
}
|
||||
|
@ -428,18 +428,8 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
|
|||
|
||||
void mndPreClose(SMnode *pMnode) {
|
||||
if (pMnode != NULL) {
|
||||
atomic_store_8(&(pMnode->syncMgmt.leaderTransferFinish), 0);
|
||||
syncLeaderTransfer(pMnode->syncMgmt.sync);
|
||||
|
||||
#if 0
|
||||
mInfo("vgId:1, mnode start leader transfer");
|
||||
// wait for leader transfer finish
|
||||
while (!atomic_load_8(&(pMnode->syncMgmt.leaderTransferFinish))) {
|
||||
taosMsleep(10);
|
||||
mInfo("vgId:1, mnode waiting for leader transfer");
|
||||
}
|
||||
mInfo("vgId:1, mnode finish leader transfer");
|
||||
#endif
|
||||
syncPreStop(pMnode->syncMgmt.sync);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,128 +464,18 @@ void mndStop(SMnode *pMnode) {
|
|||
mndCleanupTimer(pMnode);
|
||||
}
|
||||
|
||||
int32_t mndProcessSyncCtrlMsg(SRpcMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->info.node;
|
||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||
int32_t code = 0;
|
||||
|
||||
mInfo("vgId:%d, process sync ctrl msg", 1);
|
||||
|
||||
if (!syncEnvIsStart()) {
|
||||
mError("failed to process sync msg:%p type:%s since syncEnv stop", pMsg, TMSG_INFO(pMsg->msgType));
|
||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
SSyncNode *pSyncNode = syncNodeAcquire(pMgmt->sync);
|
||||
if (pSyncNode == NULL) {
|
||||
mError("failed to process sync msg:%p type:%s since syncNode is null", pMsg, TMSG_INFO(pMsg->msgType));
|
||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pMsg->msgType == TDMT_SYNC_HEARTBEAT) {
|
||||
SyncHeartbeat *pSyncMsg = syncHeartbeatFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnHeartbeat(pSyncNode, pSyncMsg);
|
||||
syncHeartbeatDestroy(pSyncMsg);
|
||||
|
||||
} else if (pMsg->msgType == TDMT_SYNC_HEARTBEAT_REPLY) {
|
||||
SyncHeartbeatReply *pSyncMsg = syncHeartbeatReplyFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnHeartbeatReply(pSyncNode, pSyncMsg);
|
||||
syncHeartbeatReplyDestroy(pSyncMsg);
|
||||
}
|
||||
|
||||
syncNodeRelease(pSyncNode);
|
||||
|
||||
if (code != 0) {
|
||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->info.node;
|
||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||
int32_t code = 0;
|
||||
|
||||
if (!syncEnvIsStart()) {
|
||||
mError("failed to process sync msg:%p type:%s since syncEnv stop", pMsg, TMSG_INFO(pMsg->msgType));
|
||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
SSyncNode *pSyncNode = syncNodeAcquire(pMgmt->sync);
|
||||
if (pSyncNode == NULL) {
|
||||
mError("failed to process sync msg:%p type:%s since syncNode is null", pMsg, TMSG_INFO(pMsg->msgType));
|
||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pMsg->msgType == TDMT_SYNC_TIMEOUT) {
|
||||
SyncTimeout *pSyncMsg = syncTimeoutFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnTimer(pSyncNode, pSyncMsg);
|
||||
syncTimeoutDestroy(pSyncMsg);
|
||||
|
||||
} else if (pMsg->msgType == TDMT_SYNC_PING) {
|
||||
SyncPing *pSyncMsg = syncPingFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnPing(pSyncNode, pSyncMsg);
|
||||
syncPingDestroy(pSyncMsg);
|
||||
|
||||
} else if (pMsg->msgType == TDMT_SYNC_PING_REPLY) {
|
||||
SyncPingReply *pSyncMsg = syncPingReplyFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnPingReply(pSyncNode, pSyncMsg);
|
||||
syncPingReplyDestroy(pSyncMsg);
|
||||
|
||||
} else if (pMsg->msgType == TDMT_SYNC_CLIENT_REQUEST) {
|
||||
SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnClientRequest(pSyncNode, pSyncMsg, NULL);
|
||||
syncClientRequestDestroy(pSyncMsg);
|
||||
|
||||
} else if (pMsg->msgType == TDMT_SYNC_REQUEST_VOTE) {
|
||||
SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnRequestVote(pSyncNode, pSyncMsg);
|
||||
syncRequestVoteDestroy(pSyncMsg);
|
||||
|
||||
} else if (pMsg->msgType == TDMT_SYNC_REQUEST_VOTE_REPLY) {
|
||||
SyncRequestVoteReply *pSyncMsg = syncRequestVoteReplyFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnRequestVoteReply(pSyncNode, pSyncMsg);
|
||||
syncRequestVoteReplyDestroy(pSyncMsg);
|
||||
|
||||
} else if (pMsg->msgType == TDMT_SYNC_APPEND_ENTRIES) {
|
||||
SyncAppendEntries *pSyncMsg = syncAppendEntriesFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnAppendEntries(pSyncNode, pSyncMsg);
|
||||
syncAppendEntriesDestroy(pSyncMsg);
|
||||
|
||||
} else if (pMsg->msgType == TDMT_SYNC_APPEND_ENTRIES_REPLY) {
|
||||
SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnAppendEntriesReply(pSyncNode, pSyncMsg);
|
||||
syncAppendEntriesReplyDestroy(pSyncMsg);
|
||||
|
||||
} else if (pMsg->msgType == TDMT_SYNC_SNAPSHOT_SEND) {
|
||||
SyncSnapshotSend *pSyncMsg = syncSnapshotSendFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnSnapshot(pSyncNode, pSyncMsg);
|
||||
syncSnapshotSendDestroy(pSyncMsg);
|
||||
|
||||
} else if (pMsg->msgType == TDMT_SYNC_SNAPSHOT_RSP) {
|
||||
SyncSnapshotRsp *pSyncMsg = syncSnapshotRspFromRpcMsg2(pMsg);
|
||||
code = syncNodeOnSnapshotReply(pSyncNode, pSyncMsg);
|
||||
syncSnapshotRspDestroy(pSyncMsg);
|
||||
|
||||
} else if (pMsg->msgType == TDMT_SYNC_SET_MNODE_STANDBY) {
|
||||
code = syncSetStandby(pMgmt->sync);
|
||||
SRpcMsg rsp = {.code = code, .info = pMsg->info};
|
||||
tmsgSendRsp(&rsp);
|
||||
|
||||
} else {
|
||||
mError("failed to process msg:%p since invalid type:%s", pMsg, TMSG_INFO(pMsg->msgType));
|
||||
code = -1;
|
||||
}
|
||||
|
||||
syncNodeRelease(pSyncNode);
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
mGTrace("vgId:1, sync msg:%p will be processed, type:%s", pMsg, TMSG_INFO(pMsg->msgType));
|
||||
|
||||
int32_t code = syncProcessMsg(pMgmt->sync, pMsg);
|
||||
if (code != 0) {
|
||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
mGError("vgId:1, failed to process sync msg:%p type:%s since %s", pMsg, TMSG_INFO(pMsg->msgType), terrstr());
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -608,14 +488,14 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
|
|||
}
|
||||
if (mndAcquireRpc(pMsg->info.node) == 0) return 0;
|
||||
|
||||
SMnode *pMnode = pMsg->info.node;
|
||||
const char *role = syncGetMyRoleStr(pMnode->syncMgmt.sync);
|
||||
bool restored = syncIsRestoreFinish(pMnode->syncMgmt.sync);
|
||||
if (pMsg->msgType == TDMT_MND_MQ_TIMER || pMsg->msgType == TDMT_MND_TELEM_TIMER ||
|
||||
SMnode *pMnode = pMsg->info.node;
|
||||
SSyncState state = syncGetState(pMnode->syncMgmt.sync);
|
||||
|
||||
if (pMsg->msgType == TDMT_MND_TMQ_TIMER || pMsg->msgType == TDMT_MND_TELEM_TIMER ||
|
||||
pMsg->msgType == TDMT_MND_TRANS_TIMER || pMsg->msgType == TDMT_MND_TTL_TIMER ||
|
||||
pMsg->msgType == TDMT_MND_UPTIME_TIMER) {
|
||||
mTrace("timer not process since mnode restored:%d stopped:%d, sync restored:%d role:%s ", pMnode->restored,
|
||||
pMnode->stopped, restored, role);
|
||||
pMnode->stopped, state.restored, syncStr(state.restored));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -626,8 +506,8 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
|
|||
mDebug(
|
||||
"msg:%p, type:%s failed to process since %s, mnode restored:%d stopped:%d, sync restored:%d "
|
||||
"role:%s, redirect numOfEps:%d inUse:%d",
|
||||
pMsg, TMSG_INFO(pMsg->msgType), terrstr(), pMnode->restored, pMnode->stopped, restored, role, epSet.numOfEps,
|
||||
epSet.inUse);
|
||||
pMsg, TMSG_INFO(pMsg->msgType), terrstr(), pMnode->restored, pMnode->stopped, state.restored,
|
||||
syncStr(state.restored), epSet.numOfEps, epSet.inUse);
|
||||
|
||||
if (epSet.numOfEps > 0) {
|
||||
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
||||
|
@ -850,8 +730,9 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
|
|||
}
|
||||
|
||||
int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad) {
|
||||
pLoad->syncState = syncGetMyRole(pMnode->syncMgmt.sync);
|
||||
pLoad->syncRestore = pMnode->restored;
|
||||
SSyncState state = syncGetState(pMnode->syncMgmt.sync);
|
||||
pLoad->syncState = state.state;
|
||||
pLoad->syncRestore = state.restored;
|
||||
mTrace("mnode current syncState is %s, syncRestore:%d", syncStr(pLoad->syncState), pLoad->syncRestore);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -472,7 +472,8 @@ static int32_t mndSetDropMnodeCommitLogs(SMnode *pMnode, STrans *pTrans, SMnodeO
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnodeObj *pDnode, SMnodeObj *pObj) {
|
||||
static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnodeObj *pDnode, SMnodeObj *pObj,
|
||||
bool force) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
void *pIter = NULL;
|
||||
SDDropMnodeReq dropReq = {0};
|
||||
|
@ -485,12 +486,21 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
|
|||
|
||||
int32_t totalMnodes = sdbGetSize(pSdb, SDB_MNODE);
|
||||
if (totalMnodes == 2) {
|
||||
if (force) {
|
||||
mError("cant't force drop dnode, since a mnode on it and replica is 2");
|
||||
terrno = TSDB_CODE_NODE_OFFLINE;
|
||||
return -1;
|
||||
}
|
||||
mInfo("vgId:1, has %d mnodes, exec redo log first", totalMnodes);
|
||||
if (mndSetDropMnodeRedoLogs(pMnode, pTrans, pObj) != 0) return -1;
|
||||
if (mndBuildDropMnodeRedoAction(pTrans, &dropReq, &dropEpSet) != 0) return -1;
|
||||
if (!force) {
|
||||
if (mndBuildDropMnodeRedoAction(pTrans, &dropReq, &dropEpSet) != 0) return -1;
|
||||
}
|
||||
} else if (totalMnodes == 3) {
|
||||
mInfo("vgId:1, has %d mnodes, exec redo action first", totalMnodes);
|
||||
if (mndBuildDropMnodeRedoAction(pTrans, &dropReq, &dropEpSet) != 0) return -1;
|
||||
if (!force) {
|
||||
if (mndBuildDropMnodeRedoAction(pTrans, &dropReq, &dropEpSet) != 0) return -1;
|
||||
}
|
||||
if (mndSetDropMnodeRedoLogs(pMnode, pTrans, pObj) != 0) return -1;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -499,9 +509,9 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndSetDropMnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
|
||||
int32_t mndSetDropMnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj, bool force) {
|
||||
if (pObj == NULL) return 0;
|
||||
if (mndSetDropMnodeRedoActions(pMnode, pTrans, pObj->pDnode, pObj) != 0) return -1;
|
||||
if (mndSetDropMnodeRedoActions(pMnode, pTrans, pObj->pDnode, pObj, force) != 0) return -1;
|
||||
if (mndSetDropMnodeCommitLogs(pMnode, pTrans, pObj) != 0) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -515,7 +525,7 @@ static int32_t mndDropMnode(SMnode *pMnode, SRpcMsg *pReq, SMnodeObj *pObj) {
|
|||
mndTransSetSerial(pTrans);
|
||||
mInfo("trans:%d, used to drop mnode:%d", pTrans->id, pObj->id);
|
||||
|
||||
if (mndSetDropMnodeInfoToTrans(pMnode, pTrans, pObj) != 0) goto _OVER;
|
||||
if (mndSetDropMnodeInfoToTrans(pMnode, pTrans, pObj, false) != 0) goto _OVER;
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
code = 0;
|
||||
|
@ -743,7 +753,7 @@ static void mndReloadSyncConfig(SMnode *pMnode) {
|
|||
mInfo("vgId:1, mnode sync not reconfig since readyMnodes:%d updatingMnodes:%d", readyMnodes, updatingMnodes);
|
||||
return;
|
||||
}
|
||||
// ASSERT(0);
|
||||
// ASSERT(0);
|
||||
|
||||
if (cfg.myIndex == -1) {
|
||||
#if 1
|
||||
|
|
|
@ -353,11 +353,13 @@ static int32_t mndSetDropQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQn
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndSetDropQnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SQnodeObj *pObj) {
|
||||
int32_t mndSetDropQnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SQnodeObj *pObj, bool force) {
|
||||
if (pObj == NULL) return 0;
|
||||
if (mndSetDropQnodeRedoLogs(pTrans, pObj) != 0) return -1;
|
||||
if (mndSetDropQnodeCommitLogs(pTrans, pObj) != 0) return -1;
|
||||
if (mndSetDropQnodeRedoActions(pTrans, pObj->pDnode, pObj) != 0) return -1;
|
||||
if (!force) {
|
||||
if (mndSetDropQnodeRedoActions(pTrans, pObj->pDnode, pObj) != 0) return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -368,7 +370,7 @@ static int32_t mndDropQnode(SMnode *pMnode, SRpcMsg *pReq, SQnodeObj *pObj) {
|
|||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
mInfo("trans:%d, used to drop qnode:%d", pTrans->id, pObj->id);
|
||||
if (mndSetDropQnodeInfoToTrans(pMnode, pTrans, pObj) != 0) goto _OVER;
|
||||
if (mndSetDropQnodeInfoToTrans(pMnode, pTrans, pObj, false) != 0) goto _OVER;
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
code = 0;
|
||||
|
|
|
@ -55,7 +55,7 @@ int32_t mndProcessQueryMsg(SRpcMsg *pMsg) {
|
|||
code = qWorkerProcessHbMsg(pMnode, pMnode->pQuery, pMsg, 0);
|
||||
break;
|
||||
default:
|
||||
terrno = TSDB_CODE_VND_APP_ERROR;
|
||||
terrno = TSDB_CODE_APP_ERROR;
|
||||
mError("unknown msg type:%d in query queue", pMsg->msgType);
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
|||
for (int32_t i = 0; i < msgNum; ++i) {
|
||||
if (offset >= pMsg->contLen) {
|
||||
mError("offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
taosArrayDestroy(batchRsp);
|
||||
return -1;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
|||
offset += sizeof(req.msgIdx);
|
||||
if (offset >= pMsg->contLen) {
|
||||
mError("offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
taosArrayDestroy(batchRsp);
|
||||
return -1;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
|||
offset += sizeof(req.msgType);
|
||||
if (offset >= pMsg->contLen) {
|
||||
mError("offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
taosArrayDestroy(batchRsp);
|
||||
return -1;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
|||
offset += sizeof(req.msgLen);
|
||||
if (offset >= pMsg->contLen) {
|
||||
mError("offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
taosArrayDestroy(batchRsp);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -487,6 +487,7 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
|
|||
qDestroyQueryPlan(pPlan);
|
||||
return -1;
|
||||
}
|
||||
pTask->fillHistory = pStream->fillHistory;
|
||||
mndAddTaskToTaskSet(taskOneLevel, pTask);
|
||||
|
||||
// source
|
||||
|
|
|
@ -360,11 +360,13 @@ static int32_t mndSetDropSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SSn
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndSetDropSnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SSnodeObj *pObj) {
|
||||
int32_t mndSetDropSnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SSnodeObj *pObj, bool force) {
|
||||
if (pObj == NULL) return 0;
|
||||
if (mndSetDropSnodeRedoLogs(pTrans, pObj) != 0) return -1;
|
||||
if (mndSetDropSnodeCommitLogs(pTrans, pObj) != 0) return -1;
|
||||
if (mndSetDropSnodeRedoActions(pTrans, pObj->pDnode, pObj) != 0) return -1;
|
||||
if (!force) {
|
||||
if (mndSetDropSnodeRedoActions(pTrans, pObj->pDnode, pObj) != 0) return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -375,7 +377,7 @@ static int32_t mndDropSnode(SMnode *pMnode, SRpcMsg *pReq, SSnodeObj *pObj) {
|
|||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
mInfo("trans:%d, used to drop snode:%d", pTrans->id, pObj->id);
|
||||
if (mndSetDropSnodeInfoToTrans(pMnode, pTrans, pObj) != 0) goto _OVER;
|
||||
if (mndSetDropSnodeInfoToTrans(pMnode, pTrans, pObj, false) != 0) goto _OVER;
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
code = 0;
|
||||
|
@ -386,9 +388,9 @@ _OVER:
|
|||
}
|
||||
|
||||
static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq) {
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
int32_t code = -1;
|
||||
SSnodeObj *pObj = NULL;
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
int32_t code = -1;
|
||||
SSnodeObj *pObj = NULL;
|
||||
SMDropSnodeReq dropReq = {0};
|
||||
|
||||
if (tDeserializeSCreateDropMQSNodeReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
||||
|
|
|
@ -2029,7 +2029,7 @@ static int32_t mndSetDropStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *
|
|||
action.pCont = pReq;
|
||||
action.contLen = contLen;
|
||||
action.msgType = TDMT_VND_DROP_STB;
|
||||
action.acceptableCode = TSDB_CODE_VND_TB_NOT_EXIST;
|
||||
action.acceptableCode = TSDB_CODE_TDB_STB_NOT_EXIST;
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
|
|
|
@ -557,78 +557,6 @@ static int32_t mndPersistTaskDropReq(STrans *pTrans, SStreamTask *pTask) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int32_t mndPersistTaskRecoverReq(STrans *pTrans, SStreamTask *pTask) {
|
||||
SMStreamTaskRecoverReq *pReq = taosMemoryCalloc(1, sizeof(SMStreamTaskRecoverReq));
|
||||
if (pReq == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
pReq->streamId = pTask->streamId;
|
||||
pReq->taskId = pTask->taskId;
|
||||
int32_t len;
|
||||
int32_t code;
|
||||
tEncodeSize(tEncodeSMStreamTaskRecoverReq, pReq, len, code);
|
||||
if (code != 0) {
|
||||
return -1;
|
||||
}
|
||||
void *buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len);
|
||||
if (buf == NULL) {
|
||||
return -1;
|
||||
}
|
||||
void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
||||
SEncoder encoder;
|
||||
tEncoderInit(&encoder, abuf, len);
|
||||
tEncodeSMStreamTaskRecoverReq(&encoder, pReq);
|
||||
((SMsgHead *)buf)->vgId = pTask->nodeId;
|
||||
|
||||
STransAction action = {0};
|
||||
memcpy(&action.epSet, &pTask->epSet, sizeof(SEpSet));
|
||||
action.pCont = buf;
|
||||
action.contLen = sizeof(SMsgHead) + len;
|
||||
action.msgType = TDMT_STREAM_TASK_RECOVER;
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(buf);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndRecoverStreamTasks(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) {
|
||||
if (pStream->isDistributed) {
|
||||
int32_t lv = taosArrayGetSize(pStream->tasks);
|
||||
for (int32_t i = 0; i < lv; i++) {
|
||||
SArray *pTasks = taosArrayGetP(pStream->tasks, i);
|
||||
int32_t sz = taosArrayGetSize(pTasks);
|
||||
SStreamTask *pTask = taosArrayGetP(pTasks, 0);
|
||||
if (pTask->taskLevel == TASK_LEVEL__AGG) {
|
||||
ASSERT(sz == 1);
|
||||
if (mndPersistTaskRecoverReq(pTrans, pTask) < 0) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int32_t lv = taosArrayGetSize(pStream->tasks);
|
||||
for (int32_t i = 0; i < lv; i++) {
|
||||
SArray *pTasks = taosArrayGetP(pStream->tasks, i);
|
||||
int32_t sz = taosArrayGetSize(pTasks);
|
||||
for (int32_t j = 0; j < sz; j++) {
|
||||
SStreamTask *pTask = taosArrayGetP(pTasks, j);
|
||||
if (pTask->taskLevel != TASK_LEVEL__SOURCE) break;
|
||||
ASSERT(pTask->taskLevel != TASK_LEVEL__SINK);
|
||||
if (mndPersistTaskRecoverReq(pTrans, pTask) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t mndDropStreamTasks(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) {
|
||||
int32_t lv = taosArrayGetSize(pStream->tasks);
|
||||
for (int32_t i = 0; i < lv; i++) {
|
||||
|
@ -777,7 +705,8 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, "drop-stream");
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, "drop-stream");
|
||||
mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetDb);
|
||||
if (pTrans == NULL) {
|
||||
mError("stream:%s, failed to drop since %s", dropReq.name, terrstr());
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
|
|
|
@ -73,11 +73,11 @@ int32_t mndInitSubscribe(SMnode *pMnode) {
|
|||
.deleteFp = (SdbDeleteFp)mndSubActionDelete,
|
||||
};
|
||||
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_MQ_VG_CHANGE_RSP, mndTransProcessRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_MQ_VG_DELETE_RSP, mndTransProcessRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_MQ_DO_REBALANCE, mndProcessRebalanceReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_MQ_DROP_CGROUP, mndProcessDropCgroupReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_MQ_DROP_CGROUP_RSP, mndTransProcessRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_TMQ_SUBSCRIBE_RSP, mndTransProcessRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_TMQ_DELETE_SUB_RSP, mndTransProcessRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_DO_REBALANCE, mndProcessRebalanceReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_DROP_CGROUP, mndProcessDropCgroupReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_DROP_CGROUP_RSP, mndTransProcessRsp);
|
||||
|
||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_SUBSCRIPTIONS, mndRetrieveSubscribe);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndCancelGetNextSubscribe);
|
||||
|
@ -164,7 +164,7 @@ static int32_t mndPersistSubChangeVgReq(SMnode *pMnode, STrans *pTrans, const SM
|
|||
action.epSet = mndGetVgroupEpset(pMnode, pVgObj);
|
||||
action.pCont = buf;
|
||||
action.contLen = tlen;
|
||||
action.msgType = TDMT_VND_MQ_VG_CHANGE;
|
||||
action.msgType = TDMT_VND_TMQ_SUBSCRIBE;
|
||||
|
||||
mndReleaseVgroup(pMnode, pVgObj);
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
|
@ -612,14 +612,14 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) {
|
|||
mndReleaseSubscribe(pMnode, pSub);
|
||||
}
|
||||
|
||||
// TODO replace assert with error check
|
||||
ASSERT(mndDoRebalance(pMnode, &rebInput, &rebOutput) == 0);
|
||||
if (mndDoRebalance(pMnode, &rebInput, &rebOutput) < 0) {
|
||||
mError("mq rebalance internal error");
|
||||
}
|
||||
|
||||
// if add more consumer to balanced subscribe,
|
||||
// possibly no vg is changed
|
||||
/*ASSERT(taosArrayGetSize(rebOutput.rebVgs) != 0);*/
|
||||
|
||||
// TODO replace assert with error check
|
||||
if (mndPersistRebResult(pMnode, pMsg, &rebOutput) < 0) {
|
||||
mError("mq rebalance persist rebalance output error, possibly vnode splitted or dropped");
|
||||
}
|
||||
|
@ -920,7 +920,7 @@ int32_t mndDropSubByTopic(SMnode *pMnode, STrans *pTrans, const char *topicName)
|
|||
action.epSet = pVgEp->epSet;
|
||||
action.pCont = pReq;
|
||||
action.contLen = sizeof(SMqVDeleteReq);
|
||||
action.msgType = TDMT_VND_MQ_VG_DELETE;
|
||||
action.msgType = TDMT_VND_TMQ_DELETE_SUB;
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
return -1;
|
||||
|
|
|
@ -17,11 +17,44 @@
|
|||
#include "mndSync.h"
|
||||
#include "mndTrans.h"
|
||||
|
||||
static int32_t mndSyncEqMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) {
|
||||
static int32_t mndSyncEqCtrlMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) {
|
||||
if (pMsg == NULL || pMsg->pCont == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SMsgHead *pHead = pMsg->pCont;
|
||||
pHead->contLen = htonl(pHead->contLen);
|
||||
pHead->vgId = htonl(pHead->vgId);
|
||||
|
||||
if (msgcb == NULL || msgcb->putToQueueFp == NULL) {
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
pMsg->pCont = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t code = tmsgPutToQueue(msgcb, SYNC_CTRL_QUEUE, pMsg);
|
||||
if (code != 0) {
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
pMsg->pCont = NULL;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndSyncEqMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) {
|
||||
if (pMsg == NULL || pMsg->pCont == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SMsgHead *pHead = pMsg->pCont;
|
||||
pHead->contLen = htonl(pHead->contLen);
|
||||
pHead->vgId = htonl(pHead->vgId);
|
||||
|
||||
if (msgcb == NULL || msgcb->putToQueueFp == NULL) {
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
pMsg->pCont = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t code = tmsgPutToQueue(msgcb, SYNC_QUEUE, pMsg);
|
||||
if (code != 0) {
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
|
@ -39,25 +72,25 @@ static int32_t mndSyncSendMsg(const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
|||
return code;
|
||||
}
|
||||
|
||||
void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
||||
void mndSyncCommitMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
SMnode *pMnode = pFsm->data;
|
||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||
SSdbRaw *pRaw = pMsg->pCont;
|
||||
|
||||
// delete msg handle
|
||||
SRpcMsg rpcMsg = {0};
|
||||
syncGetAndDelRespRpc(pMnode->syncMgmt.sync, cbMeta.seqNum, &rpcMsg.info);
|
||||
rpcMsg.info = pMsg->info;
|
||||
|
||||
int32_t transId = sdbGetIdFromRaw(pMnode->pSdb, pRaw);
|
||||
pMgmt->errCode = cbMeta.code;
|
||||
pMgmt->errCode = pMeta->code;
|
||||
mInfo("trans:%d, is proposed, saved:%d code:0x%x, apply index:%" PRId64 " term:%" PRIu64 " config:%" PRId64
|
||||
" role:%s raw:%p",
|
||||
transId, pMgmt->transId, cbMeta.code, cbMeta.index, cbMeta.term, cbMeta.lastConfigIndex, syncStr(cbMeta.state),
|
||||
transId, pMgmt->transId, pMeta->code, pMeta->index, pMeta->term, pMeta->lastConfigIndex, syncStr(pMeta->state),
|
||||
pRaw);
|
||||
|
||||
if (pMgmt->errCode == 0) {
|
||||
sdbWriteWithoutFree(pMnode->pSdb, pRaw);
|
||||
sdbSetApplyInfo(pMnode->pSdb, cbMeta.index, cbMeta.term, cbMeta.lastConfigIndex);
|
||||
sdbSetApplyInfo(pMnode->pSdb, pMeta->index, pMeta->term, pMeta->lastConfigIndex);
|
||||
}
|
||||
|
||||
taosWLockLatch(&pMgmt->lock);
|
||||
|
@ -87,7 +120,7 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM
|
|||
}
|
||||
}
|
||||
|
||||
int32_t mndSyncGetSnapshot(struct SSyncFSM *pFsm, SSnapshot *pSnapshot, void *pReaderParam, void **ppReader) {
|
||||
int32_t mndSyncGetSnapshot(const SSyncFSM *pFsm, SSnapshot *pSnapshot, void *pReaderParam, void **ppReader) {
|
||||
mInfo("start to read snapshot from sdb in atomic way");
|
||||
SMnode *pMnode = pFsm->data;
|
||||
return sdbStartRead(pMnode->pSdb, (SSdbIter **)ppReader, &pSnapshot->lastApplyIndex, &pSnapshot->lastApplyTerm,
|
||||
|
@ -95,13 +128,13 @@ int32_t mndSyncGetSnapshot(struct SSyncFSM *pFsm, SSnapshot *pSnapshot, void *pR
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndSyncGetSnapshotInfo(struct SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
||||
int32_t mndSyncGetSnapshotInfo(const SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
||||
SMnode *pMnode = pFsm->data;
|
||||
sdbGetCommitInfo(pMnode->pSdb, &pSnapshot->lastApplyIndex, &pSnapshot->lastApplyTerm, &pSnapshot->lastConfigIndex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mndRestoreFinish(struct SSyncFSM *pFsm) {
|
||||
void mndRestoreFinish(const SSyncFSM *pFsm) {
|
||||
SMnode *pMnode = pFsm->data;
|
||||
|
||||
if (!pMnode->deploy) {
|
||||
|
@ -113,32 +146,30 @@ void mndRestoreFinish(struct SSyncFSM *pFsm) {
|
|||
}
|
||||
}
|
||||
|
||||
void mndReConfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta *cbMeta) {}
|
||||
|
||||
int32_t mndSnapshotStartRead(struct SSyncFSM *pFsm, void *pParam, void **ppReader) {
|
||||
int32_t mndSnapshotStartRead(const SSyncFSM *pFsm, void *pParam, void **ppReader) {
|
||||
mInfo("start to read snapshot from sdb");
|
||||
SMnode *pMnode = pFsm->data;
|
||||
return sdbStartRead(pMnode->pSdb, (SSdbIter **)ppReader, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
int32_t mndSnapshotStopRead(struct SSyncFSM *pFsm, void *pReader) {
|
||||
int32_t mndSnapshotStopRead(const SSyncFSM *pFsm, void *pReader) {
|
||||
mInfo("stop to read snapshot from sdb");
|
||||
SMnode *pMnode = pFsm->data;
|
||||
return sdbStopRead(pMnode->pSdb, pReader);
|
||||
}
|
||||
|
||||
int32_t mndSnapshotDoRead(struct SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) {
|
||||
int32_t mndSnapshotDoRead(const SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) {
|
||||
SMnode *pMnode = pFsm->data;
|
||||
return sdbDoRead(pMnode->pSdb, pReader, ppBuf, len);
|
||||
}
|
||||
|
||||
int32_t mndSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void **ppWriter) {
|
||||
int32_t mndSnapshotStartWrite(const SSyncFSM *pFsm, void *pParam, void **ppWriter) {
|
||||
mInfo("start to apply snapshot to sdb");
|
||||
SMnode *pMnode = pFsm->data;
|
||||
return sdbStartWrite(pMnode->pSdb, (SSdbIter **)ppWriter);
|
||||
}
|
||||
|
||||
int32_t mndSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply, SSnapshot *pSnapshot) {
|
||||
int32_t mndSnapshotStopWrite(const SSyncFSM *pFsm, void *pWriter, bool isApply, SSnapshot *pSnapshot) {
|
||||
mInfo("stop to apply snapshot to sdb, apply:%d, index:%" PRId64 " term:%" PRIu64 " config:%" PRId64, isApply,
|
||||
pSnapshot->lastApplyIndex, pSnapshot->lastApplyTerm, pSnapshot->lastConfigIndex);
|
||||
SMnode *pMnode = pFsm->data;
|
||||
|
@ -146,18 +177,12 @@ int32_t mndSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply,
|
|||
pSnapshot->lastConfigIndex);
|
||||
}
|
||||
|
||||
int32_t mndSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) {
|
||||
int32_t mndSnapshotDoWrite(const SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) {
|
||||
SMnode *pMnode = pFsm->data;
|
||||
return sdbDoWrite(pMnode->pSdb, pWriter, pBuf, len);
|
||||
}
|
||||
|
||||
void mndLeaderTransfer(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
||||
SMnode *pMnode = pFsm->data;
|
||||
atomic_store_8(&(pMnode->syncMgmt.leaderTransferFinish), 1);
|
||||
mInfo("vgId:1, mnode leader transfer finish");
|
||||
}
|
||||
|
||||
static void mndBecomeFollower(struct SSyncFSM *pFsm) {
|
||||
static void mndBecomeFollower(const SSyncFSM *pFsm) {
|
||||
SMnode *pMnode = pFsm->data;
|
||||
mInfo("vgId:1, become follower");
|
||||
|
||||
|
@ -172,7 +197,7 @@ static void mndBecomeFollower(struct SSyncFSM *pFsm) {
|
|||
taosWUnLockLatch(&pMnode->syncMgmt.lock);
|
||||
}
|
||||
|
||||
static void mndBecomeLeader(struct SSyncFSM *pFsm) {
|
||||
static void mndBecomeLeader(const SSyncFSM *pFsm) {
|
||||
mInfo("vgId:1, become leader");
|
||||
SMnode *pMnode = pFsm->data;
|
||||
}
|
||||
|
@ -184,8 +209,8 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
|
|||
pFsm->FpPreCommitCb = NULL;
|
||||
pFsm->FpRollBackCb = NULL;
|
||||
pFsm->FpRestoreFinishCb = mndRestoreFinish;
|
||||
pFsm->FpLeaderTransferCb = mndLeaderTransfer;
|
||||
pFsm->FpReConfigCb = mndReConfig;
|
||||
pFsm->FpLeaderTransferCb = NULL;
|
||||
pFsm->FpReConfigCb = NULL;
|
||||
pFsm->FpBecomeLeaderCb = mndBecomeLeader;
|
||||
pFsm->FpBecomeFollowerCb = mndBecomeFollower;
|
||||
pFsm->FpGetSnapshot = mndSyncGetSnapshot;
|
||||
|
@ -209,10 +234,13 @@ int32_t mndInitSync(SMnode *pMnode) {
|
|||
.batchSize = 1,
|
||||
.vgId = 1,
|
||||
.pWal = pMnode->pWal,
|
||||
.msgcb = NULL,
|
||||
.FpSendMsg = mndSyncSendMsg,
|
||||
.FpEqMsg = mndSyncEqMsg,
|
||||
.FpEqCtrlMsg = NULL,
|
||||
.msgcb = &pMnode->msgCb,
|
||||
.syncSendMSg = mndSyncSendMsg,
|
||||
.syncEqMsg = mndSyncEqMsg,
|
||||
.syncEqCtrlMsg = mndSyncEqCtrlMsg,
|
||||
.pingMs = 5000,
|
||||
.electMs = 3000,
|
||||
.heartbeatMs = 500,
|
||||
};
|
||||
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s%ssync", pMnode->path, TD_DIRSEP);
|
||||
|
@ -236,11 +264,6 @@ int32_t mndInitSync(SMnode *pMnode) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
// decrease election timer
|
||||
setPingTimerMS(pMgmt->sync, 5000);
|
||||
setElectTimerMS(pMgmt->sync, 3000);
|
||||
setHeartbeatTimerMS(pMgmt->sync, 500);
|
||||
|
||||
mInfo("mnode-sync is opened, id:%" PRId64, pMgmt->sync);
|
||||
return 0;
|
||||
}
|
||||
|
@ -256,32 +279,26 @@ void mndCleanupSync(SMnode *pMnode) {
|
|||
|
||||
int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
|
||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||
SRpcMsg req = {.msgType = TDMT_MND_APPLY_MSG, .contLen = sdbGetRawTotalSize(pRaw)};
|
||||
if (req.contLen <= 0) {
|
||||
terrno = TSDB_CODE_APP_ERROR;
|
||||
return -1;
|
||||
}
|
||||
pMgmt->errCode = 0;
|
||||
|
||||
SRpcMsg req = {.msgType = TDMT_MND_APPLY_MSG, .contLen = sdbGetRawTotalSize(pRaw)};
|
||||
req.pCont = rpcMallocCont(req.contLen);
|
||||
if (req.pCont == NULL) return -1;
|
||||
memcpy(req.pCont, pRaw, req.contLen);
|
||||
|
||||
pMgmt->errCode = 0;
|
||||
taosWLockLatch(&pMgmt->lock);
|
||||
if (pMgmt->transId != 0) {
|
||||
mError("trans:%d, can't be proposed since trans:%d alrady waiting for confirm", transId, pMgmt->transId);
|
||||
mError("trans:%d, can't be proposed since trans:%d already waiting for confirm", transId, pMgmt->transId);
|
||||
taosWUnLockLatch(&pMgmt->lock);
|
||||
terrno = TSDB_CODE_APP_NOT_READY;
|
||||
return -1;
|
||||
} else {
|
||||
pMgmt->transId = transId;
|
||||
mInfo("trans:%d, will be proposed", pMgmt->transId);
|
||||
taosWUnLockLatch(&pMgmt->lock);
|
||||
}
|
||||
|
||||
const bool isWeak = false;
|
||||
int32_t code = syncPropose(pMgmt->sync, &req, isWeak);
|
||||
mInfo("trans:%d, will be proposed", transId);
|
||||
pMgmt->transId = transId;
|
||||
taosWUnLockLatch(&pMgmt->lock);
|
||||
|
||||
int32_t code = syncPropose(pMgmt->sync, &req, false);
|
||||
if (code == 0) {
|
||||
mInfo("trans:%d, is proposing and wait sem", pMgmt->transId);
|
||||
tsem_wait(&pMgmt->syncSem);
|
||||
|
@ -294,8 +311,8 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
|
|||
sdbSetApplyInfo(pMnode->pSdb, req.info.conn.applyIndex, req.info.conn.applyTerm, SYNC_INDEX_INVALID);
|
||||
code = 0;
|
||||
} else {
|
||||
taosWLockLatch(&pMgmt->lock);
|
||||
mInfo("trans:%d, failed to proposed since %s", transId, terrstr());
|
||||
taosWLockLatch(&pMgmt->lock);
|
||||
pMgmt->transId = 0;
|
||||
taosWUnLockLatch(&pMgmt->lock);
|
||||
if (terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
||||
|
@ -311,13 +328,12 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
|
|||
return code;
|
||||
}
|
||||
|
||||
if (pMgmt->errCode != 0) terrno = pMgmt->errCode;
|
||||
terrno = pMgmt->errCode;
|
||||
return pMgmt->errCode;
|
||||
}
|
||||
|
||||
void mndSyncStart(SMnode *pMnode) {
|
||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||
syncSetMsgCb(pMgmt->sync, &pMnode->msgCb);
|
||||
syncStart(pMgmt->sync);
|
||||
mInfo("vgId:1, sync started, id:%" PRId64, pMgmt->sync);
|
||||
}
|
||||
|
@ -333,11 +349,15 @@ void mndSyncStop(SMnode *pMnode) {
|
|||
}
|
||||
|
||||
bool mndIsLeader(SMnode *pMnode) {
|
||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||
SSyncState state = syncGetState(pMnode->syncMgmt.sync);
|
||||
|
||||
if (!syncIsReady(pMgmt->sync)) {
|
||||
// get terrno from syncIsReady
|
||||
// terrno = TSDB_CODE_SYN_NOT_LEADER;
|
||||
if (state.state != TAOS_SYNC_STATE_LEADER || !state.restored) {
|
||||
if (state.state != TAOS_SYNC_STATE_LEADER) {
|
||||
terrno = TSDB_CODE_SYN_NOT_LEADER;
|
||||
} else {
|
||||
terrno = TSDB_CODE_APP_NOT_READY;
|
||||
}
|
||||
mDebug("vgId:1, mnode not ready, state:%s, restore:%d", syncStr(state.state), state.restored);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,11 +53,10 @@ int32_t mndInitTopic(SMnode *pMnode) {
|
|||
.deleteFp = (SdbDeleteFp)mndTopicActionDelete,
|
||||
};
|
||||
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_TOPIC, mndProcessCreateTopicReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_TOPIC, mndProcessDropTopicReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_DROP_TOPIC_RSP, mndTransProcessRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_ADD_CHECK_INFO_RSP, mndTransProcessRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_DELETE_CHECK_INFO_RSP, mndTransProcessRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_CREATE_TOPIC, mndProcessCreateTopicReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_DROP_TOPIC, mndProcessDropTopicReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_TMQ_ADD_CHECKINFO_RSP, mndTransProcessRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_TMQ_DEL_CHECKINFO_RSP, mndTransProcessRsp);
|
||||
|
||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndRetrieveTopic);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndCancelGetNextTopic);
|
||||
|
@ -506,7 +505,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
|
|||
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||
action.pCont = buf;
|
||||
action.contLen = sizeof(SMsgHead) + len;
|
||||
action.msgType = TDMT_VND_ADD_CHECK_INFO;
|
||||
action.msgType = TDMT_VND_TMQ_ADD_CHECKINFO;
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(buf);
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
|
@ -715,7 +714,7 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
|||
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||
action.pCont = buf;
|
||||
action.contLen = sizeof(SMsgHead) + TSDB_TOPIC_FNAME_LEN;
|
||||
action.msgType = TDMT_VND_DELETE_CHECK_INFO;
|
||||
action.msgType = TDMT_VND_TMQ_DEL_CHECKINFO;
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(buf);
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
|
|
|
@ -1071,7 +1071,7 @@ int32_t mndAddDropVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgOb
|
|||
}
|
||||
|
||||
int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, int32_t vnIndex,
|
||||
SArray *pArray) {
|
||||
SArray *pArray, bool force) {
|
||||
SVgObj newVg = {0};
|
||||
memcpy(&newVg, pVgroup, sizeof(SVgObj));
|
||||
|
||||
|
@ -1080,24 +1080,45 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
|
|||
mInfo("vgId:%d, vnode:%d dnode:%d", newVg.vgId, i, newVg.vnodeGid[i].dnodeId);
|
||||
}
|
||||
|
||||
mInfo("vgId:%d, will add 1 vnodes", pVgroup->vgId);
|
||||
if (mndAddVnodeToVgroup(pMnode, &newVg, pArray) != 0) return -1;
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[newVg.replica - 1]) != 0) return -1;
|
||||
for (int32_t i = 0; i < newVg.replica - 1; ++i) {
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
||||
}
|
||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||
if (!force) {
|
||||
mInfo("vgId:%d, will add 1 vnode", pVgroup->vgId);
|
||||
if (mndAddVnodeToVgroup(pMnode, &newVg, pArray) != 0) return -1;
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[newVg.replica - 1]) != 0) return -1;
|
||||
for (int32_t i = 0; i < newVg.replica - 1; ++i) {
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
||||
}
|
||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||
|
||||
mInfo("vgId:%d, will remove 1 vnodes", pVgroup->vgId);
|
||||
newVg.replica--;
|
||||
SVnodeGid del = newVg.vnodeGid[vnIndex];
|
||||
newVg.vnodeGid[vnIndex] = newVg.vnodeGid[newVg.replica];
|
||||
memset(&newVg.vnodeGid[newVg.replica], 0, sizeof(SVnodeGid));
|
||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true) != 0) return -1;
|
||||
for (int32_t i = 0; i < newVg.replica; ++i) {
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
||||
mInfo("vgId:%d, will remove 1 vnode", pVgroup->vgId);
|
||||
newVg.replica--;
|
||||
SVnodeGid del = newVg.vnodeGid[vnIndex];
|
||||
newVg.vnodeGid[vnIndex] = newVg.vnodeGid[newVg.replica];
|
||||
memset(&newVg.vnodeGid[newVg.replica], 0, sizeof(SVnodeGid));
|
||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true) != 0) return -1;
|
||||
for (int32_t i = 0; i < newVg.replica; ++i) {
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
||||
}
|
||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||
} else {
|
||||
mInfo("vgId:%d, will add 1 vnode and force remove 1 vnode", pVgroup->vgId);
|
||||
if (mndAddVnodeToVgroup(pMnode, &newVg, pArray) != 0) return -1;
|
||||
newVg.replica--;
|
||||
SVnodeGid del = newVg.vnodeGid[vnIndex];
|
||||
newVg.vnodeGid[vnIndex] = newVg.vnodeGid[newVg.replica];
|
||||
memset(&newVg.vnodeGid[newVg.replica], 0, sizeof(SVnodeGid));
|
||||
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[vnIndex]) != 0) return -1;
|
||||
for (int32_t i = 0; i < newVg.replica; ++i) {
|
||||
if (i != vnIndex) {
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
||||
}
|
||||
}
|
||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||
|
||||
if (newVg.replica == 1) {
|
||||
mInfo("vgId:%d, all data is dropped since replica=1", pVgroup->vgId);
|
||||
}
|
||||
}
|
||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||
|
||||
{
|
||||
SSdbRaw *pRaw = mndVgroupActionEncode(&newVg);
|
||||
|
@ -1120,7 +1141,7 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndSetMoveVgroupsInfoToTrans(SMnode *pMnode, STrans *pTrans, int32_t delDnodeId) {
|
||||
int32_t mndSetMoveVgroupsInfoToTrans(SMnode *pMnode, STrans *pTrans, int32_t delDnodeId, bool force) {
|
||||
int32_t code = 0;
|
||||
SArray *pArray = mndBuildDnodesArray(pMnode, delDnodeId);
|
||||
if (pArray == NULL) return -1;
|
||||
|
@ -1141,9 +1162,9 @@ int32_t mndSetMoveVgroupsInfoToTrans(SMnode *pMnode, STrans *pTrans, int32_t del
|
|||
|
||||
code = 0;
|
||||
if (vnIndex != -1) {
|
||||
mInfo("vgId:%d, vnode:%d will be removed from dnode:%d", pVgroup->vgId, vnIndex, delDnodeId);
|
||||
mInfo("vgId:%d, vnode:%d will be removed from dnode:%d, force:%d", pVgroup->vgId, vnIndex, delDnodeId, force);
|
||||
SDbObj *pDb = mndAcquireDb(pMnode, pVgroup->dbName);
|
||||
code = mndSetMoveVgroupInfoToTrans(pMnode, pTrans, pDb, pVgroup, vnIndex, pArray);
|
||||
code = mndSetMoveVgroupInfoToTrans(pMnode, pTrans, pDb, pVgroup, vnIndex, pArray, force);
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
}
|
||||
|
||||
|
|
|
@ -265,34 +265,47 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
|||
if (ret < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
mError("failed to read sdb file:%s since %s", file, tstrerror(code));
|
||||
break;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (ret != readLen) {
|
||||
code = TSDB_CODE_FILE_CORRUPTED;
|
||||
mError("failed to read sdb file:%s since %s", file, tstrerror(code));
|
||||
break;
|
||||
mError("failed to read sdb file:%s since %s, ret:%" PRId64 " != readLen:%d", file, tstrerror(code), ret, readLen);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
readLen = pRaw->dataLen + sizeof(int32_t);
|
||||
if (readLen >= pRaw->dataLen) {
|
||||
SSdbRaw *pNewRaw = taosMemoryMalloc(pRaw->dataLen + TSDB_MAX_MSG_SIZE);
|
||||
if (pNewRaw == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
mError("failed read sdb file since malloc new sdbRaw size:%d failed", pRaw->dataLen + TSDB_MAX_MSG_SIZE);
|
||||
goto _OVER;
|
||||
}
|
||||
mInfo("malloc new sdbRaw size:%d, type:%d", pRaw->dataLen + TSDB_MAX_MSG_SIZE, pRaw->type);
|
||||
memcpy(pNewRaw, pRaw, sizeof(SSdbRaw));
|
||||
sdbFreeRaw(pRaw);
|
||||
pRaw = pNewRaw;
|
||||
}
|
||||
|
||||
ret = taosReadFile(pFile, pRaw->pData, readLen);
|
||||
if (ret < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
mError("failed to read sdb file:%s since %s", file, tstrerror(code));
|
||||
break;
|
||||
mError("failed to read sdb file:%s since %s, ret:%" PRId64 " readLen:%d", file, tstrerror(code), ret, readLen);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (ret != readLen) {
|
||||
code = TSDB_CODE_FILE_CORRUPTED;
|
||||
mError("failed to read sdb file:%s since %s", file, tstrerror(code));
|
||||
break;
|
||||
mError("failed to read sdb file:%s since %s, ret:%" PRId64 " != readLen:%d", file, tstrerror(code), ret, readLen);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
int32_t totalLen = sizeof(SSdbRaw) + pRaw->dataLen + sizeof(int32_t);
|
||||
if ((!taosCheckChecksumWhole((const uint8_t *)pRaw, totalLen)) != 0) {
|
||||
code = TSDB_CODE_CHECKSUM_ERROR;
|
||||
mError("failed to read sdb file:%s since %s", file, tstrerror(code));
|
||||
break;
|
||||
mError("failed to read sdb file:%s since %s, readLen:%d", file, tstrerror(code), readLen);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
code = sdbWriteWithoutFree(pSdb, pRaw);
|
||||
|
|
|
@ -90,12 +90,12 @@ int32_t qndProcessQueryMsg(SQnode *pQnode, int64_t ts, SRpcMsg *pMsg) {
|
|||
code = qWorkerProcessFetchMsg(pQnode, pQnode->pQuery, pMsg, ts);
|
||||
break;
|
||||
case TDMT_SCH_CANCEL_TASK:
|
||||
//code = qWorkerProcessCancelMsg(pQnode, pQnode->pQuery, pMsg, ts);
|
||||
// code = qWorkerProcessCancelMsg(pQnode, pQnode->pQuery, pMsg, ts);
|
||||
break;
|
||||
case TDMT_SCH_DROP_TASK:
|
||||
code = qWorkerProcessDropMsg(pQnode, pQnode->pQuery, pMsg, ts);
|
||||
break;
|
||||
case TDMT_VND_CONSUME:
|
||||
case TDMT_VND_TMQ_CONSUME:
|
||||
// code = tqProcessConsumeReq(pQnode->pTq, pMsg);
|
||||
// break;
|
||||
case TDMT_SCH_QUERY_HEARTBEAT:
|
||||
|
@ -103,7 +103,7 @@ int32_t qndProcessQueryMsg(SQnode *pQnode, int64_t ts, SRpcMsg *pMsg) {
|
|||
break;
|
||||
default:
|
||||
qError("unknown msg type:%d in qnode queue", pMsg->msgType);
|
||||
terrno = TSDB_CODE_VND_APP_ERROR;
|
||||
terrno = TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
if (code == 0) return TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
|
|
|
@ -231,10 +231,10 @@ int32_t sndProcessTaskRetrieveReq(SSnode *pSnode, SRpcMsg *pMsg) {
|
|||
|
||||
int32_t sndProcessTaskDispatchRsp(SSnode *pSnode, SRpcMsg *pMsg) {
|
||||
SStreamDispatchRsp *pRsp = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||
int32_t taskId = pRsp->taskId;
|
||||
int32_t taskId = ntohl(pRsp->upstreamTaskId);
|
||||
SStreamTask *pTask = streamMetaGetTask(pSnode->pMeta, taskId);
|
||||
if (pTask) {
|
||||
streamProcessDispatchRsp(pTask, pRsp);
|
||||
streamProcessDispatchRsp(pTask, pRsp, pMsg->code);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -261,18 +261,52 @@ int32_t sndProcessWriteMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg *pRsp) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t sndProcessTaskRecoverFinishReq(SSnode *pSnode, SRpcMsg *pMsg) {
|
||||
char *msg = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||
int32_t msgLen = pMsg->contLen - sizeof(SMsgHead);
|
||||
|
||||
// deserialize
|
||||
SStreamRecoverFinishReq req;
|
||||
|
||||
SDecoder decoder;
|
||||
tDecoderInit(&decoder, msg, msgLen);
|
||||
tDecodeSStreamRecoverFinishReq(&decoder, &req);
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
// find task
|
||||
SStreamTask *pTask = streamMetaGetTask(pSnode->pMeta, req.taskId);
|
||||
if (pTask == NULL) {
|
||||
return -1;
|
||||
}
|
||||
// do process request
|
||||
if (streamProcessRecoverFinishReq(pTask, req.childId) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t sndProcessTaskRecoverFinishRsp(SSnode *pSnode, SRpcMsg *pMsg) {
|
||||
//
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t sndProcessStreamMsg(SSnode *pSnode, SRpcMsg *pMsg) {
|
||||
switch (pMsg->msgType) {
|
||||
case TDMT_STREAM_TASK_RUN:
|
||||
return sndProcessTaskRunReq(pSnode, pMsg);
|
||||
case TDMT_STREAM_TASK_DISPATCH:
|
||||
return sndProcessTaskDispatchReq(pSnode, pMsg, true);
|
||||
case TDMT_STREAM_RETRIEVE:
|
||||
return sndProcessTaskRetrieveReq(pSnode, pMsg);
|
||||
case TDMT_STREAM_TASK_DISPATCH_RSP:
|
||||
return sndProcessTaskDispatchRsp(pSnode, pMsg);
|
||||
case TDMT_STREAM_RETRIEVE:
|
||||
return sndProcessTaskRetrieveReq(pSnode, pMsg);
|
||||
case TDMT_STREAM_RETRIEVE_RSP:
|
||||
return sndProcessTaskRetrieveRsp(pSnode, pMsg);
|
||||
case TDMT_STREAM_RECOVER_FINISH:
|
||||
return sndProcessTaskRecoverFinishReq(pSnode, pMsg);
|
||||
case TDMT_STREAM_RECOVER_FINISH_RSP:
|
||||
return sndProcessTaskRecoverFinishRsp(pSnode, pMsg);
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
|
|
|
@ -83,7 +83,6 @@ int32_t vnodePreprocessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
|||
|
||||
int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg *pRsp);
|
||||
int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
||||
int32_t vnodeProcessSyncCtrlMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
||||
int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
||||
int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo);
|
||||
void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs);
|
||||
|
@ -159,7 +158,7 @@ int32_t tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, void *pTableL
|
|||
void tsdbReaderClose(STsdbReader *pReader);
|
||||
bool tsdbNextDataBlock(STsdbReader *pReader);
|
||||
bool tsdbTableNextDataBlock(STsdbReader *pReader, uint64_t uid);
|
||||
void tsdbRetrieveDataBlockInfo(STsdbReader *pReader, SDataBlockInfo *pDataBlockInfo);
|
||||
void tsdbRetrieveDataBlockInfo(const STsdbReader *pReader, int32_t *rows, uint64_t *uid, STimeWindow *pWindow);
|
||||
int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SColumnDataAgg ***pBlockStatis, bool *allHave);
|
||||
SArray *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList);
|
||||
int32_t tsdbReaderReset(STsdbReader *pReader, SQueryTableDataCond *pCond);
|
||||
|
@ -241,7 +240,7 @@ bool tqNextDataBlock(STqReader *pReader);
|
|||
bool tqNextDataBlockFilterOut(STqReader *pReader, SHashObj *filterOutUids);
|
||||
int32_t tqRetrieveDataBlock(SSDataBlock *pBlock, STqReader *pReader);
|
||||
|
||||
void vnodeEnqueueStreamMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
||||
int32_t vnodeEnqueueStreamMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
||||
|
||||
// sma
|
||||
int32_t smaGetTSmaDays(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days);
|
||||
|
|
|
@ -643,6 +643,7 @@ typedef struct SSttBlockLoadInfo {
|
|||
STSchema *pSchema;
|
||||
int16_t *colIds;
|
||||
int32_t numOfCols;
|
||||
bool sttBlockLoaded;
|
||||
} SSttBlockLoadInfo;
|
||||
|
||||
typedef struct SMergeTree {
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define _TD_VND_H_
|
||||
|
||||
#include "sync.h"
|
||||
#include "syncTools.h"
|
||||
#include "ttrace.h"
|
||||
#include "vnodeInt.h"
|
||||
|
||||
|
|
|
@ -150,19 +150,19 @@ typedef struct {
|
|||
int32_t metaGetStbStats(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo);
|
||||
|
||||
// tsdb
|
||||
int tsdbOpen(SVnode* pVnode, STsdb** ppTsdb, const char* dir, STsdbKeepCfg* pKeepCfg, int8_t rollback);
|
||||
int tsdbClose(STsdb** pTsdb);
|
||||
int32_t tsdbBegin(STsdb* pTsdb);
|
||||
int32_t tsdbCommit(STsdb* pTsdb);
|
||||
int32_t tsdbFinishCommit(STsdb* pTsdb);
|
||||
int32_t tsdbRollbackCommit(STsdb* pTsdb);
|
||||
int32_t tsdbDoRetention(STsdb* pTsdb, int64_t now);
|
||||
int tsdbScanAndConvertSubmitMsg(STsdb* pTsdb, SSubmitReq* pMsg);
|
||||
int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSubmitRsp* pRsp);
|
||||
int32_t tsdbInsertTableData(STsdb* pTsdb, int64_t version, SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock,
|
||||
SSubmitBlkRsp* pRsp);
|
||||
int32_t tsdbDeleteTableData(STsdb* pTsdb, int64_t version, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKEY eKey);
|
||||
int32_t tsdbSetKeepCfg(STsdb* pTsdb, STsdbCfg* pCfg);
|
||||
int tsdbOpen(SVnode* pVnode, STsdb** ppTsdb, const char* dir, STsdbKeepCfg* pKeepCfg, int8_t rollback);
|
||||
int tsdbClose(STsdb** pTsdb);
|
||||
int32_t tsdbBegin(STsdb* pTsdb);
|
||||
int32_t tsdbCommit(STsdb* pTsdb);
|
||||
int32_t tsdbFinishCommit(STsdb* pTsdb);
|
||||
int32_t tsdbRollbackCommit(STsdb* pTsdb);
|
||||
int32_t tsdbDoRetention(STsdb* pTsdb, int64_t now);
|
||||
int tsdbScanAndConvertSubmitMsg(STsdb* pTsdb, SSubmitReq* pMsg);
|
||||
int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSubmitRsp* pRsp);
|
||||
int32_t tsdbInsertTableData(STsdb* pTsdb, int64_t version, SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock,
|
||||
SSubmitBlkRsp* pRsp);
|
||||
int32_t tsdbDeleteTableData(STsdb* pTsdb, int64_t version, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKEY eKey);
|
||||
int32_t tsdbSetKeepCfg(STsdb* pTsdb, STsdbCfg* pCfg);
|
||||
|
||||
// tq
|
||||
int tqInit();
|
||||
|
@ -176,22 +176,26 @@ int32_t tqCheckColModifiable(STQ* pTq, int64_t tbUid, int32_t colId);
|
|||
// tq-mq
|
||||
int32_t tqProcessAddCheckInfoReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessDelCheckInfoReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessVgDeleteReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessSubscribeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessDeleteSubReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessOffsetCommitReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
// tq-stream
|
||||
int32_t tqProcessTaskDeployReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessTaskDropReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessStreamTaskCheckReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessStreamTaskCheckRsp(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessSubmitReq(STQ* pTq, SSubmitReq* data, int64_t ver);
|
||||
int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver);
|
||||
int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg, bool exec);
|
||||
int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessTaskRetrieveReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessTaskRetrieveRsp(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessTaskRecover1Req(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessTaskRecover2Req(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessTaskRecoverFinishReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessTaskRecoverFinishRsp(STQ* pTq, SRpcMsg* pMsg);
|
||||
|
||||
SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pSchema,
|
||||
SSchemaWrapper* pTagSchemaWrapper, bool createTb, int64_t suid, const char* stbFullName,
|
||||
|
|
|
@ -53,7 +53,7 @@ static void metaGetEntryInfo(const SMetaEntry *pEntry, SMetaInfo *pInfo) {
|
|||
static int metaUpdateMetaRsp(tb_uid_t uid, char *tbName, SSchemaWrapper *pSchema, STableMetaRsp *pMetaRsp) {
|
||||
pMetaRsp->pSchemas = taosMemoryMalloc(pSchema->nCols * sizeof(SSchema));
|
||||
if (NULL == pMetaRsp->pSchemas) {
|
||||
terrno = TSDB_CODE_VND_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -498,7 +498,7 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
|
|||
|
||||
rc = tdbTbGet(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pData, &nData);
|
||||
if (rc < 0) {
|
||||
terrno = TSDB_CODE_VND_TABLE_NOT_EXIST;
|
||||
terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
||||
return -1;
|
||||
}
|
||||
uid = *(tb_uid_t *)pData;
|
||||
|
@ -743,7 +743,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
// search name index
|
||||
ret = tdbTbGet(pMeta->pNameIdx, pAlterTbReq->tbName, strlen(pAlterTbReq->tbName) + 1, &pVal, &nVal);
|
||||
if (ret < 0) {
|
||||
terrno = TSDB_CODE_VND_TABLE_NOT_EXIST;
|
||||
terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -824,7 +824,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
break;
|
||||
case TSDB_ALTER_TABLE_DROP_COLUMN:
|
||||
if (pColumn == NULL) {
|
||||
terrno = TSDB_CODE_VND_TABLE_COL_NOT_EXISTS;
|
||||
terrno = TSDB_CODE_VND_COL_NOT_EXISTS;
|
||||
goto _err;
|
||||
}
|
||||
if (pColumn->colId == 0) {
|
||||
|
@ -846,7 +846,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
break;
|
||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
||||
if (pColumn == NULL) {
|
||||
terrno = TSDB_CODE_VND_TABLE_COL_NOT_EXISTS;
|
||||
terrno = TSDB_CODE_VND_COL_NOT_EXISTS;
|
||||
goto _err;
|
||||
}
|
||||
if (!IS_VAR_DATA_TYPE(pColumn->type) || pColumn->bytes > pAlterTbReq->colModBytes) {
|
||||
|
@ -866,7 +866,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
goto _err;
|
||||
}
|
||||
if (pColumn == NULL) {
|
||||
terrno = TSDB_CODE_VND_TABLE_COL_NOT_EXISTS;
|
||||
terrno = TSDB_CODE_VND_COL_NOT_EXISTS;
|
||||
goto _err;
|
||||
}
|
||||
if (tqCheckColModifiable(pMeta->pVnode->pTq, uid, pColumn->colId) != 0) {
|
||||
|
@ -934,7 +934,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
|||
// search name index
|
||||
ret = tdbTbGet(pMeta->pNameIdx, pAlterTbReq->tbName, strlen(pAlterTbReq->tbName) + 1, &pVal, &nVal);
|
||||
if (ret < 0) {
|
||||
terrno = TSDB_CODE_VND_TABLE_NOT_EXIST;
|
||||
terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -990,7 +990,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
|||
}
|
||||
|
||||
if (pColumn == NULL) {
|
||||
terrno = TSDB_CODE_VND_TABLE_COL_NOT_EXISTS;
|
||||
terrno = TSDB_CODE_VND_COL_NOT_EXISTS;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -1093,7 +1093,7 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
|||
// search name index
|
||||
ret = tdbTbGet(pMeta->pNameIdx, pAlterTbReq->tbName, strlen(pAlterTbReq->tbName) + 1, &pVal, &nVal);
|
||||
if (ret < 0) {
|
||||
terrno = TSDB_CODE_VND_TABLE_NOT_EXIST;
|
||||
terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char
|
|||
}
|
||||
|
||||
if (pTsmaStat->pTSma->indexUid != indexUid) {
|
||||
terrno = TSDB_CODE_VND_APP_ERROR;
|
||||
terrno = TSDB_CODE_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;
|
||||
|
|
|
@ -709,7 +709,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqProcessVgDeleteReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen) {
|
||||
int32_t tqProcessDeleteSubReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen) {
|
||||
SMqVDeleteReq* pReq = (SMqVDeleteReq*)msg;
|
||||
|
||||
taosWLockLatch(&pTq->pushLock);
|
||||
|
@ -767,7 +767,7 @@ int32_t tqProcessDelCheckInfoReq(STQ* pTq, int64_t version, char* msg, int32_t m
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen) {
|
||||
int32_t tqProcessSubscribeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen) {
|
||||
SMqRebVgReq req = {0};
|
||||
tDecodeSMqRebVgReq(msg, &req);
|
||||
// todo lock
|
||||
|
@ -896,6 +896,10 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver) {
|
|||
pTask->startVer = ver;
|
||||
|
||||
// expand executor
|
||||
if (pTask->fillHistory) {
|
||||
pTask->taskStatus = TASK_STATUS__WAIT_DOWNSTREAM;
|
||||
}
|
||||
|
||||
if (pTask->taskLevel == TASK_LEVEL__SOURCE) {
|
||||
pTask->pState = streamStateOpen(pTq->pStreamMeta->path, pTask, false, -1, -1);
|
||||
if (pTask->pState == NULL) {
|
||||
|
@ -911,9 +915,6 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver) {
|
|||
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle);
|
||||
ASSERT(pTask->exec.executor);
|
||||
|
||||
if (pTask->fillHistory) {
|
||||
pTask->taskStatus = TASK_STATUS__RECOVER_PREPARE;
|
||||
}
|
||||
} else if (pTask->taskLevel == TASK_LEVEL__AGG) {
|
||||
pTask->pState = streamStateOpen(pTq->pStreamMeta->path, pTask, false, -1, -1);
|
||||
if (pTask->pState == NULL) {
|
||||
|
@ -947,11 +948,90 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver) {
|
|||
|
||||
streamSetupTrigger(pTask);
|
||||
|
||||
tqInfo("expand stream task on vg %d, task id %d, child id %d", TD_VID(pTq->pVnode), pTask->taskId,
|
||||
pTask->selfChildId);
|
||||
tqInfo("expand stream task on vg %d, task id %d, child id %d, level %d", TD_VID(pTq->pVnode), pTask->taskId,
|
||||
pTask->selfChildId, pTask->taskLevel);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqProcessStreamTaskCheckReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||
char* msgStr = pMsg->pCont;
|
||||
char* msgBody = POINTER_SHIFT(msgStr, sizeof(SMsgHead));
|
||||
int32_t msgLen = pMsg->contLen - sizeof(SMsgHead);
|
||||
SStreamTaskCheckReq req;
|
||||
SDecoder decoder;
|
||||
tDecoderInit(&decoder, msgBody, msgLen);
|
||||
tDecodeSStreamTaskCheckReq(&decoder, &req);
|
||||
tDecoderClear(&decoder);
|
||||
int32_t taskId = req.downstreamTaskId;
|
||||
SStreamTaskCheckRsp rsp = {
|
||||
.reqId = req.reqId,
|
||||
.streamId = req.streamId,
|
||||
.childId = req.childId,
|
||||
.downstreamNodeId = req.downstreamNodeId,
|
||||
.downstreamTaskId = req.downstreamTaskId,
|
||||
.upstreamNodeId = req.upstreamNodeId,
|
||||
.upstreamTaskId = req.upstreamTaskId,
|
||||
};
|
||||
SStreamTask* pTask = streamMetaGetTask(pTq->pStreamMeta, taskId);
|
||||
if (pTask && atomic_load_8(&pTask->taskStatus) == TASK_STATUS__NORMAL) {
|
||||
rsp.status = 1;
|
||||
} else {
|
||||
rsp.status = 0;
|
||||
}
|
||||
|
||||
tqDebug("tq recv task check req(reqId: %" PRId64 ") %d at node %d check req from task %d at node %d, status %d",
|
||||
rsp.reqId, rsp.downstreamTaskId, rsp.downstreamNodeId, rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.status);
|
||||
|
||||
SEncoder encoder;
|
||||
int32_t code;
|
||||
int32_t len;
|
||||
tEncodeSize(tEncodeSStreamTaskCheckRsp, &rsp, len, code);
|
||||
if (code < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
void* buf = rpcMallocCont(sizeof(SMsgHead) + len);
|
||||
((SMsgHead*)buf)->vgId = htonl(req.upstreamNodeId);
|
||||
|
||||
void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
||||
tEncoderInit(&encoder, (uint8_t*)abuf, len);
|
||||
tEncodeSStreamTaskCheckRsp(&encoder, &rsp);
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
SRpcMsg rspMsg = {
|
||||
.code = 0,
|
||||
.pCont = buf,
|
||||
.contLen = sizeof(SMsgHead) + len,
|
||||
.info = pMsg->info,
|
||||
};
|
||||
|
||||
tmsgSendRsp(&rspMsg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqProcessStreamTaskCheckRsp(STQ* pTq, int64_t version, char* msg, int32_t msgLen) {
|
||||
int32_t code;
|
||||
SStreamTaskCheckRsp rsp;
|
||||
|
||||
SDecoder decoder;
|
||||
tDecoderInit(&decoder, (uint8_t*)msg, msgLen);
|
||||
code = tDecodeSStreamTaskCheckRsp(&decoder, &rsp);
|
||||
if (code < 0) {
|
||||
tDecoderClear(&decoder);
|
||||
return -1;
|
||||
}
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
tqDebug("tq recv task check rsp(reqId: %" PRId64 ") %d at node %d check req from task %d at node %d, status %d",
|
||||
rsp.reqId, rsp.downstreamTaskId, rsp.downstreamNodeId, rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.status);
|
||||
|
||||
SStreamTask* pTask = streamMetaGetTask(pTq->pStreamMeta, rsp.upstreamTaskId);
|
||||
if (pTask == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return streamProcessTaskCheckRsp(pTask, &rsp, version);
|
||||
}
|
||||
|
||||
int32_t tqProcessTaskDeployReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen) {
|
||||
int32_t code;
|
||||
#if 0
|
||||
|
@ -982,36 +1062,17 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, int64_t version, char* msg, int32_t msg
|
|||
|
||||
// 3.go through recover steps to fill history
|
||||
if (pTask->fillHistory) {
|
||||
streamSetParamForRecover(pTask);
|
||||
if (pTask->taskLevel == TASK_LEVEL__SOURCE) {
|
||||
streamSourceRecoverPrepareStep1(pTask, version);
|
||||
|
||||
SStreamRecoverStep1Req req;
|
||||
streamBuildSourceRecover1Req(pTask, &req);
|
||||
|
||||
void* serialziedReq = (void*)&req;
|
||||
int32_t len = sizeof(SStreamRecoverStep1Req);
|
||||
|
||||
SRpcMsg rpcMsg = {
|
||||
.contLen = len,
|
||||
.pCont = serialziedReq,
|
||||
.msgType = TDMT_VND_STREAM_RECOVER_STEP1,
|
||||
};
|
||||
|
||||
tmsgPutToQueue(&pTq->pVnode->msgCb, STREAM_QUEUE, &rpcMsg);
|
||||
|
||||
} else if (pTask->taskLevel == TASK_LEVEL__AGG) {
|
||||
streamAggRecoverPrepare(pTask);
|
||||
} else if (pTask->taskLevel == TASK_LEVEL__SINK) {
|
||||
// do nothing
|
||||
}
|
||||
streamTaskCheckDownstream(pTask, version);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqProcessTaskRecover1Req(STQ* pTq, char* msg, int32_t msgLen) {
|
||||
int32_t code;
|
||||
int32_t tqProcessTaskRecover1Req(STQ* pTq, SRpcMsg* pMsg) {
|
||||
int32_t code;
|
||||
char* msg = pMsg->pCont;
|
||||
int32_t msgLen = pMsg->contLen;
|
||||
|
||||
SStreamRecoverStep1Req* pReq = (SStreamRecoverStep1Req*)msg;
|
||||
SStreamTask* pTask = streamMetaGetTask(pTq->pStreamMeta, pReq->taskId);
|
||||
if (pTask == NULL) {
|
||||
|
@ -1035,16 +1096,24 @@ int32_t tqProcessTaskRecover1Req(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
ASSERT(pReq->taskId == pTask->taskId);
|
||||
|
||||
// serialize msg
|
||||
int32_t len = sizeof(SStreamRecoverStep2Req);
|
||||
void* serializedReq = (void*)&req;
|
||||
int32_t len = sizeof(SStreamRecoverStep1Req);
|
||||
|
||||
void* serializedReq = rpcMallocCont(len);
|
||||
if (serializedReq == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(serializedReq, &req, len);
|
||||
|
||||
// dispatch msg
|
||||
SRpcMsg rpcMsg = {
|
||||
.code = 0,
|
||||
.contLen = len,
|
||||
.msgType = TDMT_VND_STREAM_RECOVER_STEP2,
|
||||
.pCont = (void*)serializedReq,
|
||||
.pCont = serializedReq,
|
||||
};
|
||||
|
||||
tmsgPutToQueue(&pTq->pVnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
|
@ -1087,15 +1156,15 @@ int32_t tqProcessTaskRecover2Req(STQ* pTq, int64_t version, char* msg, int32_t m
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqProcessTaskRecoverFinishReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||
int32_t code;
|
||||
int32_t tqProcessTaskRecoverFinishReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||
char* msg = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||
int32_t msgLen = pMsg->contLen - sizeof(SMsgHead);
|
||||
|
||||
// deserialize
|
||||
int32_t len;
|
||||
SStreamRecoverFinishReq req;
|
||||
|
||||
SDecoder decoder;
|
||||
tDecoderInit(&decoder, msg, sizeof(SStreamRecoverFinishReq));
|
||||
tDecoderInit(&decoder, msg, msgLen);
|
||||
tDecodeSStreamRecoverFinishReq(&decoder, &req);
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
|
@ -1112,6 +1181,11 @@ int32_t tqProcessTaskRecoverFinishReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqProcessTaskRecoverFinishRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||
//
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) {
|
||||
bool failed = false;
|
||||
SDecoder* pCoder = &(SDecoder){0};
|
||||
|
@ -1235,7 +1309,7 @@ int32_t tqProcessSubmitReq(STQ* pTq, SSubmitReq* pReq, int64_t ver) {
|
|||
pSubmit = streamDataSubmitNew(pReq);
|
||||
if (pSubmit == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
qError("failed to create data submit for stream since out of memory");
|
||||
tqError("failed to create data submit for stream since out of memory");
|
||||
failed = true;
|
||||
}
|
||||
|
||||
|
@ -1244,18 +1318,21 @@ int32_t tqProcessSubmitReq(STQ* pTq, SSubmitReq* pReq, int64_t ver) {
|
|||
if (pIter == NULL) break;
|
||||
SStreamTask* pTask = *(SStreamTask**)pIter;
|
||||
if (pTask->taskLevel != TASK_LEVEL__SOURCE) continue;
|
||||
if (pTask->taskStatus == TASK_STATUS__RECOVER_PREPARE || pTask->taskStatus == TASK_STATUS__RECOVER1) continue;
|
||||
if (pTask->taskStatus == TASK_STATUS__RECOVER_PREPARE || pTask->taskStatus == TASK_STATUS__WAIT_DOWNSTREAM) {
|
||||
tqDebug("skip push task %d, task status %d", pTask->taskId, pTask->taskStatus);
|
||||
continue;
|
||||
}
|
||||
|
||||
qDebug("data submit enqueue stream task: %d, ver: %" PRId64, pTask->taskId, ver);
|
||||
tqDebug("data submit enqueue stream task: %d, ver: %" PRId64, pTask->taskId, ver);
|
||||
|
||||
if (!failed) {
|
||||
if (streamTaskInput(pTask, (SStreamQueueItem*)pSubmit) < 0) {
|
||||
qError("stream task input failed, task id %d", pTask->taskId);
|
||||
tqError("stream task input failed, task id %d", pTask->taskId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streamSchedExec(pTask) < 0) {
|
||||
qError("stream task launch failed, task id %d", pTask->taskId);
|
||||
tqError("stream task launch failed, task id %d", pTask->taskId);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
@ -1306,39 +1383,13 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg, bool exec) {
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||
SStreamTaskRecoverReq* pReq = pMsg->pCont;
|
||||
int32_t taskId = pReq->taskId;
|
||||
SStreamTask* pTask = streamMetaGetTask(pTq->pStreamMeta, taskId);
|
||||
if (pTask) {
|
||||
streamProcessRecoverReq(pTask, pReq, pMsg);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||
SStreamTaskRecoverRsp* pRsp = pMsg->pCont;
|
||||
int32_t taskId = pRsp->rspTaskId;
|
||||
|
||||
SStreamTask* pTask = streamMetaGetTask(pTq->pStreamMeta, taskId);
|
||||
if (pTask) {
|
||||
streamProcessRecoverRsp(pTask, pRsp);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||
SStreamDispatchRsp* pRsp = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||
int32_t taskId = pRsp->taskId;
|
||||
int32_t taskId = ntohl(pRsp->upstreamTaskId);
|
||||
SStreamTask* pTask = streamMetaGetTask(pTq->pStreamMeta, taskId);
|
||||
tqDebug("recv dispatch rsp, code: %x", pMsg->code);
|
||||
if (pTask) {
|
||||
streamProcessDispatchRsp(pTask, pRsp);
|
||||
streamProcessDispatchRsp(pTask, pRsp, pMsg->code);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -1379,12 +1430,12 @@ int32_t tqProcessTaskRetrieveRsp(STQ* pTq, SRpcMsg* pMsg) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void vnodeEnqueueStreamMsg(SVnode* pVnode, SRpcMsg* pMsg) {
|
||||
STQ* pTq = pVnode->pTq;
|
||||
char* msgStr = pMsg->pCont;
|
||||
char* msgBody = POINTER_SHIFT(msgStr, sizeof(SMsgHead));
|
||||
int32_t msgLen = pMsg->contLen - sizeof(SMsgHead);
|
||||
int32_t code = 0;
|
||||
int32_t vnodeEnqueueStreamMsg(SVnode* pVnode, SRpcMsg* pMsg) {
|
||||
STQ* pTq = pVnode->pTq;
|
||||
SMsgHead* msgStr = pMsg->pCont;
|
||||
char* msgBody = POINTER_SHIFT(msgStr, sizeof(SMsgHead));
|
||||
int32_t msgLen = pMsg->contLen - sizeof(SMsgHead);
|
||||
int32_t code = 0;
|
||||
|
||||
SStreamDispatchReq req;
|
||||
SDecoder decoder;
|
||||
|
@ -1407,16 +1458,45 @@ void vnodeEnqueueStreamMsg(SVnode* pVnode, SRpcMsg* pMsg) {
|
|||
streamProcessDispatchReq(pTask, &req, &rsp, false);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
code = TSDB_CODE_STREAM_TASK_NOT_EXIST;
|
||||
|
||||
FAIL:
|
||||
if (pMsg->info.handle == NULL) return;
|
||||
if (pMsg->info.handle == NULL) return -1;
|
||||
|
||||
SMsgHead* pRspHead = rpcMallocCont(sizeof(SMsgHead) + sizeof(SStreamDispatchRsp));
|
||||
if (pRspHead == NULL) {
|
||||
SRpcMsg rsp = {
|
||||
.code = TSDB_CODE_OUT_OF_MEMORY,
|
||||
.info = pMsg->info,
|
||||
};
|
||||
tqDebug("send dispatch error rsp, code: %x", code);
|
||||
tmsgSendRsp(&rsp);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pRspHead->vgId = htonl(req.upstreamNodeId);
|
||||
SStreamDispatchRsp* pRsp = POINTER_SHIFT(pRspHead, sizeof(SMsgHead));
|
||||
pRsp->streamId = htobe64(req.streamId);
|
||||
pRsp->upstreamTaskId = htonl(req.upstreamTaskId);
|
||||
pRsp->upstreamNodeId = htonl(req.upstreamNodeId);
|
||||
pRsp->downstreamNodeId = htonl(pVnode->config.vgId);
|
||||
pRsp->downstreamTaskId = htonl(req.taskId);
|
||||
pRsp->inputStatus = TASK_OUTPUT_STATUS__NORMAL;
|
||||
|
||||
SRpcMsg rsp = {
|
||||
.code = code,
|
||||
.info = pMsg->info,
|
||||
.contLen = sizeof(SMsgHead) + sizeof(SStreamDispatchRsp),
|
||||
.pCont = pRspHead,
|
||||
};
|
||||
tqDebug("send dispatch error rsp, code: %x", code);
|
||||
tmsgSendRsp(&rsp);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -199,6 +199,9 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHea
|
|||
goto END;
|
||||
}
|
||||
|
||||
tqDebug("vgId:%d, taosx get msg ver %" PRId64 ", type: %s", pTq->pVnode->config.vgId, offset,
|
||||
TMSG_INFO((*ppCkHead)->head.msgType));
|
||||
|
||||
if ((*ppCkHead)->head.msgType == TDMT_VND_SUBMIT) {
|
||||
code = walFetchBody(pHandle->pWalReader, ppCkHead);
|
||||
|
||||
|
@ -216,17 +219,20 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHea
|
|||
SWalCont* pHead = &((*ppCkHead)->head);
|
||||
if (IS_META_MSG(pHead->msgType)) {
|
||||
code = walFetchBody(pHandle->pWalReader, ppCkHead);
|
||||
|
||||
if (code < 0) {
|
||||
ASSERT(0);
|
||||
*fetchOffset = offset;
|
||||
code = -1;
|
||||
goto END;
|
||||
}
|
||||
|
||||
if (isValValidForTable(pHandle, pHead)) {
|
||||
*fetchOffset = offset;
|
||||
code = 0;
|
||||
goto END;
|
||||
} else {
|
||||
offset++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -586,8 +592,39 @@ int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) {
|
|||
taosHashPut(pExec->execHandle.execDb.pFilterOutTbUid, &tbUid, sizeof(int64_t), NULL, 0);
|
||||
}
|
||||
}
|
||||
} else if (pExec->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
||||
if (isAdd) {
|
||||
SArray* qa = taosArrayInit(4, sizeof(tb_uid_t));
|
||||
SMetaReader mr = {0};
|
||||
metaReaderInit(&mr, pTq->pVnode->pMeta, 0);
|
||||
for (int32_t i = 0; i < taosArrayGetSize(tbUidList); ++i) {
|
||||
uint64_t* id = (uint64_t*)taosArrayGet(tbUidList, i);
|
||||
|
||||
int32_t code = metaGetTableEntryByUid(&mr, *id);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("failed to get table meta, uid:%" PRIu64 " code:%s", *id, tstrerror(terrno));
|
||||
continue;
|
||||
}
|
||||
|
||||
tDecoderClear(&mr.coder);
|
||||
|
||||
if (mr.me.type != TSDB_CHILD_TABLE || mr.me.ctbEntry.suid != pExec->execHandle.execTb.suid) {
|
||||
tqDebug("table uid %" PRId64 " does not add to tq handle", *id);
|
||||
continue;
|
||||
}
|
||||
tqDebug("table uid %" PRId64 " add to tq handle", *id);
|
||||
taosArrayPush(qa, id);
|
||||
}
|
||||
metaReaderClear(&mr);
|
||||
if (taosArrayGetSize(qa) > 0) {
|
||||
tqReaderAddTbUidList(pExec->execHandle.pExecReader, qa);
|
||||
}
|
||||
taosArrayDestroy(qa);
|
||||
} else {
|
||||
// TODO handle delete table from stb
|
||||
}
|
||||
} else {
|
||||
// tq update id
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
while (1) {
|
||||
|
|
|
@ -684,7 +684,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
|
|||
if (*state->pDataFReader != NULL) {
|
||||
tsdbDataFReaderClose(state->pDataFReader);
|
||||
|
||||
resetLastBlockLoadInfo(state->pLoadInfo);
|
||||
// resetLastBlockLoadInfo(state->pLoadInfo);
|
||||
}
|
||||
|
||||
code = tsdbDataFReaderOpen(state->pDataFReader, state->pTsdb, pFileSet);
|
||||
|
@ -764,7 +764,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
|
|||
if (--state->iBlock < 0) {
|
||||
tsdbDataFReaderClose(state->pDataFReader);
|
||||
*state->pDataFReader = NULL;
|
||||
resetLastBlockLoadInfo(state->pLoadInfo);
|
||||
// resetLastBlockLoadInfo(state->pLoadInfo);
|
||||
|
||||
if (state->aBlockIdx) {
|
||||
taosArrayDestroy(state->aBlockIdx);
|
||||
|
|
|
@ -333,11 +333,12 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
|||
code = TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
_end:
|
||||
_end:
|
||||
tsdbDataFReaderClose(&pr->pDataFReaderLast);
|
||||
tsdbDataFReaderClose(&pr->pDataFReader);
|
||||
|
||||
tsdbUntakeReadSnap(pr->pVnode->pTsdb, pr->pReadSnap, "cache-l");
|
||||
resetLastBlockLoadInfo(pr->pLoadInfo);
|
||||
|
||||
for (int32_t j = 0; j < pr->numOfCols; ++j) {
|
||||
taosMemoryFree(pRes[j]);
|
||||
|
|
|
@ -116,6 +116,13 @@ int32_t tsdbInsertTableData(STsdb *pTsdb, int64_t version, SSubmitMsgIter *pMsgI
|
|||
if (info.suid) {
|
||||
metaGetInfo(pTsdb->pVnode->pMeta, info.suid, &info);
|
||||
}
|
||||
if (pMsgIter->sversion != info.skmVer) {
|
||||
tsdbError("vgId:%d, req sver:%d, skmVer:%d suid:%" PRId64 " uid:%" PRId64,
|
||||
TD_VID(pTsdb->pVnode), pMsgIter->sversion, info.skmVer, suid, uid);
|
||||
code = TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
pRsp->sver = info.skmVer;
|
||||
|
||||
// create/get STbData to op
|
||||
|
@ -133,6 +140,7 @@ int32_t tsdbInsertTableData(STsdb *pTsdb, int64_t version, SSubmitMsgIter *pMsgI
|
|||
return code;
|
||||
|
||||
_err:
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ void resetLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) {
|
|||
|
||||
pLoadInfo[i].elapsedTime = 0;
|
||||
pLoadInfo[i].loadBlocks = 0;
|
||||
pLoadInfo[i].sttBlockLoaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -278,9 +279,10 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
|
|||
|
||||
(*pIter)->pBlockLoadInfo = pBlockLoadInfo;
|
||||
|
||||
size_t size = taosArrayGetSize(pBlockLoadInfo->aSttBlk);
|
||||
if (size == 0) {
|
||||
// size_t size = taosArrayGetSize(pBlockLoadInfo->aSttBlk);
|
||||
if (!pBlockLoadInfo->sttBlockLoaded) {
|
||||
int64_t st = taosGetTimestampUs();
|
||||
pBlockLoadInfo->sttBlockLoaded = true;
|
||||
|
||||
code = tsdbReadSttBlk(pReader, iStt, pBlockLoadInfo->aSttBlk);
|
||||
if (code) {
|
||||
|
@ -288,7 +290,7 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
|
|||
}
|
||||
|
||||
// only apply to the child tables, ordinary tables will not incur this filter procedure.
|
||||
size = taosArrayGetSize(pBlockLoadInfo->aSttBlk);
|
||||
size_t size = taosArrayGetSize(pBlockLoadInfo->aSttBlk);
|
||||
|
||||
if (size >= 1) {
|
||||
SSttBlk *pStart = taosArrayGet(pBlockLoadInfo->aSttBlk, 0);
|
||||
|
@ -296,10 +298,10 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
|
|||
|
||||
// all identical
|
||||
if (pStart->suid == pEnd->suid) {
|
||||
if (pStart->suid == suid) {
|
||||
// do nothing
|
||||
} else if (pStart->suid != suid) {
|
||||
if (pStart->suid != suid) {
|
||||
// no qualified stt block existed
|
||||
taosArrayClear(pBlockLoadInfo->aSttBlk);
|
||||
|
||||
(*pIter)->iSttBlk = -1;
|
||||
double el = (taosGetTimestampUs() - st) / 1000.0;
|
||||
tsdbDebug("load the last file info completed, elapsed time:%.2fms, %s", el, idStr);
|
||||
|
@ -330,7 +332,7 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
|
|||
tsdbDebug("load the last file info completed, elapsed time:%.2fms, %s", el, idStr);
|
||||
}
|
||||
|
||||
size = taosArrayGetSize(pBlockLoadInfo->aSttBlk);
|
||||
size_t size = taosArrayGetSize(pBlockLoadInfo->aSttBlk);
|
||||
|
||||
// find the start block
|
||||
(*pIter)->iSttBlk = binarySearchForStartBlock(pBlockLoadInfo->aSttBlk->pData, size, uid, backward);
|
||||
|
|
|
@ -48,7 +48,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
|
|||
}
|
||||
|
||||
pTsdb->path = (char *)&pTsdb[1];
|
||||
sprintf(pTsdb->path, "%s%s%s", pVnode->path, TD_DIRSEP, dir);
|
||||
snprintf(pTsdb->path, TD_PATH_MAX, "%s%s%s", pVnode->path, TD_DIRSEP, dir);
|
||||
taosRealPath(pTsdb->path, NULL, slen);
|
||||
pTsdb->pVnode = pVnode;
|
||||
taosThreadRwlockInit(&pTsdb->rwLock, NULL);
|
||||
|
|
|
@ -35,11 +35,17 @@ typedef struct {
|
|||
int32_t numOfLastFiles;
|
||||
} SBlockNumber;
|
||||
|
||||
typedef struct SBlockIndex {
|
||||
int32_t ordinalIndex;
|
||||
int64_t inFileOffset;
|
||||
STimeWindow window;
|
||||
} SBlockIndex;
|
||||
|
||||
typedef struct STableBlockScanInfo {
|
||||
uint64_t uid;
|
||||
TSKEY lastKey;
|
||||
SMapData mapData; // block info (compressed)
|
||||
SArray* pBlockList; // block data index list
|
||||
SArray* pBlockList; // block data index list, SArray<SBlockIndex>
|
||||
SIterInfo iter; // mem buffer skip list iterator
|
||||
SIterInfo iiter; // imem buffer skip list iterator
|
||||
SArray* delSkyline; // delete info for this table
|
||||
|
@ -72,6 +78,7 @@ typedef struct SIOCostSummary {
|
|||
double lastBlockLoadTime;
|
||||
int64_t composedBlocks;
|
||||
double buildComposedBlockTime;
|
||||
double createScanInfoList;
|
||||
} SIOCostSummary;
|
||||
|
||||
typedef struct SBlockLoadSuppInfo {
|
||||
|
@ -131,7 +138,7 @@ typedef struct SReaderStatus {
|
|||
bool loadFromFile; // check file stage
|
||||
bool composedDataBlock; // the returned data block is a composed block or not
|
||||
SHashObj* pTableMap; // SHash<STableBlockScanInfo>
|
||||
STableBlockScanInfo* pTableIter; // table iterator used in building in-memory buffer data blocks.
|
||||
STableBlockScanInfo** pTableIter; // table iterator used in building in-memory buffer data blocks.
|
||||
SUidOrderCheckInfo uidCheckInfo; // check all table in uid order
|
||||
SFileBlockDumpInfo fBlockDumpInfo;
|
||||
SDFileSet* pCurrentFileset; // current opened file set
|
||||
|
@ -140,6 +147,12 @@ typedef struct SReaderStatus {
|
|||
SDataBlockIter blockIter;
|
||||
} SReaderStatus;
|
||||
|
||||
typedef struct SBlockInfoBuf {
|
||||
int32_t currentIndex;
|
||||
SArray* pData;
|
||||
int32_t numPerBucket;
|
||||
} SBlockInfoBuf;
|
||||
|
||||
struct STsdbReader {
|
||||
STsdb* pTsdb;
|
||||
uint64_t suid;
|
||||
|
@ -157,9 +170,9 @@ struct STsdbReader {
|
|||
STSchema* pMemSchema; // the previous schema for in-memory data, to avoid load schema too many times
|
||||
SDataFReader* pFileReader;
|
||||
SVersionRange verRange;
|
||||
|
||||
int32_t step;
|
||||
STsdbReader* innerReader[2];
|
||||
SBlockInfoBuf blockInfoBuf;
|
||||
int32_t step;
|
||||
STsdbReader* innerReader[2];
|
||||
};
|
||||
|
||||
static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter);
|
||||
|
@ -225,6 +238,50 @@ static int32_t setColumnIdSlotList(STsdbReader* pReader, SSDataBlock* pBlock) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t initBlockScanInfoBuf(SBlockInfoBuf* pBuf, int32_t numOfTables) {
|
||||
int32_t num = numOfTables / pBuf->numPerBucket;
|
||||
int32_t remainder = numOfTables % pBuf->numPerBucket;
|
||||
if (pBuf->pData == NULL) {
|
||||
pBuf->pData = taosArrayInit(num + 1, POINTER_BYTES);
|
||||
}
|
||||
|
||||
for(int32_t i = 0; i < num; ++i) {
|
||||
char* p = taosMemoryCalloc(pBuf->numPerBucket, sizeof(STableBlockScanInfo));
|
||||
if (p == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
taosArrayPush(pBuf->pData, &p);
|
||||
}
|
||||
|
||||
if (remainder > 0) {
|
||||
char* p = taosMemoryCalloc(remainder, sizeof(STableBlockScanInfo));
|
||||
if (p == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
taosArrayPush(pBuf->pData, &p);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void clearBlockScanInfoBuf(SBlockInfoBuf* pBuf) {
|
||||
size_t num = taosArrayGetSize(pBuf->pData);
|
||||
for(int32_t i = 0; i < num; ++i) {
|
||||
char** p = taosArrayGet(pBuf->pData, i);
|
||||
taosMemoryFree(*p);
|
||||
}
|
||||
|
||||
taosArrayDestroy(pBuf->pData);
|
||||
}
|
||||
|
||||
static void* getPosInBlockInfoBuf(SBlockInfoBuf* pBuf, int32_t index) {
|
||||
int32_t bucketIndex = index / pBuf->numPerBucket;
|
||||
char** pBucket = taosArrayGet(pBuf->pData, bucketIndex);
|
||||
return (*pBucket) + (index % pBuf->numPerBucket) * sizeof(STableBlockScanInfo);
|
||||
}
|
||||
|
||||
// NOTE: speedup the whole processing by preparing the buffer for STableBlockScanInfo in batch model
|
||||
static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableKeyInfo* idList, int32_t numOfTables) {
|
||||
// allocate buffer in order to load data blocks from file
|
||||
// todo use simple hash instead, optimize the memory consumption
|
||||
|
@ -234,8 +291,24 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableK
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int64_t st = taosGetTimestampUs();
|
||||
initBlockScanInfoBuf(&pTsdbReader->blockInfoBuf, numOfTables);
|
||||
|
||||
for (int32_t j = 0; j < numOfTables; ++j) {
|
||||
STableBlockScanInfo info = {.lastKey = 0, .uid = idList[j].uid};
|
||||
STableBlockScanInfo* pScanInfo = getPosInBlockInfoBuf(&pTsdbReader->blockInfoBuf, j);
|
||||
pScanInfo->uid = idList[j].uid;
|
||||
if (ASCENDING_TRAVERSE(pTsdbReader->order)) {
|
||||
int64_t skey = pTsdbReader->window.skey;
|
||||
pScanInfo->lastKey = (skey > INT64_MIN) ? (skey - 1) : skey;
|
||||
} else {
|
||||
int64_t ekey = pTsdbReader->window.ekey;
|
||||
pScanInfo->lastKey = (ekey < INT64_MAX) ? (ekey + 1) : ekey;
|
||||
}
|
||||
|
||||
taosHashPut(pTableMap, &pScanInfo->uid, sizeof(uint64_t), &pScanInfo, POINTER_BYTES);
|
||||
|
||||
#if 0
|
||||
// STableBlockScanInfo info = {.lastKey = 0, .uid = idList[j].uid};
|
||||
if (ASCENDING_TRAVERSE(pTsdbReader->order)) {
|
||||
int64_t skey = pTsdbReader->window.skey;
|
||||
info.lastKey = (skey > INT64_MIN) ? (skey - 1) : skey;
|
||||
|
@ -245,28 +318,33 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableK
|
|||
}
|
||||
|
||||
taosHashPut(pTableMap, &info.uid, sizeof(uint64_t), &info, sizeof(info));
|
||||
tsdbDebug("%p check table uid:%" PRId64 " from lastKey:%" PRId64 " %s", pTsdbReader, info.uid, info.lastKey,
|
||||
#endif
|
||||
|
||||
tsdbTrace("%p check table uid:%" PRId64 " from lastKey:%" PRId64 " %s", pTsdbReader, pScanInfo->uid, pScanInfo->lastKey,
|
||||
pTsdbReader->idStr);
|
||||
}
|
||||
|
||||
tsdbDebug("%p create %d tables scan-info, size:%.2f Kb, %s", pTsdbReader, numOfTables,
|
||||
(sizeof(STableBlockScanInfo) * numOfTables) / 1024.0, pTsdbReader->idStr);
|
||||
pTsdbReader->cost.createScanInfoList = (taosGetTimestampUs() - st) / 1000.0;
|
||||
tsdbDebug("%p create %d tables scan-info, size:%.2f Kb, elapsed time:%.2f ms, %s", pTsdbReader, numOfTables,
|
||||
(sizeof(STableBlockScanInfo) * numOfTables) / 1024.0, pTsdbReader->cost.createScanInfoList,
|
||||
pTsdbReader->idStr);
|
||||
|
||||
return pTableMap;
|
||||
}
|
||||
|
||||
static void resetDataBlockScanInfo(SHashObj* pTableMap, int64_t ts) {
|
||||
STableBlockScanInfo* p = NULL;
|
||||
|
||||
static void resetAllDataBlockScanInfo(SHashObj* pTableMap, int64_t ts) {
|
||||
STableBlockScanInfo** p = NULL;
|
||||
while ((p = taosHashIterate(pTableMap, p)) != NULL) {
|
||||
p->iterInit = false;
|
||||
p->iiter.hasVal = false;
|
||||
if (p->iter.iter != NULL) {
|
||||
p->iter.iter = tsdbTbDataIterDestroy(p->iter.iter);
|
||||
STableBlockScanInfo* pInfo = *(STableBlockScanInfo**) p;
|
||||
|
||||
pInfo->iterInit = false;
|
||||
pInfo->iiter.hasVal = false;
|
||||
if (pInfo->iter.iter != NULL) {
|
||||
pInfo->iter.iter = tsdbTbDataIterDestroy(pInfo->iter.iter);
|
||||
}
|
||||
|
||||
p->delSkyline = taosArrayDestroy(p->delSkyline);
|
||||
p->lastKey = ts;
|
||||
pInfo->delSkyline = taosArrayDestroy(pInfo->delSkyline);
|
||||
pInfo->lastKey = ts;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,10 +365,10 @@ static void clearBlockScanInfo(STableBlockScanInfo* p) {
|
|||
tMapDataClear(&p->mapData);
|
||||
}
|
||||
|
||||
static void destroyBlockScanInfo(SHashObj* pTableMap) {
|
||||
STableBlockScanInfo* p = NULL;
|
||||
static void destroyAllBlockScanInfo(SHashObj* pTableMap) {
|
||||
void* p = NULL;
|
||||
while ((p = taosHashIterate(pTableMap, p)) != NULL) {
|
||||
clearBlockScanInfo(p);
|
||||
clearBlockScanInfo(*(STableBlockScanInfo**)p);
|
||||
}
|
||||
|
||||
taosHashCleanup(pTableMap);
|
||||
|
@ -495,7 +573,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
|
|||
pReader->verRange = getQueryVerRange(pVnode, pCond, level);
|
||||
pReader->type = pCond->type;
|
||||
pReader->window = updateQueryTimeWindow(pReader->pTsdb, &pCond->twindows);
|
||||
|
||||
pReader->blockInfoBuf.numPerBucket = 1000; // 1000 tables per bucket
|
||||
ASSERT(pCond->numOfCols > 0);
|
||||
|
||||
limitOutputBufferSize(pCond, &pReader->capacity);
|
||||
|
@ -566,9 +644,9 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFReader* pFileReader,
|
|||
continue;
|
||||
}
|
||||
|
||||
STableBlockScanInfo* pScanInfo = p;
|
||||
STableBlockScanInfo* pScanInfo = *(STableBlockScanInfo**)p;
|
||||
if (pScanInfo->pBlockList == NULL) {
|
||||
pScanInfo->pBlockList = taosArrayInit(4, sizeof(int32_t));
|
||||
pScanInfo->pBlockList = taosArrayInit(4, sizeof(SBlockIndex));
|
||||
}
|
||||
|
||||
taosArrayPush(pIndexList, pBlockIdx);
|
||||
|
@ -586,7 +664,7 @@ _end:
|
|||
}
|
||||
|
||||
static void cleanupTableScanInfo(SHashObj* pTableMap) {
|
||||
STableBlockScanInfo* px = NULL;
|
||||
STableBlockScanInfo** px = NULL;
|
||||
while (1) {
|
||||
px = taosHashIterate(pTableMap, px);
|
||||
if (px == NULL) {
|
||||
|
@ -594,8 +672,8 @@ static void cleanupTableScanInfo(SHashObj* pTableMap) {
|
|||
}
|
||||
|
||||
// reset the index in last block when handing a new file
|
||||
tMapDataClear(&px->mapData);
|
||||
taosArrayClear(px->pBlockList);
|
||||
tMapDataClear(&(*px)->mapData);
|
||||
taosArrayClear((*px)->pBlockList);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -610,7 +688,8 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN
|
|||
for (int32_t i = 0; i < numOfTables; ++i) {
|
||||
SBlockIdx* pBlockIdx = taosArrayGet(pIndexList, i);
|
||||
|
||||
STableBlockScanInfo* pScanInfo = taosHashGet(pReader->status.pTableMap, &pBlockIdx->uid, sizeof(int64_t));
|
||||
STableBlockScanInfo* pScanInfo =
|
||||
*(STableBlockScanInfo**)taosHashGet(pReader->status.pTableMap, &pBlockIdx->uid, sizeof(int64_t));
|
||||
|
||||
tMapDataReset(&pScanInfo->mapData);
|
||||
tsdbReadDataBlk(pReader->pFileReader, pBlockIdx, &pScanInfo->mapData);
|
||||
|
@ -630,7 +709,10 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN
|
|||
continue;
|
||||
}
|
||||
|
||||
void* p = taosArrayPush(pScanInfo->pBlockList, &j);
|
||||
SBlockIndex bIndex = {.ordinalIndex = j, .inFileOffset = block.aSubBlock->offset};
|
||||
bIndex.window = (STimeWindow) {.skey = block.minKey.ts, .ekey = block.maxKey.ts};
|
||||
|
||||
void* p = taosArrayPush(pScanInfo->pBlockList, &bIndex);
|
||||
if (p == NULL) {
|
||||
tMapDataClear(&pScanInfo->mapData);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -821,7 +903,8 @@ int32_t getEndPosInDataBlock(STsdbReader* pReader, SBlockData* pBlockData, SData
|
|||
} else if (!asc && pReader->window.skey <= pBlock->minKey.ts) {
|
||||
endPos = 0;
|
||||
} else {
|
||||
endPos = doBinarySearchKey(pBlockData->aTSKEY, pBlock->nRow, pos, pReader->window.ekey, pReader->order);
|
||||
int64_t key = asc ? pReader->window.ekey : pReader->window.skey;
|
||||
endPos = doBinarySearchKey(pBlockData->aTSKEY, pBlock->nRow, pos, key, pReader->order);
|
||||
}
|
||||
|
||||
return endPos;
|
||||
|
@ -852,8 +935,9 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
|||
// pDumpInfo->rowIndex = pBlock->nRow - 1;
|
||||
} else {
|
||||
int32_t pos = asc ? pBlock->nRow - 1 : 0;
|
||||
int32_t order = (pReader->order == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC;
|
||||
pDumpInfo->rowIndex = doBinarySearchKey(pBlockData->aTSKEY, pBlock->nRow, pos, pReader->window.skey, order);
|
||||
int32_t order = asc ? TSDB_ORDER_DESC : TSDB_ORDER_ASC;
|
||||
int64_t key = asc ? pReader->window.skey : pReader->window.ekey;
|
||||
pDumpInfo->rowIndex = doBinarySearchKey(pBlockData->aTSKEY, pBlock->nRow, pos, key, order);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1053,14 +1137,14 @@ static int32_t fileDataBlockOrderCompar(const void* pLeft, const void* pRight, v
|
|||
static int32_t doSetCurrentBlock(SDataBlockIter* pBlockIter, const char* idStr) {
|
||||
SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(pBlockIter);
|
||||
if (pBlockInfo != NULL) {
|
||||
STableBlockScanInfo* pScanInfo = taosHashGet(pBlockIter->pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid));
|
||||
STableBlockScanInfo** pScanInfo = taosHashGet(pBlockIter->pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid));
|
||||
if (pScanInfo == NULL) {
|
||||
tsdbError("failed to locate the uid:%" PRIu64 " in query table uid list, %s", pBlockInfo->uid, idStr);
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
int32_t* mapDataIndex = taosArrayGet(pScanInfo->pBlockList, pBlockInfo->tbBlockIdx);
|
||||
tMapDataGetItemByIdx(&pScanInfo->mapData, *mapDataIndex, &pBlockIter->block, tGetDataBlk);
|
||||
SBlockIndex* pIndex = taosArrayGet((*pScanInfo)->pBlockList, pBlockInfo->tbBlockIdx);
|
||||
tMapDataGetItemByIdx(&(*pScanInfo)->mapData, pIndex->ordinalIndex, &pBlockIter->block, tGetDataBlk);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -1073,6 +1157,7 @@ static int32_t doSetCurrentBlock(SDataBlockIter* pBlockIter, const char* idStr)
|
|||
static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIter, int32_t numOfBlocks) {
|
||||
bool asc = ASCENDING_TRAVERSE(pReader->order);
|
||||
|
||||
SBlockOrderSupporter sup = {0};
|
||||
pBlockIter->numOfBlocks = numOfBlocks;
|
||||
taosArrayClear(pBlockIter->blockList);
|
||||
pBlockIter->pTableMap = pReader->status.pTableMap;
|
||||
|
@ -1081,9 +1166,7 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
|
|||
int32_t numOfTables = (int32_t)taosHashGetSize(pReader->status.pTableMap);
|
||||
|
||||
int64_t st = taosGetTimestampUs();
|
||||
|
||||
SBlockOrderSupporter sup = {0};
|
||||
int32_t code = initBlockOrderSupporter(&sup, numOfTables);
|
||||
int32_t code = initBlockOrderSupporter(&sup, numOfTables);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1096,7 +1179,7 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
|
|||
break;
|
||||
}
|
||||
|
||||
STableBlockScanInfo* pTableScanInfo = (STableBlockScanInfo*)ptr;
|
||||
STableBlockScanInfo* pTableScanInfo = *(STableBlockScanInfo**)ptr;
|
||||
if (pTableScanInfo->pBlockList == NULL || taosArrayGetSize(pTableScanInfo->pBlockList) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1111,17 +1194,11 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
|
|||
}
|
||||
|
||||
sup.pDataBlockInfo[sup.numOfTables] = (SBlockOrderWrapper*)buf;
|
||||
SDataBlk block = {0};
|
||||
|
||||
for (int32_t k = 0; k < num; ++k) {
|
||||
SBlockOrderWrapper wrapper = {0};
|
||||
|
||||
int32_t* mapDataIndex = taosArrayGet(pTableScanInfo->pBlockList, k);
|
||||
tMapDataGetItemByIdx(&pTableScanInfo->mapData, *mapDataIndex, &block, tGetDataBlk);
|
||||
|
||||
wrapper.uid = pTableScanInfo->uid;
|
||||
wrapper.offset = block.aSubBlock[0].offset;
|
||||
|
||||
sup.pDataBlockInfo[sup.numOfTables][k] = wrapper;
|
||||
SBlockIndex* pIndex = taosArrayGet(pTableScanInfo->pBlockList, k);
|
||||
sup.pDataBlockInfo[sup.numOfTables][k] =
|
||||
(SBlockOrderWrapper){.uid = pTableScanInfo->uid, .offset = pIndex->inFileOffset};
|
||||
cnt++;
|
||||
}
|
||||
|
||||
|
@ -1212,25 +1289,22 @@ static int32_t dataBlockPartiallyRequired(STimeWindow* pWindow, SVersionRange* p
|
|||
(pVerRange->maxVer < pBlock->maxVer && pVerRange->maxVer >= pBlock->minVer);
|
||||
}
|
||||
|
||||
static SDataBlk* getNeighborBlockOfSameTable(SFileDataBlockInfo* pBlockInfo, STableBlockScanInfo* pTableBlockScanInfo,
|
||||
int32_t* nextIndex, int32_t order) {
|
||||
static bool getNeighborBlockOfSameTable(SFileDataBlockInfo* pBlockInfo, STableBlockScanInfo* pTableBlockScanInfo,
|
||||
int32_t* nextIndex, int32_t order, SBlockIndex* pBlockIndex) {
|
||||
bool asc = ASCENDING_TRAVERSE(order);
|
||||
if (asc && pBlockInfo->tbBlockIdx >= taosArrayGetSize(pTableBlockScanInfo->pBlockList) - 1) {
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!asc && pBlockInfo->tbBlockIdx == 0) {
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t step = asc ? 1 : -1;
|
||||
*nextIndex = pBlockInfo->tbBlockIdx + step;
|
||||
|
||||
SDataBlk* pBlock = taosMemoryCalloc(1, sizeof(SDataBlk));
|
||||
int32_t* indexInMapdata = taosArrayGet(pTableBlockScanInfo->pBlockList, *nextIndex);
|
||||
|
||||
tMapDataGetItemByIdx(&pTableBlockScanInfo->mapData, *indexInMapdata, pBlock, tGetDataBlk);
|
||||
return pBlock;
|
||||
*pBlockIndex = *(SBlockIndex*) taosArrayGet(pTableBlockScanInfo->pBlockList, *nextIndex);
|
||||
// tMapDataGetItemByIdx(&pTableBlockScanInfo->mapData, pIndex->ordinalIndex, pBlock, tGetDataBlk);
|
||||
return true;
|
||||
}
|
||||
|
||||
static int32_t findFileBlockInfoIndex(SDataBlockIter* pBlockIter, SFileDataBlockInfo* pFBlockInfo) {
|
||||
|
@ -1272,12 +1346,12 @@ static int32_t setFileBlockActiveInBlockIter(SDataBlockIter* pBlockIter, int32_t
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static bool overlapWithNeighborBlock(SDataBlk* pBlock, SDataBlk* pNeighbor, int32_t order) {
|
||||
static bool overlapWithNeighborBlock(SDataBlk* pBlock, SBlockIndex* pNeighborBlockIndex, int32_t order) {
|
||||
// it is the last block in current file, no chance to overlap with neighbor blocks.
|
||||
if (ASCENDING_TRAVERSE(order)) {
|
||||
return pBlock->maxKey.ts == pNeighbor->minKey.ts;
|
||||
return pBlock->maxKey.ts == pNeighborBlockIndex->window.skey;
|
||||
} else {
|
||||
return pBlock->minKey.ts == pNeighbor->maxKey.ts;
|
||||
return pBlock->minKey.ts == pNeighborBlockIndex->window.ekey;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1293,10 +1367,10 @@ static bool keyOverlapFileBlock(TSDBKEY key, SDataBlk* pBlock, SVersionRange* pV
|
|||
(pBlock->minVer <= pVerRange->maxVer);
|
||||
}
|
||||
|
||||
static bool doCheckforDatablockOverlap(STableBlockScanInfo* pBlockScanInfo, const SDataBlk* pBlock) {
|
||||
static bool doCheckforDatablockOverlap(STableBlockScanInfo* pBlockScanInfo, const SDataBlk* pBlock, int32_t startIndex) {
|
||||
size_t num = taosArrayGetSize(pBlockScanInfo->delSkyline);
|
||||
|
||||
for (int32_t i = pBlockScanInfo->fileDelIndex; i < num; i += 1) {
|
||||
for (int32_t i = startIndex; i < num; i += 1) {
|
||||
TSDBKEY* p = taosArrayGet(pBlockScanInfo->delSkyline, i);
|
||||
if (p->ts >= pBlock->minKey.ts && p->ts <= pBlock->maxKey.ts) {
|
||||
if (p->version >= pBlock->minVer) {
|
||||
|
@ -1335,7 +1409,7 @@ static bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SDa
|
|||
|
||||
// version is not overlap
|
||||
if (ASCENDING_TRAVERSE(order)) {
|
||||
return doCheckforDatablockOverlap(pBlockScanInfo, pBlock);
|
||||
return doCheckforDatablockOverlap(pBlockScanInfo, pBlock, pBlockScanInfo->fileDelIndex);
|
||||
} else {
|
||||
int32_t index = pBlockScanInfo->fileDelIndex;
|
||||
while (1) {
|
||||
|
@ -1347,7 +1421,7 @@ static bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SDa
|
|||
}
|
||||
}
|
||||
|
||||
return doCheckforDatablockOverlap(pBlockScanInfo, pBlock);
|
||||
return doCheckforDatablockOverlap(pBlockScanInfo, pBlock, index);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1364,13 +1438,14 @@ typedef struct {
|
|||
static void getBlockToLoadInfo(SDataBlockToLoadInfo* pInfo, SFileDataBlockInfo* pBlockInfo, SDataBlk* pBlock,
|
||||
STableBlockScanInfo* pScanInfo, TSDBKEY keyInBuf, SLastBlockReader* pLastBlockReader,
|
||||
STsdbReader* pReader) {
|
||||
int32_t neighborIndex = 0;
|
||||
SDataBlk* pNeighbor = getNeighborBlockOfSameTable(pBlockInfo, pScanInfo, &neighborIndex, pReader->order);
|
||||
int32_t neighborIndex = 0;
|
||||
SBlockIndex bIndex = {0};
|
||||
|
||||
bool hasNeighbor = getNeighborBlockOfSameTable(pBlockInfo, pScanInfo, &neighborIndex, pReader->order, &bIndex);
|
||||
|
||||
// overlap with neighbor
|
||||
if (pNeighbor) {
|
||||
pInfo->overlapWithNeighborBlock = overlapWithNeighborBlock(pBlock, pNeighbor, pReader->order);
|
||||
taosMemoryFree(pNeighbor);
|
||||
if (hasNeighbor) {
|
||||
pInfo->overlapWithNeighborBlock = overlapWithNeighborBlock(pBlock, &bIndex, pReader->order);
|
||||
}
|
||||
|
||||
// has duplicated ts of different version in this block
|
||||
|
@ -2111,7 +2186,7 @@ static bool isValidFileBlockRow(SBlockData* pBlockData, SFileBlockDumpInfo* pDum
|
|||
static bool initLastBlockReader(SLastBlockReader* pLBlockReader, STableBlockScanInfo* pScanInfo, STsdbReader* pReader) {
|
||||
// the last block reader has been initialized for this table.
|
||||
if (pLBlockReader->uid == pScanInfo->uid) {
|
||||
return true;
|
||||
return hasDataInLastBlock(pLBlockReader);
|
||||
}
|
||||
|
||||
if (pLBlockReader->uid != 0) {
|
||||
|
@ -2228,7 +2303,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
|||
|
||||
STableBlockScanInfo* pBlockScanInfo = NULL;
|
||||
if (pBlockInfo != NULL) {
|
||||
pBlockScanInfo = taosHashGet(pReader->status.pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid));
|
||||
pBlockScanInfo = *(STableBlockScanInfo**)taosHashGet(pReader->status.pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid));
|
||||
if (pBlockScanInfo == NULL) {
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
tsdbError("failed to locate the uid:%" PRIu64 " in query table uid list, total tables:%d, %s", pBlockInfo->uid,
|
||||
|
@ -2244,11 +2319,14 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
|||
if (pReader->order == TSDB_ORDER_ASC ||
|
||||
(pReader->order == TSDB_ORDER_DESC && (!hasDataInLastBlock(pLastBlockReader)))) {
|
||||
copyBlockDataToSDataBlock(pReader, pBlockScanInfo);
|
||||
|
||||
// record the last key value
|
||||
pBlockScanInfo->lastKey = ASCENDING_TRAVERSE(pReader->order)? pBlock->maxKey.ts:pBlock->minKey.ts;
|
||||
goto _end;
|
||||
}
|
||||
}
|
||||
} else { // file blocks not exist
|
||||
pBlockScanInfo = pReader->status.pTableIter;
|
||||
pBlockScanInfo = *pReader->status.pTableIter;
|
||||
}
|
||||
|
||||
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
|
||||
|
@ -2473,7 +2551,7 @@ static void extractOrderedTableUidList(SUidOrderCheckInfo* pOrderCheckInfo, SRea
|
|||
|
||||
void* p = taosHashIterate(pStatus->pTableMap, NULL);
|
||||
while (p != NULL) {
|
||||
STableBlockScanInfo* pScanInfo = p;
|
||||
STableBlockScanInfo* pScanInfo = *(STableBlockScanInfo**) p;
|
||||
pOrderCheckInfo->tableUidList[index++] = pScanInfo->uid;
|
||||
p = taosHashIterate(pStatus->pTableMap, p);
|
||||
}
|
||||
|
@ -2547,7 +2625,7 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
|
|||
|
||||
while (1) {
|
||||
// load the last data block of current table
|
||||
STableBlockScanInfo* pScanInfo = pStatus->pTableIter;
|
||||
STableBlockScanInfo* pScanInfo = *(STableBlockScanInfo**) pStatus->pTableIter;
|
||||
bool hasVal = initLastBlockReader(pLastBlockReader, pScanInfo, pReader);
|
||||
if (!hasVal) {
|
||||
bool hasNexTable = moveToNextTable(pOrderedCheckInfo, pStatus);
|
||||
|
@ -2585,9 +2663,9 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
|
|||
SLastBlockReader* pLastBlockReader = pReader->status.fileIter.pLastBlockReader;
|
||||
|
||||
if (pBlockInfo != NULL) {
|
||||
pScanInfo = taosHashGet(pReader->status.pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid));
|
||||
pScanInfo = *(STableBlockScanInfo**)taosHashGet(pReader->status.pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid));
|
||||
} else {
|
||||
pScanInfo = pReader->status.pTableIter;
|
||||
pScanInfo = *pReader->status.pTableIter;
|
||||
}
|
||||
|
||||
if (pScanInfo == NULL) {
|
||||
|
@ -2635,6 +2713,9 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
|
|||
pInfo->window = (STimeWindow){.skey = pBlock->minKey.ts, .ekey = pBlock->maxKey.ts};
|
||||
setComposedBlockFlag(pReader, false);
|
||||
setBlockAllDumped(&pStatus->fBlockDumpInfo, pBlock->maxKey.ts, pReader->order);
|
||||
|
||||
// update the last key for the corresponding table
|
||||
pScanInfo->lastKey = ASCENDING_TRAVERSE(pReader->order)? pInfo->window.ekey:pInfo->window.skey;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2652,11 +2733,11 @@ static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) {
|
|||
}
|
||||
}
|
||||
|
||||
STableBlockScanInfo* pBlockScanInfo = pStatus->pTableIter;
|
||||
initMemDataIterator(pBlockScanInfo, pReader);
|
||||
STableBlockScanInfo** pBlockScanInfo = pStatus->pTableIter;
|
||||
initMemDataIterator(*pBlockScanInfo, pReader);
|
||||
|
||||
int64_t endKey = (ASCENDING_TRAVERSE(pReader->order)) ? INT64_MAX : INT64_MIN;
|
||||
int32_t code = buildDataBlockFromBuf(pReader, pBlockScanInfo, endKey);
|
||||
int32_t code = buildDataBlockFromBuf(pReader, *pBlockScanInfo, endKey);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
@ -3067,15 +3148,15 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn
|
|||
*state = CHECK_FILEBLOCK_QUIT;
|
||||
int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1;
|
||||
|
||||
int32_t nextIndex = -1;
|
||||
SDataBlk* pNeighborBlock = getNeighborBlockOfSameTable(pFBlock, pScanInfo, &nextIndex, pReader->order);
|
||||
if (pNeighborBlock == NULL) { // do nothing
|
||||
int32_t nextIndex = -1;
|
||||
SBlockIndex bIndex = {0};
|
||||
|
||||
bool hasNeighbor = getNeighborBlockOfSameTable(pFBlock, pScanInfo, &nextIndex, pReader->order, &bIndex);
|
||||
if (!hasNeighbor) { // do nothing
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool overlap = overlapWithNeighborBlock(pBlock, pNeighborBlock, pReader->order);
|
||||
taosMemoryFree(pNeighborBlock);
|
||||
|
||||
bool overlap = overlapWithNeighborBlock(pBlock, &bIndex, pReader->order);
|
||||
if (overlap) { // load next block
|
||||
SReaderStatus* pStatus = &pReader->status;
|
||||
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
||||
|
@ -3458,18 +3539,23 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e
|
|||
// TODO refactor: with createDataBlockScanInfo
|
||||
int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t num) {
|
||||
ASSERT(pReader != NULL);
|
||||
int32_t size = taosHashGetSize(pReader->status.pTableMap);
|
||||
|
||||
STableBlockScanInfo* p = NULL;
|
||||
STableBlockScanInfo** p = NULL;
|
||||
while ((p = taosHashIterate(pReader->status.pTableMap, p)) != NULL) {
|
||||
clearBlockScanInfo(p);
|
||||
clearBlockScanInfo(*p);
|
||||
}
|
||||
|
||||
// todo handle the case where size is less than the value of num
|
||||
ASSERT(size >= num);
|
||||
|
||||
taosHashClear(pReader->status.pTableMap);
|
||||
|
||||
STableKeyInfo* pList = (STableKeyInfo*) pTableList;
|
||||
for(int32_t i = 0; i < num; ++i) {
|
||||
STableBlockScanInfo info = {.lastKey = 0, .uid = pList[i].uid};
|
||||
taosHashPut(pReader->status.pTableMap, &info.uid, sizeof(uint64_t), &info, sizeof(info));
|
||||
STableBlockScanInfo* pInfo = getPosInBlockInfoBuf(&pReader->blockInfoBuf, i);
|
||||
pInfo->uid = pList[i].uid;
|
||||
taosHashPut(pReader->status.pTableMap, &pInfo->uid, sizeof(uint64_t), &pInfo, POINTER_BYTES);
|
||||
}
|
||||
|
||||
return TDB_CODE_SUCCESS;
|
||||
|
@ -3496,7 +3582,6 @@ static int32_t doOpenReaderImpl(STsdbReader* pReader) {
|
|||
|
||||
initFilesetIterator(&pReader->status.fileIter, pReader->pReadSnap->fs.aDFileSet, pReader);
|
||||
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
||||
// resetDataBlockScanInfo(pReader->status.pTableMap, pReader->window.skey);
|
||||
|
||||
// no data in files, let's try buffer in memory
|
||||
if (pReader->status.fileIter.numOfFiles == 0) {
|
||||
|
@ -3674,8 +3759,9 @@ void tsdbReaderClose(STsdbReader* pReader) {
|
|||
cleanupDataBlockIterator(&pReader->status.blockIter);
|
||||
|
||||
size_t numOfTables = taosHashGetSize(pReader->status.pTableMap);
|
||||
destroyBlockScanInfo(pReader->status.pTableMap);
|
||||
destroyAllBlockScanInfo(pReader->status.pTableMap);
|
||||
blockDataDestroy(pReader->pResBlock);
|
||||
clearBlockScanInfoBuf(&pReader->blockInfoBuf);
|
||||
|
||||
if (pReader->pFileReader != NULL) {
|
||||
tsdbDataFReaderClose(&pReader->pFileReader);
|
||||
|
@ -3697,15 +3783,16 @@ void tsdbReaderClose(STsdbReader* pReader) {
|
|||
taosMemoryFree(pLReader);
|
||||
}
|
||||
|
||||
tsdbDebug(
|
||||
"%p :io-cost summary: head-file:%" PRIu64 ", head-file time:%.2f ms, SMA:%" PRId64
|
||||
" SMA-time:%.2f ms, fileBlocks:%" PRId64
|
||||
", fileBlocks-load-time:%.2f ms, "
|
||||
"build in-memory-block-time:%.2f ms, lastBlocks:%" PRId64 ", lastBlocks-time:%.2f ms, composed-blocks:%" PRId64
|
||||
", composed-blocks-time:%.2fms, STableBlockScanInfo size:%.2f Kb %s",
|
||||
pReader, pCost->headFileLoad, pCost->headFileLoadTime, pCost->smaDataLoad, pCost->smaLoadTime, pCost->numOfBlocks,
|
||||
pCost->blockLoadTime, pCost->buildmemBlock, pCost->lastBlockLoad, pCost->lastBlockLoadTime, pCost->composedBlocks,
|
||||
pCost->buildComposedBlockTime, numOfTables * sizeof(STableBlockScanInfo) / 1000.0, pReader->idStr);
|
||||
tsdbDebug("%p :io-cost summary: head-file:%" PRIu64 ", head-file time:%.2f ms, SMA:%" PRId64
|
||||
" SMA-time:%.2f ms, fileBlocks:%" PRId64
|
||||
", fileBlocks-load-time:%.2f ms, "
|
||||
"build in-memory-block-time:%.2f ms, lastBlocks:%" PRId64
|
||||
", lastBlocks-time:%.2f ms, composed-blocks:%" PRId64
|
||||
", composed-blocks-time:%.2fms, STableBlockScanInfo size:%.2f Kb, creatTime:%.2f ms, %s",
|
||||
pReader, pCost->headFileLoad, pCost->headFileLoadTime, pCost->smaDataLoad, pCost->smaLoadTime,
|
||||
pCost->numOfBlocks, pCost->blockLoadTime, pCost->buildmemBlock, pCost->lastBlockLoad,
|
||||
pCost->lastBlockLoadTime, pCost->composedBlocks, pCost->buildComposedBlockTime,
|
||||
numOfTables * sizeof(STableBlockScanInfo) / 1000.0, pCost->createScanInfoList, pReader->idStr);
|
||||
|
||||
taosMemoryFree(pReader->idStr);
|
||||
taosMemoryFree(pReader->pSchema);
|
||||
|
@ -3758,7 +3845,7 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
|
|||
if (pReader->step == EXTERNAL_ROWS_PREV) {
|
||||
// prepare for the main scan
|
||||
int32_t code = doOpenReaderImpl(pReader);
|
||||
resetDataBlockScanInfo(pReader->status.pTableMap, pReader->innerReader[0]->window.ekey);
|
||||
resetAllDataBlockScanInfo(pReader->status.pTableMap, pReader->innerReader[0]->window.ekey);
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
|
@ -3775,7 +3862,7 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
|
|||
if (pReader->innerReader[1] != NULL && pReader->step == EXTERNAL_ROWS_MAIN) {
|
||||
// prepare for the next row scan
|
||||
int32_t code = doOpenReaderImpl(pReader->innerReader[1]);
|
||||
resetDataBlockScanInfo(pReader->innerReader[1]->status.pTableMap, pReader->window.ekey);
|
||||
resetAllDataBlockScanInfo(pReader->innerReader[1]->status.pTableMap, pReader->window.ekey);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
@ -3791,7 +3878,7 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
|
|||
}
|
||||
|
||||
bool tsdbTableNextDataBlock(STsdbReader* pReader, uint64_t uid) {
|
||||
STableBlockScanInfo* pBlockScanInfo = taosHashGet(pReader->status.pTableMap, &uid, sizeof(uid));
|
||||
STableBlockScanInfo* pBlockScanInfo = *(STableBlockScanInfo**)taosHashGet(pReader->status.pTableMap, &uid, sizeof(uid));
|
||||
if (pBlockScanInfo == NULL) { // no data block for the table of given uid
|
||||
return false;
|
||||
}
|
||||
|
@ -3799,24 +3886,24 @@ bool tsdbTableNextDataBlock(STsdbReader* pReader, uint64_t uid) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static void setBlockInfo(STsdbReader* pReader, SDataBlockInfo* pDataBlockInfo) {
|
||||
ASSERT(pDataBlockInfo != NULL && pReader != NULL);
|
||||
pDataBlockInfo->rows = pReader->pResBlock->info.rows;
|
||||
pDataBlockInfo->uid = pReader->pResBlock->info.uid;
|
||||
pDataBlockInfo->window = pReader->pResBlock->info.window;
|
||||
static void setBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64_t* uid, STimeWindow* pWindow) {
|
||||
ASSERT(pReader != NULL);
|
||||
*rows = pReader->pResBlock->info.rows;
|
||||
*uid = pReader->pResBlock->info.uid;
|
||||
*pWindow = pReader->pResBlock->info.window;
|
||||
}
|
||||
|
||||
void tsdbRetrieveDataBlockInfo(STsdbReader* pReader, SDataBlockInfo* pDataBlockInfo) {
|
||||
void tsdbRetrieveDataBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64_t* uid, STimeWindow* pWindow) {
|
||||
if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) {
|
||||
if (pReader->step == EXTERNAL_ROWS_MAIN) {
|
||||
setBlockInfo(pReader, pDataBlockInfo);
|
||||
setBlockInfo(pReader, rows, uid, pWindow);
|
||||
} else if (pReader->step == EXTERNAL_ROWS_PREV) {
|
||||
setBlockInfo(pReader->innerReader[0], pDataBlockInfo);
|
||||
setBlockInfo(pReader->innerReader[0], rows, uid, pWindow);
|
||||
} else {
|
||||
setBlockInfo(pReader->innerReader[1], pDataBlockInfo);
|
||||
setBlockInfo(pReader->innerReader[1], rows, uid, pWindow);
|
||||
}
|
||||
} else {
|
||||
setBlockInfo(pReader, pDataBlockInfo);
|
||||
setBlockInfo(pReader, rows, uid, pWindow);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3838,7 +3925,7 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockS
|
|||
SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pReader->status.blockIter);
|
||||
|
||||
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
||||
int64_t stime = taosGetTimestampUs();
|
||||
// int64_t stime = taosGetTimestampUs();
|
||||
|
||||
SBlockLoadSuppInfo* pSup = &pReader->suppInfo;
|
||||
|
||||
|
@ -3869,7 +3956,9 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockS
|
|||
size_t numOfCols = blockDataGetNumOfCols(pReader->pResBlock);
|
||||
|
||||
int32_t i = 0, j = 0;
|
||||
while (j < numOfCols && i < taosArrayGetSize(pSup->pColAgg)) {
|
||||
size_t size = taosArrayGetSize(pSup->pColAgg);
|
||||
|
||||
while (j < numOfCols && i < size) {
|
||||
SColumnDataAgg* pAgg = taosArrayGet(pSup->pColAgg, i);
|
||||
if (pAgg->colId == pSup->colIds[j]) {
|
||||
if (IS_BSMA_ON(&(pReader->pSchema->columns[i]))) {
|
||||
|
@ -3886,14 +3975,10 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockS
|
|||
}
|
||||
}
|
||||
|
||||
double elapsed = (taosGetTimestampUs() - stime) / 1000.0;
|
||||
pReader->cost.smaLoadTime += elapsed;
|
||||
pReader->cost.smaDataLoad += 1;
|
||||
|
||||
*pBlockStatis = pSup->plist;
|
||||
|
||||
tsdbDebug("vgId:%d, succeed to load block SMA for uid %" PRIu64 ", elapsed time:%.2f ms, %s", 0, pFBlock->uid,
|
||||
elapsed, pReader->idStr);
|
||||
tsdbDebug("vgId:%d, succeed to load block SMA for uid %" PRIu64 ", %s", 0, pFBlock->uid, pReader->idStr);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -3906,7 +3991,7 @@ static SArray* doRetrieveDataBlock(STsdbReader* pReader) {
|
|||
}
|
||||
|
||||
SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(&pStatus->blockIter);
|
||||
STableBlockScanInfo* pBlockScanInfo = taosHashGet(pStatus->pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid));
|
||||
STableBlockScanInfo* pBlockScanInfo = *(STableBlockScanInfo**)taosHashGet(pStatus->pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid));
|
||||
if (pBlockScanInfo == NULL) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
tsdbError("failed to locate the uid:%" PRIu64 " in query table uid list, total tables:%d, %s", pBlockInfo->uid,
|
||||
|
@ -3942,6 +4027,8 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SDataBlockIter* pBlockIter = &pReader->status.blockIter;
|
||||
|
||||
pReader->order = pCond->order;
|
||||
pReader->type = TIMEWINDOW_RANGE_CONTAINED;
|
||||
pReader->status.loadFromFile = true;
|
||||
|
@ -3958,13 +4045,12 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
|
|||
int32_t numOfTables = taosHashGetSize(pReader->status.pTableMap);
|
||||
|
||||
initFilesetIterator(&pReader->status.fileIter, pReader->pReadSnap->fs.aDFileSet, pReader);
|
||||
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
||||
resetDataBlockIterator(pBlockIter, pReader->order);
|
||||
|
||||
int64_t ts = ASCENDING_TRAVERSE(pReader->order) ? pReader->window.skey - 1 : pReader->window.ekey + 1;
|
||||
resetDataBlockScanInfo(pReader->status.pTableMap, ts);
|
||||
resetAllDataBlockScanInfo(pReader->status.pTableMap, ts);
|
||||
|
||||
int32_t code = 0;
|
||||
SDataBlockIter* pBlockIter = &pReader->status.blockIter;
|
||||
int32_t code = 0;
|
||||
|
||||
// no data in files, let's try buffer in memory
|
||||
if (pReader->status.fileIter.numOfFiles == 0) {
|
||||
|
@ -4066,7 +4152,7 @@ int64_t tsdbGetNumOfRowsInMemTable(STsdbReader* pReader) {
|
|||
pStatus->pTableIter = taosHashIterate(pStatus->pTableMap, NULL);
|
||||
|
||||
while (pStatus->pTableIter != NULL) {
|
||||
STableBlockScanInfo* pBlockScanInfo = pStatus->pTableIter;
|
||||
STableBlockScanInfo* pBlockScanInfo = *(STableBlockScanInfo**)pStatus->pTableIter;
|
||||
|
||||
STbData* d = NULL;
|
||||
if (pReader->pTsdb->mem != NULL) {
|
||||
|
|
|
@ -212,6 +212,12 @@ int vnodeCommit(SVnode *pVnode) {
|
|||
vInfo("vgId:%d, start to commit, commit ID:%" PRId64 " version:%" PRId64, TD_VID(pVnode), pVnode->state.commitID,
|
||||
pVnode->state.applied);
|
||||
|
||||
// persist wal before starting
|
||||
if (walPersist(pVnode->pWal) < 0) {
|
||||
vError("vgId:%d, failed to persist wal since %s", TD_VID(pVnode), terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
pVnode->state.commitTerm = pVnode->state.applyTerm;
|
||||
|
||||
// save info
|
||||
|
|
|
@ -245,6 +245,7 @@ _err:
|
|||
void vnodePreClose(SVnode *pVnode) {
|
||||
if (pVnode) {
|
||||
syncLeaderTransfer(pVnode->sync);
|
||||
syncPreStop(pVnode->sync);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
for (int32_t i = 0; i < msgNum; ++i) {
|
||||
if (offset >= pMsg->contLen) {
|
||||
qError("vnode offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
taosArrayDestroy(batchRsp);
|
||||
return -1;
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
|
||||
if (offset >= pMsg->contLen) {
|
||||
qError("vnode offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
taosArrayDestroy(batchRsp);
|
||||
return -1;
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
|
||||
if (offset >= pMsg->contLen) {
|
||||
qError("vnode offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
taosArrayDestroy(batchRsp);
|
||||
return -1;
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
|
||||
if (offset >= pMsg->contLen) {
|
||||
qError("vnode offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
taosArrayDestroy(batchRsp);
|
||||
return -1;
|
||||
}
|
||||
|
@ -362,6 +362,7 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
offset = 0;
|
||||
|
||||
if (rspSize > MAX_META_BATCH_RSP_SIZE) {
|
||||
qError("rspSize:%d overload", rspSize);
|
||||
code = TSDB_CODE_INVALID_MSG_LEN;
|
||||
goto _exit;
|
||||
}
|
||||
|
@ -414,9 +415,11 @@ _exit:
|
|||
}
|
||||
|
||||
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
|
||||
SSyncState state = syncGetState(pVnode->sync);
|
||||
|
||||
pLoad->vgId = TD_VID(pVnode);
|
||||
pLoad->syncState = syncGetMyRole(pVnode->sync);
|
||||
pLoad->syncRestore = pVnode->restored;
|
||||
pLoad->syncState = state.state;
|
||||
pLoad->syncRestore = state.restored;
|
||||
pLoad->cacheUsage = tsdbCacheGetUsage(pVnode);
|
||||
pLoad->numOfTables = metaGetTbNum(pVnode->pMeta);
|
||||
pLoad->numOfTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta);
|
||||
|
|
|
@ -173,7 +173,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
|||
int32_t ret;
|
||||
|
||||
if (!pVnode->inUse) {
|
||||
terrno = TSDB_CODE_VND_NOT_SYNCED;
|
||||
terrno = TSDB_CODE_VND_NO_AVAIL_BUFPOOL;
|
||||
vError("vgId:%d, not ready to write since %s", TD_VID(pVnode), terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
@ -228,38 +228,33 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
|||
if (vnodeProcessBatchDeleteReq(pVnode, version, pReq, len, pRsp) < 0) goto _err;
|
||||
break;
|
||||
/* TQ */
|
||||
case TDMT_VND_MQ_VG_CHANGE:
|
||||
if (tqProcessVgChangeReq(pVnode->pTq, version, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)),
|
||||
pMsg->contLen - sizeof(SMsgHead)) < 0) {
|
||||
case TDMT_VND_TMQ_SUBSCRIBE:
|
||||
if (tqProcessSubscribeReq(pVnode->pTq, version, pReq, len) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
break;
|
||||
case TDMT_VND_MQ_VG_DELETE:
|
||||
if (tqProcessVgDeleteReq(pVnode->pTq, version, pMsg->pCont, pMsg->contLen) < 0) {
|
||||
case TDMT_VND_TMQ_DELETE_SUB:
|
||||
if (tqProcessDeleteSubReq(pVnode->pTq, version, pMsg->pCont, pMsg->contLen) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
break;
|
||||
case TDMT_VND_MQ_COMMIT_OFFSET:
|
||||
if (tqProcessOffsetCommitReq(pVnode->pTq, version, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)),
|
||||
pMsg->contLen - sizeof(SMsgHead)) < 0) {
|
||||
case TDMT_VND_TMQ_COMMIT_OFFSET:
|
||||
if (tqProcessOffsetCommitReq(pVnode->pTq, version, pReq, pMsg->contLen - sizeof(SMsgHead)) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
break;
|
||||
case TDMT_VND_ADD_CHECK_INFO:
|
||||
if (tqProcessAddCheckInfoReq(pVnode->pTq, version, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)),
|
||||
pMsg->contLen - sizeof(SMsgHead)) < 0) {
|
||||
case TDMT_VND_TMQ_ADD_CHECKINFO:
|
||||
if (tqProcessAddCheckInfoReq(pVnode->pTq, version, pReq, len) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
break;
|
||||
case TDMT_VND_DELETE_CHECK_INFO:
|
||||
if (tqProcessDelCheckInfoReq(pVnode->pTq, version, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)),
|
||||
pMsg->contLen - sizeof(SMsgHead)) < 0) {
|
||||
case TDMT_VND_TMQ_DEL_CHECKINFO:
|
||||
if (tqProcessDelCheckInfoReq(pVnode->pTq, version, pReq, len) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
break;
|
||||
case TDMT_STREAM_TASK_DEPLOY: {
|
||||
if (tqProcessTaskDeployReq(pVnode->pTq, version, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)),
|
||||
pMsg->contLen - sizeof(SMsgHead)) < 0) {
|
||||
if (tqProcessTaskDeployReq(pVnode->pTq, version, pReq, len) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
} break;
|
||||
|
@ -268,6 +263,16 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
|||
goto _err;
|
||||
}
|
||||
} break;
|
||||
case TDMT_VND_STREAM_RECOVER_STEP2: {
|
||||
if (tqProcessTaskRecover2Req(pVnode->pTq, version, pMsg->pCont, pMsg->contLen) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
} break;
|
||||
case TDMT_STREAM_TASK_CHECK_RSP: {
|
||||
if (tqProcessStreamTaskCheckRsp(pVnode->pTq, version, pReq, len) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
} break;
|
||||
case TDMT_VND_ALTER_CONFIRM:
|
||||
vnodeProcessAlterConfirmReq(pVnode, version, pReq, len, pRsp);
|
||||
break;
|
||||
|
@ -280,11 +285,12 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
|||
case TDMT_VND_COMMIT:
|
||||
goto _do_commit;
|
||||
default:
|
||||
ASSERT(0);
|
||||
break;
|
||||
vError("vgId:%d, unprocessed msg, %d", TD_VID(pVnode), pMsg->msgType);
|
||||
return -1;
|
||||
}
|
||||
|
||||
vTrace("vgId:%d, process %s request success, index:%" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType), version);
|
||||
vTrace("vgId:%d, process %s request, code:0x%x index:%" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType), pRsp->code,
|
||||
version);
|
||||
|
||||
walApplyVer(pVnode->pWal, version);
|
||||
|
||||
|
@ -328,7 +334,8 @@ int32_t vnodePreprocessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
|
||||
int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||
vTrace("message in vnode query queue is processing");
|
||||
if ((pMsg->msgType == TDMT_SCH_QUERY) && !vnodeIsLeader(pVnode)) {
|
||||
// if ((pMsg->msgType == TDMT_SCH_QUERY) && !vnodeIsLeader(pVnode)) {
|
||||
if ((pMsg->msgType == TDMT_SCH_QUERY) && !syncIsReadyForRead(pVnode->sync)) {
|
||||
vnodeRedirectRpcMsg(pVnode, pMsg);
|
||||
return 0;
|
||||
}
|
||||
|
@ -342,7 +349,7 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
return qWorkerProcessCQueryMsg(&handle, pVnode->pQuery, pMsg, 0);
|
||||
default:
|
||||
vError("unknown msg type:%d in query queue", pMsg->msgType);
|
||||
return TSDB_CODE_VND_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,19 +357,17 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
|||
vTrace("vgId:%d, msg:%p in fetch queue is processing", pVnode->config.vgId, pMsg);
|
||||
if ((pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_VND_TABLE_META || pMsg->msgType == TDMT_VND_TABLE_CFG ||
|
||||
pMsg->msgType == TDMT_VND_BATCH_META) &&
|
||||
!vnodeIsLeader(pVnode)) {
|
||||
!syncIsReadyForRead(pVnode->sync)) {
|
||||
// !vnodeIsLeader(pVnode)) {
|
||||
vnodeRedirectRpcMsg(pVnode, pMsg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (pMsg->msgType == TDMT_VND_CONSUME && !pVnode->restored) {
|
||||
if (pMsg->msgType == TDMT_VND_TMQ_CONSUME && !pVnode->restored) {
|
||||
vnodeRedirectRpcMsg(pVnode, pMsg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *msgstr = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||
int32_t msgLen = pMsg->contLen - sizeof(SMsgHead);
|
||||
|
||||
switch (pMsg->msgType) {
|
||||
case TDMT_SCH_FETCH:
|
||||
case TDMT_SCH_MERGE_FETCH:
|
||||
|
@ -381,27 +386,31 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
|||
return vnodeGetTableCfg(pVnode, pMsg, true);
|
||||
case TDMT_VND_BATCH_META:
|
||||
return vnodeGetBatchMeta(pVnode, pMsg);
|
||||
case TDMT_VND_CONSUME:
|
||||
case TDMT_VND_TMQ_CONSUME:
|
||||
return tqProcessPollReq(pVnode->pTq, pMsg);
|
||||
case TDMT_STREAM_TASK_RUN:
|
||||
return tqProcessTaskRunReq(pVnode->pTq, pMsg);
|
||||
#if 0
|
||||
#if 1
|
||||
case TDMT_STREAM_TASK_DISPATCH:
|
||||
return tqProcessTaskDispatchReq(pVnode->pTq, pMsg, true);
|
||||
#endif
|
||||
/*case TDMT_STREAM_TASK_RECOVER:*/
|
||||
/*return tqProcessTaskRecoverReq(pVnode->pTq, pMsg);*/
|
||||
case TDMT_STREAM_RETRIEVE:
|
||||
return tqProcessTaskRetrieveReq(pVnode->pTq, pMsg);
|
||||
case TDMT_STREAM_TASK_CHECK:
|
||||
return tqProcessStreamTaskCheckReq(pVnode->pTq, pMsg);
|
||||
case TDMT_STREAM_TASK_DISPATCH_RSP:
|
||||
return tqProcessTaskDispatchRsp(pVnode->pTq, pMsg);
|
||||
/*case TDMT_STREAM_TASK_RECOVER_RSP:*/
|
||||
/*return tqProcessTaskRecoverRsp(pVnode->pTq, pMsg);*/
|
||||
case TDMT_STREAM_RETRIEVE:
|
||||
return tqProcessTaskRetrieveReq(pVnode->pTq, pMsg);
|
||||
case TDMT_STREAM_RETRIEVE_RSP:
|
||||
return tqProcessTaskRetrieveRsp(pVnode->pTq, pMsg);
|
||||
case TDMT_VND_STREAM_RECOVER_STEP1:
|
||||
return tqProcessTaskRecover1Req(pVnode->pTq, pMsg);
|
||||
case TDMT_STREAM_RECOVER_FINISH:
|
||||
return tqProcessTaskRecoverFinishReq(pVnode->pTq, pMsg);
|
||||
case TDMT_STREAM_RECOVER_FINISH_RSP:
|
||||
return tqProcessTaskRecoverFinishRsp(pVnode->pTq, pMsg);
|
||||
default:
|
||||
vError("unknown msg type:%d in fetch queue", pMsg->msgType);
|
||||
return TSDB_CODE_VND_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -767,7 +776,7 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq
|
|||
/* code */
|
||||
ret = metaDropTable(pVnode->pMeta, version, pDropTbReq, tbUids, &tbUid);
|
||||
if (ret < 0) {
|
||||
if (pDropTbReq->igNotExists && terrno == TSDB_CODE_VND_TABLE_NOT_EXIST) {
|
||||
if (pDropTbReq->igNotExists && terrno == TSDB_CODE_TDB_TABLE_NOT_EXIST) {
|
||||
dropTbRsp.code = TSDB_CODE_SUCCESS;
|
||||
} else {
|
||||
dropTbRsp.code = terrno;
|
||||
|
@ -856,6 +865,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
|||
SEncoder encoder = {0};
|
||||
SArray *newTbUids = NULL;
|
||||
SVStatis statis = {0};
|
||||
bool tbCreated = false;
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
|
||||
pRsp->code = 0;
|
||||
|
@ -889,11 +899,10 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
|||
if (pBlock == NULL) break;
|
||||
|
||||
SSubmitBlkRsp submitBlkRsp = {0};
|
||||
tbCreated = false;
|
||||
|
||||
// create table for auto create table mode
|
||||
if (msgIter.schemaLen > 0) {
|
||||
submitBlkRsp.hashMeta = 1;
|
||||
|
||||
tDecoderInit(&decoder, pBlock->data, msgIter.schemaLen);
|
||||
if (tDecodeSVCreateTbReq(&decoder, &createTbReq) < 0) {
|
||||
pRsp->code = TSDB_CODE_INVALID_MSG;
|
||||
|
@ -930,12 +939,13 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
|||
}
|
||||
|
||||
taosArrayPush(newTbUids, &createTbReq.uid);
|
||||
|
||||
submitBlkRsp.uid = createTbReq.uid;
|
||||
submitBlkRsp.tblFName = taosMemoryMalloc(strlen(pVnode->config.dbname) + strlen(createTbReq.name) + 2);
|
||||
sprintf(submitBlkRsp.tblFName, "%s.%s", pVnode->config.dbname, createTbReq.name);
|
||||
tbCreated = true;
|
||||
}
|
||||
|
||||
submitBlkRsp.uid = createTbReq.uid;
|
||||
submitBlkRsp.tblFName = taosMemoryMalloc(strlen(pVnode->config.dbname) + strlen(createTbReq.name) + 2);
|
||||
sprintf(submitBlkRsp.tblFName, "%s.%s", pVnode->config.dbname, createTbReq.name);
|
||||
|
||||
|
||||
msgIter.uid = createTbReq.uid;
|
||||
if (createTbReq.type == TSDB_CHILD_TABLE) {
|
||||
msgIter.suid = createTbReq.ctb.suid;
|
||||
|
@ -948,10 +958,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
|||
#endif
|
||||
tDecoderClear(&decoder);
|
||||
taosArrayDestroy(createTbReq.ctb.tagName);
|
||||
} else {
|
||||
submitBlkRsp.tblFName = taosMemoryMalloc(TSDB_TABLE_FNAME_LEN);
|
||||
sprintf(submitBlkRsp.tblFName, "%s.", pVnode->config.dbname);
|
||||
}
|
||||
}
|
||||
|
||||
if (tsdbInsertTableData(pVnode->pTsdb, version, &msgIter, pBlock, &submitBlkRsp) < 0) {
|
||||
submitBlkRsp.code = terrno;
|
||||
|
@ -959,7 +966,9 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
|||
|
||||
submitRsp.numOfRows += submitBlkRsp.numOfRows;
|
||||
submitRsp.affectedRows += submitBlkRsp.affectedRows;
|
||||
taosArrayPush(submitRsp.pArray, &submitBlkRsp);
|
||||
if (tbCreated || submitBlkRsp.code) {
|
||||
taosArrayPush(submitRsp.pArray, &submitBlkRsp);
|
||||
}
|
||||
}
|
||||
|
||||
if (taosArrayGetSize(newTbUids) > 0) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue