Merge branch '3.0' into feature/stream
This commit is contained in:
commit
15ad147c40
|
@ -175,6 +175,7 @@ def pre_test_build_mac() {
|
||||||
cd ${WK}/debug
|
cd ${WK}/debug
|
||||||
cmake .. -DBUILD_TEST=true -DBUILD_HTTPS=false
|
cmake .. -DBUILD_TEST=true -DBUILD_HTTPS=false
|
||||||
make -j10
|
make -j10
|
||||||
|
ctest -j10 || exit 7
|
||||||
'''
|
'''
|
||||||
sh '''
|
sh '''
|
||||||
date
|
date
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
IF (DEFINED VERNUMBER)
|
IF (DEFINED VERNUMBER)
|
||||||
SET(TD_VER_NUMBER ${VERNUMBER})
|
SET(TD_VER_NUMBER ${VERNUMBER})
|
||||||
ELSE ()
|
ELSE ()
|
||||||
SET(TD_VER_NUMBER "3.0.1.5")
|
SET(TD_VER_NUMBER "3.0.1.6")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (DEFINED VERCOMPATIBLE)
|
IF (DEFINED VERCOMPATIBLE)
|
||||||
|
|
|
@ -7,12 +7,12 @@ title: Table
|
||||||
You create standard tables and subtables with the `CREATE TABLE` statement.
|
You create standard tables and subtables with the `CREATE TABLE` statement.
|
||||||
|
|
||||||
```sql
|
```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 create_subtable_clause
|
||||||
|
|
||||||
CREATE TABLE [IF NOT EXISTS] [db_name.]tb_name (create_definition [, create_definitionn] ...)
|
CREATE TABLE [IF NOT EXISTS] [db_name.]tb_name (create_definition [, create_definition] ...)
|
||||||
[TAGS (create_definition [, create_definitionn] ...)]
|
[TAGS (create_definition [, create_definition] ...)]
|
||||||
[table_options]
|
[table_options]
|
||||||
|
|
||||||
create_subtable_clause: {
|
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;
|
DESCRIBE [db_name.]tb_name;
|
||||||
```
|
```
|
||||||
|
|
|
@ -6,7 +6,7 @@ title: Supertable
|
||||||
## Create a Supertable
|
## Create a Supertable
|
||||||
|
|
||||||
```sql
|
```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:
|
create_definition:
|
||||||
col_name column_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
|
### 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
|
#### Configuration parameters for executing the specified query statement
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,12 @@ description: 对表的各种管理操作
|
||||||
`CREATE TABLE` 语句用于创建普通表和以超级表为模板创建子表。
|
`CREATE TABLE` 语句用于创建普通表和以超级表为模板创建子表。
|
||||||
|
|
||||||
```sql
|
```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 create_subtable_clause
|
||||||
|
|
||||||
CREATE TABLE [IF NOT EXISTS] [db_name.]tb_name (create_definition [, create_definitionn] ...)
|
CREATE TABLE [IF NOT EXISTS] [db_name.]tb_name (create_definition [, create_definition] ...)
|
||||||
[TAGS (create_definition [, create_definitionn] ...)]
|
[TAGS (create_definition [, create_definition] ...)]
|
||||||
[table_options]
|
[table_options]
|
||||||
|
|
||||||
create_subtable_clause: {
|
create_subtable_clause: {
|
||||||
|
|
|
@ -7,7 +7,7 @@ description: 对超级表的各种管理操作
|
||||||
## 创建超级表
|
## 创建超级表
|
||||||
|
|
||||||
```sql
|
```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:
|
create_definition:
|
||||||
col_name column_definition
|
col_name column_definition
|
||||||
|
|
|
@ -224,7 +224,7 @@ GROUP BY 子句中的表达式可以包含表或视图中的任何列,这些
|
||||||
该子句对行进行分组,但不保证结果集的顺序。若要对分组进行排序,请使用 ORDER BY 子句
|
该子句对行进行分组,但不保证结果集的顺序。若要对分组进行排序,请使用 ORDER BY 子句
|
||||||
|
|
||||||
|
|
||||||
## PARTITON BY
|
## PARTITION BY
|
||||||
|
|
||||||
PARTITION BY 子句是 TDengine 特色语法,按 part_list 对数据进行切分,在每个切分的分片中进行计算。
|
PARTITION BY 子句是 TDengine 特色语法,按 part_list 对数据进行切分,在每个切分的分片中进行计算。
|
||||||
|
|
||||||
|
|
|
@ -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 ,单位为秒。
|
||||||
|
|
||||||
|
其它通用参数详见[通用配置参数](#通用配置参数)。
|
||||||
|
|
||||||
#### 执行指定查询语句的配置参数
|
#### 执行指定查询语句的配置参数
|
||||||
|
|
||||||
|
|
|
@ -297,7 +297,6 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
int8_t hashMeta;
|
|
||||||
int64_t uid;
|
int64_t uid;
|
||||||
char* tblFName;
|
char* tblFName;
|
||||||
int32_t numOfRows;
|
int32_t numOfRows;
|
||||||
|
@ -1128,6 +1127,7 @@ typedef struct {
|
||||||
SQnodeLoad qload;
|
SQnodeLoad qload;
|
||||||
SClusterCfg clusterCfg;
|
SClusterCfg clusterCfg;
|
||||||
SArray* pVloads; // array of SVnodeLoad
|
SArray* pVloads; // array of SVnodeLoad
|
||||||
|
int32_t statusSeq;
|
||||||
} SStatusReq;
|
} SStatusReq;
|
||||||
|
|
||||||
int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
|
int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
|
||||||
|
@ -1149,6 +1149,7 @@ typedef struct {
|
||||||
int64_t dnodeVer;
|
int64_t dnodeVer;
|
||||||
SDnodeCfg dnodeCfg;
|
SDnodeCfg dnodeCfg;
|
||||||
SArray* pDnodeEps; // Array of SDnodeEp
|
SArray* pDnodeEps; // Array of SDnodeEp
|
||||||
|
int32_t statusSeq;
|
||||||
} SStatusRsp;
|
} SStatusRsp;
|
||||||
|
|
||||||
int32_t tSerializeSStatusRsp(void* buf, int32_t bufLen, SStatusRsp* pRsp);
|
int32_t tSerializeSStatusRsp(void* buf, int32_t bufLen, SStatusRsp* pRsp);
|
||||||
|
|
|
@ -273,6 +273,8 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_HEARTBEAT, "sync-heartbeat", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_HEARTBEAT, "sync-heartbeat", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_HEARTBEAT_REPLY, "sync-heartbeat-reply", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_HEARTBEAT_REPLY, "sync-heartbeat-reply", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_LOCAL_CMD, "sync-local-cmd", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_LOCAL_CMD, "sync-local-cmd", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SYNC_PRE_SNAPSHOT, "sync-pre-snapshot", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SYNC_PRE_SNAPSHOT_REPLY, "sync-pre-snapshot-reply", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_MAX_MSG, "sync-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_MAX_MSG, "sync-max", NULL, NULL)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_VND_STREAM_MSG)
|
TD_NEW_MSG_SEG(TDMT_VND_STREAM_MSG)
|
||||||
|
|
|
@ -203,13 +203,11 @@ int32_t catalogUpdateTableMeta(SCatalog* pCatalog, STableMetaRsp* rspMsg);
|
||||||
|
|
||||||
int32_t catalogUpdateTableMeta(SCatalog* pCatalog, STableMetaRsp* rspMsg);
|
int32_t catalogUpdateTableMeta(SCatalog* pCatalog, STableMetaRsp* rspMsg);
|
||||||
|
|
||||||
int32_t catalogGetCachedTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableMeta** pTableMeta);
|
int32_t catalogGetCachedTableMeta(SCatalog* pCtg, const SName* pTableName, STableMeta** pTableMeta);
|
||||||
|
|
||||||
int32_t catalogGetCachedSTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName,
|
int32_t catalogGetCachedSTableMeta(SCatalog* pCtg, const SName* pTableName, STableMeta** pTableMeta);
|
||||||
STableMeta** pTableMeta);
|
|
||||||
|
|
||||||
int32_t catalogGetCachedTableHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName,
|
int32_t catalogGetCachedTableHashVgroup(SCatalog* pCtg, const SName* pTableName, SVgroupInfo* pVgroup, bool* exists);
|
||||||
SVgroupInfo* pVgroup, bool* exists);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force refresh DB's local cached vgroup info.
|
* Force refresh DB's local cached vgroup info.
|
||||||
|
@ -309,7 +307,7 @@ int32_t catalogGetUdfInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char* f
|
||||||
int32_t catalogChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, const char* dbFName, AUTH_TYPE type,
|
int32_t catalogChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, const char* dbFName, AUTH_TYPE type,
|
||||||
bool* pass);
|
bool* pass);
|
||||||
|
|
||||||
int32_t catalogChkAuthFromCache(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, const char* dbFName, AUTH_TYPE type,
|
int32_t catalogChkAuthFromCache(SCatalog* pCtg, const char* user, const char* dbFName, AUTH_TYPE type,
|
||||||
bool* pass, bool* exists);
|
bool* pass, bool* exists);
|
||||||
|
|
||||||
int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth);
|
int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth);
|
||||||
|
@ -326,6 +324,10 @@ SMetaData* catalogCloneMetaData(SMetaData* pData);
|
||||||
|
|
||||||
void catalogFreeMetaData(SMetaData* pData);
|
void catalogFreeMetaData(SMetaData* pData);
|
||||||
|
|
||||||
|
int32_t ctgdEnableDebug(char *option, bool enable);
|
||||||
|
|
||||||
|
int32_t ctgdHandleDbgCommand(char *command);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy catalog and relase all resources
|
* Destroy catalog and relase all resources
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -242,13 +242,13 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
||||||
#define SET_META_TYPE_BOTH_TABLE(t) (t) = META_TYPE_BOTH_TABLE
|
#define SET_META_TYPE_BOTH_TABLE(t) (t) = META_TYPE_BOTH_TABLE
|
||||||
|
|
||||||
#define NEED_CLIENT_RM_TBLMETA_ERROR(_code) \
|
#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_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_TAGS_NOT_MATCHED || (_code) == TSDB_CODE_PAR_VALUE_TOO_LONG || \
|
||||||
(_code) == TSDB_CODE_PAR_INVALID_DROP_COL || ((_code) == TSDB_CODE_TDB_INVALID_TABLE_ID))
|
(_code) == TSDB_CODE_PAR_INVALID_DROP_COL || ((_code) == TSDB_CODE_TDB_INVALID_TABLE_ID))
|
||||||
#define NEED_CLIENT_REFRESH_VG_ERROR(_code) \
|
#define NEED_CLIENT_REFRESH_VG_ERROR(_code) \
|
||||||
((_code) == TSDB_CODE_VND_HASH_MISMATCH || (_code) == TSDB_CODE_VND_INVALID_VGROUP_ID)
|
((_code) == TSDB_CODE_VND_HASH_MISMATCH || (_code) == TSDB_CODE_VND_INVALID_VGROUP_ID)
|
||||||
#define NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code) ((_code) == TSDB_CODE_TDB_TABLE_RECREATED)
|
#define NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code) ((_code) == TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER)
|
||||||
#define NEED_CLIENT_HANDLE_ERROR(_code) \
|
#define NEED_CLIENT_HANDLE_ERROR(_code) \
|
||||||
(NEED_CLIENT_RM_TBLMETA_ERROR(_code) || NEED_CLIENT_REFRESH_VG_ERROR(_code) || \
|
(NEED_CLIENT_RM_TBLMETA_ERROR(_code) || NEED_CLIENT_REFRESH_VG_ERROR(_code) || \
|
||||||
NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code))
|
NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code))
|
||||||
|
|
|
@ -25,8 +25,6 @@ extern "C" {
|
||||||
#include "tlrucache.h"
|
#include "tlrucache.h"
|
||||||
#include "tmsgcb.h"
|
#include "tmsgcb.h"
|
||||||
|
|
||||||
extern bool gRaftDetailLog;
|
|
||||||
|
|
||||||
#define SYNC_RESP_TTL_MS 10000000
|
#define SYNC_RESP_TTL_MS 10000000
|
||||||
#define SYNC_SPEED_UP_HB_TIMER 400
|
#define SYNC_SPEED_UP_HB_TIMER 400
|
||||||
#define SYNC_SPEED_UP_AFTER_MS (1000 * 20)
|
#define SYNC_SPEED_UP_AFTER_MS (1000 * 20)
|
||||||
|
@ -39,6 +37,7 @@ extern bool gRaftDetailLog;
|
||||||
#define SYNC_ADD_QUORUM_COUNT 3
|
#define SYNC_ADD_QUORUM_COUNT 3
|
||||||
#define SYNC_MNODE_LOG_RETENTION 10000
|
#define SYNC_MNODE_LOG_RETENTION 10000
|
||||||
#define SYNC_VNODE_LOG_RETENTION 100
|
#define SYNC_VNODE_LOG_RETENTION 100
|
||||||
|
#define SNAPSHOT_MAX_CLOCK_SKEW_MS 1000 * 10
|
||||||
|
|
||||||
#define SYNC_APPEND_ENTRIES_TIMEOUT_MS 10000
|
#define SYNC_APPEND_ENTRIES_TIMEOUT_MS 10000
|
||||||
|
|
||||||
|
@ -132,7 +131,7 @@ typedef struct SSnapshotMeta {
|
||||||
typedef struct SSyncFSM {
|
typedef struct SSyncFSM {
|
||||||
void* data;
|
void* data;
|
||||||
|
|
||||||
void (*FpCommitCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SFsmCbMeta *pMeta);
|
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 (*FpPreCommitCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
||||||
void (*FpRollBackCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
void (*FpRollBackCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
||||||
|
|
||||||
|
@ -202,37 +201,27 @@ typedef struct SSyncInfo {
|
||||||
int32_t (*syncEqCtrlMsg)(const SMsgCb* msgcb, SRpcMsg* pMsg);
|
int32_t (*syncEqCtrlMsg)(const SMsgCb* msgcb, SRpcMsg* pMsg);
|
||||||
} SSyncInfo;
|
} SSyncInfo;
|
||||||
|
|
||||||
int32_t syncInit();
|
typedef struct SSyncState {
|
||||||
void syncCleanUp();
|
ESyncState state;
|
||||||
bool syncIsInit();
|
bool restored;
|
||||||
int64_t syncOpen(SSyncInfo* pSyncInfo);
|
} SSyncState;
|
||||||
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);
|
|
||||||
|
|
||||||
|
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 syncReconfig(int64_t rid, SSyncCfg* pCfg);
|
||||||
int32_t syncLeaderTransfer(int64_t rid);
|
|
||||||
int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex);
|
int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex);
|
||||||
int32_t syncEndSnapshot(int64_t rid);
|
int32_t syncEndSnapshot(int64_t rid);
|
||||||
|
int32_t syncLeaderTransfer(int64_t rid);
|
||||||
int32_t syncStepDown(int64_t rid, SyncTerm newTerm);
|
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* syncUtilState2String(ESyncState state);
|
const char* syncStr(ESyncState state);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_MSG_DECODE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0128)
|
#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_NO_AVAIL_DISK TAOS_DEF_ERROR_CODE(0, 0x0129)
|
||||||
#define TSDB_CODE_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x012A)
|
#define TSDB_CODE_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x012A)
|
||||||
|
#define TSDB_CODE_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x012B)
|
||||||
|
|
||||||
//client
|
//client
|
||||||
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)
|
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)
|
||||||
|
@ -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_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_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_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_CACHE_ERASED TAOS_DEF_ERROR_CODE(0, 0x020E)
|
||||||
#define TSDB_CODE_TSC_QUERY_CANCELLED TAOS_DEF_ERROR_CODE(0, 0x020F)
|
#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)
|
#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)
|
#define TSDB_CODE_NODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x040A)
|
||||||
|
|
||||||
// vnode
|
// 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_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_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_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_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_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_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_NO_AVAIL_BUFPOOL TAOS_DEF_ERROR_CODE(0, 0x0528)
|
||||||
#define TSDB_CODE_VND_INVALID_TERM_FILE TAOS_DEF_ERROR_CODE(0, 0x0529)
|
|
||||||
|
|
||||||
// tsdb
|
// tsdb
|
||||||
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
|
#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_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_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0604)
|
||||||
#define TSDB_CODE_TDB_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0605)
|
#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_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_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0608)
|
||||||
#define TSDB_CODE_TDB_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0609)
|
#define TSDB_CODE_TDB_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0609)
|
||||||
|
@ -361,13 +340,12 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_TDB_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0618)
|
#define TSDB_CODE_TDB_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0618)
|
||||||
#define TSDB_CODE_TDB_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0619)
|
#define TSDB_CODE_TDB_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0619)
|
||||||
#define TSDB_CODE_TDB_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x061A)
|
#define TSDB_CODE_TDB_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x061A)
|
||||||
#define TSDB_CODE_TDB_TABLE_RECREATED TAOS_DEF_ERROR_CODE(0, 0x061B)
|
#define TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER TAOS_DEF_ERROR_CODE(0, 0x061B)
|
||||||
#define TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR TAOS_DEF_ERROR_CODE(0, 0x061C)
|
#define TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR TAOS_DEF_ERROR_CODE(0, 0x061C)
|
||||||
|
|
||||||
// query
|
// query
|
||||||
#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700)
|
#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_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_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_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0704)
|
||||||
#define TSDB_CODE_QRY_DUP_JOIN_KEY TAOS_DEF_ERROR_CODE(0, 0x0705)
|
#define TSDB_CODE_QRY_DUP_JOIN_KEY TAOS_DEF_ERROR_CODE(0, 0x0705)
|
||||||
|
@ -430,7 +408,6 @@ int32_t* taosGetErrno();
|
||||||
// tq
|
// tq
|
||||||
#define TSDB_CODE_TQ_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0A00)
|
#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_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_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_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0A04)
|
||||||
#define TSDB_CODE_TQ_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0A05)
|
#define TSDB_CODE_TQ_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0A05)
|
||||||
|
|
|
@ -211,7 +211,8 @@ elif [[ ${packgeName} =~ "tar" ]];then
|
||||||
|
|
||||||
if [ ${diffNumbers} != 0 ];then
|
if [ ${diffNumbers} != 0 ];then
|
||||||
echoColor R "The number and names of files is different from the previous installation package"
|
echoColor R "The number and names of files is different from the previous installation package"
|
||||||
echoColor Y `cat ${installPath}/diffFile.log`
|
diffLog=`cat ${installPath}/diffFile.log`
|
||||||
|
echoColor Y "${diffLog}"
|
||||||
exit -1
|
exit -1
|
||||||
else
|
else
|
||||||
echoColor G "The number and names of files are the same as previous installation packages"
|
echoColor G "The number and names of files are the same as previous installation packages"
|
||||||
|
|
|
@ -318,6 +318,7 @@ void* createTscObj(const char* user, const char* auth, const char* db, int32_
|
||||||
void destroyTscObj(void* pObj);
|
void destroyTscObj(void* pObj);
|
||||||
STscObj* acquireTscObj(int64_t rid);
|
STscObj* acquireTscObj(int64_t rid);
|
||||||
int32_t releaseTscObj(int64_t rid);
|
int32_t releaseTscObj(int64_t rid);
|
||||||
|
void destroyAppInst(SAppInstInfo *pAppInfo);
|
||||||
|
|
||||||
uint64_t generateRequestId();
|
uint64_t generateRequestId();
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ typedef enum {
|
||||||
STMT_BIND_COL,
|
STMT_BIND_COL,
|
||||||
STMT_ADD_BATCH,
|
STMT_ADD_BATCH,
|
||||||
STMT_EXECUTE,
|
STMT_EXECUTE,
|
||||||
|
STMT_MAX,
|
||||||
} STMT_STATUS;
|
} STMT_STATUS;
|
||||||
|
|
||||||
typedef struct SStmtTableCache {
|
typedef struct SStmtTableCache {
|
||||||
|
@ -94,12 +95,18 @@ typedef struct STscStmt {
|
||||||
STscObj *taos;
|
STscObj *taos;
|
||||||
SCatalog *pCatalog;
|
SCatalog *pCatalog;
|
||||||
int32_t affectedRows;
|
int32_t affectedRows;
|
||||||
|
uint32_t seqId;
|
||||||
|
uint32_t seqIds[STMT_MAX];
|
||||||
|
|
||||||
SStmtSQLInfo sql;
|
SStmtSQLInfo sql;
|
||||||
SStmtExecInfo exec;
|
SStmtExecInfo exec;
|
||||||
SStmtBindInfo bInfo;
|
SStmtBindInfo bInfo;
|
||||||
} STscStmt;
|
} STscStmt;
|
||||||
|
|
||||||
|
extern char *gStmtStatusStr[];
|
||||||
|
|
||||||
|
#define STMT_LOG_SEQ(n) do { (pStmt)->seqId++; (pStmt)->seqIds[n]++; STMT_DLOG("the %dth:%d %s", (pStmt)->seqIds[n], (pStmt)->seqId, gStmtStatusStr[n]); } while (0)
|
||||||
|
|
||||||
#define STMT_STATUS_NE(S) (pStmt->sql.status != STMT_##S)
|
#define STMT_STATUS_NE(S) (pStmt->sql.status != STMT_##S)
|
||||||
#define STMT_STATUS_EQ(S) (pStmt->sql.status == STMT_##S)
|
#define STMT_STATUS_EQ(S) (pStmt->sql.status == STMT_##S)
|
||||||
|
|
||||||
|
@ -128,6 +135,12 @@ typedef struct STscStmt {
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define STMT_ELOG(param, ...) qError("stmt:%p " param, pStmt, __VA_ARGS__)
|
||||||
|
#define STMT_DLOG(param, ...) qDebug("stmt:%p " param, pStmt, __VA_ARGS__)
|
||||||
|
|
||||||
|
#define STMT_ELOG_E(param) qError("stmt:%p " param, pStmt)
|
||||||
|
#define STMT_DLOG_E(param) qDebug("stmt:%p " param, pStmt)
|
||||||
|
|
||||||
TAOS_STMT *stmtInit(STscObj *taos);
|
TAOS_STMT *stmtInit(STscObj *taos);
|
||||||
int stmtClose(TAOS_STMT *stmt);
|
int stmtClose(TAOS_STMT *stmt);
|
||||||
int stmtExec(TAOS_STMT *stmt);
|
int stmtExec(TAOS_STMT *stmt);
|
||||||
|
|
|
@ -133,6 +133,12 @@ STscObj* taos_connect_internal(const char* ip, const char* user, const char* pas
|
||||||
taosThreadMutexInit(&p->qnodeMutex, NULL);
|
taosThreadMutexInit(&p->qnodeMutex, NULL);
|
||||||
p->pTransporter = openTransporter(user, secretEncrypt, tsNumOfCores);
|
p->pTransporter = openTransporter(user, secretEncrypt, tsNumOfCores);
|
||||||
p->pAppHbMgr = appHbMgrInit(p, key);
|
p->pAppHbMgr = appHbMgrInit(p, key);
|
||||||
|
if (NULL == p->pAppHbMgr) {
|
||||||
|
destroyAppInst(p);
|
||||||
|
taosThreadMutexUnlock(&appInfo.mutex);
|
||||||
|
taosMemoryFreeClear(key);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
taosHashPut(appInfo.pInstMap, key, strlen(key), &p, POINTER_BYTES);
|
taosHashPut(appInfo.pInstMap, key, strlen(key), &p, POINTER_BYTES);
|
||||||
p->instKey = key;
|
p->instKey = key;
|
||||||
key = NULL;
|
key = NULL;
|
||||||
|
@ -1266,7 +1272,9 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
|
||||||
pMsgSendInfo->requestObjRefId = pRequest->self;
|
pMsgSendInfo->requestObjRefId = pRequest->self;
|
||||||
pMsgSendInfo->requestId = pRequest->requestId;
|
pMsgSendInfo->requestId = pRequest->requestId;
|
||||||
pMsgSendInfo->fp = getMsgRspHandle(pMsgSendInfo->msgType);
|
pMsgSendInfo->fp = getMsgRspHandle(pMsgSendInfo->msgType);
|
||||||
pMsgSendInfo->param = pRequest;
|
pMsgSendInfo->param = taosMemoryCalloc(1, sizeof(pRequest->self));
|
||||||
|
|
||||||
|
*(int64_t*)pMsgSendInfo->param = pRequest->self;
|
||||||
|
|
||||||
SConnectReq connectReq = {0};
|
SConnectReq connectReq = {0};
|
||||||
STscObj* pObj = pRequest->pTscObj;
|
STscObj* pObj = pRequest->pTscObj;
|
||||||
|
|
|
@ -286,7 +286,8 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
// assert to avoid un-initialization error
|
// assert to avoid un-initialization error
|
||||||
ASSERT(0);
|
tscError("invalid result passed to taos_fetch_row");
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,13 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
SRequestObj* pRequest = param;
|
SRequestObj *pRequest = acquireRequest(*(int64_t*)param);
|
||||||
|
if (NULL == pRequest) {
|
||||||
|
setErrno(pRequest, TSDB_CODE_TSC_DISCONNECTED);
|
||||||
|
tsem_post(&pRequest->body.rspSem);
|
||||||
|
goto End;
|
||||||
|
}
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
setErrno(pRequest, code);
|
setErrno(pRequest, code);
|
||||||
tsem_post(&pRequest->body.rspSem);
|
tsem_post(&pRequest->body.rspSem);
|
||||||
|
@ -55,6 +60,12 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
|
|
||||||
STscObj* pTscObj = pRequest->pTscObj;
|
STscObj* pTscObj = pRequest->pTscObj;
|
||||||
|
|
||||||
|
if (NULL == pTscObj->pAppInfo || NULL == pTscObj->pAppInfo->pAppHbMgr) {
|
||||||
|
setErrno(pRequest, TSDB_CODE_TSC_DISCONNECTED);
|
||||||
|
tsem_post(&pRequest->body.rspSem);
|
||||||
|
goto End;
|
||||||
|
}
|
||||||
|
|
||||||
SConnectRsp connectRsp = {0};
|
SConnectRsp connectRsp = {0};
|
||||||
if (tDeserializeSConnectRsp(pMsg->pData, pMsg->len, &connectRsp) != 0) {
|
if (tDeserializeSConnectRsp(pMsg->pData, pMsg->len, &connectRsp) != 0) {
|
||||||
code = TSDB_CODE_TSC_INVALID_VERSION;
|
code = TSDB_CODE_TSC_INVALID_VERSION;
|
||||||
|
@ -115,10 +126,15 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
|
|
||||||
tscDebug("0x%" PRIx64 " clusterId:%" PRId64 ", totalConn:%" PRId64, pRequest->requestId, connectRsp.clusterId,
|
tscDebug("0x%" PRIx64 " clusterId:%" PRId64 ", totalConn:%" PRId64, pRequest->requestId, connectRsp.clusterId,
|
||||||
pTscObj->pAppInfo->numOfConns);
|
pTscObj->pAppInfo->numOfConns);
|
||||||
|
|
||||||
tsem_post(&pRequest->body.rspSem);
|
tsem_post(&pRequest->body.rspSem);
|
||||||
End:
|
End:
|
||||||
|
|
||||||
|
if (pRequest) {
|
||||||
|
releaseRequest(pRequest->self);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(param);
|
||||||
taosMemoryFree(pMsg->pEpSet);
|
taosMemoryFree(pMsg->pEpSet);
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -1181,7 +1181,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
pVgData = NULL;
|
pVgData = NULL;
|
||||||
pArray = NULL;
|
pArray = NULL;
|
||||||
code = pRequest->code;
|
code = pRequest->code;
|
||||||
if (code == TSDB_CODE_VND_TABLE_NOT_EXIST) {
|
if (code == TSDB_CODE_TDB_TABLE_NOT_EXIST) {
|
||||||
code = TSDB_CODE_SUCCESS;
|
code = TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
#include "clientStmt.h"
|
#include "clientStmt.h"
|
||||||
|
|
||||||
|
char *gStmtStatusStr[] = {"unknown", "init", "prepare", "settbname", "settags", "fetchFields", "bind", "bindCol", "addBatch", "exec"};
|
||||||
|
|
||||||
static int32_t stmtCreateRequest(STscStmt* pStmt) {
|
static int32_t stmtCreateRequest(STscStmt* pStmt) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -21,6 +23,10 @@ static int32_t stmtCreateRequest(STscStmt* pStmt) {
|
||||||
int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) {
|
int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
if (newStatus >= STMT_INIT && newStatus < STMT_MAX) {
|
||||||
|
STMT_LOG_SEQ(newStatus);
|
||||||
|
}
|
||||||
|
|
||||||
switch (newStatus) {
|
switch (newStatus) {
|
||||||
case STMT_PREPARE:
|
case STMT_PREPARE:
|
||||||
break;
|
break;
|
||||||
|
@ -528,13 +534,17 @@ TAOS_STMT* stmtInit(STscObj* taos) {
|
||||||
pStmt->bInfo.needParse = true;
|
pStmt->bInfo.needParse = true;
|
||||||
pStmt->sql.status = STMT_INIT;
|
pStmt->sql.status = STMT_INIT;
|
||||||
|
|
||||||
|
STMT_LOG_SEQ(STMT_INIT);
|
||||||
|
|
||||||
|
tscDebug("stmt:%p initialized", pStmt);
|
||||||
|
|
||||||
return pStmt;
|
return pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
int stmtPrepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
|
int stmtPrepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
tscDebug("stmt start to prepare");
|
STMT_DLOG_E("start to prepare");
|
||||||
|
|
||||||
if (pStmt->sql.status >= STMT_PREPARE) {
|
if (pStmt->sql.status >= STMT_PREPARE) {
|
||||||
STMT_ERR_RET(stmtResetStmt(pStmt));
|
STMT_ERR_RET(stmtResetStmt(pStmt));
|
||||||
|
@ -555,7 +565,7 @@ int stmtPrepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
|
||||||
int stmtSetTbName(TAOS_STMT* stmt, const char* tbName) {
|
int stmtSetTbName(TAOS_STMT* stmt, const char* tbName) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
tscDebug("stmt start to set tbName: %s", tbName);
|
STMT_DLOG("start to set tbName: %s", tbName);
|
||||||
|
|
||||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_SETTBNAME));
|
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_SETTBNAME));
|
||||||
|
|
||||||
|
@ -587,7 +597,7 @@ int stmtSetTbName(TAOS_STMT* stmt, const char* tbName) {
|
||||||
int stmtSetTbTags(TAOS_STMT* stmt, TAOS_MULTI_BIND* tags) {
|
int stmtSetTbTags(TAOS_STMT* stmt, TAOS_MULTI_BIND* tags) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
tscDebug("stmt start to set tbTags");
|
STMT_DLOG_E("start to set tbTags");
|
||||||
|
|
||||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_SETTAGS));
|
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_SETTAGS));
|
||||||
|
|
||||||
|
@ -649,7 +659,7 @@ int stmtFetchColFields(STscStmt* pStmt, int32_t* fieldNum, TAOS_FIELD_E** fields
|
||||||
int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
|
int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
tscDebug("start to bind stmt data, colIdx: %d", colIdx);
|
STMT_DLOG("start to bind stmt data, colIdx: %d", colIdx);
|
||||||
|
|
||||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_BIND));
|
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_BIND));
|
||||||
|
|
||||||
|
@ -743,7 +753,7 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
|
||||||
int stmtAddBatch(TAOS_STMT* stmt) {
|
int stmtAddBatch(TAOS_STMT* stmt) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
tscDebug("stmt start to add batch");
|
STMT_DLOG_E("start to add batch");
|
||||||
|
|
||||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_ADD_BATCH));
|
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_ADD_BATCH));
|
||||||
|
|
||||||
|
@ -756,8 +766,7 @@ int stmtUpdateTableUid(STscStmt* pStmt, SSubmitRsp* pRsp) {
|
||||||
tscDebug("stmt start to update tbUid, blockNum: %d", pRsp->nBlocks);
|
tscDebug("stmt start to update tbUid, blockNum: %d", pRsp->nBlocks);
|
||||||
|
|
||||||
if (pRsp->nBlocks <= 0) {
|
if (pRsp->nBlocks <= 0) {
|
||||||
tscError("invalid submit resp block number %d", pRsp->nBlocks);
|
return TSDB_CODE_SUCCESS;
|
||||||
STMT_ERR_RET(TSDB_CODE_TSC_APP_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t keyLen = 0;
|
size_t keyLen = 0;
|
||||||
|
@ -810,7 +819,7 @@ int stmtExec(TAOS_STMT* stmt) {
|
||||||
SSubmitRsp* pRsp = NULL;
|
SSubmitRsp* pRsp = NULL;
|
||||||
bool autoCreateTbl = pStmt->exec.autoCreateTbl;
|
bool autoCreateTbl = pStmt->exec.autoCreateTbl;
|
||||||
|
|
||||||
tscDebug("stmt start to exec");
|
STMT_DLOG_E("start to exec");
|
||||||
|
|
||||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_EXECUTE));
|
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_EXECUTE));
|
||||||
|
|
||||||
|
@ -885,6 +894,8 @@ int stmtAffectedRowsOnce(TAOS_STMT* stmt) { return ((STscStmt*)stmt)->exec.affec
|
||||||
int stmtIsInsert(TAOS_STMT* stmt, int* insert) {
|
int stmtIsInsert(TAOS_STMT* stmt, int* insert) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
|
STMT_DLOG_E("start is insert");
|
||||||
|
|
||||||
if (pStmt->sql.type) {
|
if (pStmt->sql.type) {
|
||||||
*insert = (STMT_TYPE_INSERT == pStmt->sql.type || STMT_TYPE_MULTI_INSERT == pStmt->sql.type);
|
*insert = (STMT_TYPE_INSERT == pStmt->sql.type || STMT_TYPE_MULTI_INSERT == pStmt->sql.type);
|
||||||
} else {
|
} else {
|
||||||
|
@ -897,6 +908,8 @@ int stmtIsInsert(TAOS_STMT* stmt, int* insert) {
|
||||||
int stmtGetTagFields(TAOS_STMT* stmt, int* nums, TAOS_FIELD_E** fields) {
|
int stmtGetTagFields(TAOS_STMT* stmt, int* nums, TAOS_FIELD_E** fields) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
|
STMT_DLOG_E("start to get tag fields");
|
||||||
|
|
||||||
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
||||||
STMT_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
STMT_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -927,6 +940,8 @@ int stmtGetTagFields(TAOS_STMT* stmt, int* nums, TAOS_FIELD_E** fields) {
|
||||||
int stmtGetColFields(TAOS_STMT* stmt, int* nums, TAOS_FIELD_E** fields) {
|
int stmtGetColFields(TAOS_STMT* stmt, int* nums, TAOS_FIELD_E** fields) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
|
STMT_DLOG_E("start to get col fields");
|
||||||
|
|
||||||
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
||||||
STMT_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
STMT_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -957,6 +972,8 @@ int stmtGetColFields(TAOS_STMT* stmt, int* nums, TAOS_FIELD_E** fields) {
|
||||||
int stmtGetParamNum(TAOS_STMT* stmt, int* nums) {
|
int stmtGetParamNum(TAOS_STMT* stmt, int* nums) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
|
STMT_DLOG_E("start to get param num");
|
||||||
|
|
||||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_FETCH_FIELDS));
|
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_FETCH_FIELDS));
|
||||||
|
|
||||||
if (pStmt->bInfo.needParse && pStmt->sql.runTimes && pStmt->sql.type > 0 &&
|
if (pStmt->bInfo.needParse && pStmt->sql.runTimes && pStmt->sql.type > 0 &&
|
||||||
|
@ -986,6 +1003,8 @@ int stmtGetParamNum(TAOS_STMT* stmt, int* nums) {
|
||||||
int stmtGetParam(TAOS_STMT* stmt, int idx, int* type, int* bytes) {
|
int stmtGetParam(TAOS_STMT* stmt, int idx, int* type, int* bytes) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
|
STMT_DLOG_E("start to get param");
|
||||||
|
|
||||||
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
||||||
STMT_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
STMT_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -1028,6 +1047,8 @@ int stmtGetParam(TAOS_STMT* stmt, int idx, int* type, int* bytes) {
|
||||||
TAOS_RES* stmtUseResult(TAOS_STMT* stmt) {
|
TAOS_RES* stmtUseResult(TAOS_STMT* stmt) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
|
STMT_DLOG_E("start to use result");
|
||||||
|
|
||||||
if (STMT_TYPE_QUERY != pStmt->sql.type) {
|
if (STMT_TYPE_QUERY != pStmt->sql.type) {
|
||||||
tscError("useResult only for query statement");
|
tscError("useResult only for query statement");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -285,7 +285,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int
|
||||||
// ASSERT(finalNumOfRows * pColumnInfoData->info.bytes);
|
// ASSERT(finalNumOfRows * pColumnInfoData->info.bytes);
|
||||||
char* tmp = taosMemoryRealloc(pColumnInfoData->pData, finalNumOfRows * pColumnInfoData->info.bytes);
|
char* tmp = taosMemoryRealloc(pColumnInfoData->pData, finalNumOfRows * pColumnInfoData->info.bytes);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return TSDB_CODE_VND_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
pColumnInfoData->pData = tmp;
|
pColumnInfoData->pData = tmp;
|
||||||
|
@ -1913,6 +1913,22 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
|
||||||
len += snprintf(dumpBuf + len, size - len, " %25s |", pBuf);
|
len += snprintf(dumpBuf + len, size - len, " %25s |", pBuf);
|
||||||
if (len >= size - 1) return dumpBuf;
|
if (len >= size - 1) return dumpBuf;
|
||||||
break;
|
break;
|
||||||
|
case TSDB_DATA_TYPE_TINYINT:
|
||||||
|
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int8_t*)var);
|
||||||
|
if (len >= size - 1) return dumpBuf;
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_UTINYINT:
|
||||||
|
len += snprintf(dumpBuf + len, size - len, " %15d |", *(uint8_t*)var);
|
||||||
|
if (len >= size - 1) return dumpBuf;
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_SMALLINT:
|
||||||
|
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int16_t*)var);
|
||||||
|
if (len >= size - 1) return dumpBuf;
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_USMALLINT:
|
||||||
|
len += snprintf(dumpBuf + len, size - len, " %15d |", *(uint16_t*)var);
|
||||||
|
if (len >= size - 1) return dumpBuf;
|
||||||
|
break;
|
||||||
case TSDB_DATA_TYPE_INT:
|
case TSDB_DATA_TYPE_INT:
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int32_t*)var);
|
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int32_t*)var);
|
||||||
if (len >= size - 1) return dumpBuf;
|
if (len >= size - 1) return dumpBuf;
|
||||||
|
|
|
@ -1020,6 +1020,7 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
||||||
if (tEncodeI64(&encoder, pReq->qload.timeInQueryQueue) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->qload.timeInQueryQueue) < 0) return -1;
|
||||||
if (tEncodeI64(&encoder, pReq->qload.timeInFetchQueue) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->qload.timeInFetchQueue) < 0) return -1;
|
||||||
|
|
||||||
|
if (tEncodeI32(&encoder, pReq->statusSeq) < 0) return -1;
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -1095,6 +1096,7 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
||||||
if (tDecodeI64(&decoder, &pReq->qload.timeInQueryQueue) < 0) return -1;
|
if (tDecodeI64(&decoder, &pReq->qload.timeInQueryQueue) < 0) return -1;
|
||||||
if (tDecodeI64(&decoder, &pReq->qload.timeInFetchQueue) < 0) return -1;
|
if (tDecodeI64(&decoder, &pReq->qload.timeInFetchQueue) < 0) return -1;
|
||||||
|
|
||||||
|
if (tDecodeI32(&decoder, &pReq->statusSeq) < 0) return -1;
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1126,6 +1128,7 @@ int32_t tSerializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) {
|
||||||
if (tEncodeU16(&encoder, pDnodeEp->ep.port) < 0) return -1;
|
if (tEncodeU16(&encoder, pDnodeEp->ep.port) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tEncodeI32(&encoder, pRsp->statusSeq) < 0) return -1;
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -1167,6 +1170,7 @@ int32_t tDeserializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tDecodeI32(&decoder, &pRsp->statusSeq) < 0) return -1;
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -5432,9 +5436,12 @@ static int32_t tEncodeSSubmitBlkRsp(SEncoder *pEncoder, const SSubmitBlkRsp *pBl
|
||||||
if (tStartEncode(pEncoder) < 0) return -1;
|
if (tStartEncode(pEncoder) < 0) return -1;
|
||||||
|
|
||||||
if (tEncodeI32(pEncoder, pBlock->code) < 0) return -1;
|
if (tEncodeI32(pEncoder, pBlock->code) < 0) return -1;
|
||||||
if (tEncodeI8(pEncoder, pBlock->hashMeta) < 0) return -1;
|
|
||||||
if (tEncodeI64(pEncoder, pBlock->uid) < 0) return -1;
|
if (tEncodeI64(pEncoder, pBlock->uid) < 0) return -1;
|
||||||
if (tEncodeCStr(pEncoder, pBlock->tblFName) < 0) return -1;
|
if (pBlock->tblFName) {
|
||||||
|
if (tEncodeCStr(pEncoder, pBlock->tblFName) < 0) return -1;
|
||||||
|
} else {
|
||||||
|
if (tEncodeCStr(pEncoder, "") < 0) return -1;
|
||||||
|
}
|
||||||
if (tEncodeI32v(pEncoder, pBlock->numOfRows) < 0) return -1;
|
if (tEncodeI32v(pEncoder, pBlock->numOfRows) < 0) return -1;
|
||||||
if (tEncodeI32v(pEncoder, pBlock->affectedRows) < 0) return -1;
|
if (tEncodeI32v(pEncoder, pBlock->affectedRows) < 0) return -1;
|
||||||
if (tEncodeI64v(pEncoder, pBlock->sver) < 0) return -1;
|
if (tEncodeI64v(pEncoder, pBlock->sver) < 0) return -1;
|
||||||
|
@ -5451,7 +5458,6 @@ static int32_t tDecodeSSubmitBlkRsp(SDecoder *pDecoder, SSubmitBlkRsp *pBlock) {
|
||||||
if (tStartDecode(pDecoder) < 0) return -1;
|
if (tStartDecode(pDecoder) < 0) return -1;
|
||||||
|
|
||||||
if (tDecodeI32(pDecoder, &pBlock->code) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pBlock->code) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &pBlock->hashMeta) < 0) return -1;
|
|
||||||
if (tDecodeI64(pDecoder, &pBlock->uid) < 0) return -1;
|
if (tDecodeI64(pDecoder, &pBlock->uid) < 0) return -1;
|
||||||
pBlock->tblFName = taosMemoryCalloc(TSDB_TABLE_FNAME_LEN, 1);
|
pBlock->tblFName = taosMemoryCalloc(TSDB_TABLE_FNAME_LEN, 1);
|
||||||
if (NULL == pBlock->tblFName) return -1;
|
if (NULL == pBlock->tblFName) return -1;
|
||||||
|
|
|
@ -31,7 +31,7 @@ static int32_t STSBufUpdateHeader(STSBuf* pTSBuf, STSBufFileHeader* pHeader);
|
||||||
*/
|
*/
|
||||||
STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
|
STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
|
||||||
if (!osTempSpaceAvailable()) {
|
if (!osTempSpaceAvailable()) {
|
||||||
terrno = TSDB_CODE_TSC_NO_DISKSPACE;
|
terrno = TSDB_CODE_NO_DISKSPACE;
|
||||||
// tscError("tmp file created failed since %s", terrstr());
|
// tscError("tmp file created failed since %s", terrstr());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ typedef struct SDnodeMgmt {
|
||||||
GetVnodeLoadsFp getVnodeLoadsFp;
|
GetVnodeLoadsFp getVnodeLoadsFp;
|
||||||
GetMnodeLoadsFp getMnodeLoadsFp;
|
GetMnodeLoadsFp getMnodeLoadsFp;
|
||||||
GetQnodeLoadsFp getQnodeLoadsFp;
|
GetQnodeLoadsFp getQnodeLoadsFp;
|
||||||
|
int32_t statusSeq;
|
||||||
} SDnodeMgmt;
|
} SDnodeMgmt;
|
||||||
|
|
||||||
// dmHandle.c
|
// dmHandle.c
|
||||||
|
|
|
@ -32,9 +32,13 @@ static void dmUpdateDnodeCfg(SDnodeMgmt *pMgmt, SDnodeCfg *pCfg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
||||||
|
const STraceId *trace = &pRsp->info.traceId;
|
||||||
|
dGTrace("status rsp received from mnode, statusSeq:%d code:0x%x", pMgmt->statusSeq, pRsp->code);
|
||||||
|
|
||||||
if (pRsp->code != 0) {
|
if (pRsp->code != 0) {
|
||||||
if (pRsp->code == TSDB_CODE_MND_DNODE_NOT_EXIST && !pMgmt->pData->dropped && pMgmt->pData->dnodeId > 0) {
|
if (pRsp->code == TSDB_CODE_MND_DNODE_NOT_EXIST && !pMgmt->pData->dropped && pMgmt->pData->dnodeId > 0) {
|
||||||
dInfo("dnode:%d, set to dropped since not exist in mnode", pMgmt->pData->dnodeId);
|
dGInfo("dnode:%d, set to dropped since not exist in mnode, statusSeq:%d", pMgmt->pData->dnodeId,
|
||||||
|
pMgmt->statusSeq);
|
||||||
pMgmt->pData->dropped = 1;
|
pMgmt->pData->dropped = 1;
|
||||||
dmWriteEps(pMgmt->pData);
|
dmWriteEps(pMgmt->pData);
|
||||||
}
|
}
|
||||||
|
@ -42,9 +46,9 @@ static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
||||||
SStatusRsp statusRsp = {0};
|
SStatusRsp statusRsp = {0};
|
||||||
if (pRsp->pCont != NULL && pRsp->contLen > 0 &&
|
if (pRsp->pCont != NULL && pRsp->contLen > 0 &&
|
||||||
tDeserializeSStatusRsp(pRsp->pCont, pRsp->contLen, &statusRsp) == 0) {
|
tDeserializeSStatusRsp(pRsp->pCont, pRsp->contLen, &statusRsp) == 0) {
|
||||||
dTrace("status msg received from mnode, dnodeVer:%" PRId64 " saved:%" PRId64, statusRsp.dnodeVer,
|
|
||||||
pMgmt->pData->dnodeVer);
|
|
||||||
if (pMgmt->pData->dnodeVer != statusRsp.dnodeVer) {
|
if (pMgmt->pData->dnodeVer != statusRsp.dnodeVer) {
|
||||||
|
dGInfo("status rsp received from mnode, statusSeq:%d:%d dnodeVer:%" PRId64 ":%" PRId64, pMgmt->statusSeq,
|
||||||
|
statusRsp.statusSeq, pMgmt->pData->dnodeVer, statusRsp.dnodeVer);
|
||||||
pMgmt->pData->dnodeVer = statusRsp.dnodeVer;
|
pMgmt->pData->dnodeVer = statusRsp.dnodeVer;
|
||||||
dmUpdateDnodeCfg(pMgmt, &statusRsp.dnodeCfg);
|
dmUpdateDnodeCfg(pMgmt, &statusRsp.dnodeCfg);
|
||||||
dmUpdateEps(pMgmt->pData, statusRsp.pDnodeEps);
|
dmUpdateEps(pMgmt->pData, statusRsp.pDnodeEps);
|
||||||
|
@ -91,6 +95,9 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
|
|
||||||
(*pMgmt->getQnodeLoadsFp)(&req.qload);
|
(*pMgmt->getQnodeLoadsFp)(&req.qload);
|
||||||
|
|
||||||
|
pMgmt->statusSeq++;
|
||||||
|
req.statusSeq = pMgmt->statusSeq;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSStatusReq(NULL, 0, &req);
|
int32_t contLen = tSerializeSStatusReq(NULL, 0, &req);
|
||||||
void *pHead = rpcMallocCont(contLen);
|
void *pHead = rpcMallocCont(contLen);
|
||||||
tSerializeSStatusReq(pHead, contLen, &req);
|
tSerializeSStatusReq(pHead, contLen, &req);
|
||||||
|
@ -99,13 +106,13 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
SRpcMsg rpcMsg = {.pCont = pHead, .contLen = contLen, .msgType = TDMT_MND_STATUS, .info.ahandle = (void *)0x9527};
|
SRpcMsg rpcMsg = {.pCont = pHead, .contLen = contLen, .msgType = TDMT_MND_STATUS, .info.ahandle = (void *)0x9527};
|
||||||
SRpcMsg rpcRsp = {0};
|
SRpcMsg rpcRsp = {0};
|
||||||
|
|
||||||
dTrace("send status msg to mnode, dnodeVer:%" PRId64, req.dnodeVer);
|
dTrace("send status req to mnode, dnodeVer:%" PRId64 " statusSeq:%d", req.dnodeVer, req.statusSeq);
|
||||||
|
|
||||||
SEpSet epSet = {0};
|
SEpSet epSet = {0};
|
||||||
dmGetMnodeEpSet(pMgmt->pData, &epSet);
|
dmGetMnodeEpSet(pMgmt->pData, &epSet);
|
||||||
rpcSendRecv(pMgmt->msgCb.clientRpc, &epSet, &rpcMsg, &rpcRsp);
|
rpcSendRecv(pMgmt->msgCb.clientRpc, &epSet, &rpcMsg, &rpcRsp);
|
||||||
if (rpcRsp.code != 0) {
|
if (rpcRsp.code != 0) {
|
||||||
dError("failed to send status msg since %s, numOfEps:%d inUse:%d", tstrerror(rpcRsp.code), epSet.numOfEps,
|
dError("failed to send status req since %s, numOfEps:%d inUse:%d", tstrerror(rpcRsp.code), epSet.numOfEps,
|
||||||
epSet.inUse);
|
epSet.inUse);
|
||||||
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
||||||
dDebug("index:%d, mnode ep:%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port);
|
dDebug("index:%d, mnode ep:%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port);
|
||||||
|
|
|
@ -195,6 +195,8 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, mmPutMsgToSyncCtrlQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, mmPutMsgToSyncCtrlQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, mmPutMsgToSyncCtrlQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, mmPutMsgToSyncCtrlQueue, 1) == NULL) goto _OVER;
|
||||||
|
|
|
@ -437,6 +437,9 @@ SArray *vmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
|
||||||
break;
|
break;
|
||||||
case WRITE_QUEUE:
|
case WRITE_QUEUE:
|
||||||
if (!osDataSpaceAvailable()) {
|
if (!osDataSpaceAvailable()) {
|
||||||
terrno = TSDB_CODE_VND_NO_DISKSPACE;
|
terrno = TSDB_CODE_NO_DISKSPACE;
|
||||||
code = terrno;
|
code = terrno;
|
||||||
dError("vgId:%d, msg:%p put into vnode-write queue failed since %s", pVnode->vgId, pMsg, terrstr(code));
|
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)) {
|
} else if ((pMsg->msgType == TDMT_VND_SUBMIT) && (grantCheck(TSDB_GRANT_STORAGE) != TSDB_CODE_SUCCESS)) {
|
||||||
|
|
|
@ -71,17 +71,17 @@ static bool dmCheckDiskSpace() {
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
if (!osDataSpaceAvailable()) {
|
if (!osDataSpaceAvailable()) {
|
||||||
dError("data disk space unavailable, i.e. %s", tsDataDir);
|
dError("data disk space unavailable, i.e. %s", tsDataDir);
|
||||||
terrno = TSDB_CODE_VND_NO_DISKSPACE;
|
terrno = TSDB_CODE_NO_DISKSPACE;
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
if (!osLogSpaceAvailable()) {
|
if (!osLogSpaceAvailable()) {
|
||||||
dError("log disk space unavailable, i.e. %s", tsLogDir);
|
dError("log disk space unavailable, i.e. %s", tsLogDir);
|
||||||
terrno = TSDB_CODE_VND_NO_DISKSPACE;
|
terrno = TSDB_CODE_NO_DISKSPACE;
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
if (!osTempSpaceAvailable()) {
|
if (!osTempSpaceAvailable()) {
|
||||||
dError("temp disk space unavailable, i.e. %s", tsTempDir);
|
dError("temp disk space unavailable, i.e. %s", tsTempDir);
|
||||||
terrno = TSDB_CODE_VND_NO_DISKSPACE;
|
terrno = TSDB_CODE_NO_DISKSPACE;
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -105,6 +105,7 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsReq(pRpc) && pRpc->pCont == NULL) {
|
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;
|
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -133,6 +134,7 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
dGError("msg:%p, type:%s contLen is 0", pRpc, TMSG_INFO(pRpc->msgType));
|
||||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
|
@ -345,6 +345,19 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t dnodeVer = sdbGetTableVer(pMnode->pSdb, SDB_DNODE) + sdbGetTableVer(pMnode->pSdb, SDB_MNODE);
|
||||||
|
int64_t curMs = taosGetTimestampMs();
|
||||||
|
bool online = mndIsDnodeOnline(pDnode, curMs);
|
||||||
|
bool dnodeChanged = (statusReq.dnodeVer == 0) || (statusReq.dnodeVer != dnodeVer);
|
||||||
|
bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
|
||||||
|
bool needCheck = !online || dnodeChanged || reboot;
|
||||||
|
|
||||||
|
pDnode->accessTimes++;
|
||||||
|
pDnode->lastAccessTime = curMs;
|
||||||
|
const STraceId *trace = &pReq->info.traceId;
|
||||||
|
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
||||||
|
pDnode->accessTimes, needCheck, online, reboot, dnodeChanged, statusReq.statusSeq);
|
||||||
|
|
||||||
for (int32_t v = 0; v < taosArrayGetSize(statusReq.pVloads); ++v) {
|
for (int32_t v = 0; v < taosArrayGetSize(statusReq.pVloads); ++v) {
|
||||||
SVnodeLoad *pVload = taosArrayGet(statusReq.pVloads, v);
|
SVnodeLoad *pVload = taosArrayGet(statusReq.pVloads, v);
|
||||||
|
|
||||||
|
@ -396,13 +409,6 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
mndReleaseQnode(pMnode, pQnode);
|
mndReleaseQnode(pMnode, pQnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t dnodeVer = sdbGetTableVer(pMnode->pSdb, SDB_DNODE) + sdbGetTableVer(pMnode->pSdb, SDB_MNODE);
|
|
||||||
int64_t curMs = taosGetTimestampMs();
|
|
||||||
bool online = mndIsDnodeOnline(pDnode, curMs);
|
|
||||||
bool dnodeChanged = (statusReq.dnodeVer == 0) || (statusReq.dnodeVer != dnodeVer);
|
|
||||||
bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
|
|
||||||
bool needCheck = !online || dnodeChanged || reboot;
|
|
||||||
|
|
||||||
if (needCheck) {
|
if (needCheck) {
|
||||||
if (statusReq.sver != tsVersion) {
|
if (statusReq.sver != tsVersion) {
|
||||||
if (pDnode != NULL) {
|
if (pDnode != NULL) {
|
||||||
|
@ -424,9 +430,6 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
pMnode->clusterId);
|
pMnode->clusterId);
|
||||||
terrno = TSDB_CODE_MND_INVALID_CLUSTER_ID;
|
terrno = TSDB_CODE_MND_INVALID_CLUSTER_ID;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
} else {
|
|
||||||
pDnode->accessTimes++;
|
|
||||||
mDebug("dnode:%d, status received, access times %d", pDnode->id, pDnode->accessTimes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,6 +456,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
pDnode->memTotal = statusReq.memTotal;
|
pDnode->memTotal = statusReq.memTotal;
|
||||||
|
|
||||||
SStatusRsp statusRsp = {0};
|
SStatusRsp statusRsp = {0};
|
||||||
|
statusRsp.statusSeq++;
|
||||||
statusRsp.dnodeVer = dnodeVer;
|
statusRsp.dnodeVer = dnodeVer;
|
||||||
statusRsp.dnodeCfg.dnodeId = pDnode->id;
|
statusRsp.dnodeCfg.dnodeId = pDnode->id;
|
||||||
statusRsp.dnodeCfg.clusterId = pMnode->clusterId;
|
statusRsp.dnodeCfg.clusterId = pMnode->clusterId;
|
||||||
|
@ -473,8 +477,6 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
pReq->info.rsp = pHead;
|
pReq->info.rsp = pHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
pDnode->lastAccessTime = curMs;
|
|
||||||
pDnode->accessTimes++;
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
|
|
|
@ -487,14 +487,14 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
if (mndAcquireRpc(pMsg->info.node) == 0) return 0;
|
if (mndAcquireRpc(pMsg->info.node) == 0) return 0;
|
||||||
|
|
||||||
SMnode *pMnode = pMsg->info.node;
|
SMnode *pMnode = pMsg->info.node;
|
||||||
const char *role = syncGetMyRoleStr(pMnode->syncMgmt.sync);
|
SSyncState state = syncGetState(pMnode->syncMgmt.sync);
|
||||||
bool restored = syncIsRestoreFinish(pMnode->syncMgmt.sync);
|
|
||||||
if (pMsg->msgType == TDMT_MND_TMQ_TIMER || pMsg->msgType == TDMT_MND_TELEM_TIMER ||
|
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_TRANS_TIMER || pMsg->msgType == TDMT_MND_TTL_TIMER ||
|
||||||
pMsg->msgType == TDMT_MND_UPTIME_TIMER) {
|
pMsg->msgType == TDMT_MND_UPTIME_TIMER) {
|
||||||
mTrace("timer not process since mnode restored:%d stopped:%d, sync restored:%d role:%s ", pMnode->restored,
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,8 +505,8 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
|
||||||
mDebug(
|
mDebug(
|
||||||
"msg:%p, type:%s failed to process since %s, mnode restored:%d stopped:%d, sync restored:%d "
|
"msg:%p, type:%s failed to process since %s, mnode restored:%d stopped:%d, sync restored:%d "
|
||||||
"role:%s, redirect numOfEps:%d inUse:%d",
|
"role:%s, redirect numOfEps:%d inUse:%d",
|
||||||
pMsg, TMSG_INFO(pMsg->msgType), terrstr(), pMnode->restored, pMnode->stopped, restored, role, epSet.numOfEps,
|
pMsg, TMSG_INFO(pMsg->msgType), terrstr(), pMnode->restored, pMnode->stopped, state.restored,
|
||||||
epSet.inUse);
|
syncStr(state.restored), epSet.numOfEps, epSet.inUse);
|
||||||
|
|
||||||
if (epSet.numOfEps > 0) {
|
if (epSet.numOfEps > 0) {
|
||||||
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
||||||
|
@ -729,8 +729,9 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad) {
|
int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad) {
|
||||||
pLoad->syncState = syncGetMyRole(pMnode->syncMgmt.sync);
|
SSyncState state = syncGetState(pMnode->syncMgmt.sync);
|
||||||
pLoad->syncRestore = pMnode->restored;
|
pLoad->syncState = state.state;
|
||||||
|
pLoad->syncRestore = state.restored;
|
||||||
mTrace("mnode current syncState is %s, syncRestore:%d", syncStr(pLoad->syncState), pLoad->syncRestore);
|
mTrace("mnode current syncState is %s, syncRestore:%d", syncStr(pLoad->syncState), pLoad->syncRestore);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ int32_t mndProcessQueryMsg(SRpcMsg *pMsg) {
|
||||||
code = qWorkerProcessHbMsg(pMnode, pMnode->pQuery, pMsg, 0);
|
code = qWorkerProcessHbMsg(pMnode, pMnode->pQuery, pMsg, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
terrno = TSDB_CODE_VND_APP_ERROR;
|
terrno = TSDB_CODE_APP_ERROR;
|
||||||
mError("unknown msg type:%d in query queue", pMsg->msgType);
|
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) {
|
for (int32_t i = 0; i < msgNum; ++i) {
|
||||||
if (offset >= pMsg->contLen) {
|
if (offset >= pMsg->contLen) {
|
||||||
mError("offset %d is bigger than contLen %d", 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);
|
taosArrayDestroy(batchRsp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
||||||
offset += sizeof(req.msgIdx);
|
offset += sizeof(req.msgIdx);
|
||||||
if (offset >= pMsg->contLen) {
|
if (offset >= pMsg->contLen) {
|
||||||
mError("offset %d is bigger than contLen %d", 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);
|
taosArrayDestroy(batchRsp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
||||||
offset += sizeof(req.msgType);
|
offset += sizeof(req.msgType);
|
||||||
if (offset >= pMsg->contLen) {
|
if (offset >= pMsg->contLen) {
|
||||||
mError("offset %d is bigger than contLen %d", 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);
|
taosArrayDestroy(batchRsp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
||||||
offset += sizeof(req.msgLen);
|
offset += sizeof(req.msgLen);
|
||||||
if (offset >= pMsg->contLen) {
|
if (offset >= pMsg->contLen) {
|
||||||
mError("offset %d is bigger than contLen %d", 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);
|
taosArrayDestroy(batchRsp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -349,11 +349,15 @@ void mndSyncStop(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mndIsLeader(SMnode *pMnode) {
|
bool mndIsLeader(SMnode *pMnode) {
|
||||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
SSyncState state = syncGetState(pMnode->syncMgmt.sync);
|
||||||
|
|
||||||
if (!syncIsReady(pMgmt->sync)) {
|
if (state.state != TAOS_SYNC_STATE_LEADER || !state.restored) {
|
||||||
// get terrno from syncIsReady
|
if (state.state != TAOS_SYNC_STATE_LEADER) {
|
||||||
// terrno = TSDB_CODE_SYN_NOT_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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -265,34 +265,47 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
mError("failed to read sdb file:%s since %s", file, tstrerror(code));
|
mError("failed to read sdb file:%s since %s", file, tstrerror(code));
|
||||||
break;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret != readLen) {
|
if (ret != readLen) {
|
||||||
code = TSDB_CODE_FILE_CORRUPTED;
|
code = TSDB_CODE_FILE_CORRUPTED;
|
||||||
mError("failed to read sdb file:%s since %s", file, tstrerror(code));
|
mError("failed to read sdb file:%s since %s, ret:%" PRId64 " != readLen:%d", file, tstrerror(code), ret, readLen);
|
||||||
break;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
readLen = pRaw->dataLen + sizeof(int32_t);
|
readLen = pRaw->dataLen + sizeof(int32_t);
|
||||||
|
if (readLen >= pRaw->dataLen) {
|
||||||
|
SSdbRaw *pNewRaw = taosMemoryMalloc(pRaw->dataLen + TSDB_MAX_MSG_SIZE);
|
||||||
|
if (pNewRaw == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
mError("failed read sdb file since malloc new sdbRaw size:%d failed", pRaw->dataLen + TSDB_MAX_MSG_SIZE);
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
mInfo("malloc new sdbRaw size:%d, type:%d", pRaw->dataLen + TSDB_MAX_MSG_SIZE, pRaw->type);
|
||||||
|
memcpy(pNewRaw, pRaw, sizeof(SSdbRaw));
|
||||||
|
sdbFreeRaw(pRaw);
|
||||||
|
pRaw = pNewRaw;
|
||||||
|
}
|
||||||
|
|
||||||
ret = taosReadFile(pFile, pRaw->pData, readLen);
|
ret = taosReadFile(pFile, pRaw->pData, readLen);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
mError("failed to read sdb file:%s since %s", file, tstrerror(code));
|
mError("failed to read sdb file:%s since %s, ret:%" PRId64 " readLen:%d", file, tstrerror(code), ret, readLen);
|
||||||
break;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret != readLen) {
|
if (ret != readLen) {
|
||||||
code = TSDB_CODE_FILE_CORRUPTED;
|
code = TSDB_CODE_FILE_CORRUPTED;
|
||||||
mError("failed to read sdb file:%s since %s", file, tstrerror(code));
|
mError("failed to read sdb file:%s since %s, ret:%" PRId64 " != readLen:%d", file, tstrerror(code), ret, readLen);
|
||||||
break;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t totalLen = sizeof(SSdbRaw) + pRaw->dataLen + sizeof(int32_t);
|
int32_t totalLen = sizeof(SSdbRaw) + pRaw->dataLen + sizeof(int32_t);
|
||||||
if ((!taosCheckChecksumWhole((const uint8_t *)pRaw, totalLen)) != 0) {
|
if ((!taosCheckChecksumWhole((const uint8_t *)pRaw, totalLen)) != 0) {
|
||||||
code = TSDB_CODE_CHECKSUM_ERROR;
|
code = TSDB_CODE_CHECKSUM_ERROR;
|
||||||
mError("failed to read sdb file:%s since %s", file, tstrerror(code));
|
mError("failed to read sdb file:%s since %s, readLen:%d", file, tstrerror(code), readLen);
|
||||||
break;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = sdbWriteWithoutFree(pSdb, pRaw);
|
code = sdbWriteWithoutFree(pSdb, pRaw);
|
||||||
|
|
|
@ -103,7 +103,7 @@ int32_t qndProcessQueryMsg(SQnode *pQnode, int64_t ts, SRpcMsg *pMsg) {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qError("unknown msg type:%d in qnode queue", pMsg->msgType);
|
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;
|
if (code == 0) return TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
|
@ -643,6 +643,7 @@ typedef struct SSttBlockLoadInfo {
|
||||||
STSchema *pSchema;
|
STSchema *pSchema;
|
||||||
int16_t *colIds;
|
int16_t *colIds;
|
||||||
int32_t numOfCols;
|
int32_t numOfCols;
|
||||||
|
bool sttBlockLoaded;
|
||||||
} SSttBlockLoadInfo;
|
} SSttBlockLoadInfo;
|
||||||
|
|
||||||
typedef struct SMergeTree {
|
typedef struct SMergeTree {
|
||||||
|
|
|
@ -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) {
|
static int metaUpdateMetaRsp(tb_uid_t uid, char *tbName, SSchemaWrapper *pSchema, STableMetaRsp *pMetaRsp) {
|
||||||
pMetaRsp->pSchemas = taosMemoryMalloc(pSchema->nCols * sizeof(SSchema));
|
pMetaRsp->pSchemas = taosMemoryMalloc(pSchema->nCols * sizeof(SSchema));
|
||||||
if (NULL == pMetaRsp->pSchemas) {
|
if (NULL == pMetaRsp->pSchemas) {
|
||||||
terrno = TSDB_CODE_VND_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
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);
|
rc = tdbTbGet(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pData, &nData);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
terrno = TSDB_CODE_VND_TABLE_NOT_EXIST;
|
terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
uid = *(tb_uid_t *)pData;
|
uid = *(tb_uid_t *)pData;
|
||||||
|
@ -743,7 +743,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
// search name index
|
// search name index
|
||||||
ret = tdbTbGet(pMeta->pNameIdx, pAlterTbReq->tbName, strlen(pAlterTbReq->tbName) + 1, &pVal, &nVal);
|
ret = tdbTbGet(pMeta->pNameIdx, pAlterTbReq->tbName, strlen(pAlterTbReq->tbName) + 1, &pVal, &nVal);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
terrno = TSDB_CODE_VND_TABLE_NOT_EXIST;
|
terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,7 +824,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_DROP_COLUMN:
|
case TSDB_ALTER_TABLE_DROP_COLUMN:
|
||||||
if (pColumn == NULL) {
|
if (pColumn == NULL) {
|
||||||
terrno = TSDB_CODE_VND_TABLE_COL_NOT_EXISTS;
|
terrno = TSDB_CODE_VND_COL_NOT_EXISTS;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
if (pColumn->colId == 0) {
|
if (pColumn->colId == 0) {
|
||||||
|
@ -846,7 +846,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
||||||
if (pColumn == NULL) {
|
if (pColumn == NULL) {
|
||||||
terrno = TSDB_CODE_VND_TABLE_COL_NOT_EXISTS;
|
terrno = TSDB_CODE_VND_COL_NOT_EXISTS;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
if (!IS_VAR_DATA_TYPE(pColumn->type) || pColumn->bytes > pAlterTbReq->colModBytes) {
|
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;
|
goto _err;
|
||||||
}
|
}
|
||||||
if (pColumn == NULL) {
|
if (pColumn == NULL) {
|
||||||
terrno = TSDB_CODE_VND_TABLE_COL_NOT_EXISTS;
|
terrno = TSDB_CODE_VND_COL_NOT_EXISTS;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
if (tqCheckColModifiable(pMeta->pVnode->pTq, uid, pColumn->colId) != 0) {
|
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
|
// search name index
|
||||||
ret = tdbTbGet(pMeta->pNameIdx, pAlterTbReq->tbName, strlen(pAlterTbReq->tbName) + 1, &pVal, &nVal);
|
ret = tdbTbGet(pMeta->pNameIdx, pAlterTbReq->tbName, strlen(pAlterTbReq->tbName) + 1, &pVal, &nVal);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
terrno = TSDB_CODE_VND_TABLE_NOT_EXIST;
|
terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -990,7 +990,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pColumn == NULL) {
|
if (pColumn == NULL) {
|
||||||
terrno = TSDB_CODE_VND_TABLE_COL_NOT_EXISTS;
|
terrno = TSDB_CODE_VND_COL_NOT_EXISTS;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1093,7 +1093,7 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
||||||
// search name index
|
// search name index
|
||||||
ret = tdbTbGet(pMeta->pNameIdx, pAlterTbReq->tbName, strlen(pAlterTbReq->tbName) + 1, &pVal, &nVal);
|
ret = tdbTbGet(pMeta->pNameIdx, pAlterTbReq->tbName, strlen(pAlterTbReq->tbName) + 1, &pVal, &nVal);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
terrno = TSDB_CODE_VND_TABLE_NOT_EXIST;
|
terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTsmaStat->pTSma->indexUid != indexUid) {
|
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,
|
smaError("vgId:%d, tsma insert for smaIndex %" PRIi64 "(!=%" PRIi64 ") failed since %s", SMA_VID(pSma), indexUid,
|
||||||
pTsmaStat->pTSma->indexUid, tstrerror(terrno));
|
pTsmaStat->pTSma->indexUid, tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
|
|
|
@ -333,11 +333,13 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
||||||
code = TSDB_CODE_INVALID_PARA;
|
code = TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
|
|
||||||
_end:
|
_end:
|
||||||
tsdbDataFReaderClose(&pr->pDataFReaderLast);
|
tsdbDataFReaderClose(&pr->pDataFReaderLast);
|
||||||
tsdbDataFReaderClose(&pr->pDataFReader);
|
tsdbDataFReaderClose(&pr->pDataFReader);
|
||||||
|
|
||||||
tsdbUntakeReadSnap(pr->pVnode->pTsdb, pr->pReadSnap, "cache-l");
|
tsdbUntakeReadSnap(pr->pVnode->pTsdb, pr->pReadSnap, "cache-l");
|
||||||
|
pr->pDataFReaderLast = NULL;
|
||||||
|
pr->pDataFReader = NULL;
|
||||||
|
|
||||||
for (int32_t j = 0; j < pr->numOfCols; ++j) {
|
for (int32_t j = 0; j < pr->numOfCols; ++j) {
|
||||||
taosMemoryFree(pRes[j]);
|
taosMemoryFree(pRes[j]);
|
||||||
|
|
|
@ -116,6 +116,13 @@ int32_t tsdbInsertTableData(STsdb *pTsdb, int64_t version, SSubmitMsgIter *pMsgI
|
||||||
if (info.suid) {
|
if (info.suid) {
|
||||||
metaGetInfo(pTsdb->pVnode->pMeta, info.suid, &info);
|
metaGetInfo(pTsdb->pVnode->pMeta, info.suid, &info);
|
||||||
}
|
}
|
||||||
|
if (pMsgIter->sversion != info.skmVer) {
|
||||||
|
tsdbError("vgId:%d, req sver:%d, skmVer:%d suid:%" PRId64 " uid:%" PRId64,
|
||||||
|
TD_VID(pTsdb->pVnode), pMsgIter->sversion, info.skmVer, suid, uid);
|
||||||
|
code = TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
pRsp->sver = info.skmVer;
|
pRsp->sver = info.skmVer;
|
||||||
|
|
||||||
// create/get STbData to op
|
// create/get STbData to op
|
||||||
|
@ -133,6 +140,7 @@ int32_t tsdbInsertTableData(STsdb *pTsdb, int64_t version, SSubmitMsgIter *pMsgI
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
terrno = code;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ void resetLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) {
|
||||||
|
|
||||||
pLoadInfo[i].elapsedTime = 0;
|
pLoadInfo[i].elapsedTime = 0;
|
||||||
pLoadInfo[i].loadBlocks = 0;
|
pLoadInfo[i].loadBlocks = 0;
|
||||||
|
pLoadInfo[i].sttBlockLoaded = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,9 +279,10 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
|
||||||
|
|
||||||
(*pIter)->pBlockLoadInfo = pBlockLoadInfo;
|
(*pIter)->pBlockLoadInfo = pBlockLoadInfo;
|
||||||
|
|
||||||
size_t size = taosArrayGetSize(pBlockLoadInfo->aSttBlk);
|
// size_t size = taosArrayGetSize(pBlockLoadInfo->aSttBlk);
|
||||||
if (size == 0) {
|
if (!pBlockLoadInfo->sttBlockLoaded) {
|
||||||
int64_t st = taosGetTimestampUs();
|
int64_t st = taosGetTimestampUs();
|
||||||
|
pBlockLoadInfo->sttBlockLoaded = true;
|
||||||
|
|
||||||
code = tsdbReadSttBlk(pReader, iStt, pBlockLoadInfo->aSttBlk);
|
code = tsdbReadSttBlk(pReader, iStt, pBlockLoadInfo->aSttBlk);
|
||||||
if (code) {
|
if (code) {
|
||||||
|
@ -288,7 +290,7 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
// only apply to the child tables, ordinary tables will not incur this filter procedure.
|
// only apply to the child tables, ordinary tables will not incur this filter procedure.
|
||||||
size = taosArrayGetSize(pBlockLoadInfo->aSttBlk);
|
size_t size = taosArrayGetSize(pBlockLoadInfo->aSttBlk);
|
||||||
|
|
||||||
if (size >= 1) {
|
if (size >= 1) {
|
||||||
SSttBlk *pStart = taosArrayGet(pBlockLoadInfo->aSttBlk, 0);
|
SSttBlk *pStart = taosArrayGet(pBlockLoadInfo->aSttBlk, 0);
|
||||||
|
@ -296,10 +298,10 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
|
||||||
|
|
||||||
// all identical
|
// all identical
|
||||||
if (pStart->suid == pEnd->suid) {
|
if (pStart->suid == pEnd->suid) {
|
||||||
if (pStart->suid == suid) {
|
if (pStart->suid != suid) {
|
||||||
// do nothing
|
|
||||||
} else if (pStart->suid != suid) {
|
|
||||||
// no qualified stt block existed
|
// no qualified stt block existed
|
||||||
|
taosArrayClear(pBlockLoadInfo->aSttBlk);
|
||||||
|
|
||||||
(*pIter)->iSttBlk = -1;
|
(*pIter)->iSttBlk = -1;
|
||||||
double el = (taosGetTimestampUs() - st) / 1000.0;
|
double el = (taosGetTimestampUs() - st) / 1000.0;
|
||||||
tsdbDebug("load the last file info completed, elapsed time:%.2fms, %s", el, idStr);
|
tsdbDebug("load the last file info completed, elapsed time:%.2fms, %s", el, idStr);
|
||||||
|
@ -330,7 +332,7 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
|
||||||
tsdbDebug("load the last file info completed, elapsed time:%.2fms, %s", el, idStr);
|
tsdbDebug("load the last file info completed, elapsed time:%.2fms, %s", el, idStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
size = taosArrayGetSize(pBlockLoadInfo->aSttBlk);
|
size_t size = taosArrayGetSize(pBlockLoadInfo->aSttBlk);
|
||||||
|
|
||||||
// find the start block
|
// find the start block
|
||||||
(*pIter)->iSttBlk = binarySearchForStartBlock(pBlockLoadInfo->aSttBlk->pData, size, uid, backward);
|
(*pIter)->iSttBlk = binarySearchForStartBlock(pBlockLoadInfo->aSttBlk->pData, size, uid, backward);
|
||||||
|
|
|
@ -138,7 +138,7 @@ typedef struct SReaderStatus {
|
||||||
bool loadFromFile; // check file stage
|
bool loadFromFile; // check file stage
|
||||||
bool composedDataBlock; // the returned data block is a composed block or not
|
bool composedDataBlock; // the returned data block is a composed block or not
|
||||||
SHashObj* pTableMap; // SHash<STableBlockScanInfo>
|
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
|
SUidOrderCheckInfo uidCheckInfo; // check all table in uid order
|
||||||
SFileBlockDumpInfo fBlockDumpInfo;
|
SFileBlockDumpInfo fBlockDumpInfo;
|
||||||
SDFileSet* pCurrentFileset; // current opened file set
|
SDFileSet* pCurrentFileset; // current opened file set
|
||||||
|
@ -147,6 +147,12 @@ typedef struct SReaderStatus {
|
||||||
SDataBlockIter blockIter;
|
SDataBlockIter blockIter;
|
||||||
} SReaderStatus;
|
} SReaderStatus;
|
||||||
|
|
||||||
|
typedef struct SBlockInfoBuf {
|
||||||
|
int32_t currentIndex;
|
||||||
|
SArray* pData;
|
||||||
|
int32_t numPerBucket;
|
||||||
|
} SBlockInfoBuf;
|
||||||
|
|
||||||
struct STsdbReader {
|
struct STsdbReader {
|
||||||
STsdb* pTsdb;
|
STsdb* pTsdb;
|
||||||
uint64_t suid;
|
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
|
STSchema* pMemSchema; // the previous schema for in-memory data, to avoid load schema too many times
|
||||||
SDataFReader* pFileReader;
|
SDataFReader* pFileReader;
|
||||||
SVersionRange verRange;
|
SVersionRange verRange;
|
||||||
|
SBlockInfoBuf blockInfoBuf;
|
||||||
int32_t step;
|
int32_t step;
|
||||||
STsdbReader* innerReader[2];
|
STsdbReader* innerReader[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter);
|
static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter);
|
||||||
|
@ -232,6 +238,50 @@ static int32_t setColumnIdSlotList(STsdbReader* pReader, SSDataBlock* pBlock) {
|
||||||
return TSDB_CODE_SUCCESS;
|
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) {
|
static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableKeyInfo* idList, int32_t numOfTables) {
|
||||||
// allocate buffer in order to load data blocks from file
|
// allocate buffer in order to load data blocks from file
|
||||||
// todo use simple hash instead, optimize the memory consumption
|
// todo use simple hash instead, optimize the memory consumption
|
||||||
|
@ -242,9 +292,23 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableK
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t st = taosGetTimestampUs();
|
int64_t st = taosGetTimestampUs();
|
||||||
|
initBlockScanInfoBuf(&pTsdbReader->blockInfoBuf, numOfTables);
|
||||||
|
|
||||||
for (int32_t j = 0; j < numOfTables; ++j) {
|
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)) {
|
if (ASCENDING_TRAVERSE(pTsdbReader->order)) {
|
||||||
int64_t skey = pTsdbReader->window.skey;
|
int64_t skey = pTsdbReader->window.skey;
|
||||||
info.lastKey = (skey > INT64_MIN) ? (skey - 1) : 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));
|
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);
|
pTsdbReader->idStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,18 +332,19 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableK
|
||||||
return pTableMap;
|
return pTableMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resetDataBlockScanInfo(SHashObj* pTableMap, int64_t ts) {
|
static void resetAllDataBlockScanInfo(SHashObj* pTableMap, int64_t ts) {
|
||||||
STableBlockScanInfo* p = NULL;
|
STableBlockScanInfo** p = NULL;
|
||||||
|
|
||||||
while ((p = taosHashIterate(pTableMap, p)) != NULL) {
|
while ((p = taosHashIterate(pTableMap, p)) != NULL) {
|
||||||
p->iterInit = false;
|
STableBlockScanInfo* pInfo = *(STableBlockScanInfo**) p;
|
||||||
p->iiter.hasVal = false;
|
|
||||||
if (p->iter.iter != NULL) {
|
pInfo->iterInit = false;
|
||||||
p->iter.iter = tsdbTbDataIterDestroy(p->iter.iter);
|
pInfo->iiter.hasVal = false;
|
||||||
|
if (pInfo->iter.iter != NULL) {
|
||||||
|
pInfo->iter.iter = tsdbTbDataIterDestroy(pInfo->iter.iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
p->delSkyline = taosArrayDestroy(p->delSkyline);
|
pInfo->delSkyline = taosArrayDestroy(pInfo->delSkyline);
|
||||||
p->lastKey = ts;
|
pInfo->lastKey = ts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,10 +365,10 @@ static void clearBlockScanInfo(STableBlockScanInfo* p) {
|
||||||
tMapDataClear(&p->mapData);
|
tMapDataClear(&p->mapData);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyBlockScanInfo(SHashObj* pTableMap) {
|
static void destroyAllBlockScanInfo(SHashObj* pTableMap) {
|
||||||
STableBlockScanInfo* p = NULL;
|
void* p = NULL;
|
||||||
while ((p = taosHashIterate(pTableMap, p)) != NULL) {
|
while ((p = taosHashIterate(pTableMap, p)) != NULL) {
|
||||||
clearBlockScanInfo(p);
|
clearBlockScanInfo(*(STableBlockScanInfo**)p);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashCleanup(pTableMap);
|
taosHashCleanup(pTableMap);
|
||||||
|
@ -506,7 +573,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
|
||||||
pReader->verRange = getQueryVerRange(pVnode, pCond, level);
|
pReader->verRange = getQueryVerRange(pVnode, pCond, level);
|
||||||
pReader->type = pCond->type;
|
pReader->type = pCond->type;
|
||||||
pReader->window = updateQueryTimeWindow(pReader->pTsdb, &pCond->twindows);
|
pReader->window = updateQueryTimeWindow(pReader->pTsdb, &pCond->twindows);
|
||||||
|
pReader->blockInfoBuf.numPerBucket = 1000; // 1000 tables per bucket
|
||||||
ASSERT(pCond->numOfCols > 0);
|
ASSERT(pCond->numOfCols > 0);
|
||||||
|
|
||||||
limitOutputBufferSize(pCond, &pReader->capacity);
|
limitOutputBufferSize(pCond, &pReader->capacity);
|
||||||
|
@ -577,7 +644,7 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFReader* pFileReader,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableBlockScanInfo* pScanInfo = p;
|
STableBlockScanInfo* pScanInfo = *(STableBlockScanInfo**)p;
|
||||||
if (pScanInfo->pBlockList == NULL) {
|
if (pScanInfo->pBlockList == NULL) {
|
||||||
pScanInfo->pBlockList = taosArrayInit(4, sizeof(SBlockIndex));
|
pScanInfo->pBlockList = taosArrayInit(4, sizeof(SBlockIndex));
|
||||||
}
|
}
|
||||||
|
@ -597,7 +664,7 @@ _end:
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cleanupTableScanInfo(SHashObj* pTableMap) {
|
static void cleanupTableScanInfo(SHashObj* pTableMap) {
|
||||||
STableBlockScanInfo* px = NULL;
|
STableBlockScanInfo** px = NULL;
|
||||||
while (1) {
|
while (1) {
|
||||||
px = taosHashIterate(pTableMap, px);
|
px = taosHashIterate(pTableMap, px);
|
||||||
if (px == NULL) {
|
if (px == NULL) {
|
||||||
|
@ -605,8 +672,8 @@ static void cleanupTableScanInfo(SHashObj* pTableMap) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset the index in last block when handing a new file
|
// reset the index in last block when handing a new file
|
||||||
tMapDataClear(&px->mapData);
|
tMapDataClear(&(*px)->mapData);
|
||||||
taosArrayClear(px->pBlockList);
|
taosArrayClear((*px)->pBlockList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,7 +688,8 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN
|
||||||
for (int32_t i = 0; i < numOfTables; ++i) {
|
for (int32_t i = 0; i < numOfTables; ++i) {
|
||||||
SBlockIdx* pBlockIdx = taosArrayGet(pIndexList, 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);
|
tMapDataReset(&pScanInfo->mapData);
|
||||||
tsdbReadDataBlk(pReader->pFileReader, pBlockIdx, &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) {
|
static int32_t doSetCurrentBlock(SDataBlockIter* pBlockIter, const char* idStr) {
|
||||||
SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(pBlockIter);
|
SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(pBlockIter);
|
||||||
if (pBlockInfo != NULL) {
|
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) {
|
if (pScanInfo == NULL) {
|
||||||
tsdbError("failed to locate the uid:%" PRIu64 " in query table uid list, %s", pBlockInfo->uid, idStr);
|
tsdbError("failed to locate the uid:%" PRIu64 " in query table uid list, %s", pBlockInfo->uid, idStr);
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
|
|
||||||
SBlockIndex* pIndex = taosArrayGet(pScanInfo->pBlockList, pBlockInfo->tbBlockIdx);
|
SBlockIndex* pIndex = taosArrayGet((*pScanInfo)->pBlockList, pBlockInfo->tbBlockIdx);
|
||||||
tMapDataGetItemByIdx(&pScanInfo->mapData, pIndex->ordinalIndex, &pBlockIter->block, tGetDataBlk);
|
tMapDataGetItemByIdx(&(*pScanInfo)->mapData, pIndex->ordinalIndex, &pBlockIter->block, tGetDataBlk);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -1111,7 +1179,7 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableBlockScanInfo* pTableScanInfo = (STableBlockScanInfo*)ptr;
|
STableBlockScanInfo* pTableScanInfo = *(STableBlockScanInfo**)ptr;
|
||||||
if (pTableScanInfo->pBlockList == NULL || taosArrayGetSize(pTableScanInfo->pBlockList) == 0) {
|
if (pTableScanInfo->pBlockList == NULL || taosArrayGetSize(pTableScanInfo->pBlockList) == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1299,10 +1367,10 @@ static bool keyOverlapFileBlock(TSDBKEY key, SDataBlk* pBlock, SVersionRange* pV
|
||||||
(pBlock->minVer <= pVerRange->maxVer);
|
(pBlock->minVer <= pVerRange->maxVer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool doCheckforDatablockOverlap(STableBlockScanInfo* pBlockScanInfo, const SDataBlk* pBlock) {
|
static bool doCheckforDatablockOverlap(STableBlockScanInfo* pBlockScanInfo, const SDataBlk* pBlock, int32_t startIndex) {
|
||||||
size_t num = taosArrayGetSize(pBlockScanInfo->delSkyline);
|
size_t num = taosArrayGetSize(pBlockScanInfo->delSkyline);
|
||||||
|
|
||||||
for (int32_t i = pBlockScanInfo->fileDelIndex; i < num; i += 1) {
|
for (int32_t i = startIndex; i < num; i += 1) {
|
||||||
TSDBKEY* p = taosArrayGet(pBlockScanInfo->delSkyline, i);
|
TSDBKEY* p = taosArrayGet(pBlockScanInfo->delSkyline, i);
|
||||||
if (p->ts >= pBlock->minKey.ts && p->ts <= pBlock->maxKey.ts) {
|
if (p->ts >= pBlock->minKey.ts && p->ts <= pBlock->maxKey.ts) {
|
||||||
if (p->version >= pBlock->minVer) {
|
if (p->version >= pBlock->minVer) {
|
||||||
|
@ -1341,7 +1409,7 @@ static bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SDa
|
||||||
|
|
||||||
// version is not overlap
|
// version is not overlap
|
||||||
if (ASCENDING_TRAVERSE(order)) {
|
if (ASCENDING_TRAVERSE(order)) {
|
||||||
return doCheckforDatablockOverlap(pBlockScanInfo, pBlock);
|
return doCheckforDatablockOverlap(pBlockScanInfo, pBlock, pBlockScanInfo->fileDelIndex);
|
||||||
} else {
|
} else {
|
||||||
int32_t index = pBlockScanInfo->fileDelIndex;
|
int32_t index = pBlockScanInfo->fileDelIndex;
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -1353,7 +1421,7 @@ static bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SDa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return doCheckforDatablockOverlap(pBlockScanInfo, pBlock);
|
return doCheckforDatablockOverlap(pBlockScanInfo, pBlock, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2118,7 +2186,7 @@ static bool isValidFileBlockRow(SBlockData* pBlockData, SFileBlockDumpInfo* pDum
|
||||||
static bool initLastBlockReader(SLastBlockReader* pLBlockReader, STableBlockScanInfo* pScanInfo, STsdbReader* pReader) {
|
static bool initLastBlockReader(SLastBlockReader* pLBlockReader, STableBlockScanInfo* pScanInfo, STsdbReader* pReader) {
|
||||||
// the last block reader has been initialized for this table.
|
// the last block reader has been initialized for this table.
|
||||||
if (pLBlockReader->uid == pScanInfo->uid) {
|
if (pLBlockReader->uid == pScanInfo->uid) {
|
||||||
return true;
|
return hasDataInLastBlock(pLBlockReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pLBlockReader->uid != 0) {
|
if (pLBlockReader->uid != 0) {
|
||||||
|
@ -2235,7 +2303,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
||||||
|
|
||||||
STableBlockScanInfo* pBlockScanInfo = NULL;
|
STableBlockScanInfo* pBlockScanInfo = NULL;
|
||||||
if (pBlockInfo != 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) {
|
if (pBlockScanInfo == NULL) {
|
||||||
code = TSDB_CODE_INVALID_PARA;
|
code = TSDB_CODE_INVALID_PARA;
|
||||||
tsdbError("failed to locate the uid:%" PRIu64 " in query table uid list, total tables:%d, %s", pBlockInfo->uid,
|
tsdbError("failed to locate the uid:%" PRIu64 " in query table uid list, total tables:%d, %s", pBlockInfo->uid,
|
||||||
|
@ -2251,11 +2319,14 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
||||||
if (pReader->order == TSDB_ORDER_ASC ||
|
if (pReader->order == TSDB_ORDER_ASC ||
|
||||||
(pReader->order == TSDB_ORDER_DESC && (!hasDataInLastBlock(pLastBlockReader)))) {
|
(pReader->order == TSDB_ORDER_DESC && (!hasDataInLastBlock(pLastBlockReader)))) {
|
||||||
copyBlockDataToSDataBlock(pReader, pBlockScanInfo);
|
copyBlockDataToSDataBlock(pReader, pBlockScanInfo);
|
||||||
|
|
||||||
|
// record the last key value
|
||||||
|
pBlockScanInfo->lastKey = ASCENDING_TRAVERSE(pReader->order)? pBlock->maxKey.ts:pBlock->minKey.ts;
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // file blocks not exist
|
} else { // file blocks not exist
|
||||||
pBlockScanInfo = pReader->status.pTableIter;
|
pBlockScanInfo = *pReader->status.pTableIter;
|
||||||
}
|
}
|
||||||
|
|
||||||
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
|
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
|
||||||
|
@ -2480,7 +2551,7 @@ static void extractOrderedTableUidList(SUidOrderCheckInfo* pOrderCheckInfo, SRea
|
||||||
|
|
||||||
void* p = taosHashIterate(pStatus->pTableMap, NULL);
|
void* p = taosHashIterate(pStatus->pTableMap, NULL);
|
||||||
while (p != NULL) {
|
while (p != NULL) {
|
||||||
STableBlockScanInfo* pScanInfo = p;
|
STableBlockScanInfo* pScanInfo = *(STableBlockScanInfo**) p;
|
||||||
pOrderCheckInfo->tableUidList[index++] = pScanInfo->uid;
|
pOrderCheckInfo->tableUidList[index++] = pScanInfo->uid;
|
||||||
p = taosHashIterate(pStatus->pTableMap, p);
|
p = taosHashIterate(pStatus->pTableMap, p);
|
||||||
}
|
}
|
||||||
|
@ -2554,7 +2625,7 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
// load the last data block of current table
|
// load the last data block of current table
|
||||||
STableBlockScanInfo* pScanInfo = pStatus->pTableIter;
|
STableBlockScanInfo* pScanInfo = *(STableBlockScanInfo**) pStatus->pTableIter;
|
||||||
bool hasVal = initLastBlockReader(pLastBlockReader, pScanInfo, pReader);
|
bool hasVal = initLastBlockReader(pLastBlockReader, pScanInfo, pReader);
|
||||||
if (!hasVal) {
|
if (!hasVal) {
|
||||||
bool hasNexTable = moveToNextTable(pOrderedCheckInfo, pStatus);
|
bool hasNexTable = moveToNextTable(pOrderedCheckInfo, pStatus);
|
||||||
|
@ -2592,9 +2663,9 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
|
||||||
SLastBlockReader* pLastBlockReader = pReader->status.fileIter.pLastBlockReader;
|
SLastBlockReader* pLastBlockReader = pReader->status.fileIter.pLastBlockReader;
|
||||||
|
|
||||||
if (pBlockInfo != NULL) {
|
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 {
|
} else {
|
||||||
pScanInfo = pReader->status.pTableIter;
|
pScanInfo = *pReader->status.pTableIter;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pScanInfo == NULL) {
|
if (pScanInfo == NULL) {
|
||||||
|
@ -2642,6 +2713,9 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
|
||||||
pInfo->window = (STimeWindow){.skey = pBlock->minKey.ts, .ekey = pBlock->maxKey.ts};
|
pInfo->window = (STimeWindow){.skey = pBlock->minKey.ts, .ekey = pBlock->maxKey.ts};
|
||||||
setComposedBlockFlag(pReader, false);
|
setComposedBlockFlag(pReader, false);
|
||||||
setBlockAllDumped(&pStatus->fBlockDumpInfo, pBlock->maxKey.ts, pReader->order);
|
setBlockAllDumped(&pStatus->fBlockDumpInfo, pBlock->maxKey.ts, pReader->order);
|
||||||
|
|
||||||
|
// update the last key for the corresponding table
|
||||||
|
pScanInfo->lastKey = ASCENDING_TRAVERSE(pReader->order)? pInfo->window.ekey:pInfo->window.skey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2659,11 +2733,11 @@ static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STableBlockScanInfo* pBlockScanInfo = pStatus->pTableIter;
|
STableBlockScanInfo** pBlockScanInfo = pStatus->pTableIter;
|
||||||
initMemDataIterator(pBlockScanInfo, pReader);
|
initMemDataIterator(*pBlockScanInfo, pReader);
|
||||||
|
|
||||||
int64_t endKey = (ASCENDING_TRAVERSE(pReader->order)) ? INT64_MAX : INT64_MIN;
|
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) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -3465,18 +3539,23 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e
|
||||||
// TODO refactor: with createDataBlockScanInfo
|
// TODO refactor: with createDataBlockScanInfo
|
||||||
int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t num) {
|
int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t num) {
|
||||||
ASSERT(pReader != NULL);
|
ASSERT(pReader != NULL);
|
||||||
|
int32_t size = taosHashGetSize(pReader->status.pTableMap);
|
||||||
|
|
||||||
STableBlockScanInfo* p = NULL;
|
STableBlockScanInfo** p = NULL;
|
||||||
while ((p = taosHashIterate(pReader->status.pTableMap, 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);
|
taosHashClear(pReader->status.pTableMap);
|
||||||
|
|
||||||
STableKeyInfo* pList = (STableKeyInfo*) pTableList;
|
STableKeyInfo* pList = (STableKeyInfo*) pTableList;
|
||||||
for(int32_t i = 0; i < num; ++i) {
|
for(int32_t i = 0; i < num; ++i) {
|
||||||
STableBlockScanInfo info = {.lastKey = 0, .uid = pList[i].uid};
|
STableBlockScanInfo* pInfo = getPosInBlockInfoBuf(&pReader->blockInfoBuf, i);
|
||||||
taosHashPut(pReader->status.pTableMap, &info.uid, sizeof(uint64_t), &info, sizeof(info));
|
pInfo->uid = pList[i].uid;
|
||||||
|
taosHashPut(pReader->status.pTableMap, &pInfo->uid, sizeof(uint64_t), &pInfo, POINTER_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TDB_CODE_SUCCESS;
|
return TDB_CODE_SUCCESS;
|
||||||
|
@ -3680,8 +3759,9 @@ void tsdbReaderClose(STsdbReader* pReader) {
|
||||||
cleanupDataBlockIterator(&pReader->status.blockIter);
|
cleanupDataBlockIterator(&pReader->status.blockIter);
|
||||||
|
|
||||||
size_t numOfTables = taosHashGetSize(pReader->status.pTableMap);
|
size_t numOfTables = taosHashGetSize(pReader->status.pTableMap);
|
||||||
destroyBlockScanInfo(pReader->status.pTableMap);
|
destroyAllBlockScanInfo(pReader->status.pTableMap);
|
||||||
blockDataDestroy(pReader->pResBlock);
|
blockDataDestroy(pReader->pResBlock);
|
||||||
|
clearBlockScanInfoBuf(&pReader->blockInfoBuf);
|
||||||
|
|
||||||
if (pReader->pFileReader != NULL) {
|
if (pReader->pFileReader != NULL) {
|
||||||
tsdbDataFReaderClose(&pReader->pFileReader);
|
tsdbDataFReaderClose(&pReader->pFileReader);
|
||||||
|
@ -3765,7 +3845,7 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
|
||||||
if (pReader->step == EXTERNAL_ROWS_PREV) {
|
if (pReader->step == EXTERNAL_ROWS_PREV) {
|
||||||
// prepare for the main scan
|
// prepare for the main scan
|
||||||
int32_t code = doOpenReaderImpl(pReader);
|
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) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -3782,7 +3862,7 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
|
||||||
if (pReader->innerReader[1] != NULL && pReader->step == EXTERNAL_ROWS_MAIN) {
|
if (pReader->innerReader[1] != NULL && pReader->step == EXTERNAL_ROWS_MAIN) {
|
||||||
// prepare for the next row scan
|
// prepare for the next row scan
|
||||||
int32_t code = doOpenReaderImpl(pReader->innerReader[1]);
|
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) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -3798,7 +3878,7 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tsdbTableNextDataBlock(STsdbReader* pReader, uint64_t uid) {
|
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
|
if (pBlockScanInfo == NULL) { // no data block for the table of given uid
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -3911,7 +3991,7 @@ static SArray* doRetrieveDataBlock(STsdbReader* pReader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(&pStatus->blockIter);
|
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) {
|
if (pBlockScanInfo == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
tsdbError("failed to locate the uid:%" PRIu64 " in query table uid list, total tables:%d, %s", pBlockInfo->uid,
|
tsdbError("failed to locate the uid:%" PRIu64 " in query table uid list, total tables:%d, %s", pBlockInfo->uid,
|
||||||
|
@ -3947,6 +4027,8 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDataBlockIter* pBlockIter = &pReader->status.blockIter;
|
||||||
|
|
||||||
pReader->order = pCond->order;
|
pReader->order = pCond->order;
|
||||||
pReader->type = TIMEWINDOW_RANGE_CONTAINED;
|
pReader->type = TIMEWINDOW_RANGE_CONTAINED;
|
||||||
pReader->status.loadFromFile = true;
|
pReader->status.loadFromFile = true;
|
||||||
|
@ -3963,13 +4045,12 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
|
||||||
int32_t numOfTables = taosHashGetSize(pReader->status.pTableMap);
|
int32_t numOfTables = taosHashGetSize(pReader->status.pTableMap);
|
||||||
|
|
||||||
initFilesetIterator(&pReader->status.fileIter, pReader->pReadSnap->fs.aDFileSet, pReader);
|
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;
|
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;
|
int32_t code = 0;
|
||||||
SDataBlockIter* pBlockIter = &pReader->status.blockIter;
|
|
||||||
|
|
||||||
// no data in files, let's try buffer in memory
|
// no data in files, let's try buffer in memory
|
||||||
if (pReader->status.fileIter.numOfFiles == 0) {
|
if (pReader->status.fileIter.numOfFiles == 0) {
|
||||||
|
@ -4071,7 +4152,7 @@ int64_t tsdbGetNumOfRowsInMemTable(STsdbReader* pReader) {
|
||||||
pStatus->pTableIter = taosHashIterate(pStatus->pTableMap, NULL);
|
pStatus->pTableIter = taosHashIterate(pStatus->pTableMap, NULL);
|
||||||
|
|
||||||
while (pStatus->pTableIter != NULL) {
|
while (pStatus->pTableIter != NULL) {
|
||||||
STableBlockScanInfo* pBlockScanInfo = pStatus->pTableIter;
|
STableBlockScanInfo* pBlockScanInfo = *(STableBlockScanInfo**)pStatus->pTableIter;
|
||||||
|
|
||||||
STbData* d = NULL;
|
STbData* d = NULL;
|
||||||
if (pReader->pTsdb->mem != NULL) {
|
if (pReader->pTsdb->mem != NULL) {
|
||||||
|
|
|
@ -290,7 +290,7 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
for (int32_t i = 0; i < msgNum; ++i) {
|
for (int32_t i = 0; i < msgNum; ++i) {
|
||||||
if (offset >= pMsg->contLen) {
|
if (offset >= pMsg->contLen) {
|
||||||
qError("vnode offset %d is bigger than contLen %d", 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);
|
taosArrayDestroy(batchRsp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
|
|
||||||
if (offset >= pMsg->contLen) {
|
if (offset >= pMsg->contLen) {
|
||||||
qError("vnode offset %d is bigger than contLen %d", 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);
|
taosArrayDestroy(batchRsp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
|
|
||||||
if (offset >= pMsg->contLen) {
|
if (offset >= pMsg->contLen) {
|
||||||
qError("vnode offset %d is bigger than contLen %d", 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);
|
taosArrayDestroy(batchRsp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,7 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
|
|
||||||
if (offset >= pMsg->contLen) {
|
if (offset >= pMsg->contLen) {
|
||||||
qError("vnode offset %d is bigger than contLen %d", 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);
|
taosArrayDestroy(batchRsp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -362,6 +362,7 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
|
||||||
if (rspSize > MAX_META_BATCH_RSP_SIZE) {
|
if (rspSize > MAX_META_BATCH_RSP_SIZE) {
|
||||||
|
qError("rspSize:%d overload", rspSize);
|
||||||
code = TSDB_CODE_INVALID_MSG_LEN;
|
code = TSDB_CODE_INVALID_MSG_LEN;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
@ -414,9 +415,11 @@ _exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
|
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
|
||||||
|
SSyncState state = syncGetState(pVnode->sync);
|
||||||
|
|
||||||
pLoad->vgId = TD_VID(pVnode);
|
pLoad->vgId = TD_VID(pVnode);
|
||||||
pLoad->syncState = syncGetMyRole(pVnode->sync);
|
pLoad->syncState = state.state;
|
||||||
pLoad->syncRestore = pVnode->restored;
|
pLoad->syncRestore = state.restored;
|
||||||
pLoad->cacheUsage = tsdbCacheGetUsage(pVnode);
|
pLoad->cacheUsage = tsdbCacheGetUsage(pVnode);
|
||||||
pLoad->numOfTables = metaGetTbNum(pVnode->pMeta);
|
pLoad->numOfTables = metaGetTbNum(pVnode->pMeta);
|
||||||
pLoad->numOfTimeSeries = metaGetTimeSeriesNum(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;
|
int32_t ret;
|
||||||
|
|
||||||
if (!pVnode->inUse) {
|
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());
|
vError("vgId:%d, not ready to write since %s", TD_VID(pVnode), terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -348,7 +348,7 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
return qWorkerProcessCQueryMsg(&handle, pVnode->pQuery, pMsg, 0);
|
return qWorkerProcessCQueryMsg(&handle, pVnode->pQuery, pMsg, 0);
|
||||||
default:
|
default:
|
||||||
vError("unknown msg type:%d in query queue", pMsg->msgType);
|
vError("unknown msg type:%d in query queue", pMsg->msgType);
|
||||||
return TSDB_CODE_VND_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
||||||
return tqProcessTaskRecoverFinishRsp(pVnode->pTq, pMsg);
|
return tqProcessTaskRecoverFinishRsp(pVnode->pTq, pMsg);
|
||||||
default:
|
default:
|
||||||
vError("unknown msg type:%d in fetch queue", pMsg->msgType);
|
vError("unknown msg type:%d in fetch queue", pMsg->msgType);
|
||||||
return TSDB_CODE_VND_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -774,7 +774,7 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq
|
||||||
/* code */
|
/* code */
|
||||||
ret = metaDropTable(pVnode->pMeta, version, pDropTbReq, tbUids, &tbUid);
|
ret = metaDropTable(pVnode->pMeta, version, pDropTbReq, tbUids, &tbUid);
|
||||||
if (ret < 0) {
|
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;
|
dropTbRsp.code = TSDB_CODE_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
dropTbRsp.code = terrno;
|
dropTbRsp.code = terrno;
|
||||||
|
@ -863,6 +863,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
SArray *newTbUids = NULL;
|
SArray *newTbUids = NULL;
|
||||||
SVStatis statis = {0};
|
SVStatis statis = {0};
|
||||||
|
bool tbCreated = false;
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
pRsp->code = 0;
|
pRsp->code = 0;
|
||||||
|
@ -896,11 +897,10 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
||||||
if (pBlock == NULL) break;
|
if (pBlock == NULL) break;
|
||||||
|
|
||||||
SSubmitBlkRsp submitBlkRsp = {0};
|
SSubmitBlkRsp submitBlkRsp = {0};
|
||||||
|
tbCreated = false;
|
||||||
|
|
||||||
// create table for auto create table mode
|
// create table for auto create table mode
|
||||||
if (msgIter.schemaLen > 0) {
|
if (msgIter.schemaLen > 0) {
|
||||||
submitBlkRsp.hashMeta = 1;
|
|
||||||
|
|
||||||
tDecoderInit(&decoder, pBlock->data, msgIter.schemaLen);
|
tDecoderInit(&decoder, pBlock->data, msgIter.schemaLen);
|
||||||
if (tDecodeSVCreateTbReq(&decoder, &createTbReq) < 0) {
|
if (tDecodeSVCreateTbReq(&decoder, &createTbReq) < 0) {
|
||||||
pRsp->code = TSDB_CODE_INVALID_MSG;
|
pRsp->code = TSDB_CODE_INVALID_MSG;
|
||||||
|
@ -937,12 +937,13 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayPush(newTbUids, &createTbReq.uid);
|
taosArrayPush(newTbUids, &createTbReq.uid);
|
||||||
|
|
||||||
|
submitBlkRsp.uid = createTbReq.uid;
|
||||||
|
submitBlkRsp.tblFName = taosMemoryMalloc(strlen(pVnode->config.dbname) + strlen(createTbReq.name) + 2);
|
||||||
|
sprintf(submitBlkRsp.tblFName, "%s.%s", pVnode->config.dbname, createTbReq.name);
|
||||||
|
tbCreated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
submitBlkRsp.uid = createTbReq.uid;
|
|
||||||
submitBlkRsp.tblFName = taosMemoryMalloc(strlen(pVnode->config.dbname) + strlen(createTbReq.name) + 2);
|
|
||||||
sprintf(submitBlkRsp.tblFName, "%s.%s", pVnode->config.dbname, createTbReq.name);
|
|
||||||
|
|
||||||
msgIter.uid = createTbReq.uid;
|
msgIter.uid = createTbReq.uid;
|
||||||
if (createTbReq.type == TSDB_CHILD_TABLE) {
|
if (createTbReq.type == TSDB_CHILD_TABLE) {
|
||||||
msgIter.suid = createTbReq.ctb.suid;
|
msgIter.suid = createTbReq.ctb.suid;
|
||||||
|
@ -955,10 +956,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
||||||
#endif
|
#endif
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
taosArrayDestroy(createTbReq.ctb.tagName);
|
taosArrayDestroy(createTbReq.ctb.tagName);
|
||||||
} else {
|
}
|
||||||
submitBlkRsp.tblFName = taosMemoryMalloc(TSDB_TABLE_FNAME_LEN);
|
|
||||||
sprintf(submitBlkRsp.tblFName, "%s.", pVnode->config.dbname);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tsdbInsertTableData(pVnode->pTsdb, version, &msgIter, pBlock, &submitBlkRsp) < 0) {
|
if (tsdbInsertTableData(pVnode->pTsdb, version, &msgIter, pBlock, &submitBlkRsp) < 0) {
|
||||||
submitBlkRsp.code = terrno;
|
submitBlkRsp.code = terrno;
|
||||||
|
@ -966,7 +964,9 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
||||||
|
|
||||||
submitRsp.numOfRows += submitBlkRsp.numOfRows;
|
submitRsp.numOfRows += submitBlkRsp.numOfRows;
|
||||||
submitRsp.affectedRows += submitBlkRsp.affectedRows;
|
submitRsp.affectedRows += submitBlkRsp.affectedRows;
|
||||||
taosArrayPush(submitRsp.pArray, &submitBlkRsp);
|
if (tbCreated || submitBlkRsp.code) {
|
||||||
|
taosArrayPush(submitRsp.pArray, &submitBlkRsp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosArrayGetSize(newTbUids) > 0) {
|
if (taosArrayGetSize(newTbUids) > 0) {
|
||||||
|
|
|
@ -309,13 +309,13 @@ static void vnodeSyncApplyMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const S
|
||||||
const STraceId *trace = &pMsg->info.traceId;
|
const STraceId *trace = &pMsg->info.traceId;
|
||||||
vGTrace("vgId:%d, commit-cb is excuted, fsm:%p, index:%" PRId64 ", term:%" PRIu64 ", msg-index:%" PRId64
|
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",
|
", weak:%d, code:%d, state:%d %s, type:%s",
|
||||||
syncGetVgId(pVnode->sync), pFsm, pMeta->index, pMeta->term, rpcMsg.info.conn.applyIndex, pMeta->isWeak,
|
pVnode->config.vgId, pFsm, pMeta->index, pMeta->term, rpcMsg.info.conn.applyIndex, pMeta->isWeak,
|
||||||
pMeta->code, pMeta->state, syncUtilState2String(pMeta->state), TMSG_INFO(pMsg->msgType));
|
pMeta->code, pMeta->state, syncStr(pMeta->state), TMSG_INFO(pMsg->msgType));
|
||||||
|
|
||||||
tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, &rpcMsg);
|
tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, &rpcMsg);
|
||||||
} else {
|
} else {
|
||||||
SRpcMsg rsp = {.code = pMeta->code, .info = pMsg->info};
|
SRpcMsg rsp = {.code = pMeta->code, .info = pMsg->info};
|
||||||
vError("vgId:%d, commit-cb execute error, type:%s, index:%" PRId64 ", error:0x%x %s", syncGetVgId(pVnode->sync),
|
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));
|
TMSG_INFO(pMsg->msgType), pMeta->index, pMeta->code, tstrerror(pMeta->code));
|
||||||
if (rsp.info.handle != NULL) {
|
if (rsp.info.handle != NULL) {
|
||||||
tmsgSendRsp(&rsp);
|
tmsgSendRsp(&rsp);
|
||||||
|
@ -338,8 +338,8 @@ static void vnodeSyncPreCommitMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, con
|
||||||
static void vnodeSyncRollBackMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
static void vnodeSyncRollBackMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||||
SVnode *pVnode = pFsm->data;
|
SVnode *pVnode = pFsm->data;
|
||||||
vTrace("vgId:%d, rollback-cb is excuted, fsm:%p, index:%" PRId64 ", weak:%d, code:%d, state:%d %s, type:%s",
|
vTrace("vgId:%d, rollback-cb is excuted, fsm:%p, index:%" PRId64 ", weak:%d, code:%d, state:%d %s, type:%s",
|
||||||
syncGetVgId(pVnode->sync), pFsm, pMeta->index, pMeta->isWeak, pMeta->code, pMeta->state,
|
pVnode->config.vgId, pFsm, pMeta->index, pMeta->isWeak, pMeta->code, pMeta->state, syncStr(pMeta->state),
|
||||||
syncUtilState2String(pMeta->state), TMSG_INFO(pMsg->msgType));
|
TMSG_INFO(pMsg->msgType));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define USE_TSDB_SNAPSHOT
|
#define USE_TSDB_SNAPSHOT
|
||||||
|
@ -552,12 +552,21 @@ void vnodeSyncClose(SVnode *pVnode) {
|
||||||
syncStop(pVnode->sync);
|
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) {
|
bool vnodeIsLeader(SVnode *pVnode) {
|
||||||
if (!syncIsReady(pVnode->sync)) {
|
SSyncState state = syncGetState(pVnode->sync);
|
||||||
vDebug("vgId:%d, vnode not ready, state:%s, restore:%d", pVnode->config.vgId, syncGetMyRoleStr(pVnode->sync),
|
|
||||||
syncRestoreFinish(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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ extern "C" {
|
||||||
#define CTG_DEFAULT_MAX_RETRY_TIMES 3
|
#define CTG_DEFAULT_MAX_RETRY_TIMES 3
|
||||||
#define CTG_DEFAULT_BATCH_NUM 64
|
#define CTG_DEFAULT_BATCH_NUM 64
|
||||||
#define CTG_DEFAULT_FETCH_NUM 8
|
#define CTG_DEFAULT_FETCH_NUM 8
|
||||||
|
#define CTG_MAX_COMMAND_LEN 512
|
||||||
|
|
||||||
#define CTG_RENT_SLOT_SECOND 1.5
|
#define CTG_RENT_SLOT_SECOND 1.5
|
||||||
|
|
||||||
|
@ -223,6 +224,7 @@ typedef struct SCtgUserAuth {
|
||||||
|
|
||||||
typedef struct SCatalog {
|
typedef struct SCatalog {
|
||||||
uint64_t clusterId;
|
uint64_t clusterId;
|
||||||
|
bool stopUpdate;
|
||||||
SHashObj* userCache; // key:user, value:SCtgUserAuth
|
SHashObj* userCache; // key:user, value:SCtgUserAuth
|
||||||
SHashObj* dbCache; // key:dbname, value:SCtgDBCache
|
SHashObj* dbCache; // key:dbname, value:SCtgDBCache
|
||||||
SCtgRentMgmt dbRent;
|
SCtgRentMgmt dbRent;
|
||||||
|
@ -671,7 +673,7 @@ void ctgdShowClusterCache(SCatalog* pCtg);
|
||||||
int32_t ctgdShowCacheInfo(void);
|
int32_t ctgdShowCacheInfo(void);
|
||||||
|
|
||||||
int32_t ctgRemoveTbMetaFromCache(SCatalog* pCtg, SName* pTableName, bool syncReq);
|
int32_t ctgRemoveTbMetaFromCache(SCatalog* pCtg, SName* pTableName, bool syncReq);
|
||||||
int32_t ctgGetTbMetaFromCache(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta);
|
int32_t ctgGetTbMetaFromCache(SCatalog* pCtg, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta);
|
||||||
int32_t ctgGetTbMetasFromCache(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetasCtx* ctx, int32_t dbIdx,
|
int32_t ctgGetTbMetasFromCache(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetasCtx* ctx, int32_t dbIdx,
|
||||||
int32_t* fetchIdx, int32_t baseResIdx, SArray* pList);
|
int32_t* fetchIdx, int32_t baseResIdx, SArray* pList);
|
||||||
|
|
||||||
|
@ -786,6 +788,7 @@ void ctgFreeTbCacheImpl(SCtgTbCache* pCache);
|
||||||
int32_t ctgRemoveTbMeta(SCatalog* pCtg, SName* pTableName);
|
int32_t ctgRemoveTbMeta(SCatalog* pCtg, SName* pTableName);
|
||||||
int32_t ctgGetTbHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SVgroupInfo* pVgroup, bool* exists);
|
int32_t ctgGetTbHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SVgroupInfo* pVgroup, bool* exists);
|
||||||
SName* ctgGetFetchName(SArray* pNames, SCtgFetch* pFetch);
|
SName* ctgGetFetchName(SArray* pNames, SCtgFetch* pFetch);
|
||||||
|
int32_t ctgdGetOneHandle(SCatalog **pHandle);
|
||||||
|
|
||||||
extern SCatalogMgmt gCtgMgmt;
|
extern SCatalogMgmt gCtgMgmt;
|
||||||
extern SCtgDebug gCTGDebug;
|
extern SCtgDebug gCTGDebug;
|
||||||
|
|
|
@ -202,7 +202,7 @@ int32_t ctgGetTbMeta(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetaCtx* ctx
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
STableMetaOutput* output = NULL;
|
STableMetaOutput* output = NULL;
|
||||||
|
|
||||||
CTG_ERR_RET(ctgGetTbMetaFromCache(pCtg, pConn, ctx, pTableMeta));
|
CTG_ERR_RET(ctgGetTbMetaFromCache(pCtg, ctx, pTableMeta));
|
||||||
if (*pTableMeta || (ctx->flag & CTG_FLAG_ONLY_CACHE)) {
|
if (*pTableMeta || (ctx->flag & CTG_FLAG_ONLY_CACHE)) {
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
@ -959,14 +959,14 @@ int32_t catalogGetTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName
|
||||||
CTG_API_LEAVE(ctgGetTbMeta(pCtg, pConn, &ctx, pTableMeta));
|
CTG_API_LEAVE(ctgGetTbMeta(pCtg, pConn, &ctx, pTableMeta));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t catalogGetCachedTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableMeta** pTableMeta) {
|
int32_t catalogGetCachedTableMeta(SCatalog* pCtg, const SName* pTableName, STableMeta** pTableMeta) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
SCtgTbMetaCtx ctx = {0};
|
SCtgTbMetaCtx ctx = {0};
|
||||||
ctx.pName = (SName*)pTableName;
|
ctx.pName = (SName*)pTableName;
|
||||||
ctx.flag = CTG_FLAG_UNKNOWN_STB | CTG_FLAG_ONLY_CACHE;
|
ctx.flag = CTG_FLAG_UNKNOWN_STB | CTG_FLAG_ONLY_CACHE;
|
||||||
|
|
||||||
CTG_API_LEAVE(ctgGetTbMeta(pCtg, pConn, &ctx, pTableMeta));
|
CTG_API_LEAVE(ctgGetTbMeta(pCtg, NULL, &ctx, pTableMeta));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -981,15 +981,14 @@ int32_t catalogGetSTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SNam
|
||||||
CTG_API_LEAVE(ctgGetTbMeta(pCtg, pConn, &ctx, pTableMeta));
|
CTG_API_LEAVE(ctgGetTbMeta(pCtg, pConn, &ctx, pTableMeta));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t catalogGetCachedSTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName,
|
int32_t catalogGetCachedSTableMeta(SCatalog* pCtg, const SName* pTableName, STableMeta** pTableMeta) {
|
||||||
STableMeta** pTableMeta) {
|
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
SCtgTbMetaCtx ctx = {0};
|
SCtgTbMetaCtx ctx = {0};
|
||||||
ctx.pName = (SName*)pTableName;
|
ctx.pName = (SName*)pTableName;
|
||||||
ctx.flag = CTG_FLAG_STB | CTG_FLAG_ONLY_CACHE;
|
ctx.flag = CTG_FLAG_STB | CTG_FLAG_ONLY_CACHE;
|
||||||
|
|
||||||
CTG_API_LEAVE(ctgGetTbMeta(pCtg, pConn, &ctx, pTableMeta));
|
CTG_API_LEAVE(ctgGetTbMeta(pCtg, NULL, &ctx, pTableMeta));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1114,11 +1113,10 @@ int32_t catalogGetTableHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const
|
||||||
CTG_API_LEAVE(ctgGetTbHashVgroup(pCtg, pConn, pTableName, pVgroup, NULL));
|
CTG_API_LEAVE(ctgGetTbHashVgroup(pCtg, pConn, pTableName, pVgroup, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t catalogGetCachedTableHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName,
|
int32_t catalogGetCachedTableHashVgroup(SCatalog* pCtg, const SName* pTableName, SVgroupInfo* pVgroup, bool* exists) {
|
||||||
SVgroupInfo* pVgroup, bool* exists) {
|
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
CTG_API_LEAVE(ctgGetTbHashVgroup(pCtg, pConn, pTableName, pVgroup, exists));
|
CTG_API_LEAVE(ctgGetTbHashVgroup(pCtg, NULL, pTableName, pVgroup, exists));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -1387,16 +1385,16 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t catalogChkAuthFromCache(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, const char* dbFName, AUTH_TYPE type,
|
int32_t catalogChkAuthFromCache(SCatalog* pCtg, const char* user, const char* dbFName, AUTH_TYPE type,
|
||||||
bool* pass, bool* exists) {
|
bool* pass, bool* exists) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
if (NULL == pCtg || NULL == pConn || NULL == user || NULL == dbFName || NULL == pass || NULL == exists) {
|
if (NULL == pCtg || NULL == user || NULL == dbFName || NULL == pass || NULL == exists) {
|
||||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
CTG_ERR_JRET(ctgChkAuth(pCtg, pConn, user, dbFName, type, pass, exists));
|
CTG_ERR_JRET(ctgChkAuth(pCtg, NULL, user, dbFName, type, pass, exists));
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
|
|
|
@ -1204,11 +1204,15 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
||||||
stbCtx.flag = flag;
|
stbCtx.flag = flag;
|
||||||
stbCtx.pName = &stbName;
|
stbCtx.pName = &stbName;
|
||||||
|
|
||||||
taosMemoryFreeClear(pOut->tbMeta);
|
STableMeta *stbMeta = NULL;
|
||||||
CTG_ERR_JRET(ctgReadTbMetaFromCache(pCtg, &stbCtx, &pOut->tbMeta));
|
ctgReadTbMetaFromCache(pCtg, &stbCtx, &stbMeta);
|
||||||
if (pOut->tbMeta) {
|
if (stbMeta && stbMeta->sversion >= pOut->tbMeta->sversion) {
|
||||||
ctgDebug("use cached stb meta, tbName:%s", tNameGetTableName(pName));
|
ctgDebug("use cached stb meta, tbName:%s", tNameGetTableName(pName));
|
||||||
exist = 1;
|
exist = 1;
|
||||||
|
} else {
|
||||||
|
ctgDebug("need to get/update stb meta, tbName:%s", tNameGetTableName(pName));
|
||||||
|
taosMemoryFreeClear(pOut->tbMeta);
|
||||||
|
taosMemoryFreeClear(stbMeta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1641,7 +1645,7 @@ int32_t ctgLaunchGetTbMetaTask(SCtgTask* pTask) {
|
||||||
pMsgCtx->pBatchs = pJob->pBatchs;
|
pMsgCtx->pBatchs = pJob->pBatchs;
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_ERR_RET(ctgGetTbMetaFromCache(pCtg, pConn, (SCtgTbMetaCtx*)pTask->taskCtx, (STableMeta**)&pTask->res));
|
CTG_ERR_RET(ctgGetTbMetaFromCache(pCtg, (SCtgTbMetaCtx*)pTask->taskCtx, (STableMeta**)&pTask->res));
|
||||||
if (pTask->res) {
|
if (pTask->res) {
|
||||||
CTG_ERR_RET(ctgHandleTaskEnd(pTask, 0));
|
CTG_ERR_RET(ctgHandleTaskEnd(pTask, 0));
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -248,6 +248,8 @@ int32_t ctgAcquireStbMetaFromCache(SCatalog *pCtg, char *dbFName, uint64_t suid,
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosHashRelease(dbCache->stbCache, stName);
|
||||||
|
|
||||||
CTG_LOCK(CTG_READ, &pCache->metaLock);
|
CTG_LOCK(CTG_READ, &pCache->metaLock);
|
||||||
if (NULL == pCache->pMeta) {
|
if (NULL == pCache->pMeta) {
|
||||||
ctgDebug("stb 0x%" PRIx64 " meta not in cache, dbFName:%s", suid, dbFName);
|
ctgDebug("stb 0x%" PRIx64 " meta not in cache, dbFName:%s", suid, dbFName);
|
||||||
|
@ -1550,7 +1552,7 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
|
||||||
char *dbFName = msg->dbFName;
|
char *dbFName = msg->dbFName;
|
||||||
SCatalog *pCtg = msg->pCtg;
|
SCatalog *pCtg = msg->pCtg;
|
||||||
|
|
||||||
if (NULL == dbInfo->vgHash) {
|
if (pCtg->stopUpdate || NULL == dbInfo->vgHash) {
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1620,6 +1622,10 @@ int32_t ctgOpDropDbCache(SCtgCacheOperation *operation) {
|
||||||
SCtgDropDBMsg *msg = operation->data;
|
SCtgDropDBMsg *msg = operation->data;
|
||||||
SCatalog *pCtg = msg->pCtg;
|
SCatalog *pCtg = msg->pCtg;
|
||||||
|
|
||||||
|
if (pCtg->stopUpdate) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
ctgGetDBCache(msg->pCtg, msg->dbFName, &dbCache);
|
ctgGetDBCache(msg->pCtg, msg->dbFName, &dbCache);
|
||||||
if (NULL == dbCache) {
|
if (NULL == dbCache) {
|
||||||
|
@ -1646,6 +1652,10 @@ int32_t ctgOpDropDbVgroup(SCtgCacheOperation *operation) {
|
||||||
SCtgDropDbVgroupMsg *msg = operation->data;
|
SCtgDropDbVgroupMsg *msg = operation->data;
|
||||||
SCatalog *pCtg = msg->pCtg;
|
SCatalog *pCtg = msg->pCtg;
|
||||||
|
|
||||||
|
if (pCtg->stopUpdate) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
ctgGetDBCache(msg->pCtg, msg->dbFName, &dbCache);
|
ctgGetDBCache(msg->pCtg, msg->dbFName, &dbCache);
|
||||||
if (NULL == dbCache) {
|
if (NULL == dbCache) {
|
||||||
|
@ -1675,6 +1685,10 @@ int32_t ctgOpUpdateTbMeta(SCtgCacheOperation *operation) {
|
||||||
STableMetaOutput *pMeta = msg->pMeta;
|
STableMetaOutput *pMeta = msg->pMeta;
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
|
|
||||||
|
if (pCtg->stopUpdate) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((!CTG_IS_META_CTABLE(pMeta->metaType)) && NULL == pMeta->tbMeta) {
|
if ((!CTG_IS_META_CTABLE(pMeta->metaType)) && NULL == pMeta->tbMeta) {
|
||||||
ctgError("no valid tbmeta got from meta rsp, dbFName:%s, tbName:%s", pMeta->dbFName, pMeta->tbName);
|
ctgError("no valid tbmeta got from meta rsp, dbFName:%s, tbName:%s", pMeta->dbFName, pMeta->tbName);
|
||||||
CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||||
|
@ -1723,6 +1737,10 @@ int32_t ctgOpDropStbMeta(SCtgCacheOperation *operation) {
|
||||||
SCtgDropStbMetaMsg *msg = operation->data;
|
SCtgDropStbMetaMsg *msg = operation->data;
|
||||||
SCatalog *pCtg = msg->pCtg;
|
SCatalog *pCtg = msg->pCtg;
|
||||||
|
|
||||||
|
if (pCtg->stopUpdate) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
ctgGetDBCache(pCtg, msg->dbFName, &dbCache);
|
ctgGetDBCache(pCtg, msg->dbFName, &dbCache);
|
||||||
if (NULL == dbCache) {
|
if (NULL == dbCache) {
|
||||||
|
@ -1776,6 +1794,10 @@ int32_t ctgOpDropTbMeta(SCtgCacheOperation *operation) {
|
||||||
SCtgDropTblMetaMsg *msg = operation->data;
|
SCtgDropTblMetaMsg *msg = operation->data;
|
||||||
SCatalog *pCtg = msg->pCtg;
|
SCatalog *pCtg = msg->pCtg;
|
||||||
|
|
||||||
|
if (pCtg->stopUpdate) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
ctgGetDBCache(pCtg, msg->dbFName, &dbCache);
|
ctgGetDBCache(pCtg, msg->dbFName, &dbCache);
|
||||||
if (NULL == dbCache) {
|
if (NULL == dbCache) {
|
||||||
|
@ -1819,6 +1841,10 @@ int32_t ctgOpUpdateUser(SCtgCacheOperation *operation) {
|
||||||
SCtgUpdateUserMsg *msg = operation->data;
|
SCtgUpdateUserMsg *msg = operation->data;
|
||||||
SCatalog *pCtg = msg->pCtg;
|
SCatalog *pCtg = msg->pCtg;
|
||||||
|
|
||||||
|
if (pCtg->stopUpdate) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
SCtgUserAuth *pUser = (SCtgUserAuth *)taosHashGet(pCtg->userCache, msg->userAuth.user, strlen(msg->userAuth.user));
|
SCtgUserAuth *pUser = (SCtgUserAuth *)taosHashGet(pCtg->userCache, msg->userAuth.user, strlen(msg->userAuth.user));
|
||||||
if (NULL == pUser) {
|
if (NULL == pUser) {
|
||||||
SCtgUserAuth userAuth = {0};
|
SCtgUserAuth userAuth = {0};
|
||||||
|
@ -1872,8 +1898,12 @@ int32_t ctgOpUpdateEpset(SCtgCacheOperation *operation) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgUpdateEpsetMsg *msg = operation->data;
|
SCtgUpdateEpsetMsg *msg = operation->data;
|
||||||
SCatalog *pCtg = msg->pCtg;
|
SCatalog *pCtg = msg->pCtg;
|
||||||
|
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
|
|
||||||
|
if (pCtg->stopUpdate) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
CTG_ERR_JRET(ctgGetDBCache(pCtg, msg->dbFName, &dbCache));
|
CTG_ERR_JRET(ctgGetDBCache(pCtg, msg->dbFName, &dbCache));
|
||||||
if (NULL == dbCache) {
|
if (NULL == dbCache) {
|
||||||
ctgDebug("db %s not exist, ignore epset update", msg->dbFName);
|
ctgDebug("db %s not exist, ignore epset update", msg->dbFName);
|
||||||
|
@ -1920,6 +1950,10 @@ int32_t ctgOpUpdateTbIndex(SCtgCacheOperation *operation) {
|
||||||
STableIndex *pIndex = msg->pIndex;
|
STableIndex *pIndex = msg->pIndex;
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
|
|
||||||
|
if (pCtg->stopUpdate) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
CTG_ERR_JRET(ctgGetAddDBCache(pCtg, pIndex->dbFName, 0, &dbCache));
|
CTG_ERR_JRET(ctgGetAddDBCache(pCtg, pIndex->dbFName, 0, &dbCache));
|
||||||
|
|
||||||
CTG_ERR_JRET(ctgWriteTbIndexToCache(pCtg, dbCache, pIndex->dbFName, pIndex->tbName, &pIndex));
|
CTG_ERR_JRET(ctgWriteTbIndexToCache(pCtg, dbCache, pIndex->dbFName, pIndex->tbName, &pIndex));
|
||||||
|
@ -1942,6 +1976,10 @@ int32_t ctgOpDropTbIndex(SCtgCacheOperation *operation) {
|
||||||
SCatalog *pCtg = msg->pCtg;
|
SCatalog *pCtg = msg->pCtg;
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
|
|
||||||
|
if (pCtg->stopUpdate) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
CTG_ERR_JRET(ctgGetDBCache(pCtg, msg->dbFName, &dbCache));
|
CTG_ERR_JRET(ctgGetDBCache(pCtg, msg->dbFName, &dbCache));
|
||||||
if (NULL == dbCache) {
|
if (NULL == dbCache) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -2154,7 +2192,7 @@ int32_t ctgStartUpdateThread() {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgGetTbMetaFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMetaCtx *ctx, STableMeta **pTableMeta) {
|
int32_t ctgGetTbMetaFromCache(SCatalog *pCtg, SCtgTbMetaCtx *ctx, STableMeta **pTableMeta) {
|
||||||
if (IS_SYS_DBNAME(ctx->pName->dbname)) {
|
if (IS_SYS_DBNAME(ctx->pName->dbname)) {
|
||||||
CTG_FLAG_SET_SYS_DB(ctx->flag);
|
CTG_FLAG_SET_SYS_DB(ctx->flag);
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,28 +226,45 @@ _return:
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgdEnableDebug(char *option) {
|
int32_t ctgdEnableDebug(char *option, bool enable) {
|
||||||
if (0 == strcasecmp(option, "lock")) {
|
if (0 == strcasecmp(option, "lock")) {
|
||||||
gCTGDebug.lockEnable = true;
|
gCTGDebug.lockEnable = enable;
|
||||||
qDebug("lock debug enabled");
|
qDebug("catalog lock debug set to %d", enable);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == strcasecmp(option, "cache")) {
|
if (0 == strcasecmp(option, "cache")) {
|
||||||
gCTGDebug.cacheEnable = true;
|
gCTGDebug.cacheEnable = enable;
|
||||||
qDebug("cache debug enabled");
|
qDebug("catalog cache debug set to %d", enable);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == strcasecmp(option, "api")) {
|
if (0 == strcasecmp(option, "api")) {
|
||||||
gCTGDebug.apiEnable = true;
|
gCTGDebug.apiEnable = enable;
|
||||||
qDebug("api debug enabled");
|
qDebug("catalog api debug set to %d", enable);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == strcasecmp(option, "meta")) {
|
if (0 == strcasecmp(option, "meta")) {
|
||||||
gCTGDebug.metaEnable = true;
|
gCTGDebug.metaEnable = enable;
|
||||||
qDebug("api debug enabled");
|
qDebug("catalog meta debug set to %d", enable);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 == strcasecmp(option, "stopUpdate")) {
|
||||||
|
SCatalog *pCtg = NULL;
|
||||||
|
|
||||||
|
void *pIter = taosHashIterate(gCtgMgmt.pCluster, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
pCtg = *(SCatalog **)pIter;
|
||||||
|
|
||||||
|
pCtg->stopUpdate = enable;
|
||||||
|
|
||||||
|
pIter = taosHashIterate(gCtgMgmt.pCluster, pIter);
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("catalog stopUpdate set to %d", enable);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,6 +273,77 @@ int32_t ctgdEnableDebug(char *option) {
|
||||||
return TSDB_CODE_CTG_INTERNAL_ERROR;
|
return TSDB_CODE_CTG_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgdHandleDbgCommand(char *command) {
|
||||||
|
if (NULL == command) {
|
||||||
|
CTG_RET(TSDB_CODE_INVALID_PARA);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen(command) > CTG_MAX_COMMAND_LEN) {
|
||||||
|
CTG_RET(TSDB_CODE_INVALID_PARA);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *dup = strdup(command);
|
||||||
|
char *option = NULL;
|
||||||
|
char *param = NULL;
|
||||||
|
|
||||||
|
int32_t i = 0;
|
||||||
|
bool newItem = true;
|
||||||
|
while (*(dup + i)) {
|
||||||
|
if (isspace(*(dup + i))) {
|
||||||
|
*(dup + i) = 0;
|
||||||
|
++i;
|
||||||
|
newItem = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!newItem) {
|
||||||
|
++i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
newItem = false;
|
||||||
|
if (NULL == option) {
|
||||||
|
option = dup + i;
|
||||||
|
++i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL == param) {
|
||||||
|
param = dup + i;
|
||||||
|
++i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(dup);
|
||||||
|
CTG_RET(TSDB_CODE_INVALID_PARA);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool enable = atoi(param);
|
||||||
|
|
||||||
|
int32_t code = ctgdEnableDebug(option, enable);
|
||||||
|
|
||||||
|
taosMemoryFree(dup);
|
||||||
|
|
||||||
|
CTG_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ctgdGetOneHandle(SCatalog **pHandle) {
|
||||||
|
SCatalog *pCtg = NULL;
|
||||||
|
|
||||||
|
void *pIter = taosHashIterate(gCtgMgmt.pCluster, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
pCtg = *(SCatalog **)pIter;
|
||||||
|
|
||||||
|
taosHashCancelIterate(gCtgMgmt.pCluster, pIter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pHandle = pCtg;
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgdGetStatNum(char *option, void *res) {
|
int32_t ctgdGetStatNum(char *option, void *res) {
|
||||||
if (0 == strcasecmp(option, "runtime.numOfOpDequeue")) {
|
if (0 == strcasecmp(option, "runtime.numOfOpDequeue")) {
|
||||||
*(uint64_t *)res = atomic_load_64(&gCtgMgmt.stat.runtime.numOfOpDequeue);
|
*(uint64_t *)res = atomic_load_64(&gCtgMgmt.stat.runtime.numOfOpDequeue);
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
extern "C" int32_t ctgdGetClusterCacheNum(struct SCatalog *pCatalog, int32_t type);
|
extern "C" int32_t ctgdGetClusterCacheNum(struct SCatalog *pCatalog, int32_t type);
|
||||||
extern "C" int32_t ctgdEnableDebug(char *option);
|
|
||||||
extern "C" int32_t ctgdGetStatNum(char *option, void *res);
|
extern "C" int32_t ctgdGetStatNum(char *option, void *res);
|
||||||
|
|
||||||
void ctgTestSetRspTableMeta();
|
void ctgTestSetRspTableMeta();
|
||||||
|
@ -49,6 +48,8 @@ void ctgTestSetRspCTableMeta();
|
||||||
void ctgTestSetRspSTableMeta();
|
void ctgTestSetRspSTableMeta();
|
||||||
void ctgTestSetRspMultiSTableMeta();
|
void ctgTestSetRspMultiSTableMeta();
|
||||||
|
|
||||||
|
extern int32_t clientConnRefPool;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
CTGT_RSP_VGINFO = 1,
|
CTGT_RSP_VGINFO = 1,
|
||||||
CTGT_RSP_TBMETA,
|
CTGT_RSP_TBMETA,
|
||||||
|
@ -151,10 +152,10 @@ void ctgTestInitLogFile() {
|
||||||
qDebugFlag = 159;
|
qDebugFlag = 159;
|
||||||
strcpy(tsLogDir, TD_LOG_DIR_PATH);
|
strcpy(tsLogDir, TD_LOG_DIR_PATH);
|
||||||
|
|
||||||
ctgdEnableDebug("api");
|
ctgdEnableDebug("api", true);
|
||||||
ctgdEnableDebug("meta");
|
ctgdEnableDebug("meta", true);
|
||||||
ctgdEnableDebug("cache");
|
ctgdEnableDebug("cache", true);
|
||||||
ctgdEnableDebug("lock");
|
ctgdEnableDebug("lock", true);
|
||||||
|
|
||||||
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
|
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
|
||||||
printf("failed to open log file in directory:%s\n", tsLogDir);
|
printf("failed to open log file in directory:%s\n", tsLogDir);
|
||||||
|
@ -1204,6 +1205,34 @@ void *ctgTestSetCtableMetaThread(void *param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ctgTestFetchRows(TAOS_RES *result, int32_t *rows) {
|
||||||
|
TAOS_ROW row;
|
||||||
|
int num_fields = taos_num_fields(result);
|
||||||
|
TAOS_FIELD *fields = taos_fetch_fields(result);
|
||||||
|
char temp[256];
|
||||||
|
|
||||||
|
// fetch the records row by row
|
||||||
|
while ((row = taos_fetch_row(result))) {
|
||||||
|
(*rows)++;
|
||||||
|
memset(temp, 0, sizeof(temp));
|
||||||
|
taos_print_row(temp, row, fields, num_fields);
|
||||||
|
printf("\t[%s]\n", temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ctgTestExecQuery(TAOS * taos, char* sql, bool fetch, int32_t *rows) {
|
||||||
|
TAOS_RES *result = taos_query(taos, sql);
|
||||||
|
int code = taos_errno(result);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
if (fetch) {
|
||||||
|
ctgTestFetchRows(result, rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
taos_free_result(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(tableMeta, normalTable) {
|
TEST(tableMeta, normalTable) {
|
||||||
struct SCatalog *pCtg = NULL;
|
struct SCatalog *pCtg = NULL;
|
||||||
SVgroupInfo vgInfo = {0};
|
SVgroupInfo vgInfo = {0};
|
||||||
|
@ -1245,7 +1274,7 @@ TEST(tableMeta, normalTable) {
|
||||||
|
|
||||||
memset(&vgInfo, 0, sizeof(vgInfo));
|
memset(&vgInfo, 0, sizeof(vgInfo));
|
||||||
bool exists = false;
|
bool exists = false;
|
||||||
code = catalogGetCachedTableHashVgroup(pCtg, mockPointer, &n, &vgInfo, &exists);
|
code = catalogGetCachedTableHashVgroup(pCtg, &n, &vgInfo, &exists);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
ASSERT_EQ(vgInfo.vgId, 8);
|
ASSERT_EQ(vgInfo.vgId, 8);
|
||||||
ASSERT_EQ(vgInfo.epSet.numOfEps, 3);
|
ASSERT_EQ(vgInfo.epSet.numOfEps, 3);
|
||||||
|
@ -1292,7 +1321,7 @@ TEST(tableMeta, normalTable) {
|
||||||
taosMemoryFree(tableMeta);
|
taosMemoryFree(tableMeta);
|
||||||
|
|
||||||
tableMeta = NULL;
|
tableMeta = NULL;
|
||||||
catalogGetCachedTableMeta(pCtg, mockPointer, &n, &tableMeta);
|
catalogGetCachedTableMeta(pCtg, &n, &tableMeta);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
ASSERT_EQ(tableMeta->vgId, 8);
|
ASSERT_EQ(tableMeta->vgId, 8);
|
||||||
ASSERT_EQ(tableMeta->tableType, TSDB_NORMAL_TABLE);
|
ASSERT_EQ(tableMeta->tableType, TSDB_NORMAL_TABLE);
|
||||||
|
@ -1500,7 +1529,7 @@ TEST(tableMeta, superTableCase) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tableMeta = NULL;
|
tableMeta = NULL;
|
||||||
code = catalogGetCachedSTableMeta(pCtg, mockPointer, &n, &tableMeta);
|
code = catalogGetCachedSTableMeta(pCtg, &n, &tableMeta);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
ASSERT_EQ(tableMeta->vgId, 0);
|
ASSERT_EQ(tableMeta->vgId, 0);
|
||||||
ASSERT_EQ(tableMeta->tableType, TSDB_SUPER_TABLE);
|
ASSERT_EQ(tableMeta->tableType, TSDB_SUPER_TABLE);
|
||||||
|
@ -2772,7 +2801,7 @@ TEST(apiTest, catalogChkAuth_test) {
|
||||||
|
|
||||||
bool pass = false;
|
bool pass = false;
|
||||||
bool exists = false;
|
bool exists = false;
|
||||||
code = catalogChkAuthFromCache(pCtg, mockPointer, ctgTestUsername, ctgTestDbname, AUTH_TYPE_READ, &pass, &exists);
|
code = catalogChkAuthFromCache(pCtg, ctgTestUsername, ctgTestDbname, AUTH_TYPE_READ, &pass, &exists);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
ASSERT_EQ(exists, false);
|
ASSERT_EQ(exists, false);
|
||||||
|
|
||||||
|
@ -2790,7 +2819,7 @@ TEST(apiTest, catalogChkAuth_test) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
code = catalogChkAuthFromCache(pCtg, mockPointer, ctgTestUsername, ctgTestDbname, AUTH_TYPE_READ, &pass, &exists);
|
code = catalogChkAuthFromCache(pCtg, ctgTestUsername, ctgTestDbname, AUTH_TYPE_READ, &pass, &exists);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
ASSERT_EQ(pass, true);
|
ASSERT_EQ(pass, true);
|
||||||
ASSERT_EQ(exists, true);
|
ASSERT_EQ(exists, true);
|
||||||
|
@ -3063,6 +3092,58 @@ TEST(apiTest, catalogGetDnodeList_test) {
|
||||||
catalogDestroy();
|
catalogDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef INTEGRATION_TEST
|
||||||
|
TEST(intTest, autoCreateTableTest) {
|
||||||
|
struct SCatalog *pCtg = NULL;
|
||||||
|
|
||||||
|
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
ASSERT_TRUE(NULL != taos);
|
||||||
|
|
||||||
|
ctgdEnableDebug("api", true);
|
||||||
|
ctgdEnableDebug("meta", true);
|
||||||
|
ctgdEnableDebug("cache", true);
|
||||||
|
ctgdEnableDebug("lock", true);
|
||||||
|
|
||||||
|
ctgTestExecQuery(taos, "drop database if exists db1", false, NULL);
|
||||||
|
ctgTestExecQuery(taos, "create database db1", false, NULL);
|
||||||
|
ctgTestExecQuery(taos, "create stable db1.st1 (ts timestamp, f1 int) tags(tg1 int)", false, NULL);
|
||||||
|
ctgTestExecQuery(taos, "insert into db1.tb1 using db1.st1 tags(1) values(now, 1)", false, NULL);
|
||||||
|
|
||||||
|
ctgdGetOneHandle(&pCtg);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
uint32_t n = ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM);
|
||||||
|
if (2 != n) {
|
||||||
|
taosMsleep(50);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t n = 0, m = 0;
|
||||||
|
ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n);
|
||||||
|
|
||||||
|
ctgTestExecQuery(taos, "insert into db1.tb1 using db1.st1 tags(1) values(now, 2)", false, NULL);
|
||||||
|
|
||||||
|
ctgTestExecQuery(taos, "insert into db1.tb1 values(now, 3)", false, NULL);
|
||||||
|
|
||||||
|
taosMsleep(1000);
|
||||||
|
ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&m);
|
||||||
|
|
||||||
|
ASSERT_EQ(n, m);
|
||||||
|
|
||||||
|
ctgdEnableDebug("stopUpdate", true);
|
||||||
|
ctgTestExecQuery(taos, "alter table db1.st1 add column f2 double", false, NULL);
|
||||||
|
|
||||||
|
ctgdEnableDebug("stopUpdate", false);
|
||||||
|
|
||||||
|
ctgTestExecQuery(taos, "insert into db1.tb1 (ts, f1) values(now, 4)", false, NULL);
|
||||||
|
|
||||||
|
taos_close(taos);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
|
@ -96,6 +96,7 @@ extern "C" {
|
||||||
#define COMMAND_RESET_LOG "resetLog"
|
#define COMMAND_RESET_LOG "resetLog"
|
||||||
#define COMMAND_SCHEDULE_POLICY "schedulePolicy"
|
#define COMMAND_SCHEDULE_POLICY "schedulePolicy"
|
||||||
#define COMMAND_ENABLE_RESCHEDULE "enableReSchedule"
|
#define COMMAND_ENABLE_RESCHEDULE "enableReSchedule"
|
||||||
|
#define COMMAND_CATALOG_DEBUG "catalogDebug"
|
||||||
|
|
||||||
typedef struct SExplainGroup {
|
typedef struct SExplainGroup {
|
||||||
int32_t nodeNum;
|
int32_t nodeNum;
|
||||||
|
|
|
@ -571,6 +571,8 @@ static int32_t execAlterCmd(char* cmd, char* value, bool* processed) {
|
||||||
code = schedulerUpdatePolicy(atoi(value));
|
code = schedulerUpdatePolicy(atoi(value));
|
||||||
} else if (0 == strcasecmp(cmd, COMMAND_ENABLE_RESCHEDULE)) {
|
} else if (0 == strcasecmp(cmd, COMMAND_ENABLE_RESCHEDULE)) {
|
||||||
code = schedulerEnableReSchedule(atoi(value));
|
code = schedulerEnableReSchedule(atoi(value));
|
||||||
|
} else if (0 == strcasecmp(cmd, COMMAND_CATALOG_DEBUG)) {
|
||||||
|
code = ctgdHandleDbgCommand(value);
|
||||||
} else {
|
} else {
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,10 @@
|
||||||
// The numOfOutputGroups is specified by physical plan. and will not be affect by numOfGroups
|
// The numOfOutputGroups is specified by physical plan. and will not be affect by numOfGroups
|
||||||
struct STableListInfo {
|
struct STableListInfo {
|
||||||
bool oneTableForEachGroup;
|
bool oneTableForEachGroup;
|
||||||
int32_t numOfOuputGroups; // the data block will be generated one by one
|
int32_t numOfOuputGroups; // the data block will be generated one by one
|
||||||
int32_t* groupOffset; // keep the offset value for each group in the tableList
|
int32_t* groupOffset; // keep the offset value for each group in the tableList
|
||||||
SArray* pTableList;
|
SArray* pTableList;
|
||||||
SHashObj* map; // speedup acquire the tableQueryInfo by table uid
|
SHashObj* map; // speedup acquire the tableQueryInfo by table uid
|
||||||
uint64_t suid;
|
uint64_t suid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -925,6 +925,15 @@ static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray*
|
||||||
|
|
||||||
SArray* pTbList = getTableNameList(pList);
|
SArray* pTbList = getTableNameList(pList);
|
||||||
int32_t numOfTables = taosArrayGetSize(pTbList);
|
int32_t numOfTables = taosArrayGetSize(pTbList);
|
||||||
|
SHashObj *uHash = NULL;
|
||||||
|
size_t listlen = taosArrayGetSize(list); // len > 0 means there already have uids
|
||||||
|
if (listlen > 0) {
|
||||||
|
uHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||||
|
for (int i = 0; i < listlen; i++) {
|
||||||
|
int64_t *uid = taosArrayGet(list, i);
|
||||||
|
taosHashPut(uHash, uid, sizeof(int64_t), &i, sizeof(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < numOfTables; i++) {
|
for (int i = 0; i < numOfTables; i++) {
|
||||||
char* name = taosArrayGetP(pTbList, i);
|
char* name = taosArrayGetP(pTbList, i);
|
||||||
|
@ -933,9 +942,12 @@ static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray*
|
||||||
if (metaGetTableUidByName(metaHandle, name, &uid) == 0) {
|
if (metaGetTableUidByName(metaHandle, name, &uid) == 0) {
|
||||||
ETableType tbType = TSDB_TABLE_MAX;
|
ETableType tbType = TSDB_TABLE_MAX;
|
||||||
if (metaGetTableTypeByName(metaHandle, name, &tbType) == 0 && tbType == TSDB_CHILD_TABLE) {
|
if (metaGetTableTypeByName(metaHandle, name, &tbType) == 0 && tbType == TSDB_CHILD_TABLE) {
|
||||||
taosArrayPush(list, &uid);
|
if (NULL == uHash || taosHashGet(uHash, &uid, sizeof(uid)) == NULL) {
|
||||||
|
taosArrayPush(list, &uid);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
taosArrayDestroy(pTbList);
|
taosArrayDestroy(pTbList);
|
||||||
|
taosHashCleanup(uHash);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -944,6 +956,7 @@ static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosHashCleanup(uHash);
|
||||||
taosArrayDestroy(pTbList);
|
taosArrayDestroy(pTbList);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1678,9 +1691,7 @@ uint64_t tableListGetSize(const STableListInfo* pTableList) {
|
||||||
return taosArrayGetSize(pTableList->pTableList);
|
return taosArrayGetSize(pTableList->pTableList);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t tableListGetSuid(const STableListInfo* pTableList) {
|
uint64_t tableListGetSuid(const STableListInfo* pTableList) { return pTableList->suid; }
|
||||||
return pTableList->suid;
|
|
||||||
}
|
|
||||||
|
|
||||||
STableKeyInfo* tableListGetInfo(const STableListInfo* pTableList, int32_t index) {
|
STableKeyInfo* tableListGetInfo(const STableListInfo* pTableList, int32_t index) {
|
||||||
if (taosArrayGetSize(pTableList->pTableList) == 0) {
|
if (taosArrayGetSize(pTableList->pTableList) == 0) {
|
||||||
|
@ -1718,7 +1729,7 @@ int32_t tableListAddTableInfo(STableListInfo* pTableList, uint64_t uid, uint64_t
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tableListGetGroupList(const STableListInfo* pTableList, int32_t ordinalGroupIndex, STableKeyInfo** pKeyInfo,
|
int32_t tableListGetGroupList(const STableListInfo* pTableList, int32_t ordinalGroupIndex, STableKeyInfo** pKeyInfo,
|
||||||
int32_t* size) {
|
int32_t* size) {
|
||||||
int32_t total = tableListGetOutputGroups(pTableList);
|
int32_t total = tableListGetOutputGroups(pTableList);
|
||||||
if (ordinalGroupIndex < 0 || ordinalGroupIndex >= total) {
|
if (ordinalGroupIndex < 0 || ordinalGroupIndex >= total) {
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
@ -1728,7 +1739,7 @@ int32_t tableListGetGroupList(const STableListInfo* pTableList, int32_t ordinalG
|
||||||
// 1. only one group exists, and 2. one table exists for each group.
|
// 1. only one group exists, and 2. one table exists for each group.
|
||||||
if (total == 1) {
|
if (total == 1) {
|
||||||
*size = tableListGetSize(pTableList);
|
*size = tableListGetSize(pTableList);
|
||||||
*pKeyInfo = (*size == 0)? NULL:taosArrayGet(pTableList->pTableList, 0);
|
*pKeyInfo = (*size == 0) ? NULL : taosArrayGet(pTableList->pTableList, 0);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
} else if (total == tableListGetSize(pTableList)) {
|
} else if (total == tableListGetSize(pTableList)) {
|
||||||
*size = 1;
|
*size = 1;
|
||||||
|
@ -1806,13 +1817,13 @@ void tableListClear(STableListInfo* pTableListInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t orderbyGroupIdComparFn(const void* p1, const void* p2) {
|
static int32_t orderbyGroupIdComparFn(const void* p1, const void* p2) {
|
||||||
STableKeyInfo* pInfo1 = (STableKeyInfo*) p1;
|
STableKeyInfo* pInfo1 = (STableKeyInfo*)p1;
|
||||||
STableKeyInfo* pInfo2 = (STableKeyInfo*) p2;
|
STableKeyInfo* pInfo2 = (STableKeyInfo*)p2;
|
||||||
|
|
||||||
if (pInfo1->groupId == pInfo2->groupId) {
|
if (pInfo1->groupId == pInfo2->groupId) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return pInfo1->groupId < pInfo2->groupId? -1:1;
|
return pInfo1->groupId < pInfo2->groupId ? -1 : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1825,12 +1836,12 @@ static int32_t sortTableGroup(STableListInfo* pTableListInfo) {
|
||||||
SArray* pList = taosArrayInit(4, sizeof(int32_t));
|
SArray* pList = taosArrayInit(4, sizeof(int32_t));
|
||||||
|
|
||||||
STableKeyInfo* pInfo = taosArrayGet(pTableListInfo->pTableList, 0);
|
STableKeyInfo* pInfo = taosArrayGet(pTableListInfo->pTableList, 0);
|
||||||
uint64_t gid = pInfo->groupId;
|
uint64_t gid = pInfo->groupId;
|
||||||
|
|
||||||
int32_t start = 0;
|
int32_t start = 0;
|
||||||
taosArrayPush(pList, &start);
|
taosArrayPush(pList, &start);
|
||||||
|
|
||||||
for(int32_t i = 1; i < size; ++i) {
|
for (int32_t i = 1; i < size; ++i) {
|
||||||
pInfo = taosArrayGet(pTableListInfo->pTableList, i);
|
pInfo = taosArrayGet(pTableListInfo->pTableList, i);
|
||||||
if (pInfo->groupId != gid) {
|
if (pInfo->groupId != gid) {
|
||||||
taosArrayPush(pList, &i);
|
taosArrayPush(pList, &i);
|
||||||
|
@ -1845,16 +1856,17 @@ static int32_t sortTableGroup(STableListInfo* pTableListInfo) {
|
||||||
return TDB_CODE_SUCCESS;
|
return TDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t buildGroupIdMapForAllTables(STableListInfo* pTableListInfo, SReadHandle* pHandle, SNodeList* group, bool groupSort) {
|
int32_t buildGroupIdMapForAllTables(STableListInfo* pTableListInfo, SReadHandle* pHandle, SNodeList* group,
|
||||||
|
bool groupSort) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
ASSERT(pTableListInfo->map != NULL);
|
ASSERT(pTableListInfo->map != NULL);
|
||||||
|
|
||||||
bool groupByTbname = groupbyTbname(group);
|
bool groupByTbname = groupbyTbname(group);
|
||||||
size_t numOfTables = taosArrayGetSize(pTableListInfo->pTableList);
|
size_t numOfTables = taosArrayGetSize(pTableListInfo->pTableList);
|
||||||
if (group == NULL || groupByTbname) {
|
if (group == NULL || groupByTbname) {
|
||||||
for (int32_t i = 0; i < numOfTables; i++) {
|
for (int32_t i = 0; i < numOfTables; i++) {
|
||||||
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
||||||
info->groupId = groupByTbname? info->uid:0;
|
info->groupId = groupByTbname ? info->uid : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTableListInfo->oneTableForEachGroup = groupByTbname;
|
pTableListInfo->oneTableForEachGroup = groupByTbname;
|
||||||
|
@ -1878,7 +1890,7 @@ int32_t buildGroupIdMapForAllTables(STableListInfo* pTableListInfo, SReadHandle*
|
||||||
|
|
||||||
// add all table entry in the hash map
|
// add all table entry in the hash map
|
||||||
size_t size = taosArrayGetSize(pTableListInfo->pTableList);
|
size_t size = taosArrayGetSize(pTableListInfo->pTableList);
|
||||||
for(int32_t i = 0; i < size; ++i) {
|
for (int32_t i = 0; i < size; ++i) {
|
||||||
STableKeyInfo* p = taosArrayGet(pTableListInfo->pTableList, i);
|
STableKeyInfo* p = taosArrayGet(pTableListInfo->pTableList, i);
|
||||||
taosHashPut(pTableListInfo->map, &p->uid, sizeof(uint64_t), &i, sizeof(int32_t));
|
taosHashPut(pTableListInfo->map, &p->uid, sizeof(uint64_t), &i, sizeof(int32_t));
|
||||||
}
|
}
|
||||||
|
@ -1889,7 +1901,7 @@ int32_t buildGroupIdMapForAllTables(STableListInfo* pTableListInfo, SReadHandle*
|
||||||
int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags, bool groupSort, SReadHandle* pHandle,
|
int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags, bool groupSort, SReadHandle* pHandle,
|
||||||
STableListInfo* pTableListInfo, SNode* pTagCond, SNode* pTagIndexCond,
|
STableListInfo* pTableListInfo, SNode* pTagCond, SNode* pTagIndexCond,
|
||||||
struct SExecTaskInfo* pTaskInfo) {
|
struct SExecTaskInfo* pTaskInfo) {
|
||||||
int64_t st = taosGetTimestampUs();
|
int64_t st = taosGetTimestampUs();
|
||||||
const char* idStr = GET_TASKID(pTaskInfo);
|
const char* idStr = GET_TASKID(pTaskInfo);
|
||||||
|
|
||||||
if (pHandle == NULL) {
|
if (pHandle == NULL) {
|
||||||
|
@ -1919,7 +1931,7 @@ int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTaskInfo->cost.groupIdMapTime = (taosGetTimestampUs() - st1)/1000.0;
|
pTaskInfo->cost.groupIdMapTime = (taosGetTimestampUs() - st1) / 1000.0;
|
||||||
qDebug("generate group id map completed, elapsed time:%.2f ms %s", pTaskInfo->cost.groupIdMapTime, idStr);
|
qDebug("generate group id map completed, elapsed time:%.2f ms %s", pTaskInfo->cost.groupIdMapTime, idStr);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -321,7 +321,7 @@ static SArray* filterUnqualifiedTables(const SStreamScanInfo* pScanInfo, const S
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bool isAdd) {
|
int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bool isAdd) {
|
||||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||||
|
|
||||||
if (isAdd) {
|
if (isAdd) {
|
||||||
qDebug("add %d tables id into query list, %s", (int32_t)taosArrayGetSize(tableIdList), pTaskInfo->id.str);
|
qDebug("add %d tables id into query list, %s", (int32_t)taosArrayGetSize(tableIdList), pTaskInfo->id.str);
|
||||||
|
@ -473,7 +473,7 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId,
|
||||||
|
|
||||||
qDebug("subplan task create completed, TID:0x%" PRIx64 " QID:0x%" PRIx64, taskId, pSubplan->id.queryId);
|
qDebug("subplan task create completed, TID:0x%" PRIx64 " QID:0x%" PRIx64, taskId, pSubplan->id.queryId);
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
// if failed to add ref for all tables in this query, abort current query
|
// if failed to add ref for all tables in this query, abort current query
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1027,10 +1027,11 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
|
|
||||||
if (pTableScanInfo->dataReader == NULL) {
|
if (pTableScanInfo->dataReader == NULL) {
|
||||||
STableKeyInfo* pList = tableListGetInfo(pTaskInfo->pTableInfoList, 0);
|
STableKeyInfo* pList = tableListGetInfo(pTaskInfo->pTableInfoList, 0);
|
||||||
int32_t num = tableListGetSize(pTaskInfo->pTableInfoList);
|
int32_t num = tableListGetSize(pTaskInfo->pTableInfoList);
|
||||||
|
|
||||||
if (tsdbReaderOpen(pTableScanInfo->readHandle.vnode, &pTableScanInfo->cond, pList, num,
|
if (tsdbReaderOpen(pTableScanInfo->readHandle.vnode, &pTableScanInfo->cond, pList, num,
|
||||||
&pTableScanInfo->dataReader, NULL) < 0 || pTableScanInfo->dataReader == NULL) {
|
&pTableScanInfo->dataReader, NULL) < 0 ||
|
||||||
|
pTableScanInfo->dataReader == NULL) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1071,14 +1072,14 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
initQueryTableDataCondForTmq(&pTaskInfo->streamInfo.tableCond, sContext, &mtInfo);
|
initQueryTableDataCondForTmq(&pTaskInfo->streamInfo.tableCond, sContext, &mtInfo);
|
||||||
pTaskInfo->streamInfo.tableCond.twindows.skey = pOffset->ts;
|
pTaskInfo->streamInfo.tableCond.twindows.skey = pOffset->ts;
|
||||||
|
|
||||||
if (pTaskInfo->pTableInfoList == NULL) {
|
if (pTaskInfo->pTableInfoList == NULL) {
|
||||||
pTaskInfo->pTableInfoList = tableListCreate();
|
pTaskInfo->pTableInfoList = tableListCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
tableListAddTableInfo(pTaskInfo->pTableInfoList, mtInfo.uid, 0);
|
tableListAddTableInfo(pTaskInfo->pTableInfoList, mtInfo.uid, 0);
|
||||||
|
|
||||||
STableKeyInfo* pList = tableListGetInfo(pTaskInfo->pTableInfoList, 0);
|
STableKeyInfo* pList = tableListGetInfo(pTaskInfo->pTableInfoList, 0);
|
||||||
int32_t size = tableListGetSize(pTaskInfo->pTableInfoList);
|
int32_t size = tableListGetSize(pTaskInfo->pTableInfoList);
|
||||||
ASSERT(size == 1);
|
ASSERT(size == 1);
|
||||||
|
|
||||||
tsdbReaderOpen(pInfo->vnode, &pTaskInfo->streamInfo.tableCond, pList, size, &pInfo->dataReader, NULL);
|
tsdbReaderOpen(pInfo->vnode, &pTaskInfo->streamInfo.tableCond, pList, size, &pInfo->dataReader, NULL);
|
||||||
|
|
|
@ -621,9 +621,10 @@ int32_t* setupColumnOffset(const SSDataBlock* pBlock, int32_t rowCapacity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clearPartitionOperator(SPartitionOperatorInfo* pInfo) {
|
static void clearPartitionOperator(SPartitionOperatorInfo* pInfo) {
|
||||||
void* ite = NULL;
|
int32_t size = taosArrayGetSize(pInfo->sortedGroupArray);
|
||||||
while ((ite = taosHashIterate(pInfo->pGroupSet, ite)) != NULL) {
|
for (int32_t i = 0; i < size; i++) {
|
||||||
taosArrayDestroy(((SDataGroupInfo*)ite)->pPageList);
|
SDataGroupInfo* pGp = taosArrayGet(pInfo->sortedGroupArray, i);
|
||||||
|
taosArrayDestroy(pGp->pPageList);
|
||||||
}
|
}
|
||||||
taosArrayClear(pInfo->sortedGroupArray);
|
taosArrayClear(pInfo->sortedGroupArray);
|
||||||
clearDiskbasedBuf(pInfo->pBuf);
|
clearDiskbasedBuf(pInfo->pBuf);
|
||||||
|
|
|
@ -1062,15 +1062,18 @@ SOperatorInfo* createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDi
|
||||||
|
|
||||||
int32_t code = initTableblockDistQueryCond(pBlockScanNode->suid, &cond);
|
int32_t code = initTableblockDistQueryCond(pBlockScanNode->suid, &cond);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return NULL;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableListInfo* pTableListInfo = pTaskInfo->pTableInfoList;
|
STableListInfo* pTableListInfo = pTaskInfo->pTableInfoList;
|
||||||
size_t num = tableListGetSize(pTableListInfo);
|
size_t num = tableListGetSize(pTableListInfo);
|
||||||
void* pList = tableListGetInfo(pTableListInfo, 0);
|
void* pList = tableListGetInfo(pTableListInfo, 0);
|
||||||
|
|
||||||
tsdbReaderOpen(readHandle->vnode, &cond, pList, num, &pInfo->pHandle, pTaskInfo->id.str);
|
code = tsdbReaderOpen(readHandle->vnode, &cond, pList, num, &pInfo->pHandle, pTaskInfo->id.str);
|
||||||
cleanupQueryTableDataCond(&cond);
|
cleanupQueryTableDataCond(&cond);
|
||||||
|
if (code != 0) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->readHandle = *readHandle;
|
pInfo->readHandle = *readHandle;
|
||||||
|
@ -1164,6 +1167,7 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU
|
||||||
GET_TASKID(pTaskInfo));
|
GET_TASKID(pTaskInfo));
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2426,8 +2430,9 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
if (pHandle->initTableReader) {
|
if (pHandle->initTableReader) {
|
||||||
pTSInfo->scanMode = TABLE_SCAN__TABLE_ORDER;
|
pTSInfo->scanMode = TABLE_SCAN__TABLE_ORDER;
|
||||||
pTSInfo->dataReader = NULL;
|
pTSInfo->dataReader = NULL;
|
||||||
if (tsdbReaderOpen(pHandle->vnode, &pTSInfo->cond, pList, num, &pTSInfo->dataReader, NULL) < 0) {
|
int32_t code = tsdbReaderOpen(pHandle->vnode, &pTSInfo->cond, pList, num, &pTSInfo->dataReader, NULL);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
if (code != 0) {
|
||||||
|
terrno = code;
|
||||||
destroyTableScanOperatorInfo(pTableScanOp);
|
destroyTableScanOperatorInfo(pTableScanOp);
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
@ -4292,131 +4297,6 @@ int32_t createMultipleDataReaders(SQueryTableDataCond* pQueryCond, SReadHandle*
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t createMultipleDataReaders2(SQueryTableDataCond* pQueryCond, SReadHandle* pHandle,
|
|
||||||
STableListInfo* pTableListInfo, int32_t tableStartIdx, int32_t tableEndIdx,
|
|
||||||
STsdbReader** ppReader, const char* idstr) {
|
|
||||||
STsdbReader* pReader = NULL;
|
|
||||||
void* pStart = tableListGetInfo(pTableListInfo, tableStartIdx);
|
|
||||||
int32_t num = tableEndIdx - tableStartIdx + 1;
|
|
||||||
|
|
||||||
int32_t code = tsdbReaderOpen(pHandle->vnode, pQueryCond, pStart, num, &pReader, idstr);
|
|
||||||
if (code != 0) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ppReader = pReader;
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t loadDataBlockFromOneTable2(SOperatorInfo* pOperator, STableMergeScanInfo* pTableScanInfo,
|
|
||||||
SSDataBlock* pBlock, uint32_t* status) {
|
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
|
||||||
STableMergeScanInfo* pInfo = pOperator->info;
|
|
||||||
|
|
||||||
uint64_t uid = pBlock->info.uid;
|
|
||||||
|
|
||||||
SFileBlockLoadRecorder* pCost = &pTableScanInfo->readRecorder;
|
|
||||||
|
|
||||||
pCost->totalBlocks += 1;
|
|
||||||
pCost->totalRows += pBlock->info.rows;
|
|
||||||
|
|
||||||
*status = pInfo->dataBlockLoadFlag;
|
|
||||||
if (pTableScanInfo->pFilterNode != NULL ||
|
|
||||||
overlapWithTimeWindow(&pTableScanInfo->interval, &pBlock->info, pTableScanInfo->cond.order)) {
|
|
||||||
(*status) = FUNC_DATA_REQUIRED_DATA_LOAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDataBlockInfo* pBlockInfo = &pBlock->info;
|
|
||||||
taosMemoryFreeClear(pBlock->pBlockAgg);
|
|
||||||
|
|
||||||
if (*status == FUNC_DATA_REQUIRED_FILTEROUT) {
|
|
||||||
qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo),
|
|
||||||
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
|
|
||||||
pCost->filterOutBlocks += 1;
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
} else if (*status == FUNC_DATA_REQUIRED_NOT_LOAD) {
|
|
||||||
qDebug("%s data block skipped, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo),
|
|
||||||
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
|
|
||||||
pCost->skipBlocks += 1;
|
|
||||||
|
|
||||||
// clear all data in pBlock that are set when handing the previous block
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pBlock->pDataBlock); ++i) {
|
|
||||||
SColumnInfoData* pcol = taosArrayGet(pBlock->pDataBlock, i);
|
|
||||||
pcol->pData = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
} else if (*status == FUNC_DATA_REQUIRED_STATIS_LOAD) {
|
|
||||||
pCost->loadBlockStatis += 1;
|
|
||||||
|
|
||||||
bool allColumnsHaveAgg = true;
|
|
||||||
SColumnDataAgg** pColAgg = NULL;
|
|
||||||
STsdbReader* reader = pTableScanInfo->pReader;
|
|
||||||
tsdbRetrieveDatablockSMA(reader, &pColAgg, &allColumnsHaveAgg);
|
|
||||||
|
|
||||||
if (allColumnsHaveAgg == true) {
|
|
||||||
int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
|
|
||||||
|
|
||||||
// todo create this buffer during creating operator
|
|
||||||
if (pBlock->pBlockAgg == NULL) {
|
|
||||||
pBlock->pBlockAgg = taosMemoryCalloc(numOfCols, POINTER_BYTES);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
|
||||||
SColMatchItem* pColMatchInfo = taosArrayGet(pTableScanInfo->matchInfo.pList, i);
|
|
||||||
if (!pColMatchInfo->needOutput) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
pBlock->pBlockAgg[pColMatchInfo->dstSlotId] = pColAgg[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
} else { // failed to load the block sma data, data block statistics does not exist, load data block instead
|
|
||||||
*status = FUNC_DATA_REQUIRED_DATA_LOAD;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT(*status == FUNC_DATA_REQUIRED_DATA_LOAD);
|
|
||||||
|
|
||||||
pCost->totalCheckedRows += pBlock->info.rows;
|
|
||||||
pCost->loadBlocks += 1;
|
|
||||||
|
|
||||||
STsdbReader* reader = pTableScanInfo->pReader;
|
|
||||||
SArray* pCols = tsdbRetrieveDataBlock(reader, NULL);
|
|
||||||
if (pCols == NULL) {
|
|
||||||
return terrno;
|
|
||||||
}
|
|
||||||
|
|
||||||
relocateColumnData(pBlock, pTableScanInfo->matchInfo.pList, pCols, true);
|
|
||||||
|
|
||||||
// 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));
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
T_LONG_JMP(pTaskInfo->env, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pTableScanInfo->pFilterNode != NULL) {
|
|
||||||
int64_t st = taosGetTimestampMs();
|
|
||||||
doFilter(pTableScanInfo->pFilterNode, pBlock, &pTableScanInfo->matchInfo, NULL);
|
|
||||||
|
|
||||||
double el = (taosGetTimestampUs() - st) / 1000.0;
|
|
||||||
pTableScanInfo->readRecorder.filterTime += el;
|
|
||||||
|
|
||||||
if (pBlock->info.rows == 0) {
|
|
||||||
pCost->filterOutBlocks += 1;
|
|
||||||
qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d, elapsed time:%.2f ms",
|
|
||||||
GET_TASKID(pTaskInfo), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, el);
|
|
||||||
} else {
|
|
||||||
qDebug("%s data block filter applied, elapsed time:%.2f ms", GET_TASKID(pTaskInfo), el);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo refactor
|
// todo refactor
|
||||||
static int32_t loadDataBlockFromOneTable(SOperatorInfo* pOperator, STableMergeScanInfo* pTableScanInfo,
|
static int32_t loadDataBlockFromOneTable(SOperatorInfo* pOperator, STableMergeScanInfo* pTableScanInfo,
|
||||||
int32_t readerIdx, SSDataBlock* pBlock, uint32_t* status) {
|
int32_t readerIdx, SSDataBlock* pBlock, uint32_t* status) {
|
||||||
|
@ -4543,7 +4423,7 @@ typedef struct STableMergeScanSortSourceParam {
|
||||||
SSDataBlock* inputBlock;
|
SSDataBlock* inputBlock;
|
||||||
} STableMergeScanSortSourceParam;
|
} STableMergeScanSortSourceParam;
|
||||||
|
|
||||||
static SSDataBlock* getTableDataBlockTemp(void* param) {
|
static SSDataBlock* getTableDataBlockImpl(void* param) {
|
||||||
STableMergeScanSortSourceParam* source = param;
|
STableMergeScanSortSourceParam* source = param;
|
||||||
SOperatorInfo* pOperator = source->pOperator;
|
SOperatorInfo* pOperator = source->pOperator;
|
||||||
STableMergeScanInfo* pInfo = pOperator->info;
|
STableMergeScanInfo* pInfo = pOperator->info;
|
||||||
|
@ -4560,7 +4440,11 @@ static SSDataBlock* getTableDataBlockTemp(void* param) {
|
||||||
|
|
||||||
void* p = tableListGetInfo(pInfo->tableListInfo, readIdx + pInfo->tableStartIndex);
|
void* p = tableListGetInfo(pInfo->tableListInfo, readIdx + pInfo->tableStartIndex);
|
||||||
SReadHandle* pHandle = &pInfo->readHandle;
|
SReadHandle* pHandle = &pInfo->readHandle;
|
||||||
tsdbReaderOpen(pHandle->vnode, pQueryCond, p, 1, &pInfo->pReader, GET_TASKID(pTaskInfo));
|
|
||||||
|
int32_t code = tsdbReaderOpen(pHandle->vnode, pQueryCond, p, 1, &pInfo->pReader, GET_TASKID(pTaskInfo));
|
||||||
|
if (code != 0) {
|
||||||
|
T_LONG_JMP(pOperator->pTaskInfo->env, code);
|
||||||
|
}
|
||||||
|
|
||||||
STsdbReader* reader = pInfo->pReader;
|
STsdbReader* reader = pInfo->pReader;
|
||||||
while (tsdbNextDataBlock(reader)) {
|
while (tsdbNextDataBlock(reader)) {
|
||||||
|
@ -4611,55 +4495,6 @@ static SSDataBlock* getTableDataBlockTemp(void* param) {
|
||||||
pInfo->pReader = NULL;
|
pInfo->pReader = NULL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
static SSDataBlock* getTableDataBlock2(void* param) {
|
|
||||||
STableMergeScanSortSourceParam* source = param;
|
|
||||||
SOperatorInfo* pOperator = source->pOperator;
|
|
||||||
int64_t uid = source->uid;
|
|
||||||
SSDataBlock* pBlock = source->inputBlock;
|
|
||||||
STableMergeScanInfo* pTableScanInfo = pOperator->info;
|
|
||||||
|
|
||||||
int64_t st = taosGetTimestampUs();
|
|
||||||
|
|
||||||
blockDataCleanup(pBlock);
|
|
||||||
|
|
||||||
STsdbReader* reader = pTableScanInfo->pReader;
|
|
||||||
while (tsdbTableNextDataBlock(reader, uid)) {
|
|
||||||
if (isTaskKilled(pOperator->pTaskInfo)) {
|
|
||||||
T_LONG_JMP(pOperator->pTaskInfo->env, TSDB_CODE_TSC_QUERY_CANCELLED);
|
|
||||||
}
|
|
||||||
|
|
||||||
// process this data block based on the probabilities
|
|
||||||
bool processThisBlock = processBlockWithProbability(&pTableScanInfo->sample);
|
|
||||||
if (!processThisBlock) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
blockDataCleanup(pBlock);
|
|
||||||
|
|
||||||
int32_t rows = 0;
|
|
||||||
tsdbRetrieveDataBlockInfo(reader, &rows, &pBlock->info.uid, &pBlock->info.window);
|
|
||||||
blockDataEnsureCapacity(pBlock, rows);
|
|
||||||
pBlock->info.rows = rows;
|
|
||||||
|
|
||||||
uint32_t status = 0;
|
|
||||||
int32_t code = loadDataBlockFromOneTable2(pOperator, pTableScanInfo, pBlock, &status);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
T_LONG_JMP(pOperator->pTaskInfo->env, code);
|
|
||||||
}
|
|
||||||
|
|
||||||
// current block is filter out according to filter condition, continue load the next block
|
|
||||||
if (status == FUNC_DATA_REQUIRED_FILTEROUT || pBlock->info.rows == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
pBlock->info.groupId = getTableGroupId(pOperator->pTaskInfo->pTableInfoList, pBlock->info.uid);
|
|
||||||
pOperator->resultInfo.totalRows = pTableScanInfo->readRecorder.totalRows;
|
|
||||||
pTableScanInfo->readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0;
|
|
||||||
|
|
||||||
return pBlock;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SSDataBlock* getTableDataBlock(void* param) {
|
static SSDataBlock* getTableDataBlock(void* param) {
|
||||||
STableMergeScanSortSourceParam* source = param;
|
STableMergeScanSortSourceParam* source = param;
|
||||||
|
@ -4769,7 +4604,7 @@ int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) {
|
||||||
pInfo->pSortHandle = tsortCreateSortHandle(pInfo->pSortInfo, SORT_MULTISOURCE_MERGE, pInfo->bufPageSize, numOfBufPage,
|
pInfo->pSortHandle = tsortCreateSortHandle(pInfo->pSortInfo, SORT_MULTISOURCE_MERGE, pInfo->bufPageSize, numOfBufPage,
|
||||||
pInfo->pSortInputBlock, pTaskInfo->id.str);
|
pInfo->pSortInputBlock, pTaskInfo->id.str);
|
||||||
|
|
||||||
tsortSetFetchRawDataFp(pInfo->pSortHandle, getTableDataBlockTemp, NULL, NULL);
|
tsortSetFetchRawDataFp(pInfo->pSortHandle, getTableDataBlockImpl, NULL, NULL);
|
||||||
|
|
||||||
// one table has one data block
|
// one table has one data block
|
||||||
int32_t numOfTable = tableEndIdx - tableStartIdx + 1;
|
int32_t numOfTable = tableEndIdx - tableStartIdx + 1;
|
||||||
|
|
|
@ -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 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]);
|
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;
|
// param[0][1] = 0;
|
||||||
double param12 = param[1][2] - param02 * (param[1][0] / param00);
|
double param12 = param[1][2] - param02 * (param[1][0] / param00);
|
||||||
// param[1][0] = 0;
|
// param[1][0] = 0;
|
||||||
|
@ -2707,7 +2713,9 @@ int32_t apercentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
taosMemoryFree(res);
|
taosMemoryFree(res);
|
||||||
} else { // no need to free
|
} else { // no need to free
|
||||||
// setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes);
|
// setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes);
|
||||||
return TSDB_CODE_SUCCESS;
|
// return TSDB_CODE_SUCCESS;
|
||||||
|
qDebug("%s get the final res, elements:%" PRId64 ", numOfEntry:%d. result is null", __FUNCTION__,
|
||||||
|
pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,15 +122,18 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) {
|
||||||
taosGetCpuCores(&numCpuCores);
|
taosGetCpuCores(&numCpuCores);
|
||||||
snprintf(thrdPoolSizeEnvItem, 32, "%s=%d", "UV_THREADPOOL_SIZE", (int)numCpuCores * 2);
|
snprintf(thrdPoolSizeEnvItem, 32, "%s=%d", "UV_THREADPOOL_SIZE", (int)numCpuCores * 2);
|
||||||
|
|
||||||
char pathTaosdLdLib[512] = {0};
|
char pathTaosdLdLib[512] = {0};
|
||||||
size_t taosdLdLibPathLen = sizeof(pathTaosdLdLib);
|
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};
|
char udfdPathLdLib[1024] = {0};
|
||||||
size_t udfdLdLibPathLen = strlen(tsUdfdLdLibPath);
|
size_t udfdLdLibPathLen = strlen(tsUdfdLdLibPath);
|
||||||
strncpy(udfdPathLdLib, tsUdfdLdLibPath, udfdLdLibPathLen);
|
strncpy(udfdPathLdLib, tsUdfdLdLibPath, udfdLdLibPathLen);
|
||||||
udfdPathLdLib[udfdLdLibPathLen] = ':';
|
udfdPathLdLib[udfdLdLibPathLen] = ':';
|
||||||
strncpy(udfdPathLdLib + udfdLdLibPathLen + 1, pathTaosdLdLib, sizeof(udfdPathLdLib) - udfdLdLibPathLen);
|
strncpy(udfdPathLdLib + udfdLdLibPathLen + 1, pathTaosdLdLib, sizeof(udfdPathLdLib) - udfdLdLibPathLen - 1);
|
||||||
if (udfdLdLibPathLen + taosdLdLibPathLen < 1024) {
|
if (udfdLdLibPathLen + taosdLdLibPathLen < 1024) {
|
||||||
fnInfo("udfd LD_LIBRARY_PATH: %s", udfdPathLdLib);
|
fnInfo("udfd LD_LIBRARY_PATH: %s", udfdPathLdLib);
|
||||||
} else {
|
} else {
|
||||||
|
@ -359,7 +362,7 @@ typedef struct SUdfcProxy {
|
||||||
SArray *udfStubs; // SUdfcFuncStub
|
SArray *udfStubs; // SUdfcFuncStub
|
||||||
|
|
||||||
uv_mutex_t udfcUvMutex;
|
uv_mutex_t udfcUvMutex;
|
||||||
int8_t initialized;
|
int8_t initialized;
|
||||||
} SUdfcProxy;
|
} SUdfcProxy;
|
||||||
|
|
||||||
SUdfcProxy gUdfcProxy = {0};
|
SUdfcProxy gUdfcProxy = {0};
|
||||||
|
|
|
@ -152,7 +152,7 @@ IFileCtx* idxFileCtxCreate(WriterType type, const char* path, bool readOnly, int
|
||||||
if (ctx->type == TFILE) {
|
if (ctx->type == TFILE) {
|
||||||
// ugly code, refactor later
|
// ugly code, refactor later
|
||||||
ctx->file.readOnly = readOnly;
|
ctx->file.readOnly = readOnly;
|
||||||
memcpy(ctx->file.buf, path, sizeof(ctx->file.buf));
|
memcpy(ctx->file.buf, path, strlen(path));
|
||||||
if (readOnly == false) {
|
if (readOnly == false) {
|
||||||
ctx->file.pFile = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
|
ctx->file.pFile = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
|
||||||
taosFtruncateFile(ctx->file.pFile, 0);
|
taosFtruncateFile(ctx->file.pFile, 0);
|
||||||
|
|
|
@ -280,7 +280,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_add_fetch_32(&pJob->resNumOfRows, rsp->affectedRows);
|
atomic_add_fetch_32(&pJob->resNumOfRows, rsp->affectedRows);
|
||||||
SCH_TASK_DLOG("submit succeed, affectedRows:%d", rsp->affectedRows);
|
SCH_TASK_DLOG("submit succeed, affectedRows:%d, blocks:%d", rsp->affectedRows, rsp->nBlocks);
|
||||||
|
|
||||||
SCH_LOCK(SCH_WRITE, &pJob->resLock);
|
SCH_LOCK(SCH_WRITE, &pJob->resLock);
|
||||||
if (pJob->execRes.res) {
|
if (pJob->execRes.res) {
|
||||||
|
|
|
@ -52,6 +52,7 @@ typedef struct SSyncEnv {
|
||||||
} SSyncEnv;
|
} SSyncEnv;
|
||||||
|
|
||||||
SSyncEnv* syncEnv();
|
SSyncEnv* syncEnv();
|
||||||
|
bool syncIsInit();
|
||||||
|
|
||||||
int64_t syncNodeAdd(SSyncNode* pNode);
|
int64_t syncNodeAdd(SSyncNode* pNode);
|
||||||
void syncNodeRemove(int64_t rid);
|
void syncNodeRemove(int64_t rid);
|
||||||
|
|
|
@ -22,9 +22,9 @@ extern "C" {
|
||||||
|
|
||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "syncTools.h"
|
#include "syncTools.h"
|
||||||
#include "tlog.h"
|
|
||||||
#include "ttimer.h"
|
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
|
#include "tlog.h"
|
||||||
|
#include "trpc.h"
|
||||||
#include "ttimer.h"
|
#include "ttimer.h"
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
@ -314,6 +314,7 @@ int32_t syncNodePeerStateInit(SSyncNode* pSyncNode);
|
||||||
|
|
||||||
// trace log
|
// trace log
|
||||||
void syncLogRecvTimer(SSyncNode* pSyncNode, const SyncTimeout* pMsg, const char* s);
|
void syncLogRecvTimer(SSyncNode* pSyncNode, const SyncTimeout* pMsg, const char* s);
|
||||||
|
void syncLogRecvLocalCmd(SSyncNode* pSyncNode, const SyncLocalCmd* pMsg, const char* s);
|
||||||
|
|
||||||
void syncLogSendRequestVote(SSyncNode* pSyncNode, const SyncRequestVote* pMsg, const char* s);
|
void syncLogSendRequestVote(SSyncNode* pSyncNode, const SyncRequestVote* pMsg, const char* s);
|
||||||
void syncLogRecvRequestVote(SSyncNode* pSyncNode, const SyncRequestVote* pMsg, const char* s);
|
void syncLogRecvRequestVote(SSyncNode* pSyncNode, const SyncRequestVote* pMsg, const char* s);
|
||||||
|
@ -336,7 +337,17 @@ void syncLogRecvHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, const
|
||||||
void syncLogSendHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* pMsg, const char* s);
|
void syncLogSendHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* pMsg, const char* s);
|
||||||
void syncLogRecvHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* pMsg, const char* s);
|
void syncLogRecvHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* pMsg, const char* s);
|
||||||
|
|
||||||
void syncLogRecvLocalCmd(SSyncNode* pSyncNode, const SyncLocalCmd* pMsg, const char* s);
|
void syncLogSendSyncPreSnapshot(SSyncNode* pSyncNode, const SyncPreSnapshot* pMsg, const char* s);
|
||||||
|
void syncLogRecvSyncPreSnapshot(SSyncNode* pSyncNode, const SyncPreSnapshot* pMsg, const char* s);
|
||||||
|
|
||||||
|
void syncLogSendSyncPreSnapshotReply(SSyncNode* pSyncNode, const SyncPreSnapshotReply* pMsg, const char* s);
|
||||||
|
void syncLogRecvSyncPreSnapshotReply(SSyncNode* pSyncNode, const SyncPreSnapshotReply* pMsg, const char* s);
|
||||||
|
|
||||||
|
void syncLogSendSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* pMsg, const char* s);
|
||||||
|
void syncLogRecvSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* pMsg, const char* s);
|
||||||
|
|
||||||
|
void syncLogSendSyncSnapshotRsp(SSyncNode* pSyncNode, const SyncSnapshotRsp* pMsg, const char* s);
|
||||||
|
void syncLogRecvSyncSnapshotRsp(SSyncNode* pSyncNode, const SyncSnapshotRsp* pMsg, const char* s);
|
||||||
|
|
||||||
// for debug --------------
|
// for debug --------------
|
||||||
void syncNodePrint(SSyncNode* pObj);
|
void syncNodePrint(SSyncNode* pObj);
|
||||||
|
|
|
@ -28,10 +28,11 @@ extern "C" {
|
||||||
#include "syncMessage.h"
|
#include "syncMessage.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
|
|
||||||
#define SYNC_SNAPSHOT_SEQ_INVALID -1
|
#define SYNC_SNAPSHOT_SEQ_INVALID -2
|
||||||
#define SYNC_SNAPSHOT_SEQ_FORCE_CLOSE -2
|
#define SYNC_SNAPSHOT_SEQ_FORCE_CLOSE -3
|
||||||
#define SYNC_SNAPSHOT_SEQ_BEGIN 0
|
#define SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT -1
|
||||||
#define SYNC_SNAPSHOT_SEQ_END 0x7FFFFFFF
|
#define SYNC_SNAPSHOT_SEQ_BEGIN 0
|
||||||
|
#define SYNC_SNAPSHOT_SEQ_END 0x7FFFFFFF
|
||||||
|
|
||||||
#define SYNC_SNAPSHOT_RETRY_MS 5000
|
#define SYNC_SNAPSHOT_RETRY_MS 5000
|
||||||
|
|
||||||
|
@ -47,19 +48,19 @@ typedef struct SSyncSnapshotSender {
|
||||||
SSnapshot snapshot;
|
SSnapshot snapshot;
|
||||||
SSyncCfg lastConfig;
|
SSyncCfg lastConfig;
|
||||||
int64_t sendingMS;
|
int64_t sendingMS;
|
||||||
SSyncNode *pSyncNode;
|
|
||||||
int32_t replicaIndex;
|
|
||||||
SyncTerm term;
|
SyncTerm term;
|
||||||
SyncTerm privateTerm;
|
|
||||||
int64_t startTime;
|
int64_t startTime;
|
||||||
bool finish;
|
bool finish;
|
||||||
|
|
||||||
|
// init when create
|
||||||
|
SSyncNode *pSyncNode;
|
||||||
|
int32_t replicaIndex;
|
||||||
} SSyncSnapshotSender;
|
} SSyncSnapshotSender;
|
||||||
|
|
||||||
SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaIndex);
|
SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaIndex);
|
||||||
void snapshotSenderDestroy(SSyncSnapshotSender *pSender);
|
void snapshotSenderDestroy(SSyncSnapshotSender *pSender);
|
||||||
bool snapshotSenderIsStart(SSyncSnapshotSender *pSender);
|
bool snapshotSenderIsStart(SSyncSnapshotSender *pSender);
|
||||||
int32_t snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshotParam snapshotParam, SSnapshot snapshot,
|
int32_t snapshotSenderStart(SSyncSnapshotSender *pSender);
|
||||||
void *pReader);
|
|
||||||
int32_t snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish);
|
int32_t snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish);
|
||||||
int32_t snapshotSend(SSyncSnapshotSender *pSender);
|
int32_t snapshotSend(SSyncSnapshotSender *pSender);
|
||||||
int32_t snapshotReSend(SSyncSnapshotSender *pSender);
|
int32_t snapshotReSend(SSyncSnapshotSender *pSender);
|
||||||
|
@ -76,11 +77,13 @@ typedef struct SSyncSnapshotReceiver {
|
||||||
int32_t ack;
|
int32_t ack;
|
||||||
void *pWriter;
|
void *pWriter;
|
||||||
SyncTerm term;
|
SyncTerm term;
|
||||||
SyncTerm privateTerm;
|
|
||||||
SSnapshotParam snapshotParam;
|
SSnapshotParam snapshotParam;
|
||||||
SSnapshot snapshot;
|
SSnapshot snapshot;
|
||||||
SRaftId fromId;
|
SRaftId fromId;
|
||||||
SSyncNode *pSyncNode;
|
int64_t startTime;
|
||||||
|
|
||||||
|
// init when create
|
||||||
|
SSyncNode *pSyncNode;
|
||||||
|
|
||||||
} SSyncSnapshotReceiver;
|
} SSyncSnapshotReceiver;
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,13 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "trpc.h"
|
|
||||||
|
|
||||||
// ------------------ ds -------------------
|
// ------------------ ds -------------------
|
||||||
typedef struct SRaftId {
|
typedef struct SRaftId {
|
||||||
SyncNodeId addr;
|
SyncNodeId addr;
|
||||||
SyncGroupId vgId;
|
SyncGroupId vgId;
|
||||||
} SRaftId;
|
} SRaftId;
|
||||||
|
|
||||||
char* sync2SimpleStr(int64_t rid);
|
char* sync2SimpleStr(int64_t rid);
|
||||||
|
|
||||||
// for compatibility, the same as syncPropose
|
// for compatibility, the same as syncPropose
|
||||||
int32_t syncForwardToPeer(int64_t rid, SRpcMsg* pMsg, bool isWeak);
|
int32_t syncForwardToPeer(int64_t rid, SRpcMsg* pMsg, bool isWeak);
|
||||||
|
@ -498,6 +496,69 @@ void syncHeartbeatReplyPrint2(char* s, const SyncHeartbeatReply* pMsg);
|
||||||
void syncHeartbeatReplyLog(const SyncHeartbeatReply* pMsg);
|
void syncHeartbeatReplyLog(const SyncHeartbeatReply* pMsg);
|
||||||
void syncHeartbeatReplyLog2(char* s, const SyncHeartbeatReply* pMsg);
|
void syncHeartbeatReplyLog2(char* s, const SyncHeartbeatReply* pMsg);
|
||||||
|
|
||||||
|
// ---------------------------------------------
|
||||||
|
typedef struct SyncPreSnapshot {
|
||||||
|
uint32_t bytes;
|
||||||
|
int32_t vgId;
|
||||||
|
uint32_t msgType;
|
||||||
|
SRaftId srcId;
|
||||||
|
SRaftId destId;
|
||||||
|
|
||||||
|
// private data
|
||||||
|
SyncTerm term;
|
||||||
|
|
||||||
|
} SyncPreSnapshot;
|
||||||
|
|
||||||
|
SyncPreSnapshot* syncPreSnapshotBuild(int32_t vgId);
|
||||||
|
void syncPreSnapshotDestroy(SyncPreSnapshot* pMsg);
|
||||||
|
void syncPreSnapshotSerialize(const SyncPreSnapshot* pMsg, char* buf, uint32_t bufLen);
|
||||||
|
void syncPreSnapshotDeserialize(const char* buf, uint32_t len, SyncPreSnapshot* pMsg);
|
||||||
|
char* syncPreSnapshotSerialize2(const SyncPreSnapshot* pMsg, uint32_t* len);
|
||||||
|
SyncPreSnapshot* syncPreSnapshotDeserialize2(const char* buf, uint32_t len);
|
||||||
|
void syncPreSnapshot2RpcMsg(const SyncPreSnapshot* pMsg, SRpcMsg* pRpcMsg);
|
||||||
|
void syncPreSnapshotFromRpcMsg(const SRpcMsg* pRpcMsg, SyncPreSnapshot* pMsg);
|
||||||
|
SyncPreSnapshot* syncPreSnapshotFromRpcMsg2(const SRpcMsg* pRpcMsg);
|
||||||
|
cJSON* syncPreSnapshot2Json(const SyncPreSnapshot* pMsg);
|
||||||
|
char* syncPreSnapshot2Str(const SyncPreSnapshot* pMsg);
|
||||||
|
|
||||||
|
// for debug ----------------------
|
||||||
|
void syncPreSnapshotPrint(const SyncPreSnapshot* pMsg);
|
||||||
|
void syncPreSnapshotPrint2(char* s, const SyncPreSnapshot* pMsg);
|
||||||
|
void syncPreSnapshotLog(const SyncPreSnapshot* pMsg);
|
||||||
|
void syncPreSnapshotLog2(char* s, const SyncPreSnapshot* pMsg);
|
||||||
|
|
||||||
|
// ---------------------------------------------
|
||||||
|
typedef struct SyncPreSnapshotReply {
|
||||||
|
uint32_t bytes;
|
||||||
|
int32_t vgId;
|
||||||
|
uint32_t msgType;
|
||||||
|
SRaftId srcId;
|
||||||
|
SRaftId destId;
|
||||||
|
|
||||||
|
// private data
|
||||||
|
SyncTerm term;
|
||||||
|
SyncIndex snapStart;
|
||||||
|
|
||||||
|
} SyncPreSnapshotReply;
|
||||||
|
|
||||||
|
SyncPreSnapshotReply* syncPreSnapshotReplyBuild(int32_t vgId);
|
||||||
|
void syncPreSnapshotReplyDestroy(SyncPreSnapshotReply* pMsg);
|
||||||
|
void syncPreSnapshotReplySerialize(const SyncPreSnapshotReply* pMsg, char* buf, uint32_t bufLen);
|
||||||
|
void syncPreSnapshotReplyDeserialize(const char* buf, uint32_t len, SyncPreSnapshotReply* pMsg);
|
||||||
|
char* syncPreSnapshotReplySerialize2(const SyncPreSnapshotReply* pMsg, uint32_t* len);
|
||||||
|
SyncPreSnapshotReply* syncPreSnapshotReplyDeserialize2(const char* buf, uint32_t len);
|
||||||
|
void syncPreSnapshotReply2RpcMsg(const SyncPreSnapshotReply* pMsg, SRpcMsg* pRpcMsg);
|
||||||
|
void syncPreSnapshotReplyFromRpcMsg(const SRpcMsg* pRpcMsg, SyncPreSnapshotReply* pMsg);
|
||||||
|
SyncPreSnapshotReply* syncPreSnapshotReplyFromRpcMsg2(const SRpcMsg* pRpcMsg);
|
||||||
|
cJSON* syncPreSnapshotReply2Json(const SyncPreSnapshotReply* pMsg);
|
||||||
|
char* syncPreSnapshotReply2Str(const SyncPreSnapshotReply* pMsg);
|
||||||
|
|
||||||
|
// for debug ----------------------
|
||||||
|
void syncPreSnapshotReplyPrint(const SyncPreSnapshotReply* pMsg);
|
||||||
|
void syncPreSnapshotReplyPrint2(char* s, const SyncPreSnapshotReply* pMsg);
|
||||||
|
void syncPreSnapshotReplyLog(const SyncPreSnapshotReply* pMsg);
|
||||||
|
void syncPreSnapshotReplyLog2(char* s, const SyncPreSnapshotReply* pMsg);
|
||||||
|
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
typedef struct SyncApplyMsg {
|
typedef struct SyncApplyMsg {
|
||||||
uint32_t bytes;
|
uint32_t bytes;
|
||||||
|
@ -543,7 +604,7 @@ typedef struct SyncSnapshotSend {
|
||||||
SyncTerm lastTerm; // snapshot.lastTerm
|
SyncTerm lastTerm; // snapshot.lastTerm
|
||||||
SyncIndex lastConfigIndex; // snapshot.lastConfigIndex
|
SyncIndex lastConfigIndex; // snapshot.lastConfigIndex
|
||||||
SSyncCfg lastConfig;
|
SSyncCfg lastConfig;
|
||||||
SyncTerm privateTerm;
|
int64_t startTime;
|
||||||
int32_t seq;
|
int32_t seq;
|
||||||
uint32_t dataLen;
|
uint32_t dataLen;
|
||||||
char data[];
|
char data[];
|
||||||
|
@ -578,9 +639,10 @@ typedef struct SyncSnapshotRsp {
|
||||||
SyncTerm term;
|
SyncTerm term;
|
||||||
SyncIndex lastIndex;
|
SyncIndex lastIndex;
|
||||||
SyncTerm lastTerm;
|
SyncTerm lastTerm;
|
||||||
SyncTerm privateTerm;
|
int64_t startTime;
|
||||||
int32_t ack;
|
int32_t ack;
|
||||||
int32_t code;
|
int32_t code;
|
||||||
|
SyncIndex snapBeginIndex; // when ack = SYNC_SNAPSHOT_SEQ_BEGIN, it's valid
|
||||||
} SyncSnapshotRsp;
|
} SyncSnapshotRsp;
|
||||||
|
|
||||||
SyncSnapshotRsp* syncSnapshotRspBuild(int32_t vgId);
|
SyncSnapshotRsp* syncSnapshotRspBuild(int32_t vgId);
|
||||||
|
@ -711,6 +773,9 @@ int32_t syncNodeOnRequestVoteReply(SSyncNode* ths, SyncRequestVoteReply* pMsg);
|
||||||
int32_t syncNodeOnAppendEntries(SSyncNode* ths, SyncAppendEntries* pMsg);
|
int32_t syncNodeOnAppendEntries(SSyncNode* ths, SyncAppendEntries* pMsg);
|
||||||
int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, SyncAppendEntriesReply* pMsg);
|
int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, SyncAppendEntriesReply* pMsg);
|
||||||
|
|
||||||
|
int32_t syncNodeOnPreSnapshot(SSyncNode* ths, SyncPreSnapshot* pMsg);
|
||||||
|
int32_t syncNodeOnPreSnapshotReply(SSyncNode* ths, SyncPreSnapshotReply* pMsg);
|
||||||
|
|
||||||
int32_t syncNodeOnSnapshot(SSyncNode* ths, SyncSnapshotSend* pMsg);
|
int32_t syncNodeOnSnapshot(SSyncNode* ths, SyncSnapshotSend* pMsg);
|
||||||
int32_t syncNodeOnSnapshotReply(SSyncNode* ths, SyncSnapshotRsp* pMsg);
|
int32_t syncNodeOnSnapshotReply(SSyncNode* ths, SyncSnapshotRsp* pMsg);
|
||||||
|
|
|
@ -49,7 +49,7 @@ int32_t syncUtilQuorum(int32_t replicaNum);
|
||||||
cJSON* syncUtilNodeInfo2Json(const SNodeInfo* p);
|
cJSON* syncUtilNodeInfo2Json(const SNodeInfo* p);
|
||||||
cJSON* syncUtilRaftId2Json(const SRaftId* p);
|
cJSON* syncUtilRaftId2Json(const SRaftId* p);
|
||||||
char* syncUtilRaftId2Str(const SRaftId* p);
|
char* syncUtilRaftId2Str(const SRaftId* p);
|
||||||
const char* syncUtilState2String(ESyncState state);
|
const char* syncStr(ESyncState state);
|
||||||
bool syncUtilCanPrint(char c);
|
bool syncUtilCanPrint(char c);
|
||||||
char* syncUtilprintBin(char* ptr, uint32_t len);
|
char* syncUtilprintBin(char* ptr, uint32_t len);
|
||||||
char* syncUtilprintBin2(char* ptr, uint32_t len);
|
char* syncUtilprintBin2(char* ptr, uint32_t len);
|
||||||
|
|
|
@ -142,7 +142,6 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, SyncAppendEntries* pMsg) {
|
||||||
// pReply->matchIndex = ths->pLogStore->syncLogLastIndex(ths->pLogStore);
|
// pReply->matchIndex = ths->pLogStore->syncLogLastIndex(ths->pLogStore);
|
||||||
pReply->matchIndex = SYNC_INDEX_INVALID;
|
pReply->matchIndex = SYNC_INDEX_INVALID;
|
||||||
pReply->lastSendIndex = pMsg->prevLogIndex + 1;
|
pReply->lastSendIndex = pMsg->prevLogIndex + 1;
|
||||||
pReply->privateTerm = ths->pNewNodeReceiver->privateTerm;
|
|
||||||
pReply->startTime = ths->startTime;
|
pReply->startTime = ths->startTime;
|
||||||
|
|
||||||
if (pMsg->term < ths->pRaftStore->currentTerm) {
|
if (pMsg->term < ths->pRaftStore->currentTerm) {
|
||||||
|
|
|
@ -73,6 +73,7 @@ static void syncNodeStartSnapshotOnce(SSyncNode* ths, SyncIndex beginIndex, Sync
|
||||||
int32_t code = ths->pFsm->FpSnapshotStartRead(ths->pFsm, &readerParam, &pReader);
|
int32_t code = ths->pFsm->FpSnapshotStartRead(ths->pFsm, &readerParam, &pReader);
|
||||||
ASSERT(code == 0);
|
ASSERT(code == 0);
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (pMsg->privateTerm < pSender->privateTerm) {
|
if (pMsg->privateTerm < pSender->privateTerm) {
|
||||||
ASSERT(pReader != NULL);
|
ASSERT(pReader != NULL);
|
||||||
snapshotSenderStart(pSender, readerParam, snapshot, pReader);
|
snapshotSenderStart(pSender, readerParam, snapshot, pReader);
|
||||||
|
@ -82,6 +83,7 @@ static void syncNodeStartSnapshotOnce(SSyncNode* ths, SyncIndex beginIndex, Sync
|
||||||
ths->pFsm->FpSnapshotStopRead(ths->pFsm, pReader);
|
ths->pFsm->FpSnapshotStopRead(ths->pFsm, pReader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, SyncAppendEntriesReply* pMsg) {
|
int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, SyncAppendEntriesReply* pMsg) {
|
||||||
|
|
|
@ -505,50 +505,20 @@ int32_t syncForwardToPeer(int64_t rid, SRpcMsg* pMsg, bool isWeak) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESyncState syncGetMyRole(int64_t rid) {
|
SSyncState syncGetState(int64_t rid) {
|
||||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
SSyncState state = {.state = TAOS_SYNC_STATE_ERROR};
|
||||||
if (pSyncNode == NULL) {
|
|
||||||
return TAOS_SYNC_STATE_ERROR;
|
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||||
}
|
if (pSyncNode != NULL) {
|
||||||
ASSERT(rid == pSyncNode->rid);
|
state.state = pSyncNode->state;
|
||||||
ESyncState state = pSyncNode->state;
|
state.restored = pSyncNode->restoreFinish;
|
||||||
|
syncNodeRelease(pSyncNode);
|
||||||
|
}
|
||||||
|
|
||||||
syncNodeRelease(pSyncNode);
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool syncIsReady(int64_t rid) {
|
#if 0
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t syncGetSnapshotByIndex(int64_t rid, SyncIndex index, SSnapshot* pSnapshot) {
|
int32_t syncGetSnapshotByIndex(int64_t rid, SyncIndex index, SSnapshot* pSnapshot) {
|
||||||
if (index < SYNC_INDEX_BEGIN) {
|
if (index < SYNC_INDEX_BEGIN) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -618,6 +588,7 @@ int32_t syncGetSnapshotMetaByIndex(int64_t rid, SyncIndex snapshotIndex, struct
|
||||||
syncNodeRelease(pSyncNode);
|
syncNodeRelease(pSyncNode);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode* pSyncNode, SyncIndex snapshotLastApplyIndex) {
|
SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode* pSyncNode, SyncIndex snapshotLastApplyIndex) {
|
||||||
ASSERT(pSyncNode->pRaftCfg->configIndexCount >= 1);
|
ASSERT(pSyncNode->pRaftCfg->configIndexCount >= 1);
|
||||||
|
@ -635,23 +606,7 @@ SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode* pSyncNode, SyncIndex snapsho
|
||||||
return lastIndex;
|
return lastIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* syncGetMyRoleStr(int64_t rid) {
|
#if 0
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
SyncTerm syncGetMyTerm(int64_t rid) {
|
SyncTerm syncGetMyTerm(int64_t rid) {
|
||||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||||
if (pSyncNode == NULL) {
|
if (pSyncNode == NULL) {
|
||||||
|
@ -719,6 +674,7 @@ void syncGetEpSet(int64_t rid, SEpSet* pEpSet) {
|
||||||
|
|
||||||
syncNodeRelease(pSyncNode);
|
syncNodeRelease(pSyncNode);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet) {
|
void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet) {
|
||||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||||
|
@ -742,7 +698,6 @@ void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet) {
|
||||||
|
|
||||||
syncNodeRelease(pSyncNode);
|
syncNodeRelease(pSyncNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void syncGetAndDelRespRpc(SSyncNode* pSyncNode, uint64_t index, SRpcHandleInfo* pInfo) {
|
static void syncGetAndDelRespRpc(SSyncNode* pSyncNode, uint64_t index, SRpcHandleInfo* pInfo) {
|
||||||
SRespStub stub;
|
SRespStub stub;
|
||||||
int32_t ret = syncRespMgrGetAndDel(pSyncNode->pSyncRespMgr, index, &stub);
|
int32_t ret = syncRespMgrGetAndDel(pSyncNode->pSyncRespMgr, index, &stub);
|
||||||
|
@ -877,7 +832,7 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) {
|
||||||
} else {
|
} else {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
terrno = TSDB_CODE_SYN_NOT_LEADER;
|
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));
|
TMSG_INFO(pMsg->msgType));
|
||||||
goto _END;
|
goto _END;
|
||||||
}
|
}
|
||||||
|
@ -1603,7 +1558,7 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) {
|
||||||
|
|
||||||
// tla+ server vars
|
// tla+ server vars
|
||||||
cJSON_AddNumberToObject(pRoot, "state", pSyncNode->state);
|
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));
|
cJSON_AddItemToObject(pRoot, "pRaftStore", raftStore2Json(pSyncNode->pRaftStore));
|
||||||
|
|
||||||
// tla+ candidate vars
|
// tla+ candidate vars
|
||||||
|
@ -1743,7 +1698,7 @@ inline void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
|
||||||
"stgy:%d, bch:%d, "
|
"stgy:%d, bch:%d, "
|
||||||
"r-num:%d, "
|
"r-num:%d, "
|
||||||
"lcfg:%" PRId64 ", chging:%d, rsto:%d, dquorum:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s, %s",
|
"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,
|
pSyncNode->commitIndex, logBeginIndex, logLastIndex, pSyncNode->minMatchIndex, snapshot.lastApplyIndex,
|
||||||
snapshot.lastApplyTerm, pSyncNode->pRaftCfg->isStandBy, pSyncNode->pRaftCfg->snapshotStrategy,
|
snapshot.lastApplyTerm, pSyncNode->pRaftCfg->isStandBy, pSyncNode->pRaftCfg->snapshotStrategy,
|
||||||
pSyncNode->pRaftCfg->batchSize, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex,
|
pSyncNode->pRaftCfg->batchSize, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex,
|
||||||
|
@ -1767,7 +1722,7 @@ inline void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
|
||||||
"stgy:%d, bch:%d, "
|
"stgy:%d, bch:%d, "
|
||||||
"r-num:%d, "
|
"r-num:%d, "
|
||||||
"lcfg:%" PRId64 ", chging:%d, rsto:%d, dquorum:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s, %s",
|
"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,
|
pSyncNode->commitIndex, logBeginIndex, logLastIndex, pSyncNode->minMatchIndex, snapshot.lastApplyIndex,
|
||||||
snapshot.lastApplyTerm, pSyncNode->pRaftCfg->isStandBy, pSyncNode->pRaftCfg->snapshotStrategy,
|
snapshot.lastApplyTerm, pSyncNode->pRaftCfg->isStandBy, pSyncNode->pRaftCfg->snapshotStrategy,
|
||||||
pSyncNode->pRaftCfg->batchSize, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex,
|
pSyncNode->pRaftCfg->batchSize, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex,
|
||||||
|
@ -1821,7 +1776,7 @@ inline void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
|
||||||
"stgy:%d, bch:%d, "
|
"stgy:%d, bch:%d, "
|
||||||
"r-num:%d, "
|
"r-num:%d, "
|
||||||
"lcfg:%" PRId64 ", chging:%d, rsto:%d, dquorum:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s",
|
"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,
|
pSyncNode->commitIndex, logBeginIndex, logLastIndex, pSyncNode->minMatchIndex, snapshot.lastApplyIndex,
|
||||||
snapshot.lastApplyTerm, pSyncNode->pRaftCfg->isStandBy, pSyncNode->pRaftCfg->snapshotStrategy,
|
snapshot.lastApplyTerm, pSyncNode->pRaftCfg->isStandBy, pSyncNode->pRaftCfg->snapshotStrategy,
|
||||||
pSyncNode->pRaftCfg->batchSize, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex,
|
pSyncNode->pRaftCfg->batchSize, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex,
|
||||||
|
@ -1843,7 +1798,7 @@ inline void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
|
||||||
"stgy:%d, bch:%d, "
|
"stgy:%d, bch:%d, "
|
||||||
"r-num:%d, "
|
"r-num:%d, "
|
||||||
"lcfg:%" PRId64 ", chging:%d, rsto:%d, dquorum:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s",
|
"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,
|
pSyncNode->commitIndex, logBeginIndex, logLastIndex, pSyncNode->minMatchIndex, snapshot.lastApplyIndex,
|
||||||
snapshot.lastApplyTerm, pSyncNode->pRaftCfg->isStandBy, pSyncNode->pRaftCfg->snapshotStrategy,
|
snapshot.lastApplyTerm, pSyncNode->pRaftCfg->isStandBy, pSyncNode->pRaftCfg->snapshotStrategy,
|
||||||
pSyncNode->pRaftCfg->batchSize, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex,
|
pSyncNode->pRaftCfg->batchSize, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex,
|
||||||
|
@ -1875,9 +1830,9 @@ inline char* syncNode2SimpleStr(const SSyncNode* pSyncNode) {
|
||||||
", sby:%d, "
|
", sby:%d, "
|
||||||
"r-num:%d, "
|
"r-num:%d, "
|
||||||
"lcfg:%" PRId64 ", chging:%d, rsto:%d",
|
"lcfg:%" PRId64 ", chging:%d, rsto:%d",
|
||||||
pSyncNode->vgId, syncUtilState2String(pSyncNode->state), pSyncNode->pRaftStore->currentTerm,
|
pSyncNode->vgId, syncStr(pSyncNode->state), pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex,
|
||||||
pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy,
|
logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, pSyncNode->replicaNum,
|
||||||
pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, pSyncNode->changing, pSyncNode->restoreFinish);
|
pSyncNode->pRaftCfg->lastConfigIndex, pSyncNode->changing, pSyncNode->restoreFinish);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -2157,7 +2112,13 @@ void syncNodeUpdateTermWithoutStepDown(SSyncNode* pSyncNode, SyncTerm term) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void syncNodeStepDown(SSyncNode* pSyncNode, SyncTerm newTerm) {
|
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 {
|
do {
|
||||||
char logBuf[128];
|
char logBuf[128];
|
||||||
|
@ -2275,6 +2236,7 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) {
|
||||||
// init peer mgr
|
// init peer mgr
|
||||||
syncNodePeerStateInit(pSyncNode);
|
syncNodePeerStateInit(pSyncNode);
|
||||||
|
|
||||||
|
#if 0
|
||||||
// update sender private term
|
// update sender private term
|
||||||
SSyncSnapshotSender* pMySender = syncNodeGetSnapshotSender(pSyncNode, &(pSyncNode->myRaftId));
|
SSyncSnapshotSender* pMySender = syncNodeGetSnapshotSender(pSyncNode, &(pSyncNode->myRaftId));
|
||||||
if (pMySender != NULL) {
|
if (pMySender != NULL) {
|
||||||
|
@ -2285,6 +2247,7 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) {
|
||||||
}
|
}
|
||||||
(pMySender->privateTerm) += 100;
|
(pMySender->privateTerm) += 100;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// close receiver
|
// close receiver
|
||||||
if (snapshotReceiverIsStart(pSyncNode->pNewNodeReceiver)) {
|
if (snapshotReceiverIsStart(pSyncNode->pNewNodeReceiver)) {
|
||||||
|
@ -3600,3 +3563,52 @@ void syncLogRecvLocalCmd(SSyncNode* pSyncNode, const SyncLocalCmd* pMsg, const c
|
||||||
syncLocalCmdGetStr(pMsg->cmd), pMsg->sdNewTerm, s);
|
syncLocalCmdGetStr(pMsg->cmd), pMsg->sdNewTerm, s);
|
||||||
syncNodeEventLog(pSyncNode, logBuf);
|
syncNodeEventLog(pSyncNode, logBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void syncLogSendSyncPreSnapshot(SSyncNode* pSyncNode, const SyncPreSnapshot* pMsg, const char* s) {
|
||||||
|
char host[64];
|
||||||
|
uint16_t port;
|
||||||
|
syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port);
|
||||||
|
char logBuf[256];
|
||||||
|
snprintf(logBuf, sizeof(logBuf), "send sync-pre-snapshot to %s:%d {term:%" PRIu64 "}, %s", host, port, pMsg->term, s);
|
||||||
|
syncNodeEventLog(pSyncNode, logBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncLogRecvSyncPreSnapshot(SSyncNode* pSyncNode, const SyncPreSnapshot* pMsg, const char* s) {
|
||||||
|
char host[64];
|
||||||
|
uint16_t port;
|
||||||
|
syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port);
|
||||||
|
char logBuf[256];
|
||||||
|
snprintf(logBuf, sizeof(logBuf), "recv sync-pre-snapshot from %s:%d {term:%" PRIu64 "}, %s", host, port, pMsg->term,
|
||||||
|
s);
|
||||||
|
syncNodeEventLog(pSyncNode, logBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncLogSendSyncPreSnapshotReply(SSyncNode* pSyncNode, const SyncPreSnapshotReply* pMsg, const char* s) {
|
||||||
|
char host[64];
|
||||||
|
uint16_t port;
|
||||||
|
syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port);
|
||||||
|
char logBuf[256];
|
||||||
|
snprintf(logBuf, sizeof(logBuf),
|
||||||
|
"send sync-pre-snapshot-reply to %s:%d {term:%" PRIu64 ", snap-start:%" PRId64 "}, %s", host, port,
|
||||||
|
pMsg->term, pMsg->snapStart, s);
|
||||||
|
syncNodeEventLog(pSyncNode, logBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncLogRecvSyncPreSnapshotReply(SSyncNode* pSyncNode, const SyncPreSnapshotReply* pMsg, const char* s) {
|
||||||
|
char host[64];
|
||||||
|
uint16_t port;
|
||||||
|
syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port);
|
||||||
|
char logBuf[256];
|
||||||
|
snprintf(logBuf, sizeof(logBuf),
|
||||||
|
"recv sync-pre-snapshot-reply from %s:%d {term:%" PRIu64 ", snap-start:%" PRId64 "}, %s", host, port,
|
||||||
|
pMsg->term, pMsg->snapStart, s);
|
||||||
|
syncNodeEventLog(pSyncNode, logBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncLogSendSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* pMsg, const char* s) {}
|
||||||
|
|
||||||
|
void syncLogRecvSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* pMsg, const char* s) {}
|
||||||
|
|
||||||
|
void syncLogSendSyncSnapshotRsp(SSyncNode* pSyncNode, const SyncSnapshotRsp* pMsg, const char* s) {}
|
||||||
|
|
||||||
|
void syncLogRecvSyncSnapshotRsp(SSyncNode* pSyncNode, const SyncSnapshotRsp* pMsg, const char* s) {}
|
||||||
|
|
|
@ -2315,6 +2315,303 @@ void syncHeartbeatReplyLog2(char* s, const SyncHeartbeatReply* pMsg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- message process SyncPreSnapshot----
|
||||||
|
SyncPreSnapshot* syncPreSnapshotBuild(int32_t vgId) {
|
||||||
|
uint32_t bytes = sizeof(SyncPreSnapshot);
|
||||||
|
SyncPreSnapshot* pMsg = taosMemoryMalloc(bytes);
|
||||||
|
memset(pMsg, 0, bytes);
|
||||||
|
pMsg->bytes = bytes;
|
||||||
|
pMsg->vgId = vgId;
|
||||||
|
pMsg->msgType = TDMT_SYNC_PRE_SNAPSHOT;
|
||||||
|
return pMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshotDestroy(SyncPreSnapshot* pMsg) {
|
||||||
|
if (pMsg != NULL) {
|
||||||
|
taosMemoryFree(pMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshotSerialize(const SyncPreSnapshot* pMsg, char* buf, uint32_t bufLen) {
|
||||||
|
ASSERT(pMsg->bytes <= bufLen);
|
||||||
|
memcpy(buf, pMsg, pMsg->bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshotDeserialize(const char* buf, uint32_t len, SyncPreSnapshot* pMsg) {
|
||||||
|
memcpy(pMsg, buf, len);
|
||||||
|
ASSERT(len == pMsg->bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
char* syncPreSnapshotSerialize2(const SyncPreSnapshot* pMsg, uint32_t* len) {
|
||||||
|
char* buf = taosMemoryMalloc(pMsg->bytes);
|
||||||
|
ASSERT(buf != NULL);
|
||||||
|
syncPreSnapshotSerialize(pMsg, buf, pMsg->bytes);
|
||||||
|
if (len != NULL) {
|
||||||
|
*len = pMsg->bytes;
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncPreSnapshot* syncPreSnapshotDeserialize2(const char* buf, uint32_t len) {
|
||||||
|
uint32_t bytes = *((uint32_t*)buf);
|
||||||
|
SyncPreSnapshot* pMsg = taosMemoryMalloc(bytes);
|
||||||
|
ASSERT(pMsg != NULL);
|
||||||
|
syncPreSnapshotDeserialize(buf, len, pMsg);
|
||||||
|
ASSERT(len == pMsg->bytes);
|
||||||
|
return pMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshot2RpcMsg(const SyncPreSnapshot* pMsg, SRpcMsg* pRpcMsg) {
|
||||||
|
memset(pRpcMsg, 0, sizeof(*pRpcMsg));
|
||||||
|
pRpcMsg->msgType = pMsg->msgType;
|
||||||
|
pRpcMsg->contLen = pMsg->bytes;
|
||||||
|
pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen);
|
||||||
|
syncPreSnapshotSerialize(pMsg, pRpcMsg->pCont, pRpcMsg->contLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshotFromRpcMsg(const SRpcMsg* pRpcMsg, SyncPreSnapshot* pMsg) {
|
||||||
|
syncPreSnapshotDeserialize(pRpcMsg->pCont, pRpcMsg->contLen, pMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncPreSnapshot* syncPreSnapshotFromRpcMsg2(const SRpcMsg* pRpcMsg) {
|
||||||
|
SyncPreSnapshot* pMsg = syncPreSnapshotDeserialize2(pRpcMsg->pCont, pRpcMsg->contLen);
|
||||||
|
ASSERT(pMsg != NULL);
|
||||||
|
return pMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON* syncPreSnapshot2Json(const SyncPreSnapshot* pMsg) {
|
||||||
|
char u64buf[128] = {0};
|
||||||
|
cJSON* pRoot = cJSON_CreateObject();
|
||||||
|
|
||||||
|
if (pMsg != NULL) {
|
||||||
|
cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes);
|
||||||
|
cJSON_AddNumberToObject(pRoot, "vgId", pMsg->vgId);
|
||||||
|
cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
|
||||||
|
|
||||||
|
cJSON* pSrcId = cJSON_CreateObject();
|
||||||
|
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->srcId.addr);
|
||||||
|
cJSON_AddStringToObject(pSrcId, "addr", u64buf);
|
||||||
|
{
|
||||||
|
uint64_t u64 = pMsg->srcId.addr;
|
||||||
|
cJSON* pTmp = pSrcId;
|
||||||
|
char host[128] = {0};
|
||||||
|
uint16_t port;
|
||||||
|
syncUtilU642Addr(u64, host, sizeof(host), &port);
|
||||||
|
cJSON_AddStringToObject(pTmp, "addr_host", host);
|
||||||
|
cJSON_AddNumberToObject(pTmp, "addr_port", port);
|
||||||
|
}
|
||||||
|
cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId);
|
||||||
|
cJSON_AddItemToObject(pRoot, "srcId", pSrcId);
|
||||||
|
|
||||||
|
cJSON* pDestId = cJSON_CreateObject();
|
||||||
|
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->destId.addr);
|
||||||
|
cJSON_AddStringToObject(pDestId, "addr", u64buf);
|
||||||
|
{
|
||||||
|
uint64_t u64 = pMsg->destId.addr;
|
||||||
|
cJSON* pTmp = pDestId;
|
||||||
|
char host[128] = {0};
|
||||||
|
uint16_t port;
|
||||||
|
syncUtilU642Addr(u64, host, sizeof(host), &port);
|
||||||
|
cJSON_AddStringToObject(pTmp, "addr_host", host);
|
||||||
|
cJSON_AddNumberToObject(pTmp, "addr_port", port);
|
||||||
|
}
|
||||||
|
cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId);
|
||||||
|
cJSON_AddItemToObject(pRoot, "destId", pDestId);
|
||||||
|
|
||||||
|
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->term);
|
||||||
|
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON* pJson = cJSON_CreateObject();
|
||||||
|
cJSON_AddItemToObject(pJson, "SyncPreSnapshot", pRoot);
|
||||||
|
return pJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* syncPreSnapshot2Str(const SyncPreSnapshot* pMsg) {
|
||||||
|
cJSON* pJson = syncPreSnapshot2Json(pMsg);
|
||||||
|
char* serialized = cJSON_Print(pJson);
|
||||||
|
cJSON_Delete(pJson);
|
||||||
|
return serialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshotPrint(const SyncPreSnapshot* pMsg) {
|
||||||
|
char* serialized = syncPreSnapshot2Str(pMsg);
|
||||||
|
printf("syncPreSnapshotPrint | len:%d | %s \n", (int32_t)strlen(serialized), serialized);
|
||||||
|
fflush(NULL);
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshotPrint2(char* s, const SyncPreSnapshot* pMsg) {
|
||||||
|
char* serialized = syncPreSnapshot2Str(pMsg);
|
||||||
|
printf("syncPreSnapshotPrint2 | len:%d | %s | %s \n", (int32_t)strlen(serialized), s, serialized);
|
||||||
|
fflush(NULL);
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshotLog(const SyncPreSnapshot* pMsg) {
|
||||||
|
char* serialized = syncPreSnapshot2Str(pMsg);
|
||||||
|
sTrace("syncPreSnapshotLog | len:%d | %s", (int32_t)strlen(serialized), serialized);
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshotLog2(char* s, const SyncPreSnapshot* pMsg) {
|
||||||
|
if (gRaftDetailLog) {
|
||||||
|
char* serialized = syncPreSnapshot2Str(pMsg);
|
||||||
|
sTrace("syncPreSnapshotLog2 | len:%d | %s | %s", (int32_t)strlen(serialized), s, serialized);
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- message process SyncPreSnapshotReply----
|
||||||
|
SyncPreSnapshotReply* syncPreSnapshotReplyBuild(int32_t vgId) {
|
||||||
|
uint32_t bytes = sizeof(SyncPreSnapshotReply);
|
||||||
|
SyncPreSnapshotReply* pMsg = taosMemoryMalloc(bytes);
|
||||||
|
memset(pMsg, 0, bytes);
|
||||||
|
pMsg->bytes = bytes;
|
||||||
|
pMsg->vgId = vgId;
|
||||||
|
pMsg->msgType = TDMT_SYNC_PRE_SNAPSHOT_REPLY;
|
||||||
|
return pMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshotReplyDestroy(SyncPreSnapshotReply* pMsg) {
|
||||||
|
if (pMsg != NULL) {
|
||||||
|
taosMemoryFree(pMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshotReplySerialize(const SyncPreSnapshotReply* pMsg, char* buf, uint32_t bufLen) {
|
||||||
|
ASSERT(pMsg->bytes <= bufLen);
|
||||||
|
memcpy(buf, pMsg, pMsg->bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshotReplyDeserialize(const char* buf, uint32_t len, SyncPreSnapshotReply* pMsg) {
|
||||||
|
memcpy(pMsg, buf, len);
|
||||||
|
ASSERT(len == pMsg->bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
char* syncPreSnapshotReplySerialize2(const SyncPreSnapshotReply* pMsg, uint32_t* len) {
|
||||||
|
char* buf = taosMemoryMalloc(pMsg->bytes);
|
||||||
|
ASSERT(buf != NULL);
|
||||||
|
syncPreSnapshotReplySerialize(pMsg, buf, pMsg->bytes);
|
||||||
|
if (len != NULL) {
|
||||||
|
*len = pMsg->bytes;
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncPreSnapshotReply* syncPreSnapshotReplyDeserialize2(const char* buf, uint32_t len) {
|
||||||
|
uint32_t bytes = *((uint32_t*)buf);
|
||||||
|
SyncPreSnapshotReply* pMsg = taosMemoryMalloc(bytes);
|
||||||
|
ASSERT(pMsg != NULL);
|
||||||
|
syncPreSnapshotReplyDeserialize(buf, len, pMsg);
|
||||||
|
ASSERT(len == pMsg->bytes);
|
||||||
|
return pMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshotReply2RpcMsg(const SyncPreSnapshotReply* pMsg, SRpcMsg* pRpcMsg) {
|
||||||
|
memset(pRpcMsg, 0, sizeof(*pRpcMsg));
|
||||||
|
pRpcMsg->msgType = pMsg->msgType;
|
||||||
|
pRpcMsg->contLen = pMsg->bytes;
|
||||||
|
pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen);
|
||||||
|
syncPreSnapshotReplySerialize(pMsg, pRpcMsg->pCont, pRpcMsg->contLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshotReplyFromRpcMsg(const SRpcMsg* pRpcMsg, SyncPreSnapshotReply* pMsg) {
|
||||||
|
syncPreSnapshotReplyDeserialize(pRpcMsg->pCont, pRpcMsg->contLen, pMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncPreSnapshotReply* syncPreSnapshotReplyFromRpcMsg2(const SRpcMsg* pRpcMsg) {
|
||||||
|
SyncPreSnapshotReply* pMsg = syncPreSnapshotReplyDeserialize2(pRpcMsg->pCont, pRpcMsg->contLen);
|
||||||
|
ASSERT(pMsg != NULL);
|
||||||
|
return pMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON* syncPreSnapshotReply2Json(const SyncPreSnapshotReply* pMsg) {
|
||||||
|
char u64buf[128] = {0};
|
||||||
|
cJSON* pRoot = cJSON_CreateObject();
|
||||||
|
|
||||||
|
if (pMsg != NULL) {
|
||||||
|
cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes);
|
||||||
|
cJSON_AddNumberToObject(pRoot, "vgId", pMsg->vgId);
|
||||||
|
cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
|
||||||
|
|
||||||
|
cJSON* pSrcId = cJSON_CreateObject();
|
||||||
|
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->srcId.addr);
|
||||||
|
cJSON_AddStringToObject(pSrcId, "addr", u64buf);
|
||||||
|
{
|
||||||
|
uint64_t u64 = pMsg->srcId.addr;
|
||||||
|
cJSON* pTmp = pSrcId;
|
||||||
|
char host[128] = {0};
|
||||||
|
uint16_t port;
|
||||||
|
syncUtilU642Addr(u64, host, sizeof(host), &port);
|
||||||
|
cJSON_AddStringToObject(pTmp, "addr_host", host);
|
||||||
|
cJSON_AddNumberToObject(pTmp, "addr_port", port);
|
||||||
|
}
|
||||||
|
cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId);
|
||||||
|
cJSON_AddItemToObject(pRoot, "srcId", pSrcId);
|
||||||
|
|
||||||
|
cJSON* pDestId = cJSON_CreateObject();
|
||||||
|
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->destId.addr);
|
||||||
|
cJSON_AddStringToObject(pDestId, "addr", u64buf);
|
||||||
|
{
|
||||||
|
uint64_t u64 = pMsg->destId.addr;
|
||||||
|
cJSON* pTmp = pDestId;
|
||||||
|
char host[128] = {0};
|
||||||
|
uint16_t port;
|
||||||
|
syncUtilU642Addr(u64, host, sizeof(host), &port);
|
||||||
|
cJSON_AddStringToObject(pTmp, "addr_host", host);
|
||||||
|
cJSON_AddNumberToObject(pTmp, "addr_port", port);
|
||||||
|
}
|
||||||
|
cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId);
|
||||||
|
cJSON_AddItemToObject(pRoot, "destId", pDestId);
|
||||||
|
|
||||||
|
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->term);
|
||||||
|
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
||||||
|
|
||||||
|
snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->snapStart);
|
||||||
|
cJSON_AddStringToObject(pRoot, "snap-start", u64buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON* pJson = cJSON_CreateObject();
|
||||||
|
cJSON_AddItemToObject(pJson, "SyncPreSnapshotReply", pRoot);
|
||||||
|
return pJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* syncPreSnapshotReply2Str(const SyncPreSnapshotReply* pMsg) {
|
||||||
|
cJSON* pJson = syncPreSnapshotReply2Json(pMsg);
|
||||||
|
char* serialized = cJSON_Print(pJson);
|
||||||
|
cJSON_Delete(pJson);
|
||||||
|
return serialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshotReplyPrint(const SyncPreSnapshotReply* pMsg) {
|
||||||
|
char* serialized = syncPreSnapshotReply2Str(pMsg);
|
||||||
|
printf("syncPreSnapshotReplyPrint | len:%d | %s \n", (int32_t)strlen(serialized), serialized);
|
||||||
|
fflush(NULL);
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshotReplyPrint2(char* s, const SyncPreSnapshotReply* pMsg) {
|
||||||
|
char* serialized = syncPreSnapshotReply2Str(pMsg);
|
||||||
|
printf("syncPreSnapshotReplyPrint2 | len:%d | %s | %s \n", (int32_t)strlen(serialized), s, serialized);
|
||||||
|
fflush(NULL);
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshotReplyLog(const SyncPreSnapshotReply* pMsg) {
|
||||||
|
char* serialized = syncPreSnapshotReply2Str(pMsg);
|
||||||
|
sTrace("syncPreSnapshotReplyLog | len:%d | %s", (int32_t)strlen(serialized), serialized);
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncPreSnapshotReplyLog2(char* s, const SyncPreSnapshotReply* pMsg) {
|
||||||
|
if (gRaftDetailLog) {
|
||||||
|
char* serialized = syncPreSnapshotReply2Str(pMsg);
|
||||||
|
sTrace("syncPreSnapshotReplyLog2 | len:%d | %s | %s", (int32_t)strlen(serialized), s, serialized);
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---- message process SyncApplyMsg----
|
// ---- message process SyncApplyMsg----
|
||||||
SyncApplyMsg* syncApplyMsgBuild(uint32_t dataLen) {
|
SyncApplyMsg* syncApplyMsgBuild(uint32_t dataLen) {
|
||||||
uint32_t bytes = sizeof(SyncApplyMsg) + dataLen;
|
uint32_t bytes = sizeof(SyncApplyMsg) + dataLen;
|
||||||
|
@ -2413,7 +2710,7 @@ cJSON* syncApplyMsg2Json(const SyncApplyMsg* pMsg) {
|
||||||
cJSON_AddNumberToObject(pRoot, "fsmMeta.isWeak", pMsg->fsmMeta.isWeak);
|
cJSON_AddNumberToObject(pRoot, "fsmMeta.isWeak", pMsg->fsmMeta.isWeak);
|
||||||
cJSON_AddNumberToObject(pRoot, "fsmMeta.code", pMsg->fsmMeta.code);
|
cJSON_AddNumberToObject(pRoot, "fsmMeta.code", pMsg->fsmMeta.code);
|
||||||
cJSON_AddNumberToObject(pRoot, "fsmMeta.state", pMsg->fsmMeta.state);
|
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);
|
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->fsmMeta.seqNum);
|
||||||
cJSON_AddStringToObject(pRoot, "fsmMeta.seqNum", u64buf);
|
cJSON_AddStringToObject(pRoot, "fsmMeta.seqNum", u64buf);
|
||||||
|
|
||||||
|
@ -2576,8 +2873,8 @@ cJSON* syncSnapshotSend2Json(const SyncSnapshotSend* pMsg) {
|
||||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->term);
|
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->term);
|
||||||
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
||||||
|
|
||||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->privateTerm);
|
snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->startTime);
|
||||||
cJSON_AddStringToObject(pRoot, "privateTerm", u64buf);
|
cJSON_AddStringToObject(pRoot, "startTime", u64buf);
|
||||||
|
|
||||||
snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->beginIndex);
|
snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->beginIndex);
|
||||||
cJSON_AddStringToObject(pRoot, "beginIndex", u64buf);
|
cJSON_AddStringToObject(pRoot, "beginIndex", u64buf);
|
||||||
|
@ -2751,8 +3048,8 @@ cJSON* syncSnapshotRsp2Json(const SyncSnapshotRsp* pMsg) {
|
||||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->term);
|
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->term);
|
||||||
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
||||||
|
|
||||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->privateTerm);
|
snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->startTime);
|
||||||
cJSON_AddStringToObject(pRoot, "privateTerm", u64buf);
|
cJSON_AddStringToObject(pRoot, "startTime", u64buf);
|
||||||
|
|
||||||
snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->lastIndex);
|
snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->lastIndex);
|
||||||
cJSON_AddStringToObject(pRoot, "lastIndex", u64buf);
|
cJSON_AddStringToObject(pRoot, "lastIndex", u64buf);
|
||||||
|
@ -2762,6 +3059,9 @@ cJSON* syncSnapshotRsp2Json(const SyncSnapshotRsp* pMsg) {
|
||||||
|
|
||||||
cJSON_AddNumberToObject(pRoot, "ack", pMsg->ack);
|
cJSON_AddNumberToObject(pRoot, "ack", pMsg->ack);
|
||||||
cJSON_AddNumberToObject(pRoot, "code", pMsg->code);
|
cJSON_AddNumberToObject(pRoot, "code", pMsg->code);
|
||||||
|
|
||||||
|
snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->snapBeginIndex);
|
||||||
|
cJSON_AddStringToObject(pRoot, "snap-begin", u64buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
cJSON* pJson = cJSON_CreateObject();
|
cJSON* pJson = cJSON_CreateObject();
|
||||||
|
|
|
@ -62,8 +62,8 @@ int32_t syncNodeReplicateOne(SSyncNode* pSyncNode, SRaftId* pDestId) {
|
||||||
syncNodeEventLog(pSyncNode, logBuf);
|
syncNodeEventLog(pSyncNode, logBuf);
|
||||||
|
|
||||||
// start snapshot
|
// start snapshot
|
||||||
int32_t code = syncNodeStartSnapshot(pSyncNode, pDestId);
|
// int32_t code = syncNodeStartSnapshot(pSyncNode, pDestId);
|
||||||
ASSERT(code == 0);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,6 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI
|
||||||
}
|
}
|
||||||
memset(pSender, 0, sizeof(*pSender));
|
memset(pSender, 0, sizeof(*pSender));
|
||||||
|
|
||||||
int64_t timeNow = taosGetTimestampMs();
|
|
||||||
|
|
||||||
pSender->start = false;
|
pSender->start = false;
|
||||||
pSender->seq = SYNC_SNAPSHOT_SEQ_INVALID;
|
pSender->seq = SYNC_SNAPSHOT_SEQ_INVALID;
|
||||||
pSender->ack = SYNC_SNAPSHOT_SEQ_INVALID;
|
pSender->ack = SYNC_SNAPSHOT_SEQ_INVALID;
|
||||||
|
@ -53,8 +51,7 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI
|
||||||
pSender->pSyncNode = pSyncNode;
|
pSender->pSyncNode = pSyncNode;
|
||||||
pSender->replicaIndex = replicaIndex;
|
pSender->replicaIndex = replicaIndex;
|
||||||
pSender->term = pSyncNode->pRaftStore->currentTerm;
|
pSender->term = pSyncNode->pRaftStore->currentTerm;
|
||||||
pSender->privateTerm = timeNow + 100;
|
pSender->startTime = 0;
|
||||||
pSender->startTime = timeNow;
|
|
||||||
pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &(pSender->snapshot));
|
pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &(pSender->snapshot));
|
||||||
pSender->finish = false;
|
pSender->finish = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -88,88 +85,30 @@ void snapshotSenderDestroy(SSyncSnapshotSender *pSender) {
|
||||||
|
|
||||||
bool snapshotSenderIsStart(SSyncSnapshotSender *pSender) { return pSender->start; }
|
bool snapshotSenderIsStart(SSyncSnapshotSender *pSender) { return pSender->start; }
|
||||||
|
|
||||||
// begin send snapshot by param, snapshot, pReader
|
int32_t snapshotSenderStart(SSyncSnapshotSender *pSender) {
|
||||||
//
|
|
||||||
// action:
|
|
||||||
// 1. assert reader not start
|
|
||||||
// 2. update state
|
|
||||||
// 3. send first snapshot block
|
|
||||||
int32_t snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshotParam snapshotParam, SSnapshot snapshot,
|
|
||||||
void *pReader) {
|
|
||||||
ASSERT(!snapshotSenderIsStart(pSender));
|
ASSERT(!snapshotSenderIsStart(pSender));
|
||||||
|
|
||||||
// init snapshot, parm, reader
|
|
||||||
ASSERT(pSender->pReader == NULL);
|
|
||||||
pSender->pReader = pReader;
|
|
||||||
pSender->snapshot = snapshot;
|
|
||||||
pSender->snapshotParam = snapshotParam;
|
|
||||||
|
|
||||||
// init current block
|
|
||||||
if (pSender->pCurrentBlock != NULL) {
|
|
||||||
taosMemoryFree(pSender->pCurrentBlock);
|
|
||||||
}
|
|
||||||
pSender->blockLen = 0;
|
|
||||||
|
|
||||||
// update term
|
|
||||||
pSender->term = pSender->pSyncNode->pRaftStore->currentTerm;
|
|
||||||
++(pSender->privateTerm); // increase private term
|
|
||||||
|
|
||||||
// update state
|
|
||||||
pSender->finish = false;
|
|
||||||
pSender->start = true;
|
pSender->start = true;
|
||||||
pSender->seq = SYNC_SNAPSHOT_SEQ_BEGIN;
|
pSender->seq = SYNC_SNAPSHOT_SEQ_BEGIN;
|
||||||
pSender->ack = SYNC_SNAPSHOT_SEQ_INVALID;
|
pSender->ack = SYNC_SNAPSHOT_SEQ_INVALID;
|
||||||
|
pSender->pReader = NULL;
|
||||||
|
pSender->pCurrentBlock = NULL;
|
||||||
|
pSender->blockLen = 0;
|
||||||
|
|
||||||
// init last config
|
pSender->snapshotParam.start = SYNC_INDEX_INVALID;
|
||||||
if (pSender->snapshot.lastConfigIndex != SYNC_INDEX_INVALID) {
|
pSender->snapshotParam.end = SYNC_INDEX_INVALID;
|
||||||
int32_t code = 0;
|
|
||||||
SSyncRaftEntry *pEntry = NULL;
|
|
||||||
bool getLastConfig = false;
|
|
||||||
|
|
||||||
code = pSender->pSyncNode->pLogStore->syncLogGetEntry(pSender->pSyncNode->pLogStore,
|
pSender->snapshot.data = NULL;
|
||||||
pSender->snapshot.lastConfigIndex, &pEntry);
|
pSender->snapshotParam.end = SYNC_INDEX_INVALID;
|
||||||
if (code == 0 && pEntry != NULL) {
|
pSender->snapshot.lastApplyIndex = SYNC_INDEX_INVALID;
|
||||||
SRpcMsg rpcMsg;
|
pSender->snapshot.lastApplyTerm = SYNC_TERM_INVALID;
|
||||||
syncEntry2OriginalRpc(pEntry, &rpcMsg);
|
pSender->snapshot.lastConfigIndex = SYNC_INDEX_INVALID;
|
||||||
|
|
||||||
SSyncCfg lastConfig;
|
memset(&(pSender->lastConfig), 0, sizeof(pSender->lastConfig));
|
||||||
int32_t ret = syncCfgFromStr(rpcMsg.pCont, &lastConfig);
|
pSender->sendingMS = 0;
|
||||||
ASSERT(ret == 0);
|
pSender->term = pSender->pSyncNode->pRaftStore->currentTerm;
|
||||||
pSender->lastConfig = lastConfig;
|
pSender->startTime = taosGetTimestampMs();
|
||||||
getLastConfig = true;
|
pSender->finish = false;
|
||||||
|
|
||||||
rpcFreeCont(rpcMsg.pCont);
|
|
||||||
syncEntryDestory(pEntry);
|
|
||||||
} else {
|
|
||||||
if (pSender->snapshot.lastConfigIndex == pSender->pSyncNode->pRaftCfg->lastConfigIndex) {
|
|
||||||
sTrace("vgId:%d, sync sender get cfg from local", pSender->pSyncNode->vgId);
|
|
||||||
pSender->lastConfig = pSender->pSyncNode->pRaftCfg->cfg;
|
|
||||||
getLastConfig = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// last config not found in wal, update to -1
|
|
||||||
if (!getLastConfig) {
|
|
||||||
SyncIndex oldLastConfigIndex = pSender->snapshot.lastConfigIndex;
|
|
||||||
SyncIndex newLastConfigIndex = SYNC_INDEX_INVALID;
|
|
||||||
pSender->snapshot.lastConfigIndex = SYNC_INDEX_INVALID;
|
|
||||||
memset(&(pSender->lastConfig), 0, sizeof(SSyncCfg));
|
|
||||||
|
|
||||||
// event log
|
|
||||||
do {
|
|
||||||
char logBuf[128];
|
|
||||||
snprintf(logBuf, sizeof(logBuf), "snapshot sender update lcindex from %" PRId64 " to %" PRId64,
|
|
||||||
oldLastConfigIndex, newLastConfigIndex);
|
|
||||||
char *eventLog = snapshotSender2SimpleStr(pSender, logBuf);
|
|
||||||
syncNodeEventLog(pSender->pSyncNode, eventLog);
|
|
||||||
taosMemoryFree(eventLog);
|
|
||||||
} while (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// no last config
|
|
||||||
memset(&(pSender->lastConfig), 0, sizeof(SSyncCfg));
|
|
||||||
}
|
|
||||||
|
|
||||||
// build begin msg
|
// build begin msg
|
||||||
SyncSnapshotSend *pMsg = syncSnapshotSendBuild(0, pSender->pSyncNode->vgId);
|
SyncSnapshotSend *pMsg = syncSnapshotSendBuild(0, pSender->pSyncNode->vgId);
|
||||||
|
@ -181,8 +120,8 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshotParam snapsho
|
||||||
pMsg->lastTerm = pSender->snapshot.lastApplyTerm;
|
pMsg->lastTerm = pSender->snapshot.lastApplyTerm;
|
||||||
pMsg->lastConfigIndex = pSender->snapshot.lastConfigIndex;
|
pMsg->lastConfigIndex = pSender->snapshot.lastConfigIndex;
|
||||||
pMsg->lastConfig = pSender->lastConfig;
|
pMsg->lastConfig = pSender->lastConfig;
|
||||||
pMsg->seq = pSender->seq; // SYNC_SNAPSHOT_SEQ_BEGIN
|
pMsg->startTime = pSender->startTime;
|
||||||
pMsg->privateTerm = pSender->privateTerm;
|
pMsg->seq = SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT;
|
||||||
|
|
||||||
// send msg
|
// send msg
|
||||||
SRpcMsg rpcMsg;
|
SRpcMsg rpcMsg;
|
||||||
|
@ -201,6 +140,10 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshotParam snapsho
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) {
|
int32_t snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) {
|
||||||
|
// update flag
|
||||||
|
pSender->start = false;
|
||||||
|
pSender->finish = finish;
|
||||||
|
|
||||||
// close reader
|
// close reader
|
||||||
if (pSender->pReader != NULL) {
|
if (pSender->pReader != NULL) {
|
||||||
int32_t ret = pSender->pSyncNode->pFsm->FpSnapshotStopRead(pSender->pSyncNode->pFsm, pSender->pReader);
|
int32_t ret = pSender->pSyncNode->pFsm->FpSnapshotStopRead(pSender->pSyncNode->pFsm, pSender->pReader);
|
||||||
|
@ -215,12 +158,6 @@ int32_t snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) {
|
||||||
pSender->blockLen = 0;
|
pSender->blockLen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update flag
|
|
||||||
pSender->start = false;
|
|
||||||
pSender->finish = finish;
|
|
||||||
|
|
||||||
// do not update term, maybe print
|
|
||||||
|
|
||||||
// event log
|
// event log
|
||||||
do {
|
do {
|
||||||
char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender stop");
|
char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender stop");
|
||||||
|
@ -263,7 +200,9 @@ int32_t snapshotSend(SSyncSnapshotSender *pSender) {
|
||||||
pMsg->lastConfigIndex = pSender->snapshot.lastConfigIndex;
|
pMsg->lastConfigIndex = pSender->snapshot.lastConfigIndex;
|
||||||
pMsg->lastConfig = pSender->lastConfig;
|
pMsg->lastConfig = pSender->lastConfig;
|
||||||
pMsg->seq = pSender->seq;
|
pMsg->seq = pSender->seq;
|
||||||
pMsg->privateTerm = pSender->privateTerm;
|
|
||||||
|
// pMsg->privateTerm = pSender->privateTerm;
|
||||||
|
|
||||||
memcpy(pMsg->data, pSender->pCurrentBlock, pSender->blockLen);
|
memcpy(pMsg->data, pSender->pCurrentBlock, pSender->blockLen);
|
||||||
|
|
||||||
// send msg
|
// send msg
|
||||||
|
@ -302,7 +241,9 @@ int32_t snapshotReSend(SSyncSnapshotSender *pSender) {
|
||||||
pMsg->lastConfigIndex = pSender->snapshot.lastConfigIndex;
|
pMsg->lastConfigIndex = pSender->snapshot.lastConfigIndex;
|
||||||
pMsg->lastConfig = pSender->lastConfig;
|
pMsg->lastConfig = pSender->lastConfig;
|
||||||
pMsg->seq = pSender->seq;
|
pMsg->seq = pSender->seq;
|
||||||
pMsg->privateTerm = pSender->privateTerm;
|
|
||||||
|
// pMsg->privateTerm = pSender->privateTerm;
|
||||||
|
|
||||||
memcpy(pMsg->data, pSender->pCurrentBlock, pSender->blockLen);
|
memcpy(pMsg->data, pSender->pCurrentBlock, pSender->blockLen);
|
||||||
|
|
||||||
// send msg
|
// send msg
|
||||||
|
@ -367,8 +308,10 @@ cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender) {
|
||||||
cJSON_AddNumberToObject(pRoot, "replicaIndex", pSender->replicaIndex);
|
cJSON_AddNumberToObject(pRoot, "replicaIndex", pSender->replicaIndex);
|
||||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSender->term);
|
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSender->term);
|
||||||
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
||||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSender->privateTerm);
|
|
||||||
cJSON_AddStringToObject(pRoot, "privateTerm", u64buf);
|
// snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSender->privateTerm);
|
||||||
|
// cJSON_AddStringToObject(pRoot, "privateTerm", u64buf);
|
||||||
|
|
||||||
cJSON_AddNumberToObject(pRoot, "finish", pSender->finish);
|
cJSON_AddNumberToObject(pRoot, "finish", pSender->finish);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,30 +338,38 @@ char *snapshotSender2SimpleStr(SSyncSnapshotSender *pSender, char *event) {
|
||||||
|
|
||||||
snprintf(s, len,
|
snprintf(s, len,
|
||||||
"%s {%p s-param:%" PRId64 " e-param:%" PRId64 " laindex:%" PRId64 " laterm:%" PRIu64 " lcindex:%" PRId64
|
"%s {%p s-param:%" PRId64 " e-param:%" PRId64 " laindex:%" PRId64 " laterm:%" PRIu64 " lcindex:%" PRId64
|
||||||
" seq:%d ack:%d finish:%d pterm:%" PRIu64
|
" seq:%d ack:%d finish:%d replica-index:%d %s:%d}",
|
||||||
" "
|
|
||||||
"replica-index:%d %s:%d}",
|
|
||||||
event, pSender, pSender->snapshotParam.start, pSender->snapshotParam.end, pSender->snapshot.lastApplyIndex,
|
event, pSender, pSender->snapshotParam.start, pSender->snapshotParam.end, pSender->snapshot.lastApplyIndex,
|
||||||
pSender->snapshot.lastApplyTerm, pSender->snapshot.lastConfigIndex, pSender->seq, pSender->ack,
|
pSender->snapshot.lastApplyTerm, pSender->snapshot.lastConfigIndex, pSender->seq, pSender->ack,
|
||||||
pSender->finish, pSender->privateTerm, pSender->replicaIndex, host, port);
|
pSender->finish, pSender->replicaIndex, host, port);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t syncNodeStartSnapshot(SSyncNode *pSyncNode, SRaftId *pDestId) {
|
int32_t syncNodeStartSnapshot(SSyncNode *pSyncNode, SRaftId *pDestId) {
|
||||||
// calculate <start, end> index
|
syncNodeEventLog(pSyncNode, "starting snapshot ...");
|
||||||
|
|
||||||
syncNodeEventLog(pSyncNode, "start snapshot ...");
|
|
||||||
|
|
||||||
SSyncSnapshotSender *pSender = syncNodeGetSnapshotSender(pSyncNode, pDestId);
|
SSyncSnapshotSender *pSender = syncNodeGetSnapshotSender(pSyncNode, pDestId);
|
||||||
if (pSender == NULL) {
|
if (pSender == NULL) {
|
||||||
// create sender
|
syncNodeErrorLog(pSyncNode, "start snapshot error, sender is null");
|
||||||
} else {
|
return -1;
|
||||||
// if <start, end> is same
|
|
||||||
// return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// send begin msg
|
int32_t code = 0;
|
||||||
|
|
||||||
|
if (snapshotSenderIsStart(pSender)) {
|
||||||
|
code = snapshotSenderStop(pSender, false);
|
||||||
|
if (code != 0) {
|
||||||
|
syncNodeErrorLog(pSyncNode, "snapshot sender stop error");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
code = snapshotSenderStart(pSender);
|
||||||
|
if (code != 0) {
|
||||||
|
syncNodeErrorLog(pSyncNode, "snapshot sender start error");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -440,7 +391,6 @@ SSyncSnapshotReceiver *snapshotReceiverCreate(SSyncNode *pSyncNode, SRaftId from
|
||||||
pReceiver->pSyncNode = pSyncNode;
|
pReceiver->pSyncNode = pSyncNode;
|
||||||
pReceiver->fromId = fromId;
|
pReceiver->fromId = fromId;
|
||||||
pReceiver->term = pSyncNode->pRaftStore->currentTerm;
|
pReceiver->term = pSyncNode->pRaftStore->currentTerm;
|
||||||
pReceiver->privateTerm = 0;
|
|
||||||
pReceiver->snapshot.data = NULL;
|
pReceiver->snapshot.data = NULL;
|
||||||
pReceiver->snapshot.lastApplyIndex = SYNC_INDEX_INVALID;
|
pReceiver->snapshot.lastApplyIndex = SYNC_INDEX_INVALID;
|
||||||
pReceiver->snapshot.lastApplyTerm = 0;
|
pReceiver->snapshot.lastApplyTerm = 0;
|
||||||
|
@ -474,19 +424,8 @@ bool snapshotReceiverIsStart(SSyncSnapshotReceiver *pReceiver) { return pReceive
|
||||||
// receive first snapshot data
|
// receive first snapshot data
|
||||||
// write first block data
|
// write first block data
|
||||||
static void snapshotReceiverDoStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pBeginMsg) {
|
static void snapshotReceiverDoStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pBeginMsg) {
|
||||||
// update state
|
|
||||||
pReceiver->term = pReceiver->pSyncNode->pRaftStore->currentTerm;
|
|
||||||
pReceiver->privateTerm = pBeginMsg->privateTerm;
|
|
||||||
pReceiver->ack = SYNC_SNAPSHOT_SEQ_BEGIN;
|
|
||||||
pReceiver->fromId = pBeginMsg->srcId;
|
|
||||||
pReceiver->start = true;
|
pReceiver->start = true;
|
||||||
|
pReceiver->ack = SYNC_SNAPSHOT_SEQ_BEGIN;
|
||||||
// update snapshot
|
|
||||||
pReceiver->snapshot.lastApplyIndex = pBeginMsg->lastIndex;
|
|
||||||
pReceiver->snapshot.lastApplyTerm = pBeginMsg->lastTerm;
|
|
||||||
pReceiver->snapshot.lastConfigIndex = pBeginMsg->lastConfigIndex;
|
|
||||||
pReceiver->snapshotParam.start = pBeginMsg->beginIndex;
|
|
||||||
pReceiver->snapshotParam.end = pBeginMsg->lastIndex;
|
|
||||||
|
|
||||||
// start writer
|
// start writer
|
||||||
ASSERT(pReceiver->pWriter == NULL);
|
ASSERT(pReceiver->pWriter == NULL);
|
||||||
|
@ -494,6 +433,19 @@ static void snapshotReceiverDoStart(SSyncSnapshotReceiver *pReceiver, SyncSnapsh
|
||||||
&(pReceiver->snapshotParam), &(pReceiver->pWriter));
|
&(pReceiver->snapshotParam), &(pReceiver->pWriter));
|
||||||
ASSERT(ret == 0);
|
ASSERT(ret == 0);
|
||||||
|
|
||||||
|
pReceiver->term = pReceiver->pSyncNode->pRaftStore->currentTerm;
|
||||||
|
pReceiver->snapshotParam.start = pBeginMsg->beginIndex;
|
||||||
|
pReceiver->snapshotParam.end = pBeginMsg->lastIndex;
|
||||||
|
|
||||||
|
pReceiver->fromId = pBeginMsg->srcId;
|
||||||
|
|
||||||
|
// update snapshot
|
||||||
|
pReceiver->snapshot.lastApplyIndex = pBeginMsg->lastIndex;
|
||||||
|
pReceiver->snapshot.lastApplyTerm = pBeginMsg->lastTerm;
|
||||||
|
pReceiver->snapshot.lastConfigIndex = pBeginMsg->lastConfigIndex;
|
||||||
|
|
||||||
|
pReceiver->startTime = pBeginMsg->startTime;
|
||||||
|
|
||||||
// event log
|
// event log
|
||||||
do {
|
do {
|
||||||
char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver start");
|
char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver start");
|
||||||
|
@ -523,22 +475,9 @@ void snapshotReceiverForceStop(SSyncSnapshotReceiver *pReceiver) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if receiver receive msg from seq = SYNC_SNAPSHOT_SEQ_BEGIN, start receiver
|
// if receiver receive msg from seq = SYNC_SNAPSHOT_SEQ_BEGIN, start receiver
|
||||||
// if already start, force close, start again
|
|
||||||
int32_t snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pBeginMsg) {
|
int32_t snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pBeginMsg) {
|
||||||
if (!snapshotReceiverIsStart(pReceiver)) {
|
ASSERT(!snapshotReceiverIsStart(pReceiver));
|
||||||
// first start
|
snapshotReceiverDoStart(pReceiver, pBeginMsg);
|
||||||
snapshotReceiverDoStart(pReceiver, pBeginMsg);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// already start
|
|
||||||
sInfo("vgId:%d, snapshot recv, receiver already start", pReceiver->pSyncNode->vgId);
|
|
||||||
|
|
||||||
// force close, abandon incomplete data
|
|
||||||
snapshotReceiverForceStop(pReceiver);
|
|
||||||
|
|
||||||
// start again
|
|
||||||
snapshotReceiverDoStart(pReceiver, pBeginMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -698,8 +637,8 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) {
|
||||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pReceiver->term);
|
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pReceiver->term);
|
||||||
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
||||||
|
|
||||||
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pReceiver->privateTerm);
|
snprintf(u64buf, sizeof(u64buf), "%" PRId64, pReceiver->startTime);
|
||||||
cJSON_AddStringToObject(pRoot, "privateTerm", u64buf);
|
cJSON_AddStringToObject(pRoot, "startTime", u64buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
cJSON *pJson = cJSON_CreateObject();
|
cJSON *pJson = cJSON_CreateObject();
|
||||||
|
@ -724,38 +663,204 @@ char *snapshotReceiver2SimpleStr(SSyncSnapshotReceiver *pReceiver, char *event)
|
||||||
syncUtilU642Addr(fromId.addr, host, sizeof(host), &port);
|
syncUtilU642Addr(fromId.addr, host, sizeof(host), &port);
|
||||||
|
|
||||||
snprintf(s, len,
|
snprintf(s, len,
|
||||||
"%s {%p start:%d ack:%d term:%" PRIu64 " pterm:%" PRIu64 " from:%s:%d s-param:%" PRId64 " e-param:%" PRId64
|
"%s {%p start:%d ack:%d term:%" PRIu64 " start-time:%" PRId64 " from:%s:%d s-param:%" PRId64
|
||||||
" laindex:%" PRId64 " laterm:%" PRIu64
|
" e-param:%" PRId64 " laindex:%" PRId64 " laterm:%" PRIu64
|
||||||
" "
|
" "
|
||||||
"lcindex:%" PRId64 "}",
|
"lcindex:%" PRId64 "}",
|
||||||
event, pReceiver, pReceiver->start, pReceiver->ack, pReceiver->term, pReceiver->privateTerm, host, port,
|
event, pReceiver, pReceiver->start, pReceiver->ack, pReceiver->term, pReceiver->startTime, host, port,
|
||||||
pReceiver->snapshotParam.start, pReceiver->snapshotParam.end, pReceiver->snapshot.lastApplyIndex,
|
pReceiver->snapshotParam.start, pReceiver->snapshotParam.end, pReceiver->snapshot.lastApplyIndex,
|
||||||
pReceiver->snapshot.lastApplyTerm, pReceiver->snapshot.lastConfigIndex);
|
pReceiver->snapshot.lastApplyTerm, pReceiver->snapshot.lastConfigIndex);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SyncIndex syncNodeGetSnapBeginIndex(SSyncNode *ths) {
|
||||||
|
SyncIndex snapStart = SYNC_INDEX_INVALID;
|
||||||
|
|
||||||
|
if (syncNodeIsMnode(ths)) {
|
||||||
|
snapStart = SYNC_INDEX_BEGIN;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
SSyncLogStoreData *pData = ths->pLogStore->data;
|
||||||
|
SWal *pWal = pData->pWal;
|
||||||
|
|
||||||
|
bool isEmpty = ths->pLogStore->syncLogIsEmpty(ths->pLogStore);
|
||||||
|
int64_t walCommitVer = walGetCommittedVer(pWal);
|
||||||
|
|
||||||
|
if (!isEmpty && ths->commitIndex != walCommitVer) {
|
||||||
|
char logBuf[128];
|
||||||
|
snprintf(logBuf, sizeof(logBuf), "commit not same, wal-commit:%" PRId64 ", commit:%" PRId64 ", ignore",
|
||||||
|
walCommitVer, ths->commitIndex);
|
||||||
|
syncNodeErrorLog(ths, logBuf);
|
||||||
|
|
||||||
|
snapStart = walCommitVer + 1;
|
||||||
|
} else {
|
||||||
|
snapStart = ths->commitIndex + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return snapStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t syncNodeOnSnapshotPre(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
|
||||||
|
SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver;
|
||||||
|
|
||||||
|
if (snapshotReceiverIsStart(pReceiver)) {
|
||||||
|
// already start
|
||||||
|
|
||||||
|
if (pMsg->startTime > pReceiver->startTime) {
|
||||||
|
goto _START_RECEIVER;
|
||||||
|
|
||||||
|
} else if (pMsg->startTime == pReceiver->startTime) {
|
||||||
|
goto _SEND_REPLY;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// ignore
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// start new
|
||||||
|
goto _START_RECEIVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
_START_RECEIVER:
|
||||||
|
if (taosGetTimestampMs() - pMsg->startTime > SNAPSHOT_MAX_CLOCK_SKEW_MS) {
|
||||||
|
syncNodeErrorLog(pSyncNode, "snapshot receiver time skew too much");
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
// waiting for clock match
|
||||||
|
while (taosGetTimestampMs() > pMsg->startTime) {
|
||||||
|
taosMsleep(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
snapshotReceiverStart(pReceiver, pMsg); // set start-time same with sender
|
||||||
|
}
|
||||||
|
|
||||||
|
_SEND_REPLY:
|
||||||
|
// build msg
|
||||||
|
; // make complier happy
|
||||||
|
SyncSnapshotRsp *pRspMsg = syncSnapshotRspBuild(pSyncNode->vgId);
|
||||||
|
pRspMsg->srcId = pSyncNode->myRaftId;
|
||||||
|
pRspMsg->destId = pMsg->srcId;
|
||||||
|
pRspMsg->term = pSyncNode->pRaftStore->currentTerm;
|
||||||
|
pRspMsg->lastIndex = pMsg->lastIndex;
|
||||||
|
pRspMsg->lastTerm = pMsg->lastTerm;
|
||||||
|
pRspMsg->startTime = pReceiver->startTime;
|
||||||
|
pRspMsg->ack = pMsg->seq; // receiver maybe already closed
|
||||||
|
pRspMsg->code = 0;
|
||||||
|
pRspMsg->snapBeginIndex = syncNodeGetSnapBeginIndex(pSyncNode);
|
||||||
|
|
||||||
|
// send msg
|
||||||
|
SRpcMsg rpcMsg;
|
||||||
|
syncSnapshotRsp2RpcMsg(pRspMsg, &rpcMsg);
|
||||||
|
syncNodeSendMsgById(&(pRspMsg->destId), pSyncNode, &rpcMsg);
|
||||||
|
syncSnapshotRspDestroy(pRspMsg);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t syncNodeOnSnapshotBegin(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
|
||||||
|
// condition 1
|
||||||
|
SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver;
|
||||||
|
|
||||||
|
if (snapshotReceiverIsStart(pReceiver)) {
|
||||||
|
if (pMsg->startTime > pReceiver->startTime) {
|
||||||
|
snapshotReceiverStop(pReceiver);
|
||||||
|
|
||||||
|
} else if (pMsg->startTime == pReceiver->startTime) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
// ignore
|
||||||
|
syncNodeEventLog(pSyncNode, "msg ignore");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_START_RECEIVER:
|
||||||
|
if (taosGetTimestampMs() - pMsg->startTime > SNAPSHOT_MAX_CLOCK_SKEW_MS) {
|
||||||
|
syncNodeErrorLog(pSyncNode, "snapshot receiver time skew too much");
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
// waiting for clock match
|
||||||
|
while (taosGetTimestampMs() > pMsg->startTime) {
|
||||||
|
taosMsleep(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
snapshotReceiverStart(pReceiver, pMsg);
|
||||||
|
|
||||||
|
// build msg
|
||||||
|
SyncSnapshotRsp *pRspMsg = syncSnapshotRspBuild(pSyncNode->vgId);
|
||||||
|
pRspMsg->srcId = pSyncNode->myRaftId;
|
||||||
|
pRspMsg->destId = pMsg->srcId;
|
||||||
|
pRspMsg->term = pSyncNode->pRaftStore->currentTerm;
|
||||||
|
pRspMsg->lastIndex = pMsg->lastIndex;
|
||||||
|
pRspMsg->lastTerm = pMsg->lastTerm;
|
||||||
|
pRspMsg->ack = pReceiver->ack; // receiver maybe already closed
|
||||||
|
pRspMsg->code = 0;
|
||||||
|
|
||||||
|
// send msg
|
||||||
|
SRpcMsg rpcMsg;
|
||||||
|
syncSnapshotRsp2RpcMsg(pRspMsg, &rpcMsg);
|
||||||
|
syncNodeSendMsgById(&(pRspMsg->destId), pSyncNode, &rpcMsg);
|
||||||
|
syncSnapshotRspDestroy(pRspMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t syncNodeOnSnapshotTransfer(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { return 0; }
|
||||||
|
|
||||||
|
static int32_t syncNodeOnSnapshotEnd(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { return 0; }
|
||||||
|
|
||||||
// receiver on message
|
// receiver on message
|
||||||
//
|
//
|
||||||
// condition 1, recv SYNC_SNAPSHOT_SEQ_BEGIN, start receiver, update privateTerm
|
// condition 1, recv SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT
|
||||||
// condition 2, recv SYNC_SNAPSHOT_SEQ_END, finish receiver(apply snapshot data, update commit index, maybe reconfig)
|
// if receiver already start
|
||||||
// condition 3, recv SYNC_SNAPSHOT_SEQ_FORCE_CLOSE, force close
|
// if sender.start-time > receiver.start-time, restart receiver(reply snapshot start)
|
||||||
// condition 4, got data, update ack
|
// if sender.start-time = receiver.start-time, maybe duplicate msg
|
||||||
|
// if sender.start-time < receiver.start-time, ignore
|
||||||
|
// else
|
||||||
|
// waiting for clock match
|
||||||
|
// start receiver(reply snapshot start)
|
||||||
|
//
|
||||||
|
// condition 2, recv SYNC_SNAPSHOT_SEQ_BEGIN
|
||||||
|
// a. create writer with <begin, end>
|
||||||
|
//
|
||||||
|
// condition 3, recv SYNC_SNAPSHOT_SEQ_END, finish receiver(apply snapshot data, update commit index, maybe reconfig)
|
||||||
|
//
|
||||||
|
// condition 4, recv SYNC_SNAPSHOT_SEQ_FORCE_CLOSE, force close
|
||||||
|
//
|
||||||
|
// condition 5, got data, update ack
|
||||||
//
|
//
|
||||||
int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
|
int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
|
||||||
// get receiver
|
// if already drop replica, do not process
|
||||||
SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver;
|
if (!syncNodeInRaftGroup(pSyncNode, &(pMsg->srcId))) {
|
||||||
bool needRsp = false;
|
syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "not in my config");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMsg->term < pSyncNode->pRaftStore->currentTerm) {
|
||||||
|
syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "reject, small term");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMsg->term > pSyncNode->pRaftStore->currentTerm) {
|
||||||
|
syncNodeStepDown(pSyncNode, pMsg->term);
|
||||||
|
}
|
||||||
|
syncNodeResetElectTimer(pSyncNode);
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver;
|
||||||
|
|
||||||
// state, term, seq/ack
|
// state, term, seq/ack
|
||||||
if (pSyncNode->state == TAOS_SYNC_STATE_FOLLOWER) {
|
if (pSyncNode->state == TAOS_SYNC_STATE_FOLLOWER) {
|
||||||
if (pMsg->term == pSyncNode->pRaftStore->currentTerm) {
|
if (pMsg->term == pSyncNode->pRaftStore->currentTerm) {
|
||||||
if (pMsg->seq == SYNC_SNAPSHOT_SEQ_BEGIN) {
|
if (pMsg->seq == SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT) {
|
||||||
// condition 1
|
syncNodeOnSnapshotPre(pSyncNode, pMsg);
|
||||||
// begin, no data
|
|
||||||
snapshotReceiverStart(pReceiver, pMsg);
|
} else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_BEGIN) {
|
||||||
needRsp = true;
|
syncNodeOnSnapshotBegin(pSyncNode, pMsg);
|
||||||
|
|
||||||
} else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_END) {
|
} else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_END) {
|
||||||
// condition 2
|
// condition 2
|
||||||
|
@ -764,7 +869,7 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
snapshotReceiverStop(pReceiver);
|
snapshotReceiverStop(pReceiver);
|
||||||
}
|
}
|
||||||
needRsp = true;
|
bool needRsp = true;
|
||||||
|
|
||||||
// maybe update lastconfig
|
// maybe update lastconfig
|
||||||
if (pMsg->lastConfigIndex >= SYNC_INDEX_BEGIN) {
|
if (pMsg->lastConfigIndex >= SYNC_INDEX_BEGIN) {
|
||||||
|
@ -782,7 +887,7 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
|
||||||
// condition 3
|
// condition 3
|
||||||
// force close
|
// force close
|
||||||
snapshotReceiverForceStop(pReceiver);
|
snapshotReceiverForceStop(pReceiver);
|
||||||
needRsp = false;
|
bool needRsp = false;
|
||||||
|
|
||||||
} else if (pMsg->seq > SYNC_SNAPSHOT_SEQ_BEGIN && pMsg->seq < SYNC_SNAPSHOT_SEQ_END) {
|
} else if (pMsg->seq > SYNC_SNAPSHOT_SEQ_BEGIN && pMsg->seq < SYNC_SNAPSHOT_SEQ_END) {
|
||||||
// condition 4
|
// condition 4
|
||||||
|
@ -790,7 +895,7 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
|
||||||
if (pMsg->seq == pReceiver->ack + 1) {
|
if (pMsg->seq == pReceiver->ack + 1) {
|
||||||
snapshotReceiverGotData(pReceiver, pMsg);
|
snapshotReceiverGotData(pReceiver, pMsg);
|
||||||
}
|
}
|
||||||
needRsp = true;
|
bool needRsp = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// error log
|
// error log
|
||||||
|
@ -805,26 +910,6 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send ack
|
|
||||||
if (needRsp) {
|
|
||||||
// build msg
|
|
||||||
SyncSnapshotRsp *pRspMsg = syncSnapshotRspBuild(pSyncNode->vgId);
|
|
||||||
pRspMsg->srcId = pSyncNode->myRaftId;
|
|
||||||
pRspMsg->destId = pMsg->srcId;
|
|
||||||
pRspMsg->term = pSyncNode->pRaftStore->currentTerm;
|
|
||||||
pRspMsg->lastIndex = pMsg->lastIndex;
|
|
||||||
pRspMsg->lastTerm = pMsg->lastTerm;
|
|
||||||
pRspMsg->ack = pReceiver->ack; // receiver maybe already closed
|
|
||||||
pRspMsg->code = 0;
|
|
||||||
pRspMsg->privateTerm = pReceiver->privateTerm; // receiver maybe already closed
|
|
||||||
|
|
||||||
// send msg
|
|
||||||
SRpcMsg rpcMsg;
|
|
||||||
syncSnapshotRsp2RpcMsg(pRspMsg, &rpcMsg);
|
|
||||||
syncNodeSendMsgById(&(pRspMsg->destId), pSyncNode, &rpcMsg);
|
|
||||||
syncSnapshotRspDestroy(pRspMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// error log
|
// error log
|
||||||
do {
|
do {
|
||||||
|
@ -849,6 +934,52 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t syncNodeOnSnapshotReplyPre(SSyncNode *pSyncNode, SyncSnapshotRsp *pMsg) {
|
||||||
|
// get sender
|
||||||
|
SSyncSnapshotSender *pSender = syncNodeGetSnapshotSender(pSyncNode, &(pMsg->srcId));
|
||||||
|
ASSERT(pSender != NULL);
|
||||||
|
|
||||||
|
SSnapshot snapshot;
|
||||||
|
pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot);
|
||||||
|
|
||||||
|
// prepare <begin, end>
|
||||||
|
pSender->snapshotParam.start = pMsg->snapBeginIndex;
|
||||||
|
pSender->snapshotParam.end = snapshot.lastApplyIndex;
|
||||||
|
|
||||||
|
if (pMsg->snapBeginIndex > snapshot.lastApplyIndex) {
|
||||||
|
syncNodeErrorLog(pSyncNode, "snapshot last index too small");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// start reader
|
||||||
|
int32_t code = pSyncNode->pFsm->FpSnapshotStartRead(pSyncNode->pFsm, &(pSender->snapshotParam), &(pSender->pReader));
|
||||||
|
if (code != 0) {
|
||||||
|
syncNodeErrorLog(pSyncNode, "create snapshot reader error");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// build begin msg
|
||||||
|
SyncSnapshotSend *pSendMsg = syncSnapshotSendBuild(0, pSender->pSyncNode->vgId);
|
||||||
|
pSendMsg->srcId = pSender->pSyncNode->myRaftId;
|
||||||
|
pSendMsg->destId = (pSender->pSyncNode->replicasId)[pSender->replicaIndex];
|
||||||
|
pSendMsg->term = pSender->pSyncNode->pRaftStore->currentTerm;
|
||||||
|
pSendMsg->beginIndex = pSender->snapshotParam.start;
|
||||||
|
pSendMsg->lastIndex = pSender->snapshot.lastApplyIndex;
|
||||||
|
pSendMsg->lastTerm = pSender->snapshot.lastApplyTerm;
|
||||||
|
pSendMsg->lastConfigIndex = pSender->snapshot.lastConfigIndex;
|
||||||
|
pSendMsg->lastConfig = pSender->lastConfig;
|
||||||
|
pSendMsg->startTime = pSender->startTime;
|
||||||
|
pSendMsg->seq = SYNC_SNAPSHOT_SEQ_BEGIN;
|
||||||
|
|
||||||
|
// send msg
|
||||||
|
SRpcMsg rpcMsg;
|
||||||
|
syncSnapshotSend2RpcMsg(pSendMsg, &rpcMsg);
|
||||||
|
syncNodeSendMsgById(&(pSendMsg->destId), pSender->pSyncNode, &rpcMsg);
|
||||||
|
syncSnapshotSendDestroy(pSendMsg);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// sender on message
|
// sender on message
|
||||||
//
|
//
|
||||||
// condition 1 sender receives SYNC_SNAPSHOT_SEQ_END, close sender
|
// condition 1 sender receives SYNC_SNAPSHOT_SEQ_END, close sender
|
||||||
|
@ -857,8 +988,8 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
|
||||||
//
|
//
|
||||||
int32_t syncNodeOnSnapshotReply(SSyncNode *pSyncNode, SyncSnapshotRsp *pMsg) {
|
int32_t syncNodeOnSnapshotReply(SSyncNode *pSyncNode, SyncSnapshotRsp *pMsg) {
|
||||||
// if already drop replica, do not process
|
// if already drop replica, do not process
|
||||||
if (!syncNodeInRaftGroup(pSyncNode, &(pMsg->srcId)) && pSyncNode->state == TAOS_SYNC_STATE_LEADER) {
|
if (!syncNodeInRaftGroup(pSyncNode, &(pMsg->srcId))) {
|
||||||
sError("vgId:%d, recv sync-snapshot-rsp, maybe replica already dropped", pSyncNode->vgId);
|
syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "maybe replica already dropped");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -866,17 +997,26 @@ int32_t syncNodeOnSnapshotReply(SSyncNode *pSyncNode, SyncSnapshotRsp *pMsg) {
|
||||||
SSyncSnapshotSender *pSender = syncNodeGetSnapshotSender(pSyncNode, &(pMsg->srcId));
|
SSyncSnapshotSender *pSender = syncNodeGetSnapshotSender(pSyncNode, &(pMsg->srcId));
|
||||||
ASSERT(pSender != NULL);
|
ASSERT(pSender != NULL);
|
||||||
|
|
||||||
|
if (pMsg->startTime != pSender->startTime) {
|
||||||
|
syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "sender/receiver start time not match");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// state, term, seq/ack
|
// state, term, seq/ack
|
||||||
if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) {
|
if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) {
|
||||||
if (pMsg->term == pSyncNode->pRaftStore->currentTerm) {
|
if (pMsg->term == pSyncNode->pRaftStore->currentTerm) {
|
||||||
// condition 1
|
// prepare <begin, end>, send begin msg
|
||||||
|
if (pMsg->ack == SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT) {
|
||||||
|
syncNodeOnSnapshotReplyPre(pSyncNode, pMsg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// receive ack is finish, close sender
|
// receive ack is finish, close sender
|
||||||
if (pMsg->ack == SYNC_SNAPSHOT_SEQ_END) {
|
if (pMsg->ack == SYNC_SNAPSHOT_SEQ_END) {
|
||||||
snapshotSenderStop(pSender, true);
|
snapshotSenderStop(pSender, true);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// condition 2
|
|
||||||
// send next msg
|
// send next msg
|
||||||
if (pMsg->ack == pSender->seq) {
|
if (pMsg->ack == pSender->seq) {
|
||||||
// update sender ack
|
// update sender ack
|
||||||
|
@ -922,3 +1062,63 @@ int32_t syncNodeOnSnapshotReply(SSyncNode *pSyncNode, SyncSnapshotRsp *pMsg) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t syncNodeOnPreSnapshot(SSyncNode *ths, SyncPreSnapshot *pMsg) {
|
||||||
|
syncLogRecvSyncPreSnapshot(ths, pMsg, "");
|
||||||
|
|
||||||
|
SyncPreSnapshotReply *pMsgReply = syncPreSnapshotReplyBuild(ths->vgId);
|
||||||
|
pMsgReply->srcId = ths->myRaftId;
|
||||||
|
pMsgReply->destId = pMsg->srcId;
|
||||||
|
pMsgReply->term = ths->pRaftStore->currentTerm;
|
||||||
|
|
||||||
|
SSyncLogStoreData *pData = ths->pLogStore->data;
|
||||||
|
SWal *pWal = pData->pWal;
|
||||||
|
|
||||||
|
if (syncNodeIsMnode(ths)) {
|
||||||
|
pMsgReply->snapStart = SYNC_INDEX_BEGIN;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
bool isEmpty = ths->pLogStore->syncLogIsEmpty(ths->pLogStore);
|
||||||
|
int64_t walCommitVer = walGetCommittedVer(pWal);
|
||||||
|
|
||||||
|
if (!isEmpty && ths->commitIndex != walCommitVer) {
|
||||||
|
char logBuf[128];
|
||||||
|
snprintf(logBuf, sizeof(logBuf), "commit not same, wal-commit:%" PRId64 ", commit:%" PRId64 ", ignore",
|
||||||
|
walCommitVer, ths->commitIndex);
|
||||||
|
syncNodeErrorLog(ths, logBuf);
|
||||||
|
|
||||||
|
goto _IGNORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
pMsgReply->snapStart = ths->commitIndex + 1;
|
||||||
|
|
||||||
|
// make local log clean
|
||||||
|
int32_t code = ths->pLogStore->syncLogTruncate(ths->pLogStore, pMsgReply->snapStart);
|
||||||
|
if (code != 0) {
|
||||||
|
syncNodeErrorLog(ths, "truncate wal error");
|
||||||
|
goto _IGNORE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// can not write behind _RESPONSE
|
||||||
|
SRpcMsg rpcMsg;
|
||||||
|
|
||||||
|
_RESPONSE:
|
||||||
|
syncPreSnapshotReply2RpcMsg(pMsgReply, &rpcMsg);
|
||||||
|
syncNodeSendMsgById(&pMsgReply->destId, ths, &rpcMsg);
|
||||||
|
|
||||||
|
syncPreSnapshotReplyDestroy(pMsgReply);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
_IGNORE:
|
||||||
|
syncPreSnapshotReplyDestroy(pMsgReply);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t syncNodeOnPreSnapshotReply(SSyncNode *ths, SyncPreSnapshotReply *pMsg) {
|
||||||
|
syncLogRecvSyncPreSnapshotReply(ths, pMsg, "");
|
||||||
|
|
||||||
|
// start snapshot
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -176,18 +176,6 @@ char* syncUtilRaftId2Str(const SRaftId* p) {
|
||||||
return serialized;
|
return serialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* syncUtilState2String(ESyncState state) {
|
|
||||||
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) {
|
bool syncUtilCanPrint(char c) {
|
||||||
if (c >= 32 && c <= 126) {
|
if (c >= 32 && c <= 126) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -60,6 +60,8 @@ add_executable(syncRaftCfgIndexTest "")
|
||||||
add_executable(syncHeartbeatTest "")
|
add_executable(syncHeartbeatTest "")
|
||||||
add_executable(syncHeartbeatReplyTest "")
|
add_executable(syncHeartbeatReplyTest "")
|
||||||
add_executable(syncLocalCmdTest "")
|
add_executable(syncLocalCmdTest "")
|
||||||
|
add_executable(syncPreSnapshotTest "")
|
||||||
|
add_executable(syncPreSnapshotReplyTest "")
|
||||||
|
|
||||||
|
|
||||||
target_sources(syncTest
|
target_sources(syncTest
|
||||||
|
@ -310,6 +312,14 @@ target_sources(syncLocalCmdTest
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"syncLocalCmdTest.cpp"
|
"syncLocalCmdTest.cpp"
|
||||||
)
|
)
|
||||||
|
target_sources(syncPreSnapshotTest
|
||||||
|
PRIVATE
|
||||||
|
"syncPreSnapshotTest.cpp"
|
||||||
|
)
|
||||||
|
target_sources(syncPreSnapshotReplyTest
|
||||||
|
PRIVATE
|
||||||
|
"syncPreSnapshotReplyTest.cpp"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
target_include_directories(syncTest
|
target_include_directories(syncTest
|
||||||
|
@ -622,6 +632,16 @@ target_include_directories(syncLocalCmdTest
|
||||||
"${TD_SOURCE_DIR}/include/libs/sync"
|
"${TD_SOURCE_DIR}/include/libs/sync"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||||
)
|
)
|
||||||
|
target_include_directories(syncPreSnapshotTest
|
||||||
|
PUBLIC
|
||||||
|
"${TD_SOURCE_DIR}/include/libs/sync"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||||
|
)
|
||||||
|
target_include_directories(syncPreSnapshotReplyTest
|
||||||
|
PUBLIC
|
||||||
|
"${TD_SOURCE_DIR}/include/libs/sync"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
target_link_libraries(syncTest
|
target_link_libraries(syncTest
|
||||||
|
@ -872,6 +892,14 @@ target_link_libraries(syncLocalCmdTest
|
||||||
sync
|
sync
|
||||||
gtest_main
|
gtest_main
|
||||||
)
|
)
|
||||||
|
target_link_libraries(syncPreSnapshotTest
|
||||||
|
sync
|
||||||
|
gtest_main
|
||||||
|
)
|
||||||
|
target_link_libraries(syncPreSnapshotReplyTest
|
||||||
|
sync
|
||||||
|
gtest_main
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
|
@ -47,8 +47,8 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
||||||
snprintf(logBuf, sizeof(logBuf),
|
snprintf(logBuf, sizeof(logBuf),
|
||||||
"==callback== ==CommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s, flag:%" PRIu64
|
"==callback== ==CommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s, flag:%" PRIu64
|
||||||
", term:%" PRIu64 " \n",
|
", term:%" PRIu64 " \n",
|
||||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state),
|
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag,
|
||||||
cbMeta.flag, cbMeta.term);
|
cbMeta.term);
|
||||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||||
} else {
|
} else {
|
||||||
sTrace("==callback== ==CommitCb== do not apply again %" PRId64, cbMeta.index);
|
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) {
|
void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
||||||
char logBuf[256] = {0};
|
char logBuf[256] = {0};
|
||||||
snprintf(
|
snprintf(logBuf, sizeof(logBuf),
|
||||||
logBuf, sizeof(logBuf),
|
"==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64
|
||||||
"==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64 "\n",
|
"\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);
|
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +68,7 @@ void RollBackCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
||||||
char logBuf[256];
|
char logBuf[256];
|
||||||
snprintf(logBuf, sizeof(logBuf),
|
snprintf(logBuf, sizeof(logBuf),
|
||||||
"==callback== ==RollBackCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64 "\n",
|
"==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),
|
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag);
|
||||||
cbMeta.flag);
|
|
||||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,6 +157,7 @@ SSyncFSM* createFsm() {
|
||||||
SSyncFSM* pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(SSyncFSM));
|
SSyncFSM* pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(SSyncFSM));
|
||||||
memset(pFsm, 0, sizeof(*pFsm));
|
memset(pFsm, 0, sizeof(*pFsm));
|
||||||
|
|
||||||
|
#if 0
|
||||||
pFsm->FpCommitCb = CommitCb;
|
pFsm->FpCommitCb = CommitCb;
|
||||||
pFsm->FpPreCommitCb = PreCommitCb;
|
pFsm->FpPreCommitCb = PreCommitCb;
|
||||||
pFsm->FpRollBackCb = RollBackCb;
|
pFsm->FpRollBackCb = RollBackCb;
|
||||||
|
@ -172,6 +172,7 @@ SSyncFSM* createFsm() {
|
||||||
pFsm->FpSnapshotDoWrite = SnapshotDoWrite;
|
pFsm->FpSnapshotDoWrite = SnapshotDoWrite;
|
||||||
|
|
||||||
pFsm->FpReConfigCb = ReConfigCb;
|
pFsm->FpReConfigCb = ReConfigCb;
|
||||||
|
#endif
|
||||||
|
|
||||||
return pFsm;
|
return pFsm;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ void init() {
|
||||||
|
|
||||||
void cleanup() { walCleanUp(); }
|
void cleanup() { walCleanUp(); }
|
||||||
|
|
||||||
void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
void CommitCb(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SFsmCbMeta cbMeta) {
|
||||||
SyncIndex beginIndex = SYNC_INDEX_INVALID;
|
SyncIndex beginIndex = SYNC_INDEX_INVALID;
|
||||||
if (pFsm->FpGetSnapshotInfo != NULL) {
|
if (pFsm->FpGetSnapshotInfo != NULL) {
|
||||||
SSnapshot snapshot;
|
SSnapshot snapshot;
|
||||||
|
@ -45,33 +45,31 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
||||||
char logBuf[256] = {0};
|
char logBuf[256] = {0};
|
||||||
snprintf(logBuf, sizeof(logBuf),
|
snprintf(logBuf, sizeof(logBuf),
|
||||||
"==callback== ==CommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64 "\n",
|
"==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),
|
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag);
|
||||||
cbMeta.flag);
|
|
||||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||||
} else {
|
} else {
|
||||||
sTrace("==callback== ==CommitCb== do not apply again %" PRId64, cbMeta.index);
|
sTrace("==callback== ==CommitCb== do not apply again %" PRId64, cbMeta.index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
void PreCommitCb(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
||||||
char logBuf[256] = {0};
|
char logBuf[256] = {0};
|
||||||
snprintf(
|
snprintf(logBuf, sizeof(logBuf),
|
||||||
logBuf, sizeof(logBuf),
|
"==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64
|
||||||
"==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64 "\n",
|
"\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);
|
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RollBackCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
void RollBackCb(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
||||||
char logBuf[256];
|
char logBuf[256];
|
||||||
snprintf(logBuf, sizeof(logBuf),
|
snprintf(logBuf, sizeof(logBuf),
|
||||||
"==callback== ==RollBackCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64 "\n",
|
"==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),
|
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag);
|
||||||
cbMeta.flag);
|
|
||||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t GetSnapshotCb(struct SSyncFSM* pFsm, SSnapshot* pSnapshot) {
|
int32_t GetSnapshotCb(const struct SSyncFSM* pFsm, SSnapshot* pSnapshot) {
|
||||||
pSnapshot->data = NULL;
|
pSnapshot->data = NULL;
|
||||||
pSnapshot->lastApplyIndex = gSnapshotLastApplyIndex;
|
pSnapshot->lastApplyIndex = gSnapshotLastApplyIndex;
|
||||||
pSnapshot->lastApplyTerm = 100;
|
pSnapshot->lastApplyTerm = 100;
|
||||||
|
@ -89,6 +87,7 @@ SSyncFSM* createFsm() {
|
||||||
SSyncFSM* pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(SSyncFSM));
|
SSyncFSM* pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(SSyncFSM));
|
||||||
memset(pFsm, 0, sizeof(*pFsm));
|
memset(pFsm, 0, sizeof(*pFsm));
|
||||||
|
|
||||||
|
#if 0
|
||||||
pFsm->FpCommitCb = CommitCb;
|
pFsm->FpCommitCb = CommitCb;
|
||||||
pFsm->FpPreCommitCb = PreCommitCb;
|
pFsm->FpPreCommitCb = PreCommitCb;
|
||||||
pFsm->FpRollBackCb = RollBackCb;
|
pFsm->FpRollBackCb = RollBackCb;
|
||||||
|
@ -97,6 +96,7 @@ SSyncFSM* createFsm() {
|
||||||
pFsm->FpRestoreFinishCb = RestoreFinishCb;
|
pFsm->FpRestoreFinishCb = RestoreFinishCb;
|
||||||
|
|
||||||
pFsm->FpReConfigCb = ReConfigCb;
|
pFsm->FpReConfigCb = ReConfigCb;
|
||||||
|
#endif
|
||||||
|
|
||||||
return pFsm;
|
return pFsm;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,12 @@ int main() {
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
|
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 5; ++i) {
|
||||||
ret = syncEnvStartTimer();
|
//ret = syncEnvStartTimer();
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
|
|
||||||
taosMsleep(5000);
|
taosMsleep(5000);
|
||||||
|
|
||||||
ret = syncEnvStopTimer();
|
//ret = syncEnvStopTimer();
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
|
|
||||||
taosMsleep(5000);
|
taosMsleep(5000);
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "syncIO.h"
|
||||||
|
#include "syncInt.h"
|
||||||
|
#include "syncMessage.h"
|
||||||
|
#include "syncUtil.h"
|
||||||
|
|
||||||
|
void logTest() {
|
||||||
|
sTrace("--- sync log test: trace");
|
||||||
|
sDebug("--- sync log test: debug");
|
||||||
|
sInfo("--- sync log test: info");
|
||||||
|
sWarn("--- sync log test: warn");
|
||||||
|
sError("--- sync log test: error");
|
||||||
|
sFatal("--- sync log test: fatal");
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncPreSnapshotReply *createMsg() {
|
||||||
|
SyncPreSnapshotReply *pMsg = syncPreSnapshotReplyBuild(789);
|
||||||
|
pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 1234);
|
||||||
|
pMsg->srcId.vgId = 100;
|
||||||
|
pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 5678);
|
||||||
|
pMsg->destId.vgId = 100;
|
||||||
|
pMsg->term = 9527;
|
||||||
|
pMsg->snapStart = 12306;
|
||||||
|
return pMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test1() {
|
||||||
|
SyncPreSnapshotReply *pMsg = createMsg();
|
||||||
|
syncPreSnapshotReplyLog2((char *)"test1:", pMsg);
|
||||||
|
syncPreSnapshotReplyDestroy(pMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test2() {
|
||||||
|
SyncPreSnapshotReply *pMsg = createMsg();
|
||||||
|
uint32_t len = pMsg->bytes;
|
||||||
|
char * serialized = (char *)taosMemoryMalloc(len);
|
||||||
|
syncPreSnapshotReplySerialize(pMsg, serialized, len);
|
||||||
|
SyncPreSnapshotReply *pMsg2 = syncPreSnapshotReplyBuild(789);
|
||||||
|
syncPreSnapshotReplyDeserialize(serialized, len, pMsg2);
|
||||||
|
syncPreSnapshotReplyLog2((char *)"test2: syncPreSnapshotReplySerialize -> syncPreSnapshotReplyDeserialize ", pMsg2);
|
||||||
|
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
syncPreSnapshotReplyDestroy(pMsg);
|
||||||
|
syncPreSnapshotReplyDestroy(pMsg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test3() {
|
||||||
|
SyncPreSnapshotReply *pMsg = createMsg();
|
||||||
|
uint32_t len;
|
||||||
|
char * serialized = syncPreSnapshotReplySerialize2(pMsg, &len);
|
||||||
|
SyncPreSnapshotReply *pMsg2 = syncPreSnapshotReplyDeserialize2(serialized, len);
|
||||||
|
syncPreSnapshotReplyLog2((char *)"test3: syncPreSnapshotReplySerialize2 -> syncPreSnapshotReplyDeserialize2 ", pMsg2);
|
||||||
|
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
syncPreSnapshotReplyDestroy(pMsg);
|
||||||
|
syncPreSnapshotReplyDestroy(pMsg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test4() {
|
||||||
|
SyncPreSnapshotReply *pMsg = createMsg();
|
||||||
|
SRpcMsg rpcMsg;
|
||||||
|
syncPreSnapshotReply2RpcMsg(pMsg, &rpcMsg);
|
||||||
|
SyncPreSnapshotReply *pMsg2 = (SyncPreSnapshotReply *)taosMemoryMalloc(rpcMsg.contLen);
|
||||||
|
syncPreSnapshotReplyFromRpcMsg(&rpcMsg, pMsg2);
|
||||||
|
syncPreSnapshotReplyLog2((char *)"test4: syncPreSnapshotReply2RpcMsg -> syncPreSnapshotReplyFromRpcMsg ", pMsg2);
|
||||||
|
|
||||||
|
rpcFreeCont(rpcMsg.pCont);
|
||||||
|
syncPreSnapshotReplyDestroy(pMsg);
|
||||||
|
syncPreSnapshotReplyDestroy(pMsg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test5() {
|
||||||
|
SyncPreSnapshotReply *pMsg = createMsg();
|
||||||
|
SRpcMsg rpcMsg;
|
||||||
|
syncPreSnapshotReply2RpcMsg(pMsg, &rpcMsg);
|
||||||
|
SyncPreSnapshotReply *pMsg2 = syncPreSnapshotReplyFromRpcMsg2(&rpcMsg);
|
||||||
|
syncPreSnapshotReplyLog2((char *)"test5: syncPreSnapshotReply2RpcMsg -> syncPreSnapshotReplyFromRpcMsg2 ", pMsg2);
|
||||||
|
|
||||||
|
rpcFreeCont(rpcMsg.pCont);
|
||||||
|
syncPreSnapshotReplyDestroy(pMsg);
|
||||||
|
syncPreSnapshotReplyDestroy(pMsg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
tsAsyncLog = 0;
|
||||||
|
sDebugFlag = DEBUG_TRACE + DEBUG_SCREEN + DEBUG_FILE;
|
||||||
|
gRaftDetailLog = true;
|
||||||
|
logTest();
|
||||||
|
|
||||||
|
test1();
|
||||||
|
test2();
|
||||||
|
test3();
|
||||||
|
test4();
|
||||||
|
test5();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "syncIO.h"
|
||||||
|
#include "syncInt.h"
|
||||||
|
#include "syncMessage.h"
|
||||||
|
#include "syncUtil.h"
|
||||||
|
|
||||||
|
void logTest() {
|
||||||
|
sTrace("--- sync log test: trace");
|
||||||
|
sDebug("--- sync log test: debug");
|
||||||
|
sInfo("--- sync log test: info");
|
||||||
|
sWarn("--- sync log test: warn");
|
||||||
|
sError("--- sync log test: error");
|
||||||
|
sFatal("--- sync log test: fatal");
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncPreSnapshot *createMsg() {
|
||||||
|
SyncPreSnapshot *pMsg = syncPreSnapshotBuild(789);
|
||||||
|
pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 1234);
|
||||||
|
pMsg->srcId.vgId = 100;
|
||||||
|
pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 5678);
|
||||||
|
pMsg->destId.vgId = 100;
|
||||||
|
pMsg->term = 9527;
|
||||||
|
return pMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test1() {
|
||||||
|
SyncPreSnapshot *pMsg = createMsg();
|
||||||
|
syncPreSnapshotLog2((char *)"test1:", pMsg);
|
||||||
|
syncPreSnapshotDestroy(pMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test2() {
|
||||||
|
SyncPreSnapshot *pMsg = createMsg();
|
||||||
|
uint32_t len = pMsg->bytes;
|
||||||
|
char * serialized = (char *)taosMemoryMalloc(len);
|
||||||
|
syncPreSnapshotSerialize(pMsg, serialized, len);
|
||||||
|
SyncPreSnapshot *pMsg2 = syncPreSnapshotBuild(789);
|
||||||
|
syncPreSnapshotDeserialize(serialized, len, pMsg2);
|
||||||
|
syncPreSnapshotLog2((char *)"test2: syncPreSnapshotSerialize -> syncPreSnapshotDeserialize ", pMsg2);
|
||||||
|
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
syncPreSnapshotDestroy(pMsg);
|
||||||
|
syncPreSnapshotDestroy(pMsg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test3() {
|
||||||
|
SyncPreSnapshot *pMsg = createMsg();
|
||||||
|
uint32_t len;
|
||||||
|
char * serialized = syncPreSnapshotSerialize2(pMsg, &len);
|
||||||
|
SyncPreSnapshot *pMsg2 = syncPreSnapshotDeserialize2(serialized, len);
|
||||||
|
syncPreSnapshotLog2((char *)"test3: syncPreSnapshotSerialize2 -> syncPreSnapshotDeserialize2 ", pMsg2);
|
||||||
|
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
syncPreSnapshotDestroy(pMsg);
|
||||||
|
syncPreSnapshotDestroy(pMsg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test4() {
|
||||||
|
SyncPreSnapshot *pMsg = createMsg();
|
||||||
|
SRpcMsg rpcMsg;
|
||||||
|
syncPreSnapshot2RpcMsg(pMsg, &rpcMsg);
|
||||||
|
SyncPreSnapshot *pMsg2 = (SyncPreSnapshot *)taosMemoryMalloc(rpcMsg.contLen);
|
||||||
|
syncPreSnapshotFromRpcMsg(&rpcMsg, pMsg2);
|
||||||
|
syncPreSnapshotLog2((char *)"test4: syncPreSnapshot2RpcMsg -> syncPreSnapshotFromRpcMsg ", pMsg2);
|
||||||
|
|
||||||
|
rpcFreeCont(rpcMsg.pCont);
|
||||||
|
syncPreSnapshotDestroy(pMsg);
|
||||||
|
syncPreSnapshotDestroy(pMsg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test5() {
|
||||||
|
SyncPreSnapshot *pMsg = createMsg();
|
||||||
|
SRpcMsg rpcMsg;
|
||||||
|
syncPreSnapshot2RpcMsg(pMsg, &rpcMsg);
|
||||||
|
SyncPreSnapshot *pMsg2 = syncPreSnapshotFromRpcMsg2(&rpcMsg);
|
||||||
|
syncPreSnapshotLog2((char *)"test5: syncPreSnapshot2RpcMsg -> syncPreSnapshotFromRpcMsg2 ", pMsg2);
|
||||||
|
|
||||||
|
rpcFreeCont(rpcMsg.pCont);
|
||||||
|
syncPreSnapshotDestroy(pMsg);
|
||||||
|
syncPreSnapshotDestroy(pMsg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
tsAsyncLog = 0;
|
||||||
|
sDebugFlag = DEBUG_TRACE + DEBUG_SCREEN + DEBUG_FILE;
|
||||||
|
gRaftDetailLog = true;
|
||||||
|
logTest();
|
||||||
|
|
||||||
|
test1();
|
||||||
|
test2();
|
||||||
|
test3();
|
||||||
|
test4();
|
||||||
|
test5();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -25,7 +25,7 @@ const char* pWalPath = "./syncLogStoreTest_wal";
|
||||||
SyncIndex gSnapshotLastApplyIndex;
|
SyncIndex gSnapshotLastApplyIndex;
|
||||||
SyncIndex gSnapshotLastApplyTerm;
|
SyncIndex gSnapshotLastApplyTerm;
|
||||||
|
|
||||||
int32_t GetSnapshotCb(struct SSyncFSM* pFsm, SSnapshot* pSnapshot) {
|
int32_t GetSnapshotCb(const struct SSyncFSM* pFsm, SSnapshot* pSnapshot) {
|
||||||
pSnapshot->data = NULL;
|
pSnapshot->data = NULL;
|
||||||
pSnapshot->lastApplyIndex = gSnapshotLastApplyIndex;
|
pSnapshot->lastApplyIndex = gSnapshotLastApplyIndex;
|
||||||
pSnapshot->lastApplyTerm = gSnapshotLastApplyTerm;
|
pSnapshot->lastApplyTerm = gSnapshotLastApplyTerm;
|
||||||
|
|
|
@ -27,7 +27,7 @@ const char* pWalPath = "./syncLogStoreTest_wal";
|
||||||
SyncIndex gSnapshotLastApplyIndex;
|
SyncIndex gSnapshotLastApplyIndex;
|
||||||
SyncIndex gSnapshotLastApplyTerm;
|
SyncIndex gSnapshotLastApplyTerm;
|
||||||
|
|
||||||
int32_t GetSnapshotCb(struct SSyncFSM* pFsm, SSnapshot* pSnapshot) {
|
int32_t GetSnapshotCb(const struct SSyncFSM* pFsm, SSnapshot* pSnapshot) {
|
||||||
pSnapshot->data = NULL;
|
pSnapshot->data = NULL;
|
||||||
pSnapshot->lastApplyIndex = gSnapshotLastApplyIndex;
|
pSnapshot->lastApplyIndex = gSnapshotLastApplyIndex;
|
||||||
pSnapshot->lastApplyTerm = gSnapshotLastApplyTerm;
|
pSnapshot->lastApplyTerm = gSnapshotLastApplyTerm;
|
||||||
|
|
|
@ -42,7 +42,7 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
||||||
char logBuf[256];
|
char logBuf[256];
|
||||||
snprintf(logBuf, sizeof(logBuf),
|
snprintf(logBuf, sizeof(logBuf),
|
||||||
"==callback== ==CommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
"==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);
|
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||||
} else {
|
} else {
|
||||||
sTrace("==callback== ==CommitCb== do not apply again %" PRId64, cbMeta.index);
|
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];
|
char logBuf[256];
|
||||||
snprintf(logBuf, sizeof(logBuf),
|
snprintf(logBuf, sizeof(logBuf),
|
||||||
"==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
"==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);
|
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ void RollBackCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
||||||
char logBuf[256];
|
char logBuf[256];
|
||||||
snprintf(logBuf, sizeof(logBuf),
|
snprintf(logBuf, sizeof(logBuf),
|
||||||
"==callback== ==RollBackCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
"==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);
|
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,10 +74,14 @@ int32_t GetSnapshotCb(struct SSyncFSM* pFsm, SSnapshot* pSnapshot) {
|
||||||
|
|
||||||
SSyncFSM* createFsm() {
|
SSyncFSM* createFsm() {
|
||||||
SSyncFSM* pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(SSyncFSM));
|
SSyncFSM* pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(SSyncFSM));
|
||||||
|
|
||||||
|
#if 0
|
||||||
pFsm->FpCommitCb = CommitCb;
|
pFsm->FpCommitCb = CommitCb;
|
||||||
pFsm->FpPreCommitCb = PreCommitCb;
|
pFsm->FpPreCommitCb = PreCommitCb;
|
||||||
pFsm->FpRollBackCb = RollBackCb;
|
pFsm->FpRollBackCb = RollBackCb;
|
||||||
pFsm->FpGetSnapshotInfo = GetSnapshotCb;
|
pFsm->FpGetSnapshotInfo = GetSnapshotCb;
|
||||||
|
#endif
|
||||||
|
|
||||||
return pFsm;
|
return pFsm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,12 @@ SSyncSnapshotReceiver* createReceiver() {
|
||||||
SSyncNode* pSyncNode = (SSyncNode*)taosMemoryMalloc(sizeof(*pSyncNode));
|
SSyncNode* pSyncNode = (SSyncNode*)taosMemoryMalloc(sizeof(*pSyncNode));
|
||||||
pSyncNode->pRaftStore = (SRaftStore*)taosMemoryMalloc(sizeof(*(pSyncNode->pRaftStore)));
|
pSyncNode->pRaftStore = (SRaftStore*)taosMemoryMalloc(sizeof(*(pSyncNode->pRaftStore)));
|
||||||
pSyncNode->pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(*(pSyncNode->pFsm)));
|
pSyncNode->pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(*(pSyncNode->pFsm)));
|
||||||
|
|
||||||
|
#if 0
|
||||||
pSyncNode->pFsm->FpSnapshotStartWrite = SnapshotStartWrite;
|
pSyncNode->pFsm->FpSnapshotStartWrite = SnapshotStartWrite;
|
||||||
pSyncNode->pFsm->FpSnapshotStopWrite = SnapshotStopWrite;
|
pSyncNode->pFsm->FpSnapshotStopWrite = SnapshotStopWrite;
|
||||||
pSyncNode->pFsm->FpSnapshotDoWrite = SnapshotDoWrite;
|
pSyncNode->pFsm->FpSnapshotDoWrite = SnapshotDoWrite;
|
||||||
|
#endif
|
||||||
|
|
||||||
SRaftId id;
|
SRaftId id;
|
||||||
id.addr = syncUtilAddr2U64("1.2.3.4", 99);
|
id.addr = syncUtilAddr2U64("1.2.3.4", 99);
|
||||||
|
@ -50,7 +53,6 @@ SSyncSnapshotReceiver* createReceiver() {
|
||||||
pReceiver->ack = 20;
|
pReceiver->ack = 20;
|
||||||
pReceiver->pWriter = (void*)0x11;
|
pReceiver->pWriter = (void*)0x11;
|
||||||
pReceiver->term = 66;
|
pReceiver->term = 66;
|
||||||
pReceiver->privateTerm = 99;
|
|
||||||
|
|
||||||
return pReceiver;
|
return pReceiver;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ SyncSnapshotRsp *createMsg() {
|
||||||
pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 5678);
|
pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 5678);
|
||||||
pMsg->destId.vgId = 100;
|
pMsg->destId.vgId = 100;
|
||||||
pMsg->term = 11;
|
pMsg->term = 11;
|
||||||
pMsg->privateTerm = 99;
|
pMsg->startTime = 99;
|
||||||
pMsg->lastIndex = 22;
|
pMsg->lastIndex = 22;
|
||||||
pMsg->lastTerm = 33;
|
pMsg->lastTerm = 33;
|
||||||
pMsg->ack = 44;
|
pMsg->ack = 44;
|
||||||
|
|
|
@ -21,7 +21,6 @@ SyncSnapshotSend *createMsg() {
|
||||||
pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 5678);
|
pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 5678);
|
||||||
pMsg->destId.vgId = 100;
|
pMsg->destId.vgId = 100;
|
||||||
pMsg->term = 11;
|
pMsg->term = 11;
|
||||||
pMsg->privateTerm = 99;
|
|
||||||
pMsg->lastIndex = 22;
|
pMsg->lastIndex = 22;
|
||||||
pMsg->lastTerm = 33;
|
pMsg->lastTerm = 33;
|
||||||
|
|
||||||
|
|
|
@ -37,10 +37,13 @@ SSyncSnapshotSender* createSender() {
|
||||||
SSyncNode* pSyncNode = (SSyncNode*)taosMemoryMalloc(sizeof(*pSyncNode));
|
SSyncNode* pSyncNode = (SSyncNode*)taosMemoryMalloc(sizeof(*pSyncNode));
|
||||||
pSyncNode->pRaftStore = (SRaftStore*)taosMemoryMalloc(sizeof(*(pSyncNode->pRaftStore)));
|
pSyncNode->pRaftStore = (SRaftStore*)taosMemoryMalloc(sizeof(*(pSyncNode->pRaftStore)));
|
||||||
pSyncNode->pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(*(pSyncNode->pFsm)));
|
pSyncNode->pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(*(pSyncNode->pFsm)));
|
||||||
|
|
||||||
|
#if 0
|
||||||
pSyncNode->pFsm->FpSnapshotStartRead = SnapshotStartRead;
|
pSyncNode->pFsm->FpSnapshotStartRead = SnapshotStartRead;
|
||||||
pSyncNode->pFsm->FpSnapshotStopRead = SnapshotStopRead;
|
pSyncNode->pFsm->FpSnapshotStopRead = SnapshotStopRead;
|
||||||
pSyncNode->pFsm->FpSnapshotDoRead = SnapshotDoRead;
|
pSyncNode->pFsm->FpSnapshotDoRead = SnapshotDoRead;
|
||||||
pSyncNode->pFsm->FpGetSnapshotInfo = GetSnapshot;
|
pSyncNode->pFsm->FpGetSnapshotInfo = GetSnapshot;
|
||||||
|
#endif
|
||||||
|
|
||||||
SSyncSnapshotSender* pSender = snapshotSenderCreate(pSyncNode, 2);
|
SSyncSnapshotSender* pSender = snapshotSenderCreate(pSyncNode, 2);
|
||||||
pSender->start = true;
|
pSender->start = true;
|
||||||
|
@ -55,7 +58,8 @@ SSyncSnapshotSender* createSender() {
|
||||||
pSender->snapshot.lastApplyTerm = 88;
|
pSender->snapshot.lastApplyTerm = 88;
|
||||||
pSender->sendingMS = 77;
|
pSender->sendingMS = 77;
|
||||||
pSender->term = 66;
|
pSender->term = 66;
|
||||||
pSender->privateTerm = 99;
|
|
||||||
|
//pSender->privateTerm = 99;
|
||||||
|
|
||||||
return pSender;
|
return pSender;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ SyncIndex snapshotLastApplyIndex = SYNC_INDEX_INVALID;
|
||||||
const char *pDir = "./syncSnapshotTest";
|
const char *pDir = "./syncSnapshotTest";
|
||||||
const char *pWalDir = "./syncSnapshotTest_wal";
|
const char *pWalDir = "./syncSnapshotTest_wal";
|
||||||
|
|
||||||
void CommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
void CommitCb(const struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
||||||
SyncIndex beginIndex = SYNC_INDEX_INVALID;
|
SyncIndex beginIndex = SYNC_INDEX_INVALID;
|
||||||
if (pFsm->FpGetSnapshotInfo != NULL) {
|
if (pFsm->FpGetSnapshotInfo != NULL) {
|
||||||
SSnapshot snapshot;
|
SSnapshot snapshot;
|
||||||
|
@ -45,30 +45,30 @@ void CommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
||||||
char logBuf[256];
|
char logBuf[256];
|
||||||
snprintf(logBuf, sizeof(logBuf),
|
snprintf(logBuf, sizeof(logBuf),
|
||||||
"==callback== ==CommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
"==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);
|
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
||||||
} else {
|
} else {
|
||||||
sTrace("==callback== ==CommitCb== do not apply again %" PRId64, cbMeta.index);
|
sTrace("==callback== ==CommitCb== do not apply again %" PRId64, cbMeta.index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreCommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
void PreCommitCb(const struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
||||||
char logBuf[256];
|
char logBuf[256];
|
||||||
snprintf(logBuf, sizeof(logBuf),
|
snprintf(logBuf, sizeof(logBuf),
|
||||||
"==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
"==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);
|
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RollBackCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
void RollBackCb(const struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
||||||
char logBuf[256];
|
char logBuf[256];
|
||||||
snprintf(logBuf, sizeof(logBuf),
|
snprintf(logBuf, sizeof(logBuf),
|
||||||
"==callback== ==RollBackCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
"==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);
|
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t GetSnapshotCb(struct SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
int32_t GetSnapshotCb(const struct SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
||||||
pSnapshot->data = NULL;
|
pSnapshot->data = NULL;
|
||||||
pSnapshot->lastApplyIndex = snapshotLastApplyIndex;
|
pSnapshot->lastApplyIndex = snapshotLastApplyIndex;
|
||||||
pSnapshot->lastApplyTerm = 100;
|
pSnapshot->lastApplyTerm = 100;
|
||||||
|
@ -78,10 +78,14 @@ int32_t GetSnapshotCb(struct SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
||||||
void initFsm() {
|
void initFsm() {
|
||||||
pFsm = (SSyncFSM *)taosMemoryMalloc(sizeof(SSyncFSM));
|
pFsm = (SSyncFSM *)taosMemoryMalloc(sizeof(SSyncFSM));
|
||||||
memset(pFsm, 0, sizeof(*pFsm));
|
memset(pFsm, 0, sizeof(*pFsm));
|
||||||
|
|
||||||
|
#if 0
|
||||||
pFsm->FpCommitCb = CommitCb;
|
pFsm->FpCommitCb = CommitCb;
|
||||||
pFsm->FpPreCommitCb = PreCommitCb;
|
pFsm->FpPreCommitCb = PreCommitCb;
|
||||||
pFsm->FpRollBackCb = RollBackCb;
|
pFsm->FpRollBackCb = RollBackCb;
|
||||||
pFsm->FpGetSnapshotInfo = GetSnapshotCb;
|
pFsm->FpGetSnapshotInfo = GetSnapshotCb;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SSyncNode *syncNodeInit() {
|
SSyncNode *syncNodeInit() {
|
||||||
|
|
|
@ -44,8 +44,8 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
||||||
", term:%" PRIu64
|
", term:%" PRIu64
|
||||||
" "
|
" "
|
||||||
"currentTerm:%" PRIu64 " \n",
|
"currentTerm:%" PRIu64 " \n",
|
||||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state),
|
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag,
|
||||||
cbMeta.flag, cbMeta.term, cbMeta.currentTerm);
|
cbMeta.term, cbMeta.currentTerm);
|
||||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,8 +56,8 @@ void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta)
|
||||||
", term:%" PRIu64
|
", term:%" PRIu64
|
||||||
" "
|
" "
|
||||||
"currentTerm:%" PRIu64 " \n",
|
"currentTerm:%" PRIu64 " \n",
|
||||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state),
|
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag,
|
||||||
cbMeta.flag, cbMeta.term, cbMeta.currentTerm);
|
cbMeta.term, cbMeta.currentTerm);
|
||||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +68,8 @@ void RollBackCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
|
||||||
", term:%" PRIu64
|
", term:%" PRIu64
|
||||||
" "
|
" "
|
||||||
"currentTerm:%" PRIu64 " \n",
|
"currentTerm:%" PRIu64 " \n",
|
||||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state),
|
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag,
|
||||||
cbMeta.flag, cbMeta.term, cbMeta.currentTerm);
|
cbMeta.term, cbMeta.currentTerm);
|
||||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
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
|
", isWeak:%d, code:%d, state:%d %s, flag:%" PRIu64 ", term:%" PRIu64
|
||||||
" "
|
" "
|
||||||
"currentTerm:%" PRIu64 " \n",
|
"currentTerm:%" PRIu64 " \n",
|
||||||
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state),
|
pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncStr(cbMeta.state), cbMeta.flag,
|
||||||
cbMeta.flag, cbMeta.term, cbMeta.currentTerm);
|
cbMeta.term, cbMeta.currentTerm);
|
||||||
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +177,7 @@ SSyncFSM* createFsm() {
|
||||||
SSyncFSM* pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(SSyncFSM));
|
SSyncFSM* pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(SSyncFSM));
|
||||||
memset(pFsm, 0, sizeof(*pFsm));
|
memset(pFsm, 0, sizeof(*pFsm));
|
||||||
|
|
||||||
|
#if 0
|
||||||
pFsm->FpCommitCb = CommitCb;
|
pFsm->FpCommitCb = CommitCb;
|
||||||
pFsm->FpPreCommitCb = PreCommitCb;
|
pFsm->FpPreCommitCb = PreCommitCb;
|
||||||
pFsm->FpRollBackCb = RollBackCb;
|
pFsm->FpRollBackCb = RollBackCb;
|
||||||
|
@ -193,6 +194,7 @@ SSyncFSM* createFsm() {
|
||||||
pFsm->FpSnapshotDoWrite = SnapshotDoWrite;
|
pFsm->FpSnapshotDoWrite = SnapshotDoWrite;
|
||||||
|
|
||||||
pFsm->FpLeaderTransferCb = LeaderTransferCb;
|
pFsm->FpLeaderTransferCb = LeaderTransferCb;
|
||||||
|
#endif
|
||||||
|
|
||||||
return pFsm;
|
return pFsm;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ void CommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
||||||
char logBuf[256];
|
char logBuf[256];
|
||||||
snprintf(logBuf, sizeof(logBuf),
|
snprintf(logBuf, sizeof(logBuf),
|
||||||
"==callback== ==CommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
"==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);
|
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ void PreCommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta)
|
||||||
char logBuf[256];
|
char logBuf[256];
|
||||||
snprintf(logBuf, sizeof(logBuf),
|
snprintf(logBuf, sizeof(logBuf),
|
||||||
"==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
"==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);
|
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,15 +51,19 @@ void RollBackCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
||||||
char logBuf[256];
|
char logBuf[256];
|
||||||
snprintf(logBuf, sizeof(logBuf),
|
snprintf(logBuf, sizeof(logBuf),
|
||||||
"==callback== ==RollBackCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm,
|
"==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);
|
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initFsm() {
|
void initFsm() {
|
||||||
pFsm = (SSyncFSM *)taosMemoryMalloc(sizeof(SSyncFSM));
|
pFsm = (SSyncFSM *)taosMemoryMalloc(sizeof(SSyncFSM));
|
||||||
|
|
||||||
|
#if 0
|
||||||
pFsm->FpCommitCb = CommitCb;
|
pFsm->FpCommitCb = CommitCb;
|
||||||
pFsm->FpPreCommitCb = PreCommitCb;
|
pFsm->FpPreCommitCb = PreCommitCb;
|
||||||
pFsm->FpRollBackCb = RollBackCb;
|
pFsm->FpRollBackCb = RollBackCb;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SSyncNode *syncNodeInit() {
|
SSyncNode *syncNodeInit() {
|
||||||
|
|
|
@ -1715,16 +1715,20 @@ int tdbBtreeNext(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen) {
|
||||||
memcpy(pKey, cd.pKey, cd.kLen);
|
memcpy(pKey, cd.pKey, cd.kLen);
|
||||||
|
|
||||||
if (ppVal) {
|
if (ppVal) {
|
||||||
// TODO: vLen may be zero
|
if (cd.vLen > 0) {
|
||||||
pVal = tdbRealloc(*ppVal, cd.vLen);
|
pVal = tdbRealloc(*ppVal, cd.vLen);
|
||||||
if (pVal == NULL) {
|
if (pVal == NULL) {
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(pVal, cd.pVal, cd.vLen);
|
||||||
|
} else {
|
||||||
|
pVal = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ppVal = pVal;
|
*ppVal = pVal;
|
||||||
*vLen = cd.vLen;
|
*vLen = cd.vLen;
|
||||||
memcpy(pVal, cd.pVal, cd.vLen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = tdbBtcMoveToNext(pBtc);
|
ret = tdbBtcMoveToNext(pBtc);
|
||||||
|
|
|
@ -718,8 +718,10 @@ static void cliSendCb(uv_write_t* req, int status) {
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
tTrace("%s conn %p data already was written out", CONN_GET_INST_LABEL(pConn), pConn);
|
tTrace("%s conn %p data already was written out", CONN_GET_INST_LABEL(pConn), pConn);
|
||||||
} else {
|
} else {
|
||||||
tError("%s conn %p failed to write:%s", CONN_GET_INST_LABEL(pConn), pConn, uv_err_name(status));
|
if (!uv_is_closing((uv_handle_t*)&pConn->stream)) {
|
||||||
cliHandleExcept(pConn);
|
tError("%s conn %p failed to write:%s", CONN_GET_INST_LABEL(pConn), pConn, uv_err_name(status));
|
||||||
|
cliHandleExcept(pConn);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cliHandleNoResp(pConn) == true) {
|
if (cliHandleNoResp(pConn) == true) {
|
||||||
|
|
|
@ -127,7 +127,7 @@ static void uvFreeCb(uv_handle_t* handle);
|
||||||
|
|
||||||
static FORCE_INLINE void uvStartSendRespImpl(SSvrMsg* smsg);
|
static FORCE_INLINE void uvStartSendRespImpl(SSvrMsg* smsg);
|
||||||
|
|
||||||
static void uvPrepareSendData(SSvrMsg* msg, uv_buf_t* wb);
|
static int uvPrepareSendData(SSvrMsg* msg, uv_buf_t* wb);
|
||||||
static void uvStartSendResp(SSvrMsg* msg);
|
static void uvStartSendResp(SSvrMsg* msg);
|
||||||
|
|
||||||
static void uvNotifyLinkBrokenToApp(SSvrConn* conn);
|
static void uvNotifyLinkBrokenToApp(SSvrConn* conn);
|
||||||
|
@ -363,9 +363,11 @@ void uvOnSendCb(uv_write_t* req, int status) {
|
||||||
}
|
}
|
||||||
transUnrefSrvHandle(conn);
|
transUnrefSrvHandle(conn);
|
||||||
} else {
|
} else {
|
||||||
tError("conn %p failed to write data, %s", conn, uv_err_name(status));
|
if (!uv_is_closing((uv_handle_t*)(conn->pTcp))) {
|
||||||
conn->broken = true;
|
tError("conn %p failed to write data, %s", conn, uv_err_name(status));
|
||||||
transUnrefSrvHandle(conn);
|
conn->broken = true;
|
||||||
|
transUnrefSrvHandle(conn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void uvOnPipeWriteCb(uv_write_t* req, int status) {
|
static void uvOnPipeWriteCb(uv_write_t* req, int status) {
|
||||||
|
@ -382,7 +384,7 @@ static void uvOnPipeWriteCb(uv_write_t* req, int status) {
|
||||||
taosMemoryFree(req);
|
taosMemoryFree(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) {
|
static int uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) {
|
||||||
SSvrConn* pConn = smsg->pConn;
|
SSvrConn* pConn = smsg->pConn;
|
||||||
STransMsg* pMsg = &smsg->msg;
|
STransMsg* pMsg = &smsg->msg;
|
||||||
if (pMsg->pCont == 0) {
|
if (pMsg->pCont == 0) {
|
||||||
|
@ -395,6 +397,13 @@ static void uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) {
|
||||||
pHead->hasEpSet = pMsg->info.hasEpSet;
|
pHead->hasEpSet = pMsg->info.hasEpSet;
|
||||||
pHead->magicNum = htonl(TRANS_MAGIC_NUM);
|
pHead->magicNum = htonl(TRANS_MAGIC_NUM);
|
||||||
|
|
||||||
|
// handle invalid drop_task resp, TD-20098
|
||||||
|
if (pMsg->msgType == TDMT_SCH_DROP_TASK && pMsg->code == TSDB_CODE_VND_INVALID_VGROUP_ID) {
|
||||||
|
transQueuePop(&pConn->srvMsgs);
|
||||||
|
destroySmsg(smsg);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (pConn->status == ConnNormal) {
|
if (pConn->status == ConnNormal) {
|
||||||
pHead->msgType = (0 == pMsg->msgType ? pConn->inType + 1 : pMsg->msgType);
|
pHead->msgType = (0 == pMsg->msgType ? pConn->inType + 1 : pMsg->msgType);
|
||||||
if (smsg->type == Release) pHead->msgType = 0;
|
if (smsg->type == Release) pHead->msgType = 0;
|
||||||
|
@ -429,6 +438,7 @@ static void uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) {
|
||||||
|
|
||||||
wb->base = (char*)pHead;
|
wb->base = (char*)pHead;
|
||||||
wb->len = len;
|
wb->len = len;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void uvStartSendRespImpl(SSvrMsg* smsg) {
|
static FORCE_INLINE void uvStartSendRespImpl(SSvrMsg* smsg) {
|
||||||
|
@ -438,7 +448,9 @@ static FORCE_INLINE void uvStartSendRespImpl(SSvrMsg* smsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uv_buf_t wb;
|
uv_buf_t wb;
|
||||||
uvPrepareSendData(smsg, &wb);
|
if (uvPrepareSendData(smsg, &wb) < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
transRefSrvHandle(pConn);
|
transRefSrvHandle(pConn);
|
||||||
uv_write_t* req = transReqQueuePush(&pConn->wreqQueue);
|
uv_write_t* req = transReqQueuePush(&pConn->wreqQueue);
|
||||||
|
@ -449,8 +461,9 @@ static void uvStartSendResp(SSvrMsg* smsg) {
|
||||||
SSvrConn* pConn = smsg->pConn;
|
SSvrConn* pConn = smsg->pConn;
|
||||||
if (pConn->broken == true) {
|
if (pConn->broken == true) {
|
||||||
// persist by
|
// persist by
|
||||||
transFreeMsg(smsg->msg.pCont);
|
destroySmsg(smsg);
|
||||||
taosMemoryFree(smsg);
|
// transFreeMsg(smsg->msg.pCont);
|
||||||
|
// taosMemoryFree(smsg);
|
||||||
transUnrefSrvHandle(pConn);
|
transUnrefSrvHandle(pConn);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -746,10 +759,11 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
transSockInfo2Str(&sockname, pConn->src);
|
transSockInfo2Str(&sockname, pConn->src);
|
||||||
struct sockaddr_in addr = *(struct sockaddr_in*)&sockname;
|
|
||||||
|
|
||||||
|
struct sockaddr_in addr = *(struct sockaddr_in*)&peername;
|
||||||
pConn->clientIp = addr.sin_addr.s_addr;
|
pConn->clientIp = addr.sin_addr.s_addr;
|
||||||
pConn->port = ntohs(addr.sin_port);
|
pConn->port = ntohs(addr.sin_port);
|
||||||
|
|
||||||
uv_read_start((uv_stream_t*)(pConn->pTcp), uvAllocRecvBufferCb, uvOnRecvCb);
|
uv_read_start((uv_stream_t*)(pConn->pTcp), uvAllocRecvBufferCb, uvOnRecvCb);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -201,7 +201,13 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end == fileSize) firstTrial = false;
|
if (end == fileSize) firstTrial = false;
|
||||||
if (firstTrial && terrno == TSDB_CODE_SUCCESS) continue;
|
if (firstTrial) {
|
||||||
|
if (terrno == TSDB_CODE_SUCCESS) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
firstTrial = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (retVer >= 0 || offset == 0) break;
|
if (retVer >= 0 || offset == 0) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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_MSG_DECODE_ERROR, "Msg decode error")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_NO_AVAIL_DISK, "No available disk")
|
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_NOT_FOUND, "Not found")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_NO_DISKSPACE, "Out of disk space")
|
||||||
|
|
||||||
//client
|
//client
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_OPERATION, "Invalid operation")
|
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_TABLE_ID_LENGTH, "Table name too long")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_CONNECTION, "Invalid connection")
|
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_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_CACHE_ERASED, "Query cache erased")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_QUERY_CANCELLED, "Query terminated")
|
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
|
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")
|
TAOS_DEFINE_ERROR(TSDB_CODE_NODE_NOT_DEPLOYED, "Node not deployed")
|
||||||
|
|
||||||
// vnode
|
// 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_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_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_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_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_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_COL_SUBSCRIBED, "Table column is subscribed")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_CFG_FILE, "Invalid config file")
|
TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_AVAIL_BUFPOOL, "No availabe buffer pool")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_TERM_FILE, "Invalid term file")
|
|
||||||
|
|
||||||
// tsdb
|
// tsdb
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_TABLE_ID, "Invalid table ID")
|
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_TABLE_ALREADY_EXIST, "Table already exists")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_CONFIG, "Invalid configuration")
|
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_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_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_FILE_CORRUPTED, "Data file(s) corrupted")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_OUT_OF_MEMORY, "Out of memory")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_OUT_OF_MEMORY, "Out of memory")
|
||||||
|
@ -362,13 +340,12 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_CACHE_LAST_ROW, "TSDB no cache last ro
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TABLE_NOT_EXIST, "Table not exists")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TABLE_NOT_EXIST, "Table not exists")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_STB_ALREADY_EXIST, "Stable already exists")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_STB_ALREADY_EXIST, "Stable already exists")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_STB_NOT_EXIST, "Stable not exists")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_STB_NOT_EXIST, "Stable not exists")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TABLE_RECREATED, "Table re-created")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER, "Table schema is old")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR, "TDB env open error")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR, "TDB env open error")
|
||||||
|
|
||||||
// query
|
// query
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_QHANDLE, "Invalid handle")
|
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_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_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_APP_ERROR, "Unexpected generic error in query")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_DUP_JOIN_KEY, "Duplicated join key")
|
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
|
//tq
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TQ_INVALID_CONFIG, "TQ invalid config")
|
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_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_NO_DISK_PERMISSIONS, "TQ no disk permissions")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TQ_FILE_CORRUPTED, "TQ file corrupted")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TQ_FILE_CORRUPTED, "TQ file corrupted")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TQ_OUT_OF_MEMORY, "TQ out of memory")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TQ_OUT_OF_MEMORY, "TQ out of memory")
|
||||||
|
|
|
@ -25,7 +25,8 @@ class TDTestCase:
|
||||||
'''
|
'''
|
||||||
return
|
return
|
||||||
|
|
||||||
def init(self, conn, logSql, replicaVarl=1):
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
tdLog.debug("start to execute %s" % __file__)
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
tdSql.init(conn.cursor())
|
tdSql.init(conn.cursor())
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,8 @@ class TDTestCase:
|
||||||
'''
|
'''
|
||||||
return
|
return
|
||||||
|
|
||||||
def init(self, conn, logSql, replicaVarl=1):
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
tdLog.debug("start to execute %s" % __file__)
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
tdSql.init(conn.cursor(), logSql)
|
tdSql.init(conn.cursor(), logSql)
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue