Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b06870f7
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b06870f7
编写于
10月 24, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into fix/liao_cov
上级
9f722438
2c33026b
变更
105
展开全部
隐藏空白更改
内联
并排
Showing
105 changed file
with
8812 addition
and
10261 deletion
+8812
-10261
.gitignore
.gitignore
+2
-1
include/common/tmsg.h
include/common/tmsg.h
+15
-15
include/common/ttypes.h
include/common/ttypes.h
+1
-1
include/dnode/mnode/mnode.h
include/dnode/mnode/mnode.h
+1
-0
include/libs/sync/sync.h
include/libs/sync/sync.h
+14
-23
include/libs/sync/syncTools.h
include/libs/sync/syncTools.h
+17
-19
packaging/tools/post.sh
packaging/tools/post.sh
+1
-0
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+17
-16
source/client/src/clientSml.c
source/client/src/clientSml.c
+1
-1
source/client/src/clientTmq.c
source/client/src/clientTmq.c
+2
-1
source/client/src/clientTmqConnector.c
source/client/src/clientTmqConnector.c
+6
-1
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+16
-10
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
+2
-0
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+3
-0
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
+38
-0
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+13
-3
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+2
-0
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+2
-5
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+98
-82
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+30
-32
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+1
-1
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+9
-1
source/dnode/mnode/impl/test/CMakeLists.txt
source/dnode/mnode/impl/test/CMakeLists.txt
+2
-2
source/dnode/mnode/impl/test/user/CMakeLists.txt
source/dnode/mnode/impl/test/user/CMakeLists.txt
+5
-4
source/dnode/mnode/sdb/CMakeLists.txt
source/dnode/mnode/sdb/CMakeLists.txt
+2
-2
source/dnode/mnode/sdb/inc/sdb.h
source/dnode/mnode/sdb/inc/sdb.h
+2
-0
source/dnode/mnode/sdb/src/sdb.c
source/dnode/mnode/sdb/src/sdb.c
+1
-0
source/dnode/mnode/sdb/src/sdbFile.c
source/dnode/mnode/sdb/src/sdbFile.c
+14
-2
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+4
-0
source/dnode/vnode/src/inc/meta.h
source/dnode/vnode/src/inc/meta.h
+16
-2
source/dnode/vnode/src/meta/metaOpen.c
source/dnode/vnode/src/meta/metaOpen.c
+58
-0
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+142
-2
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+76
-5
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+8
-1
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+7
-4
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+7
-0
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+11
-8
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+95
-121
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+7
-0
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+8
-19
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+862
-137
source/libs/index/inc/indexFst.h
source/libs/index/inc/indexFst.h
+6
-6
source/libs/index/src/indexFst.c
source/libs/index/src/indexFst.c
+21
-21
source/libs/index/src/indexJson.c
source/libs/index/src/indexJson.c
+1
-1
source/libs/sync/inc/syncAppendEntries.h
source/libs/sync/inc/syncAppendEntries.h
+2
-3
source/libs/sync/inc/syncAppendEntriesReply.h
source/libs/sync/inc/syncAppendEntriesReply.h
+1
-3
source/libs/sync/inc/syncElection.h
source/libs/sync/inc/syncElection.h
+2
-4
source/libs/sync/inc/syncEnv.h
source/libs/sync/inc/syncEnv.h
+6
-6
source/libs/sync/inc/syncIO.h
source/libs/sync/inc/syncIO.h
+2
-3
source/libs/sync/inc/syncIndexMgr.h
source/libs/sync/inc/syncIndexMgr.h
+2
-2
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+62
-19
source/libs/sync/inc/syncRaftCfg.h
source/libs/sync/inc/syncRaftCfg.h
+7
-7
source/libs/sync/inc/syncReplication.h
source/libs/sync/inc/syncReplication.h
+7
-8
source/libs/sync/inc/syncRequestVote.h
source/libs/sync/inc/syncRequestVote.h
+1
-2
source/libs/sync/inc/syncRequestVoteReply.h
source/libs/sync/inc/syncRequestVoteReply.h
+1
-2
source/libs/sync/inc/syncRespMgr.h
source/libs/sync/inc/syncRespMgr.h
+2
-2
source/libs/sync/inc/syncSnapshot.h
source/libs/sync/inc/syncSnapshot.h
+8
-5
source/libs/sync/inc/syncTimeout.h
source/libs/sync/inc/syncTimeout.h
+1
-1
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+169
-725
source/libs/sync/src/syncAppendEntriesReply.c
source/libs/sync/src/syncAppendEntriesReply.c
+26
-304
source/libs/sync/src/syncCommit.c
source/libs/sync/src/syncCommit.c
+20
-10
source/libs/sync/src/syncElection.c
source/libs/sync/src/syncElection.c
+25
-53
source/libs/sync/src/syncIO.c
source/libs/sync/src/syncIO.c
+4
-4
source/libs/sync/src/syncIndexMgr.c
source/libs/sync/src/syncIndexMgr.c
+4
-0
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+611
-322
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+67
-67
source/libs/sync/src/syncRaftCfg.c
source/libs/sync/src/syncRaftCfg.c
+13
-15
source/libs/sync/src/syncRaftEntry.c
source/libs/sync/src/syncRaftEntry.c
+8
-8
source/libs/sync/src/syncRaftLog.c
source/libs/sync/src/syncRaftLog.c
+26
-196
source/libs/sync/src/syncRaftStore.c
source/libs/sync/src/syncRaftStore.c
+4
-4
source/libs/sync/src/syncReplication.c
source/libs/sync/src/syncReplication.c
+108
-373
source/libs/sync/src/syncRequestVote.c
source/libs/sync/src/syncRequestVote.c
+8
-70
source/libs/sync/src/syncRequestVoteReply.c
source/libs/sync/src/syncRequestVoteReply.c
+4
-59
source/libs/sync/src/syncRespMgr.c
source/libs/sync/src/syncRespMgr.c
+1
-1
source/libs/sync/src/syncSnapshot.c
source/libs/sync/src/syncSnapshot.c
+24
-3
source/libs/sync/src/syncTimeout.c
source/libs/sync/src/syncTimeout.c
+38
-11
source/libs/sync/src/syncVoteMgr.c
source/libs/sync/src/syncVoteMgr.c
+8
-8
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
+2
-2
source/libs/sync/test/syncEncodeTest.cpp
source/libs/sync/test/syncEncodeTest.cpp
+5
-2
source/libs/sync/test/syncHeartbeatReplyTest.cpp
source/libs/sync/test/syncHeartbeatReplyTest.cpp
+2
-2
source/libs/sync/test/syncHeartbeatTest.cpp
source/libs/sync/test/syncHeartbeatTest.cpp
+2
-2
source/libs/sync/test/syncLogStoreTest.cpp
source/libs/sync/test/syncLogStoreTest.cpp
+5
-7
source/libs/sync/test/syncTestTool.cpp
source/libs/sync/test/syncTestTool.cpp
+2
-4
source/libs/transport/src/trans.c
source/libs/transport/src/trans.c
+1
-0
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+4
-5
source/os/src/osDir.c
source/os/src/osDir.c
+9
-2
source/os/src/osSocket.c
source/os/src/osSocket.c
+65
-42
source/util/src/tqueue.c
source/util/src/tqueue.c
+0
-4
tests/pytest/util/dnodes.py
tests/pytest/util/dnodes.py
+1
-1
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+3
-2
tests/script/tsim/db/alter_replica_13.sim
tests/script/tsim/db/alter_replica_13.sim
+20
-1
tests/script/tsim/mnode/basic5.sim
tests/script/tsim/mnode/basic5.sim
+1
-1
tests/script/tsim/parser/where.sim
tests/script/tsim/parser/where.sim
+11
-11
tests/script/tsim/stable/metrics_idx.sim
tests/script/tsim/stable/metrics_idx.sim
+65
-0
tests/script/tsim/sync/sync2-test.sim
tests/script/tsim/sync/sync2-test.sim
+175
-0
tests/system-test/2-query/Today.py
tests/system-test/2-query/Today.py
+7
-1
tests/system-test/2-query/nestedQuery.py
tests/system-test/2-query/nestedQuery.py
+5207
-1583
tests/system-test/2-query/nestedQuery_math.py
tests/system-test/2-query/nestedQuery_math.py
+76
-0
tests/system-test/2-query/nestedQuery_str.py
tests/system-test/2-query/nestedQuery_str.py
+42
-5716
tests/system-test/2-query/nestedQuery_time.py
tests/system-test/2-query/nestedQuery_time.py
+76
-0
tests/system-test/2-query/stablity.py
tests/system-test/2-query/stablity.py
+8
-6
tests/system-test/2-query/stablity_1.py
tests/system-test/2-query/stablity_1.py
+73
-0
tests/system-test/2-query/timetruncate.py
tests/system-test/2-query/timetruncate.py
+19
-8
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+9
-8
tools/CMakeLists.txt
tools/CMakeLists.txt
+4
-2
未找到文件。
.gitignore
浏览文件 @
b06870f7
...
@@ -127,4 +127,5 @@ tools/THANKS
...
@@ -127,4 +127,5 @@ tools/THANKS
tools/NEWS
tools/NEWS
tools/COPYING
tools/COPYING
tools/BUGS
tools/BUGS
tools/taos-tools
tools/taos-tools
\ No newline at end of file
tools/taosws-rs
include/common/tmsg.h
浏览文件 @
b06870f7
...
@@ -1234,20 +1234,20 @@ int32_t tSerializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq*
...
@@ -1234,20 +1234,20 @@ int32_t tSerializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq*
int32_t
tDeserializeSCompactVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SCompactVnodeReq
*
pReq
);
int32_t
tDeserializeSCompactVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SCompactVnodeReq
*
pReq
);
typedef
struct
{
typedef
struct
{
int32_t
vgVersion
;
int32_t
vgVersion
;
int32_t
buffer
;
int32_t
buffer
;
int32_t
pageSize
;
int32_t
pageSize
;
int32_t
pages
;
int32_t
pages
;
int32_t
cacheLastSize
;
int32_t
cacheLastSize
;
int32_t
daysPerFile
;
int32_t
daysPerFile
;
int32_t
daysToKeep0
;
int32_t
daysToKeep0
;
int32_t
daysToKeep1
;
int32_t
daysToKeep1
;
int32_t
daysToKeep2
;
int32_t
daysToKeep2
;
int32_t
walFsyncPeriod
;
int32_t
walFsyncPeriod
;
int8_t
walLevel
;
int8_t
walLevel
;
int8_t
strict
;
int8_t
strict
;
int8_t
cacheLast
;
int8_t
cacheLast
;
int64_t
reserved
[
8
];
int64_t
reserved
[
8
];
}
SAlterVnodeConfigReq
;
}
SAlterVnodeConfigReq
;
int32_t
tSerializeSAlterVnodeConfigReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterVnodeConfigReq
*
pReq
);
int32_t
tSerializeSAlterVnodeConfigReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterVnodeConfigReq
*
pReq
);
...
@@ -3065,7 +3065,7 @@ static FORCE_INLINE void* tDecodeSMqAskEpRsp(void* buf, SMqAskEpRsp* pRsp) {
...
@@ -3065,7 +3065,7 @@ static FORCE_INLINE void* tDecodeSMqAskEpRsp(void* buf, SMqAskEpRsp* pRsp) {
}
}
static
FORCE_INLINE
void
tDeleteSMqAskEpRsp
(
SMqAskEpRsp
*
pRsp
)
{
static
FORCE_INLINE
void
tDeleteSMqAskEpRsp
(
SMqAskEpRsp
*
pRsp
)
{
taosArrayDestroyEx
(
pRsp
->
topics
,
(
void
(
*
)(
void
*
)
)
tDeleteSMqSubTopicEp
);
taosArrayDestroyEx
(
pRsp
->
topics
,
(
FDelete
)
tDeleteSMqSubTopicEp
);
}
}
#define TD_AUTO_CREATE_TABLE 0x1
#define TD_AUTO_CREATE_TABLE 0x1
...
...
include/common/ttypes.h
浏览文件 @
b06870f7
...
@@ -340,7 +340,7 @@ typedef struct tDataTypeDescriptor {
...
@@ -340,7 +340,7 @@ typedef struct tDataTypeDescriptor {
}
tDataTypeDescriptor
;
}
tDataTypeDescriptor
;
extern
tDataTypeDescriptor
tDataTypes
[
TSDB_DATA_TYPE_MAX
];
extern
tDataTypeDescriptor
tDataTypes
[
TSDB_DATA_TYPE_MAX
];
bool
isValidDataType
(
int32_t
type
);
bool
isValidDataType
(
int32_t
type
);
void
assignVal
(
char
*
val
,
const
char
*
src
,
int32_t
len
,
int32_t
type
);
void
assignVal
(
char
*
val
,
const
char
*
src
,
int32_t
len
,
int32_t
type
);
void
operateVal
(
void
*
dst
,
void
*
s1
,
void
*
s2
,
int32_t
optr
,
int32_t
type
);
void
operateVal
(
void
*
dst
,
void
*
s1
,
void
*
s2
,
int32_t
optr
,
int32_t
type
);
...
...
include/dnode/mnode/mnode.h
浏览文件 @
b06870f7
...
@@ -99,6 +99,7 @@ int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
...
@@ -99,6 +99,7 @@ int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
*/
*/
int32_t
mndProcessRpcMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndProcessRpcMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndProcessSyncMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndProcessSyncMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndProcessSyncCtrlMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndPreProcessQueryMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndPreProcessQueryMsg
(
SRpcMsg
*
pMsg
);
void
mndPostProcessQueryMsg
(
SRpcMsg
*
pMsg
);
void
mndPostProcessQueryMsg
(
SRpcMsg
*
pMsg
);
...
...
include/libs/sync/sync.h
浏览文件 @
b06870f7
...
@@ -35,7 +35,12 @@ extern bool gRaftDetailLog;
...
@@ -35,7 +35,12 @@ extern bool gRaftDetailLog;
#define SYNC_MAX_PROGRESS_WAIT_MS 4000
#define SYNC_MAX_PROGRESS_WAIT_MS 4000
#define SYNC_MAX_START_TIME_RANGE_MS (1000 * 20)
#define SYNC_MAX_START_TIME_RANGE_MS (1000 * 20)
#define SYNC_MAX_RECV_TIME_RANGE_MS 1200
#define SYNC_MAX_RECV_TIME_RANGE_MS 1200
#define SYNC_DEL_WAL_MS (1000 * 60)
#define SYNC_ADD_QUORUM_COUNT 3
#define SYNC_ADD_QUORUM_COUNT 3
#define SYNC_MNODE_LOG_RETENTION 10000
#define SYNC_VNODE_LOG_RETENTION 500
#define SYNC_APPEND_ENTRIES_TIMEOUT_MS 10000
#define SYNC_MAX_BATCH_SIZE 1
#define SYNC_MAX_BATCH_SIZE 1
#define SYNC_INDEX_BEGIN 0
#define SYNC_INDEX_BEGIN 0
...
@@ -157,32 +162,15 @@ typedef struct SSyncLogStore {
...
@@ -157,32 +162,15 @@ typedef struct SSyncLogStore {
SLRUCache
*
pCache
;
SLRUCache
*
pCache
;
void
*
data
;
void
*
data
;
// append one log entry
int32_t
(
*
syncLogUpdateCommitIndex
)(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
index
);
int32_t
(
*
appendEntry
)(
struct
SSyncLogStore
*
pLogStore
,
SSyncRaftEntry
*
pEntry
);
SyncIndex
(
*
syncLogCommitIndex
)(
struct
SSyncLogStore
*
pLogStore
);
// get one log entry, user need to free pEntry->pCont
SSyncRaftEntry
*
(
*
getEntry
)(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
index
);
// truncate log with index, entries after the given index (>=index) will be deleted
int32_t
(
*
truncate
)(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
fromIndex
);
// return index of last entry
SyncIndex
(
*
getLastIndex
)(
struct
SSyncLogStore
*
pLogStore
);
// return term of last entry
SyncTerm
(
*
getLastTerm
)(
struct
SSyncLogStore
*
pLogStore
);
// update log store commit index with "index"
int32_t
(
*
updateCommitIndex
)(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
index
);
// return commit index of log
SyncIndex
(
*
getCommitIndex
)(
struct
SSyncLogStore
*
pLogStore
);
SyncIndex
(
*
syncLogBeginIndex
)(
struct
SSyncLogStore
*
pLogStore
);
SyncIndex
(
*
syncLogBeginIndex
)(
struct
SSyncLogStore
*
pLogStore
);
SyncIndex
(
*
syncLogEndIndex
)(
struct
SSyncLogStore
*
pLogStore
);
SyncIndex
(
*
syncLogEndIndex
)(
struct
SSyncLogStore
*
pLogStore
);
bool
(
*
syncLogIsEmpty
)(
struct
SSyncLogStore
*
pLogStore
);
int32_t
(
*
syncLogEntryCount
)(
struct
SSyncLogStore
*
pLogStore
);
int32_t
(
*
syncLogEntryCount
)(
struct
SSyncLogStore
*
pLogStore
);
int32_t
(
*
syncLogRestoreFromSnapshot
)(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
index
);
int32_t
(
*
syncLogRestoreFromSnapshot
)(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
index
);
bool
(
*
syncLogIsEmpty
)(
struct
SSyncLogStore
*
pLogStore
);
bool
(
*
syncLogExist
)(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
index
);
bool
(
*
syncLogExist
)(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
index
);
SyncIndex
(
*
syncLogWriteIndex
)(
struct
SSyncLogStore
*
pLogStore
);
SyncIndex
(
*
syncLogWriteIndex
)(
struct
SSyncLogStore
*
pLogStore
);
...
@@ -207,6 +195,7 @@ typedef struct SSyncInfo {
...
@@ -207,6 +195,7 @@ typedef struct SSyncInfo {
SMsgCb
*
msgcb
;
SMsgCb
*
msgcb
;
int32_t
(
*
FpSendMsg
)(
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
int32_t
(
*
FpSendMsg
)(
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
int32_t
(
*
FpEqMsg
)(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
);
int32_t
(
*
FpEqMsg
)(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
);
int32_t
(
*
FpEqCtrlMsg
)(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
);
}
SSyncInfo
;
}
SSyncInfo
;
int32_t
syncInit
();
int32_t
syncInit
();
...
@@ -217,7 +206,6 @@ void syncStop(int64_t rid);
...
@@ -217,7 +206,6 @@ void syncStop(int64_t rid);
int32_t
syncSetStandby
(
int64_t
rid
);
int32_t
syncSetStandby
(
int64_t
rid
);
ESyncState
syncGetMyRole
(
int64_t
rid
);
ESyncState
syncGetMyRole
(
int64_t
rid
);
bool
syncIsReady
(
int64_t
rid
);
bool
syncIsReady
(
int64_t
rid
);
bool
syncIsReadyForRead
(
int64_t
rid
);
const
char
*
syncGetMyRoleStr
(
int64_t
rid
);
const
char
*
syncGetMyRoleStr
(
int64_t
rid
);
bool
syncRestoreFinish
(
int64_t
rid
);
bool
syncRestoreFinish
(
int64_t
rid
);
SyncTerm
syncGetMyTerm
(
int64_t
rid
);
SyncTerm
syncGetMyTerm
(
int64_t
rid
);
...
@@ -227,7 +215,7 @@ SyncGroupId syncGetVgId(int64_t rid);
...
@@ -227,7 +215,7 @@ SyncGroupId syncGetVgId(int64_t rid);
void
syncGetEpSet
(
int64_t
rid
,
SEpSet
*
pEpSet
);
void
syncGetEpSet
(
int64_t
rid
,
SEpSet
*
pEpSet
);
void
syncGetRetryEpSet
(
int64_t
rid
,
SEpSet
*
pEpSet
);
void
syncGetRetryEpSet
(
int64_t
rid
,
SEpSet
*
pEpSet
);
int32_t
syncPropose
(
int64_t
rid
,
SRpcMsg
*
pMsg
,
bool
isWeak
);
int32_t
syncPropose
(
int64_t
rid
,
SRpcMsg
*
pMsg
,
bool
isWeak
);
int32_t
syncProposeBatch
(
int64_t
rid
,
SRpcMsg
**
pMsgPArr
,
bool
*
pIsWeakArr
,
int32_t
arrSize
);
//
int32_t syncProposeBatch(int64_t rid, SRpcMsg** pMsgPArr, bool* pIsWeakArr, int32_t arrSize);
bool
syncEnvIsStart
();
bool
syncEnvIsStart
();
const
char
*
syncStr
(
ESyncState
state
);
const
char
*
syncStr
(
ESyncState
state
);
bool
syncIsRestoreFinish
(
int64_t
rid
);
bool
syncIsRestoreFinish
(
int64_t
rid
);
...
@@ -241,6 +229,9 @@ int32_t syncReconfigBuild(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg
...
@@ -241,6 +229,9 @@ int32_t syncReconfigBuild(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg
int32_t
syncLeaderTransfer
(
int64_t
rid
);
int32_t
syncLeaderTransfer
(
int64_t
rid
);
int32_t
syncLeaderTransferTo
(
int64_t
rid
,
SNodeInfo
newLeader
);
int32_t
syncLeaderTransferTo
(
int64_t
rid
,
SNodeInfo
newLeader
);
int32_t
syncBeginSnapshot
(
int64_t
rid
,
int64_t
lastApplyIndex
);
int32_t
syncEndSnapshot
(
int64_t
rid
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/libs/sync/syncTools.h
浏览文件 @
b06870f7
...
@@ -157,6 +157,8 @@ typedef enum ESyncTimeoutType {
...
@@ -157,6 +157,8 @@ typedef enum ESyncTimeoutType {
SYNC_TIMEOUT_HEARTBEAT
,
SYNC_TIMEOUT_HEARTBEAT
,
}
ESyncTimeoutType
;
}
ESyncTimeoutType
;
const
char
*
syncTimerTypeStr
(
enum
ESyncTimeoutType
timerType
);
typedef
struct
SyncTimeout
{
typedef
struct
SyncTimeout
{
uint32_t
bytes
;
uint32_t
bytes
;
int32_t
vgId
;
int32_t
vgId
;
...
@@ -423,6 +425,7 @@ typedef struct SyncAppendEntriesReply {
...
@@ -423,6 +425,7 @@ typedef struct SyncAppendEntriesReply {
SyncTerm
privateTerm
;
SyncTerm
privateTerm
;
bool
success
;
bool
success
;
SyncIndex
matchIndex
;
SyncIndex
matchIndex
;
SyncIndex
lastSendIndex
;
int64_t
startTime
;
int64_t
startTime
;
}
SyncAppendEntriesReply
;
}
SyncAppendEntriesReply
;
...
@@ -456,6 +459,8 @@ typedef struct SyncHeartbeat {
...
@@ -456,6 +459,8 @@ typedef struct SyncHeartbeat {
SyncTerm
term
;
SyncTerm
term
;
SyncIndex
commitIndex
;
SyncIndex
commitIndex
;
SyncTerm
privateTerm
;
SyncTerm
privateTerm
;
SyncTerm
minMatchIndex
;
}
SyncHeartbeat
;
}
SyncHeartbeat
;
SyncHeartbeat
*
syncHeartbeatBuild
(
int32_t
vgId
);
SyncHeartbeat
*
syncHeartbeatBuild
(
int32_t
vgId
);
...
@@ -676,24 +681,17 @@ void syncReconfigFinishLog2(char* s, const SyncReconfigFinish* pMsg);
...
@@ -676,24 +681,17 @@ void syncReconfigFinishLog2(char* s, const SyncReconfigFinish* pMsg);
// on message ----------------------
// on message ----------------------
int32_t
syncNodeOnPingCb
(
SSyncNode
*
ths
,
SyncPing
*
pMsg
);
int32_t
syncNodeOnPingCb
(
SSyncNode
*
ths
,
SyncPing
*
pMsg
);
int32_t
syncNodeOnPingReplyCb
(
SSyncNode
*
ths
,
SyncPingReply
*
pMsg
);
int32_t
syncNodeOnPingReplyCb
(
SSyncNode
*
ths
,
SyncPingReply
*
pMsg
);
int32_t
syncNodeOnTimeoutCb
(
SSyncNode
*
ths
,
SyncTimeout
*
pMsg
);
int32_t
syncNodeOnTimer
(
SSyncNode
*
ths
,
SyncTimeout
*
pMsg
);
int32_t
syncNodeOnClientRequestCb
(
SSyncNode
*
ths
,
SyncClientRequest
*
pMsg
,
SyncIndex
*
pRetIndex
);
int32_t
syncNodeOnClientRequestBatchCb
(
SSyncNode
*
ths
,
SyncClientRequestBatch
*
pMsg
);
int32_t
syncNodeOnRequestVoteCb
(
SSyncNode
*
ths
,
SyncRequestVote
*
pMsg
);
int32_t
syncNodeOnRequestVoteReplyCb
(
SSyncNode
*
ths
,
SyncRequestVoteReply
*
pMsg
);
int32_t
syncNodeOnAppendEntriesCb
(
SSyncNode
*
ths
,
SyncAppendEntries
*
pMsg
);
int32_t
syncNodeOnAppendEntriesReplyCb
(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
syncNodeOnRequestVoteSnapshotCb
(
SSyncNode
*
ths
,
SyncRequestVote
*
pMsg
);
int32_t
syncNodeOnRequestVoteReplySnapshotCb
(
SSyncNode
*
ths
,
SyncRequestVoteReply
*
pMsg
);
int32_t
syncNodeOnAppendEntriesSnapshotCb
(
SSyncNode
*
ths
,
SyncAppendEntries
*
pMsg
);
int32_t
syncNodeOnAppendEntriesReplySnapshotCb
(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
syncNodeOnAppendEntriesSnapshot2Cb
(
SSyncNode
*
ths
,
SyncAppendEntriesBatch
*
pMsg
);
int32_t
syncNodeOnHeartbeat
(
SSyncNode
*
ths
,
SyncHeartbeat
*
pMsg
);
int32_t
syncNodeOnAppendEntriesReplySnapshot2Cb
(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
syncNodeOnHeartbeatReply
(
SSyncNode
*
ths
,
SyncHeartbeatReply
*
pMsg
);
int32_t
syncNodeOnClientRequest
(
SSyncNode
*
ths
,
SyncClientRequest
*
pMsg
,
SyncIndex
*
pRetIndex
);
int32_t
syncNodeOnSnapshotSendCb
(
SSyncNode
*
ths
,
SyncSnapshotSend
*
pMsg
);
int32_t
syncNodeOnRequestVote
(
SSyncNode
*
ths
,
SyncRequestVote
*
pMsg
);
int32_t
syncNodeOnSnapshotRspCb
(
SSyncNode
*
ths
,
SyncSnapshotRsp
*
pMsg
);
int32_t
syncNodeOnRequestVoteReply
(
SSyncNode
*
ths
,
SyncRequestVoteReply
*
pMsg
);
int32_t
syncNodeOnAppendEntries
(
SSyncNode
*
ths
,
SyncAppendEntries
*
pMsg
);
int32_t
syncNodeOnAppendEntriesReply
(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
syncNodeOnSnapshot
(
SSyncNode
*
ths
,
SyncSnapshotSend
*
pMsg
);
int32_t
syncNodeOnSnapshotReply
(
SSyncNode
*
ths
,
SyncSnapshotRsp
*
pMsg
);
int32_t
syncNodeOnHeartbeat
(
SSyncNode
*
ths
,
SyncHeartbeat
*
pMsg
);
int32_t
syncNodeOnHeartbeat
(
SSyncNode
*
ths
,
SyncHeartbeat
*
pMsg
);
int32_t
syncNodeOnHeartbeatReply
(
SSyncNode
*
ths
,
SyncHeartbeatReply
*
pMsg
);
int32_t
syncNodeOnHeartbeatReply
(
SSyncNode
*
ths
,
SyncHeartbeatReply
*
pMsg
);
...
@@ -707,8 +705,8 @@ typedef int32_t (*FpOnRequestVoteReplyCb)(SSyncNode* ths, SyncRequestVoteReply*
...
@@ -707,8 +705,8 @@ typedef int32_t (*FpOnRequestVoteReplyCb)(SSyncNode* ths, SyncRequestVoteReply*
typedef
int32_t
(
*
FpOnAppendEntriesCb
)(
SSyncNode
*
ths
,
SyncAppendEntries
*
pMsg
);
typedef
int32_t
(
*
FpOnAppendEntriesCb
)(
SSyncNode
*
ths
,
SyncAppendEntries
*
pMsg
);
typedef
int32_t
(
*
FpOnAppendEntriesReplyCb
)(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
typedef
int32_t
(
*
FpOnAppendEntriesReplyCb
)(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
typedef
int32_t
(
*
FpOnTimeoutCb
)(
SSyncNode
*
pSyncNode
,
SyncTimeout
*
pMsg
);
typedef
int32_t
(
*
FpOnTimeoutCb
)(
SSyncNode
*
pSyncNode
,
SyncTimeout
*
pMsg
);
typedef
int32_t
(
*
FpOnSnapshot
Send
Cb
)(
SSyncNode
*
ths
,
SyncSnapshotSend
*
pMsg
);
typedef
int32_t
(
*
FpOnSnapshotCb
)(
SSyncNode
*
ths
,
SyncSnapshotSend
*
pMsg
);
typedef
int32_t
(
*
FpOnSnapshotR
sp
Cb
)(
SSyncNode
*
ths
,
SyncSnapshotRsp
*
pMsg
);
typedef
int32_t
(
*
FpOnSnapshotR
eply
Cb
)(
SSyncNode
*
ths
,
SyncSnapshotRsp
*
pMsg
);
// option ----------------------------------
// option ----------------------------------
bool
syncNodeSnapshotEnable
(
SSyncNode
*
pSyncNode
);
bool
syncNodeSnapshotEnable
(
SSyncNode
*
pSyncNode
);
...
...
packaging/tools/post.sh
浏览文件 @
b06870f7
...
@@ -118,6 +118,7 @@ function kill_taosd() {
...
@@ -118,6 +118,7 @@ function kill_taosd() {
}
}
function
install_include
()
{
function
install_include
()
{
${
csudo
}
mkdir
-p
${
inc_link_dir
}
${
csudo
}
rm
-f
${
inc_link_dir
}
/taos.h
${
inc_link_dir
}
/taosdef.h
${
inc_link_dir
}
/taoserror.h
${
inc_link_dir
}
/taosudf.h
||
:
${
csudo
}
rm
-f
${
inc_link_dir
}
/taos.h
${
inc_link_dir
}
/taosdef.h
${
inc_link_dir
}
/taoserror.h
${
inc_link_dir
}
/taosudf.h
||
:
[
-f
${
inc_link_dir
}
/taosws.h
]
&&
${
csudo
}
rm
-f
${
inc_link_dir
}
/taosws.h
||
:
[
-f
${
inc_link_dir
}
/taosws.h
]
&&
${
csudo
}
rm
-f
${
inc_link_dir
}
/taosws.h
||
:
...
...
source/client/src/clientMsgHandler.c
浏览文件 @
b06870f7
...
@@ -46,38 +46,38 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) {
...
@@ -46,38 +46,38 @@ 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
=
param
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
taosMemoryFree
(
pMsg
->
pEpSet
);
taosMemoryFree
(
pMsg
->
pData
);
setErrno
(
pRequest
,
code
);
setErrno
(
pRequest
,
code
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
return
code
;
goto
End
;
}
}
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
SConnectRsp
connectRsp
=
{
0
};
SConnectRsp
connectRsp
=
{
0
};
tDeserializeSConnectRsp
(
pMsg
->
pData
,
pMsg
->
len
,
&
connectRsp
);
if
(
tDeserializeSConnectRsp
(
pMsg
->
pData
,
pMsg
->
len
,
&
connectRsp
)
!=
0
)
{
code
=
TSDB_CODE_TSC_INVALID_VERSION
;
setErrno
(
pRequest
,
code
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
goto
End
;
}
int32_t
now
=
taosGetTimestampSec
();
int32_t
now
=
taosGetTimestampSec
();
int32_t
delta
=
abs
(
now
-
connectRsp
.
svrTimestamp
);
int32_t
delta
=
abs
(
now
-
connectRsp
.
svrTimestamp
);
if
(
delta
>
timestampDeltaLimit
)
{
if
(
delta
>
timestampDeltaLimit
)
{
code
=
TSDB_CODE_TIME_UNSYNCED
;
code
=
TSDB_CODE_TIME_UNSYNCED
;
tscError
(
"time diff:%ds is too big"
,
delta
);
tscError
(
"time diff:%ds is too big"
,
delta
);
taosMemoryFree
(
pMsg
->
pEpSet
);
taosMemoryFree
(
pMsg
->
pData
);
setErrno
(
pRequest
,
code
);
setErrno
(
pRequest
,
code
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
return
code
;
goto
End
;
}
}
/*assert(connectRsp.epSet.numOfEps > 0);*/
/*assert(connectRsp.epSet.numOfEps > 0);*/
if
(
connectRsp
.
epSet
.
numOfEps
==
0
)
{
if
(
connectRsp
.
epSet
.
numOfEps
==
0
)
{
taosMemoryFree
(
pMsg
->
pEpSet
);
taosMemoryFree
(
pMsg
->
pData
);
setErrno
(
pRequest
,
TSDB_CODE_MND_APP_ERROR
);
setErrno
(
pRequest
,
TSDB_CODE_MND_APP_ERROR
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
return
code
;
goto
End
;
}
}
if
(
connectRsp
.
dnodeNum
==
1
)
{
if
(
connectRsp
.
dnodeNum
==
1
)
{
...
@@ -113,14 +113,15 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
...
@@ -113,14 +113,15 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
hbRegisterConn
(
pTscObj
->
pAppInfo
->
pAppHbMgr
,
pTscObj
->
id
,
connectRsp
.
clusterId
,
connectRsp
.
connType
);
hbRegisterConn
(
pTscObj
->
pAppInfo
->
pAppHbMgr
,
pTscObj
->
id
,
connectRsp
.
clusterId
,
connectRsp
.
connType
);
// pRequest->body.resInfo.pRspMsg = pMsg->pData;
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
);
taosMemoryFree
(
pMsg
->
pData
);
taosMemoryFree
(
pMsg
->
pEpSet
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
return
0
;
End:
taosMemoryFree
(
pMsg
->
pEpSet
);
taosMemoryFree
(
pMsg
->
pData
);
return
code
;
}
}
SMsgSendInfo
*
buildMsgInfoImpl
(
SRequestObj
*
pRequest
)
{
SMsgSendInfo
*
buildMsgInfoImpl
(
SRequestObj
*
pRequest
)
{
...
@@ -194,7 +195,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
...
@@ -194,7 +195,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
SUseDbRsp
usedbRsp
=
{
0
};
SUseDbRsp
usedbRsp
=
{
0
};
tDeserializeSUseDbRsp
(
pMsg
->
pData
,
pMsg
->
len
,
&
usedbRsp
);
tDeserializeSUseDbRsp
(
pMsg
->
pData
,
pMsg
->
len
,
&
usedbRsp
);
if
(
strlen
(
usedbRsp
.
db
)
==
0
)
{
if
(
strlen
(
usedbRsp
.
db
)
==
0
)
{
return
TSDB_CODE_MND_DB_NOT_EXIST
;
return
TSDB_CODE_MND_DB_NOT_EXIST
;
}
}
...
@@ -292,7 +293,7 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
...
@@ -292,7 +293,7 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
tDeserializeSDropDbRsp
(
pMsg
->
pData
,
pMsg
->
len
,
&
dropdbRsp
);
tDeserializeSDropDbRsp
(
pMsg
->
pData
,
pMsg
->
len
,
&
dropdbRsp
);
struct
SCatalog
*
pCatalog
=
NULL
;
struct
SCatalog
*
pCatalog
=
NULL
;
int32_t
code
=
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
pCatalog
);
int32_t
code
=
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
pCatalog
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
catalogRemoveDB
(
pCatalog
,
dropdbRsp
.
db
,
dropdbRsp
.
uid
);
catalogRemoveDB
(
pCatalog
,
dropdbRsp
.
db
,
dropdbRsp
.
uid
);
}
}
...
...
source/client/src/clientSml.c
浏览文件 @
b06870f7
...
@@ -2394,7 +2394,7 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], char* rawLine, char
...
@@ -2394,7 +2394,7 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], char* rawLine, char
code
=
smlParseJSON
(
info
,
rawLine
);
code
=
smlParseJSON
(
info
,
rawLine
);
}
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" smlParseJSON failed:%s"
,
info
->
id
,
*
lines
);
uError
(
"SML:0x%"
PRIx64
" smlParseJSON failed:%s"
,
info
->
id
,
lines
?*
lines
:
rawLine
);
return
code
;
return
code
;
}
}
return
code
;
return
code
;
...
...
source/client/src/clientTmq.c
浏览文件 @
b06870f7
...
@@ -1206,7 +1206,7 @@ CREATE_MSG_FAIL:
...
@@ -1206,7 +1206,7 @@ CREATE_MSG_FAIL:
return
-
1
;
return
-
1
;
}
}
bool
tmqUpdateEp
(
tmq_t
*
tmq
,
int32_t
epoch
,
SMqAskEpRsp
*
pRsp
)
{
bool
tmqUpdateEp
(
tmq_t
*
tmq
,
int32_t
epoch
,
const
SMqAskEpRsp
*
pRsp
)
{
bool
set
=
false
;
bool
set
=
false
;
int32_t
topicNumGet
=
taosArrayGetSize
(
pRsp
->
topics
);
int32_t
topicNumGet
=
taosArrayGetSize
(
pRsp
->
topics
);
...
@@ -1599,6 +1599,7 @@ int32_t tmqHandleNoPollRsp(tmq_t* tmq, SMqRspWrapper* rspWrapper, bool* pReset)
...
@@ -1599,6 +1599,7 @@ int32_t tmqHandleNoPollRsp(tmq_t* tmq, SMqRspWrapper* rspWrapper, bool* pReset)
SMqAskEpRsp
*
rspMsg
=
&
pEpRspWrapper
->
msg
;
SMqAskEpRsp
*
rspMsg
=
&
pEpRspWrapper
->
msg
;
tmqUpdateEp
(
tmq
,
rspWrapper
->
epoch
,
rspMsg
);
tmqUpdateEp
(
tmq
,
rspWrapper
->
epoch
,
rspMsg
);
/*tmqClearUnhandleMsg(tmq);*/
/*tmqClearUnhandleMsg(tmq);*/
tDeleteSMqAskEpRsp
(
rspMsg
);
*
pReset
=
true
;
*
pReset
=
true
;
}
else
{
}
else
{
*
pReset
=
false
;
*
pReset
=
false
;
...
...
source/client/src/clientTmqConnector.c
浏览文件 @
b06870f7
...
@@ -73,8 +73,8 @@ JNIEXPORT void JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqConfDestroyImp
...
@@ -73,8 +73,8 @@ JNIEXPORT void JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqConfDestroyImp
if
(
conf
==
NULL
)
{
if
(
conf
==
NULL
)
{
jniDebug
(
"jobj:%p, tmq config is already destroyed"
,
jobj
);
jniDebug
(
"jobj:%p, tmq config is already destroyed"
,
jobj
);
}
else
{
}
else
{
tmq_conf_destroy
(
conf
);
jniDebug
(
"jobj:%p, config:%p, tmq successfully destroy config"
,
jobj
,
conf
);
jniDebug
(
"jobj:%p, config:%p, tmq successfully destroy config"
,
jobj
,
conf
);
tmq_conf_destroy
(
conf
);
}
}
}
}
...
@@ -206,6 +206,7 @@ JNIEXPORT void JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqCommitAsync(JN
...
@@ -206,6 +206,7 @@ JNIEXPORT void JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqCommitAsync(JN
tmq_t
*
tmq
=
(
tmq_t
*
)
jtmq
;
tmq_t
*
tmq
=
(
tmq_t
*
)
jtmq
;
if
(
tmq
==
NULL
)
{
if
(
tmq
==
NULL
)
{
jniError
(
"jobj:%p, tmq is closed"
,
jobj
);
jniError
(
"jobj:%p, tmq is closed"
,
jobj
);
return
;
}
}
TAOS_RES
*
res
=
(
TAOS_RES
*
)
jres
;
TAOS_RES
*
res
=
(
TAOS_RES
*
)
jres
;
consumer
=
(
*
env
)
->
NewGlobalRef
(
env
,
consumer
);
consumer
=
(
*
env
)
->
NewGlobalRef
(
env
,
consumer
);
...
@@ -252,6 +253,7 @@ JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqGetTopicNam
...
@@ -252,6 +253,7 @@ JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqGetTopicNam
TAOS_RES
*
res
=
(
TAOS_RES
*
)
jres
;
TAOS_RES
*
res
=
(
TAOS_RES
*
)
jres
;
if
(
res
==
NULL
)
{
if
(
res
==
NULL
)
{
jniDebug
(
"jobj:%p, invalid res handle"
,
jobj
);
jniDebug
(
"jobj:%p, invalid res handle"
,
jobj
);
return
NULL
;
}
}
return
(
*
env
)
->
NewStringUTF
(
env
,
tmq_get_topic_name
(
res
));
return
(
*
env
)
->
NewStringUTF
(
env
,
tmq_get_topic_name
(
res
));
}
}
...
@@ -259,6 +261,7 @@ JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqGetDbName(J
...
@@ -259,6 +261,7 @@ JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqGetDbName(J
TAOS_RES
*
res
=
(
TAOS_RES
*
)
jres
;
TAOS_RES
*
res
=
(
TAOS_RES
*
)
jres
;
if
(
res
==
NULL
)
{
if
(
res
==
NULL
)
{
jniDebug
(
"jobj:%p, invalid res handle"
,
jobj
);
jniDebug
(
"jobj:%p, invalid res handle"
,
jobj
);
return
NULL
;
}
}
return
(
*
env
)
->
NewStringUTF
(
env
,
tmq_get_db_name
(
res
));
return
(
*
env
)
->
NewStringUTF
(
env
,
tmq_get_db_name
(
res
));
}
}
...
@@ -266,6 +269,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqGetVgroupId(JN
...
@@ -266,6 +269,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqGetVgroupId(JN
TAOS_RES
*
res
=
(
TAOS_RES
*
)
jres
;
TAOS_RES
*
res
=
(
TAOS_RES
*
)
jres
;
if
(
res
==
NULL
)
{
if
(
res
==
NULL
)
{
jniDebug
(
"jobj:%p, invalid res handle"
,
jobj
);
jniDebug
(
"jobj:%p, invalid res handle"
,
jobj
);
return
-
1
;
}
}
return
tmq_get_vgroup_id
(
res
);
return
tmq_get_vgroup_id
(
res
);
}
}
...
@@ -275,6 +279,7 @@ JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqGetTableNam
...
@@ -275,6 +279,7 @@ JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqGetTableNam
TAOS_RES
*
res
=
(
TAOS_RES
*
)
jres
;
TAOS_RES
*
res
=
(
TAOS_RES
*
)
jres
;
if
(
res
==
NULL
)
{
if
(
res
==
NULL
)
{
jniDebug
(
"jobj:%p, invalid res handle"
,
jobj
);
jniDebug
(
"jobj:%p, invalid res handle"
,
jobj
);
return
NULL
;
}
}
return
(
*
env
)
->
NewStringUTF
(
env
,
tmq_get_table_name
(
res
));
return
(
*
env
)
->
NewStringUTF
(
env
,
tmq_get_table_name
(
res
));
}
}
...
...
source/common/src/tdatablock.c
浏览文件 @
b06870f7
...
@@ -2030,21 +2030,24 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB
...
@@ -2030,21 +2030,24 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB
tdAppendColValToRow
(
&
rb
,
PRIMARYKEY_TIMESTAMP_COL_ID
,
TSDB_DATA_TYPE_TIMESTAMP
,
TD_VTYPE_NORM
,
var
,
true
,
tdAppendColValToRow
(
&
rb
,
PRIMARYKEY_TIMESTAMP_COL_ID
,
TSDB_DATA_TYPE_TIMESTAMP
,
TD_VTYPE_NORM
,
var
,
true
,
offset
,
k
);
offset
,
k
);
}
else
if
(
colDataIsNull_s
(
pColInfoData
,
j
))
{
tdAppendColValToRow
(
&
rb
,
PRIMARYKEY_TIMESTAMP_COL_ID
+
k
,
TSDB_DATA_TYPE_TIMESTAMP
,
TD_VTYPE_NULL
,
NULL
,
false
,
offset
,
k
);
}
else
{
}
else
{
tdAppendColValToRow
(
&
rb
,
PRIMARYKEY_TIMESTAMP_COL_ID
+
k
,
TSDB_DATA_TYPE_TIMESTAMP
,
TD_VTYPE_NORM
,
var
,
tdAppendColValToRow
(
&
rb
,
PRIMARYKEY_TIMESTAMP_COL_ID
+
k
,
TSDB_DATA_TYPE_TIMESTAMP
,
TD_VTYPE_NORM
,
var
,
true
,
offset
,
k
);
true
,
offset
,
k
);
}
}
break
;
break
;
case
TSDB_DATA_TYPE_NCHAR
:
{
case
TSDB_DATA_TYPE_NCHAR
:
void
*
data
=
colDataGetData
(
pColInfoData
,
j
);
tdAppendColValToRow
(
&
rb
,
PRIMARYKEY_TIMESTAMP_COL_ID
+
k
,
TSDB_DATA_TYPE_NCHAR
,
TD_VTYPE_NORM
,
data
,
true
,
offset
,
k
);
break
;
}
case
TSDB_DATA_TYPE_VARCHAR
:
{
// TSDB_DATA_TYPE_BINARY
case
TSDB_DATA_TYPE_VARCHAR
:
{
// TSDB_DATA_TYPE_BINARY
void
*
data
=
colDataGetData
(
pColInfoData
,
j
);
if
(
colDataIsNull_s
(
pColInfoData
,
j
))
{
tdAppendColValToRow
(
&
rb
,
PRIMARYKEY_TIMESTAMP_COL_ID
+
k
,
TSDB_DATA_TYPE_VARCHAR
,
TD_VTYPE_NORM
,
data
,
true
,
tdAppendColValToRow
(
&
rb
,
PRIMARYKEY_TIMESTAMP_COL_ID
+
k
,
pColInfoData
->
info
.
type
,
TD_VTYPE_NULL
,
NULL
,
offset
,
k
);
false
,
offset
,
k
);
}
else
{
void
*
data
=
colDataGetData
(
pColInfoData
,
j
);
tdAppendColValToRow
(
&
rb
,
PRIMARYKEY_TIMESTAMP_COL_ID
+
k
,
pColInfoData
->
info
.
type
,
TD_VTYPE_NORM
,
data
,
true
,
offset
,
k
);
}
break
;
break
;
}
}
case
TSDB_DATA_TYPE_VARBINARY
:
case
TSDB_DATA_TYPE_VARBINARY
:
...
@@ -2057,7 +2060,10 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB
...
@@ -2057,7 +2060,10 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB
break
;
break
;
default:
default:
if
(
pColInfoData
->
info
.
type
<
TSDB_DATA_TYPE_MAX
&&
pColInfoData
->
info
.
type
>
TSDB_DATA_TYPE_NULL
)
{
if
(
pColInfoData
->
info
.
type
<
TSDB_DATA_TYPE_MAX
&&
pColInfoData
->
info
.
type
>
TSDB_DATA_TYPE_NULL
)
{
if
(
pCol
->
type
==
pColInfoData
->
info
.
type
)
{
if
(
colDataIsNull_s
(
pColInfoData
,
j
))
{
tdAppendColValToRow
(
&
rb
,
PRIMARYKEY_TIMESTAMP_COL_ID
+
k
,
pCol
->
type
,
TD_VTYPE_NULL
,
NULL
,
false
,
offset
,
k
);
}
else
if
(
pCol
->
type
==
pColInfoData
->
info
.
type
)
{
tdAppendColValToRow
(
&
rb
,
PRIMARYKEY_TIMESTAMP_COL_ID
+
k
,
pCol
->
type
,
TD_VTYPE_NORM
,
var
,
true
,
offset
,
tdAppendColValToRow
(
&
rb
,
PRIMARYKEY_TIMESTAMP_COL_ID
+
k
,
pCol
->
type
,
TD_VTYPE_NORM
,
var
,
true
,
offset
,
k
);
k
);
}
else
{
}
else
{
...
...
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
浏览文件 @
b06870f7
...
@@ -34,6 +34,7 @@ typedef struct SMnodeMgmt {
...
@@ -34,6 +34,7 @@ typedef struct SMnodeMgmt {
SSingleWorker
readWorker
;
SSingleWorker
readWorker
;
SSingleWorker
writeWorker
;
SSingleWorker
writeWorker
;
SSingleWorker
syncWorker
;
SSingleWorker
syncWorker
;
SSingleWorker
syncCtrlWorker
;
bool
stopped
;
bool
stopped
;
int32_t
refCount
;
int32_t
refCount
;
TdThreadRwlock
lock
;
TdThreadRwlock
lock
;
...
@@ -53,6 +54,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt);
...
@@ -53,6 +54,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt);
void
mmStopWorker
(
SMnodeMgmt
*
pMgmt
);
void
mmStopWorker
(
SMnodeMgmt
*
pMgmt
);
int32_t
mmPutMsgToWriteQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToWriteQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToSyncQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToSyncQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToSyncCtrlQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToFetchQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToFetchQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
...
...
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
b06870f7
...
@@ -197,6 +197,9 @@ SArray *mmGetMsgHandles() {
...
@@ -197,6 +197,9 @@ SArray *mmGetMsgHandles() {
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_HEARTBEAT
,
mmPutMsgToSyncCtrlQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_HEARTBEAT_REPLY
,
mmPutMsgToSyncCtrlQueue
,
1
)
==
NULL
)
goto
_OVER
;
code
=
0
;
code
=
0
;
_OVER:
_OVER:
...
...
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
浏览文件 @
b06870f7
...
@@ -67,6 +67,24 @@ static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
...
@@ -67,6 +67,24 @@ static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
taosFreeQitem
(
pMsg
);
taosFreeQitem
(
pMsg
);
}
}
static
void
mmProcessSyncCtrlMsg
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
SMnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
pMsg
->
info
.
node
=
pMgmt
->
pMnode
;
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
dGTrace
(
"msg:%p, get from mnode-sync-ctrl queue"
,
pMsg
);
SMsgHead
*
pHead
=
pMsg
->
pCont
;
pHead
->
contLen
=
ntohl
(
pHead
->
contLen
);
pHead
->
vgId
=
ntohl
(
pHead
->
vgId
);
int32_t
code
=
mndProcessSyncCtrlMsg
(
pMsg
);
dGTrace
(
"msg:%p, is freed, code:0x%x"
,
pMsg
,
code
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
static
void
mmProcessSyncMsg
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
static
void
mmProcessSyncMsg
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
SMnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
SMnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
pMsg
->
info
.
node
=
pMgmt
->
pMnode
;
pMsg
->
info
.
node
=
pMgmt
->
pMnode
;
...
@@ -108,6 +126,10 @@ int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
...
@@ -108,6 +126,10 @@ int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return
mmPutMsgToWorker
(
pMgmt
,
&
pMgmt
->
syncWorker
,
pMsg
);
return
mmPutMsgToWorker
(
pMgmt
,
&
pMgmt
->
syncWorker
,
pMsg
);
}
}
int32_t
mmPutMsgToSyncCtrlQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
mmPutMsgToWorker
(
pMgmt
,
&
pMgmt
->
syncCtrlWorker
,
pMsg
);
}
int32_t
mmPutMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
mmPutMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
mmPutMsgToWorker
(
pMgmt
,
&
pMgmt
->
readWorker
,
pMsg
);
return
mmPutMsgToWorker
(
pMgmt
,
&
pMgmt
->
readWorker
,
pMsg
);
}
}
...
@@ -144,6 +166,9 @@ int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
...
@@ -144,6 +166,9 @@ int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
case
SYNC_QUEUE
:
case
SYNC_QUEUE
:
pWorker
=
&
pMgmt
->
syncWorker
;
pWorker
=
&
pMgmt
->
syncWorker
;
break
;
break
;
case
SYNC_CTRL_QUEUE
:
pWorker
=
&
pMgmt
->
syncCtrlWorker
;
break
;
default:
default:
terrno
=
TSDB_CODE_INVALID_PARA
;
terrno
=
TSDB_CODE_INVALID_PARA
;
}
}
...
@@ -223,6 +248,18 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
...
@@ -223,6 +248,18 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
return
-
1
;
return
-
1
;
}
}
SSingleWorkerCfg
scCfg
=
{
.
min
=
1
,
.
max
=
1
,
.
name
=
"mnode-sync-ctrl"
,
.
fp
=
(
FItem
)
mmProcessSyncCtrlMsg
,
.
param
=
pMgmt
,
};
if
(
tSingleWorkerInit
(
&
pMgmt
->
syncCtrlWorker
,
&
scCfg
)
!=
0
)
{
dError
(
"failed to start mnode mnode-sync-ctrl worker since %s"
,
terrstr
());
return
-
1
;
}
dDebug
(
"mnode workers are initialized"
);
dDebug
(
"mnode workers are initialized"
);
return
0
;
return
0
;
}
}
...
@@ -235,5 +272,6 @@ void mmStopWorker(SMnodeMgmt *pMgmt) {
...
@@ -235,5 +272,6 @@ void mmStopWorker(SMnodeMgmt *pMgmt) {
tSingleWorkerCleanup
(
&
pMgmt
->
readWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
readWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
writeWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
writeWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
syncWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
syncWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
syncCtrlWorker
);
dDebug
(
"mnode workers are closed"
);
dDebug
(
"mnode workers are closed"
);
}
}
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
b06870f7
...
@@ -66,7 +66,7 @@ void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) {
...
@@ -66,7 +66,7 @@ void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) {
pInfo
->
vstat
.
totalVnodes
=
totalVnodes
;
pInfo
->
vstat
.
totalVnodes
=
totalVnodes
;
pInfo
->
vstat
.
masterNum
=
masterNum
;
pInfo
->
vstat
.
masterNum
=
masterNum
;
pInfo
->
vstat
.
numOfSelectReqs
=
numOfSelectReqs
-
pMgmt
->
state
.
numOfSelectReqs
;
pInfo
->
vstat
.
numOfSelectReqs
=
numOfSelectReqs
;
pInfo
->
vstat
.
numOfInsertReqs
=
numOfInsertReqs
;
// delta
pInfo
->
vstat
.
numOfInsertReqs
=
numOfInsertReqs
;
// delta
pInfo
->
vstat
.
numOfInsertSuccessReqs
=
numOfInsertSuccessReqs
;
// delta
pInfo
->
vstat
.
numOfInsertSuccessReqs
=
numOfInsertSuccessReqs
;
// delta
pInfo
->
vstat
.
numOfBatchInsertReqs
=
numOfBatchInsertReqs
;
// delta
pInfo
->
vstat
.
numOfBatchInsertReqs
=
numOfBatchInsertReqs
;
// delta
...
@@ -188,7 +188,7 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
...
@@ -188,7 +188,7 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
req
.
walRollPeriod
,
req
.
walSegmentSize
,
req
.
hashMethod
,
req
.
hashBegin
,
req
.
hashEnd
,
req
.
hashPrefix
,
req
.
walRollPeriod
,
req
.
walSegmentSize
,
req
.
hashMethod
,
req
.
hashBegin
,
req
.
hashEnd
,
req
.
hashPrefix
,
req
.
hashSuffix
,
req
.
replica
,
req
.
selfIndex
,
req
.
strict
);
req
.
hashSuffix
,
req
.
replica
,
req
.
selfIndex
,
req
.
strict
);
for
(
int32_t
i
=
0
;
i
<
req
.
replica
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
req
.
replica
;
++
i
)
{
dInfo
(
"vgId:%d, replica:%d
fqdn:%s port:%u"
,
req
.
vgId
,
req
.
replicas
[
i
].
id
,
req
.
replicas
[
i
].
fqdn
,
dInfo
(
"vgId:%d, replica:%d
id:%d fqdn:%s port:%u"
,
req
.
vgId
,
i
,
req
.
replicas
[
i
].
id
,
req
.
replicas
[
i
].
fqdn
,
req
.
replicas
[
i
].
port
);
req
.
replicas
[
i
].
port
);
}
}
vmGenerateVnodeCfg
(
&
req
,
&
vnodeCfg
);
vmGenerateVnodeCfg
(
&
req
,
&
vnodeCfg
);
...
@@ -273,7 +273,17 @@ int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
...
@@ -273,7 +273,17 @@ int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
}
}
int32_t
vgId
=
alterReq
.
vgId
;
int32_t
vgId
=
alterReq
.
vgId
;
dInfo
(
"vgId:%d, start to alter vnode replica"
,
alterReq
.
vgId
);
dInfo
(
"vgId:%d, start to alter vnode, replica:%d selfIndex:%d strict:%d"
,
alterReq
.
vgId
,
alterReq
.
replica
,
alterReq
.
selfIndex
,
alterReq
.
strict
);
for
(
int32_t
i
=
0
;
i
<
alterReq
.
replica
;
++
i
)
{
dInfo
(
"vgId:%d, replica:%d ep:%s:%u"
,
alterReq
.
vgId
,
i
,
alterReq
.
replicas
[
i
].
fqdn
,
alterReq
.
replicas
[
i
].
port
);
}
if
(
alterReq
.
replica
<=
0
||
alterReq
.
selfIndex
<
0
||
alterReq
.
selfIndex
>=
alterReq
.
replica
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
dError
(
"vgId:%d, failed to alter replica since invalid msg"
,
alterReq
.
vgId
);
return
-
1
;
}
SVnodeObj
*
pVnode
=
vmAcquireVnode
(
pMgmt
,
vgId
);
SVnodeObj
*
pVnode
=
vmAcquireVnode
(
pMgmt
,
vgId
);
if
(
pVnode
==
NULL
)
{
if
(
pVnode
==
NULL
)
{
...
...
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
b06870f7
...
@@ -241,6 +241,8 @@ static void *vmCloseVnodeInThread(void *param) {
...
@@ -241,6 +241,8 @@ static void *vmCloseVnodeInThread(void *param) {
static
void
vmCloseVnodes
(
SVnodeMgmt
*
pMgmt
)
{
static
void
vmCloseVnodes
(
SVnodeMgmt
*
pMgmt
)
{
dInfo
(
"start to close all vnodes"
);
dInfo
(
"start to close all vnodes"
);
tSingleWorkerCleanup
(
&
pMgmt
->
mgmtWorker
);
dInfo
(
"vnodes mgmt worker is stopped"
);
int32_t
numOfVnodes
=
0
;
int32_t
numOfVnodes
=
0
;
SVnodeObj
**
ppVnodes
=
vmGetVnodeListFromHash
(
pMgmt
,
&
numOfVnodes
);
SVnodeObj
**
ppVnodes
=
vmGetVnodeListFromHash
(
pMgmt
,
&
numOfVnodes
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
b06870f7
...
@@ -234,11 +234,9 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
...
@@ -234,11 +234,9 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
return
code
;
return
code
;
}
}
int32_t
vmPutMsgToSync
Queue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
SYNC
_QUEUE
);
}
int32_t
vmPutMsgToSync
CtrlQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
SYNC_CTRL
_QUEUE
);
}
int32_t
vmPutMsgToSyncCtrlQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
vmPutMsgToSyncQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
SYNC_QUEUE
);
}
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
SYNC_CTRL_QUEUE
);
}
int32_t
vmPutMsgToWriteQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
WRITE_QUEUE
);
}
int32_t
vmPutMsgToWriteQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
WRITE_QUEUE
);
}
...
@@ -405,7 +403,6 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) {
...
@@ -405,7 +403,6 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) {
}
}
void
vmStopWorker
(
SVnodeMgmt
*
pMgmt
)
{
void
vmStopWorker
(
SVnodeMgmt
*
pMgmt
)
{
tSingleWorkerCleanup
(
&
pMgmt
->
mgmtWorker
);
tWWorkerCleanup
(
&
pMgmt
->
writePool
);
tWWorkerCleanup
(
&
pMgmt
->
writePool
);
tWWorkerCleanup
(
&
pMgmt
->
applyPool
);
tWWorkerCleanup
(
&
pMgmt
->
applyPool
);
tWWorkerCleanup
(
&
pMgmt
->
syncPool
);
tWWorkerCleanup
(
&
pMgmt
->
syncPool
);
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
b06870f7
...
@@ -250,6 +250,7 @@ static int32_t mndInitSdb(SMnode *pMnode) {
...
@@ -250,6 +250,7 @@ static int32_t mndInitSdb(SMnode *pMnode) {
opt
.
path
=
pMnode
->
path
;
opt
.
path
=
pMnode
->
path
;
opt
.
pMnode
=
pMnode
;
opt
.
pMnode
=
pMnode
;
opt
.
pWal
=
pMnode
->
pWal
;
opt
.
pWal
=
pMnode
->
pWal
;
opt
.
sync
=
pMnode
->
syncMgmt
.
sync
;
pMnode
->
pSdb
=
sdbInit
(
&
opt
);
pMnode
->
pSdb
=
sdbInit
(
&
opt
);
if
(
pMnode
->
pSdb
==
NULL
)
{
if
(
pMnode
->
pSdb
==
NULL
)
{
...
@@ -381,6 +382,7 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
...
@@ -381,6 +382,7 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
mError
(
"failed to open mnode since %s"
,
terrstr
());
mError
(
"failed to open mnode since %s"
,
terrstr
());
return
NULL
;
return
NULL
;
}
}
memset
(
pMnode
,
0
,
sizeof
(
SMnode
));
char
timestr
[
24
]
=
"1970-01-01 00:00:00.00"
;
char
timestr
[
24
]
=
"1970-01-01 00:00:00.00"
;
(
void
)
taosParseTime
(
timestr
,
&
pMnode
->
checkTime
,
(
int32_t
)
strlen
(
timestr
),
TSDB_TIME_PRECISION_MILLI
,
0
);
(
void
)
taosParseTime
(
timestr
,
&
pMnode
->
checkTime
,
(
int32_t
)
strlen
(
timestr
),
TSDB_TIME_PRECISION_MILLI
,
0
);
...
@@ -474,6 +476,45 @@ void mndStop(SMnode *pMnode) {
...
@@ -474,6 +476,45 @@ void mndStop(SMnode *pMnode) {
mndCleanupTimer
(
pMnode
);
mndCleanupTimer
(
pMnode
);
}
}
int32_t
mndProcessSyncCtrlMsg
(
SRpcMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
int32_t
code
=
0
;
mInfo
(
"vgId:%d, process sync ctrl msg"
,
1
);
if
(
!
syncEnvIsStart
())
{
mError
(
"failed to process sync msg:%p type:%s since syncEnv stop"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
terrno
=
TSDB_CODE_SYN_INTERNAL_ERROR
;
return
-
1
;
}
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
pMgmt
->
sync
);
if
(
pSyncNode
==
NULL
)
{
mError
(
"failed to process sync msg:%p type:%s since syncNode is null"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
terrno
=
TSDB_CODE_SYN_INTERNAL_ERROR
;
return
-
1
;
}
if
(
pMsg
->
msgType
==
TDMT_SYNC_HEARTBEAT
)
{
SyncHeartbeat
*
pSyncMsg
=
syncHeartbeatFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnHeartbeat
(
pSyncNode
,
pSyncMsg
);
syncHeartbeatDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_HEARTBEAT_REPLY
)
{
SyncHeartbeatReply
*
pSyncMsg
=
syncHeartbeatReplyFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnHeartbeatReply
(
pSyncNode
,
pSyncMsg
);
syncHeartbeatReplyDestroy
(
pSyncMsg
);
}
syncNodeRelease
(
pSyncNode
);
if
(
code
!=
0
)
{
terrno
=
TSDB_CODE_SYN_INTERNAL_ERROR
;
}
return
code
;
}
int32_t
mndProcessSyncMsg
(
SRpcMsg
*
pMsg
)
{
int32_t
mndProcessSyncMsg
(
SRpcMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
...
@@ -492,89 +533,64 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
...
@@ -492,89 +533,64 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
// ToDo: ugly! use function pointer
if
(
pMsg
->
msgType
==
TDMT_SYNC_TIMEOUT
)
{
if
(
syncNodeStrategy
(
pSyncNode
)
==
SYNC_STRATEGY_STANDARD_SNAPSHOT
)
{
SyncTimeout
*
pSyncMsg
=
syncTimeoutFromRpcMsg2
(
pMsg
);
if
(
pMsg
->
msgType
==
TDMT_SYNC_TIMEOUT
)
{
code
=
syncNodeOnTimer
(
pSyncNode
,
pSyncMsg
);
SyncTimeout
*
pSyncMsg
=
syncTimeoutFromRpcMsg2
(
pMsg
);
syncTimeoutDestroy
(
pSyncMsg
);
code
=
syncNodeOnTimeoutCb
(
pSyncNode
,
pSyncMsg
);
syncTimeoutDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_PING
)
{
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_PING
)
{
SyncPing
*
pSyncMsg
=
syncPingFromRpcMsg2
(
pMsg
);
SyncPing
*
pSyncMsg
=
syncPingFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnPingCb
(
pSyncNode
,
pSyncMsg
);
code
=
syncNodeOnPingCb
(
pSyncNode
,
pSyncMsg
);
syncPingDestroy
(
pSyncMsg
);
syncPingDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_PING_REPLY
)
{
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_PING_REPLY
)
{
SyncPingReply
*
pSyncMsg
=
syncPingReplyFromRpcMsg2
(
pMsg
);
SyncPingReply
*
pSyncMsg
=
syncPingReplyFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnPingReplyCb
(
pSyncNode
,
pSyncMsg
);
code
=
syncNodeOnPingReplyCb
(
pSyncNode
,
pSyncMsg
);
syncPingReplyDestroy
(
pSyncMsg
);
syncPingReplyDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_CLIENT_REQUEST
)
{
SyncClientRequest
*
pSyncMsg
=
syncClientRequestFromRpcMsg2
(
pMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_CLIENT_REQUEST
)
{
code
=
syncNodeOnClientRequestCb
(
pSyncNode
,
pSyncMsg
,
NULL
);
SyncClientRequest
*
pSyncMsg
=
syncClientRequestFromRpcMsg2
(
pMsg
);
syncClientRequestDestroy
(
pSyncMsg
);
code
=
syncNodeOnClientRequest
(
pSyncNode
,
pSyncMsg
,
NULL
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_REQUEST_VOTE
)
{
syncClientRequestDestroy
(
pSyncMsg
);
SyncRequestVote
*
pSyncMsg
=
syncRequestVoteFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnRequestVoteSnapshotCb
(
pSyncNode
,
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_REQUEST_VOTE
)
{
syncRequestVoteDestroy
(
pSyncMsg
);
SyncRequestVote
*
pSyncMsg
=
syncRequestVoteFromRpcMsg2
(
pMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_REQUEST_VOTE_REPLY
)
{
code
=
syncNodeOnRequestVote
(
pSyncNode
,
pSyncMsg
);
SyncRequestVoteReply
*
pSyncMsg
=
syncRequestVoteReplyFromRpcMsg2
(
pMsg
);
syncRequestVoteDestroy
(
pSyncMsg
);
code
=
syncNodeOnRequestVoteReplySnapshotCb
(
pSyncNode
,
pSyncMsg
);
syncRequestVoteReplyDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_REQUEST_VOTE_REPLY
)
{
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_APPEND_ENTRIES
)
{
SyncRequestVoteReply
*
pSyncMsg
=
syncRequestVoteReplyFromRpcMsg2
(
pMsg
);
SyncAppendEntries
*
pSyncMsg
=
syncAppendEntriesFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnRequestVoteReply
(
pSyncNode
,
pSyncMsg
);
code
=
syncNodeOnAppendEntriesSnapshotCb
(
pSyncNode
,
pSyncMsg
);
syncRequestVoteReplyDestroy
(
pSyncMsg
);
syncAppendEntriesDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_APPEND_ENTRIES_REPLY
)
{
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_APPEND_ENTRIES
)
{
SyncAppendEntriesReply
*
pSyncMsg
=
syncAppendEntriesReplyFromRpcMsg2
(
pMsg
);
SyncAppendEntries
*
pSyncMsg
=
syncAppendEntriesFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnAppendEntriesReplySnapshotCb
(
pSyncNode
,
pSyncMsg
);
code
=
syncNodeOnAppendEntries
(
pSyncNode
,
pSyncMsg
);
syncAppendEntriesReplyDestroy
(
pSyncMsg
);
syncAppendEntriesDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_SNAPSHOT_SEND
)
{
SyncSnapshotSend
*
pSyncMsg
=
syncSnapshotSendFromRpcMsg2
(
pMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_APPEND_ENTRIES_REPLY
)
{
code
=
syncNodeOnSnapshotSendCb
(
pSyncNode
,
pSyncMsg
);
SyncAppendEntriesReply
*
pSyncMsg
=
syncAppendEntriesReplyFromRpcMsg2
(
pMsg
);
syncSnapshotSendDestroy
(
pSyncMsg
);
code
=
syncNodeOnAppendEntriesReply
(
pSyncNode
,
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_SNAPSHOT_RSP
)
{
syncAppendEntriesReplyDestroy
(
pSyncMsg
);
SyncSnapshotRsp
*
pSyncMsg
=
syncSnapshotRspFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnSnapshotRspCb
(
pSyncNode
,
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_SNAPSHOT_SEND
)
{
syncSnapshotRspDestroy
(
pSyncMsg
);
SyncSnapshotSend
*
pSyncMsg
=
syncSnapshotSendFromRpcMsg2
(
pMsg
);
}
else
{
code
=
syncNodeOnSnapshot
(
pSyncNode
,
pSyncMsg
);
mError
(
"failed to process msg:%p since invalid type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
syncSnapshotSendDestroy
(
pSyncMsg
);
code
=
-
1
;
}
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_SNAPSHOT_RSP
)
{
SyncSnapshotRsp
*
pSyncMsg
=
syncSnapshotRspFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnSnapshotReply
(
pSyncNode
,
pSyncMsg
);
syncSnapshotRspDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_SET_MNODE_STANDBY
)
{
code
=
syncSetStandby
(
pMgmt
->
sync
);
SRpcMsg
rsp
=
{.
code
=
code
,
.
info
=
pMsg
->
info
};
tmsgSendRsp
(
&
rsp
);
}
else
{
}
else
{
if
(
pMsg
->
msgType
==
TDMT_SYNC_TIMEOUT
)
{
mError
(
"failed to process msg:%p since invalid type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
SyncTimeout
*
pSyncMsg
=
syncTimeoutFromRpcMsg2
(
pMsg
);
code
=
-
1
;
code
=
syncNodeOnTimeoutCb
(
pSyncNode
,
pSyncMsg
);
syncTimeoutDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_PING
)
{
SyncPing
*
pSyncMsg
=
syncPingFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnPingCb
(
pSyncNode
,
pSyncMsg
);
syncPingDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_PING_REPLY
)
{
SyncPingReply
*
pSyncMsg
=
syncPingReplyFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnPingReplyCb
(
pSyncNode
,
pSyncMsg
);
syncPingReplyDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_CLIENT_REQUEST
)
{
SyncClientRequest
*
pSyncMsg
=
syncClientRequestFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnClientRequestCb
(
pSyncNode
,
pSyncMsg
,
NULL
);
syncClientRequestDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_REQUEST_VOTE
)
{
SyncRequestVote
*
pSyncMsg
=
syncRequestVoteFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnRequestVoteCb
(
pSyncNode
,
pSyncMsg
);
syncRequestVoteDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_REQUEST_VOTE_REPLY
)
{
SyncRequestVoteReply
*
pSyncMsg
=
syncRequestVoteReplyFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnRequestVoteReplyCb
(
pSyncNode
,
pSyncMsg
);
syncRequestVoteReplyDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_APPEND_ENTRIES
)
{
SyncAppendEntries
*
pSyncMsg
=
syncAppendEntriesFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnAppendEntriesCb
(
pSyncNode
,
pSyncMsg
);
syncAppendEntriesDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_APPEND_ENTRIES_REPLY
)
{
SyncAppendEntriesReply
*
pSyncMsg
=
syncAppendEntriesReplyFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnAppendEntriesReplyCb
(
pSyncNode
,
pSyncMsg
);
syncAppendEntriesReplyDestroy
(
pSyncMsg
);
}
else
{
mError
(
"failed to process msg:%p since invalid type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
code
=
-
1
;
}
}
}
syncNodeRelease
(
pSyncNode
);
syncNodeRelease
(
pSyncNode
);
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
b06870f7
...
@@ -71,8 +71,8 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM
...
@@ -71,8 +71,8 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM
mInfo
(
"trans:%d, is proposed and post sem"
,
transId
);
mInfo
(
"trans:%d, is proposed and post sem"
,
transId
);
}
}
pMgmt
->
transId
=
0
;
pMgmt
->
transId
=
0
;
taosWUnLockLatch
(
&
pMgmt
->
lock
);
tsem_post
(
&
pMgmt
->
syncSem
);
tsem_post
(
&
pMgmt
->
syncSem
);
taosWUnLockLatch
(
&
pMgmt
->
lock
);
}
else
{
}
else
{
taosWUnLockLatch
(
&
pMgmt
->
lock
);
taosWUnLockLatch
(
&
pMgmt
->
lock
);
STrans
*
pTrans
=
mndAcquireTrans
(
pMnode
,
transId
);
STrans
*
pTrans
=
mndAcquireTrans
(
pMnode
,
transId
);
...
@@ -113,27 +113,7 @@ void mndRestoreFinish(struct SSyncFSM *pFsm) {
...
@@ -113,27 +113,7 @@ void mndRestoreFinish(struct SSyncFSM *pFsm) {
}
}
}
}
void
mndReConfig
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SReConfigCbMeta
*
cbMeta
)
{
void
mndReConfig
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SReConfigCbMeta
*
cbMeta
)
{}
SMnode
*
pMnode
=
pFsm
->
data
;
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
pMgmt
->
errCode
=
cbMeta
->
code
;
mInfo
(
"trans:-1, sync reconfig is proposed, saved:%d code:0x%x, index:%"
PRId64
" term:%"
PRId64
,
pMgmt
->
transId
,
cbMeta
->
code
,
cbMeta
->
index
,
cbMeta
->
term
);
taosWLockLatch
(
&
pMgmt
->
lock
);
if
(
pMgmt
->
transId
==
-
1
)
{
if
(
pMgmt
->
errCode
!=
0
)
{
mError
(
"trans:-1, failed to propose sync reconfig since %s, post sem"
,
tstrerror
(
pMgmt
->
errCode
));
}
else
{
mInfo
(
"trans:-1, sync reconfig is proposed, saved:%d code:0x%x, index:%"
PRId64
" term:%"
PRId64
" post sem"
,
pMgmt
->
transId
,
cbMeta
->
code
,
cbMeta
->
index
,
cbMeta
->
term
);
}
pMgmt
->
transId
=
0
;
tsem_post
(
&
pMgmt
->
syncSem
);
}
taosWUnLockLatch
(
&
pMgmt
->
lock
);
}
int32_t
mndSnapshotStartRead
(
struct
SSyncFSM
*
pFsm
,
void
*
pParam
,
void
**
ppReader
)
{
int32_t
mndSnapshotStartRead
(
struct
SSyncFSM
*
pFsm
,
void
*
pParam
,
void
**
ppReader
)
{
mInfo
(
"start to read snapshot from sdb"
);
mInfo
(
"start to read snapshot from sdb"
);
...
@@ -179,11 +159,14 @@ void mndLeaderTransfer(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cb
...
@@ -179,11 +159,14 @@ void mndLeaderTransfer(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cb
static
void
mndBecomeFollower
(
struct
SSyncFSM
*
pFsm
)
{
static
void
mndBecomeFollower
(
struct
SSyncFSM
*
pFsm
)
{
SMnode
*
pMnode
=
pFsm
->
data
;
SMnode
*
pMnode
=
pFsm
->
data
;
mInfo
(
"vgId:1, become follower
and post sem
"
);
mInfo
(
"vgId:1, become follower"
);
taosWLockLatch
(
&
pMnode
->
syncMgmt
.
lock
);
taosWLockLatch
(
&
pMnode
->
syncMgmt
.
lock
);
if
(
pMnode
->
syncMgmt
.
transId
!=
0
)
{
if
(
pMnode
->
syncMgmt
.
transId
!=
0
)
{
mInfo
(
"vgId:1, become follower and post sem, trans:%d, failed to propose since not leader"
,
pMnode
->
syncMgmt
.
transId
);
pMnode
->
syncMgmt
.
transId
=
0
;
pMnode
->
syncMgmt
.
transId
=
0
;
pMnode
->
syncMgmt
.
errCode
=
TSDB_CODE_SYN_NOT_LEADER
;
tsem_post
(
&
pMnode
->
syncMgmt
.
syncSem
);
tsem_post
(
&
pMnode
->
syncMgmt
.
syncSem
);
}
}
taosWUnLockLatch
(
&
pMnode
->
syncMgmt
.
lock
);
taosWUnLockLatch
(
&
pMnode
->
syncMgmt
.
lock
);
...
@@ -221,13 +204,21 @@ int32_t mndInitSync(SMnode *pMnode) {
...
@@ -221,13 +204,21 @@ int32_t mndInitSync(SMnode *pMnode) {
taosInitRWLatch
(
&
pMgmt
->
lock
);
taosInitRWLatch
(
&
pMgmt
->
lock
);
pMgmt
->
transId
=
0
;
pMgmt
->
transId
=
0
;
SSyncInfo
syncInfo
=
{.
vgId
=
1
,
.
FpSendMsg
=
mndSyncSendMsg
,
.
FpEqMsg
=
mndSyncEqMsg
};
SSyncInfo
syncInfo
=
{
.
snapshotStrategy
=
SYNC_STRATEGY_STANDARD_SNAPSHOT
,
.
batchSize
=
1
,
.
vgId
=
1
,
.
pWal
=
pMnode
->
pWal
,
.
msgcb
=
NULL
,
.
FpSendMsg
=
mndSyncSendMsg
,
.
FpEqMsg
=
mndSyncEqMsg
,
.
FpEqCtrlMsg
=
NULL
,
};
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s%ssync"
,
pMnode
->
path
,
TD_DIRSEP
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s%ssync"
,
pMnode
->
path
,
TD_DIRSEP
);
syncInfo
.
pWal
=
pMnode
->
pWal
;
syncInfo
.
pFsm
=
mndSyncMakeFsm
(
pMnode
);
syncInfo
.
pFsm
=
mndSyncMakeFsm
(
pMnode
);
syncInfo
.
snapshotStrategy
=
SYNC_STRATEGY_STANDARD_SNAPSHOT
;
mInfo
(
"vgId:1, start to open sync,
selfIndex:%d replica:%d"
,
pMgmt
->
selfIndex
,
pMgmt
->
numOfReplicas
);
mInfo
(
"vgId:1, start to open sync,
replica:%d selfIndex:%d"
,
pMgmt
->
numOfReplicas
,
pMgmt
->
selfIndex
);
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
pCfg
->
replicaNum
=
pMgmt
->
numOfReplicas
;
pCfg
->
replicaNum
=
pMgmt
->
numOfReplicas
;
pCfg
->
myIndex
=
pMgmt
->
selfIndex
;
pCfg
->
myIndex
=
pMgmt
->
selfIndex
;
...
@@ -292,6 +283,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
...
@@ -292,6 +283,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
int32_t
code
=
syncPropose
(
pMgmt
->
sync
,
&
req
,
isWeak
);
int32_t
code
=
syncPropose
(
pMgmt
->
sync
,
&
req
,
isWeak
);
if
(
code
==
0
)
{
if
(
code
==
0
)
{
mInfo
(
"trans:%d, is proposing and wait sem"
,
pMgmt
->
transId
);
tsem_wait
(
&
pMgmt
->
syncSem
);
tsem_wait
(
&
pMgmt
->
syncSem
);
}
else
if
(
code
>
0
)
{
}
else
if
(
code
>
0
)
{
mInfo
(
"trans:%d, confirm at once since replica is 1, continue execute"
,
transId
);
mInfo
(
"trans:%d, confirm at once since replica is 1, continue execute"
,
transId
);
...
@@ -301,12 +293,16 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
...
@@ -301,12 +293,16 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
sdbWriteWithoutFree
(
pMnode
->
pSdb
,
pRaw
);
sdbWriteWithoutFree
(
pMnode
->
pSdb
,
pRaw
);
sdbSetApplyInfo
(
pMnode
->
pSdb
,
req
.
info
.
conn
.
applyIndex
,
req
.
info
.
conn
.
applyTerm
,
SYNC_INDEX_INVALID
);
sdbSetApplyInfo
(
pMnode
->
pSdb
,
req
.
info
.
conn
.
applyIndex
,
req
.
info
.
conn
.
applyTerm
,
SYNC_INDEX_INVALID
);
code
=
0
;
code
=
0
;
}
else
if
(
code
==
-
1
&&
terrno
==
TSDB_CODE_SYN_NOT_LEADER
)
{
terrno
=
TSDB_CODE_APP_NOT_READY
;
}
else
if
(
code
==
-
1
&&
terrno
==
TSDB_CODE_SYN_INTERNAL_ERROR
)
{
terrno
=
TSDB_CODE_SYN_INTERNAL_ERROR
;
}
else
{
}
else
{
terrno
=
TSDB_CODE_APP_ERROR
;
taosWLockLatch
(
&
pMgmt
->
lock
);
mInfo
(
"trans:%d, failed to proposed since %s"
,
transId
,
terrstr
());
pMgmt
->
transId
=
0
;
taosWUnLockLatch
(
&
pMgmt
->
lock
);
if
(
terrno
==
TSDB_CODE_SYN_NOT_LEADER
)
{
terrno
=
TSDB_CODE_APP_NOT_READY
;
}
else
{
terrno
=
TSDB_CODE_APP_ERROR
;
}
}
}
rpcFreeCont
(
req
.
pCont
);
rpcFreeCont
(
req
.
pCont
);
...
@@ -315,6 +311,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
...
@@ -315,6 +311,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
return
code
;
return
code
;
}
}
if
(
pMgmt
->
errCode
!=
0
)
terrno
=
pMgmt
->
errCode
;
return
pMgmt
->
errCode
;
return
pMgmt
->
errCode
;
}
}
...
@@ -328,6 +325,7 @@ void mndSyncStart(SMnode *pMnode) {
...
@@ -328,6 +325,7 @@ void mndSyncStart(SMnode *pMnode) {
void
mndSyncStop
(
SMnode
*
pMnode
)
{
void
mndSyncStop
(
SMnode
*
pMnode
)
{
taosWLockLatch
(
&
pMnode
->
syncMgmt
.
lock
);
taosWLockLatch
(
&
pMnode
->
syncMgmt
.
lock
);
if
(
pMnode
->
syncMgmt
.
transId
!=
0
)
{
if
(
pMnode
->
syncMgmt
.
transId
!=
0
)
{
mInfo
(
"vgId:1, is stopped and post sem, trans:%d"
,
pMnode
->
syncMgmt
.
transId
);
pMnode
->
syncMgmt
.
transId
=
0
;
pMnode
->
syncMgmt
.
transId
=
0
;
tsem_post
(
&
pMnode
->
syncMgmt
.
syncSem
);
tsem_post
(
&
pMnode
->
syncMgmt
.
syncSem
);
}
}
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
b06870f7
...
@@ -778,7 +778,7 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
...
@@ -778,7 +778,7 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
mInfo
(
"trans:%d, sync to other mnodes, stage:%s"
,
pTrans
->
id
,
mndTransStr
(
pTrans
->
stage
));
mInfo
(
"trans:%d, sync to other mnodes, stage:%s"
,
pTrans
->
id
,
mndTransStr
(
pTrans
->
stage
));
int32_t
code
=
mndSyncPropose
(
pMnode
,
pRaw
,
pTrans
->
id
);
int32_t
code
=
mndSyncPropose
(
pMnode
,
pRaw
,
pTrans
->
id
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to sync
since %s"
,
pTrans
->
id
,
terrstr
(
));
mError
(
"trans:%d, failed to sync
, errno:%s code:%s"
,
pTrans
->
id
,
terrstr
(),
tstrerror
(
code
));
sdbFreeRaw
(
pRaw
);
sdbFreeRaw
(
pRaw
);
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
b06870f7
...
@@ -341,6 +341,12 @@ static void *mndBuildAlterVnodeReplicaReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p
...
@@ -341,6 +341,12 @@ static void *mndBuildAlterVnodeReplicaReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p
alterReq
.
selfIndex
=
v
;
alterReq
.
selfIndex
=
v
;
}
}
}
}
alterReq
.
replica
=
pVgroup
->
replica
;
mInfo
(
"vgId:%d, start to alter vnode, replica:%d selfIndex:%d strict:%d"
,
alterReq
.
vgId
,
alterReq
.
replica
,
alterReq
.
selfIndex
,
alterReq
.
strict
);
for
(
int32_t
i
=
0
;
i
<
alterReq
.
replica
;
++
i
)
{
mInfo
(
"vgId:%d, replica:%d ep:%s:%u"
,
alterReq
.
vgId
,
i
,
alterReq
.
replicas
[
i
].
fqdn
,
alterReq
.
replicas
[
i
].
port
);
}
if
(
alterReq
.
selfIndex
==
-
1
)
{
if
(
alterReq
.
selfIndex
==
-
1
)
{
terrno
=
TSDB_CODE_MND_APP_ERROR
;
terrno
=
TSDB_CODE_MND_APP_ERROR
;
...
@@ -1580,10 +1586,11 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb
...
@@ -1580,10 +1586,11 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb
if
(
mndAddVnodeToVgroup
(
pMnode
,
&
newVgroup
,
pArray
)
!=
0
)
return
-
1
;
if
(
mndAddVnodeToVgroup
(
pMnode
,
&
newVgroup
,
pArray
)
!=
0
)
return
-
1
;
if
(
mndAddVnodeToVgroup
(
pMnode
,
&
newVgroup
,
pArray
)
!=
0
)
return
-
1
;
if
(
mndAddVnodeToVgroup
(
pMnode
,
&
newVgroup
,
pArray
)
!=
0
)
return
-
1
;
if
(
mndAddCreateVnodeAction
(
pMnode
,
pTrans
,
pNewDb
,
&
newVgroup
,
&
newVgroup
.
vnodeGid
[
1
])
!=
0
)
return
-
1
;
if
(
mndAddCreateVnodeAction
(
pMnode
,
pTrans
,
pNewDb
,
&
newVgroup
,
&
newVgroup
.
vnodeGid
[
1
])
!=
0
)
return
-
1
;
if
(
mndAddCreateVnodeAction
(
pMnode
,
pTrans
,
pNewDb
,
&
newVgroup
,
&
newVgroup
.
vnodeGid
[
2
])
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeReplicaAction
(
pMnode
,
pTrans
,
pNewDb
,
&
newVgroup
,
newVgroup
.
vnodeGid
[
0
].
dnodeId
)
!=
0
)
if
(
mndAddAlterVnodeReplicaAction
(
pMnode
,
pTrans
,
pNewDb
,
&
newVgroup
,
newVgroup
.
vnodeGid
[
0
].
dnodeId
)
!=
0
)
return
-
1
;
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pNewDb
,
&
newVgroup
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pNewDb
,
&
newVgroup
)
!=
0
)
return
-
1
;
if
(
mndAddCreateVnodeAction
(
pMnode
,
pTrans
,
pNewDb
,
&
newVgroup
,
&
newVgroup
.
vnodeGid
[
2
])
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pNewDb
,
&
newVgroup
)
!=
0
)
return
-
1
;
}
else
if
(
newVgroup
.
replica
==
3
&&
pNewDb
->
cfg
.
replications
==
1
)
{
}
else
if
(
newVgroup
.
replica
==
3
&&
pNewDb
->
cfg
.
replications
==
1
)
{
mInfo
(
"db:%s, vgId:%d, will remove 2 vnodes, vn:0 dnode:%d vn:1 dnode:%d vn:2 dnode:%d"
,
pVgroup
->
dbName
,
mInfo
(
"db:%s, vgId:%d, will remove 2 vnodes, vn:0 dnode:%d vn:1 dnode:%d vn:2 dnode:%d"
,
pVgroup
->
dbName
,
pVgroup
->
vgId
,
pVgroup
->
vnodeGid
[
0
].
dnodeId
,
pVgroup
->
vnodeGid
[
1
].
dnodeId
,
pVgroup
->
vnodeGid
[
2
].
dnodeId
);
pVgroup
->
vgId
,
pVgroup
->
vnodeGid
[
0
].
dnodeId
,
pVgroup
->
vnodeGid
[
1
].
dnodeId
,
pVgroup
->
vnodeGid
[
2
].
dnodeId
);
...
@@ -1593,6 +1600,7 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb
...
@@ -1593,6 +1600,7 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb
if
(
mndRemoveVnodeFromVgroup
(
pMnode
,
&
newVgroup
,
pArray
,
&
del1
)
!=
0
)
return
-
1
;
if
(
mndRemoveVnodeFromVgroup
(
pMnode
,
&
newVgroup
,
pArray
,
&
del1
)
!=
0
)
return
-
1
;
if
(
mndRemoveVnodeFromVgroup
(
pMnode
,
&
newVgroup
,
pArray
,
&
del2
)
!=
0
)
return
-
1
;
if
(
mndRemoveVnodeFromVgroup
(
pMnode
,
&
newVgroup
,
pArray
,
&
del2
)
!=
0
)
return
-
1
;
if
(
mndAddDropVnodeAction
(
pMnode
,
pTrans
,
pNewDb
,
&
newVgroup
,
&
del1
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddDropVnodeAction
(
pMnode
,
pTrans
,
pNewDb
,
&
newVgroup
,
&
del1
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pNewDb
,
&
newVgroup
)
!=
0
)
return
-
1
;
if
(
mndAddDropVnodeAction
(
pMnode
,
pTrans
,
pNewDb
,
&
newVgroup
,
&
del2
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddDropVnodeAction
(
pMnode
,
pTrans
,
pNewDb
,
&
newVgroup
,
&
del2
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeReplicaAction
(
pMnode
,
pTrans
,
pNewDb
,
&
newVgroup
,
newVgroup
.
vnodeGid
[
0
].
dnodeId
)
!=
0
)
if
(
mndAddAlterVnodeReplicaAction
(
pMnode
,
pTrans
,
pNewDb
,
&
newVgroup
,
newVgroup
.
vnodeGid
[
0
].
dnodeId
)
!=
0
)
return
-
1
;
return
-
1
;
...
...
source/dnode/mnode/impl/test/CMakeLists.txt
浏览文件 @
b06870f7
enable_testing
()
enable_testing
()
add_subdirectory
(
acct
)
add_subdirectory
(
acct
)
add_subdirectory
(
db
)
#
add_subdirectory(db)
#add_subdirectory(dnode)
#add_subdirectory(dnode)
add_subdirectory
(
func
)
add_subdirectory
(
func
)
#add_subdirectory(mnode)
#add_subdirectory(mnode)
...
@@ -14,4 +14,4 @@ add_subdirectory(snode)
...
@@ -14,4 +14,4 @@ add_subdirectory(snode)
add_subdirectory
(
stb
)
add_subdirectory
(
stb
)
add_subdirectory
(
topic
)
add_subdirectory
(
topic
)
add_subdirectory
(
trans
)
add_subdirectory
(
trans
)
add_subdirectory
(
user
)
#
add_subdirectory(user)
source/dnode/mnode/impl/test/user/CMakeLists.txt
浏览文件 @
b06870f7
...
@@ -5,7 +5,8 @@ target_link_libraries(
...
@@ -5,7 +5,8 @@ target_link_libraries(
PUBLIC sut
PUBLIC sut
)
)
add_test
(
NAME userTest
#add_test(
COMMAND userTest
# NAME userTest
)
# COMMAND userTest
#)
source/dnode/mnode/sdb/CMakeLists.txt
浏览文件 @
b06870f7
...
@@ -5,5 +5,5 @@ target_include_directories(
...
@@ -5,5 +5,5 @@ target_include_directories(
PUBLIC
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
PUBLIC
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
)
target_link_libraries
(
target_link_libraries
(
sdb os common util wal
sdb os common util wal sync
)
)
\ No newline at end of file
source/dnode/mnode/sdb/inc/sdb.h
浏览文件 @
b06870f7
...
@@ -169,6 +169,7 @@ typedef struct SSdbRow {
...
@@ -169,6 +169,7 @@ typedef struct SSdbRow {
typedef
struct
SSdb
{
typedef
struct
SSdb
{
SMnode
*
pMnode
;
SMnode
*
pMnode
;
SWal
*
pWal
;
SWal
*
pWal
;
int64_t
sync
;
char
*
currDir
;
char
*
currDir
;
char
*
tmpDir
;
char
*
tmpDir
;
int64_t
commitIndex
;
int64_t
commitIndex
;
...
@@ -212,6 +213,7 @@ typedef struct SSdbOpt {
...
@@ -212,6 +213,7 @@ typedef struct SSdbOpt {
const
char
*
path
;
const
char
*
path
;
SMnode
*
pMnode
;
SMnode
*
pMnode
;
SWal
*
pWal
;
SWal
*
pWal
;
int64_t
sync
;
}
SSdbOpt
;
}
SSdbOpt
;
/**
/**
...
...
source/dnode/mnode/sdb/src/sdb.c
浏览文件 @
b06870f7
...
@@ -53,6 +53,7 @@ SSdb *sdbInit(SSdbOpt *pOption) {
...
@@ -53,6 +53,7 @@ SSdb *sdbInit(SSdbOpt *pOption) {
}
}
pSdb
->
pWal
=
pOption
->
pWal
;
pSdb
->
pWal
=
pOption
->
pWal
;
pSdb
->
sync
=
pOption
->
sync
;
pSdb
->
applyIndex
=
-
1
;
pSdb
->
applyIndex
=
-
1
;
pSdb
->
applyTerm
=
-
1
;
pSdb
->
applyTerm
=
-
1
;
pSdb
->
applyConfig
=
-
1
;
pSdb
->
applyConfig
=
-
1
;
...
...
source/dnode/mnode/sdb/src/sdbFile.c
浏览文件 @
b06870f7
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "sdb.h"
#include "sdb.h"
#include "sync.h"
#include "tchecksum.h"
#include "tchecksum.h"
#include "wal.h"
#include "wal.h"
...
@@ -456,14 +457,25 @@ int32_t sdbWriteFile(SSdb *pSdb, int32_t delta) {
...
@@ -456,14 +457,25 @@ int32_t sdbWriteFile(SSdb *pSdb, int32_t delta) {
taosThreadMutexLock
(
&
pSdb
->
filelock
);
taosThreadMutexLock
(
&
pSdb
->
filelock
);
if
(
pSdb
->
pWal
!=
NULL
)
{
if
(
pSdb
->
pWal
!=
NULL
)
{
code
=
walBeginSnapshot
(
pSdb
->
pWal
,
pSdb
->
applyIndex
);
// code = walBeginSnapshot(pSdb->pWal, pSdb->applyIndex);
if
(
pSdb
->
sync
==
0
)
{
code
=
0
;
}
else
{
code
=
syncBeginSnapshot
(
pSdb
->
sync
,
pSdb
->
applyIndex
);
}
}
}
if
(
code
==
0
)
{
if
(
code
==
0
)
{
code
=
sdbWriteFileImp
(
pSdb
);
code
=
sdbWriteFileImp
(
pSdb
);
}
}
if
(
code
==
0
)
{
if
(
code
==
0
)
{
if
(
pSdb
->
pWal
!=
NULL
)
{
if
(
pSdb
->
pWal
!=
NULL
)
{
code
=
walEndSnapshot
(
pSdb
->
pWal
);
// code = walEndSnapshot(pSdb->pWal);
if
(
pSdb
->
sync
==
0
)
{
code
=
0
;
}
else
{
code
=
syncEndSnapshot
(
pSdb
->
sync
);
}
}
}
}
}
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
b06870f7
...
@@ -120,7 +120,11 @@ typedef struct SMetaFltParam {
...
@@ -120,7 +120,11 @@ typedef struct SMetaFltParam {
}
SMetaFltParam
;
}
SMetaFltParam
;
// TODO, refactor later
int32_t
metaFilterTableIds
(
SMeta
*
pMeta
,
SMetaFltParam
*
param
,
SArray
*
results
);
int32_t
metaFilterTableIds
(
SMeta
*
pMeta
,
SMetaFltParam
*
param
,
SArray
*
results
);
int32_t
metaFilterCreateTime
(
SMeta
*
pMeta
,
SMetaFltParam
*
parm
,
SArray
*
pUids
);
int32_t
metaFilterTableName
(
SMeta
*
pMeta
,
SMetaFltParam
*
param
,
SArray
*
pUids
);
int32_t
metaFilterTtl
(
SMeta
*
pMeta
,
SMetaFltParam
*
param
,
SArray
*
pUids
);
#if 1 // refact APIs below (TODO)
#if 1 // refact APIs below (TODO)
typedef
SVCreateTbReq
STbCfg
;
typedef
SVCreateTbReq
STbCfg
;
...
...
source/dnode/vnode/src/inc/meta.h
浏览文件 @
b06870f7
...
@@ -86,8 +86,12 @@ struct SMeta {
...
@@ -86,8 +86,12 @@ struct SMeta {
TTB
*
pSuidIdx
;
TTB
*
pSuidIdx
;
// ivt idx and idx
// ivt idx and idx
void
*
pTagIvtIdx
;
void
*
pTagIvtIdx
;
TTB
*
pTagIdx
;
TTB
*
pTtlIdx
;
TTB
*
pTagIdx
;
TTB
*
pTtlIdx
;
TTB
*
pCtimeIdx
;
// table created time idx
TTB
*
pNcolIdx
;
// ncol of table idx, normal table only
TTB
*
pSmaIdx
;
TTB
*
pSmaIdx
;
...
@@ -142,6 +146,16 @@ typedef struct {
...
@@ -142,6 +146,16 @@ typedef struct {
int64_t
smaUid
;
int64_t
smaUid
;
}
SSmaIdxKey
;
}
SSmaIdxKey
;
typedef
struct
{
int64_t
ctime
;
tb_uid_t
uid
;
}
SCtimeIdxKey
;
typedef
struct
{
int64_t
ncol
;
tb_uid_t
uid
;
}
SNcolIdxKey
;
// metaTable ==================
// metaTable ==================
int
metaCreateTagIdxKey
(
tb_uid_t
suid
,
int32_t
cid
,
const
void
*
pTagData
,
int32_t
nTagData
,
int8_t
type
,
tb_uid_t
uid
,
int
metaCreateTagIdxKey
(
tb_uid_t
suid
,
int32_t
cid
,
const
void
*
pTagData
,
int32_t
nTagData
,
int8_t
type
,
tb_uid_t
uid
,
STagIdxKey
**
ppTagIdxKey
,
int32_t
*
nTagIdxKey
);
STagIdxKey
**
ppTagIdxKey
,
int32_t
*
nTagIdxKey
);
...
...
source/dnode/vnode/src/meta/metaOpen.c
浏览文件 @
b06870f7
...
@@ -24,6 +24,9 @@ static int uidIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kL
...
@@ -24,6 +24,9 @@ static int uidIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kL
static
int
smaIdxKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
);
static
int
smaIdxKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
);
static
int
taskIdxKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
);
static
int
taskIdxKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
);
static
int
ctimeIdxCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
);
static
int
ncolIdxCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
);
static
int32_t
metaInitLock
(
SMeta
*
pMeta
)
{
return
taosThreadRwlockInit
(
&
pMeta
->
lock
,
NULL
);
}
static
int32_t
metaInitLock
(
SMeta
*
pMeta
)
{
return
taosThreadRwlockInit
(
&
pMeta
->
lock
,
NULL
);
}
static
int32_t
metaDestroyLock
(
SMeta
*
pMeta
)
{
return
taosThreadRwlockDestroy
(
&
pMeta
->
lock
);
}
static
int32_t
metaDestroyLock
(
SMeta
*
pMeta
)
{
return
taosThreadRwlockDestroy
(
&
pMeta
->
lock
);
}
...
@@ -139,6 +142,20 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
...
@@ -139,6 +142,20 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
goto
_err
;
goto
_err
;
}
}
// idx table create time
ret
=
tdbTbOpen
(
"ctime.idx"
,
sizeof
(
SCtimeIdxKey
),
0
,
ctimeIdxCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pCtimeIdx
,
0
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d, failed to open meta ctime index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// idx num of col, normal table only
ret
=
tdbTbOpen
(
"ncol.idx"
,
sizeof
(
SNcolIdxKey
),
0
,
ncolIdxCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pNcolIdx
,
0
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d, failed to open meta ncol index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
ret
=
tdbTbOpen
(
"stream.task.db"
,
sizeof
(
int64_t
),
-
1
,
taskIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pStreamDb
,
0
);
ret
=
tdbTbOpen
(
"stream.task.db"
,
sizeof
(
int64_t
),
-
1
,
taskIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pStreamDb
,
0
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
metaError
(
"vgId:%d, failed to open meta stream task index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
metaError
(
"vgId:%d, failed to open meta stream task index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
...
@@ -166,6 +183,8 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
...
@@ -166,6 +183,8 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
_err:
_err:
if
(
pMeta
->
pIdx
)
metaCloseIdx
(
pMeta
);
if
(
pMeta
->
pIdx
)
metaCloseIdx
(
pMeta
);
if
(
pMeta
->
pStreamDb
)
tdbTbClose
(
pMeta
->
pStreamDb
);
if
(
pMeta
->
pStreamDb
)
tdbTbClose
(
pMeta
->
pStreamDb
);
if
(
pMeta
->
pNcolIdx
)
tdbTbClose
(
pMeta
->
pNcolIdx
);
if
(
pMeta
->
pCtimeIdx
)
tdbTbClose
(
pMeta
->
pCtimeIdx
);
if
(
pMeta
->
pSmaIdx
)
tdbTbClose
(
pMeta
->
pSmaIdx
);
if
(
pMeta
->
pSmaIdx
)
tdbTbClose
(
pMeta
->
pSmaIdx
);
if
(
pMeta
->
pTtlIdx
)
tdbTbClose
(
pMeta
->
pTtlIdx
);
if
(
pMeta
->
pTtlIdx
)
tdbTbClose
(
pMeta
->
pTtlIdx
);
if
(
pMeta
->
pTagIvtIdx
)
indexClose
(
pMeta
->
pTagIvtIdx
);
if
(
pMeta
->
pTagIvtIdx
)
indexClose
(
pMeta
->
pTagIvtIdx
);
...
@@ -187,6 +206,8 @@ int metaClose(SMeta *pMeta) {
...
@@ -187,6 +206,8 @@ int metaClose(SMeta *pMeta) {
if
(
pMeta
->
pCache
)
metaCacheClose
(
pMeta
);
if
(
pMeta
->
pCache
)
metaCacheClose
(
pMeta
);
if
(
pMeta
->
pIdx
)
metaCloseIdx
(
pMeta
);
if
(
pMeta
->
pIdx
)
metaCloseIdx
(
pMeta
);
if
(
pMeta
->
pStreamDb
)
tdbTbClose
(
pMeta
->
pStreamDb
);
if
(
pMeta
->
pStreamDb
)
tdbTbClose
(
pMeta
->
pStreamDb
);
if
(
pMeta
->
pNcolIdx
)
tdbTbClose
(
pMeta
->
pNcolIdx
);
if
(
pMeta
->
pCtimeIdx
)
tdbTbClose
(
pMeta
->
pCtimeIdx
);
if
(
pMeta
->
pSmaIdx
)
tdbTbClose
(
pMeta
->
pSmaIdx
);
if
(
pMeta
->
pSmaIdx
)
tdbTbClose
(
pMeta
->
pSmaIdx
);
if
(
pMeta
->
pTtlIdx
)
tdbTbClose
(
pMeta
->
pTtlIdx
);
if
(
pMeta
->
pTtlIdx
)
tdbTbClose
(
pMeta
->
pTtlIdx
);
if
(
pMeta
->
pTagIvtIdx
)
indexClose
(
pMeta
->
pTagIvtIdx
);
if
(
pMeta
->
pTagIvtIdx
)
indexClose
(
pMeta
->
pTagIvtIdx
);
...
@@ -391,6 +412,43 @@ static int ttlIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kL
...
@@ -391,6 +412,43 @@ static int ttlIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kL
return
0
;
return
0
;
}
}
static
int
ctimeIdxCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
)
{
SCtimeIdxKey
*
pCtimeIdxKey1
=
(
SCtimeIdxKey
*
)
pKey1
;
SCtimeIdxKey
*
pCtimeIdxKey2
=
(
SCtimeIdxKey
*
)
pKey2
;
if
(
pCtimeIdxKey1
->
ctime
>
pCtimeIdxKey2
->
ctime
)
{
return
1
;
}
else
if
(
pCtimeIdxKey1
->
ctime
<
pCtimeIdxKey2
->
ctime
)
{
return
-
1
;
}
if
(
pCtimeIdxKey1
->
uid
>
pCtimeIdxKey2
->
uid
)
{
return
1
;
}
else
if
(
pCtimeIdxKey1
->
uid
<
pCtimeIdxKey2
->
uid
)
{
return
-
1
;
}
return
0
;
}
static
int
ncolIdxCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
)
{
SNcolIdxKey
*
pNcolIdxKey1
=
(
SNcolIdxKey
*
)
pKey1
;
SNcolIdxKey
*
pNcolIdxKey2
=
(
SNcolIdxKey
*
)
pKey2
;
if
(
pNcolIdxKey1
->
ncol
>
pNcolIdxKey2
->
ncol
)
{
return
1
;
}
else
if
(
pNcolIdxKey1
->
ncol
<
pNcolIdxKey2
->
ncol
)
{
return
-
1
;
}
if
(
pNcolIdxKey1
->
uid
>
pNcolIdxKey2
->
uid
)
{
return
1
;
}
else
if
(
pNcolIdxKey1
->
uid
<
pNcolIdxKey2
->
uid
)
{
return
-
1
;
}
return
0
;
}
static
int
smaIdxKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
)
{
static
int
smaIdxKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
)
{
SSmaIdxKey
*
pSmaIdxKey1
=
(
SSmaIdxKey
*
)
pKey1
;
SSmaIdxKey
*
pSmaIdxKey1
=
(
SSmaIdxKey
*
)
pKey1
;
SSmaIdxKey
*
pSmaIdxKey2
=
(
SSmaIdxKey
*
)
pKey2
;
SSmaIdxKey
*
pSmaIdxKey2
=
(
SSmaIdxKey
*
)
pKey2
;
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
b06870f7
...
@@ -1038,6 +1038,143 @@ typedef struct {
...
@@ -1038,6 +1038,143 @@ typedef struct {
int32_t
vLen
;
int32_t
vLen
;
}
SIdxCursor
;
}
SIdxCursor
;
int32_t
metaFilterCreateTime
(
SMeta
*
pMeta
,
SMetaFltParam
*
param
,
SArray
*
pUids
)
{
int32_t
ret
=
0
;
SIdxCursor
*
pCursor
=
NULL
;
pCursor
=
(
SIdxCursor
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SIdxCursor
));
pCursor
->
pMeta
=
pMeta
;
pCursor
->
suid
=
param
->
suid
;
pCursor
->
cid
=
param
->
cid
;
pCursor
->
type
=
param
->
type
;
metaRLock
(
pMeta
);
ret
=
tdbTbcOpen
(
pMeta
->
pCtimeIdx
,
&
pCursor
->
pCur
,
NULL
);
if
(
ret
!=
0
)
{
goto
END
;
}
int64_t
uidLimit
=
param
->
reverse
?
INT64_MAX
:
0
;
SCtimeIdxKey
ctimeKey
=
{.
ctime
=
*
(
int64_t
*
)(
param
->
val
),
.
uid
=
uidLimit
};
SCtimeIdxKey
*
pCtimeKey
=
&
ctimeKey
;
int
cmp
=
0
;
if
(
tdbTbcMoveTo
(
pCursor
->
pCur
,
&
ctimeKey
,
sizeof
(
ctimeKey
),
&
cmp
)
<
0
)
{
goto
END
;
}
bool
first
=
true
;
int32_t
valid
=
0
;
while
(
1
)
{
void
*
entryKey
=
NULL
;
int32_t
nEntryKey
=
-
1
;
valid
=
tdbTbcGet
(
pCursor
->
pCur
,
(
const
void
**
)
&
entryKey
,
&
nEntryKey
,
NULL
,
NULL
);
if
(
valid
<
0
)
break
;
SCtimeIdxKey
*
p
=
entryKey
;
int32_t
cmp
=
(
*
param
->
filterFunc
)((
void
*
)
&
p
->
ctime
,
(
void
*
)
&
pCtimeKey
->
ctime
,
param
->
type
);
if
(
cmp
==
0
)
taosArrayPush
(
pUids
,
&
p
->
uid
);
if
(
cmp
==
-
1
)
break
;
valid
=
param
->
reverse
?
tdbTbcMoveToPrev
(
pCursor
->
pCur
)
:
tdbTbcMoveToNext
(
pCursor
->
pCur
);
if
(
valid
<
0
)
break
;
}
END:
if
(
pCursor
->
pMeta
)
metaULock
(
pCursor
->
pMeta
);
if
(
pCursor
->
pCur
)
tdbTbcClose
(
pCursor
->
pCur
);
taosMemoryFree
(
pCursor
);
return
ret
;
}
int32_t
metaFilterTableName
(
SMeta
*
pMeta
,
SMetaFltParam
*
param
,
SArray
*
pUids
)
{
int32_t
ret
=
0
;
char
*
buf
=
NULL
;
STagIdxKey
*
pKey
=
NULL
;
int32_t
nKey
=
0
;
SIdxCursor
*
pCursor
=
NULL
;
pCursor
=
(
SIdxCursor
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SIdxCursor
));
pCursor
->
pMeta
=
pMeta
;
pCursor
->
suid
=
param
->
suid
;
pCursor
->
cid
=
param
->
cid
;
pCursor
->
type
=
param
->
type
;
char
*
pName
=
param
->
val
;
metaRLock
(
pMeta
);
ret
=
tdbTbcOpen
(
pMeta
->
pNameIdx
,
&
pCursor
->
pCur
,
NULL
);
if
(
ret
!=
0
)
{
goto
END
;
}
int
cmp
=
0
;
if
(
tdbTbcMoveTo
(
pCursor
->
pCur
,
pName
,
strlen
(
pName
)
+
1
,
&
cmp
)
<
0
)
{
goto
END
;
}
bool
first
=
true
;
int32_t
valid
=
0
;
while
(
1
)
{
void
*
pEntryKey
=
NULL
,
*
pEntryVal
=
NULL
;
int32_t
nEntryKey
=
-
1
,
nEntryVal
=
0
;
valid
=
tdbTbcGet
(
pCursor
->
pCur
,
(
const
void
**
)
pEntryKey
,
&
nEntryKey
,
(
const
void
**
)
&
pEntryVal
,
&
nEntryVal
);
if
(
valid
<
0
)
break
;
char
*
pTableKey
=
(
char
*
)
pEntryKey
;
int32_t
cmp
=
(
*
param
->
filterFunc
)(
pTableKey
,
pName
,
pCursor
->
type
);
if
(
cmp
==
0
)
{
tb_uid_t
tuid
=
*
(
tb_uid_t
*
)
pEntryVal
;
taosArrayPush
(
pUids
,
&
tuid
);
}
else
if
(
cmp
==
1
)
{
// next
}
else
{
break
;
}
valid
=
param
->
reverse
?
tdbTbcMoveToPrev
(
pCursor
->
pCur
)
:
tdbTbcMoveToNext
(
pCursor
->
pCur
);
if
(
valid
<
0
)
{
break
;
}
}
END:
if
(
pCursor
->
pMeta
)
metaULock
(
pCursor
->
pMeta
);
if
(
pCursor
->
pCur
)
tdbTbcClose
(
pCursor
->
pCur
);
taosMemoryFree
(
buf
);
taosMemoryFree
(
pKey
);
taosMemoryFree
(
pCursor
);
return
ret
;
}
int32_t
metaFilterTtl
(
SMeta
*
pMeta
,
SMetaFltParam
*
param
,
SArray
*
pUids
)
{
int32_t
ret
=
0
;
char
*
buf
=
NULL
;
STtlIdxKey
*
pKey
=
NULL
;
int32_t
nKey
=
0
;
SIdxCursor
*
pCursor
=
NULL
;
pCursor
=
(
SIdxCursor
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SIdxCursor
));
pCursor
->
pMeta
=
pMeta
;
pCursor
->
suid
=
param
->
suid
;
pCursor
->
cid
=
param
->
cid
;
pCursor
->
type
=
param
->
type
;
metaRLock
(
pMeta
);
ret
=
tdbTbcOpen
(
pMeta
->
pTtlIdx
,
&
pCursor
->
pCur
,
NULL
);
END:
if
(
pCursor
->
pMeta
)
metaULock
(
pCursor
->
pMeta
);
if
(
pCursor
->
pCur
)
tdbTbcClose
(
pCursor
->
pCur
);
taosMemoryFree
(
buf
);
taosMemoryFree
(
pKey
);
taosMemoryFree
(
pCursor
);
return
ret
;
// impl later
return
0
;
}
int32_t
metaFilterTableIds
(
SMeta
*
pMeta
,
SMetaFltParam
*
param
,
SArray
*
pUids
)
{
int32_t
metaFilterTableIds
(
SMeta
*
pMeta
,
SMetaFltParam
*
param
,
SArray
*
pUids
)
{
int32_t
ret
=
0
;
int32_t
ret
=
0
;
char
*
buf
=
NULL
;
char
*
buf
=
NULL
;
...
@@ -1053,7 +1190,7 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
...
@@ -1053,7 +1190,7 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
pCursor
->
type
=
param
->
type
;
pCursor
->
type
=
param
->
type
;
metaRLock
(
pMeta
);
metaRLock
(
pMeta
);
ret
=
tdbTbcOpen
(
pMeta
->
p
Tag
Idx
,
&
pCursor
->
pCur
,
NULL
);
ret
=
tdbTbcOpen
(
pMeta
->
p
Ctime
Idx
,
&
pCursor
->
pCur
,
NULL
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
goto
END
;
goto
END
;
}
}
...
@@ -1064,6 +1201,7 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
...
@@ -1064,6 +1201,7 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
if
(
param
->
val
==
NULL
)
{
if
(
param
->
val
==
NULL
)
{
metaError
(
"vgId:%d, failed to filter NULL data"
,
TD_VID
(
pMeta
->
pVnode
));
metaError
(
"vgId:%d, failed to filter NULL data"
,
TD_VID
(
pMeta
->
pVnode
));
ret
=
-
1
;
goto
END
;
goto
END
;
}
else
{
}
else
{
if
(
IS_VAR_DATA_TYPE
(
param
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
param
->
type
))
{
...
@@ -1104,9 +1242,11 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
...
@@ -1104,9 +1242,11 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
valid
=
tdbTbcGet
(
pCursor
->
pCur
,
(
const
void
**
)
&
entryKey
,
&
nEntryKey
,
(
const
void
**
)
&
entryVal
,
&
nEntryVal
);
valid
=
tdbTbcGet
(
pCursor
->
pCur
,
(
const
void
**
)
&
entryKey
,
&
nEntryKey
,
(
const
void
**
)
&
entryVal
,
&
nEntryVal
);
if
(
valid
<
0
)
{
if
(
valid
<
0
)
{
tdbFree
(
entryVal
);
break
;
break
;
}
}
STagIdxKey
*
p
=
entryKey
;
STagIdxKey
*
p
=
entryKey
;
if
(
p
==
NULL
)
break
;
if
(
p
->
type
!=
pCursor
->
type
)
{
if
(
p
->
type
!=
pCursor
->
type
)
{
if
(
first
)
{
if
(
first
)
{
valid
=
param
->
reverse
?
tdbTbcMoveToPrev
(
pCursor
->
pCur
)
:
tdbTbcMoveToNext
(
pCursor
->
pCur
);
valid
=
param
->
reverse
?
tdbTbcMoveToPrev
(
pCursor
->
pCur
)
:
tdbTbcMoveToNext
(
pCursor
->
pCur
);
...
@@ -1116,7 +1256,7 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
...
@@ -1116,7 +1256,7 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
break
;
break
;
}
}
}
}
if
(
p
==
NULL
||
p
->
suid
!=
pKey
->
suid
)
{
if
(
p
->
suid
!=
pKey
->
suid
)
{
break
;
break
;
}
}
first
=
false
;
first
=
false
;
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
b06870f7
...
@@ -27,6 +27,11 @@ static int metaUpdateSuidIdx(SMeta *pMeta, const SMetaEntry *pME);
...
@@ -27,6 +27,11 @@ static int metaUpdateSuidIdx(SMeta *pMeta, const SMetaEntry *pME);
static
int
metaUpdateTagIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pCtbEntry
);
static
int
metaUpdateTagIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pCtbEntry
);
static
int
metaDropTableByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int
*
type
);
static
int
metaDropTableByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int
*
type
);
static
void
metaDestroyTagIdxKey
(
STagIdxKey
*
pTagIdxKey
);
static
void
metaDestroyTagIdxKey
(
STagIdxKey
*
pTagIdxKey
);
// opt ins_tables query
static
int
metaUpdateCtimeIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaDeleteCtimeIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaUpdateNcolIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaDeleteNcolIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
void
metaGetEntryInfo
(
const
SMetaEntry
*
pEntry
,
SMetaInfo
*
pInfo
)
{
static
void
metaGetEntryInfo
(
const
SMetaEntry
*
pEntry
,
SMetaInfo
*
pInfo
)
{
pInfo
->
uid
=
pEntry
->
uid
;
pInfo
->
uid
=
pEntry
->
uid
;
...
@@ -551,6 +556,26 @@ static void metaBuildTtlIdxKey(STtlIdxKey *ttlKey, const SMetaEntry *pME) {
...
@@ -551,6 +556,26 @@ static void metaBuildTtlIdxKey(STtlIdxKey *ttlKey, const SMetaEntry *pME) {
ttlKey
->
dtime
=
ctime
/
1000
+
ttlDays
*
tsTtlUnit
;
ttlKey
->
dtime
=
ctime
/
1000
+
ttlDays
*
tsTtlUnit
;
ttlKey
->
uid
=
pME
->
uid
;
ttlKey
->
uid
=
pME
->
uid
;
}
}
static
int
metaBuildCtimeIdxKey
(
SCtimeIdxKey
*
ctimeKey
,
const
SMetaEntry
*
pME
)
{
int64_t
ctime
;
if
(
pME
->
type
==
TSDB_CHILD_TABLE
)
{
ctime
=
pME
->
ctbEntry
.
ctime
;
}
else
if
(
pME
->
type
==
TSDB_NORMAL_TABLE
)
{
ctime
=
pME
->
ntbEntry
.
ctime
;
}
else
{
return
-
1
;
}
ctimeKey
->
ctime
=
ctime
;
ctimeKey
->
uid
=
pME
->
uid
;
return
0
;
}
static
int
metaBuildNColIdxKey
(
SNcolIdxKey
*
ncolKey
,
const
SMetaEntry
*
pME
)
{
ncolKey
->
ncol
=
pME
->
ntbEntry
.
schemaRow
.
nCols
;
ncolKey
->
uid
=
pME
->
uid
;
return
0
;
}
static
int
metaDeleteTtlIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
static
int
metaDeleteTtlIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
STtlIdxKey
ttlKey
=
{
0
};
STtlIdxKey
ttlKey
=
{
0
};
...
@@ -632,6 +657,9 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
...
@@ -632,6 +657,9 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
tdbTbDelete
(
pMeta
->
pNameIdx
,
e
.
name
,
strlen
(
e
.
name
)
+
1
,
&
pMeta
->
txn
);
tdbTbDelete
(
pMeta
->
pNameIdx
,
e
.
name
,
strlen
(
e
.
name
)
+
1
,
&
pMeta
->
txn
);
tdbTbDelete
(
pMeta
->
pUidIdx
,
&
uid
,
sizeof
(
uid
),
&
pMeta
->
txn
);
tdbTbDelete
(
pMeta
->
pUidIdx
,
&
uid
,
sizeof
(
uid
),
&
pMeta
->
txn
);
if
(
e
.
type
==
TSDB_CHILD_TABLE
||
e
.
type
==
TSDB_NORMAL_TABLE
)
metaDeleteCtimeIdx
(
pMeta
,
&
e
);
if
(
e
.
type
==
TSDB_NORMAL_TABLE
)
metaDeleteNcolIdx
(
pMeta
,
&
e
);
if
(
e
.
type
!=
TSDB_SUPER_TABLE
)
metaDeleteTtlIdx
(
pMeta
,
&
e
);
if
(
e
.
type
!=
TSDB_SUPER_TABLE
)
metaDeleteTtlIdx
(
pMeta
,
&
e
);
if
(
e
.
type
==
TSDB_CHILD_TABLE
)
{
if
(
e
.
type
==
TSDB_CHILD_TABLE
)
{
...
@@ -658,6 +686,37 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
...
@@ -658,6 +686,37 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
return
0
;
return
0
;
}
}
// opt ins_tables
int
metaUpdateCtimeIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
SCtimeIdxKey
ctimeKey
=
{
0
};
if
(
metaBuildCtimeIdxKey
(
&
ctimeKey
,
pME
)
<
0
)
{
return
0
;
}
return
tdbTbInsert
(
pMeta
->
pCtimeIdx
,
&
ctimeKey
,
sizeof
(
ctimeKey
),
NULL
,
0
,
&
pMeta
->
txn
);
}
int
metaDeleteCtimeIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
SCtimeIdxKey
ctimeKey
=
{
0
};
if
(
metaBuildCtimeIdxKey
(
&
ctimeKey
,
pME
)
<
0
)
{
return
0
;
}
return
tdbTbDelete
(
pMeta
->
pCtimeIdx
,
&
ctimeKey
,
sizeof
(
ctimeKey
),
&
pMeta
->
txn
);
}
int
metaUpdateNcolIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
SNcolIdxKey
ncolKey
=
{
0
};
if
(
metaBuildNColIdxKey
(
&
ncolKey
,
pME
)
<
0
)
{
return
0
;
}
return
tdbTbInsert
(
pMeta
->
pNcolIdx
,
&
ncolKey
,
sizeof
(
ncolKey
),
NULL
,
0
,
&
pMeta
->
txn
);
}
int
metaDeleteNcolIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
SNcolIdxKey
ncolKey
=
{
0
};
if
(
metaBuildNColIdxKey
(
&
ncolKey
,
pME
)
<
0
)
{
return
0
;
}
return
tdbTbDelete
(
pMeta
->
pNcolIdx
,
&
ncolKey
,
sizeof
(
ncolKey
),
&
pMeta
->
txn
);
}
static
int
metaAlterTableColumn
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pAlterTbReq
,
STableMetaRsp
*
pMetaRsp
)
{
static
int
metaAlterTableColumn
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pAlterTbReq
,
STableMetaRsp
*
pMetaRsp
)
{
void
*
pVal
=
NULL
;
void
*
pVal
=
NULL
;
...
@@ -794,6 +853,10 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
...
@@ -794,6 +853,10 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
pColumn
->
bytes
=
pAlterTbReq
->
colModBytes
;
pColumn
->
bytes
=
pAlterTbReq
->
colModBytes
;
break
;
break
;
case
TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME
:
case
TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME
:
if
(
pAlterTbReq
->
colNewName
==
NULL
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
_err
;
}
if
(
pColumn
==
NULL
)
{
if
(
pColumn
==
NULL
)
{
terrno
=
TSDB_CODE_VND_TABLE_COL_NOT_EXISTS
;
terrno
=
TSDB_CODE_VND_TABLE_COL_NOT_EXISTS
;
goto
_err
;
goto
_err
;
...
@@ -1278,12 +1341,14 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
...
@@ -1278,12 +1341,14 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
ret
=
metaSaveJsonVarToIdx
(
pMeta
,
pCtbEntry
,
pTagColumn
);
ret
=
metaSaveJsonVarToIdx
(
pMeta
,
pCtbEntry
,
pTagColumn
);
goto
end
;
goto
end
;
}
}
if
(
metaCreateTagIdxKey
(
pCtbEntry
->
ctbEntry
.
suid
,
pTagColumn
->
colId
,
pTagData
,
nTagData
,
pTagColumn
->
type
,
if
(
pTagData
!=
NULL
)
{
pCtbEntry
->
uid
,
&
pTagIdxKey
,
&
nTagIdxKey
)
<
0
)
{
if
(
metaCreateTagIdxKey
(
pCtbEntry
->
ctbEntry
.
suid
,
pTagColumn
->
colId
,
pTagData
,
nTagData
,
pTagColumn
->
type
,
ret
=
-
1
;
pCtbEntry
->
uid
,
&
pTagIdxKey
,
&
nTagIdxKey
)
<
0
)
{
goto
end
;
ret
=
-
1
;
goto
end
;
}
tdbTbUpsert
(
pMeta
->
pTagIdx
,
pTagIdxKey
,
nTagIdxKey
,
NULL
,
0
,
&
pMeta
->
txn
);
}
}
tdbTbUpsert
(
pMeta
->
pTagIdx
,
pTagIdxKey
,
nTagIdxKey
,
NULL
,
0
,
&
pMeta
->
txn
);
end:
end:
metaDestroyTagIdxKey
(
pTagIdxKey
);
metaDestroyTagIdxKey
(
pTagIdxKey
);
tDecoderClear
(
&
dc
);
tDecoderClear
(
&
dc
);
...
@@ -1370,6 +1435,12 @@ int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME) {
...
@@ -1370,6 +1435,12 @@ int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME) {
}
}
}
}
if
(
metaUpdateCtimeIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
if
(
pME
->
type
==
TSDB_NORMAL_TABLE
)
{
if
(
metaUpdateNcolIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
}
if
(
pME
->
type
!=
TSDB_SUPER_TABLE
)
{
if
(
pME
->
type
!=
TSDB_SUPER_TABLE
)
{
if
(
metaUpdateTtlIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
if
(
metaUpdateTtlIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
b06870f7
...
@@ -1492,4 +1492,11 @@ void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity) {
...
@@ -1492,4 +1492,11 @@ void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity) {
size_t
tsdbCacheGetCapacity
(
SVnode
*
pVnode
)
{
return
taosLRUCacheGetCapacity
(
pVnode
->
pTsdb
->
lruCache
);
}
size_t
tsdbCacheGetCapacity
(
SVnode
*
pVnode
)
{
return
taosLRUCacheGetCapacity
(
pVnode
->
pTsdb
->
lruCache
);
}
size_t
tsdbCacheGetUsage
(
SVnode
*
pVnode
)
{
return
taosLRUCacheGetUsage
(
pVnode
->
pTsdb
->
lruCache
);
}
size_t
tsdbCacheGetUsage
(
SVnode
*
pVnode
)
{
size_t
usage
=
0
;
if
(
pVnode
->
pTsdb
!=
NULL
)
{
usage
=
taosLRUCacheGetUsage
(
pVnode
->
pTsdb
->
lruCache
);
}
return
usage
;
}
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
b06870f7
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#include "vnd.h"
#include "vnd.h"
#define VND_INFO_FNAME
"vnode.json"
#define VND_INFO_FNAME "vnode.json"
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
static
int
vnodeEncodeInfo
(
const
SVnodeInfo
*
pInfo
,
char
**
ppData
);
static
int
vnodeEncodeInfo
(
const
SVnodeInfo
*
pInfo
,
char
**
ppData
);
...
@@ -107,7 +107,7 @@ int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) {
...
@@ -107,7 +107,7 @@ int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) {
// free info binary
// free info binary
taosMemoryFree
(
data
);
taosMemoryFree
(
data
);
vInfo
(
"vgId:%d, vnode info is saved, fname:%s
"
,
pInfo
->
config
.
vgId
,
fname
);
vInfo
(
"vgId:%d, vnode info is saved, fname:%s
replica:%d"
,
pInfo
->
config
.
vgId
,
fname
,
pInfo
->
config
.
syncCfg
.
replicaNum
);
return
0
;
return
0
;
...
@@ -228,7 +228,9 @@ int vnodeCommit(SVnode *pVnode) {
...
@@ -228,7 +228,9 @@ int vnodeCommit(SVnode *pVnode) {
code
=
terrno
;
code
=
terrno
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
}
walBeginSnapshot
(
pVnode
->
pWal
,
pVnode
->
state
.
applied
);
// walBeginSnapshot(pVnode->pWal, pVnode->state.applied);
syncBeginSnapshot
(
pVnode
->
sync
,
pVnode
->
state
.
applied
);
code
=
smaPreCommit
(
pVnode
->
pSma
);
code
=
smaPreCommit
(
pVnode
->
pSma
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
...
@@ -282,7 +284,8 @@ int vnodeCommit(SVnode *pVnode) {
...
@@ -282,7 +284,8 @@ int vnodeCommit(SVnode *pVnode) {
}
}
// apply the commit (TODO)
// apply the commit (TODO)
walEndSnapshot
(
pVnode
->
pWal
);
// walEndSnapshot(pVnode->pWal);
syncEndSnapshot
(
pVnode
->
sync
);
_exit:
_exit:
if
(
code
)
{
if
(
code
)
{
...
...
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
b06870f7
...
@@ -87,12 +87,19 @@ int32_t vnodeAlter(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs) {
...
@@ -87,12 +87,19 @@ int32_t vnodeAlter(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs) {
vInfo
(
"vgId:%d, save config, replica:%d ep:%s:%u"
,
pReq
->
vgId
,
i
,
pNode
->
nodeFqdn
,
pNode
->
nodePort
);
vInfo
(
"vgId:%d, save config, replica:%d ep:%s:%u"
,
pReq
->
vgId
,
i
,
pNode
->
nodeFqdn
,
pNode
->
nodePort
);
}
}
info
.
config
.
syncCfg
=
*
pCfg
;
ret
=
vnodeSaveInfo
(
dir
,
&
info
);
ret
=
vnodeSaveInfo
(
dir
,
&
info
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
vError
(
"vgId:%d, failed to save vnode config since %s"
,
pReq
->
vgId
,
tstrerror
(
terrno
));
vError
(
"vgId:%d, failed to save vnode config since %s"
,
pReq
->
vgId
,
tstrerror
(
terrno
));
return
-
1
;
return
-
1
;
}
}
ret
=
vnodeCommitInfo
(
dir
,
&
info
);
if
(
ret
<
0
)
{
vError
(
"vgId:%d, failed to commit vnode config since %s"
,
pReq
->
vgId
,
tstrerror
(
terrno
));
return
-
1
;
}
vInfo
(
"vgId:%d, vnode config is saved"
,
info
.
config
.
vgId
);
vInfo
(
"vgId:%d, vnode config is saved"
,
info
.
config
.
vgId
);
return
0
;
return
0
;
}
}
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
b06870f7
...
@@ -15,10 +15,13 @@
...
@@ -15,10 +15,13 @@
#include "vnd.h"
#include "vnd.h"
#define VNODE_GET_LOAD_RESET_VALS(pVar, oVal, vType) \
#define VNODE_GET_LOAD_RESET_VALS(pVar, oVal, vType, tags) \
do { \
do { \
int##vType##_t newVal = atomic_sub_fetch_##vType(&(pVar), (oVal)); \
int##vType##_t newVal = atomic_sub_fetch_##vType(&(pVar), (oVal)); \
ASSERT(newVal >= 0); \
ASSERT(newVal >= 0); \
if (newVal < 0) { \
vWarn("vgId:%d %s, abnormal val:%" PRIi64 ", old val:%" PRIi64, TD_VID(pVnode), tags, newVal, (oVal)); \
} \
} while (0)
} while (0)
int
vnodeQueryOpen
(
SVnode
*
pVnode
)
{
int
vnodeQueryOpen
(
SVnode
*
pVnode
)
{
...
@@ -435,10 +438,10 @@ int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
...
@@ -435,10 +438,10 @@ int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
* @param pLoad
* @param pLoad
*/
*/
void
vnodeResetLoad
(
SVnode
*
pVnode
,
SVnodeLoad
*
pLoad
)
{
void
vnodeResetLoad
(
SVnode
*
pVnode
,
SVnodeLoad
*
pLoad
)
{
VNODE_GET_LOAD_RESET_VALS
(
pVnode
->
statis
.
nInsert
,
pLoad
->
numOfInsertReqs
,
64
);
VNODE_GET_LOAD_RESET_VALS
(
pVnode
->
statis
.
nInsert
,
pLoad
->
numOfInsertReqs
,
64
,
"nInsert"
);
VNODE_GET_LOAD_RESET_VALS
(
pVnode
->
statis
.
nInsertSuccess
,
pLoad
->
numOfInsertSuccessReqs
,
64
);
VNODE_GET_LOAD_RESET_VALS
(
pVnode
->
statis
.
nInsertSuccess
,
pLoad
->
numOfInsertSuccessReqs
,
64
,
"nInsertSuccess"
);
VNODE_GET_LOAD_RESET_VALS
(
pVnode
->
statis
.
nBatchInsert
,
pLoad
->
numOfBatchInsertReqs
,
64
);
VNODE_GET_LOAD_RESET_VALS
(
pVnode
->
statis
.
nBatchInsert
,
pLoad
->
numOfBatchInsertReqs
,
64
,
"nBatchInsert"
);
VNODE_GET_LOAD_RESET_VALS
(
pVnode
->
statis
.
nBatchInsertSuccess
,
pLoad
->
numOfBatchInsertSuccessReqs
,
64
);
VNODE_GET_LOAD_RESET_VALS
(
pVnode
->
statis
.
nBatchInsertSuccess
,
pLoad
->
numOfBatchInsertSuccessReqs
,
64
,
"nBatchInsertSuccess"
);
}
}
void
vnodeGetInfo
(
SVnode
*
pVnode
,
const
char
**
dbname
,
int32_t
*
vgId
)
{
void
vnodeGetInfo
(
SVnode
*
pVnode
,
const
char
**
dbname
,
int32_t
*
vgId
)
{
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
b06870f7
...
@@ -292,116 +292,67 @@ int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -292,116 +292,67 @@ int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
vGTrace
(
"vgId:%d, sync msg:%p will be processed, type:%s"
,
pVnode
->
config
.
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
vGTrace
(
"vgId:%d, sync msg:%p will be processed, type:%s"
,
pVnode
->
config
.
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
if
(
syncNodeStrategy
(
pSyncNode
)
==
SYNC_STRATEGY_NO_SNAPSHOT
)
{
if
(
pMsg
->
msgType
==
TDMT_SYNC_TIMEOUT
)
{
if
(
pMsg
->
msgType
==
TDMT_SYNC_TIMEOUT
)
{
SyncTimeout
*
pSyncMsg
=
syncTimeoutFromRpcMsg2
(
pMsg
);
SyncTimeout
*
pSyncMsg
=
syncTimeoutFromRpcMsg2
(
pMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
ASSERT
(
pSyncMsg
!=
NULL
);
code
=
syncNodeOnTimer
(
pSyncNode
,
pSyncMsg
);
code
=
syncNodeOnTimeoutCb
(
pSyncNode
,
pSyncMsg
);
syncTimeoutDestroy
(
pSyncMsg
);
syncTimeoutDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_PING
)
{
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_PING
)
{
SyncPing
*
pSyncMsg
=
syncPingFromRpcMsg2
(
pMsg
);
SyncPing
*
pSyncMsg
=
syncPingFromRpcMsg2
(
pMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
ASSERT
(
pSyncMsg
!=
NULL
);
code
=
syncNodeOnPingCb
(
pSyncNode
,
pSyncMsg
);
code
=
syncNodeOnPingCb
(
pSyncNode
,
pSyncMsg
);
syncPingDestroy
(
pSyncMsg
);
syncPingDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_PING_REPLY
)
{
SyncPingReply
*
pSyncMsg
=
syncPingReplyFromRpcMsg2
(
pMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_PING_REPLY
)
{
ASSERT
(
pSyncMsg
!=
NULL
);
SyncPingReply
*
pSyncMsg
=
syncPingReplyFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnPingReplyCb
(
pSyncNode
,
pSyncMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
syncPingReplyDestroy
(
pSyncMsg
);
code
=
syncNodeOnPingReplyCb
(
pSyncNode
,
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_CLIENT_REQUEST
)
{
syncPingReplyDestroy
(
pSyncMsg
);
SyncClientRequest
*
pSyncMsg
=
syncClientRequestFromRpcMsg2
(
pMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_CLIENT_REQUEST
)
{
code
=
syncNodeOnClientRequestCb
(
pSyncNode
,
pSyncMsg
,
NULL
);
SyncClientRequest
*
pSyncMsg
=
syncClientRequestFromRpcMsg2
(
pMsg
);
syncClientRequestDestroy
(
pSyncMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_CLIENT_REQUEST_BATCH
)
{
code
=
syncNodeOnClientRequest
(
pSyncNode
,
pSyncMsg
,
NULL
);
SyncClientRequestBatch
*
pSyncMsg
=
syncClientRequestBatchFromRpcMsg
(
pMsg
);
syncClientRequestDestroy
(
pSyncMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
code
=
syncNodeOnClientRequestBatchCb
(
pSyncNode
,
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_REQUEST_VOTE
)
{
syncClientRequestBatchDestroyDeep
(
pSyncMsg
);
SyncRequestVote
*
pSyncMsg
=
syncRequestVoteFromRpcMsg2
(
pMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_REQUEST_VOTE
)
{
ASSERT
(
pSyncMsg
!=
NULL
);
SyncRequestVote
*
pSyncMsg
=
syncRequestVoteFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnRequestVote
(
pSyncNode
,
pSyncMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
syncRequestVoteDestroy
(
pSyncMsg
);
code
=
syncNodeOnRequestVoteCb
(
pSyncNode
,
pSyncMsg
);
syncRequestVoteDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_REQUEST_VOTE_REPLY
)
{
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_REQUEST_VOTE_REPLY
)
{
SyncRequestVoteReply
*
pSyncMsg
=
syncRequestVoteReplyFromRpcMsg2
(
pMsg
);
SyncRequestVoteReply
*
pSyncMsg
=
syncRequestVoteReplyFromRpcMsg2
(
pMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
ASSERT
(
pSyncMsg
!=
NULL
);
code
=
syncNodeOnRequestVoteReply
(
pSyncNode
,
pSyncMsg
);
code
=
syncNodeOnRequestVoteReplyCb
(
pSyncNode
,
pSyncMsg
);
syncRequestVoteReplyDestroy
(
pSyncMsg
);
syncRequestVoteReplyDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_APPEND_ENTRIES
)
{
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_APPEND_ENTRIES
)
{
SyncAppendEntries
*
pSyncMsg
=
syncAppendEntriesFromRpcMsg2
(
pMsg
);
SyncAppendEntries
*
pSyncMsg
=
syncAppendEntriesFromRpcMsg2
(
pMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
ASSERT
(
pSyncMsg
!=
NULL
);
code
=
syncNodeOnAppendEntriesCb
(
pSyncNode
,
pSyncMsg
);
code
=
syncNodeOnAppendEntries
(
pSyncNode
,
pSyncMsg
);
syncAppendEntriesDestroy
(
pSyncMsg
);
syncAppendEntriesDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_APPEND_ENTRIES_REPLY
)
{
SyncAppendEntriesReply
*
pSyncMsg
=
syncAppendEntriesReplyFromRpcMsg2
(
pMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_APPEND_ENTRIES_REPLY
)
{
ASSERT
(
pSyncMsg
!=
NULL
);
SyncAppendEntriesReply
*
pSyncMsg
=
syncAppendEntriesReplyFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnAppendEntriesReplyCb
(
pSyncNode
,
pSyncMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
syncAppendEntriesReplyDestroy
(
pSyncMsg
);
code
=
syncNodeOnAppendEntriesReply
(
pSyncNode
,
pSyncMsg
);
}
else
{
syncAppendEntriesReplyDestroy
(
pSyncMsg
);
vGError
(
"vgId:%d, msg:%p failed to process since error msg type:%d"
,
pVnode
->
config
.
vgId
,
pMsg
,
pMsg
->
msgType
);
code
=
-
1
;
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_SNAPSHOT_SEND
)
{
}
SyncSnapshotSend
*
pSyncMsg
=
syncSnapshotSendFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnSnapshot
(
pSyncNode
,
pSyncMsg
);
syncSnapshotSendDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_SNAPSHOT_RSP
)
{
SyncSnapshotRsp
*
pSyncMsg
=
syncSnapshotRspFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnSnapshotReply
(
pSyncNode
,
pSyncMsg
);
syncSnapshotRspDestroy
(
pSyncMsg
);
}
else
if
(
syncNodeStrategy
(
pSyncNode
)
==
SYNC_STRATEGY_WAL_FIRST
)
{
}
else
{
// use wal first strategy
vGError
(
"vgId:%d, msg:%p failed to process since error msg type:%d"
,
pVnode
->
config
.
vgId
,
pMsg
,
pMsg
->
msgType
);
if
(
pMsg
->
msgType
==
TDMT_SYNC_TIMEOUT
)
{
code
=
-
1
;
SyncTimeout
*
pSyncMsg
=
syncTimeoutFromRpcMsg2
(
pMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
code
=
syncNodeOnTimeoutCb
(
pSyncNode
,
pSyncMsg
);
syncTimeoutDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_PING
)
{
SyncPing
*
pSyncMsg
=
syncPingFromRpcMsg2
(
pMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
code
=
syncNodeOnPingCb
(
pSyncNode
,
pSyncMsg
);
syncPingDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_PING_REPLY
)
{
SyncPingReply
*
pSyncMsg
=
syncPingReplyFromRpcMsg2
(
pMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
code
=
syncNodeOnPingReplyCb
(
pSyncNode
,
pSyncMsg
);
syncPingReplyDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_CLIENT_REQUEST
)
{
SyncClientRequest
*
pSyncMsg
=
syncClientRequestFromRpcMsg2
(
pMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
code
=
syncNodeOnClientRequestCb
(
pSyncNode
,
pSyncMsg
,
NULL
);
syncClientRequestDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_CLIENT_REQUEST_BATCH
)
{
SyncClientRequestBatch
*
pSyncMsg
=
syncClientRequestBatchFromRpcMsg
(
pMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
code
=
syncNodeOnClientRequestBatchCb
(
pSyncNode
,
pSyncMsg
);
syncClientRequestBatchDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_REQUEST_VOTE
)
{
SyncRequestVote
*
pSyncMsg
=
syncRequestVoteFromRpcMsg2
(
pMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
code
=
syncNodeOnRequestVoteSnapshotCb
(
pSyncNode
,
pSyncMsg
);
syncRequestVoteDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_REQUEST_VOTE_REPLY
)
{
SyncRequestVoteReply
*
pSyncMsg
=
syncRequestVoteReplyFromRpcMsg2
(
pMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
code
=
syncNodeOnRequestVoteReplySnapshotCb
(
pSyncNode
,
pSyncMsg
);
syncRequestVoteReplyDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_APPEND_ENTRIES_BATCH
)
{
SyncAppendEntriesBatch
*
pSyncMsg
=
syncAppendEntriesBatchFromRpcMsg2
(
pMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
code
=
syncNodeOnAppendEntriesSnapshot2Cb
(
pSyncNode
,
pSyncMsg
);
syncAppendEntriesBatchDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_APPEND_ENTRIES_REPLY
)
{
SyncAppendEntriesReply
*
pSyncMsg
=
syncAppendEntriesReplyFromRpcMsg2
(
pMsg
);
ASSERT
(
pSyncMsg
!=
NULL
);
code
=
syncNodeOnAppendEntriesReplySnapshot2Cb
(
pSyncNode
,
pSyncMsg
);
syncAppendEntriesReplyDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_SNAPSHOT_SEND
)
{
SyncSnapshotSend
*
pSyncMsg
=
syncSnapshotSendFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnSnapshotSendCb
(
pSyncNode
,
pSyncMsg
);
syncSnapshotSendDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_SYNC_SNAPSHOT_RSP
)
{
SyncSnapshotRsp
*
pSyncMsg
=
syncSnapshotRspFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnSnapshotRspCb
(
pSyncNode
,
pSyncMsg
);
syncSnapshotRspDestroy
(
pSyncMsg
);
}
else
{
vGError
(
"vgId:%d, msg:%p failed to process since error msg type:%d"
,
pVnode
->
config
.
vgId
,
pMsg
,
pMsg
->
msgType
);
code
=
-
1
;
}
}
}
vTrace
(
"vgId:%d, sync msg:%p is processed, type:%s code:0x%x"
,
pVnode
->
config
.
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
),
vTrace
(
"vgId:%d, sync msg:%p is processed, type:%s code:0x%x"
,
pVnode
->
config
.
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
),
...
@@ -413,6 +364,19 @@ int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -413,6 +364,19 @@ int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
return
code
;
return
code
;
}
}
static
int32_t
vnodeSyncEqCtrlMsg
(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
)
{
if
(
msgcb
==
NULL
)
{
return
-
1
;
}
int32_t
code
=
tmsgPutToQueue
(
msgcb
,
SYNC_CTRL_QUEUE
,
pMsg
);
if
(
code
!=
0
)
{
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
}
return
code
;
}
static
int32_t
vnodeSyncEqMsg
(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
)
{
static
int32_t
vnodeSyncEqMsg
(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
)
{
if
(
msgcb
==
NULL
)
{
if
(
msgcb
==
NULL
)
{
return
-
1
;
return
-
1
;
...
@@ -599,9 +563,7 @@ static int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *
...
@@ -599,9 +563,7 @@ static int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *
#endif
#endif
}
}
static
void
vnodeLeaderTransfer
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
static
void
vnodeLeaderTransfer
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{}
SVnode
*
pVnode
=
pFsm
->
data
;
}
static
void
vnodeRestoreFinish
(
struct
SSyncFSM
*
pFsm
)
{
static
void
vnodeRestoreFinish
(
struct
SSyncFSM
*
pFsm
)
{
SVnode
*
pVnode
=
pFsm
->
data
;
SVnode
*
pVnode
=
pFsm
->
data
;
...
@@ -641,12 +603,14 @@ static void vnodeBecomeLeader(struct SSyncFSM *pFsm) {
...
@@ -641,12 +603,14 @@ static void vnodeBecomeLeader(struct SSyncFSM *pFsm) {
SVnode
*
pVnode
=
pFsm
->
data
;
SVnode
*
pVnode
=
pFsm
->
data
;
vDebug
(
"vgId:%d, become leader"
,
pVnode
->
config
.
vgId
);
vDebug
(
"vgId:%d, become leader"
,
pVnode
->
config
.
vgId
);
// taosThreadMutexLock(&pVnode->lock);
#if 0
// if (pVnode->blocked) {
taosThreadMutexLock(&pVnode->lock);
// pVnode->blocked = false;
if (pVnode->blocked) {
// tsem_post(&pVnode->syncSem);
pVnode->blocked = false;
// }
tsem_post(&pVnode->syncSem);
// taosThreadMutexUnlock(&pVnode->lock);
}
taosThreadMutexUnlock(&pVnode->lock);
#endif
}
}
static
SSyncFSM
*
vnodeSyncMakeFsm
(
SVnode
*
pVnode
)
{
static
SSyncFSM
*
vnodeSyncMakeFsm
(
SVnode
*
pVnode
)
{
...
@@ -674,20 +638,26 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
...
@@ -674,20 +638,26 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
int32_t
vnodeSyncOpen
(
SVnode
*
pVnode
,
char
*
path
)
{
int32_t
vnodeSyncOpen
(
SVnode
*
pVnode
,
char
*
path
)
{
SSyncInfo
syncInfo
=
{
SSyncInfo
syncInfo
=
{
.
snapshotStrategy
=
SYNC_STRATEGY_WAL_FIRST
,
.
snapshotStrategy
=
SYNC_STRATEGY_WAL_FIRST
,
//.snapshotStrategy = SYNC_STRATEGY_NO_SNAPSHOT,
.
batchSize
=
1
,
.
batchSize
=
1
,
.
vgId
=
pVnode
->
config
.
vgId
,
.
vgId
=
pVnode
->
config
.
vgId
,
.
isStandBy
=
pVnode
->
config
.
standby
,
.
syncCfg
=
pVnode
->
config
.
syncCfg
,
.
syncCfg
=
pVnode
->
config
.
syncCfg
,
.
pWal
=
pVnode
->
pWal
,
.
pWal
=
pVnode
->
pWal
,
.
msgcb
=
NULL
,
.
msgcb
=
NULL
,
.
FpSendMsg
=
vnodeSyncSendMsg
,
.
FpSendMsg
=
vnodeSyncSendMsg
,
.
FpEqMsg
=
vnodeSyncEqMsg
,
.
FpEqMsg
=
vnodeSyncEqMsg
,
.
FpEqCtrlMsg
=
vnodeSyncEqCtrlMsg
,
};
};
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s%ssync"
,
path
,
TD_DIRSEP
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s%ssync"
,
path
,
TD_DIRSEP
);
syncInfo
.
pFsm
=
vnodeSyncMakeFsm
(
pVnode
);
syncInfo
.
pFsm
=
vnodeSyncMakeFsm
(
pVnode
);
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
vInfo
(
"vgId:%d, start to open sync, replica:%d selfIndex:%d"
,
pVnode
->
config
.
vgId
,
pCfg
->
replicaNum
,
pCfg
->
myIndex
);
for
(
int32_t
i
=
0
;
i
<
pCfg
->
replicaNum
;
++
i
)
{
SNodeInfo
*
pNode
=
&
pCfg
->
nodeInfo
[
i
];
vInfo
(
"vgId:%d, index:%d ep:%s:%u"
,
pVnode
->
config
.
vgId
,
i
,
pNode
->
nodeFqdn
,
pNode
->
nodePort
);
}
pVnode
->
sync
=
syncOpen
(
&
syncInfo
);
pVnode
->
sync
=
syncOpen
(
&
syncInfo
);
if
(
pVnode
->
sync
<=
0
)
{
if
(
pVnode
->
sync
<=
0
)
{
vError
(
"vgId:%d, failed to open sync since %s"
,
pVnode
->
config
.
vgId
,
terrstr
());
vError
(
"vgId:%d, failed to open sync since %s"
,
pVnode
->
config
.
vgId
,
terrstr
());
...
@@ -701,11 +671,15 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
...
@@ -701,11 +671,15 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
}
}
void
vnodeSyncStart
(
SVnode
*
pVnode
)
{
void
vnodeSyncStart
(
SVnode
*
pVnode
)
{
vDebug
(
"vgId:%d, start sync"
,
pVnode
->
config
.
vgId
);
syncSetMsgCb
(
pVnode
->
sync
,
&
pVnode
->
msgCb
);
syncSetMsgCb
(
pVnode
->
sync
,
&
pVnode
->
msgCb
);
syncStart
(
pVnode
->
sync
);
syncStart
(
pVnode
->
sync
);
}
}
void
vnodeSyncClose
(
SVnode
*
pVnode
)
{
syncStop
(
pVnode
->
sync
);
}
void
vnodeSyncClose
(
SVnode
*
pVnode
)
{
vDebug
(
"vgId:%d, close sync"
,
pVnode
->
config
.
vgId
);
syncStop
(
pVnode
->
sync
);
}
bool
vnodeIsRoleLeader
(
SVnode
*
pVnode
)
{
return
syncGetMyRole
(
pVnode
->
sync
)
==
TAOS_SYNC_STATE_LEADER
;
}
bool
vnodeIsRoleLeader
(
SVnode
*
pVnode
)
{
return
syncGetMyRole
(
pVnode
->
sync
)
==
TAOS_SYNC_STATE_LEADER
;
}
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
b06870f7
...
@@ -541,6 +541,12 @@ typedef struct {
...
@@ -541,6 +541,12 @@ typedef struct {
SSnapContext
*
sContext
;
SSnapContext
*
sContext
;
}
SStreamRawScanInfo
;
}
SStreamRawScanInfo
;
typedef
struct
SSysTableIndex
{
int8_t
init
;
SArray
*
uids
;
int32_t
lastIdx
;
}
SSysTableIndex
;
typedef
struct
SSysTableScanInfo
{
typedef
struct
SSysTableScanInfo
{
SRetrieveMetaTableRsp
*
pRsp
;
SRetrieveMetaTableRsp
*
pRsp
;
SRetrieveTableReq
req
;
SRetrieveTableReq
req
;
...
@@ -553,6 +559,7 @@ typedef struct SSysTableScanInfo {
...
@@ -553,6 +559,7 @@ typedef struct SSysTableScanInfo {
bool
showRewrite
;
bool
showRewrite
;
SNode
*
pCondition
;
// db_name filter condition, to discard data that are not in current database
SNode
*
pCondition
;
// db_name filter condition, to discard data that are not in current database
SMTbCursor
*
pCur
;
// cursor for iterate the local table meta store.
SMTbCursor
*
pCur
;
// cursor for iterate the local table meta store.
SSysTableIndex
*
pIdx
;
// idx for local table meta
SArray
*
scanCols
;
// SArray<int16_t> scan column id list
SArray
*
scanCols
;
// SArray<int16_t> scan column id list
SName
name
;
SName
name
;
SSDataBlock
*
pRes
;
SSDataBlock
*
pRes
;
...
...
source/libs/executor/src/executil.c
浏览文件 @
b06870f7
...
@@ -122,7 +122,7 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, in
...
@@ -122,7 +122,7 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, in
if
(
order
==
TSDB_ORDER_ASC
||
order
==
TSDB_ORDER_DESC
)
{
if
(
order
==
TSDB_ORDER_ASC
||
order
==
TSDB_ORDER_DESC
)
{
__compar_fn_t
fn
=
(
order
==
TSDB_ORDER_ASC
)
?
resultrowComparAsc
:
resultrowComparDesc
;
__compar_fn_t
fn
=
(
order
==
TSDB_ORDER_ASC
)
?
resultrowComparAsc
:
resultrowComparDesc
;
int32_t
size
=
POINTER_BYTES
;
int32_t
size
=
POINTER_BYTES
;
taosSort
(
pGroupResInfo
->
pRows
->
pData
,
taosArrayGetSize
(
pGroupResInfo
->
pRows
),
size
,
fn
);
taosSort
(
pGroupResInfo
->
pRows
->
pData
,
taosArrayGetSize
(
pGroupResInfo
->
pRows
),
size
,
fn
);
}
}
...
@@ -422,16 +422,6 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray*
...
@@ -422,16 +422,6 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray*
goto
end
;
goto
end
;
}
}
}
}
/*else {
code = metaGetTableTagsByUids(metaHandle, suid, uidList, tags);
if (code != 0) {
terrno = code;
qError("failed to get table from meta idx, reason: %s, suid:%" PRId64, tstrerror(code), suid);
goto end;
} else {
qInfo("succ to get table from meta idx, suid:%" PRId64, suid);
}
}*/
int32_t
rows
=
taosArrayGetSize
(
uidList
);
int32_t
rows
=
taosArrayGetSize
(
uidList
);
if
(
rows
==
0
)
{
if
(
rows
==
0
)
{
...
@@ -762,8 +752,8 @@ end:
...
@@ -762,8 +752,8 @@ end:
}
}
static
int
tableUidCompare
(
const
void
*
a
,
const
void
*
b
)
{
static
int
tableUidCompare
(
const
void
*
a
,
const
void
*
b
)
{
u
int64_t
u1
=
*
(
uint64_t
*
)
a
;
int64_t
u1
=
*
(
uint64_t
*
)
a
;
u
int64_t
u2
=
*
(
uint64_t
*
)
b
;
int64_t
u2
=
*
(
uint64_t
*
)
b
;
if
(
u1
==
u2
)
{
if
(
u1
==
u2
)
{
return
0
;
return
0
;
}
}
...
@@ -1212,11 +1202,10 @@ void createExprFromOneNode(SExprInfo* pExp, SNode* pNode, int16_t slotId) {
...
@@ -1212,11 +1202,10 @@ void createExprFromOneNode(SExprInfo* pExp, SNode* pNode, int16_t slotId) {
#if 1
#if 1
// todo refactor: add the parameter for tbname function
// todo refactor: add the parameter for tbname function
const
char
*
name
=
"tbname"
;
const
char
*
name
=
"tbname"
;
int32_t
len
=
strlen
(
name
);
int32_t
len
=
strlen
(
name
);
if
(
!
pFuncNode
->
pParameterList
&&
(
memcmp
(
pExprNode
->
_function
.
functionName
,
name
,
len
)
==
0
)
&&
if
(
!
pFuncNode
->
pParameterList
&&
(
memcmp
(
pExprNode
->
_function
.
functionName
,
name
,
len
)
==
0
)
&&
pExprNode
->
_function
.
functionName
[
len
]
==
0
)
{
pExprNode
->
_function
.
functionName
[
len
]
==
0
)
{
pFuncNode
->
pParameterList
=
nodesMakeList
();
pFuncNode
->
pParameterList
=
nodesMakeList
();
ASSERT
(
LIST_LENGTH
(
pFuncNode
->
pParameterList
)
==
0
);
ASSERT
(
LIST_LENGTH
(
pFuncNode
->
pParameterList
)
==
0
);
SValueNode
*
res
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
SValueNode
*
res
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
...
@@ -1261,13 +1250,13 @@ void createExprFromOneNode(SExprInfo* pExp, SNode* pNode, int16_t slotId) {
...
@@ -1261,13 +1250,13 @@ void createExprFromOneNode(SExprInfo* pExp, SNode* pNode, int16_t slotId) {
}
else
if
(
type
==
QUERY_NODE_CASE_WHEN
)
{
}
else
if
(
type
==
QUERY_NODE_CASE_WHEN
)
{
pExp
->
pExpr
->
nodeType
=
QUERY_NODE_OPERATOR
;
pExp
->
pExpr
->
nodeType
=
QUERY_NODE_OPERATOR
;
SCaseWhenNode
*
pCaseNode
=
(
SCaseWhenNode
*
)
pNode
;
SCaseWhenNode
*
pCaseNode
=
(
SCaseWhenNode
*
)
pNode
;
pExp
->
base
.
pParam
=
taosMemoryCalloc
(
1
,
sizeof
(
SFunctParam
));
pExp
->
base
.
pParam
=
taosMemoryCalloc
(
1
,
sizeof
(
SFunctParam
));
pExp
->
base
.
numOfParams
=
1
;
pExp
->
base
.
numOfParams
=
1
;
SDataType
*
pType
=
&
pCaseNode
->
node
.
resType
;
SDataType
*
pType
=
&
pCaseNode
->
node
.
resType
;
pExp
->
base
.
resSchema
=
createResSchema
(
pType
->
type
,
pType
->
bytes
,
slotId
,
pType
->
scale
,
pExp
->
base
.
resSchema
=
pType
->
precision
,
pCaseNode
->
node
.
aliasName
);
createResSchema
(
pType
->
type
,
pType
->
bytes
,
slotId
,
pType
->
scale
,
pType
->
precision
,
pCaseNode
->
node
.
aliasName
);
pExp
->
pExpr
->
_optrRoot
.
pRootNode
=
pNode
;
pExp
->
pExpr
->
_optrRoot
.
pRootNode
=
pNode
;
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/index/inc/indexFst.h
浏览文件 @
b06870f7
...
@@ -290,21 +290,21 @@ bool fstVerify(Fst* fst);
...
@@ -290,21 +290,21 @@ bool fstVerify(Fst* fst);
// refactor this function
// refactor this function
bool
fstBuilderNodeCompileTo
(
FstBuilderNode
*
b
,
IdxFstFile
*
wrt
,
CompiledAddr
lastAddr
,
CompiledAddr
startAddr
);
bool
fstBuilderNodeCompileTo
(
FstBuilderNode
*
b
,
IdxFstFile
*
wrt
,
CompiledAddr
lastAddr
,
CompiledAddr
startAddr
);
typedef
struct
StreamState
{
typedef
struct
Fst
StreamState
{
FstNode
*
node
;
FstNode
*
node
;
uint64_t
trans
;
uint64_t
trans
;
FstOutput
out
;
FstOutput
out
;
void
*
autState
;
void
*
autState
;
}
StreamState
;
}
Fst
StreamState
;
void
s
treamStateDestroy
(
void
*
s
);
void
fstS
treamStateDestroy
(
void
*
s
);
typedef
struct
FStmSt
{
typedef
struct
FStmSt
{
Fst
*
fst
;
Fst
*
fst
;
FAutoCtx
*
aut
;
FAutoCtx
*
aut
;
SArray
*
inp
;
SArray
*
inp
;
FstOutput
emptyOutput
;
FstOutput
emptyOutput
;
SArray
*
stack
;
// <StreamState>
SArray
*
stack
;
// <
Fst
StreamState>
FstBoundWithData
*
endAt
;
FstBoundWithData
*
endAt
;
}
FStmSt
;
}
FStmSt
;
...
@@ -317,14 +317,14 @@ typedef struct FStmStRslt {
...
@@ -317,14 +317,14 @@ typedef struct FStmStRslt {
FStmStRslt
*
swsResultCreate
(
FstSlice
*
data
,
FstOutput
fOut
,
void
*
state
);
FStmStRslt
*
swsResultCreate
(
FstSlice
*
data
,
FstOutput
fOut
,
void
*
state
);
void
swsResultDestroy
(
FStmStRslt
*
result
);
void
swsResultDestroy
(
FStmStRslt
*
result
);
typedef
void
*
(
*
StreamCallback
)(
void
*
);
typedef
void
*
(
*
streamCallback__fn
)(
void
*
);
FStmSt
*
stmStCreate
(
Fst
*
fst
,
FAutoCtx
*
automation
,
FstBoundWithData
*
min
,
FstBoundWithData
*
max
);
FStmSt
*
stmStCreate
(
Fst
*
fst
,
FAutoCtx
*
automation
,
FstBoundWithData
*
min
,
FstBoundWithData
*
max
);
void
stmStDestroy
(
FStmSt
*
sws
);
void
stmStDestroy
(
FStmSt
*
sws
);
bool
stmStSeekMin
(
FStmSt
*
sws
,
FstBoundWithData
*
min
);
bool
stmStSeekMin
(
FStmSt
*
sws
,
FstBoundWithData
*
min
);
FStmStRslt
*
stmStNextWith
(
FStmSt
*
sws
,
StreamCallback
callback
);
FStmStRslt
*
stmStNextWith
(
FStmSt
*
sws
,
streamCallback__fn
callback
);
FStmBuilder
*
stmBuilderCreate
(
Fst
*
fst
,
FAutoCtx
*
aut
);
FStmBuilder
*
stmBuilderCreate
(
Fst
*
fst
,
FAutoCtx
*
aut
);
...
...
source/libs/index/src/indexFst.c
浏览文件 @
b06870f7
...
@@ -1165,7 +1165,7 @@ FStmSt* stmStCreate(Fst* fst, FAutoCtx* automation, FstBoundWithData* min, FstBo
...
@@ -1165,7 +1165,7 @@ FStmSt* stmStCreate(Fst* fst, FAutoCtx* automation, FstBoundWithData* min, FstBo
sws
->
emptyOutput
.
null
=
true
;
sws
->
emptyOutput
.
null
=
true
;
sws
->
emptyOutput
.
out
=
0
;
sws
->
emptyOutput
.
out
=
0
;
sws
->
stack
=
(
SArray
*
)
taosArrayInit
(
256
,
sizeof
(
StreamState
));
sws
->
stack
=
(
SArray
*
)
taosArrayInit
(
256
,
sizeof
(
Fst
StreamState
));
sws
->
endAt
=
max
;
sws
->
endAt
=
max
;
stmStSeekMin
(
sws
,
min
);
stmStSeekMin
(
sws
,
min
);
...
@@ -1177,7 +1177,7 @@ void stmStDestroy(FStmSt* sws) {
...
@@ -1177,7 +1177,7 @@ void stmStDestroy(FStmSt* sws) {
}
}
taosArrayDestroy
(
sws
->
inp
);
taosArrayDestroy
(
sws
->
inp
);
taosArrayDestroyEx
(
sws
->
stack
,
s
treamStateDestroy
);
taosArrayDestroyEx
(
sws
->
stack
,
fstS
treamStateDestroy
);
taosMemoryFree
(
sws
);
taosMemoryFree
(
sws
);
}
}
...
@@ -1188,10 +1188,10 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) {
...
@@ -1188,10 +1188,10 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) {
if
(
fstBoundWithDataIsIncluded
(
min
))
{
if
(
fstBoundWithDataIsIncluded
(
min
))
{
sws
->
emptyOutput
.
out
=
fstEmptyFinalOutput
(
sws
->
fst
,
&
(
sws
->
emptyOutput
.
null
));
sws
->
emptyOutput
.
out
=
fstEmptyFinalOutput
(
sws
->
fst
,
&
(
sws
->
emptyOutput
.
null
));
}
}
StreamState
s
=
{.
node
=
fstGetRoot
(
sws
->
fst
),
Fst
StreamState
s
=
{.
node
=
fstGetRoot
(
sws
->
fst
),
.
trans
=
0
,
.
trans
=
0
,
.
out
=
{.
null
=
false
,
.
out
=
0
},
.
out
=
{.
null
=
false
,
.
out
=
0
},
.
autState
=
automFuncs
[
aut
->
type
].
start
(
aut
)};
// auto.start callback
.
autState
=
automFuncs
[
aut
->
type
].
start
(
aut
)};
// auto.start callback
taosArrayPush
(
sws
->
stack
,
&
s
);
taosArrayPush
(
sws
->
stack
,
&
s
);
return
true
;
return
true
;
}
}
...
@@ -1223,7 +1223,7 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) {
...
@@ -1223,7 +1223,7 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) {
autState
=
automFuncs
[
aut
->
type
].
accept
(
aut
,
preState
,
b
);
autState
=
automFuncs
[
aut
->
type
].
accept
(
aut
,
preState
,
b
);
taosArrayPush
(
sws
->
inp
,
&
b
);
taosArrayPush
(
sws
->
inp
,
&
b
);
StreamState
s
=
{.
node
=
node
,
.
trans
=
res
+
1
,
.
out
=
{.
null
=
false
,
.
out
=
out
},
.
autState
=
preState
};
Fst
StreamState
s
=
{.
node
=
node
,
.
trans
=
res
+
1
,
.
out
=
{.
null
=
false
,
.
out
=
out
},
.
autState
=
preState
};
node
=
NULL
;
node
=
NULL
;
taosArrayPush
(
sws
->
stack
,
&
s
);
taosArrayPush
(
sws
->
stack
,
&
s
);
...
@@ -1244,7 +1244,7 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) {
...
@@ -1244,7 +1244,7 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) {
}
}
}
}
StreamState
s
=
{.
node
=
node
,
.
trans
=
i
,
.
out
=
{.
null
=
false
,
.
out
=
out
},
.
autState
=
autState
};
Fst
StreamState
s
=
{.
node
=
node
,
.
trans
=
i
,
.
out
=
{.
null
=
false
,
.
out
=
out
},
.
autState
=
autState
};
taosArrayPush
(
sws
->
stack
,
&
s
);
taosArrayPush
(
sws
->
stack
,
&
s
);
taosMemoryFree
(
trans
);
taosMemoryFree
(
trans
);
return
true
;
return
true
;
...
@@ -1255,7 +1255,7 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) {
...
@@ -1255,7 +1255,7 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) {
uint32_t
sz
=
taosArrayGetSize
(
sws
->
stack
);
uint32_t
sz
=
taosArrayGetSize
(
sws
->
stack
);
if
(
sz
!=
0
)
{
if
(
sz
!=
0
)
{
StreamState
*
s
=
taosArrayGet
(
sws
->
stack
,
sz
-
1
);
Fst
StreamState
*
s
=
taosArrayGet
(
sws
->
stack
,
sz
-
1
);
if
(
inclusize
)
{
if
(
inclusize
)
{
s
->
trans
-=
1
;
s
->
trans
-=
1
;
taosArrayPop
(
sws
->
inp
);
taosArrayPop
(
sws
->
inp
);
...
@@ -1264,7 +1264,7 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) {
...
@@ -1264,7 +1264,7 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) {
uint64_t
trans
=
s
->
trans
;
uint64_t
trans
=
s
->
trans
;
FstTransition
trn
;
FstTransition
trn
;
fstNodeGetTransitionAt
(
n
,
trans
-
1
,
&
trn
);
fstNodeGetTransitionAt
(
n
,
trans
-
1
,
&
trn
);
StreamState
s
=
{
Fst
StreamState
s
=
{
.
node
=
fstGetNode
(
sws
->
fst
,
trn
.
addr
),
.
trans
=
0
,
.
out
=
{.
null
=
false
,
.
out
=
out
},
.
autState
=
autState
};
.
node
=
fstGetNode
(
sws
->
fst
,
trn
.
addr
),
.
trans
=
0
,
.
out
=
{.
null
=
false
,
.
out
=
out
},
.
autState
=
autState
};
taosArrayPush
(
sws
->
stack
,
&
s
);
taosArrayPush
(
sws
->
stack
,
&
s
);
return
true
;
return
true
;
...
@@ -1274,14 +1274,14 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) {
...
@@ -1274,14 +1274,14 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) {
return
false
;
return
false
;
}
}
FStmStRslt
*
stmStNextWith
(
FStmSt
*
sws
,
StreamCallback
callback
)
{
FStmStRslt
*
stmStNextWith
(
FStmSt
*
sws
,
streamCallback__fn
callback
)
{
FAutoCtx
*
aut
=
sws
->
aut
;
FAutoCtx
*
aut
=
sws
->
aut
;
FstOutput
output
=
sws
->
emptyOutput
;
FstOutput
output
=
sws
->
emptyOutput
;
if
(
output
.
null
==
false
)
{
if
(
output
.
null
==
false
)
{
FstSlice
emptySlice
=
fstSliceCreate
(
NULL
,
0
);
FstSlice
emptySlice
=
fstSliceCreate
(
NULL
,
0
);
if
(
fstBoundWithDataExceededBy
(
sws
->
endAt
,
&
emptySlice
))
{
if
(
fstBoundWithDataExceededBy
(
sws
->
endAt
,
&
emptySlice
))
{
taosArrayDestroyEx
(
sws
->
stack
,
s
treamStateDestroy
);
taosArrayDestroyEx
(
sws
->
stack
,
fstS
treamStateDestroy
);
sws
->
stack
=
(
SArray
*
)
taosArrayInit
(
256
,
sizeof
(
StreamState
));
sws
->
stack
=
(
SArray
*
)
taosArrayInit
(
256
,
sizeof
(
Fst
StreamState
));
return
NULL
;
return
NULL
;
}
}
void
*
start
=
automFuncs
[
aut
->
type
].
start
(
aut
);
void
*
start
=
automFuncs
[
aut
->
type
].
start
(
aut
);
...
@@ -1292,12 +1292,12 @@ FStmStRslt* stmStNextWith(FStmSt* sws, StreamCallback callback) {
...
@@ -1292,12 +1292,12 @@ FStmStRslt* stmStNextWith(FStmSt* sws, StreamCallback callback) {
}
}
SArray
*
nodes
=
taosArrayInit
(
8
,
sizeof
(
FstNode
*
));
SArray
*
nodes
=
taosArrayInit
(
8
,
sizeof
(
FstNode
*
));
while
(
taosArrayGetSize
(
sws
->
stack
)
>
0
)
{
while
(
taosArrayGetSize
(
sws
->
stack
)
>
0
)
{
StreamState
*
p
=
(
StreamState
*
)
taosArrayPop
(
sws
->
stack
);
FstStreamState
*
p
=
(
Fst
StreamState
*
)
taosArrayPop
(
sws
->
stack
);
if
(
p
->
trans
>=
FST_NODE_LEN
(
p
->
node
)
||
!
automFuncs
[
aut
->
type
].
canMatch
(
aut
,
p
->
autState
))
{
if
(
p
->
trans
>=
FST_NODE_LEN
(
p
->
node
)
||
!
automFuncs
[
aut
->
type
].
canMatch
(
aut
,
p
->
autState
))
{
if
(
FST_NODE_ADDR
(
p
->
node
)
!=
fstGetRootAddr
(
sws
->
fst
))
{
if
(
FST_NODE_ADDR
(
p
->
node
)
!=
fstGetRootAddr
(
sws
->
fst
))
{
taosArrayPop
(
sws
->
inp
);
taosArrayPop
(
sws
->
inp
);
}
}
s
treamStateDestroy
(
p
);
fstS
treamStateDestroy
(
p
);
continue
;
continue
;
}
}
FstTransition
trn
;
FstTransition
trn
;
...
@@ -1318,10 +1318,10 @@ FStmStRslt* stmStNextWith(FStmSt* sws, StreamCallback callback) {
...
@@ -1318,10 +1318,10 @@ FStmStRslt* stmStNextWith(FStmSt* sws, StreamCallback callback) {
isMatch
=
automFuncs
[
aut
->
type
].
isMatch
(
aut
,
eofState
);
isMatch
=
automFuncs
[
aut
->
type
].
isMatch
(
aut
,
eofState
);
}
}
}
}
StreamState
s1
=
{.
node
=
p
->
node
,
.
trans
=
p
->
trans
+
1
,
.
out
=
p
->
out
,
.
autState
=
p
->
autState
};
Fst
StreamState
s1
=
{.
node
=
p
->
node
,
.
trans
=
p
->
trans
+
1
,
.
out
=
p
->
out
,
.
autState
=
p
->
autState
};
taosArrayPush
(
sws
->
stack
,
&
s1
);
taosArrayPush
(
sws
->
stack
,
&
s1
);
StreamState
s2
=
{.
node
=
nextNode
,
.
trans
=
0
,
.
out
=
{.
null
=
false
,
.
out
=
out
},
.
autState
=
nextState
};
Fst
StreamState
s2
=
{.
node
=
nextNode
,
.
trans
=
0
,
.
out
=
{.
null
=
false
,
.
out
=
out
},
.
autState
=
nextState
};
taosArrayPush
(
sws
->
stack
,
&
s2
);
taosArrayPush
(
sws
->
stack
,
&
s2
);
int32_t
isz
=
taosArrayGetSize
(
sws
->
inp
);
int32_t
isz
=
taosArrayGetSize
(
sws
->
inp
);
...
@@ -1331,8 +1331,8 @@ FStmStRslt* stmStNextWith(FStmSt* sws, StreamCallback callback) {
...
@@ -1331,8 +1331,8 @@ FStmStRslt* stmStNextWith(FStmSt* sws, StreamCallback callback) {
}
}
FstSlice
slice
=
fstSliceCreate
(
buf
,
isz
);
FstSlice
slice
=
fstSliceCreate
(
buf
,
isz
);
if
(
fstBoundWithDataExceededBy
(
sws
->
endAt
,
&
slice
))
{
if
(
fstBoundWithDataExceededBy
(
sws
->
endAt
,
&
slice
))
{
taosArrayDestroyEx
(
sws
->
stack
,
s
treamStateDestroy
);
taosArrayDestroyEx
(
sws
->
stack
,
fstS
treamStateDestroy
);
sws
->
stack
=
(
SArray
*
)
taosArrayInit
(
256
,
sizeof
(
StreamState
));
sws
->
stack
=
(
SArray
*
)
taosArrayInit
(
256
,
sizeof
(
Fst
StreamState
));
taosMemoryFreeClear
(
buf
);
taosMemoryFreeClear
(
buf
);
fstSliceDestroy
(
&
slice
);
fstSliceDestroy
(
&
slice
);
taosArrayDestroy
(
nodes
);
taosArrayDestroy
(
nodes
);
...
@@ -1375,11 +1375,11 @@ void swsResultDestroy(FStmStRslt* result) {
...
@@ -1375,11 +1375,11 @@ void swsResultDestroy(FStmStRslt* result) {
taosMemoryFree
(
result
);
taosMemoryFree
(
result
);
}
}
void
s
treamStateDestroy
(
void
*
s
)
{
void
fstS
treamStateDestroy
(
void
*
s
)
{
if
(
NULL
==
s
)
{
if
(
NULL
==
s
)
{
return
;
return
;
}
}
StreamState
*
ss
=
(
StreamState
*
)
s
;
FstStreamState
*
ss
=
(
Fst
StreamState
*
)
s
;
fstNodeDestroy
(
ss
->
node
);
fstNodeDestroy
(
ss
->
node
);
}
}
...
...
source/libs/index/src/indexJson.c
浏览文件 @
b06870f7
...
@@ -30,7 +30,7 @@ int indexJsonPut(SIndexJson *index, SIndexJsonMultiTerm *terms, uint64_t uid) {
...
@@ -30,7 +30,7 @@ int indexJsonPut(SIndexJson *index, SIndexJsonMultiTerm *terms, uint64_t uid) {
}
else
{
}
else
{
p
->
colType
=
TSDB_DATA_TYPE_DOUBLE
;
p
->
colType
=
TSDB_DATA_TYPE_DOUBLE
;
}
}
IDX_TYPE_ADD_EXTERN_TYPE
(
p
->
colType
,
TSDB_DATA_TYPE_JSON
);
IDX_TYPE_ADD_EXTERN_TYPE
(
(
p
->
colType
)
,
TSDB_DATA_TYPE_JSON
);
}
}
// handle put
// handle put
return
indexPut
(
index
,
terms
,
uid
);
return
indexPut
(
index
,
terms
,
uid
);
...
...
source/libs/sync/inc/syncAppendEntries.h
浏览文件 @
b06870f7
...
@@ -92,9 +92,8 @@ extern "C" {
...
@@ -92,9 +92,8 @@ extern "C" {
// /\ UNCHANGED <<serverVars, commitIndex, messages>>
// /\ UNCHANGED <<serverVars, commitIndex, messages>>
// /\ UNCHANGED <<candidateVars, leaderVars>>
// /\ UNCHANGED <<candidateVars, leaderVars>>
//
//
int32_t
syncNodeOnAppendEntriesCb
(
SSyncNode
*
ths
,
SyncAppendEntries
*
pMsg
);
int32_t
syncNodeOnAppendEntriesSnapshotCb
(
SSyncNode
*
ths
,
SyncAppendEntries
*
pMsg
);
int32_t
syncNodeOnAppendEntries
(
SSyncNode
*
ths
,
SyncAppendEntries
*
pMsg
);
int32_t
syncNodeOnAppendEntriesSnapshot2Cb
(
SSyncNode
*
ths
,
SyncAppendEntriesBatch
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/sync/inc/syncAppendEntriesReply.h
浏览文件 @
b06870f7
...
@@ -40,9 +40,7 @@ extern "C" {
...
@@ -40,9 +40,7 @@ extern "C" {
// /\ Discard(m)
// /\ Discard(m)
// /\ UNCHANGED <<serverVars, candidateVars, logVars, elections>>
// /\ UNCHANGED <<serverVars, candidateVars, logVars, elections>>
//
//
int32_t
syncNodeOnAppendEntriesReplyCb
(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
syncNodeOnAppendEntriesReply
(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
syncNodeOnAppendEntriesReplySnapshotCb
(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
syncNodeOnAppendEntriesReplySnapshot2Cb
(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/sync/inc/syncElection.h
浏览文件 @
b06870f7
...
@@ -37,12 +37,10 @@ extern "C" {
...
@@ -37,12 +37,10 @@ extern "C" {
// msource |-> i,
// msource |-> i,
// mdest |-> j])
// mdest |-> j])
// /\ UNCHANGED <<serverVars, candidateVars, leaderVars, logVars>>
// /\ UNCHANGED <<serverVars, candidateVars, leaderVars, logVars>>
//
int32_t
syncNodeRequestVotePeers
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeRequestVotePeersSnapshot
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeElect
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeElect
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeRequestVote
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
const
SyncRequestVote
*
pMsg
);
int32_t
syncNodeRequestVotePeers
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeSendRequestVote
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
const
SyncRequestVote
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/sync/inc/syncEnv.h
浏览文件 @
b06870f7
...
@@ -28,13 +28,13 @@ extern "C" {
...
@@ -28,13 +28,13 @@ extern "C" {
#include "trpc.h"
#include "trpc.h"
#include "ttimer.h"
#include "ttimer.h"
#define TIMER_MAX_MS
0x7FFFFFFF
#define TIMER_MAX_MS 0x7FFFFFFF
#define ENV_TICK_TIMER_MS
1000
#define ENV_TICK_TIMER_MS 1000
#define PING_TIMER_MS
5000
#define PING_TIMER_MS 5000
#define ELECT_TIMER_MS_MIN
5000
#define ELECT_TIMER_MS_MIN 5000
#define ELECT_TIMER_MS_MAX
(ELECT_TIMER_MS_MIN * 2)
#define ELECT_TIMER_MS_MAX (ELECT_TIMER_MS_MIN * 2)
#define ELECT_TIMER_MS_RANGE (ELECT_TIMER_MS_MAX - ELECT_TIMER_MS_MIN)
#define ELECT_TIMER_MS_RANGE (ELECT_TIMER_MS_MAX - ELECT_TIMER_MS_MIN)
#define HEARTBEAT_TIMER_MS
900
#define HEARTBEAT_TIMER_MS 900
#define EMPTY_RAFT_ID ((SRaftId){.addr = 0, .vgId = 0})
#define EMPTY_RAFT_ID ((SRaftId){.addr = 0, .vgId = 0})
...
...
source/libs/sync/inc/syncIO.h
浏览文件 @
b06870f7
...
@@ -56,9 +56,8 @@ typedef struct SSyncIO {
...
@@ -56,9 +56,8 @@ typedef struct SSyncIO {
int32_t
(
*
FpOnSyncAppendEntries
)(
SSyncNode
*
pSyncNode
,
SyncAppendEntries
*
pMsg
);
int32_t
(
*
FpOnSyncAppendEntries
)(
SSyncNode
*
pSyncNode
,
SyncAppendEntries
*
pMsg
);
int32_t
(
*
FpOnSyncAppendEntriesReply
)(
SSyncNode
*
pSyncNode
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
(
*
FpOnSyncAppendEntriesReply
)(
SSyncNode
*
pSyncNode
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
(
*
FpOnSyncTimeout
)(
SSyncNode
*
pSyncNode
,
SyncTimeout
*
pMsg
);
int32_t
(
*
FpOnSyncTimeout
)(
SSyncNode
*
pSyncNode
,
SyncTimeout
*
pMsg
);
int32_t
(
*
FpOnSyncSnapshot
)(
SSyncNode
*
pSyncNode
,
SyncSnapshotSend
*
pMsg
);
int32_t
(
*
FpOnSyncSnapshotSend
)(
SSyncNode
*
pSyncNode
,
SyncSnapshotSend
*
pMsg
);
int32_t
(
*
FpOnSyncSnapshotReply
)(
SSyncNode
*
pSyncNode
,
SyncSnapshotRsp
*
pMsg
);
int32_t
(
*
FpOnSyncSnapshotRsp
)(
SSyncNode
*
pSyncNode
,
SyncSnapshotRsp
*
pMsg
);
int8_t
isStart
;
int8_t
isStart
;
...
...
source/libs/sync/inc/syncIndexMgr.h
浏览文件 @
b06870f7
...
@@ -45,8 +45,8 @@ void syncIndexMgrDestroy(SSyncIndexMgr *pSyncIndexMgr);
...
@@ -45,8 +45,8 @@ void syncIndexMgrDestroy(SSyncIndexMgr *pSyncIndexMgr);
void
syncIndexMgrClear
(
SSyncIndexMgr
*
pSyncIndexMgr
);
void
syncIndexMgrClear
(
SSyncIndexMgr
*
pSyncIndexMgr
);
void
syncIndexMgrSetIndex
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
,
SyncIndex
index
);
void
syncIndexMgrSetIndex
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
,
SyncIndex
index
);
SyncIndex
syncIndexMgrGetIndex
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
);
SyncIndex
syncIndexMgrGetIndex
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
);
cJSON
*
syncIndexMgr2Json
(
SSyncIndexMgr
*
pSyncIndexMgr
);
cJSON
*
syncIndexMgr2Json
(
SSyncIndexMgr
*
pSyncIndexMgr
);
char
*
syncIndexMgr2Str
(
SSyncIndexMgr
*
pSyncIndexMgr
);
char
*
syncIndexMgr2Str
(
SSyncIndexMgr
*
pSyncIndexMgr
);
void
syncIndexMgrSetStartTime
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
,
int64_t
startTime
);
void
syncIndexMgrSetStartTime
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
,
int64_t
startTime
);
int64_t
syncIndexMgrGetStartTime
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
);
int64_t
syncIndexMgrGetStartTime
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
);
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
b06870f7
...
@@ -57,9 +57,37 @@ typedef struct SRaftCfg SRaftCfg;
...
@@ -57,9 +57,37 @@ typedef struct SRaftCfg SRaftCfg;
typedef
struct
SSyncRespMgr
SSyncRespMgr
;
typedef
struct
SSyncRespMgr
SSyncRespMgr
;
typedef
struct
SSyncSnapshotSender
SSyncSnapshotSender
;
typedef
struct
SSyncSnapshotSender
SSyncSnapshotSender
;
typedef
struct
SSyncSnapshotReceiver
SSyncSnapshotReceiver
;
typedef
struct
SSyncSnapshotReceiver
SSyncSnapshotReceiver
;
typedef
struct
SSyncTimer
SSyncTimer
;
typedef
struct
SSyncHbTimerData
SSyncHbTimerData
;
extern
bool
gRaftDetailLog
;
extern
bool
gRaftDetailLog
;
typedef
struct
SSyncHbTimerData
{
SSyncNode
*
pSyncNode
;
SSyncTimer
*
pTimer
;
SRaftId
destId
;
uint64_t
logicClock
;
}
SSyncHbTimerData
;
typedef
struct
SSyncTimer
{
void
*
pTimer
;
TAOS_TMR_CALLBACK
timerCb
;
uint64_t
logicClock
;
uint64_t
counter
;
int32_t
timerMS
;
SRaftId
destId
;
void
*
pData
;
}
SSyncTimer
;
int32_t
syncHbTimerInit
(
SSyncNode
*
pSyncNode
,
SSyncTimer
*
pSyncTimer
,
SRaftId
destId
);
int32_t
syncHbTimerStart
(
SSyncNode
*
pSyncNode
,
SSyncTimer
*
pSyncTimer
);
int32_t
syncHbTimerStop
(
SSyncNode
*
pSyncNode
,
SSyncTimer
*
pSyncTimer
);
typedef
struct
SPeerState
{
SyncIndex
lastSendIndex
;
int64_t
lastSendTime
;
}
SPeerState
;
typedef
struct
SSyncNode
{
typedef
struct
SSyncNode
{
// init by SSyncInfo
// init by SSyncInfo
SyncGroupId
vgId
;
SyncGroupId
vgId
;
...
@@ -73,6 +101,7 @@ typedef struct SSyncNode {
...
@@ -73,6 +101,7 @@ typedef struct SSyncNode {
const
SMsgCb
*
msgcb
;
const
SMsgCb
*
msgcb
;
int32_t
(
*
FpSendMsg
)(
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
int32_t
(
*
FpSendMsg
)(
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
int32_t
(
*
FpEqMsg
)(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
);
int32_t
(
*
FpEqMsg
)(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
);
int32_t
(
*
FpEqCtrlMsg
)(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
);
// init internal
// init internal
SNodeInfo
myNodeInfo
;
SNodeInfo
myNodeInfo
;
...
@@ -138,6 +167,9 @@ typedef struct SSyncNode {
...
@@ -138,6 +167,9 @@ typedef struct SSyncNode {
TAOS_TMR_CALLBACK
FpHeartbeatTimerCB
;
// Timer Fp
TAOS_TMR_CALLBACK
FpHeartbeatTimerCB
;
// Timer Fp
uint64_t
heartbeatTimerCounter
;
uint64_t
heartbeatTimerCounter
;
// peer heartbeat timer
SSyncTimer
peerHeartbeatTimerArr
[
TSDB_MAX_REPLICA
];
// callback
// callback
FpOnPingCb
FpOnPing
;
FpOnPingCb
FpOnPing
;
FpOnPingReplyCb
FpOnPingReply
;
FpOnPingReplyCb
FpOnPingReply
;
...
@@ -147,8 +179,8 @@ typedef struct SSyncNode {
...
@@ -147,8 +179,8 @@ typedef struct SSyncNode {
FpOnRequestVoteReplyCb
FpOnRequestVoteReply
;
FpOnRequestVoteReplyCb
FpOnRequestVoteReply
;
FpOnAppendEntriesCb
FpOnAppendEntries
;
FpOnAppendEntriesCb
FpOnAppendEntries
;
FpOnAppendEntriesReplyCb
FpOnAppendEntriesReply
;
FpOnAppendEntriesReplyCb
FpOnAppendEntriesReply
;
FpOnSnapshot
SendCb
FpOnSnapshotSend
;
FpOnSnapshot
Cb
FpOnSnapshot
;
FpOnSnapshotR
spCb
FpOnSnapshotRsp
;
FpOnSnapshotR
eplyCb
FpOnSnapshotReply
;
// tools
// tools
SSyncRespMgr
*
pSyncRespMgr
;
SSyncRespMgr
*
pSyncRespMgr
;
...
@@ -159,9 +191,15 @@ typedef struct SSyncNode {
...
@@ -159,9 +191,15 @@ typedef struct SSyncNode {
SSyncSnapshotSender
*
senders
[
TSDB_MAX_REPLICA
];
SSyncSnapshotSender
*
senders
[
TSDB_MAX_REPLICA
];
SSyncSnapshotReceiver
*
pNewNodeReceiver
;
SSyncSnapshotReceiver
*
pNewNodeReceiver
;
SPeerState
peerStates
[
TSDB_MAX_REPLICA
];
// is config changing
// is config changing
bool
changing
;
bool
changing
;
int64_t
snapshottingIndex
;
int64_t
snapshottingTime
;
int64_t
minMatchIndex
;
int64_t
startTime
;
int64_t
startTime
;
int64_t
leaderTime
;
int64_t
leaderTime
;
int64_t
lastReplicateTime
;
int64_t
lastReplicateTime
;
...
@@ -174,7 +212,6 @@ void syncNodeStart(SSyncNode* pSyncNode);
...
@@ -174,7 +212,6 @@ void syncNodeStart(SSyncNode* pSyncNode);
void
syncNodeStartStandBy
(
SSyncNode
*
pSyncNode
);
void
syncNodeStartStandBy
(
SSyncNode
*
pSyncNode
);
void
syncNodeClose
(
SSyncNode
*
pSyncNode
);
void
syncNodeClose
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodePropose
(
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
,
bool
isWeak
);
int32_t
syncNodePropose
(
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
,
bool
isWeak
);
int32_t
syncNodeProposeBatch
(
SSyncNode
*
pSyncNode
,
SRpcMsg
**
pMsgPArr
,
bool
*
pIsWeakArr
,
int32_t
arrSize
);
// option
// option
bool
syncNodeSnapshotEnable
(
SSyncNode
*
pSyncNode
);
bool
syncNodeSnapshotEnable
(
SSyncNode
*
pSyncNode
);
...
@@ -197,23 +234,21 @@ int32_t syncNodeRestartElectTimer(SSyncNode* pSyncNode, int32_t ms);
...
@@ -197,23 +234,21 @@ int32_t syncNodeRestartElectTimer(SSyncNode* pSyncNode, int32_t ms);
int32_t
syncNodeResetElectTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeResetElectTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStartHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStartHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStartHeartbeatTimerNow
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStartHeartbeatTimerMS
(
SSyncNode
*
pSyncNode
,
int32_t
ms
);
int32_t
syncNodeStopHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStopHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeRestartHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeRestartHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeRestartHeartbeatTimerNow
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeRestartNowHeartbeatTimerMS
(
SSyncNode
*
pSyncNode
,
int32_t
ms
);
// utils --------------
// utils --------------
int32_t
syncNodeSendMsgById
(
const
SRaftId
*
destRaftId
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
);
int32_t
syncNodeSendMsgById
(
const
SRaftId
*
destRaftId
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
);
int32_t
syncNodeSendMsgByInfo
(
const
SNodeInfo
*
nodeInfo
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
);
int32_t
syncNodeSendMsgByInfo
(
const
SNodeInfo
*
nodeInfo
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
);
cJSON
*
syncNode2Json
(
const
SSyncNode
*
pSyncNode
);
cJSON
*
syncNode2Json
(
const
SSyncNode
*
pSyncNode
);
char
*
syncNode2Str
(
const
SSyncNode
*
pSyncNode
);
char
*
syncNode2Str
(
const
SSyncNode
*
pSyncNode
);
void
syncNodeEventLog
(
const
SSyncNode
*
pSyncNode
,
char
*
str
);
void
syncNodeEventLog
(
const
SSyncNode
*
pSyncNode
,
char
*
str
);
void
syncNodeErrorLog
(
const
SSyncNode
*
pSyncNode
,
char
*
str
);
void
syncNodeErrorLog
(
const
SSyncNode
*
pSyncNode
,
char
*
str
);
char
*
syncNode2SimpleStr
(
const
SSyncNode
*
pSyncNode
);
char
*
syncNode2SimpleStr
(
const
SSyncNode
*
pSyncNode
);
bool
syncNodeInConfig
(
SSyncNode
*
pSyncNode
,
const
SSyncCfg
*
config
);
bool
syncNodeInConfig
(
SSyncNode
*
pSyncNode
,
const
SSyncCfg
*
config
);
void
syncNodeDoConfigChange
(
SSyncNode
*
pSyncNode
,
SSyncCfg
*
newConfig
,
SyncIndex
lastConfigChangeIndex
);
void
syncNodeDoConfigChange
(
SSyncNode
*
pSyncNode
,
SSyncCfg
*
newConfig
,
SyncIndex
lastConfigChangeIndex
);
SyncIndex
syncMinMatchIndex
(
SSyncNode
*
pSyncNode
);
char
*
syncNodePeerState2Str
(
const
SSyncNode
*
pSyncNode
);
SSyncNode
*
syncNodeAcquire
(
int64_t
rid
);
SSyncNode
*
syncNodeAcquire
(
int64_t
rid
);
void
syncNodeRelease
(
SSyncNode
*
pNode
);
void
syncNodeRelease
(
SSyncNode
*
pNode
);
...
@@ -221,6 +256,7 @@ void syncNodeRelease(SSyncNode* pNode);
...
@@ -221,6 +256,7 @@ void syncNodeRelease(SSyncNode* pNode);
// raft state change --------------
// raft state change --------------
void
syncNodeUpdateTerm
(
SSyncNode
*
pSyncNode
,
SyncTerm
term
);
void
syncNodeUpdateTerm
(
SSyncNode
*
pSyncNode
,
SyncTerm
term
);
void
syncNodeUpdateTermWithoutStepDown
(
SSyncNode
*
pSyncNode
,
SyncTerm
term
);
void
syncNodeUpdateTermWithoutStepDown
(
SSyncNode
*
pSyncNode
,
SyncTerm
term
);
void
syncNodeStepDown
(
SSyncNode
*
pSyncNode
,
SyncTerm
newTerm
);
void
syncNodeBecomeFollower
(
SSyncNode
*
pSyncNode
,
const
char
*
debugStr
);
void
syncNodeBecomeFollower
(
SSyncNode
*
pSyncNode
,
const
char
*
debugStr
);
void
syncNodeBecomeLeader
(
SSyncNode
*
pSyncNode
,
const
char
*
debugStr
);
void
syncNodeBecomeLeader
(
SSyncNode
*
pSyncNode
,
const
char
*
debugStr
);
...
@@ -240,21 +276,23 @@ void syncNodeMaybeUpdateCommitBySnapshot(SSyncNode* pSyncNode);
...
@@ -240,21 +276,23 @@ void syncNodeMaybeUpdateCommitBySnapshot(SSyncNode* pSyncNode);
SyncIndex
syncNodeGetLastIndex
(
const
SSyncNode
*
pSyncNode
);
SyncIndex
syncNodeGetLastIndex
(
const
SSyncNode
*
pSyncNode
);
SyncTerm
syncNodeGetLastTerm
(
SSyncNode
*
pSyncNode
);
SyncTerm
syncNodeGetLastTerm
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeGetLastIndexTerm
(
SSyncNode
*
pSyncNode
,
SyncIndex
*
pLastIndex
,
SyncTerm
*
pLastTerm
);
int32_t
syncNodeGetLastIndexTerm
(
SSyncNode
*
pSyncNode
,
SyncIndex
*
pLastIndex
,
SyncTerm
*
pLastTerm
);
SyncIndex
syncNodeSyncStartIndex
(
SSyncNode
*
pSyncNode
);
SyncIndex
syncNodeSyncStartIndex
(
SSyncNode
*
pSyncNode
);
SyncIndex
syncNodeGetPreIndex
(
SSyncNode
*
pSyncNode
,
SyncIndex
index
);
SyncIndex
syncNodeGetPreIndex
(
SSyncNode
*
pSyncNode
,
SyncIndex
index
);
SyncTerm
syncNodeGetPreTerm
(
SSyncNode
*
pSyncNode
,
SyncIndex
index
);
SyncTerm
syncNodeGetPreTerm
(
SSyncNode
*
pSyncNode
,
SyncIndex
index
);
int32_t
syncNodeGetPreIndexTerm
(
SSyncNode
*
pSyncNode
,
SyncIndex
index
,
SyncIndex
*
pPreIndex
,
SyncTerm
*
pPreTerm
);
int32_t
syncNodeGetPreIndexTerm
(
SSyncNode
*
pSyncNode
,
SyncIndex
index
,
SyncIndex
*
pPreIndex
,
SyncTerm
*
pPreTerm
);
bool
syncNodeIsOptimizedOneReplica
(
SSyncNode
*
ths
,
SRpcMsg
*
pMsg
);
bool
syncNodeIsOptimizedOneReplica
(
SSyncNode
*
ths
,
SRpcMsg
*
pMsg
);
int32_t
syncNodeCommit
(
SSyncNode
*
ths
,
SyncIndex
beginIndex
,
SyncIndex
endIndex
,
uint64_t
flag
);
int32_t
syncNodeDoCommit
(
SSyncNode
*
ths
,
SyncIndex
beginIndex
,
SyncIndex
endIndex
,
uint64_t
flag
);
int32_t
syncNodeFollowerCommit
(
SSyncNode
*
ths
,
SyncIndex
newCommitIndex
);
int32_t
syncNodePreCommit
(
SSyncNode
*
ths
,
SSyncRaftEntry
*
pEntry
,
int32_t
code
);
int32_t
syncNodePreCommit
(
SSyncNode
*
ths
,
SSyncRaftEntry
*
pEntry
,
int32_t
code
);
int32_t
syncNodeUpdateNewConfigIndex
(
SSyncNode
*
ths
,
SSyncCfg
*
pNewCfg
);
int32_t
syncNodeUpdateNewConfigIndex
(
SSyncNode
*
ths
,
SSyncCfg
*
pNewCfg
);
bool
syncNodeInRaftGroup
(
SSyncNode
*
ths
,
SRaftId
*
pRaftId
);
bool
syncNodeInRaftGroup
(
SSyncNode
*
ths
,
SRaftId
*
pRaftId
);
SSyncSnapshotSender
*
syncNodeGetSnapshotSender
(
SSyncNode
*
ths
,
SRaftId
*
pDestId
);
SSyncSnapshotSender
*
syncNodeGetSnapshotSender
(
SSyncNode
*
ths
,
SRaftId
*
pDestId
);
SSyncTimer
*
syncNodeGetHbTimer
(
SSyncNode
*
ths
,
SRaftId
*
pDestId
);
SPeerState
*
syncNodeGetPeerState
(
SSyncNode
*
ths
,
const
SRaftId
*
pDestId
);
bool
syncNodeNeedSendAppendEntries
(
SSyncNode
*
ths
,
const
SRaftId
*
pDestId
,
const
SyncAppendEntries
*
pMsg
);
int32_t
syncGetSnapshotMeta
(
int64_t
rid
,
struct
SSnapshotMeta
*
sMeta
);
int32_t
syncGetSnapshotMeta
(
int64_t
rid
,
struct
SSnapshotMeta
*
sMeta
);
int32_t
syncGetSnapshotMetaByIndex
(
int64_t
rid
,
SyncIndex
snapshotIndex
,
struct
SSnapshotMeta
*
sMeta
);
int32_t
syncGetSnapshotMetaByIndex
(
int64_t
rid
,
SyncIndex
snapshotIndex
,
struct
SSnapshotMeta
*
sMeta
);
...
@@ -271,7 +309,12 @@ int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftEntry* p
...
@@ -271,7 +309,12 @@ int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftEntry* p
int32_t
syncNodeDynamicQuorum
(
const
SSyncNode
*
pSyncNode
);
int32_t
syncNodeDynamicQuorum
(
const
SSyncNode
*
pSyncNode
);
bool
syncNodeIsMnode
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodePeerStateInit
(
SSyncNode
*
pSyncNode
);
// trace log
// trace log
void
syncLogRecvTimer
(
SSyncNode
*
pSyncNode
,
const
SyncTimeout
*
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
);
...
...
source/libs/sync/inc/syncRaftCfg.h
浏览文件 @
b06870f7
...
@@ -45,8 +45,8 @@ int32_t raftCfgIndexClose(SRaftCfgIndex *pRaftCfgIndex);
...
@@ -45,8 +45,8 @@ int32_t raftCfgIndexClose(SRaftCfgIndex *pRaftCfgIndex);
int32_t
raftCfgIndexPersist
(
SRaftCfgIndex
*
pRaftCfgIndex
);
int32_t
raftCfgIndexPersist
(
SRaftCfgIndex
*
pRaftCfgIndex
);
int32_t
raftCfgIndexAddConfigIndex
(
SRaftCfgIndex
*
pRaftCfgIndex
,
SyncIndex
configIndex
);
int32_t
raftCfgIndexAddConfigIndex
(
SRaftCfgIndex
*
pRaftCfgIndex
,
SyncIndex
configIndex
);
cJSON
*
raftCfgIndex2Json
(
SRaftCfgIndex
*
pRaftCfgIndex
);
cJSON
*
raftCfgIndex2Json
(
SRaftCfgIndex
*
pRaftCfgIndex
);
char
*
raftCfgIndex2Str
(
SRaftCfgIndex
*
pRaftCfgIndex
);
char
*
raftCfgIndex2Str
(
SRaftCfgIndex
*
pRaftCfgIndex
);
int32_t
raftCfgIndexFromJson
(
const
cJSON
*
pRoot
,
SRaftCfgIndex
*
pRaftCfgIndex
);
int32_t
raftCfgIndexFromJson
(
const
cJSON
*
pRoot
,
SRaftCfgIndex
*
pRaftCfgIndex
);
int32_t
raftCfgIndexFromStr
(
const
char
*
s
,
SRaftCfgIndex
*
pRaftCfgIndex
);
int32_t
raftCfgIndexFromStr
(
const
char
*
s
,
SRaftCfgIndex
*
pRaftCfgIndex
);
...
@@ -73,14 +73,14 @@ int32_t raftCfgClose(SRaftCfg *pRaftCfg);
...
@@ -73,14 +73,14 @@ int32_t raftCfgClose(SRaftCfg *pRaftCfg);
int32_t
raftCfgPersist
(
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgPersist
(
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgAddConfigIndex
(
SRaftCfg
*
pRaftCfg
,
SyncIndex
configIndex
);
int32_t
raftCfgAddConfigIndex
(
SRaftCfg
*
pRaftCfg
,
SyncIndex
configIndex
);
cJSON
*
syncCfg2Json
(
SSyncCfg
*
pSyncCfg
);
cJSON
*
syncCfg2Json
(
SSyncCfg
*
pSyncCfg
);
char
*
syncCfg2Str
(
SSyncCfg
*
pSyncCfg
);
char
*
syncCfg2Str
(
SSyncCfg
*
pSyncCfg
);
char
*
syncCfg2SimpleStr
(
SSyncCfg
*
pSyncCfg
);
char
*
syncCfg2SimpleStr
(
SSyncCfg
*
pSyncCfg
);
int32_t
syncCfgFromJson
(
const
cJSON
*
pRoot
,
SSyncCfg
*
pSyncCfg
);
int32_t
syncCfgFromJson
(
const
cJSON
*
pRoot
,
SSyncCfg
*
pSyncCfg
);
int32_t
syncCfgFromStr
(
const
char
*
s
,
SSyncCfg
*
pSyncCfg
);
int32_t
syncCfgFromStr
(
const
char
*
s
,
SSyncCfg
*
pSyncCfg
);
cJSON
*
raftCfg2Json
(
SRaftCfg
*
pRaftCfg
);
cJSON
*
raftCfg2Json
(
SRaftCfg
*
pRaftCfg
);
char
*
raftCfg2Str
(
SRaftCfg
*
pRaftCfg
);
char
*
raftCfg2Str
(
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgFromJson
(
const
cJSON
*
pRoot
,
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgFromJson
(
const
cJSON
*
pRoot
,
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgFromStr
(
const
char
*
s
,
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgFromStr
(
const
char
*
s
,
SRaftCfg
*
pRaftCfg
);
...
...
source/libs/sync/inc/syncReplication.h
浏览文件 @
b06870f7
...
@@ -50,16 +50,15 @@ extern "C" {
...
@@ -50,16 +50,15 @@ extern "C" {
// msource |-> i,
// msource |-> i,
// mdest |-> j])
// mdest |-> j])
// /\ UNCHANGED <<serverVars, candidateVars, leaderVars, logVars>>
// /\ UNCHANGED <<serverVars, candidateVars, leaderVars, logVars>>
//
int32_t
syncNodeAppendEntriesPeers
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeAppendEntriesPeersSnapshot
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeAppendEntriesPeersSnapshot2
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeAppendEntriesOnePeer
(
SSyncNode
*
pSyncNode
,
SRaftId
*
pDestId
,
SyncIndex
nextIndex
);
int32_t
syncNodeHeartbeatPeers
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeSendHeartbeat
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
pDestId
,
const
SyncHeartbeat
*
pMsg
);
int32_t
syncNodeReplicate
(
SSyncNode
*
pSyncNode
,
bool
isTimer
);
int32_t
syncNodeReplicate
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeAppendEntries
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
const
SyncAppendEntries
*
pMsg
);
int32_t
syncNodeReplicateOne
(
SSyncNode
*
pSyncNode
,
SRaftId
*
pDestId
);
int32_t
syncNodeAppendEntriesBatch
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
const
SyncAppendEntriesBatch
*
pMsg
);
int32_t
syncNodeSendAppendEntries
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
pDestId
,
const
SyncAppendEntries
*
pMsg
);
int32_t
syncNodeMaybeSendAppendEntries
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
pDestId
,
const
SyncAppendEntries
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/sync/inc/syncRequestVote.h
浏览文件 @
b06870f7
...
@@ -49,8 +49,7 @@ extern "C" {
...
@@ -49,8 +49,7 @@ extern "C" {
// m)
// m)
// /\ UNCHANGED <<state, currentTerm, candidateVars, leaderVars, logVars>>
// /\ UNCHANGED <<state, currentTerm, candidateVars, leaderVars, logVars>>
//
//
int32_t
syncNodeOnRequestVoteCb
(
SSyncNode
*
ths
,
SyncRequestVote
*
pMsg
);
int32_t
syncNodeOnRequestVote
(
SSyncNode
*
ths
,
SyncRequestVote
*
pMsg
);
int32_t
syncNodeOnRequestVoteSnapshotCb
(
SSyncNode
*
ths
,
SyncRequestVote
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/sync/inc/syncRequestVoteReply.h
浏览文件 @
b06870f7
...
@@ -44,8 +44,7 @@ extern "C" {
...
@@ -44,8 +44,7 @@ extern "C" {
// /\ Discard(m)
// /\ Discard(m)
// /\ UNCHANGED <<serverVars, votedFor, leaderVars, logVars>>
// /\ UNCHANGED <<serverVars, votedFor, leaderVars, logVars>>
//
//
int32_t
syncNodeOnRequestVoteReplyCb
(
SSyncNode
*
ths
,
SyncRequestVoteReply
*
pMsg
);
int32_t
syncNodeOnRequestVoteReply
(
SSyncNode
*
ths
,
SyncRequestVoteReply
*
pMsg
);
int32_t
syncNodeOnRequestVoteReplySnapshotCb
(
SSyncNode
*
ths
,
SyncRequestVoteReply
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/sync/inc/syncRespMgr.h
浏览文件 @
b06870f7
...
@@ -32,9 +32,9 @@ typedef struct SRespStub {
...
@@ -32,9 +32,9 @@ typedef struct SRespStub {
}
SRespStub
;
}
SRespStub
;
typedef
struct
SSyncRespMgr
{
typedef
struct
SSyncRespMgr
{
SHashObj
*
pRespHash
;
SHashObj
*
pRespHash
;
int64_t
ttl
;
int64_t
ttl
;
void
*
data
;
void
*
data
;
TdThreadMutex
mutex
;
TdThreadMutex
mutex
;
uint64_t
seqNum
;
uint64_t
seqNum
;
}
SSyncRespMgr
;
}
SSyncRespMgr
;
...
...
source/libs/sync/inc/syncSnapshot.h
浏览文件 @
b06870f7
...
@@ -28,10 +28,10 @@ extern "C" {
...
@@ -28,10 +28,10 @@ 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 -1
#define SYNC_SNAPSHOT_SEQ_FORCE_CLOSE -2
#define SYNC_SNAPSHOT_SEQ_FORCE_CLOSE -2
#define SYNC_SNAPSHOT_SEQ_BEGIN
0
#define SYNC_SNAPSHOT_SEQ_BEGIN 0
#define SYNC_SNAPSHOT_SEQ_END
0x7FFFFFFF
#define SYNC_SNAPSHOT_SEQ_END 0x7FFFFFFF
#define SYNC_SNAPSHOT_RETRY_MS 5000
#define SYNC_SNAPSHOT_RETRY_MS 5000
...
@@ -51,6 +51,7 @@ typedef struct SSyncSnapshotSender {
...
@@ -51,6 +51,7 @@ typedef struct SSyncSnapshotSender {
int32_t
replicaIndex
;
int32_t
replicaIndex
;
SyncTerm
term
;
SyncTerm
term
;
SyncTerm
privateTerm
;
SyncTerm
privateTerm
;
int64_t
startTime
;
bool
finish
;
bool
finish
;
}
SSyncSnapshotSender
;
}
SSyncSnapshotSender
;
...
@@ -67,6 +68,8 @@ cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender);
...
@@ -67,6 +68,8 @@ cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender);
char
*
snapshotSender2Str
(
SSyncSnapshotSender
*
pSender
);
char
*
snapshotSender2Str
(
SSyncSnapshotSender
*
pSender
);
char
*
snapshotSender2SimpleStr
(
SSyncSnapshotSender
*
pSender
,
char
*
event
);
char
*
snapshotSender2SimpleStr
(
SSyncSnapshotSender
*
pSender
,
char
*
event
);
int32_t
syncNodeStartSnapshot
(
SSyncNode
*
pSyncNode
,
SRaftId
*
pDestId
);
//---------------------------------------------------
//---------------------------------------------------
typedef
struct
SSyncSnapshotReceiver
{
typedef
struct
SSyncSnapshotReceiver
{
bool
start
;
bool
start
;
...
@@ -94,8 +97,8 @@ char *snapshotReceiver2SimpleStr(SSyncSnapshotReceiver *pReceiver, char *event)
...
@@ -94,8 +97,8 @@ char *snapshotReceiver2SimpleStr(SSyncSnapshotReceiver *pReceiver, char *event)
//---------------------------------------------------
//---------------------------------------------------
// on message
// on message
int32_t
syncNodeOnSnapshot
SendCb
(
SSyncNode
*
ths
,
SyncSnapshotSend
*
pMsg
);
int32_t
syncNodeOnSnapshot
(
SSyncNode
*
ths
,
SyncSnapshotSend
*
pMsg
);
int32_t
syncNodeOnSnapshotR
spCb
(
SSyncNode
*
ths
,
SyncSnapshotRsp
*
pMsg
);
int32_t
syncNodeOnSnapshotR
eply
(
SSyncNode
*
ths
,
SyncSnapshotRsp
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/sync/inc/syncTimeout.h
浏览文件 @
b06870f7
...
@@ -39,7 +39,7 @@ extern "C" {
...
@@ -39,7 +39,7 @@ extern "C" {
// /\ voterLog' = [voterLog EXCEPT ![i] = [j \in {} |-> <<>>]]
// /\ voterLog' = [voterLog EXCEPT ![i] = [j \in {} |-> <<>>]]
// /\ UNCHANGED <<messages, leaderVars, logVars>>
// /\ UNCHANGED <<messages, leaderVars, logVars>>
//
//
int32_t
syncNodeOnTime
outCb
(
SSyncNode
*
ths
,
SyncTimeout
*
pMsg
);
int32_t
syncNodeOnTime
r
(
SSyncNode
*
ths
,
SyncTimeout
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/src/syncAppendEntriesReply.c
浏览文件 @
b06870f7
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include "syncRaftCfg.h"
#include "syncRaftCfg.h"
#include "syncRaftLog.h"
#include "syncRaftLog.h"
#include "syncRaftStore.h"
#include "syncRaftStore.h"
#include "syncReplication.h"
#include "syncSnapshot.h"
#include "syncSnapshot.h"
#include "syncUtil.h"
#include "syncUtil.h"
#include "syncVoteMgr.h"
#include "syncVoteMgr.h"
...
@@ -37,74 +38,6 @@
...
@@ -37,74 +38,6 @@
// /\ Discard(m)
// /\ Discard(m)
// /\ UNCHANGED <<serverVars, candidateVars, logVars, elections>>
// /\ UNCHANGED <<serverVars, candidateVars, logVars, elections>>
//
//
int32_t
syncNodeOnAppendEntriesReplyCb
(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
)
{
int32_t
ret
=
0
;
// if already drop replica, do not process
if
(
!
syncNodeInRaftGroup
(
ths
,
&
(
pMsg
->
srcId
))
&&
!
ths
->
pRaftCfg
->
isStandBy
)
{
syncLogRecvAppendEntriesReply
(
ths
,
pMsg
,
"maybe replica already dropped"
);
return
-
1
;
}
// drop stale response
if
(
pMsg
->
term
<
ths
->
pRaftStore
->
currentTerm
)
{
syncLogRecvAppendEntriesReply
(
ths
,
pMsg
,
"drop stale response"
);
return
0
;
}
// no need this code, because if I receive reply.term, then I must have sent for that term.
// if (pMsg->term > ths->pRaftStore->currentTerm) {
// syncNodeUpdateTerm(ths, pMsg->term);
// }
if
(
pMsg
->
term
>
ths
->
pRaftStore
->
currentTerm
)
{
syncLogRecvAppendEntriesReply
(
ths
,
pMsg
,
"error term"
);
return
-
1
;
}
ASSERT
(
pMsg
->
term
==
ths
->
pRaftStore
->
currentTerm
);
// update time
syncIndexMgrSetStartTime
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
pMsg
->
startTime
);
syncIndexMgrSetRecvTime
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
taosGetTimestampMs
());
SyncIndex
beforeNextIndex
=
syncIndexMgrGetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
));
SyncIndex
beforeMatchIndex
=
syncIndexMgrGetIndex
(
ths
->
pMatchIndex
,
&
(
pMsg
->
srcId
));
if
(
pMsg
->
success
)
{
// nextIndex' = [nextIndex EXCEPT ![i][j] = m.mmatchIndex + 1]
syncIndexMgrSetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
pMsg
->
matchIndex
+
1
);
// matchIndex' = [matchIndex EXCEPT ![i][j] = m.mmatchIndex]
syncIndexMgrSetIndex
(
ths
->
pMatchIndex
,
&
(
pMsg
->
srcId
),
pMsg
->
matchIndex
);
// maybe commit
syncMaybeAdvanceCommitIndex
(
ths
);
}
else
{
SyncIndex
nextIndex
=
syncIndexMgrGetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
));
// notice! int64, uint64
if
(
nextIndex
>
SYNC_INDEX_BEGIN
)
{
--
nextIndex
;
}
else
{
nextIndex
=
SYNC_INDEX_BEGIN
;
}
syncIndexMgrSetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
nextIndex
);
}
SyncIndex
afterNextIndex
=
syncIndexMgrGetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
));
SyncIndex
afterMatchIndex
=
syncIndexMgrGetIndex
(
ths
->
pMatchIndex
,
&
(
pMsg
->
srcId
));
do
{
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"before next:%"
PRId64
", match:%"
PRId64
", after next:%"
PRId64
", match:%"
PRId64
,
beforeNextIndex
,
beforeMatchIndex
,
afterNextIndex
,
afterMatchIndex
);
syncLogRecvAppendEntriesReply
(
ths
,
pMsg
,
logBuf
);
}
while
(
0
);
return
0
;
}
// only start once
// only start once
static
void
syncNodeStartSnapshotOnce
(
SSyncNode
*
ths
,
SyncIndex
beginIndex
,
SyncIndex
endIndex
,
SyncTerm
lastApplyTerm
,
static
void
syncNodeStartSnapshotOnce
(
SSyncNode
*
ths
,
SyncIndex
beginIndex
,
SyncIndex
endIndex
,
SyncTerm
lastApplyTerm
,
...
@@ -151,13 +84,13 @@ static void syncNodeStartSnapshotOnce(SSyncNode* ths, SyncIndex beginIndex, Sync
...
@@ -151,13 +84,13 @@ static void syncNodeStartSnapshotOnce(SSyncNode* ths, SyncIndex beginIndex, Sync
}
}
}
}
int32_t
syncNodeOnAppendEntriesReply
Snapshot2Cb
(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
)
{
int32_t
syncNodeOnAppendEntriesReply
(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
)
{
int32_t
ret
=
0
;
int32_t
ret
=
0
;
// if already drop replica, do not process
// if already drop replica, do not process
if
(
!
syncNodeInRaftGroup
(
ths
,
&
(
pMsg
->
srcId
))
&&
!
ths
->
pRaftCfg
->
isStandBy
)
{
if
(
!
syncNodeInRaftGroup
(
ths
,
&
(
pMsg
->
srcId
)))
{
syncLogRecvAppendEntriesReply
(
ths
,
pMsg
,
"
maybe replica already dropped
"
);
syncLogRecvAppendEntriesReply
(
ths
,
pMsg
,
"
not in my config
"
);
return
-
1
;
return
0
;
}
}
// drop stale response
// drop stale response
...
@@ -166,251 +99,40 @@ int32_t syncNodeOnAppendEntriesReplySnapshot2Cb(SSyncNode* ths, SyncAppendEntrie
...
@@ -166,251 +99,40 @@ int32_t syncNodeOnAppendEntriesReplySnapshot2Cb(SSyncNode* ths, SyncAppendEntrie
return
0
;
return
0
;
}
}
// error term
if
(
ths
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
if
(
pMsg
->
term
>
ths
->
pRaftStore
->
currentTerm
)
{
if
(
pMsg
->
term
>
ths
->
pRaftStore
->
currentTerm
)
{
syncLogRecvAppendEntriesReply
(
ths
,
pMsg
,
"error term"
);
syncLogRecvAppendEntriesReply
(
ths
,
pMsg
,
"error term"
);
return
-
1
;
syncNodeStepDown
(
ths
,
pMsg
->
term
);
}
return
-
1
;
ASSERT
(
pMsg
->
term
==
ths
->
pRaftStore
->
currentTerm
);
// update time
syncIndexMgrSetStartTime
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
pMsg
->
startTime
);
syncIndexMgrSetRecvTime
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
taosGetTimestampMs
());
SyncIndex
beforeNextIndex
=
syncIndexMgrGetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
));
SyncIndex
beforeMatchIndex
=
syncIndexMgrGetIndex
(
ths
->
pMatchIndex
,
&
(
pMsg
->
srcId
));
if
(
pMsg
->
success
)
{
SyncIndex
newNextIndex
=
pMsg
->
matchIndex
+
1
;
SyncIndex
newMatchIndex
=
pMsg
->
matchIndex
;
bool
needStartSnapshot
=
false
;
if
(
newMatchIndex
>=
SYNC_INDEX_BEGIN
&&
!
ths
->
pLogStore
->
syncLogExist
(
ths
->
pLogStore
,
newMatchIndex
))
{
needStartSnapshot
=
true
;
}
}
if
(
!
needStartSnapshot
)
{
ASSERT
(
pMsg
->
term
==
ths
->
pRaftStore
->
currentTerm
);
// update next-index, match-index
syncIndexMgrSetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
newNextIndex
);
syncIndexMgrSetIndex
(
ths
->
pMatchIndex
,
&
(
pMsg
->
srcId
),
newMatchIndex
);
// maybe commit
if
(
pMsg
->
success
)
{
if
(
ths
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
SyncIndex
oldMatchIndex
=
syncIndexMgrGetIndex
(
ths
->
pMatchIndex
,
&
(
pMsg
->
srcId
));
if
(
pMsg
->
matchIndex
>
oldMatchIndex
)
{
syncIndexMgrSetIndex
(
ths
->
pMatchIndex
,
&
(
pMsg
->
srcId
),
pMsg
->
matchIndex
);
syncMaybeAdvanceCommitIndex
(
ths
);
syncMaybeAdvanceCommitIndex
(
ths
);
}
}
syncIndexMgrSetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
pMsg
->
matchIndex
+
1
);
}
else
{
}
else
{
// start snapshot <match+1, old snapshot.end>
SyncIndex
nextIndex
=
syncIndexMgrGetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
));
SSnapshot
oldSnapshot
;
if
(
nextIndex
>
SYNC_INDEX_BEGIN
)
{
ths
->
pFsm
->
FpGetSnapshotInfo
(
ths
->
pFsm
,
&
oldSnapshot
);
--
nextIndex
;
if
(
oldSnapshot
.
lastApplyIndex
>
newMatchIndex
)
{
syncNodeStartSnapshotOnce
(
ths
,
newMatchIndex
+
1
,
oldSnapshot
.
lastApplyIndex
,
oldSnapshot
.
lastApplyTerm
,
pMsg
);
// term maybe not ok?
}
syncIndexMgrSetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
oldSnapshot
.
lastApplyIndex
+
1
);
syncIndexMgrSetIndex
(
ths
->
pMatchIndex
,
&
(
pMsg
->
srcId
),
newMatchIndex
);
}
// event log, update next-index
do
{
char
host
[
64
];
int16_t
port
;
syncUtilU642Addr
(
pMsg
->
srcId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"reset next-index:%"
PRId64
", match-index:%"
PRId64
" for %s:%d"
,
newNextIndex
,
newMatchIndex
,
host
,
port
);
syncNodeEventLog
(
ths
,
logBuf
);
}
while
(
0
);
}
else
{
SyncIndex
nextIndex
=
syncIndexMgrGetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
));
if
(
nextIndex
>
SYNC_INDEX_BEGIN
)
{
--
nextIndex
;
// speed up
if
(
nextIndex
>
pMsg
->
matchIndex
+
1
)
{
nextIndex
=
pMsg
->
matchIndex
+
1
;
}
bool
needStartSnapshot
=
false
;
if
(
nextIndex
>=
SYNC_INDEX_BEGIN
&&
!
ths
->
pLogStore
->
syncLogExist
(
ths
->
pLogStore
,
nextIndex
))
{
needStartSnapshot
=
true
;
}
if
(
nextIndex
-
1
>=
SYNC_INDEX_BEGIN
&&
!
ths
->
pLogStore
->
syncLogExist
(
ths
->
pLogStore
,
nextIndex
-
1
))
{
needStartSnapshot
=
true
;
}
if
(
!
needStartSnapshot
)
{
// do nothing
}
else
{
SSnapshot
oldSnapshot
;
ths
->
pFsm
->
FpGetSnapshotInfo
(
ths
->
pFsm
,
&
oldSnapshot
);
SyncTerm
newSnapshotTerm
=
oldSnapshot
.
lastApplyTerm
;
SyncIndex
endIndex
;
if
(
ths
->
pLogStore
->
syncLogExist
(
ths
->
pLogStore
,
nextIndex
+
1
))
{
endIndex
=
nextIndex
;
}
else
{
endIndex
=
oldSnapshot
.
lastApplyIndex
;
}
syncNodeStartSnapshotOnce
(
ths
,
pMsg
->
matchIndex
+
1
,
endIndex
,
newSnapshotTerm
,
pMsg
);
// get sender
SSyncSnapshotSender
*
pSender
=
syncNodeGetSnapshotSender
(
ths
,
&
(
pMsg
->
srcId
));
ASSERT
(
pSender
!=
NULL
);
SyncIndex
sentryIndex
=
pSender
->
snapshot
.
lastApplyIndex
+
1
;
// update nextIndex to sentryIndex
if
(
nextIndex
<=
sentryIndex
)
{
nextIndex
=
sentryIndex
;
}
}
}
syncIndexMgrSetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
nextIndex
);
}
else
{
nextIndex
=
SYNC_INDEX_BEGIN
;
}
syncIndexMgrSetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
nextIndex
);
SyncIndex
oldMatchIndex
=
syncIndexMgrGetIndex
(
ths
->
pMatchIndex
,
&
(
pMsg
->
srcId
));
if
(
pMsg
->
matchIndex
>
oldMatchIndex
)
{
syncIndexMgrSetIndex
(
ths
->
pMatchIndex
,
&
(
pMsg
->
srcId
),
pMsg
->
matchIndex
);
}
// event log, update next-index
do
{
char
host
[
64
];
int16_t
port
;
syncUtilU642Addr
(
pMsg
->
srcId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
SyncIndex
newNextIndex
=
nextIndex
;
SyncIndex
newMatchIndex
=
syncIndexMgrGetIndex
(
ths
->
pMatchIndex
,
&
(
pMsg
->
srcId
));
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"reset2 next-index:%"
PRId64
", match-index:%"
PRId64
" for %s:%d"
,
newNextIndex
,
newMatchIndex
,
host
,
port
);
syncNodeEventLog
(
ths
,
logBuf
);
}
while
(
0
);
}
SyncIndex
afterNextIndex
=
syncIndexMgrGetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
));
SyncIndex
afterMatchIndex
=
syncIndexMgrGetIndex
(
ths
->
pMatchIndex
,
&
(
pMsg
->
srcId
));
do
{
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"before next:%"
PRId64
", match:%"
PRId64
", after next:%"
PRId64
", match:%"
PRId64
,
beforeNextIndex
,
beforeMatchIndex
,
afterNextIndex
,
afterMatchIndex
);
syncLogRecvAppendEntriesReply
(
ths
,
pMsg
,
logBuf
);
}
while
(
0
);
return
0
;
}
int32_t
syncNodeOnAppendEntriesReplySnapshotCb
(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
)
{
int32_t
ret
=
0
;
// if already drop replica, do not process
if
(
!
syncNodeInRaftGroup
(
ths
,
&
(
pMsg
->
srcId
))
&&
!
ths
->
pRaftCfg
->
isStandBy
)
{
syncLogRecvAppendEntriesReply
(
ths
,
pMsg
,
"maybe replica already dropped"
);
return
-
1
;
}
// drop stale response
if
(
pMsg
->
term
<
ths
->
pRaftStore
->
currentTerm
)
{
syncLogRecvAppendEntriesReply
(
ths
,
pMsg
,
"drop stale response"
);
return
0
;
}
// no need this code, because if I receive reply.term, then I must have sent for that term.
// if (pMsg->term > ths->pRaftStore->currentTerm) {
// syncNodeUpdateTerm(ths, pMsg->term);
// }
if
(
pMsg
->
term
>
ths
->
pRaftStore
->
currentTerm
)
{
syncLogRecvAppendEntriesReply
(
ths
,
pMsg
,
"error term"
);
return
-
1
;
}
ASSERT
(
pMsg
->
term
==
ths
->
pRaftStore
->
currentTerm
);
// update time
syncIndexMgrSetStartTime
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
pMsg
->
startTime
);
syncIndexMgrSetRecvTime
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
taosGetTimestampMs
());
SyncIndex
beforeNextIndex
=
syncIndexMgrGetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
));
SyncIndex
beforeMatchIndex
=
syncIndexMgrGetIndex
(
ths
->
pMatchIndex
,
&
(
pMsg
->
srcId
));
if
(
pMsg
->
success
)
{
// nextIndex' = [nextIndex EXCEPT ![i][j] = m.mmatchIndex + 1]
syncIndexMgrSetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
pMsg
->
matchIndex
+
1
);
// matchIndex' = [matchIndex EXCEPT ![i][j] = m.mmatchIndex]
syncIndexMgrSetIndex
(
ths
->
pMatchIndex
,
&
(
pMsg
->
srcId
),
pMsg
->
matchIndex
);
// maybe commit
if
(
ths
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
syncMaybeAdvanceCommitIndex
(
ths
);
}
}
}
else
{
// send next append entries
SyncIndex
nextIndex
=
syncIndexMgrGetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
));
SPeerState
*
pState
=
syncNodeGetPeerState
(
ths
,
&
(
pMsg
->
srcId
));
ASSERT
(
pState
!=
NULL
);
// notice! int64, uint64
if
(
nextIndex
>
SYNC_INDEX_BEGIN
)
{
--
nextIndex
;
// get sender
SSyncSnapshotSender
*
pSender
=
syncNodeGetSnapshotSender
(
ths
,
&
(
pMsg
->
srcId
));
ASSERT
(
pSender
!=
NULL
);
SSnapshot
snapshot
=
{.
data
=
NULL
,
.
lastApplyIndex
=
SYNC_INDEX_INVALID
,
.
lastApplyTerm
=
0
,
.
lastConfigIndex
=
SYNC_INDEX_INVALID
};
void
*
pReader
=
NULL
;
ths
->
pFsm
->
FpGetSnapshot
(
ths
->
pFsm
,
&
snapshot
,
NULL
,
&
pReader
);
if
(
snapshot
.
lastApplyIndex
>=
SYNC_INDEX_BEGIN
&&
nextIndex
<=
snapshot
.
lastApplyIndex
+
1
&&
!
snapshotSenderIsStart
(
pSender
)
&&
pMsg
->
privateTerm
<
pSender
->
privateTerm
)
{
// has snapshot
ASSERT
(
pReader
!=
NULL
);
SSnapshotParam
readerParam
=
{.
start
=
0
,
.
end
=
snapshot
.
lastApplyIndex
};
snapshotSenderStart
(
pSender
,
readerParam
,
snapshot
,
pReader
);
}
else
{
// no snapshot
if
(
pReader
!=
NULL
)
{
ths
->
pFsm
->
FpSnapshotStopRead
(
ths
->
pFsm
,
pReader
);
}
}
SyncIndex
sentryIndex
=
pSender
->
snapshot
.
lastApplyIndex
+
1
;
if
(
pMsg
->
lastSendIndex
==
pState
->
lastSendIndex
)
{
syncNodeReplicateOne
(
ths
,
&
(
pMsg
->
srcId
));
// update nextIndex to sentryIndex
if
(
nextIndex
<=
sentryIndex
)
{
nextIndex
=
sentryIndex
;
}
}
else
{
nextIndex
=
SYNC_INDEX_BEGIN
;
}
}
syncIndexMgrSetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
nextIndex
);
}
}
SyncIndex
afterNextIndex
=
syncIndexMgrGetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
));
syncLogRecvAppendEntriesReply
(
ths
,
pMsg
,
"process"
);
SyncIndex
afterMatchIndex
=
syncIndexMgrGetIndex
(
ths
->
pMatchIndex
,
&
(
pMsg
->
srcId
));
do
{
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"before next:%"
PRId64
", match:%"
PRId64
", after next:%"
PRId64
", match:%"
PRId64
,
beforeNextIndex
,
beforeMatchIndex
,
afterNextIndex
,
afterMatchIndex
);
syncLogRecvAppendEntriesReply
(
ths
,
pMsg
,
logBuf
);
}
while
(
0
);
return
0
;
return
0
;
}
}
\ No newline at end of file
source/libs/sync/src/syncCommit.c
浏览文件 @
b06870f7
...
@@ -45,8 +45,10 @@
...
@@ -45,8 +45,10 @@
// /\ UNCHANGED <<messages, serverVars, candidateVars, leaderVars, log>>
// /\ UNCHANGED <<messages, serverVars, candidateVars, leaderVars, log>>
//
//
void
syncMaybeAdvanceCommitIndex
(
SSyncNode
*
pSyncNode
)
{
void
syncMaybeAdvanceCommitIndex
(
SSyncNode
*
pSyncNode
)
{
syncIndexMgrLog2
(
"==syncNodeMaybeAdvanceCommitIndex== pNextIndex"
,
pSyncNode
->
pNextIndex
);
if
(
pSyncNode
->
state
!=
TAOS_SYNC_STATE_LEADER
)
{
syncIndexMgrLog2
(
"==syncNodeMaybeAdvanceCommitIndex== pMatchIndex"
,
pSyncNode
->
pMatchIndex
);
syncNodeErrorLog
(
pSyncNode
,
"not leader, can not advance commit index"
);
return
;
}
// advance commit index to sanpshot first
// advance commit index to sanpshot first
SSnapshot
snapshot
;
SSnapshot
snapshot
;
...
@@ -75,9 +77,11 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
...
@@ -75,9 +77,11 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
if
(
h
)
{
if
(
h
)
{
pEntry
=
(
SSyncRaftEntry
*
)
taosLRUCacheValue
(
pCache
,
h
);
pEntry
=
(
SSyncRaftEntry
*
)
taosLRUCacheValue
(
pCache
,
h
);
}
else
{
}
else
{
pEntry
=
pSyncNode
->
pLogStore
->
getEntry
(
pSyncNode
->
pLogStore
,
index
);
int32_t
code
=
pSyncNode
->
pLogStore
->
syncLogGetEntry
(
pSyncNode
->
pLogStore
,
index
,
&
pEntry
);
if
(
pEntry
==
NULL
)
{
if
(
code
!=
0
)
{
sError
(
"failed to get entry since %s. index:%"
PRId64
,
tstrerror
(
terrno
),
index
);
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"advance commit index error, read wal index:%"
PRId64
,
index
);
syncNodeErrorLog
(
pSyncNode
,
logBuf
);
return
;
return
;
}
}
}
}
...
@@ -125,13 +129,17 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
...
@@ -125,13 +129,17 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
pSyncNode
->
commitIndex
=
newCommitIndex
;
pSyncNode
->
commitIndex
=
newCommitIndex
;
// call back Wal
// call back Wal
pSyncNode
->
pLogStore
->
u
pdateCommitIndex
(
pSyncNode
->
pLogStore
,
pSyncNode
->
commitIndex
);
pSyncNode
->
pLogStore
->
syncLogU
pdateCommitIndex
(
pSyncNode
->
pLogStore
,
pSyncNode
->
commitIndex
);
// execute fsm
// execute fsm
if
(
pSyncNode
->
pFsm
!=
NULL
)
{
if
(
pSyncNode
->
pFsm
!=
NULL
)
{
int32_t
code
=
syncNodeCommit
(
pSyncNode
,
beginIndex
,
endIndex
,
pSyncNode
->
state
);
int32_t
code
=
syncNode
Do
Commit
(
pSyncNode
,
beginIndex
,
endIndex
,
pSyncNode
->
state
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
wError
(
"failed to commit sync node since %s"
,
tstrerror
(
terrno
));
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"advance commit index error, do commit begin:%"
PRId64
", end:%"
PRId64
,
beginIndex
,
endIndex
);
syncNodeErrorLog
(
pSyncNode
,
logBuf
);
return
;
}
}
}
}
}
}
...
@@ -162,6 +170,8 @@ static inline int64_t syncNodeAbs64(int64_t a, int64_t b) {
...
@@ -162,6 +170,8 @@ static inline int64_t syncNodeAbs64(int64_t a, int64_t b) {
}
}
int32_t
syncNodeDynamicQuorum
(
const
SSyncNode
*
pSyncNode
)
{
int32_t
syncNodeDynamicQuorum
(
const
SSyncNode
*
pSyncNode
)
{
return
pSyncNode
->
quorum
;
int32_t
quorum
=
1
;
// self
int32_t
quorum
=
1
;
// self
int64_t
timeNow
=
taosGetTimestampMs
();
int64_t
timeNow
=
taosGetTimestampMs
();
...
@@ -220,6 +230,7 @@ int32_t syncNodeDynamicQuorum(const SSyncNode* pSyncNode) {
...
@@ -220,6 +230,7 @@ int32_t syncNodeDynamicQuorum(const SSyncNode* pSyncNode) {
return
quorum
;
return
quorum
;
}
}
/*
bool syncAgree(SSyncNode* pSyncNode, SyncIndex index) {
bool syncAgree(SSyncNode* pSyncNode, SyncIndex index) {
int agreeCount = 0;
int agreeCount = 0;
for (int i = 0; i < pSyncNode->replicaNum; ++i) {
for (int i = 0; i < pSyncNode->replicaNum; ++i) {
...
@@ -232,8 +243,8 @@ bool syncAgree(SSyncNode* pSyncNode, SyncIndex index) {
...
@@ -232,8 +243,8 @@ bool syncAgree(SSyncNode* pSyncNode, SyncIndex index) {
}
}
return false;
return false;
}
}
*/
/*
bool
syncAgree
(
SSyncNode
*
pSyncNode
,
SyncIndex
index
)
{
bool
syncAgree
(
SSyncNode
*
pSyncNode
,
SyncIndex
index
)
{
int
agreeCount
=
0
;
int
agreeCount
=
0
;
for
(
int
i
=
0
;
i
<
pSyncNode
->
replicaNum
;
++
i
)
{
for
(
int
i
=
0
;
i
<
pSyncNode
->
replicaNum
;
++
i
)
{
...
@@ -246,4 +257,3 @@ bool syncAgree(SSyncNode* pSyncNode, SyncIndex index) {
...
@@ -246,4 +257,3 @@ bool syncAgree(SSyncNode* pSyncNode, SyncIndex index) {
}
}
return
false
;
return
false
;
}
}
*/
source/libs/sync/src/syncElection.c
浏览文件 @
b06870f7
...
@@ -30,45 +30,6 @@
...
@@ -30,45 +30,6 @@
// msource |-> i,
// msource |-> i,
// mdest |-> j])
// mdest |-> j])
// /\ UNCHANGED <<serverVars, candidateVars, leaderVars, logVars>>
// /\ UNCHANGED <<serverVars, candidateVars, leaderVars, logVars>>
//
int32_t
syncNodeRequestVotePeers
(
SSyncNode
*
pSyncNode
)
{
ASSERT
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_CANDIDATE
);
int32_t
ret
=
0
;
for
(
int
i
=
0
;
i
<
pSyncNode
->
peersNum
;
++
i
)
{
SyncRequestVote
*
pMsg
=
syncRequestVoteBuild
(
pSyncNode
->
vgId
);
pMsg
->
srcId
=
pSyncNode
->
myRaftId
;
pMsg
->
destId
=
pSyncNode
->
peersId
[
i
];
pMsg
->
term
=
pSyncNode
->
pRaftStore
->
currentTerm
;
pMsg
->
lastLogIndex
=
pSyncNode
->
pLogStore
->
getLastIndex
(
pSyncNode
->
pLogStore
);
pMsg
->
lastLogTerm
=
pSyncNode
->
pLogStore
->
getLastTerm
(
pSyncNode
->
pLogStore
);
ret
=
syncNodeRequestVote
(
pSyncNode
,
&
pSyncNode
->
peersId
[
i
],
pMsg
);
ASSERT
(
ret
==
0
);
syncRequestVoteDestroy
(
pMsg
);
}
return
ret
;
}
int32_t
syncNodeRequestVotePeersSnapshot
(
SSyncNode
*
pSyncNode
)
{
ASSERT
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_CANDIDATE
);
int32_t
ret
=
0
;
for
(
int
i
=
0
;
i
<
pSyncNode
->
peersNum
;
++
i
)
{
SyncRequestVote
*
pMsg
=
syncRequestVoteBuild
(
pSyncNode
->
vgId
);
pMsg
->
srcId
=
pSyncNode
->
myRaftId
;
pMsg
->
destId
=
pSyncNode
->
peersId
[
i
];
pMsg
->
term
=
pSyncNode
->
pRaftStore
->
currentTerm
;
ret
=
syncNodeGetLastIndexTerm
(
pSyncNode
,
&
(
pMsg
->
lastLogIndex
),
&
(
pMsg
->
lastLogTerm
));
ASSERT
(
ret
==
0
);
ret
=
syncNodeRequestVote
(
pSyncNode
,
&
pSyncNode
->
peersId
[
i
],
pMsg
);
ASSERT
(
ret
==
0
);
syncRequestVoteDestroy
(
pMsg
);
}
return
ret
;
}
int32_t
syncNodeElect
(
SSyncNode
*
pSyncNode
)
{
int32_t
syncNodeElect
(
SSyncNode
*
pSyncNode
)
{
syncNodeEventLog
(
pSyncNode
,
"begin election"
);
syncNodeEventLog
(
pSyncNode
,
"begin election"
);
...
@@ -111,27 +72,38 @@ int32_t syncNodeElect(SSyncNode* pSyncNode) {
...
@@ -111,27 +72,38 @@ int32_t syncNodeElect(SSyncNode* pSyncNode) {
}
}
switch
(
pSyncNode
->
pRaftCfg
->
snapshotStrategy
)
{
ret
=
syncNodeRequestVotePeers
(
pSyncNode
);
case
SYNC_STRATEGY_NO_SNAPSHOT
:
ASSERT
(
ret
==
0
);
ret
=
syncNodeRequestVotePeers
(
pSyncNode
);
break
;
case
SYNC_STRATEGY_STANDARD_SNAPSHOT
:
syncNodeResetElectTimer
(
pSyncNode
);
case
SYNC_STRATEGY_WAL_FIRST
:
ret
=
syncNodeRequestVotePeersSnapshot
(
pSyncNode
);
break
;
default:
return
ret
;
ret
=
syncNodeRequestVotePeers
(
pSyncNode
);
}
break
;
int32_t
syncNodeRequestVotePeers
(
SSyncNode
*
pSyncNode
)
{
if
(
pSyncNode
->
state
!=
TAOS_SYNC_STATE_CANDIDATE
)
{
syncNodeEventLog
(
pSyncNode
,
"not candidate, stop elect"
);
return
0
;
}
}
ASSERT
(
ret
==
0
);
syncNodeResetElectTimer
(
pSyncNode
);
int32_t
ret
=
0
;
for
(
int
i
=
0
;
i
<
pSyncNode
->
peersNum
;
++
i
)
{
SyncRequestVote
*
pMsg
=
syncRequestVoteBuild
(
pSyncNode
->
vgId
);
pMsg
->
srcId
=
pSyncNode
->
myRaftId
;
pMsg
->
destId
=
pSyncNode
->
peersId
[
i
];
pMsg
->
term
=
pSyncNode
->
pRaftStore
->
currentTerm
;
ret
=
syncNodeGetLastIndexTerm
(
pSyncNode
,
&
(
pMsg
->
lastLogIndex
),
&
(
pMsg
->
lastLogTerm
));
ASSERT
(
ret
==
0
);
ret
=
syncNodeSendRequestVote
(
pSyncNode
,
&
pSyncNode
->
peersId
[
i
],
pMsg
);
ASSERT
(
ret
==
0
);
syncRequestVoteDestroy
(
pMsg
);
}
return
ret
;
return
ret
;
}
}
int32_t
syncNodeRequestVote
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
const
SyncRequestVote
*
pMsg
)
{
int32_t
syncNode
Send
RequestVote
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
const
SyncRequestVote
*
pMsg
)
{
int32_t
ret
=
0
;
int32_t
ret
=
0
;
syncLogSendRequestVote
(
pSyncNode
,
pMsg
,
""
);
syncLogSendRequestVote
(
pSyncNode
,
pMsg
,
""
);
...
...
source/libs/sync/src/syncIO.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/src/syncIndexMgr.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/src/syncMain.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/src/syncMessage.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRaftCfg.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRaftEntry.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRaftLog.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRaftStore.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/src/syncReplication.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRequestVote.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRequestVoteReply.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRespMgr.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/src/syncSnapshot.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/src/syncTimeout.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/src/syncVoteMgr.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/test/syncEncodeTest.cpp
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/test/syncHeartbeatReplyTest.cpp
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/test/syncHeartbeatTest.cpp
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/test/syncLogStoreTest.cpp
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/sync/test/syncTestTool.cpp
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/transport/src/trans.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/libs/transport/src/transCli.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/os/src/osDir.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/os/src/osSocket.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
source/util/src/tqueue.c
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
tests/pytest/util/dnodes.py
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
tests/script/jenkins/basic.txt
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
tests/script/tsim/db/alter_replica_13.sim
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
tests/script/tsim/mnode/basic5.sim
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
tests/script/tsim/parser/where.sim
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
tests/script/tsim/stable/metrics_idx.sim
0 → 100644
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
tests/script/tsim/sync/sync2-test.sim
0 → 100644
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
tests/system-test/2-query/Today.py
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
tests/system-test/2-query/nestedQuery.py
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
tests/system-test/2-query/nestedQuery_math.py
0 → 100755
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
tests/system-test/2-query/nestedQuery_str.py
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
tests/system-test/2-query/nestedQuery_time.py
0 → 100755
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
tests/system-test/2-query/stablity.py
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
tests/system-test/2-query/stablity_1.py
0 → 100755
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
tests/system-test/2-query/timetruncate.py
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
tests/system-test/fulltest.sh
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
tools/CMakeLists.txt
浏览文件 @
b06870f7
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录