Merge branch '3.0' into fix/td_19618
This commit is contained in:
commit
884e0cb002
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ,单位为秒。
|
||||
|
||||
其它通用参数详见[通用配置参数](#通用配置参数)。
|
||||
|
||||
#### 执行指定查询语句的配置参数
|
||||
|
||||
|
|
|
@ -126,6 +126,9 @@ extern char tsSmlChildTableName[];
|
|||
extern char tsSmlTagName[];
|
||||
extern bool tsSmlDataFormat;
|
||||
|
||||
// wal
|
||||
extern int64_t tsWalFsyncDataSizeLimit;
|
||||
|
||||
// internal
|
||||
extern int32_t tsTransPullupInterval;
|
||||
extern int32_t tsMqRebalanceInterval;
|
||||
|
|
|
@ -57,10 +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_VND_TMQ_MAX_MSG || (TYPE) < TDMT_STREAM_MAX_MSG || (TYPE) < TDMT_VND_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;
|
||||
|
|
|
@ -139,6 +139,7 @@ enum {
|
|||
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_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)
|
||||
|
@ -147,7 +148,8 @@ enum {
|
|||
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_MQ_TIMER, "mq-tmr", SMTimerReq, NULL)
|
||||
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)
|
||||
|
@ -184,6 +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_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)
|
||||
|
@ -215,30 +232,17 @@ 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_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)
|
||||
|
||||
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_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_MAX_MSG, "stream-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_MON_MSG)
|
||||
TD_DEF_MSG_TYPE(TDMT_MON_MAX_MSG, "monitor-max", NULL, NULL)
|
||||
|
||||
|
@ -270,6 +274,22 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_SYNC_LOCAL_CMD, "sync-local-cmd", 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
|
||||
|
|
|
@ -242,7 +242,7 @@ 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))
|
||||
|
|
|
@ -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)
|
||||
|
@ -132,27 +130,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,40 +191,36 @@ 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();
|
||||
bool syncIsInit();
|
||||
int64_t syncOpen(SSyncInfo* pSyncInfo);
|
||||
void syncStart(int64_t rid);
|
||||
void syncStop(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);
|
||||
const char* syncStr(ESyncState state);
|
||||
bool syncIsRestoreFinish(int64_t rid);
|
||||
int32_t syncGetSnapshotByIndex(int64_t rid, SyncIndex index, SSnapshot* pSnapshot);
|
||||
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);
|
||||
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 syncLeaderTransfer(int64_t rid);
|
||||
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);
|
||||
|
||||
int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg);
|
||||
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
|
||||
|
|
|
@ -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)
|
||||
|
@ -367,7 +346,6 @@ int32_t* taosGetErrno();
|
|||
// 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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -423,6 +426,9 @@ 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;
|
||||
|
@ -722,6 +728,8 @@ 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));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -174,7 +174,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)) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -66,7 +66,7 @@ int32_t mndInitConsumer(SMnode *pMnode) {
|
|||
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_MQ_TIMER, mndProcessMqTimerMsg);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_TIMER, mndProcessMqTimerMsg);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_CONSUMER_LOST, mndProcessConsumerLostMsg);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TMQ_CONSUMER_RECOVER, mndProcessConsumerRecoverMsg);
|
||||
|
||||
|
|
|
@ -403,6 +403,10 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
|
||||
bool needCheck = !online || dnodeChanged || reboot;
|
||||
|
||||
pDnode->accessTimes++;
|
||||
mTrace("dnode:%d, status received, access times:%d check:%d online:%d reboot:%d changed:%d", pDnode->id,
|
||||
pDnode->accessTimes, needCheck, online, reboot, dnodeChanged);
|
||||
|
||||
if (needCheck) {
|
||||
if (statusReq.sver != tsVersion) {
|
||||
if (pDnode != NULL) {
|
||||
|
@ -424,9 +428,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,7 @@ 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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -498,14 +487,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;
|
||||
}
|
||||
|
||||
|
@ -516,8 +505,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) {
|
||||
|
@ -740,8 +729,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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -72,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);
|
||||
|
@ -120,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,
|
||||
|
@ -128,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) {
|
||||
|
@ -146,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;
|
||||
|
@ -179,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");
|
||||
|
||||
|
@ -205,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;
|
||||
}
|
||||
|
@ -217,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;
|
||||
|
@ -242,10 +234,13 @@ int32_t mndInitSync(SMnode *pMnode) {
|
|||
.batchSize = 1,
|
||||
.vgId = 1,
|
||||
.pWal = pMnode->pWal,
|
||||
.msgcb = NULL,
|
||||
.FpSendMsg = mndSyncSendMsg,
|
||||
.FpEqMsg = mndSyncEqMsg,
|
||||
.FpEqCtrlMsg = mndSyncEqCtrlMsg,
|
||||
.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);
|
||||
|
@ -269,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;
|
||||
}
|
||||
|
@ -289,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);
|
||||
|
@ -327,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) {
|
||||
|
@ -344,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);
|
||||
}
|
||||
|
@ -366,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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define _TD_VND_H_
|
||||
|
||||
#include "sync.h"
|
||||
#include "syncTools.h"
|
||||
#include "ttrace.h"
|
||||
#include "vnodeInt.h"
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1268,7 +1268,7 @@ 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) {
|
||||
if (pTask->taskStatus == TASK_STATUS__RECOVER_PREPARE) {
|
||||
tqDebug("skip push task %d, task status %d", pTask->taskId, pTask->taskStatus);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -138,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
|
||||
|
@ -147,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;
|
||||
|
@ -164,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);
|
||||
|
@ -232,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
|
||||
|
@ -242,9 +292,23 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableK
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -254,7 +318,9 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -266,18 +332,19 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableK
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -298,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);
|
||||
|
@ -506,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);
|
||||
|
@ -577,7 +644,7 @@ 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(SBlockIndex));
|
||||
}
|
||||
|
@ -597,7 +664,7 @@ _end:
|
|||
}
|
||||
|
||||
static void cleanupTableScanInfo(SHashObj* pTableMap) {
|
||||
STableBlockScanInfo* px = NULL;
|
||||
STableBlockScanInfo** px = NULL;
|
||||
while (1) {
|
||||
px = taosHashIterate(pTableMap, px);
|
||||
if (px == NULL) {
|
||||
|
@ -605,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -621,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);
|
||||
|
@ -1069,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;
|
||||
}
|
||||
|
||||
SBlockIndex* pIndex = taosArrayGet(pScanInfo->pBlockList, pBlockInfo->tbBlockIdx);
|
||||
tMapDataGetItemByIdx(&pScanInfo->mapData, pIndex->ordinalIndex, &pBlockIter->block, tGetDataBlk);
|
||||
SBlockIndex* pIndex = taosArrayGet((*pScanInfo)->pBlockList, pBlockInfo->tbBlockIdx);
|
||||
tMapDataGetItemByIdx(&(*pScanInfo)->mapData, pIndex->ordinalIndex, &pBlockIter->block, tGetDataBlk);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -1111,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;
|
||||
}
|
||||
|
@ -2235,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,
|
||||
|
@ -2255,7 +2323,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
|||
}
|
||||
}
|
||||
} else { // file blocks not exist
|
||||
pBlockScanInfo = pReader->status.pTableIter;
|
||||
pBlockScanInfo = *pReader->status.pTableIter;
|
||||
}
|
||||
|
||||
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
|
||||
|
@ -2480,7 +2548,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);
|
||||
}
|
||||
|
@ -2554,7 +2622,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);
|
||||
|
@ -2592,9 +2660,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) {
|
||||
|
@ -2659,11 +2727,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;
|
||||
}
|
||||
|
@ -3465,18 +3533,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;
|
||||
|
@ -3680,8 +3753,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);
|
||||
|
@ -3765,7 +3839,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;
|
||||
|
@ -3782,7 +3856,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;
|
||||
}
|
||||
|
@ -3798,7 +3872,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;
|
||||
}
|
||||
|
@ -3911,7 +3985,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,
|
||||
|
@ -3947,6 +4021,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;
|
||||
|
@ -3963,13 +4039,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) {
|
||||
|
@ -4071,7 +4146,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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -285,8 +285,8 @@ 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, code:0x%x index:%" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType), pRsp->code,
|
||||
|
@ -348,7 +348,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -406,7 +406,7 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -772,7 +772,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;
|
||||
|
|
|
@ -237,7 +237,7 @@ int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
|||
int32_t code = syncProcessMsg(pVnode->sync, pMsg);
|
||||
if (code != 0) {
|
||||
vGError("vgId:%d, failed to process sync msg:%p type:%s since %s", pVnode->config.vgId, pMsg,
|
||||
TMSG_INFO(pMsg->msgType), terrstr());
|
||||
TMSG_INFO(pMsg->msgType), terrstr());
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -290,78 +290,61 @@ static int32_t vnodeSyncSendMsg(const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t vnodeSyncGetSnapshot(SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
||||
static int32_t vnodeSyncGetSnapshot(const SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
||||
vnodeGetSnapshot(pFsm->data, pSnapshot);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void vnodeSyncReconfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta *cbMeta) {}
|
||||
static void vnodeSyncApplyMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
SVnode *pVnode = pFsm->data;
|
||||
|
||||
static void vnodeSyncCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
||||
if (cbMeta.isWeak == 0) {
|
||||
SVnode *pVnode = pFsm->data;
|
||||
if (pMeta->code == 0) {
|
||||
SRpcMsg rpcMsg = {.msgType = pMsg->msgType, .contLen = pMsg->contLen};
|
||||
rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
|
||||
memcpy(rpcMsg.pCont, pMsg->pCont, pMsg->contLen);
|
||||
rpcMsg.info = pMsg->info;
|
||||
rpcMsg.info.conn.applyIndex = pMeta->index;
|
||||
rpcMsg.info.conn.applyTerm = pMeta->term;
|
||||
|
||||
if (cbMeta.code == 0) {
|
||||
SRpcMsg rpcMsg = {.msgType = pMsg->msgType, .contLen = pMsg->contLen};
|
||||
rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
|
||||
memcpy(rpcMsg.pCont, pMsg->pCont, pMsg->contLen);
|
||||
syncGetAndDelRespRpc(pVnode->sync, cbMeta.seqNum, &rpcMsg.info);
|
||||
rpcMsg.info.conn.applyIndex = cbMeta.index;
|
||||
rpcMsg.info.conn.applyTerm = cbMeta.term;
|
||||
|
||||
vInfo("vgId:%d, commit-cb is excuted, fsm:%p, index:%" PRId64 ", term:%" PRIu64 ", msg-index:%" PRId64
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
vGTrace("vgId:%d, commit-cb is excuted, fsm:%p, index:%" PRId64 ", term:%" PRIu64 ", msg-index:%" PRId64
|
||||
", weak:%d, code:%d, state:%d %s, type:%s",
|
||||
syncGetVgId(pVnode->sync), pFsm, cbMeta.index, cbMeta.term, rpcMsg.info.conn.applyIndex, cbMeta.isWeak,
|
||||
cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), TMSG_INFO(pMsg->msgType));
|
||||
pVnode->config.vgId, pFsm, pMeta->index, pMeta->term, rpcMsg.info.conn.applyIndex, pMeta->isWeak,
|
||||
pMeta->code, pMeta->state, syncStr(pMeta->state), TMSG_INFO(pMsg->msgType));
|
||||
|
||||
tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, &rpcMsg);
|
||||
} else {
|
||||
SRpcMsg rsp = {.code = cbMeta.code, .info = pMsg->info};
|
||||
vError("vgId:%d, commit-cb execute error, type:%s, index:%" PRId64 ", error:0x%x %s", syncGetVgId(pVnode->sync),
|
||||
TMSG_INFO(pMsg->msgType), cbMeta.index, cbMeta.code, tstrerror(cbMeta.code));
|
||||
if (rsp.info.handle != NULL) {
|
||||
tmsgSendRsp(&rsp);
|
||||
}
|
||||
tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, &rpcMsg);
|
||||
} else {
|
||||
SRpcMsg rsp = {.code = pMeta->code, .info = pMsg->info};
|
||||
vError("vgId:%d, commit-cb execute error, type:%s, index:%" PRId64 ", error:0x%x %s", pVnode->config.vgId,
|
||||
TMSG_INFO(pMsg->msgType), pMeta->index, pMeta->code, tstrerror(pMeta->code));
|
||||
if (rsp.info.handle != NULL) {
|
||||
tmsgSendRsp(&rsp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void vnodeSyncPreCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
||||
if (cbMeta.isWeak == 1) {
|
||||
SVnode *pVnode = pFsm->data;
|
||||
vTrace("vgId:%d, pre-commit-cb is excuted, fsm:%p, index:%" PRId64 ", weak:%d, code:%d, state:%d %s, type:%s",
|
||||
syncGetVgId(pVnode->sync), pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state,
|
||||
syncUtilState2String(cbMeta.state), TMSG_INFO(pMsg->msgType));
|
||||
|
||||
if (cbMeta.code == 0) {
|
||||
SRpcMsg rpcMsg = {.msgType = pMsg->msgType, .contLen = pMsg->contLen};
|
||||
rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
|
||||
memcpy(rpcMsg.pCont, pMsg->pCont, pMsg->contLen);
|
||||
syncGetAndDelRespRpc(pVnode->sync, cbMeta.seqNum, &rpcMsg.info);
|
||||
rpcMsg.info.conn.applyIndex = cbMeta.index;
|
||||
rpcMsg.info.conn.applyTerm = cbMeta.term;
|
||||
tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, &rpcMsg);
|
||||
} else {
|
||||
SRpcMsg rsp = {.code = cbMeta.code, .info = pMsg->info};
|
||||
vError("vgId:%d, pre-commit-cb execute error, type:%s, error:0x%x %s", syncGetVgId(pVnode->sync),
|
||||
TMSG_INFO(pMsg->msgType), cbMeta.code, tstrerror(cbMeta.code));
|
||||
if (rsp.info.handle != NULL) {
|
||||
tmsgSendRsp(&rsp);
|
||||
}
|
||||
}
|
||||
static void vnodeSyncCommitMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
if (pMeta->isWeak == 0) {
|
||||
vnodeSyncApplyMsg(pFsm, pMsg, pMeta);
|
||||
}
|
||||
}
|
||||
|
||||
static void vnodeSyncRollBackMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
||||
static void vnodeSyncPreCommitMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
if (pMeta->isWeak == 1) {
|
||||
vnodeSyncApplyMsg(pFsm, pMsg, pMeta);
|
||||
}
|
||||
}
|
||||
|
||||
static void vnodeSyncRollBackMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
SVnode *pVnode = pFsm->data;
|
||||
vTrace("vgId:%d, rollback-cb is excuted, fsm:%p, index:%" PRId64 ", weak:%d, code:%d, state:%d %s, type:%s",
|
||||
syncGetVgId(pVnode->sync), pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state,
|
||||
syncUtilState2String(cbMeta.state), TMSG_INFO(pMsg->msgType));
|
||||
pVnode->config.vgId, pFsm, pMeta->index, pMeta->isWeak, pMeta->code, pMeta->state, syncStr(pMeta->state),
|
||||
TMSG_INFO(pMsg->msgType));
|
||||
}
|
||||
|
||||
#define USE_TSDB_SNAPSHOT
|
||||
|
||||
static int32_t vnodeSnapshotStartRead(struct SSyncFSM *pFsm, void *pParam, void **ppReader) {
|
||||
static int32_t vnodeSnapshotStartRead(const SSyncFSM *pFsm, void *pParam, void **ppReader) {
|
||||
#ifdef USE_TSDB_SNAPSHOT
|
||||
SVnode *pVnode = pFsm->data;
|
||||
SSnapshotParam *pSnapshotParam = pParam;
|
||||
|
@ -373,7 +356,7 @@ static int32_t vnodeSnapshotStartRead(struct SSyncFSM *pFsm, void *pParam, void
|
|||
#endif
|
||||
}
|
||||
|
||||
static int32_t vnodeSnapshotStopRead(struct SSyncFSM *pFsm, void *pReader) {
|
||||
static int32_t vnodeSnapshotStopRead(const SSyncFSM *pFsm, void *pReader) {
|
||||
#ifdef USE_TSDB_SNAPSHOT
|
||||
SVnode *pVnode = pFsm->data;
|
||||
int32_t code = vnodeSnapReaderClose(pReader);
|
||||
|
@ -384,7 +367,7 @@ static int32_t vnodeSnapshotStopRead(struct SSyncFSM *pFsm, void *pReader) {
|
|||
#endif
|
||||
}
|
||||
|
||||
static int32_t vnodeSnapshotDoRead(struct SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) {
|
||||
static int32_t vnodeSnapshotDoRead(const SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) {
|
||||
#ifdef USE_TSDB_SNAPSHOT
|
||||
SVnode *pVnode = pFsm->data;
|
||||
int32_t code = vnodeSnapRead(pReader, (uint8_t **)ppBuf, len);
|
||||
|
@ -403,7 +386,7 @@ static int32_t vnodeSnapshotDoRead(struct SSyncFSM *pFsm, void *pReader, void **
|
|||
#endif
|
||||
}
|
||||
|
||||
static int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void **ppWriter) {
|
||||
static int32_t vnodeSnapshotStartWrite(const SSyncFSM *pFsm, void *pParam, void **ppWriter) {
|
||||
#ifdef USE_TSDB_SNAPSHOT
|
||||
SVnode *pVnode = pFsm->data;
|
||||
SSnapshotParam *pSnapshotParam = pParam;
|
||||
|
@ -427,7 +410,7 @@ static int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void
|
|||
#endif
|
||||
}
|
||||
|
||||
static int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply, SSnapshot *pSnapshot) {
|
||||
static int32_t vnodeSnapshotStopWrite(const SSyncFSM *pFsm, void *pWriter, bool isApply, SSnapshot *pSnapshot) {
|
||||
#ifdef USE_TSDB_SNAPSHOT
|
||||
SVnode *pVnode = pFsm->data;
|
||||
vInfo("vgId:%d, stop write vnode snapshot, apply:%d, index:%" PRId64 " term:%" PRIu64 " config:%" PRId64,
|
||||
|
@ -442,7 +425,7 @@ static int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool
|
|||
#endif
|
||||
}
|
||||
|
||||
static int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) {
|
||||
static int32_t vnodeSnapshotDoWrite(const SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) {
|
||||
#ifdef USE_TSDB_SNAPSHOT
|
||||
SVnode *pVnode = pFsm->data;
|
||||
vDebug("vgId:%d, continue write vnode snapshot, len:%d", pVnode->config.vgId, len);
|
||||
|
@ -454,9 +437,7 @@ static int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *
|
|||
#endif
|
||||
}
|
||||
|
||||
static void vnodeLeaderTransfer(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {}
|
||||
|
||||
static void vnodeRestoreFinish(struct SSyncFSM *pFsm) {
|
||||
static void vnodeRestoreFinish(const SSyncFSM *pFsm) {
|
||||
SVnode *pVnode = pFsm->data;
|
||||
|
||||
do {
|
||||
|
@ -476,7 +457,7 @@ static void vnodeRestoreFinish(struct SSyncFSM *pFsm) {
|
|||
vDebug("vgId:%d, sync restore finished", pVnode->config.vgId);
|
||||
}
|
||||
|
||||
static void vnodeBecomeFollower(struct SSyncFSM *pFsm) {
|
||||
static void vnodeBecomeFollower(const SSyncFSM *pFsm) {
|
||||
SVnode *pVnode = pFsm->data;
|
||||
vDebug("vgId:%d, become follower", pVnode->config.vgId);
|
||||
|
||||
|
@ -490,7 +471,7 @@ static void vnodeBecomeFollower(struct SSyncFSM *pFsm) {
|
|||
taosThreadMutexUnlock(&pVnode->lock);
|
||||
}
|
||||
|
||||
static void vnodeBecomeLeader(struct SSyncFSM *pFsm) {
|
||||
static void vnodeBecomeLeader(const SSyncFSM *pFsm) {
|
||||
SVnode *pVnode = pFsm->data;
|
||||
vDebug("vgId:%d, become leader", pVnode->config.vgId);
|
||||
|
||||
|
@ -512,10 +493,10 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
|
|||
pFsm->FpRollBackCb = vnodeSyncRollBackMsg;
|
||||
pFsm->FpGetSnapshotInfo = vnodeSyncGetSnapshot;
|
||||
pFsm->FpRestoreFinishCb = vnodeRestoreFinish;
|
||||
pFsm->FpLeaderTransferCb = vnodeLeaderTransfer;
|
||||
pFsm->FpLeaderTransferCb = NULL;
|
||||
pFsm->FpBecomeLeaderCb = vnodeBecomeLeader;
|
||||
pFsm->FpBecomeFollowerCb = vnodeBecomeFollower;
|
||||
pFsm->FpReConfigCb = vnodeSyncReconfig;
|
||||
pFsm->FpReConfigCb = NULL;
|
||||
pFsm->FpSnapshotStartRead = vnodeSnapshotStartRead;
|
||||
pFsm->FpSnapshotStopRead = vnodeSnapshotStopRead;
|
||||
pFsm->FpSnapshotDoRead = vnodeSnapshotDoRead;
|
||||
|
@ -533,10 +514,13 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
|
|||
.vgId = pVnode->config.vgId,
|
||||
.syncCfg = pVnode->config.syncCfg,
|
||||
.pWal = pVnode->pWal,
|
||||
.msgcb = NULL,
|
||||
.FpSendMsg = vnodeSyncSendMsg,
|
||||
.FpEqMsg = vnodeSyncEqMsg,
|
||||
.FpEqCtrlMsg = vnodeSyncEqCtrlMsg,
|
||||
.msgcb = &pVnode->msgCb,
|
||||
.syncSendMSg = vnodeSyncSendMsg,
|
||||
.syncEqMsg = vnodeSyncEqMsg,
|
||||
.syncEqCtrlMsg = vnodeSyncEqCtrlMsg,
|
||||
.pingMs = 5000,
|
||||
.electMs = 4000,
|
||||
.heartbeatMs = 700,
|
||||
};
|
||||
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s%ssync", path, TD_DIRSEP);
|
||||
|
@ -555,15 +539,11 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
setPingTimerMS(pVnode->sync, 5000);
|
||||
setElectTimerMS(pVnode->sync, 4000);
|
||||
setHeartbeatTimerMS(pVnode->sync, 700);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vnodeSyncStart(SVnode *pVnode) {
|
||||
vDebug("vgId:%d, start sync", pVnode->config.vgId);
|
||||
syncSetMsgCb(pVnode->sync, &pVnode->msgCb);
|
||||
syncStart(pVnode->sync);
|
||||
}
|
||||
|
||||
|
@ -572,12 +552,21 @@ void vnodeSyncClose(SVnode *pVnode) {
|
|||
syncStop(pVnode->sync);
|
||||
}
|
||||
|
||||
bool vnodeIsRoleLeader(SVnode *pVnode) { return syncGetMyRole(pVnode->sync) == TAOS_SYNC_STATE_LEADER; }
|
||||
bool vnodeIsRoleLeader(SVnode *pVnode) {
|
||||
SSyncState state = syncGetState(pVnode->sync);
|
||||
return state.state == TAOS_SYNC_STATE_LEADER;
|
||||
}
|
||||
|
||||
bool vnodeIsLeader(SVnode *pVnode) {
|
||||
if (!syncIsReady(pVnode->sync)) {
|
||||
vDebug("vgId:%d, vnode not ready, state:%s, restore:%d", pVnode->config.vgId, syncGetMyRoleStr(pVnode->sync),
|
||||
syncRestoreFinish(pVnode->sync));
|
||||
SSyncState state = syncGetState(pVnode->sync);
|
||||
|
||||
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;
|
||||
}
|
||||
vDebug("vgId:%d, vnode not ready, state:%s, restore:%d", pVnode->config.vgId, syncStr(state.state), state.restored);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -621,9 +621,10 @@ int32_t* setupColumnOffset(const SSDataBlock* pBlock, int32_t rowCapacity) {
|
|||
}
|
||||
|
||||
static void clearPartitionOperator(SPartitionOperatorInfo* pInfo) {
|
||||
void* ite = NULL;
|
||||
while ((ite = taosHashIterate(pInfo->pGroupSet, ite)) != NULL) {
|
||||
taosArrayDestroy(((SDataGroupInfo*)ite)->pPageList);
|
||||
int32_t size = taosArrayGetSize(pInfo->sortedGroupArray);
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
SDataGroupInfo* pGp = taosArrayGet(pInfo->sortedGroupArray, i);
|
||||
taosArrayDestroy(pGp->pPageList);
|
||||
}
|
||||
taosArrayClear(pInfo->sortedGroupArray);
|
||||
clearDiskbasedBuf(pInfo->pBuf);
|
||||
|
|
|
@ -344,7 +344,8 @@ static bool doLoadBlockSMA(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock,
|
|||
return true;
|
||||
}
|
||||
|
||||
static void doSetTagColumnData(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo, int32_t rows) {
|
||||
static void doSetTagColumnData(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo,
|
||||
int32_t rows) {
|
||||
if (pTableScanInfo->pseudoSup.numOfExprs > 0) {
|
||||
SExprSupp* pSup = &pTableScanInfo->pseudoSup;
|
||||
|
||||
|
@ -1878,7 +1879,6 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
if (pTaskInfo->streamInfo.recoverStep == STREAM_RECOVER_STEP__PREPARE1 ||
|
||||
pTaskInfo->streamInfo.recoverStep == STREAM_RECOVER_STEP__PREPARE2) {
|
||||
STableScanInfo* pTSInfo = pInfo->pTableScanOp->info;
|
||||
|
@ -1914,7 +1914,6 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
|||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t total = taosArrayGetSize(pInfo->pBlockLists);
|
||||
// TODO: refactor
|
||||
|
@ -2296,7 +2295,7 @@ SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, SExecTaskInfo* pT
|
|||
pInfo->vnode = pHandle->vnode;
|
||||
|
||||
pInfo->sContext = pHandle->sContext;
|
||||
pOperator->name = "RawStreamScanOperator";
|
||||
pOperator->name = "RawScanOperator";
|
||||
pOperator->info = pInfo;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
|
||||
|
@ -4384,8 +4383,9 @@ static int32_t loadDataBlockFromOneTable2(SOperatorInfo* pOperator, STableMergeS
|
|||
|
||||
// currently only the tbname pseudo column
|
||||
if (pTableScanInfo->pseudoSup.numOfExprs > 0) {
|
||||
int32_t code = addTagPseudoColumnData(&pTableScanInfo->readHandle, pTableScanInfo->pseudoSup.pExprInfo,
|
||||
pTableScanInfo->pseudoSup.numOfExprs, pBlock, pBlock->info.rows, GET_TASKID(pTaskInfo));
|
||||
int32_t code =
|
||||
addTagPseudoColumnData(&pTableScanInfo->readHandle, pTableScanInfo->pseudoSup.pExprInfo,
|
||||
pTableScanInfo->pseudoSup.numOfExprs, pBlock, pBlock->info.rows, GET_TASKID(pTaskInfo));
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
}
|
||||
|
@ -4501,8 +4501,9 @@ static int32_t loadDataBlockFromOneTable(SOperatorInfo* pOperator, STableMergeSc
|
|||
|
||||
// currently only the tbname pseudo column
|
||||
if (pTableScanInfo->pseudoSup.numOfExprs > 0) {
|
||||
int32_t code = addTagPseudoColumnData(&pTableScanInfo->readHandle, pTableScanInfo->pseudoSup.pExprInfo,
|
||||
pTableScanInfo->pseudoSup.numOfExprs, pBlock, pBlock->info.rows, GET_TASKID(pTaskInfo));
|
||||
int32_t code =
|
||||
addTagPseudoColumnData(&pTableScanInfo->readHandle, pTableScanInfo->pseudoSup.pExprInfo,
|
||||
pTableScanInfo->pseudoSup.numOfExprs, pBlock, pBlock->info.rows, GET_TASKID(pTaskInfo));
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
}
|
||||
|
|
|
@ -2307,6 +2307,12 @@ int32_t leastSQRFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
|
||||
double param00 = param[0][0] - param[1][0] * (param[0][1] / param[1][1]);
|
||||
double param02 = param[0][2] - param[1][2] * (param[0][1] / param[1][1]);
|
||||
|
||||
if (0 == param00) {
|
||||
colDataAppendNULL(pCol, currentRow);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// param[0][1] = 0;
|
||||
double param12 = param[1][2] - param02 * (param[1][0] / param00);
|
||||
// param[1][0] = 0;
|
||||
|
|
|
@ -124,13 +124,16 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) {
|
|||
|
||||
char pathTaosdLdLib[512] = {0};
|
||||
size_t taosdLdLibPathLen = sizeof(pathTaosdLdLib);
|
||||
uv_os_getenv("LD_LIBRARY_PATH", pathTaosdLdLib, &taosdLdLibPathLen);
|
||||
int ret = uv_os_getenv("LD_LIBRARY_PATH", pathTaosdLdLib, &taosdLdLibPathLen);
|
||||
if (ret != UV_ENOBUFS) {
|
||||
taosdLdLibPathLen = strlen(pathTaosdLdLib);
|
||||
}
|
||||
|
||||
char udfdPathLdLib[1024] = {0};
|
||||
size_t udfdLdLibPathLen = strlen(tsUdfdLdLibPath);
|
||||
strncpy(udfdPathLdLib, tsUdfdLdLibPath, udfdLdLibPathLen);
|
||||
udfdPathLdLib[udfdLdLibPathLen] = ':';
|
||||
strncpy(udfdPathLdLib + udfdLdLibPathLen + 1, pathTaosdLdLib, sizeof(udfdPathLdLib) - udfdLdLibPathLen);
|
||||
strncpy(udfdPathLdLib + udfdLdLibPathLen + 1, pathTaosdLdLib, sizeof(udfdPathLdLib) - udfdLdLibPathLen - 1);
|
||||
if (udfdLdLibPathLen + taosdLdLibPathLen < 1024) {
|
||||
fnInfo("udfd LD_LIBRARY_PATH: %s", udfdPathLdLib);
|
||||
} else {
|
||||
|
|
|
@ -52,6 +52,7 @@ typedef struct SSyncEnv {
|
|||
} SSyncEnv;
|
||||
|
||||
SSyncEnv* syncEnv();
|
||||
bool syncIsInit();
|
||||
|
||||
int64_t syncNodeAdd(SSyncNode* pNode);
|
||||
void syncNodeRemove(int64_t rid);
|
||||
|
|
|
@ -22,9 +22,9 @@ extern "C" {
|
|||
|
||||
#include "sync.h"
|
||||
#include "syncTools.h"
|
||||
#include "tlog.h"
|
||||
#include "ttimer.h"
|
||||
#include "taosdef.h"
|
||||
#include "tlog.h"
|
||||
#include "trpc.h"
|
||||
#include "ttimer.h"
|
||||
|
||||
// clang-format off
|
||||
|
@ -107,9 +107,9 @@ typedef struct SSyncNode {
|
|||
// sync io
|
||||
SWal* pWal;
|
||||
const 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 (*syncSendMSg)(const SEpSet* pEpSet, SRpcMsg* pMsg);
|
||||
int32_t (*syncEqMsg)(const SMsgCb* msgcb, SRpcMsg* pMsg);
|
||||
int32_t (*syncEqCtrlMsg)(const SMsgCb* msgcb, SRpcMsg* pMsg);
|
||||
|
||||
// init internal
|
||||
SNodeInfo myNodeInfo;
|
||||
|
|
|
@ -20,30 +20,17 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "trpc.h"
|
||||
|
||||
// ------------------ ds -------------------
|
||||
typedef struct SRaftId {
|
||||
SyncNodeId addr;
|
||||
SyncGroupId vgId;
|
||||
} SRaftId;
|
||||
|
||||
int32_t syncGetRespRpc(int64_t rid, uint64_t index, SRpcMsg* msg);
|
||||
int32_t syncGetAndDelRespRpc(int64_t rid, uint64_t index, SRpcHandleInfo* pInfo);
|
||||
void syncSetMsgCb(int64_t rid, const SMsgCb* msgcb);
|
||||
char* sync2SimpleStr(int64_t rid);
|
||||
|
||||
// set timer ms
|
||||
void setPingTimerMS(int64_t rid, int32_t pingTimerMS);
|
||||
void setElectTimerMS(int64_t rid, int32_t electTimerMS);
|
||||
void setHeartbeatTimerMS(int64_t rid, int32_t hbTimerMS);
|
||||
char* sync2SimpleStr(int64_t rid);
|
||||
|
||||
// for compatibility, the same as syncPropose
|
||||
int32_t syncForwardToPeer(int64_t rid, SRpcMsg* pMsg, bool isWeak);
|
||||
|
||||
// utils
|
||||
const char* syncUtilState2String(ESyncState state);
|
||||
|
||||
// ------------------ for debug -------------------
|
||||
void syncRpcMsgPrint(SRpcMsg* pMsg);
|
||||
void syncRpcMsgPrint2(char* s, SRpcMsg* pMsg);
|
|
@ -49,7 +49,7 @@ int32_t syncUtilQuorum(int32_t replicaNum);
|
|||
cJSON* syncUtilNodeInfo2Json(const SNodeInfo* p);
|
||||
cJSON* syncUtilRaftId2Json(const SRaftId* p);
|
||||
char* syncUtilRaftId2Str(const SRaftId* p);
|
||||
const char* syncUtilState2String(ESyncState state);
|
||||
const char* syncStr(ESyncState state);
|
||||
bool syncUtilCanPrint(char c);
|
||||
char* syncUtilprintBin(char* ptr, uint32_t len);
|
||||
char* syncUtilprintBin2(char* ptr, uint32_t len);
|
||||
|
|
|
@ -56,6 +56,12 @@ int64_t syncOpen(SSyncInfo* pSyncInfo) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
pSyncNode->pingBaseLine = pSyncInfo->pingMs;
|
||||
pSyncNode->pingTimerMS = pSyncInfo->pingMs;
|
||||
pSyncNode->electBaseLine = pSyncInfo->electMs;
|
||||
pSyncNode->hbBaseLine = pSyncInfo->heartbeatMs;
|
||||
pSyncNode->heartbeatTimerMS = pSyncInfo->heartbeatMs;
|
||||
pSyncNode->msgcb = pSyncInfo->msgcb;
|
||||
return pSyncNode->rid;
|
||||
}
|
||||
|
||||
|
@ -499,50 +505,20 @@ int32_t syncForwardToPeer(int64_t rid, SRpcMsg* pMsg, bool isWeak) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
ESyncState syncGetMyRole(int64_t rid) {
|
||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||
if (pSyncNode == NULL) {
|
||||
return TAOS_SYNC_STATE_ERROR;
|
||||
}
|
||||
ASSERT(rid == pSyncNode->rid);
|
||||
ESyncState state = pSyncNode->state;
|
||||
SSyncState syncGetState(int64_t rid) {
|
||||
SSyncState state = {.state = TAOS_SYNC_STATE_ERROR};
|
||||
|
||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||
if (pSyncNode != NULL) {
|
||||
state.state = pSyncNode->state;
|
||||
state.restored = pSyncNode->restoreFinish;
|
||||
syncNodeRelease(pSyncNode);
|
||||
}
|
||||
|
||||
syncNodeRelease(pSyncNode);
|
||||
return state;
|
||||
}
|
||||
|
||||
bool syncIsReady(int64_t rid) {
|
||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||
if (pSyncNode == NULL) {
|
||||
return false;
|
||||
}
|
||||
ASSERT(rid == pSyncNode->rid);
|
||||
bool b = (pSyncNode->state == TAOS_SYNC_STATE_LEADER) && pSyncNode->restoreFinish;
|
||||
syncNodeRelease(pSyncNode);
|
||||
|
||||
// if false, set error code
|
||||
if (false == b) {
|
||||
if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) {
|
||||
terrno = TSDB_CODE_SYN_NOT_LEADER;
|
||||
} else {
|
||||
terrno = TSDB_CODE_APP_NOT_READY;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
bool syncIsRestoreFinish(int64_t rid) {
|
||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||
if (pSyncNode == NULL) {
|
||||
return false;
|
||||
}
|
||||
ASSERT(rid == pSyncNode->rid);
|
||||
bool b = pSyncNode->restoreFinish;
|
||||
|
||||
syncNodeRelease(pSyncNode);
|
||||
return b;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t syncGetSnapshotByIndex(int64_t rid, SyncIndex index, SSnapshot* pSnapshot) {
|
||||
if (index < SYNC_INDEX_BEGIN) {
|
||||
return -1;
|
||||
|
@ -612,6 +588,7 @@ int32_t syncGetSnapshotMetaByIndex(int64_t rid, SyncIndex snapshotIndex, struct
|
|||
syncNodeRelease(pSyncNode);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode* pSyncNode, SyncIndex snapshotLastApplyIndex) {
|
||||
ASSERT(pSyncNode->pRaftCfg->configIndexCount >= 1);
|
||||
|
@ -629,23 +606,7 @@ SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode* pSyncNode, SyncIndex snapsho
|
|||
return lastIndex;
|
||||
}
|
||||
|
||||
const char* syncGetMyRoleStr(int64_t rid) {
|
||||
const char* s = syncUtilState2String(syncGetMyRole(rid));
|
||||
return s;
|
||||
}
|
||||
|
||||
bool syncRestoreFinish(int64_t rid) {
|
||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||
if (pSyncNode == NULL) {
|
||||
return false;
|
||||
}
|
||||
ASSERT(rid == pSyncNode->rid);
|
||||
bool restoreFinish = pSyncNode->restoreFinish;
|
||||
|
||||
syncNodeRelease(pSyncNode);
|
||||
return restoreFinish;
|
||||
}
|
||||
|
||||
#if 0
|
||||
SyncTerm syncGetMyTerm(int64_t rid) {
|
||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||
if (pSyncNode == NULL) {
|
||||
|
@ -713,6 +674,7 @@ void syncGetEpSet(int64_t rid, SEpSet* pEpSet) {
|
|||
|
||||
syncNodeRelease(pSyncNode);
|
||||
}
|
||||
#endif
|
||||
|
||||
void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet) {
|
||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||
|
@ -736,31 +698,7 @@ void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet) {
|
|||
|
||||
syncNodeRelease(pSyncNode);
|
||||
}
|
||||
|
||||
int32_t syncGetRespRpc(int64_t rid, uint64_t index, SRpcMsg* msg) {
|
||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||
if (pSyncNode == NULL) {
|
||||
return TAOS_SYNC_STATE_ERROR;
|
||||
}
|
||||
ASSERT(rid == pSyncNode->rid);
|
||||
|
||||
SRespStub stub;
|
||||
int32_t ret = syncRespMgrGet(pSyncNode->pSyncRespMgr, index, &stub);
|
||||
if (ret == 1) {
|
||||
memcpy(msg, &(stub.rpcMsg), sizeof(SRpcMsg));
|
||||
}
|
||||
|
||||
syncNodeRelease(pSyncNode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t syncGetAndDelRespRpc(int64_t rid, uint64_t index, SRpcHandleInfo* pInfo) {
|
||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||
if (pSyncNode == NULL) {
|
||||
return TAOS_SYNC_STATE_ERROR;
|
||||
}
|
||||
ASSERT(rid == pSyncNode->rid);
|
||||
|
||||
static void syncGetAndDelRespRpc(SSyncNode* pSyncNode, uint64_t index, SRpcHandleInfo* pInfo) {
|
||||
SRespStub stub;
|
||||
int32_t ret = syncRespMgrGetAndDel(pSyncNode->pSyncRespMgr, index, &stub);
|
||||
if (ret == 1) {
|
||||
|
@ -768,20 +706,6 @@ int32_t syncGetAndDelRespRpc(int64_t rid, uint64_t index, SRpcHandleInfo* pInfo)
|
|||
}
|
||||
|
||||
sTrace("vgId:%d, get seq:%" PRIu64 " rpc handle:%p", pSyncNode->vgId, index, pInfo->handle);
|
||||
syncNodeRelease(pSyncNode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void syncSetMsgCb(int64_t rid, const SMsgCb* msgcb) {
|
||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||
if (pSyncNode == NULL) {
|
||||
sTrace("syncSetQ get pSyncNode is NULL, rid:%" PRId64, rid);
|
||||
return;
|
||||
}
|
||||
ASSERT(rid == pSyncNode->rid);
|
||||
pSyncNode->msgcb = msgcb;
|
||||
|
||||
syncNodeRelease(pSyncNode);
|
||||
}
|
||||
|
||||
char* sync2SimpleStr(int64_t rid) {
|
||||
|
@ -797,41 +721,6 @@ char* sync2SimpleStr(int64_t rid) {
|
|||
return s;
|
||||
}
|
||||
|
||||
void setPingTimerMS(int64_t rid, int32_t pingTimerMS) {
|
||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||
if (pSyncNode == NULL) {
|
||||
return;
|
||||
}
|
||||
ASSERT(rid == pSyncNode->rid);
|
||||
pSyncNode->pingBaseLine = pingTimerMS;
|
||||
pSyncNode->pingTimerMS = pingTimerMS;
|
||||
|
||||
syncNodeRelease(pSyncNode);
|
||||
}
|
||||
|
||||
void setElectTimerMS(int64_t rid, int32_t electTimerMS) {
|
||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||
if (pSyncNode == NULL) {
|
||||
return;
|
||||
}
|
||||
ASSERT(rid == pSyncNode->rid);
|
||||
pSyncNode->electBaseLine = electTimerMS;
|
||||
|
||||
syncNodeRelease(pSyncNode);
|
||||
}
|
||||
|
||||
void setHeartbeatTimerMS(int64_t rid, int32_t hbTimerMS) {
|
||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||
if (pSyncNode == NULL) {
|
||||
return;
|
||||
}
|
||||
ASSERT(rid == pSyncNode->rid);
|
||||
pSyncNode->hbBaseLine = hbTimerMS;
|
||||
pSyncNode->heartbeatTimerMS = hbTimerMS;
|
||||
|
||||
syncNodeRelease(pSyncNode);
|
||||
}
|
||||
|
||||
int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak) {
|
||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||
if (pSyncNode == NULL) {
|
||||
|
@ -928,7 +817,7 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) {
|
|||
}
|
||||
|
||||
} else {
|
||||
if (pSyncNode->FpEqMsg != NULL && (*pSyncNode->FpEqMsg)(pSyncNode->msgcb, &rpcMsg) == 0) {
|
||||
if (pSyncNode->syncEqMsg != NULL && (*pSyncNode->syncEqMsg)(pSyncNode->msgcb, &rpcMsg) == 0) {
|
||||
ret = 0;
|
||||
} else {
|
||||
ret = -1;
|
||||
|
@ -943,7 +832,7 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) {
|
|||
} else {
|
||||
ret = -1;
|
||||
terrno = TSDB_CODE_SYN_NOT_LEADER;
|
||||
sError("vgId:%d, sync propose not leader, %s, type:%s", pSyncNode->vgId, syncUtilState2String(pSyncNode->state),
|
||||
sError("vgId:%d, sync propose not leader, %s, type:%s", pSyncNode->vgId, syncStr(pSyncNode->state),
|
||||
TMSG_INFO(pMsg->msgType));
|
||||
goto _END;
|
||||
}
|
||||
|
@ -1059,9 +948,9 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
|
|||
|
||||
pSyncNode->pWal = pSyncInfo->pWal;
|
||||
pSyncNode->msgcb = pSyncInfo->msgcb;
|
||||
pSyncNode->FpSendMsg = pSyncInfo->FpSendMsg;
|
||||
pSyncNode->FpEqMsg = pSyncInfo->FpEqMsg;
|
||||
pSyncNode->FpEqCtrlMsg = pSyncInfo->FpEqCtrlMsg;
|
||||
pSyncNode->syncSendMSg = pSyncInfo->syncSendMSg;
|
||||
pSyncNode->syncEqMsg = pSyncInfo->syncEqMsg;
|
||||
pSyncNode->syncEqCtrlMsg = pSyncInfo->syncEqCtrlMsg;
|
||||
|
||||
// init raft config
|
||||
pSyncNode->pRaftCfg = raftCfgOpen(pSyncNode->configPath);
|
||||
|
@ -1577,12 +1466,12 @@ int32_t syncNodeRestartHeartbeatTimer(SSyncNode* pSyncNode) {
|
|||
int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pSyncNode, SRpcMsg* pMsg) {
|
||||
SEpSet epSet;
|
||||
syncUtilraftId2EpSet(destRaftId, &epSet);
|
||||
if (pSyncNode->FpSendMsg != NULL) {
|
||||
if (pSyncNode->syncSendMSg != NULL) {
|
||||
// htonl
|
||||
syncUtilMsgHtoN(pMsg->pCont);
|
||||
|
||||
pMsg->info.noResp = 1;
|
||||
pSyncNode->FpSendMsg(&epSet, pMsg);
|
||||
pSyncNode->syncSendMSg(&epSet, pMsg);
|
||||
} else {
|
||||
sError("vgId:%d, sync send msg by id error, fp-send-msg is null", pSyncNode->vgId);
|
||||
return -1;
|
||||
|
@ -1594,12 +1483,12 @@ int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pSyncNode, SRp
|
|||
int32_t syncNodeSendMsgByInfo(const SNodeInfo* nodeInfo, SSyncNode* pSyncNode, SRpcMsg* pMsg) {
|
||||
SEpSet epSet;
|
||||
syncUtilnodeInfo2EpSet(nodeInfo, &epSet);
|
||||
if (pSyncNode->FpSendMsg != NULL) {
|
||||
if (pSyncNode->syncSendMSg != NULL) {
|
||||
// htonl
|
||||
syncUtilMsgHtoN(pMsg->pCont);
|
||||
|
||||
pMsg->info.noResp = 1;
|
||||
pSyncNode->FpSendMsg(&epSet, pMsg);
|
||||
pSyncNode->syncSendMSg(&epSet, pMsg);
|
||||
} else {
|
||||
sError("vgId:%d, sync send msg by info error, fp-send-msg is null", pSyncNode->vgId);
|
||||
}
|
||||
|
@ -1623,13 +1512,13 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) {
|
|||
|
||||
snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->msgcb);
|
||||
cJSON_AddStringToObject(pRoot, "rpcClient", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpSendMsg);
|
||||
cJSON_AddStringToObject(pRoot, "FpSendMsg", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->syncSendMSg);
|
||||
cJSON_AddStringToObject(pRoot, "syncSendMSg", u64buf);
|
||||
|
||||
snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->msgcb);
|
||||
cJSON_AddStringToObject(pRoot, "queue", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpEqMsg);
|
||||
cJSON_AddStringToObject(pRoot, "FpEqMsg", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->syncEqMsg);
|
||||
cJSON_AddStringToObject(pRoot, "syncEqMsg", u64buf);
|
||||
|
||||
// init internal
|
||||
cJSON* pMe = syncUtilNodeInfo2Json(&pSyncNode->myNodeInfo);
|
||||
|
@ -1669,7 +1558,7 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) {
|
|||
|
||||
// tla+ server vars
|
||||
cJSON_AddNumberToObject(pRoot, "state", pSyncNode->state);
|
||||
cJSON_AddStringToObject(pRoot, "state_str", syncUtilState2String(pSyncNode->state));
|
||||
cJSON_AddStringToObject(pRoot, "state_str", syncStr(pSyncNode->state));
|
||||
cJSON_AddItemToObject(pRoot, "pRaftStore", raftStore2Json(pSyncNode->pRaftStore));
|
||||
|
||||
// tla+ candidate vars
|
||||
|
@ -1809,7 +1698,7 @@ inline void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
|
|||
"stgy:%d, bch:%d, "
|
||||
"r-num:%d, "
|
||||
"lcfg:%" PRId64 ", chging:%d, rsto:%d, dquorum:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s, %s",
|
||||
pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm,
|
||||
pSyncNode->vgId, syncStr(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm,
|
||||
pSyncNode->commitIndex, logBeginIndex, logLastIndex, pSyncNode->minMatchIndex, snapshot.lastApplyIndex,
|
||||
snapshot.lastApplyTerm, pSyncNode->pRaftCfg->isStandBy, pSyncNode->pRaftCfg->snapshotStrategy,
|
||||
pSyncNode->pRaftCfg->batchSize, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex,
|
||||
|
@ -1833,7 +1722,7 @@ inline void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
|
|||
"stgy:%d, bch:%d, "
|
||||
"r-num:%d, "
|
||||
"lcfg:%" PRId64 ", chging:%d, rsto:%d, dquorum:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s, %s",
|
||||
pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm,
|
||||
pSyncNode->vgId, syncStr(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm,
|
||||
pSyncNode->commitIndex, logBeginIndex, logLastIndex, pSyncNode->minMatchIndex, snapshot.lastApplyIndex,
|
||||
snapshot.lastApplyTerm, pSyncNode->pRaftCfg->isStandBy, pSyncNode->pRaftCfg->snapshotStrategy,
|
||||
pSyncNode->pRaftCfg->batchSize, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex,
|
||||
|
@ -1887,7 +1776,7 @@ inline void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
|
|||
"stgy:%d, bch:%d, "
|
||||
"r-num:%d, "
|
||||
"lcfg:%" PRId64 ", chging:%d, rsto:%d, dquorum:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s",
|
||||
pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm,
|
||||
pSyncNode->vgId, syncStr(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm,
|
||||
pSyncNode->commitIndex, logBeginIndex, logLastIndex, pSyncNode->minMatchIndex, snapshot.lastApplyIndex,
|
||||
snapshot.lastApplyTerm, pSyncNode->pRaftCfg->isStandBy, pSyncNode->pRaftCfg->snapshotStrategy,
|
||||
pSyncNode->pRaftCfg->batchSize, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex,
|
||||
|
@ -1909,7 +1798,7 @@ inline void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
|
|||
"stgy:%d, bch:%d, "
|
||||
"r-num:%d, "
|
||||
"lcfg:%" PRId64 ", chging:%d, rsto:%d, dquorum:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s",
|
||||
pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm,
|
||||
pSyncNode->vgId, syncStr(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm,
|
||||
pSyncNode->commitIndex, logBeginIndex, logLastIndex, pSyncNode->minMatchIndex, snapshot.lastApplyIndex,
|
||||
snapshot.lastApplyTerm, pSyncNode->pRaftCfg->isStandBy, pSyncNode->pRaftCfg->snapshotStrategy,
|
||||
pSyncNode->pRaftCfg->batchSize, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex,
|
||||
|
@ -1941,9 +1830,9 @@ inline char* syncNode2SimpleStr(const SSyncNode* pSyncNode) {
|
|||
", sby:%d, "
|
||||
"r-num:%d, "
|
||||
"lcfg:%" PRId64 ", chging:%d, rsto:%d",
|
||||
pSyncNode->vgId, syncUtilState2String(pSyncNode->state), pSyncNode->pRaftStore->currentTerm,
|
||||
pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy,
|
||||
pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, pSyncNode->changing, pSyncNode->restoreFinish);
|
||||
pSyncNode->vgId, syncStr(pSyncNode->state), pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex,
|
||||
logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, pSyncNode->replicaNum,
|
||||
pSyncNode->pRaftCfg->lastConfigIndex, pSyncNode->changing, pSyncNode->restoreFinish);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -2223,7 +2112,13 @@ void syncNodeUpdateTermWithoutStepDown(SSyncNode* pSyncNode, SyncTerm term) {
|
|||
}
|
||||
|
||||
void syncNodeStepDown(SSyncNode* pSyncNode, SyncTerm newTerm) {
|
||||
ASSERT(pSyncNode->pRaftStore->currentTerm <= newTerm);
|
||||
if (pSyncNode->pRaftStore->currentTerm > newTerm) {
|
||||
char logBuf[128];
|
||||
snprintf(logBuf, sizeof(logBuf), "step down, ignore, new-term:%" PRIu64 ", current-term:%" PRIu64, newTerm,
|
||||
pSyncNode->pRaftStore->currentTerm);
|
||||
syncNodeEventLog(pSyncNode, logBuf);
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
char logBuf[128];
|
||||
|
@ -2642,8 +2537,8 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) {
|
|||
SRpcMsg rpcMsg;
|
||||
syncTimeout2RpcMsg(pSyncMsg, &rpcMsg);
|
||||
syncRpcMsgLog2((char*)"==syncNodeEqPingTimer==", &rpcMsg);
|
||||
if (pSyncNode->FpEqMsg != NULL) {
|
||||
int32_t code = pSyncNode->FpEqMsg(pSyncNode->msgcb, &rpcMsg);
|
||||
if (pSyncNode->syncEqMsg != NULL) {
|
||||
int32_t code = pSyncNode->syncEqMsg(pSyncNode->msgcb, &rpcMsg);
|
||||
if (code != 0) {
|
||||
sError("vgId:%d, sync enqueue ping msg error, code:%d", pSyncNode->vgId, code);
|
||||
rpcFreeCont(rpcMsg.pCont);
|
||||
|
@ -2651,7 +2546,7 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) {
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
sTrace("syncNodeEqPingTimer pSyncNode->FpEqMsg is NULL");
|
||||
sTrace("syncNodeEqPingTimer pSyncNode->syncEqMsg is NULL");
|
||||
}
|
||||
syncTimeoutDestroy(pSyncMsg);
|
||||
|
||||
|
@ -2676,8 +2571,8 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) {
|
|||
pSyncNode->vgId, pSyncNode);
|
||||
SRpcMsg rpcMsg;
|
||||
syncTimeout2RpcMsg(pSyncMsg, &rpcMsg);
|
||||
if (pSyncNode->FpEqMsg != NULL && pSyncNode->msgcb != NULL && pSyncNode->msgcb->putToQueueFp != NULL) {
|
||||
int32_t code = pSyncNode->FpEqMsg(pSyncNode->msgcb, &rpcMsg);
|
||||
if (pSyncNode->syncEqMsg != NULL && pSyncNode->msgcb != NULL && pSyncNode->msgcb->putToQueueFp != NULL) {
|
||||
int32_t code = pSyncNode->syncEqMsg(pSyncNode->msgcb, &rpcMsg);
|
||||
if (code != 0) {
|
||||
sError("vgId:%d, sync enqueue elect msg error, code:%d", pSyncNode->vgId, code);
|
||||
rpcFreeCont(rpcMsg.pCont);
|
||||
|
@ -2693,7 +2588,7 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) {
|
|||
} while (0);
|
||||
|
||||
} else {
|
||||
sTrace("syncNodeEqElectTimer FpEqMsg is NULL");
|
||||
sTrace("syncNodeEqElectTimer syncEqMsg is NULL");
|
||||
}
|
||||
|
||||
syncTimeoutDestroy(pSyncMsg);
|
||||
|
@ -2725,8 +2620,8 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
|
|||
SRpcMsg rpcMsg;
|
||||
syncTimeout2RpcMsg(pSyncMsg, &rpcMsg);
|
||||
syncRpcMsgLog2((char*)"==syncNodeEqHeartbeatTimer==", &rpcMsg);
|
||||
if (pSyncNode->FpEqMsg != NULL) {
|
||||
int32_t code = pSyncNode->FpEqMsg(pSyncNode->msgcb, &rpcMsg);
|
||||
if (pSyncNode->syncEqMsg != NULL) {
|
||||
int32_t code = pSyncNode->syncEqMsg(pSyncNode->msgcb, &rpcMsg);
|
||||
if (code != 0) {
|
||||
sError("vgId:%d, sync enqueue timer msg error, code:%d", pSyncNode->vgId, code);
|
||||
rpcFreeCont(rpcMsg.pCont);
|
||||
|
@ -2734,7 +2629,7 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
sError("vgId:%d, enqueue msg cb ptr (i.e. FpEqMsg) not set.", pSyncNode->vgId);
|
||||
sError("vgId:%d, enqueue msg cb ptr (i.e. syncEqMsg) not set.", pSyncNode->vgId);
|
||||
}
|
||||
syncTimeoutDestroy(pSyncMsg);
|
||||
|
||||
|
@ -2781,8 +2676,8 @@ static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) {
|
|||
|
||||
// eq msg
|
||||
#if 0
|
||||
if (pSyncNode->FpEqCtrlMsg != NULL) {
|
||||
int32_t code = pSyncNode->FpEqCtrlMsg(pSyncNode->msgcb, &rpcMsg);
|
||||
if (pSyncNode->syncEqCtrlMsg != NULL) {
|
||||
int32_t code = pSyncNode->syncEqCtrlMsg(pSyncNode->msgcb, &rpcMsg);
|
||||
if (code != 0) {
|
||||
sError("vgId:%d, sync ctrl enqueue timer msg error, code:%d", pSyncNode->vgId, code);
|
||||
rpcFreeCont(rpcMsg.pCont);
|
||||
|
@ -2790,7 +2685,7 @@ static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) {
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
sError("vgId:%d, enqueue ctrl msg cb ptr (i.e. FpEqMsg) not set.", pSyncNode->vgId);
|
||||
sError("vgId:%d, enqueue ctrl msg cb ptr (i.e. syncEqMsg) not set.", pSyncNode->vgId);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2830,10 +2725,10 @@ static int32_t syncNodeEqNoop(SSyncNode* ths) {
|
|||
|
||||
SRpcMsg rpcMsg = {0};
|
||||
syncClientRequest2RpcMsg(pSyncMsg, &rpcMsg);
|
||||
if (ths->FpEqMsg != NULL) {
|
||||
ths->FpEqMsg(ths->msgcb, &rpcMsg);
|
||||
if (ths->syncEqMsg != NULL) {
|
||||
ths->syncEqMsg(ths->msgcb, &rpcMsg);
|
||||
} else {
|
||||
sTrace("syncNodeEqNoop pSyncNode->FpEqMsg is NULL");
|
||||
sTrace("syncNodeEqNoop pSyncNode->syncEqMsg is NULL");
|
||||
}
|
||||
|
||||
syncEntryDestory(pEntry);
|
||||
|
@ -2944,8 +2839,8 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, SyncHeartbeat* pMsg) {
|
|||
SRpcMsg rpcMsgLocalCmd;
|
||||
syncLocalCmd2RpcMsg(pSyncMsg, &rpcMsgLocalCmd);
|
||||
|
||||
if (ths->FpEqMsg != NULL && ths->msgcb != NULL) {
|
||||
int32_t code = ths->FpEqMsg(ths->msgcb, &rpcMsgLocalCmd);
|
||||
if (ths->syncEqMsg != NULL && ths->msgcb != NULL) {
|
||||
int32_t code = ths->syncEqMsg(ths->msgcb, &rpcMsgLocalCmd);
|
||||
if (code != 0) {
|
||||
sError("vgId:%d, sync enqueue step-down msg error, code:%d", ths->vgId, code);
|
||||
rpcFreeCont(rpcMsgLocalCmd.pCont);
|
||||
|
@ -3127,17 +3022,18 @@ int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftEntry* p
|
|||
}
|
||||
|
||||
if (ths->pFsm->FpLeaderTransferCb != NULL) {
|
||||
SFsmCbMeta cbMeta = {0};
|
||||
cbMeta.code = 0;
|
||||
cbMeta.currentTerm = ths->pRaftStore->currentTerm;
|
||||
cbMeta.flag = 0;
|
||||
cbMeta.index = pEntry->index;
|
||||
cbMeta.lastConfigIndex = syncNodeGetSnapshotConfigIndex(ths, cbMeta.index);
|
||||
cbMeta.isWeak = pEntry->isWeak;
|
||||
cbMeta.seqNum = pEntry->seqNum;
|
||||
cbMeta.state = ths->state;
|
||||
cbMeta.term = pEntry->term;
|
||||
ths->pFsm->FpLeaderTransferCb(ths->pFsm, pRpcMsg, cbMeta);
|
||||
SFsmCbMeta cbMeta = {
|
||||
cbMeta.code = 0,
|
||||
cbMeta.currentTerm = ths->pRaftStore->currentTerm,
|
||||
cbMeta.flag = 0,
|
||||
cbMeta.index = pEntry->index,
|
||||
cbMeta.lastConfigIndex = syncNodeGetSnapshotConfigIndex(ths, pEntry->index),
|
||||
cbMeta.isWeak = pEntry->isWeak,
|
||||
cbMeta.seqNum = pEntry->seqNum,
|
||||
cbMeta.state = ths->state,
|
||||
cbMeta.term = pEntry->term,
|
||||
};
|
||||
ths->pFsm->FpLeaderTransferCb(ths->pFsm, pRpcMsg, &cbMeta);
|
||||
}
|
||||
|
||||
syncLeaderTransferDestroy(pSyncLeaderTransfer);
|
||||
|
@ -3315,18 +3211,20 @@ int32_t syncNodeDoCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endInde
|
|||
|
||||
// execute fsm in apply thread, or execute outside syncPropose
|
||||
if (internalExecute) {
|
||||
SFsmCbMeta cbMeta = {0};
|
||||
cbMeta.index = pEntry->index;
|
||||
cbMeta.lastConfigIndex = syncNodeGetSnapshotConfigIndex(ths, cbMeta.index);
|
||||
cbMeta.isWeak = pEntry->isWeak;
|
||||
cbMeta.code = 0;
|
||||
cbMeta.state = ths->state;
|
||||
cbMeta.seqNum = pEntry->seqNum;
|
||||
cbMeta.term = pEntry->term;
|
||||
cbMeta.currentTerm = ths->pRaftStore->currentTerm;
|
||||
cbMeta.flag = flag;
|
||||
SFsmCbMeta cbMeta = {
|
||||
.index = pEntry->index,
|
||||
.lastConfigIndex = syncNodeGetSnapshotConfigIndex(ths, pEntry->index),
|
||||
.isWeak = pEntry->isWeak,
|
||||
.code = 0,
|
||||
.state = ths->state,
|
||||
.seqNum = pEntry->seqNum,
|
||||
.term = pEntry->term,
|
||||
.currentTerm = ths->pRaftStore->currentTerm,
|
||||
.flag = flag,
|
||||
};
|
||||
|
||||
ths->pFsm->FpCommitCb(ths->pFsm, &rpcMsg, cbMeta);
|
||||
syncGetAndDelRespRpc(ths, cbMeta.seqNum, &rpcMsg.info);
|
||||
ths->pFsm->FpCommitCb(ths->pFsm, &rpcMsg, &cbMeta);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2413,7 +2413,7 @@ cJSON* syncApplyMsg2Json(const SyncApplyMsg* pMsg) {
|
|||
cJSON_AddNumberToObject(pRoot, "fsmMeta.isWeak", pMsg->fsmMeta.isWeak);
|
||||
cJSON_AddNumberToObject(pRoot, "fsmMeta.code", pMsg->fsmMeta.code);
|
||||
cJSON_AddNumberToObject(pRoot, "fsmMeta.state", pMsg->fsmMeta.state);
|
||||
cJSON_AddStringToObject(pRoot, "fsmMeta.state.str", syncUtilState2String(pMsg->fsmMeta.state));
|
||||
cJSON_AddStringToObject(pRoot, "fsmMeta.state.str", syncStr(pMsg->fsmMeta.state));
|
||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->fsmMeta.seqNum);
|
||||
cJSON_AddStringToObject(pRoot, "fsmMeta.seqNum", u64buf);
|
||||
|
||||
|
|
|
@ -145,16 +145,17 @@ void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl, bool rsp) {
|
|||
taosArrayPush(delIndexArray, pSeqNum);
|
||||
cnt++;
|
||||
|
||||
SFsmCbMeta cbMeta = {0};
|
||||
cbMeta.index = SYNC_INDEX_INVALID;
|
||||
cbMeta.lastConfigIndex = SYNC_INDEX_INVALID;
|
||||
cbMeta.isWeak = false;
|
||||
cbMeta.code = TSDB_CODE_SYN_TIMEOUT;
|
||||
cbMeta.state = pSyncNode->state;
|
||||
cbMeta.seqNum = *pSeqNum;
|
||||
cbMeta.term = SYNC_TERM_INVALID;
|
||||
cbMeta.currentTerm = pSyncNode->pRaftStore->currentTerm;
|
||||
cbMeta.flag = 0;
|
||||
SFsmCbMeta cbMeta = {
|
||||
cbMeta.index = SYNC_INDEX_INVALID,
|
||||
cbMeta.lastConfigIndex = SYNC_INDEX_INVALID,
|
||||
cbMeta.isWeak = false,
|
||||
cbMeta.code = TSDB_CODE_SYN_TIMEOUT,
|
||||
cbMeta.state = pSyncNode->state,
|
||||
cbMeta.seqNum = *pSeqNum,
|
||||
cbMeta.term = SYNC_TERM_INVALID,
|
||||
cbMeta.currentTerm = pSyncNode->pRaftStore->currentTerm,
|
||||
cbMeta.flag = 0,
|
||||
};
|
||||
|
||||
pStub->rpcMsg.pCont = NULL;
|
||||
pStub->rpcMsg.contLen = 0;
|
||||
|
|
|
@ -176,30 +176,6 @@ char* syncUtilRaftId2Str(const SRaftId* p) {
|
|||
return serialized;
|
||||
}
|
||||
|
||||
const char* syncUtilState2String(ESyncState state) {
|
||||
/*
|
||||
if (state == TAOS_SYNC_STATE_FOLLOWER) {
|
||||
return "TAOS_SYNC_STATE_FOLLOWER";
|
||||
} else if (state == TAOS_SYNC_STATE_CANDIDATE) {
|
||||
return "TAOS_SYNC_STATE_CANDIDATE";
|
||||
} else if (state == TAOS_SYNC_STATE_LEADER) {
|
||||
return "TAOS_SYNC_STATE_LEADER";
|
||||
} else {
|
||||
return "TAOS_SYNC_STATE_UNKNOWN";
|
||||
}
|
||||
*/
|
||||
|
||||
if (state == TAOS_SYNC_STATE_FOLLOWER) {
|
||||
return "follower";
|
||||
} else if (state == TAOS_SYNC_STATE_CANDIDATE) {
|
||||
return "candidate";
|
||||
} else if (state == TAOS_SYNC_STATE_LEADER) {
|
||||
return "leader";
|
||||
} else {
|
||||
return "state_error";
|
||||
}
|
||||
}
|
||||
|
||||
bool syncUtilCanPrint(char c) {
|
||||
if (c >= 32 && c <= 126) {
|
||||
return true;
|
||||
|
|
|
@ -47,8 +47,8 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
|||
snprintf(logBuf, sizeof(logBuf),
|
||||
"==callback== ==CommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s, flag:%" PRIu64
|
||||
", term:%" PRIu64 " \n",
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state),
|
||||
cbMeta.flag, cbMeta.term);
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag,
|
||||
cbMeta.term);
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||
} else {
|
||||
sTrace("==callback== ==CommitCb== do not apply again %" PRId64, cbMeta.index);
|
||||
|
@ -57,10 +57,10 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
|||
|
||||
void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
||||
char logBuf[256] = {0};
|
||||
snprintf(
|
||||
logBuf, sizeof(logBuf),
|
||||
"==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64 "\n",
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), cbMeta.flag);
|
||||
snprintf(logBuf, sizeof(logBuf),
|
||||
"==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64
|
||||
"\n",
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag);
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||
}
|
||||
|
||||
|
@ -68,8 +68,7 @@ void RollBackCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
|||
char logBuf[256];
|
||||
snprintf(logBuf, sizeof(logBuf),
|
||||
"==callback== ==RollBackCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64 "\n",
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state),
|
||||
cbMeta.flag);
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag);
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||
}
|
||||
|
||||
|
@ -195,8 +194,8 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
|
|||
SSyncInfo syncInfo;
|
||||
syncInfo.vgId = vgId;
|
||||
syncInfo.msgcb = &gSyncIO->msgcb;
|
||||
syncInfo.FpSendMsg = syncIOSendMsg;
|
||||
syncInfo.FpEqMsg = syncIOEqMsg;
|
||||
syncInfo.syncSendMSg = syncIOSendMsg;
|
||||
syncInfo.syncEqMsg = syncIOEqMsg;
|
||||
syncInfo.pFsm = createFsm();
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s_sync_replica%d_index%d", path, replicaNum, myIndex);
|
||||
syncInfo.pWal = pWal;
|
||||
|
|
|
@ -45,8 +45,7 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
|||
char logBuf[256] = {0};
|
||||
snprintf(logBuf, sizeof(logBuf),
|
||||
"==callback== ==CommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64 "\n",
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state),
|
||||
cbMeta.flag);
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag);
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||
} else {
|
||||
sTrace("==callback== ==CommitCb== do not apply again %" PRId64, cbMeta.index);
|
||||
|
@ -55,10 +54,10 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
|||
|
||||
void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
||||
char logBuf[256] = {0};
|
||||
snprintf(
|
||||
logBuf, sizeof(logBuf),
|
||||
"==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64 "\n",
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), cbMeta.flag);
|
||||
snprintf(logBuf, sizeof(logBuf),
|
||||
"==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64
|
||||
"\n",
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag);
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||
}
|
||||
|
||||
|
@ -66,8 +65,7 @@ void RollBackCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
|||
char logBuf[256];
|
||||
snprintf(logBuf, sizeof(logBuf),
|
||||
"==callback== ==RollBackCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64 "\n",
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state),
|
||||
cbMeta.flag);
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag);
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||
}
|
||||
|
||||
|
@ -120,8 +118,8 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
|
|||
SSyncInfo syncInfo;
|
||||
syncInfo.vgId = vgId;
|
||||
syncInfo.msgcb = &gSyncIO->msgcb;
|
||||
syncInfo.FpSendMsg = syncIOSendMsg;
|
||||
syncInfo.FpEqMsg = syncIOEqMsg;
|
||||
syncInfo.syncSendMSg = syncIOSendMsg;
|
||||
syncInfo.syncEqMsg = syncIOEqMsg;
|
||||
syncInfo.pFsm = createFsm();
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s_sync_replica%d_index%d", path, replicaNum, myIndex);
|
||||
syncInfo.pWal = pWal;
|
||||
|
|
|
@ -45,8 +45,8 @@ SSyncNode* createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWa
|
|||
SSyncInfo syncInfo;
|
||||
syncInfo.vgId = vgId;
|
||||
syncInfo.msgcb = &gSyncIO->msgcb;
|
||||
syncInfo.FpSendMsg = syncIOSendMsg;
|
||||
syncInfo.FpEqMsg = syncIOEqMsg;
|
||||
syncInfo.syncSendMSg = syncIOSendMsg;
|
||||
syncInfo.syncEqMsg = syncIOEqMsg;
|
||||
syncInfo.pFsm = NULL;
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s_sync_replica%d_index%d", path, replicaNum, myIndex);
|
||||
syncInfo.pWal = pWal;
|
||||
|
|
|
@ -32,8 +32,8 @@ SSyncNode *pSyncNode;
|
|||
SSyncNode *syncNodeInit() {
|
||||
syncInfo.vgId = 1234;
|
||||
syncInfo.msgcb = &gSyncIO->msgcb;
|
||||
syncInfo.FpSendMsg = syncIOSendMsg;
|
||||
syncInfo.FpEqMsg = syncIOEqMsg;
|
||||
syncInfo.syncSendMSg = syncIOSendMsg;
|
||||
syncInfo.syncEqMsg = syncIOEqMsg;
|
||||
syncInfo.pFsm = pFsm;
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./");
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ SSyncFSM* pFsm;
|
|||
|
||||
SSyncNode* syncNodeInit() {
|
||||
syncInfo.vgId = 1234;
|
||||
syncInfo.FpSendMsg = syncIOSendMsg;
|
||||
syncInfo.FpEqMsg = syncIOEqMsg;
|
||||
syncInfo.syncSendMSg = syncIOSendMsg;
|
||||
syncInfo.syncEqMsg = syncIOEqMsg;
|
||||
syncInfo.pFsm = pFsm;
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./");
|
||||
|
||||
|
@ -97,7 +97,7 @@ int main(int argc, char** argv) {
|
|||
SyncPingReply* pSyncMsg = syncPingReplyBuild2(&pSyncNode->myRaftId, &pSyncNode->myRaftId, 1000, "syncEnqTest");
|
||||
SRpcMsg rpcMsg;
|
||||
syncPingReply2RpcMsg(pSyncMsg, &rpcMsg);
|
||||
pSyncNode->FpEqMsg(pSyncNode->msgcb, &rpcMsg);
|
||||
pSyncNode->syncEqMsg(pSyncNode->msgcb, &rpcMsg);
|
||||
taosMsleep(1000);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ SSyncFSM* pFsm;
|
|||
SSyncNode* syncNodeInit() {
|
||||
syncInfo.vgId = 1234;
|
||||
syncInfo.msgcb = &gSyncIO->msgcb;
|
||||
syncInfo.FpSendMsg = syncIOSendMsg;
|
||||
syncInfo.FpEqMsg = syncIOEqMsg;
|
||||
syncInfo.syncSendMSg = syncIOSendMsg;
|
||||
syncInfo.syncEqMsg = syncIOEqMsg;
|
||||
syncInfo.pFsm = pFsm;
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./");
|
||||
|
||||
|
@ -103,7 +103,7 @@ int main(int argc, char** argv) {
|
|||
SEpSet epSet;
|
||||
syncUtilnodeInfo2EpSet(&pSyncNode->myNodeInfo, &epSet);
|
||||
rpcMsg.info.noResp = 1;
|
||||
pSyncNode->FpSendMsg(&epSet, &rpcMsg);
|
||||
pSyncNode->syncSendMSg(&epSet, &rpcMsg);
|
||||
|
||||
taosMsleep(1000);
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ SSyncFSM* pFsm;
|
|||
SSyncNode* syncNodeInit() {
|
||||
syncInfo.vgId = 1234;
|
||||
syncInfo.msgcb = &gSyncIO->msgcb;
|
||||
syncInfo.FpSendMsg = syncIOSendMsg;
|
||||
syncInfo.FpEqMsg = syncIOEqMsg;
|
||||
syncInfo.syncSendMSg = syncIOSendMsg;
|
||||
syncInfo.syncEqMsg = syncIOEqMsg;
|
||||
syncInfo.pFsm = pFsm;
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./sync_init_test");
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ SSyncFSM* pFsm;
|
|||
SSyncNode* syncNodeInit() {
|
||||
syncInfo.vgId = 1234;
|
||||
syncInfo.msgcb = &gSyncIO->msgcb;
|
||||
syncInfo.FpSendMsg = syncIOSendMsg;
|
||||
syncInfo.FpEqMsg = syncIOEqMsg;
|
||||
syncInfo.syncSendMSg = syncIOSendMsg;
|
||||
syncInfo.syncEqMsg = syncIOEqMsg;
|
||||
syncInfo.pFsm = pFsm;
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./");
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ SSyncFSM* pFsm;
|
|||
SSyncNode* syncNodeInit() {
|
||||
syncInfo.vgId = 1234;
|
||||
syncInfo.msgcb = &gSyncIO->msgcb;
|
||||
syncInfo.FpSendMsg = syncIOSendMsg;
|
||||
syncInfo.FpEqMsg = syncIOEqMsg;
|
||||
syncInfo.syncSendMSg = syncIOSendMsg;
|
||||
syncInfo.syncEqMsg = syncIOEqMsg;
|
||||
syncInfo.pFsm = pFsm;
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./");
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ SSyncFSM* pFsm;
|
|||
SSyncNode* syncNodeInit() {
|
||||
syncInfo.vgId = 1234;
|
||||
syncInfo.msgcb = &gSyncIO->msgcb;
|
||||
syncInfo.FpSendMsg = syncIOSendMsg;
|
||||
syncInfo.FpEqMsg = syncIOEqMsg;
|
||||
syncInfo.syncSendMSg = syncIOSendMsg;
|
||||
syncInfo.syncEqMsg = syncIOEqMsg;
|
||||
syncInfo.pFsm = pFsm;
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./");
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
|||
char logBuf[256];
|
||||
snprintf(logBuf, sizeof(logBuf),
|
||||
"==callback== ==CommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state));
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state));
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||
} else {
|
||||
sTrace("==callback== ==CommitCb== do not apply again %" PRId64, cbMeta.index);
|
||||
|
@ -53,7 +53,7 @@ void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta)
|
|||
char logBuf[256];
|
||||
snprintf(logBuf, sizeof(logBuf),
|
||||
"==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state));
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state));
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ void RollBackCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
|||
char logBuf[256];
|
||||
snprintf(logBuf, sizeof(logBuf),
|
||||
"==callback== ==RollBackCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state));
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state));
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||
}
|
||||
|
||||
|
@ -100,8 +100,8 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
|
|||
SSyncInfo syncInfo;
|
||||
syncInfo.vgId = vgId;
|
||||
syncInfo.msgcb = &gSyncIO->msgcb;
|
||||
syncInfo.FpSendMsg = syncIOSendMsg;
|
||||
syncInfo.FpEqMsg = syncIOEqMsg;
|
||||
syncInfo.syncSendMSg = syncIOSendMsg;
|
||||
syncInfo.syncEqMsg = syncIOEqMsg;
|
||||
syncInfo.pFsm = createFsm();
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s_sync_replica%d_index%d", path, replicaNum, myIndex);
|
||||
syncInfo.pWal = pWal;
|
||||
|
|
|
@ -45,7 +45,7 @@ void CommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
|||
char logBuf[256];
|
||||
snprintf(logBuf, sizeof(logBuf),
|
||||
"==callback== ==CommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state));
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state));
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
||||
} else {
|
||||
sTrace("==callback== ==CommitCb== do not apply again %" PRId64, cbMeta.index);
|
||||
|
@ -56,7 +56,7 @@ void PreCommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta)
|
|||
char logBuf[256];
|
||||
snprintf(logBuf, sizeof(logBuf),
|
||||
"==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state));
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state));
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ void RollBackCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
|||
char logBuf[256];
|
||||
snprintf(logBuf, sizeof(logBuf),
|
||||
"==callback== ==RollBackCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state));
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state));
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
||||
}
|
||||
|
||||
|
@ -87,8 +87,8 @@ void initFsm() {
|
|||
SSyncNode *syncNodeInit() {
|
||||
syncInfo.vgId = 1234;
|
||||
syncInfo.msgcb = &gSyncIO->msgcb;
|
||||
syncInfo.FpSendMsg = syncIOSendMsg;
|
||||
syncInfo.FpEqMsg = syncIOEqMsg;
|
||||
syncInfo.syncSendMSg = syncIOSendMsg;
|
||||
syncInfo.syncEqMsg = syncIOEqMsg;
|
||||
syncInfo.pFsm = pFsm;
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", pDir);
|
||||
|
||||
|
@ -204,7 +204,7 @@ int main(int argc, char **argv) {
|
|||
SyncClientRequest *pSyncClientRequest = pMsg1;
|
||||
SRpcMsg rpcMsg;
|
||||
syncClientRequest2RpcMsg(pSyncClientRequest, &rpcMsg);
|
||||
gSyncNode->FpEqMsg(gSyncNode->msgcb, &rpcMsg);
|
||||
gSyncNode->syncEqMsg(gSyncNode->msgcb, &rpcMsg);
|
||||
|
||||
taosMsleep(1000);
|
||||
}
|
||||
|
|
|
@ -44,8 +44,8 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
|||
", term:%" PRIu64
|
||||
" "
|
||||
"currentTerm:%" PRIu64 " \n",
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state),
|
||||
cbMeta.flag, cbMeta.term, cbMeta.currentTerm);
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag,
|
||||
cbMeta.term, cbMeta.currentTerm);
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||
}
|
||||
|
||||
|
@ -56,8 +56,8 @@ void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta)
|
|||
", term:%" PRIu64
|
||||
" "
|
||||
"currentTerm:%" PRIu64 " \n",
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state),
|
||||
cbMeta.flag, cbMeta.term, cbMeta.currentTerm);
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag,
|
||||
cbMeta.term, cbMeta.currentTerm);
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||
}
|
||||
|
||||
|
@ -68,8 +68,8 @@ void RollBackCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
|||
", term:%" PRIu64
|
||||
" "
|
||||
"currentTerm:%" PRIu64 " \n",
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state),
|
||||
cbMeta.flag, cbMeta.term, cbMeta.currentTerm);
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag,
|
||||
cbMeta.term, cbMeta.currentTerm);
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||
}
|
||||
|
||||
|
@ -168,8 +168,8 @@ void LeaderTransferCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbM
|
|||
", isWeak:%d, code:%d, state:%d %s, flag:%" PRIu64 ", term:%" PRIu64
|
||||
" "
|
||||
"currentTerm:%" PRIu64 " \n",
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state),
|
||||
cbMeta.flag, cbMeta.term, cbMeta.currentTerm);
|
||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag,
|
||||
cbMeta.term, cbMeta.currentTerm);
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||
}
|
||||
|
||||
|
@ -217,8 +217,8 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
|
|||
SSyncInfo syncInfo;
|
||||
syncInfo.vgId = vgId;
|
||||
syncInfo.msgcb = &gSyncIO->msgcb;
|
||||
syncInfo.FpSendMsg = syncIOSendMsg;
|
||||
syncInfo.FpEqMsg = syncIOEqMsg;
|
||||
syncInfo.syncSendMSg = syncIOSendMsg;
|
||||
syncInfo.syncEqMsg = syncIOEqMsg;
|
||||
syncInfo.pFsm = createFsm();
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s_sync_replica%d_index%d", path, replicaNum, myIndex);
|
||||
syncInfo.pWal = pWal;
|
||||
|
|
|
@ -28,8 +28,8 @@ SSyncNode* pSyncNode;
|
|||
SSyncNode* syncNodeInit() {
|
||||
syncInfo.vgId = 1234;
|
||||
syncInfo.msgcb = &gSyncIO->msgcb;
|
||||
syncInfo.FpSendMsg = syncIOSendMsg;
|
||||
syncInfo.FpEqMsg = syncIOEqMsg;
|
||||
syncInfo.syncSendMSg = syncIOSendMsg;
|
||||
syncInfo.syncEqMsg = syncIOEqMsg;
|
||||
syncInfo.pFsm = pFsm;
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./");
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ SSyncNode* pSyncNode;
|
|||
SSyncNode* syncNodeInit() {
|
||||
syncInfo.vgId = 1234;
|
||||
syncInfo.msgcb = &gSyncIO->msgcb;
|
||||
syncInfo.FpSendMsg = syncIOSendMsg;
|
||||
syncInfo.FpEqMsg = syncIOEqMsg;
|
||||
syncInfo.syncSendMSg = syncIOSendMsg;
|
||||
syncInfo.syncEqMsg = syncIOEqMsg;
|
||||
syncInfo.pFsm = pFsm;
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./");
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ void CommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
|||
char logBuf[256];
|
||||
snprintf(logBuf, sizeof(logBuf),
|
||||
"==callback== ==CommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state));
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state));
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ void PreCommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta)
|
|||
char logBuf[256];
|
||||
snprintf(logBuf, sizeof(logBuf),
|
||||
"==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state));
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state));
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ void RollBackCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
|||
char logBuf[256];
|
||||
snprintf(logBuf, sizeof(logBuf),
|
||||
"==callback== ==RollBackCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state));
|
||||
cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state));
|
||||
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
||||
}
|
||||
|
||||
|
@ -65,8 +65,8 @@ void initFsm() {
|
|||
SSyncNode *syncNodeInit() {
|
||||
syncInfo.vgId = 1234;
|
||||
syncInfo.msgcb = &gSyncIO->msgcb;
|
||||
syncInfo.FpSendMsg = syncIOSendMsg;
|
||||
syncInfo.FpEqMsg = syncIOEqMsg;
|
||||
syncInfo.syncSendMSg = syncIOSendMsg;
|
||||
syncInfo.syncEqMsg = syncIOEqMsg;
|
||||
syncInfo.pFsm = pFsm;
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", pDir);
|
||||
|
||||
|
@ -179,7 +179,7 @@ int main(int argc, char **argv) {
|
|||
SyncClientRequest *pSyncClientRequest = pMsg1;
|
||||
SRpcMsg rpcMsg;
|
||||
syncClientRequest2RpcMsg(pSyncClientRequest, &rpcMsg);
|
||||
gSyncNode->FpEqMsg(gSyncNode->msgcb, &rpcMsg);
|
||||
gSyncNode->syncEqMsg(gSyncNode->msgcb, &rpcMsg);
|
||||
|
||||
taosMsleep(1000);
|
||||
}
|
||||
|
|
|
@ -1715,16 +1715,20 @@ int tdbBtreeNext(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen) {
|
|||
memcpy(pKey, cd.pKey, cd.kLen);
|
||||
|
||||
if (ppVal) {
|
||||
// TODO: vLen may be zero
|
||||
pVal = tdbRealloc(*ppVal, cd.vLen);
|
||||
if (pVal == NULL) {
|
||||
tdbFree(pKey);
|
||||
return -1;
|
||||
if (cd.vLen > 0) {
|
||||
pVal = tdbRealloc(*ppVal, cd.vLen);
|
||||
if (pVal == NULL) {
|
||||
tdbFree(pKey);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(pVal, cd.pVal, cd.vLen);
|
||||
} else {
|
||||
pVal = NULL;
|
||||
}
|
||||
|
||||
*ppVal = pVal;
|
||||
*vLen = cd.vLen;
|
||||
memcpy(pVal, cd.pVal, cd.vLen);
|
||||
}
|
||||
|
||||
ret = tdbBtcMoveToNext(pBtc);
|
||||
|
|
|
@ -34,6 +34,7 @@ typedef struct {
|
|||
int64_t createTs;
|
||||
int64_t closeTs;
|
||||
int64_t fileSize;
|
||||
int64_t syncedOffset;
|
||||
} SWalFileInfo;
|
||||
|
||||
typedef struct WalIdxEntry {
|
||||
|
@ -66,6 +67,12 @@ static inline int64_t walGetLastFileSize(SWal* pWal) {
|
|||
return pInfo->fileSize;
|
||||
}
|
||||
|
||||
static inline int64_t walGetLastFileCachedSize(SWal* pWal) {
|
||||
if (taosArrayGetSize(pWal->fileInfoSet) == 0) return 0;
|
||||
SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGetLast(pWal->fileInfoSet);
|
||||
return (pInfo->fileSize - pInfo->syncedOffset);
|
||||
}
|
||||
|
||||
static inline int64_t walGetLastFileFirstVer(SWal* pWal) {
|
||||
if (taosArrayGetSize(pWal->fileInfoSet) == 0) return -1;
|
||||
SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGetLast(pWal->fileInfoSet);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "cJSON.h"
|
||||
#include "os.h"
|
||||
#include "taoserror.h"
|
||||
#include "tglobal.h"
|
||||
#include "tutil.h"
|
||||
#include "walInt.h"
|
||||
|
||||
|
@ -65,32 +66,43 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx) {
|
|||
// ensure size as non-negative
|
||||
pFileInfo->fileSize = TMAX(0, pFileInfo->fileSize);
|
||||
|
||||
int64_t stepSize = WAL_SCAN_BUF_SIZE;
|
||||
uint64_t magic = WAL_MAGIC;
|
||||
int64_t walCkHeadSz = sizeof(SWalCkHead);
|
||||
int64_t end = fileSize;
|
||||
int64_t offset = 0;
|
||||
int64_t capacity = 0;
|
||||
int64_t readSize = 0;
|
||||
char* buf = NULL;
|
||||
int64_t found = -1;
|
||||
bool firstTrial = pFileInfo->fileSize < fileSize;
|
||||
int64_t offset = TMIN(pFileInfo->fileSize, fileSize);
|
||||
int64_t offsetForward = offset - stepSize + walCkHeadSz - 1;
|
||||
int64_t offsetBackward = offset;
|
||||
int64_t retVer = -1;
|
||||
int64_t lastEntryBeginOffset = 0;
|
||||
int64_t lastEntryEndOffset = 0;
|
||||
|
||||
// check recover size
|
||||
if (2 * tsWalFsyncDataSizeLimit + offset < end) {
|
||||
wWarn("vgId:%d, possibly corrupted WAL range exceeds size limit (i.e. %" PRId64 " bytes). offset:%" PRId64
|
||||
", end:%" PRId64 ", file:%s",
|
||||
pWal->cfg.vgId, 2 * tsWalFsyncDataSizeLimit, offset, end, fnameStr);
|
||||
}
|
||||
|
||||
// search for the valid last WAL entry, e.g. block by block
|
||||
while (1) {
|
||||
offset = (firstTrial) ? pFileInfo->fileSize : TMAX(0, end - WAL_SCAN_BUF_SIZE);
|
||||
offset = (firstTrial) ? TMIN(fileSize, offsetForward + stepSize - walCkHeadSz + 1)
|
||||
: TMAX(0, offsetBackward - stepSize + walCkHeadSz - 1);
|
||||
end = TMIN(offset + stepSize, fileSize);
|
||||
if (firstTrial) {
|
||||
offsetForward = offset;
|
||||
} else {
|
||||
offsetBackward = offset;
|
||||
}
|
||||
|
||||
ASSERT(offset <= end);
|
||||
readSize = end - offset;
|
||||
capacity = readSize + sizeof(magic);
|
||||
|
||||
int64_t limit = WAL_RECOV_SIZE_LIMIT;
|
||||
if (limit < readSize) {
|
||||
wError("vgId:%d, possibly corrupted WAL range exceeds size limit (i.e. %" PRId64 " bytes). offset:%" PRId64
|
||||
", end:%" PRId64 ", file:%s",
|
||||
pWal->cfg.vgId, limit, offset, end, fnameStr);
|
||||
terrno = TSDB_CODE_WAL_SIZE_LIMIT;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
void* ptr = taosMemoryRealloc(buf, capacity);
|
||||
if (ptr == NULL) {
|
||||
terrno = TSDB_CODE_WAL_OUT_OF_MEMORY;
|
||||
|
@ -127,6 +139,7 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx) {
|
|||
}
|
||||
logContent = (SWalCkHead*)(buf + pos);
|
||||
if (walValidHeadCksum(logContent) != 0) {
|
||||
terrno = TSDB_CODE_WAL_CHKSUM_MISMATCH;
|
||||
wWarn("vgId:%d, failed to validate checksum of wal entry header. offset:%" PRId64 ", file:%s", pWal->cfg.vgId,
|
||||
offset + pos, fnameStr);
|
||||
haystack = buf + pos + 1;
|
||||
|
@ -179,46 +192,47 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx) {
|
|||
}
|
||||
|
||||
// found one
|
||||
found = pos;
|
||||
retVer = logContent->head.version;
|
||||
lastEntryBeginOffset = offset + pos;
|
||||
lastEntryEndOffset = offset + pos + sizeof(SWalCkHead) + logContent->head.bodyLen;
|
||||
|
||||
// try next
|
||||
haystack = buf + pos + 1;
|
||||
}
|
||||
|
||||
if (found >= 0 || offset == 0) break;
|
||||
|
||||
// go backwards, e.g. by at most one WAL scan buf size
|
||||
end = TMIN(offset + walCkHeadSz - 1, fileSize);
|
||||
firstTrial = false;
|
||||
if (end == fileSize) firstTrial = false;
|
||||
if (firstTrial) {
|
||||
if (terrno == TSDB_CODE_SUCCESS) {
|
||||
continue;
|
||||
} else {
|
||||
firstTrial = false;
|
||||
}
|
||||
}
|
||||
if (retVer >= 0 || offset == 0) break;
|
||||
}
|
||||
|
||||
// determine end of last entry
|
||||
SWalCkHead* lastEntry = (found >= 0) ? (SWalCkHead*)(buf + found) : NULL;
|
||||
int64_t retVer = -1;
|
||||
int64_t lastEntryBeginOffset = 0;
|
||||
int64_t lastEntryEndOffset = 0;
|
||||
|
||||
if (lastEntry == NULL) {
|
||||
if (retVer < 0) {
|
||||
terrno = TSDB_CODE_WAL_LOG_NOT_EXIST;
|
||||
} else {
|
||||
retVer = lastEntry->head.version;
|
||||
lastEntryBeginOffset = offset + (int64_t)((char*)lastEntry - (char*)buf);
|
||||
lastEntryEndOffset = lastEntryBeginOffset + sizeof(SWalCkHead) + lastEntry->head.bodyLen;
|
||||
}
|
||||
|
||||
// truncate file
|
||||
if (lastEntryEndOffset != fileSize) {
|
||||
wWarn("vgId:%d, repair meta truncate file %s to %" PRId64 ", orig size %" PRId64, pWal->cfg.vgId, fnameStr,
|
||||
lastEntryEndOffset, fileSize);
|
||||
|
||||
if (taosFtruncateFile(pFile, lastEntryEndOffset) < 0) {
|
||||
wError("failed to truncate file due to %s. file:%s", strerror(errno), fnameStr);
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
if (taosFsyncFile(pFile) < 0) {
|
||||
wError("failed to fsync file due to %s. file:%s", strerror(errno), fnameStr);
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
|
||||
pFileInfo->fileSize = lastEntryEndOffset;
|
||||
|
||||
taosCloseFile(&pFile);
|
||||
|
@ -621,6 +635,7 @@ int walRollFileInfo(SWal* pWal) {
|
|||
pNewInfo->createTs = ts;
|
||||
pNewInfo->closeTs = -1;
|
||||
pNewInfo->fileSize = 0;
|
||||
pNewInfo->syncedOffset = 0;
|
||||
taosArrayPush(pArray, pNewInfo);
|
||||
taosMemoryFree(pNewInfo);
|
||||
return 0;
|
||||
|
@ -771,6 +786,12 @@ static int walFindCurMetaVer(SWal* pWal) {
|
|||
return metaVer;
|
||||
}
|
||||
|
||||
void walUpdateSyncedOffset(SWal* pWal) {
|
||||
SWalFileInfo* pFileInfo = walGetCurFileInfo(pWal);
|
||||
if (pFileInfo == NULL) return;
|
||||
pFileInfo->syncedOffset = pFileInfo->fileSize;
|
||||
}
|
||||
|
||||
int walSaveMeta(SWal* pWal) {
|
||||
int metaVer = walFindCurMetaVer(pWal);
|
||||
char fnameStr[WAL_FILE_LEN];
|
||||
|
@ -790,6 +811,9 @@ int walSaveMeta(SWal* pWal) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
// update synced offset
|
||||
(void)walUpdateSyncedOffset(pWal);
|
||||
|
||||
// flush to a tmpfile
|
||||
n = walBuildTmpMetaName(pWal, tmpFnameStr);
|
||||
ASSERT(n < sizeof(tmpFnameStr) && "Buffer overflow of file name");
|
||||
|
|
|
@ -187,6 +187,13 @@ int32_t walAlter(SWal *pWal, SWalCfg *pCfg) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t walPersist(SWal *pWal) {
|
||||
taosThreadMutexLock(&pWal->mutex);
|
||||
int32_t ret = walSaveMeta(pWal);
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void walClose(SWal *pWal) {
|
||||
taosThreadMutexLock(&pWal->mutex);
|
||||
(void)walSaveMeta(pWal);
|
||||
|
|
|
@ -198,7 +198,7 @@ int32_t walReadSeekVerImpl(SWalReader *pReader, int64_t ver) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
wDebug("vgId:%d, wal version reset from index:%" PRId64 "(invalid:%d) to index:%" PRId64, pReader->pWal->cfg.vgId,
|
||||
wDebug("vgId:%d, wal version reset from %" PRId64 "(invalid:%d) to %" PRId64, pReader->pWal->cfg.vgId,
|
||||
pReader->curVersion, pReader->curInvalid, ver);
|
||||
|
||||
pReader->curVersion = ver;
|
||||
|
@ -347,22 +347,47 @@ static int32_t walSkipFetchBodyNew(SWalReader *pRead) {
|
|||
|
||||
int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead) {
|
||||
int64_t code;
|
||||
int64_t contLen;
|
||||
bool seeked = false;
|
||||
|
||||
wDebug("vgId:%d try to fetch ver %" PRId64 ", first ver:%" PRId64 ", commit ver:%" PRId64 ", last ver:%" PRId64
|
||||
", applied ver:%" PRId64,
|
||||
pRead->pWal->cfg.vgId, ver, pRead->pWal->vers.firstVer, pRead->pWal->vers.commitVer, pRead->pWal->vers.lastVer,
|
||||
pRead->pWal->vers.appliedVer);
|
||||
|
||||
// TODO: valid ver
|
||||
if (ver > pRead->pWal->vers.commitVer) {
|
||||
if (ver > pRead->pWal->vers.appliedVer) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pRead->curInvalid || pRead->curVersion != ver) {
|
||||
code = walReadSeekVer(pRead, ver);
|
||||
if (code < 0) return -1;
|
||||
if (code < 0) {
|
||||
pRead->curVersion = ver;
|
||||
pRead->curInvalid = 1;
|
||||
return -1;
|
||||
}
|
||||
seeked = true;
|
||||
}
|
||||
|
||||
ASSERT(taosValidFile(pRead->pLogFile) == true);
|
||||
|
||||
code = taosReadFile(pRead->pLogFile, pHead, sizeof(SWalCkHead));
|
||||
if (code != sizeof(SWalCkHead)) {
|
||||
return -1;
|
||||
while (1) {
|
||||
contLen = taosReadFile(pRead->pLogFile, pHead, sizeof(SWalCkHead));
|
||||
if (contLen == sizeof(SWalCkHead)) {
|
||||
break;
|
||||
} else if (contLen == 0 && !seeked) {
|
||||
walReadSeekVerImpl(pRead, ver);
|
||||
seeked = true;
|
||||
continue;
|
||||
} else {
|
||||
if (contLen < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
} else {
|
||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||
}
|
||||
ASSERT(0);
|
||||
pRead->curInvalid = 1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
code = walValidHeadCksum(pHead);
|
||||
|
@ -373,13 +398,20 @@ int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
pRead->curInvalid = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t walSkipFetchBody(SWalReader *pRead, const SWalCkHead *pHead) {
|
||||
int64_t code;
|
||||
|
||||
// ASSERT(pRead->curVersion == pHead->head.version);
|
||||
wDebug("vgId:%d skip fetch body %" PRId64 ", first ver:%" PRId64 ", commit ver:%" PRId64 ", last ver:%" PRId64
|
||||
", applied ver:%" PRId64,
|
||||
pRead->pWal->cfg.vgId, pHead->head.version, pRead->pWal->vers.firstVer, pRead->pWal->vers.commitVer,
|
||||
pRead->pWal->vers.lastVer, pRead->pWal->vers.appliedVer);
|
||||
|
||||
ASSERT(pRead->curVersion == pHead->head.version);
|
||||
ASSERT(pRead->curInvalid == 0);
|
||||
|
||||
code = taosLSeekFile(pRead->pLogFile, pHead->head.bodyLen, SEEK_CUR);
|
||||
if (code < 0) {
|
||||
|
@ -397,6 +429,11 @@ int32_t walFetchBody(SWalReader *pRead, SWalCkHead **ppHead) {
|
|||
SWalCont *pReadHead = &((*ppHead)->head);
|
||||
int64_t ver = pReadHead->version;
|
||||
|
||||
wDebug("vgId:%d fetch body %" PRId64 ", first ver:%" PRId64 ", commit ver:%" PRId64 ", last ver:%" PRId64
|
||||
", applied ver:%" PRId64,
|
||||
pRead->pWal->cfg.vgId, ver, pRead->pWal->vers.firstVer, pRead->pWal->vers.commitVer, pRead->pWal->vers.lastVer,
|
||||
pRead->pWal->vers.appliedVer);
|
||||
|
||||
if (pRead->capacity < pReadHead->bodyLen) {
|
||||
SWalCkHead *ptr = (SWalCkHead *)taosMemoryRealloc(*ppHead, sizeof(SWalCkHead) + pReadHead->bodyLen);
|
||||
if (ptr == NULL) {
|
||||
|
@ -409,19 +446,32 @@ int32_t walFetchBody(SWalReader *pRead, SWalCkHead **ppHead) {
|
|||
}
|
||||
|
||||
if (pReadHead->bodyLen != taosReadFile(pRead->pLogFile, pReadHead->body, pReadHead->bodyLen)) {
|
||||
if (pReadHead->bodyLen < 0) {
|
||||
ASSERT(0);
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
wError("vgId:%d, wal fetch body error:%" PRId64 ", read request index:%" PRId64 ", since %s",
|
||||
pRead->pWal->cfg.vgId, pReadHead->version, ver, tstrerror(terrno));
|
||||
} else {
|
||||
wError("vgId:%d, wal fetch body error:%" PRId64 ", read request index:%" PRId64 ", since file corrupted",
|
||||
pRead->pWal->cfg.vgId, pReadHead->version, ver);
|
||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||
}
|
||||
pRead->curInvalid = 1;
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pReadHead->version != ver) {
|
||||
ASSERT(0);
|
||||
wError("vgId:%d, wal fetch body error, index:%" PRId64 ", read request index:%" PRId64, pRead->pWal->cfg.vgId,
|
||||
pRead->pHead->head.version, ver);
|
||||
pReadHead->version, ver);
|
||||
pRead->curInvalid = 1;
|
||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (walValidBodyCksum(*ppHead) != 0) {
|
||||
ASSERT(0);
|
||||
wError("vgId:%d, wal fetch body error, index:%" PRId64 ", since body checksum not passed", pRead->pWal->cfg.vgId,
|
||||
ver);
|
||||
pRead->curInvalid = 1;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "os.h"
|
||||
#include "taoserror.h"
|
||||
#include "tchecksum.h"
|
||||
#include "tglobal.h"
|
||||
#include "walInt.h"
|
||||
|
||||
int32_t walRestoreFromSnapshot(SWal *pWal, int64_t ver) {
|
||||
|
@ -252,23 +253,36 @@ static FORCE_INLINE int32_t walCheckAndRoll(SWal *pWal) {
|
|||
}
|
||||
}
|
||||
|
||||
if (walGetLastFileCachedSize(pWal) > tsWalFsyncDataSizeLimit) {
|
||||
if (walSaveMeta(pWal) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t walBeginSnapshot(SWal *pWal, int64_t ver) {
|
||||
taosThreadMutexLock(&pWal->mutex);
|
||||
|
||||
pWal->vers.verInSnapshotting = ver;
|
||||
wDebug("vgId:%d, wal begin snapshot for version %" PRId64 ", first ver %" PRId64 ", last ver %" PRId64,
|
||||
pWal->cfg.vgId, ver, pWal->vers.firstVer, pWal->vers.lastVer);
|
||||
// check file rolling
|
||||
if (pWal->cfg.retentionPeriod == 0) {
|
||||
taosThreadMutexLock(&pWal->mutex);
|
||||
if (walGetLastFileSize(pWal) != 0) {
|
||||
walRollImpl(pWal);
|
||||
if (walRollImpl(pWal) < 0) {
|
||||
wError("vgId:%d, failed to roll wal files since %s", pWal->cfg.vgId, terrstr());
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
return 0;
|
||||
|
||||
_err:
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t walEndSnapshot(SWal *pWal) {
|
||||
|
|
|
@ -227,9 +227,7 @@ void taosGetSystemInfo() {
|
|||
#ifdef WINDOWS
|
||||
taosGetCpuCores(&tsNumOfCores);
|
||||
taosGetTotalMemory(&tsTotalMemoryKB);
|
||||
|
||||
double tmp1, tmp2, tmp3, tmp4;
|
||||
taosGetCpuUsage(&tmp1, &tmp2);
|
||||
taosGetCpuUsage(NULL, NULL);
|
||||
#elif defined(_TD_DARWIN_64)
|
||||
long physical_pages = sysconf(_SC_PHYS_PAGES);
|
||||
long page_size = sysconf(_SC_PAGESIZE);
|
||||
|
@ -240,9 +238,7 @@ void taosGetSystemInfo() {
|
|||
taosGetProcIOnfos();
|
||||
taosGetCpuCores(&tsNumOfCores);
|
||||
taosGetTotalMemory(&tsTotalMemoryKB);
|
||||
|
||||
double tmp1, tmp2, tmp3, tmp4;
|
||||
taosGetCpuUsage(&tmp1, &tmp2);
|
||||
taosGetCpuUsage(NULL, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -447,8 +443,8 @@ void taosGetCpuUsage(double *cpu_system, double *cpu_engine) {
|
|||
static int64_t curSysTotal = 0;
|
||||
static int64_t curProcTotal = 0;
|
||||
|
||||
*cpu_system = 0;
|
||||
*cpu_engine = 0;
|
||||
if (cpu_system != NULL) *cpu_system = 0;
|
||||
if (cpu_engine != NULL) *cpu_engine = 0;
|
||||
|
||||
SysCpuInfo sysCpu = {0};
|
||||
ProcCpuInfo procCpu = {0};
|
||||
|
@ -458,8 +454,12 @@ void taosGetCpuUsage(double *cpu_system, double *cpu_engine) {
|
|||
curProcTotal = procCpu.utime + procCpu.stime + procCpu.cutime + procCpu.cstime;
|
||||
|
||||
if (curSysTotal > lastSysTotal && curSysUsed >= lastSysUsed && curProcTotal >= lastProcTotal) {
|
||||
*cpu_engine = (curSysUsed - lastSysUsed) / (double)(curSysTotal - lastSysTotal) * 100;
|
||||
*cpu_system = (curProcTotal - lastProcTotal) / (double)(curSysTotal - lastSysTotal) * 100;
|
||||
if (cpu_system != NULL) {
|
||||
*cpu_system = (curSysUsed - lastSysUsed) / (double)(curSysTotal - lastSysTotal) * 100;
|
||||
}
|
||||
if (cpu_engine != NULL) {
|
||||
*cpu_engine = (curProcTotal - lastProcTotal) / (double)(curSysTotal - lastSysTotal) * 100;
|
||||
}
|
||||
}
|
||||
|
||||
lastSysUsed = curSysUsed;
|
||||
|
|
|
@ -94,6 +94,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TIMESTAMP, "Invalid timestamp for
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_MSG_DECODE_ERROR, "Msg decode error")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_NO_AVAIL_DISK, "No available disk")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_NOT_FOUND, "Not found")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_NO_DISKSPACE, "Out of disk space")
|
||||
|
||||
//client
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_OPERATION, "Invalid operation")
|
||||
|
@ -109,7 +110,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_DB_LENGTH, "Database name too lon
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH, "Table name too long")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_CONNECTION, "Invalid connection")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_OUT_OF_MEMORY, "System out of memory")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_DISKSPACE, "System out of disk space")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_QUERY_CACHE_ERASED, "Query cache erased")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_QUERY_CANCELLED, "Query terminated")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_SORTED_RES_TOO_MANY, "Result set too large to be sorted") // too many result for ordered super table projection query
|
||||
|
@ -305,35 +305,14 @@ TAOS_DEFINE_ERROR(TSDB_CODE_NODE_ALREADY_DEPLOYED, "Node already deployed
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_NODE_NOT_DEPLOYED, "Node not deployed")
|
||||
|
||||
// vnode
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_ACTION_IN_PROGRESS, "Action in progress")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_MSG_NOT_PROCESSED, "Message not processed")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_ACTION_NEED_REPROCESSED, "Action need to be reprocessed")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_VGROUP_ID, "Invalid Vgroup ID")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_INIT_FAILED, "Vnode initialization failed")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_DISKSPACE, "System out of disk space")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_DISK_PERMISSIONS, "No write permission for disk files")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_SUCH_FILE_OR_DIR, "Missing data file")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_OUT_OF_MEMORY, "Out of memory")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_APP_ERROR, "Unexpected generic error in vnode")
|
||||
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_IS_FLOWCTRL, "Database memory is full")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_IS_DROPPING, "Database is dropping")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_IS_UPDATING, "Database is updating")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_IS_CLOSING, "Database is closing")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_NOT_SYNCED, "Database suspended")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_WRITE_AUTH, "Database write operation denied")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_IS_SYNCING, "Database is syncing")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_TSDB_STATE, "Invalid tsdb state")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_TB_NOT_EXIST, "Table not exists")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_SMA_NOT_EXIST, "SMA not exists")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_HASH_MISMATCH, "Hash value mismatch")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_TABLE_NOT_EXIST, "Table does not exists")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_TABLE_ACTION, "Invalid table action")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_COL_ALREADY_EXISTS, "Table column already exists")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_TABLE_COL_NOT_EXISTS, "Table column not exists")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_COL_NOT_EXISTS, "Table column not exists")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_COL_SUBSCRIBED, "Table column is subscribed")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_CFG_FILE, "Invalid config file")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_TERM_FILE, "Invalid term file")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_AVAIL_BUFPOOL, "No availabe buffer pool")
|
||||
|
||||
// tsdb
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_TABLE_ID, "Invalid table ID")
|
||||
|
@ -342,7 +321,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION, "Invalid table schema
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TABLE_ALREADY_EXIST, "Table already exists")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_CONFIG, "Invalid configuration")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INIT_FAILED, "Tsdb init failed")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_DISKSPACE, "No diskspace for tsdb")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_DISK_PERMISSIONS, "No permission for disk files")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_FILE_CORRUPTED, "Data file(s) corrupted")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_OUT_OF_MEMORY, "Out of memory")
|
||||
|
@ -368,7 +346,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR, "TDB env open error")
|
|||
// query
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_QHANDLE, "Invalid handle")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_MSG, "Invalid message") // failed to validate the sql expression msg by vnode
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_NO_DISKSPACE, "No diskspace for query")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_OUT_OF_MEMORY, "System out of memory")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_APP_ERROR, "Unexpected generic error in query")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_DUP_JOIN_KEY, "Duplicated join key")
|
||||
|
@ -431,7 +408,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INTERNAL_ERROR, "Sync internal error")
|
|||
//tq
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TQ_INVALID_CONFIG, "TQ invalid config")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TQ_INIT_FAILED, "TQ init falied")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TQ_NO_DISKSPACE, "TQ no disk space")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TQ_NO_DISK_PERMISSIONS, "TQ no disk permissions")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TQ_FILE_CORRUPTED, "TQ file corrupted")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TQ_OUT_OF_MEMORY, "TQ out of memory")
|
||||
|
|
|
@ -45,74 +45,9 @@ if $data(4)[4] != ready then
|
|||
goto step1
|
||||
endi
|
||||
|
||||
return
|
||||
|
||||
return
|
||||
print =============== step2: create database
|
||||
sql create database db vgroups 1 replica 3
|
||||
sql select * from information_schema.ins_databases
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data(db)[4] != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select * from information_schema.ins_dnodes
|
||||
if $data(2)[2] != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data(3)[2] != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data(4)[2] != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
# vnodes
|
||||
sql select * from information_schema.ins_dnodes
|
||||
if $data(2)[2] != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data(3)[2] != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data(4)[2] != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
# v1_dnode
|
||||
$hasleader = 0
|
||||
$x = 0
|
||||
step2:
|
||||
$x = $x + 1
|
||||
sleep 1000
|
||||
if $x == 20 then
|
||||
print ====> dnode not ready!
|
||||
return -1
|
||||
endi
|
||||
sql show db.vgroups
|
||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08
|
||||
if $data(2)[3] != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data(2)[5] != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data(2)[7] != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data(2)[4] == leader then
|
||||
$hasleader = 1
|
||||
endi
|
||||
if $data(2)[6] == leader then
|
||||
$hasleader = 1
|
||||
endi
|
||||
if $data(2)[8] == leader then
|
||||
$hasleader = 1
|
||||
endi
|
||||
if $hasleader != 1 then
|
||||
goto step2
|
||||
endi
|
||||
sql create database db vgroups 33 replica 3
|
||||
|
||||
sql use db;
|
||||
sql create table stb (ts timestamp, c int) tags (t int);
|
||||
|
@ -122,6 +57,8 @@ sql select * from information_schema.ins_stables where db_name = 'db';
|
|||
sql select * from information_schema.ins_tables where db_name = 'db';
|
||||
sql show db.vgroups;
|
||||
|
||||
system sh/exec.sh -n dnode2 -s stop
|
||||
|
||||
return
|
||||
print ======== start back
|
||||
run_back tmp/back.sim
|
||||
|
|
|
@ -31,6 +31,7 @@ class TDTestCase:
|
|||
self.TDDnodes = None
|
||||
tdSql.init(conn.cursor())
|
||||
self.host = socket.gethostname()
|
||||
self.replicaVar = int(replicaVar)
|
||||
|
||||
|
||||
def getBuildPath(self):
|
||||
|
@ -118,6 +119,7 @@ class TDTestCase:
|
|||
rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"]
|
||||
rowsall=rowsPerStb*paraDict['stbNumbers']
|
||||
dbNumbers = 1
|
||||
paraDict['replica'] = self.replicaVar
|
||||
|
||||
tdLog.info("first check dnode and mnode")
|
||||
tdSql.query("select * from information_schema.ins_dnodes;")
|
||||
|
@ -167,8 +169,8 @@ class TDTestCase:
|
|||
threads.append(threading.Thread(target=clusterComCreate.insert_data, args=(newTdSql, paraDict["dbName"],stableName,paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"])))
|
||||
for tr in threads:
|
||||
tr.start()
|
||||
dnode6Port=int(6030+5*100)
|
||||
tdSql.execute("create dnode '%s:%d'"%(hostname,dnode6Port))
|
||||
dnode7Port=int(6030+6*100)
|
||||
tdSql.execute("create dnode '%s:%d'"%(hostname,dnode7Port))
|
||||
clusterComCheck.checkDnodes(dnodeNumbers)
|
||||
for tr in threads:
|
||||
tr.join()
|
||||
|
@ -219,7 +221,7 @@ class TDTestCase:
|
|||
tdSql.checkRows(rowsPerStb)
|
||||
def run(self):
|
||||
# print(self.master_dnode.cfgDict)
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='dnode')
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=6,mnodeNums=3,restartNumbers=2,stopRole='dnode')
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
|
|
|
@ -31,6 +31,7 @@ class TDTestCase:
|
|||
self.TDDnodes = None
|
||||
tdSql.init(conn.cursor())
|
||||
self.host = socket.gethostname()
|
||||
self.replicaVar = int(replicaVar)
|
||||
|
||||
|
||||
def getBuildPath(self):
|
||||
|
@ -118,6 +119,7 @@ class TDTestCase:
|
|||
rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"]
|
||||
rowsall=rowsPerStb*paraDict['stbNumbers']
|
||||
dbNumbers = 1
|
||||
paraDict['replica'] = self.replicaVar
|
||||
|
||||
tdLog.info("first check dnode and mnode")
|
||||
tdSql.query("select * from information_schema.ins_dnodes;")
|
||||
|
@ -157,7 +159,7 @@ class TDTestCase:
|
|||
stableName= '%s_%d'%(paraDict['stbName'],i)
|
||||
newTdSql=tdCom.newTdSql()
|
||||
clusterComCreate.create_ctable(newTdSql, paraDict["dbName"],stableName,stableName, paraDict['ctbNum'])
|
||||
#insert date
|
||||
#insert data
|
||||
for i in range(paraDict['stbNumbers']):
|
||||
stableName= '%s_%d'%(paraDict['stbName'],i)
|
||||
newTdSql=tdCom.newTdSql()
|
||||
|
@ -203,17 +205,19 @@ class TDTestCase:
|
|||
clusterComCheck.checkDbRows(dbNumbers)
|
||||
# clusterComCheck.checkDb(dbNumbers,1,paraDict["dbName"])
|
||||
|
||||
tdSql.execute("use %s" %(paraDict["dbName"]))
|
||||
tdSql.query("show stables")
|
||||
tdSql.checkRows(paraDict["stbNumbers"])
|
||||
# for i in range(paraDict['stbNumbers']):
|
||||
# stableName= '%s_%d'%(paraDict['stbName'],i)
|
||||
# tdSql.query("select * from %s"%stableName)
|
||||
# tdSql.checkRows(rowsPerStb)
|
||||
newTdSql=tdCom.newTdSql()
|
||||
newTdSql.execute("reset query cache")
|
||||
newTdSql.execute("use %s" %(paraDict["dbName"]))
|
||||
newTdSql.query("show %s.stables"%(paraDict["dbName"]))
|
||||
newTdSql.checkRows(paraDict["stbNumbers"])
|
||||
for i in range(paraDict['stbNumbers']):
|
||||
stableName= '%s_%d'%(paraDict['stbName'],i)
|
||||
newTdSql.query("select * from %s"%stableName)
|
||||
newTdSql.checkRows(rowsPerStb)
|
||||
|
||||
def run(self):
|
||||
# print(self.master_dnode.cfgDict)
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode')
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=6,mnodeNums=3,restartNumbers=2,stopRole='dnode')
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
|
|
|
@ -31,6 +31,7 @@ class TDTestCase:
|
|||
self.TDDnodes = None
|
||||
tdSql.init(conn.cursor())
|
||||
self.host = socket.gethostname()
|
||||
self.replicaVar = int(replicaVar)
|
||||
|
||||
|
||||
def getBuildPath(self):
|
||||
|
@ -118,6 +119,7 @@ class TDTestCase:
|
|||
rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"]
|
||||
rowsall=rowsPerStb*paraDict['stbNumbers']
|
||||
dbNumbers = 1
|
||||
paraDict['replica'] = self.replicaVar
|
||||
|
||||
tdLog.info("first check dnode and mnode")
|
||||
tdSql.query("select * from information_schema.ins_dnodes;")
|
||||
|
@ -214,7 +216,7 @@ class TDTestCase:
|
|||
|
||||
def run(self):
|
||||
# print(self.master_dnode.cfgDict)
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode')
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=6,mnodeNums=3,restartNumbers=1,stopRole='dnode')
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
|
|
|
@ -30,7 +30,7 @@ class TDTestCase:
|
|||
self.TDDnodes = None
|
||||
tdSql.init(conn.cursor())
|
||||
self.host = socket.gethostname()
|
||||
|
||||
self.replicaVar=int(replicaVar)
|
||||
|
||||
def getBuildPath(self):
|
||||
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||
|
@ -113,6 +113,7 @@ class TDTestCase:
|
|||
vnodeNumbers = int(dnodeNumbers-mnodeNums)
|
||||
allDbNumbers=(paraDict['dbNumbers']*restartNumbers)
|
||||
allStbNumbers=(paraDict['stbNumbers']*restartNumbers)
|
||||
paraDict['replica'] = self.replicaVar
|
||||
|
||||
tdLog.info("first check dnode and mnode")
|
||||
tdSql.query("select * from information_schema.ins_dnodes;")
|
||||
|
@ -198,7 +199,7 @@ class TDTestCase:
|
|||
|
||||
def run(self):
|
||||
# print(self.master_dnode.cfgDict)
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=10,stopRole='dnode')
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=6,mnodeNums=3,restartNumbers=10,stopRole='dnode')
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
|
|
|
@ -30,7 +30,7 @@ class TDTestCase:
|
|||
self.TDDnodes = None
|
||||
tdSql.init(conn.cursor())
|
||||
self.host = socket.gethostname()
|
||||
|
||||
self.replicaVar = int(replicaVar)
|
||||
|
||||
def getBuildPath(self):
|
||||
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||
|
@ -87,6 +87,7 @@ class TDTestCase:
|
|||
vnodeNumbers = int(dnodeNumbers-mnodeNums)
|
||||
allStbNumbers=(paraDict['stbNumbers']*restartNumbers)
|
||||
dbNumbers = 1
|
||||
paraDict['replica'] = self.replicaVar
|
||||
|
||||
tdLog.info("first check dnode and mnode")
|
||||
tdSql.query("select * from information_schema.ins_dnodes;")
|
||||
|
@ -171,7 +172,7 @@ class TDTestCase:
|
|||
|
||||
def run(self):
|
||||
# print(self.master_dnode.cfgDict)
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='dnode')
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=6,mnodeNums=3,restartNumbers=2,stopRole='dnode')
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
|
|
|
@ -30,7 +30,8 @@ class TDTestCase:
|
|||
self.TDDnodes = None
|
||||
tdSql.init(conn.cursor())
|
||||
self.host = socket.gethostname()
|
||||
self.replicaVar = replicaVar
|
||||
self.replicaVar = int(replicaVar)
|
||||
|
||||
def getBuildPath(self):
|
||||
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
|
@ -87,7 +88,8 @@ class TDTestCase:
|
|||
vnodeNumbers = int(dnodeNumbers-mnodeNums)
|
||||
allDbNumbers=(paraDict['dbNumbers']*restartNumbers)
|
||||
allStbNumbers=(paraDict['stbNumbers']*restartNumbers)
|
||||
paraDict['replica']=int(self.replicaVar)
|
||||
paraDict['replica'] = self.replicaVar
|
||||
|
||||
tdLog.info("first check dnode and mnode")
|
||||
tdSql.query("select * from information_schema.ins_dnodes;")
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
|
@ -171,7 +173,7 @@ class TDTestCase:
|
|||
|
||||
def run(self):
|
||||
# print(self.master_dnode.cfgDict)
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='mnode')
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=6,mnodeNums=3,restartNumbers=1,stopRole='mnode')
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
|
|
|
@ -30,7 +30,7 @@ class TDTestCase:
|
|||
self.TDDnodes = None
|
||||
tdSql.init(conn.cursor())
|
||||
self.host = socket.gethostname()
|
||||
|
||||
self.replicaVar = int(replicaVar)
|
||||
|
||||
def getBuildPath(self):
|
||||
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||
|
@ -112,6 +112,7 @@ class TDTestCase:
|
|||
vnodeNumbers = int(dnodeNumbers-mnodeNums)
|
||||
allStbNumbers=(paraDict['stbNumbers']*restartNumbers)
|
||||
dbNumbers = 1
|
||||
paraDict['replica'] = self.replicaVar
|
||||
|
||||
tdLog.info("first check dnode and mnode")
|
||||
tdSql.query("select * from information_schema.ins_dnodes;")
|
||||
|
@ -197,7 +198,7 @@ class TDTestCase:
|
|||
|
||||
def run(self):
|
||||
# print(self.master_dnode.cfgDict)
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='mnode')
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=6,mnodeNums=3,restartNumbers=2,stopRole='mnode')
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
|
|
|
@ -30,6 +30,7 @@ class TDTestCase:
|
|||
self.TDDnodes = None
|
||||
tdSql.init(conn.cursor())
|
||||
self.host = socket.gethostname()
|
||||
self.replicaVar = int(replicaVar)
|
||||
|
||||
|
||||
def getBuildPath(self):
|
||||
|
@ -88,6 +89,7 @@ class TDTestCase:
|
|||
vnodeNumbers = int(dnodeNumbers-mnodeNums)
|
||||
allDbNumbers=(paraDict['dbNumbers']*restartNumbers)
|
||||
allStbNumbers=(paraDict['stbNumbers']*restartNumbers)
|
||||
paraDict['replica'] = self.replicaVar
|
||||
|
||||
tdLog.info("first check dnode and mnode")
|
||||
tdSql.query("select * from information_schema.ins_dnodes;")
|
||||
|
@ -171,7 +173,7 @@ class TDTestCase:
|
|||
|
||||
def run(self):
|
||||
# print(self.master_dnode.cfgDict)
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=10,stopRole='vnode')
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=6,mnodeNums=3,restartNumbers=10,stopRole='vnode')
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
|
|
|
@ -30,7 +30,7 @@ class TDTestCase:
|
|||
self.TDDnodes = None
|
||||
tdSql.init(conn.cursor())
|
||||
self.host = socket.gethostname()
|
||||
print(tdSql)
|
||||
self.replicaVar = int(replicaVar)
|
||||
|
||||
def getBuildPath(self):
|
||||
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||
|
@ -112,8 +112,8 @@ class TDTestCase:
|
|||
vnodeNumbers = int(dnodeNumbers-mnodeNums)
|
||||
allStbNumbers=(paraDict['stbNumbers']*restartNumbers)
|
||||
dbNumbers = 1
|
||||
paraDict['replica'] = self.replicaVar
|
||||
|
||||
print(tdSql)
|
||||
tdLog.info("first check dnode and mnode")
|
||||
tdSql.query("select * from information_schema.ins_dnodes;")
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
|
@ -175,7 +175,7 @@ class TDTestCase:
|
|||
|
||||
# dnodeNumbers don't include database of schema
|
||||
if clusterComCheck.checkDnodes(dnodeNumbers):
|
||||
tdLog.info("123")
|
||||
tdLog.info("check numbers of dnodes right ")
|
||||
else:
|
||||
print("456")
|
||||
|
||||
|
@ -192,14 +192,15 @@ class TDTestCase:
|
|||
|
||||
tdSql.execute("use %s" %(paraDict["dbName"]))
|
||||
tdSql.query("show stables")
|
||||
tdLog.debug("we find %d stables but exepect to create %d stables "%(tdSql.queryRows,allStbNumbers))
|
||||
# # tdLog.info("check Stable Rows:")
|
||||
tdSql.checkRows(allStbNumbers)
|
||||
|
||||
if self.replicaVar==1:
|
||||
tdSql.checkRows(allStbNumbers)
|
||||
else:
|
||||
tdLog.debug("we find %d stables but exepect to create %d stables "%(tdSql.queryRows,allStbNumbers))
|
||||
|
||||
def run(self):
|
||||
# print(self.master_dnode.cfgDict)
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='vnode')
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=6,mnodeNums=3,restartNumbers=2,stopRole='vnode')
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
|
|
|
@ -47,13 +47,14 @@ class ClusterComCheck:
|
|||
for i in range(dnodeNumbers):
|
||||
if tdSql.queryResult[i][4] == "ready":
|
||||
status+=1
|
||||
tdLog.info(status)
|
||||
# tdLog.info(status)
|
||||
|
||||
if status == dnodeNumbers:
|
||||
tdLog.success("it find cluster with %d dnodes and check that all cluster dnodes are ready within %ds! " % (dnodeNumbers, count))
|
||||
tdLog.success("it find cluster with %d dnodes and check that all cluster dnodes are ready within %ds! " % (dnodeNumbers, count+1))
|
||||
return True
|
||||
count+=1
|
||||
time.sleep(1)
|
||||
count+=1
|
||||
|
||||
else:
|
||||
tdSql.query("select * from information_schema.ins_dnodes")
|
||||
tdLog.debug(tdSql.queryResult)
|
||||
|
@ -74,10 +75,10 @@ class ClusterComCheck:
|
|||
tdLog.debug(tdSql.queryResult)
|
||||
tdLog.exit("we find %d databases but expect %d in clusters! " %(tdSql.queryRows,dbNumbers))
|
||||
|
||||
def checkDb(self,dbNumbers,restartNumber,dbNameIndex):
|
||||
def checkDb(self,dbNumbers,restartNumber,dbNameIndex, timeout=100):
|
||||
count=0
|
||||
alldbNumbers=(dbNumbers*restartNumber)+2
|
||||
while count < 5:
|
||||
while count < timeout:
|
||||
query_status=0
|
||||
for j in range(dbNumbers):
|
||||
for i in range(alldbNumbers):
|
||||
|
@ -87,22 +88,24 @@ class ClusterComCheck:
|
|||
query_status+=1
|
||||
tdLog.debug("check %s_%d that status is ready "%(dbNameIndex,j))
|
||||
else:
|
||||
sleep(1)
|
||||
continue
|
||||
# print(query_status)
|
||||
count+=1
|
||||
if query_status == dbNumbers:
|
||||
tdLog.success(" check %d database and all databases are ready within 5s! " %dbNumbers)
|
||||
tdLog.success(" check %d database and all databases are ready within %ds! " %(dbNumbers,count+1))
|
||||
return True
|
||||
count+=1
|
||||
|
||||
else:
|
||||
tdLog.debug(tdSql.queryResult)
|
||||
tdLog.debug("query status is %d"%query_status)
|
||||
tdLog.exit("database is not ready within 5s")
|
||||
tdLog.exit("database is not ready within %ds"%(timeout+1))
|
||||
|
||||
def checkData(self,dbname,stbname,stableCount,CtableCount,rowsPerSTable,):
|
||||
tdSql.execute("use %s"%dbname)
|
||||
tdSql.query("show stables")
|
||||
tdSql.query("show %s.stables"%dbname)
|
||||
tdSql.checkRows(stableCount)
|
||||
tdSql.query("show tables")
|
||||
tdSql.query("show %s.tables"%dbname)
|
||||
tdSql.checkRows(CtableCount)
|
||||
for i in range(stableCount):
|
||||
tdSql.query("select count(*) from %s%d"%(stbname,i))
|
||||
|
|
|
@ -236,22 +236,29 @@ python3 ./test.py -f 6-cluster/5dnode2mnode.py -N 5 -M 3
|
|||
python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py -N 5 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeStop2Follower.py -N 5 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeStopLoop.py -N 5 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateDb.py -N 5 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py -N 5 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py -N 5 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDbRep3.py -N 6 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDbRep3.py -N 6 -M 3 -n 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateDb.py -N 6 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateDb.py -N 6 -M 3 -n 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py -N 6 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py -N 6 -M 3 -n 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py -N 6 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py -N 6 -M 3 -n 3
|
||||
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateStb.py -N 5 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py -N 5 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateStb.py -N 5 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateStb.py -N 6 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateStb.py -N 6 -M 3 -n 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py -N 6 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py -N 6 -M 3 -n 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateStb.py -N 6 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateStb.py -N 6 -M 3 -n 3
|
||||
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeRestartDnodeInsertData.py -N 5 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeRestartDnodeInsertDataAsync.py -N 5 -M 3
|
||||
# python3 ./test.py -f 6-cluster/5dnode3mnodeRestartMnodeInsertData.py -N 5 -M 3
|
||||
# python3 ./test.py -f 6-cluster/5dnode3mnodeRestartVnodeInsertData.py -N 5 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeRestartDnodeInsertData.py -N 6 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeRestartDnodeInsertData.py -N 6 -M 3 -n 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeRestartDnodeInsertDataAsync.py -N 6 -M 3
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeRestartDnodeInsertDataAsync.py -N 6 -M 3 -n 3
|
||||
|
||||
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 7 -M 3 -C 6
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 7 -M 3 -C 6 -n 3
|
||||
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 6 -M 3 -C 5
|
||||
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py
|
||||
python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py -N 5
|
||||
# TD-19646 python3 test.py -f 6-cluster/5dnode3mnodeStopConnect.py -N 5 -M 3
|
||||
|
|
Loading…
Reference in New Issue