Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
46c732db
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
46c732db
编写于
12月 17, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
12月 17, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4600 from taosdata/feature/wal
Feature/wal
上级
0b2bb3c3
0f237dc8
变更
17
展开全部
隐藏空白更改
内联
并排
Showing
17 changed file
with
469 addition
and
321 deletion
+469
-321
src/inc/taoserror.h
src/inc/taoserror.h
+6
-0
src/inc/tsync.h
src/inc/tsync.h
+0
-4
src/inc/vnode.h
src/inc/vnode.h
+1
-1
src/mnode/inc/mnodeSdb.h
src/mnode/inc/mnodeSdb.h
+1
-1
src/sync/CMakeLists.txt
src/sync/CMakeLists.txt
+3
-3
src/sync/inc/syncInt.h
src/sync/inc/syncInt.h
+12
-75
src/sync/inc/syncMsg.h
src/sync/inc/syncMsg.h
+143
-0
src/sync/inc/syncTcp.h
src/sync/inc/syncTcp.h
+6
-9
src/sync/src/syncArbitrator.c
src/sync/src/syncArbitrator.c
+19
-19
src/sync/src/syncMain.c
src/sync/src/syncMain.c
+102
-163
src/sync/src/syncMsg.c
src/sync/src/syncMsg.c
+109
-0
src/sync/src/syncRestore.c
src/sync/src/syncRestore.c
+17
-9
src/sync/src/syncRetrieve.c
src/sync/src/syncRetrieve.c
+20
-17
src/sync/src/syncTcp.c
src/sync/src/syncTcp.c
+18
-18
src/sync/test/syncServer.c
src/sync/test/syncServer.c
+2
-2
tests/script/unique/db/replica_add13.sim
tests/script/unique/db/replica_add13.sim
+5
-0
tests/script/unique/db/replica_add23.sim
tests/script/unique/db/replica_add23.sim
+5
-0
未找到文件。
src/inc/taoserror.h
浏览文件 @
46c732db
...
...
@@ -267,6 +267,12 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NOT_ENABLED, 0, 0x0901, "Sync modul
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_INVALID_VERSION
,
0
,
0x0902
,
"Invalid Sync version"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_CONFIRM_EXPIRED
,
0
,
0x0903
,
"Sync confirm expired"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_TOO_MANY_FWDINFO
,
0
,
0x0904
,
"Too many sync fwd infos"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_MISMATCHED_PROTOCOL
,
0
,
0x0905
,
"Mismatched protocol"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_MISMATCHED_CLUSTERID
,
0
,
0x0906
,
"Mismatched clusterId"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_MISMATCHED_SIGNATURE
,
0
,
0x0907
,
"Mismatched signature"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_INVALID_CHECKSUM
,
0
,
0x0908
,
"Invalid msg checksum"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_INVALID_MSGLEN
,
0
,
0x0909
,
"Invalid msg length"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_INVALID_MSGTYPE
,
0
,
0x090A
,
"Invalid msg type"
)
// wal
TAOS_DEFINE_ERROR
(
TSDB_CODE_WAL_APP_ERROR
,
0
,
0x1000
,
"Unexpected generic error in wal"
)
...
...
src/inc/tsync.h
浏览文件 @
46c732db
...
...
@@ -119,10 +119,6 @@ int32_t syncGetNodesRole(int64_t rid, SNodesRole *);
extern
char
*
syncRole
[];
//global configurable parameters
extern
int32_t
tsMaxSyncNum
;
extern
int32_t
tsSyncTcpThreads
;
extern
int32_t
tsSyncTimer
;
extern
int32_t
tsMaxFwdInfo
;
extern
int32_t
sDebugFlag
;
extern
char
tsArbitrator
[];
extern
uint16_t
tsSyncPort
;
...
...
src/inc/vnode.h
浏览文件 @
46c732db
...
...
@@ -48,7 +48,7 @@ typedef struct {
void
*
pVnode
;
SRpcMsg
rpcMsg
;
SRspRet
rspRet
;
char
reserveForSync
[
16
];
char
reserveForSync
[
24
];
SWalHead
pHead
[];
}
SVWriteMsg
;
...
...
src/mnode/inc/mnodeSdb.h
浏览文件 @
46c732db
...
...
@@ -59,7 +59,7 @@ typedef struct SSdbRow {
SMnodeMsg
*
pMsg
;
int32_t
(
*
fpReq
)(
SMnodeMsg
*
pMsg
);
int32_t
(
*
fpRsp
)(
SMnodeMsg
*
pMsg
,
int32_t
code
);
char
reserveForSync
[
16
];
char
reserveForSync
[
24
];
SWalHead
pHead
[];
}
SSdbRow
;
...
...
src/sync/CMakeLists.txt
浏览文件 @
46c732db
...
...
@@ -5,12 +5,12 @@ INCLUDE_DIRECTORIES(inc)
AUX_SOURCE_DIRECTORY
(
src SRC
)
IF
(
TD_LINUX
)
LIST
(
REMOVE_ITEM SRC src/
ta
rbitrator.c
)
LIST
(
REMOVE_ITEM SRC src/
syncA
rbitrator.c
)
ADD_LIBRARY
(
sync
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
sync tutil pthread common
)
LIST
(
APPEND BIN_SRC src/
ta
rbitrator.c
)
LIST
(
APPEND BIN_SRC src/
taosTcpPool
.c
)
LIST
(
APPEND BIN_SRC src/
syncA
rbitrator.c
)
LIST
(
APPEND BIN_SRC src/
syncTcp
.c
)
ADD_EXECUTABLE
(
tarbitrator
${
BIN_SRC
}
)
TARGET_LINK_LIBRARIES
(
tarbitrator sync common osdetail tutil
)
...
...
src/sync/inc/syncInt.h
浏览文件 @
46c732db
...
...
@@ -13,12 +13,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_SYNCINT_H
#define TDENGINE_SYNCINT_H
#ifndef TDENGINE_SYNC
_
INT_H
#define TDENGINE_SYNC
_
INT_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "syncMsg.h"
#include "twal.h"
#define sFatal(...) { if (sDebugFlag & DEBUG_FATAL) { taosPrintLog("SYN FATAL ", sDebugFlag, __VA_ARGS__); }}
#define sError(...) { if (sDebugFlag & DEBUG_ERROR) { taosPrintLog("SYN ERROR ", sDebugFlag, __VA_ARGS__); }}
...
...
@@ -27,86 +29,22 @@ extern "C" {
#define sDebug(...) { if (sDebugFlag & DEBUG_DEBUG) { taosPrintLog("SYN ", sDebugFlag, __VA_ARGS__); }}
#define sTrace(...) { if (sDebugFlag & DEBUG_TRACE) { taosPrintLog("SYN ", sDebugFlag, __VA_ARGS__); }}
typedef
enum
{
TAOS_SMSG_SYNC_DATA
=
1
,
TAOS_SMSG_FORWARD
=
2
,
TAOS_SMSG_FORWARD_RSP
=
3
,
TAOS_SMSG_SYNC_REQ
=
4
,
TAOS_SMSG_SYNC_RSP
=
5
,
TAOS_SMSG_SYNC_MUST
=
6
,
TAOS_SMSG_STATUS
=
7
,
TAOS_SMSG_SYNC_DATA_RSP
=
8
,
}
ESyncMsgType
;
#define SYNC_TCP_THREADS 2
#define SYNC_MAX_NUM 2
#define SYNC_MAX_SIZE (TSDB_MAX_WAL_SIZE + sizeof(SWalHead) + sizeof(SSyncHead) + 16)
#define SYNC_RECV_BUFFER_SIZE (5*1024*1024)
#define SYNC_FWD_TIMER 300
#define SYNC_ROLE_TIMER 10000
#define SYNC_WAIT_AFTER_CHOOSE_MASTER 3
#define SYNC_MAX_FWDS 512
#define SYNC_FWD_TIMER 300
#define SYNC_ROLE_TIMER 15000 // ms
#define SYNC_CHECK_INTERVAL 1 // ms
#define SYNC_WAIT_AFTER_CHOOSE_MASTER 10 // ms
#define nodeRole pNode->peerInfo[pNode->selfIndex]->role
#define nodeVersion pNode->peerInfo[pNode->selfIndex]->version
#define nodeSStatus pNode->peerInfo[pNode->selfIndex]->sstatus
#pragma pack(push, 1)
typedef
struct
{
char
type
;
// msg type
char
pversion
;
// protocol version
char
reserved
[
6
];
// not used
int32_t
vgId
;
// vg ID
int32_t
len
;
// content length, does not include head
// char cont[]; // message content starts from here
}
SSyncHead
;
typedef
struct
{
SSyncHead
syncHead
;
uint16_t
port
;
uint16_t
tranId
;
char
fqdn
[
TSDB_FQDN_LEN
];
int32_t
sourceId
;
// only for arbitrator
}
SFirstPkt
;
typedef
struct
{
int8_t
sync
;
int8_t
reserved
;
uint16_t
tranId
;
}
SFirstPktRsp
;
typedef
struct
{
int8_t
role
;
uint64_t
version
;
}
SPeerStatus
;
typedef
struct
{
int8_t
role
;
int8_t
ack
;
int8_t
type
;
int8_t
reserved
[
3
];
uint16_t
tranId
;
uint64_t
version
;
SPeerStatus
peersStatus
[];
}
SPeersStatus
;
typedef
struct
{
char
name
[
TSDB_FILENAME_LEN
];
uint32_t
magic
;
uint32_t
index
;
uint64_t
fversion
;
int64_t
size
;
}
SFileInfo
;
typedef
struct
{
int8_t
sync
;
}
SFileAck
;
typedef
struct
{
uint64_t
version
;
int32_t
code
;
}
SFwdRsp
;
#pragma pack(pop)
typedef
struct
{
char
*
buffer
;
int32_t
bufferSize
;
...
...
@@ -190,7 +128,6 @@ void syncRestartConnection(SSyncPeer *pPeer);
void
syncBroadcastStatus
(
SSyncNode
*
pNode
);
void
syncAddPeerRef
(
SSyncPeer
*
pPeer
);
int32_t
syncDecPeerRef
(
SSyncPeer
*
pPeer
);
uint16_t
syncGenTranId
();
#ifdef __cplusplus
}
...
...
src/sync/inc/syncMsg.h
0 → 100644
浏览文件 @
46c732db
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_SYNC_MSG_H
#define TDENGINE_SYNC_MSG_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "tsync.h"
typedef
enum
{
TAOS_SMSG_START
=
0
,
TAOS_SMSG_SYNC_DATA
=
1
,
TAOS_SMSG_SYNC_DATA_RSP
=
2
,
TAOS_SMSG_SYNC_FWD
=
3
,
TAOS_SMSG_SYNC_FWD_RSP
=
4
,
TAOS_SMSG_SYNC_REQ
=
5
,
TAOS_SMSG_SYNC_REQ_RSP
=
6
,
TAOS_SMSG_SYNC_MUST
=
7
,
TAOS_SMSG_SYNC_MUST_RSP
=
8
,
TAOS_SMSG_STATUS
=
9
,
TAOS_SMSG_STATUS_RSP
=
10
,
TAOS_SMSG_SETUP
=
11
,
TAOS_SMSG_SETUP_RSP
=
12
,
TAOS_SMSG_SYNC_FILE
=
13
,
TAOS_SMSG_SYNC_FILE_RSP
=
14
,
TAOS_SMSG_END
=
15
,
}
ESyncMsgType
;
typedef
enum
{
SYNC_STATUS_BROADCAST
,
SYNC_STATUS_BROADCAST_RSP
,
SYNC_STATUS_SETUP_CONN
,
SYNC_STATUS_SETUP_CONN_RSP
,
SYNC_STATUS_EXCHANGE_DATA
,
SYNC_STATUS_EXCHANGE_DATA_RSP
,
SYNC_STATUS_CHECK_ROLE
,
SYNC_STATUS_CHECK_ROLE_RSP
}
ESyncStatusType
;
#pragma pack(push, 1)
typedef
struct
{
int8_t
type
;
// msg type
int8_t
protocol
;
// protocol version
uint16_t
signature
;
// fixed value
int32_t
code
;
//
int32_t
cId
;
// cluster Id
int32_t
vgId
;
// vg ID
int32_t
len
;
// content length, does not include head
uint32_t
cksum
;
}
SSyncHead
;
typedef
struct
{
SSyncHead
head
;
uint16_t
port
;
uint16_t
tranId
;
int32_t
sourceId
;
// only for arbitrator
char
fqdn
[
TSDB_FQDN_LEN
];
}
SSyncMsg
;
typedef
struct
{
SSyncHead
head
;
int8_t
sync
;
int8_t
reserved
;
uint16_t
tranId
;
int8_t
reserverd
[
4
];
}
SSyncRsp
;
typedef
struct
{
int8_t
role
;
uint64_t
version
;
}
SPeerStatus
;
typedef
struct
{
SSyncHead
head
;
int8_t
role
;
int8_t
ack
;
int8_t
type
;
int8_t
reserved
[
3
];
uint16_t
tranId
;
uint64_t
version
;
SPeerStatus
peersStatus
[
TAOS_SYNC_MAX_REPLICA
];
}
SPeersStatus
;
typedef
struct
{
SSyncHead
head
;
char
name
[
TSDB_FILENAME_LEN
];
uint32_t
magic
;
uint32_t
index
;
uint64_t
fversion
;
int64_t
size
;
}
SFileInfo
;
typedef
struct
{
SSyncHead
head
;
int8_t
sync
;
}
SFileAck
;
typedef
struct
{
SSyncHead
head
;
uint64_t
version
;
int32_t
code
;
}
SFwdRsp
;
#pragma pack(pop)
#define SYNC_PROTOCOL_VERSION 1
#define SYNC_SIGNATURE ((uint16_t)(0xCDEF))
extern
char
*
statusType
[];
uint16_t
syncGenTranId
();
int32_t
syncCheckHead
(
SSyncHead
*
pHead
);
void
syncBuildSyncFwdMsg
(
SSyncHead
*
pHead
,
int32_t
vgId
,
int32_t
len
);
void
syncBuildSyncFwdRsp
(
SFwdRsp
*
pMsg
,
int32_t
vgId
,
uint64_t
version
,
int32_t
code
);
void
syncBuildSyncReqMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
);
void
syncBuildSyncDataMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
);
void
syncBuildSyncSetupMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
);
void
syncBuildPeersStatus
(
SPeersStatus
*
pMsg
,
int32_t
vgId
);
void
syncBuildFileAck
(
SFileAck
*
pMsg
,
int32_t
vgId
);
void
syncBuildFileInfo
(
SFileInfo
*
pMsg
,
int32_t
vgId
);
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_VNODEPEER_H
src/sync/inc/
taosTcpPool
.h
→
src/sync/inc/
syncTcp
.h
浏览文件 @
46c732db
...
...
@@ -13,16 +13,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_TCP_POOL_H
#define TDENGINE_TCP_POOL_H
#ifndef TDENGINE_
SYNC_
TCP_POOL_H
#define TDENGINE_
SYNC_
TCP_POOL_H
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
void
*
ttpool_h
;
typedef
void
*
tthread_h
;
typedef
struct
{
int32_t
numOfThreads
;
uint32_t
serverIp
;
...
...
@@ -33,10 +30,10 @@ typedef struct {
void
(
*
processIncomingConn
)(
int32_t
fd
,
uint32_t
ip
);
}
SPoolInfo
;
ttpool_h
taos
OpenTcpThreadPool
(
SPoolInfo
*
pInfo
);
void
taosCloseTcpThreadPool
(
ttpool_h
);
void
*
taos
AllocateTcpConn
(
void
*
,
void
*
ahandle
,
int32_t
connFd
);
void
taos
FreeTcpConn
(
void
*
);
void
*
sync
OpenTcpThreadPool
(
SPoolInfo
*
pInfo
);
void
syncCloseTcpThreadPool
(
void
*
);
void
*
sync
AllocateTcpConn
(
void
*
,
void
*
ahandle
,
int32_t
connFd
);
void
sync
FreeTcpConn
(
void
*
);
#ifdef __cplusplus
}
...
...
src/sync/src/
ta
rbitrator.c
→
src/sync/src/
syncA
rbitrator.c
浏览文件 @
46c732db
...
...
@@ -22,17 +22,17 @@
#include "tsocket.h"
#include "tglobal.h"
#include "taoserror.h"
#include "taosTcpPool.h"
#include "twal.h"
#include "tsync.h"
#include "syncInt.h"
#include "syncTcp.h"
static
void
arbSignalHandler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
);
static
void
arbProcessIncommingConnection
(
int32_t
connFd
,
uint32_t
sourceIp
);
static
void
arbProcessBrokenLink
(
void
*
param
);
static
int32_t
arbProcessPeerMsg
(
void
*
param
,
void
*
buffer
);
static
tsem_t
tsArbSem
;
static
ttpool_h
tsArbTcpPool
;
static
void
arbSignalHandler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
);
static
void
arbProcessIncommingConnection
(
int32_t
connFd
,
uint32_t
sourceIp
);
static
void
arbProcessBrokenLink
(
void
*
param
);
static
int32_t
arbProcessPeerMsg
(
void
*
param
,
void
*
buffer
);
static
tsem_t
tsArbSem
;
static
void
*
tsArbTcpPool
;
typedef
struct
{
char
id
[
TSDB_EP_LEN
+
24
];
...
...
@@ -90,7 +90,7 @@ int32_t main(int32_t argc, char *argv[]) {
info
.
processBrokenLink
=
arbProcessBrokenLink
;
info
.
processIncomingMsg
=
arbProcessPeerMsg
;
info
.
processIncomingConn
=
arbProcessIncommingConnection
;
tsArbTcpPool
=
taos
OpenTcpThreadPool
(
&
info
);
tsArbTcpPool
=
sync
OpenTcpThreadPool
(
&
info
);
if
(
tsArbTcpPool
==
NULL
)
{
sDebug
(
"failed to open TCP thread pool, exit..."
);
...
...
@@ -101,8 +101,8 @@ int32_t main(int32_t argc, char *argv[]) {
tsem_wait
(
&
tsArbSem
);
taos
CloseTcpThreadPool
(
tsArbTcpPool
);
sInfo
(
"TAOS arbitrator is shut down
\n
"
);
sync
CloseTcpThreadPool
(
tsArbTcpPool
);
sInfo
(
"TAOS arbitrator is shut down"
);
closelog
();
return
0
;
...
...
@@ -113,9 +113,9 @@ static void arbProcessIncommingConnection(int32_t connFd, uint32_t sourceIp) {
tinet_ntoa
(
ipstr
,
sourceIp
);
sDebug
(
"peer TCP connection from ip:%s"
,
ipstr
);
S
FirstPkt
firstPkt
;
if
(
taosReadMsg
(
connFd
,
&
firstPkt
,
sizeof
(
firstPkt
))
!=
sizeof
(
firstPkt
))
{
sError
(
"failed to read peer
first pkt
from ip:%s since %s"
,
ipstr
,
strerror
(
errno
));
S
SyncMsg
msg
;
if
(
taosReadMsg
(
connFd
,
&
msg
,
sizeof
(
SSyncMsg
))
!=
sizeof
(
SSyncMsg
))
{
sError
(
"failed to read peer
sync msg
from ip:%s since %s"
,
ipstr
,
strerror
(
errno
));
taosCloseSocket
(
connFd
);
return
;
}
...
...
@@ -127,9 +127,9 @@ static void arbProcessIncommingConnection(int32_t connFd, uint32_t sourceIp) {
return
;
}
firstPkt
.
fqdn
[
sizeof
(
firstPkt
.
fqdn
)
-
1
]
=
0
;
snprintf
(
pNode
->
id
,
sizeof
(
pNode
->
id
),
"vgId:%d, peer:%s:%d"
,
firstPkt
.
sourceId
,
firstPkt
.
fqdn
,
firstPkt
.
port
);
if
(
firstPkt
.
syncH
ead
.
vgId
)
{
msg
.
fqdn
[
TSDB_FQDN_LEN
-
1
]
=
0
;
snprintf
(
pNode
->
id
,
sizeof
(
pNode
->
id
),
"vgId:%d, peer:%s:%d"
,
msg
.
sourceId
,
msg
.
fqdn
,
msg
.
port
);
if
(
msg
.
h
ead
.
vgId
)
{
sDebug
(
"%s, vgId in head is not zero, close the connection"
,
pNode
->
id
);
tfree
(
pNode
);
taosCloseSocket
(
connFd
);
...
...
@@ -138,7 +138,7 @@ static void arbProcessIncommingConnection(int32_t connFd, uint32_t sourceIp) {
sDebug
(
"%s, arbitrator request is accepted"
,
pNode
->
id
);
pNode
->
nodeFd
=
connFd
;
pNode
->
pConn
=
taos
AllocateTcpConn
(
tsArbTcpPool
,
pNode
,
connFd
);
pNode
->
pConn
=
sync
AllocateTcpConn
(
tsArbTcpPool
,
pNode
,
connFd
);
return
;
}
...
...
@@ -156,8 +156,8 @@ static int32_t arbProcessPeerMsg(void *param, void *buffer) {
int32_t
bytes
=
0
;
char
*
cont
=
(
char
*
)
buffer
;
int32_t
hlen
=
taosReadMsg
(
pNode
->
nodeFd
,
&
head
,
sizeof
(
h
ead
));
if
(
hlen
!=
sizeof
(
h
ead
))
{
int32_t
hlen
=
taosReadMsg
(
pNode
->
nodeFd
,
&
head
,
sizeof
(
SSyncH
ead
));
if
(
hlen
!=
sizeof
(
SSyncH
ead
))
{
sDebug
(
"%s, failed to read msg, hlen:%d"
,
pNode
->
id
,
hlen
);
return
-
1
;
}
...
...
src/sync/src/syncMain.c
浏览文件 @
46c732db
此差异已折叠。
点击以展开。
src/sync/src/syncMsg.c
0 → 100644
浏览文件 @
46c732db
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taoserror.h"
#include "tglobal.h"
#include "tchecksum.h"
#include "syncInt.h"
char
*
statusType
[]
=
{
"broadcast"
,
"broadcast-rsp"
,
"setup-conn"
,
"setup-conn-rsp"
,
"exchange-data"
,
"exchange-data-rsp"
,
"check-role"
,
"check-role-rsp"
};
uint16_t
syncGenTranId
()
{
return
taosRand
()
&
0XFFFF
;
}
static
void
syncBuildHead
(
SSyncHead
*
pHead
)
{
pHead
->
protocol
=
SYNC_PROTOCOL_VERSION
;
pHead
->
signature
=
SYNC_SIGNATURE
;
pHead
->
code
=
0
;
pHead
->
cId
=
0
;
taosCalcChecksumAppend
(
0
,
(
uint8_t
*
)
pHead
,
sizeof
(
SSyncHead
));
}
int32_t
syncCheckHead
(
SSyncHead
*
pHead
)
{
if
(
pHead
->
protocol
!=
SYNC_PROTOCOL_VERSION
)
return
TSDB_CODE_SYN_MISMATCHED_PROTOCOL
;
if
(
pHead
->
signature
!=
SYNC_SIGNATURE
)
return
TSDB_CODE_SYN_MISMATCHED_SIGNATURE
;
if
(
pHead
->
cId
!=
0
)
return
TSDB_CODE_SYN_MISMATCHED_CLUSTERID
;
if
(
pHead
->
len
<=
0
||
pHead
->
len
>
TSDB_MAX_WAL_SIZE
)
return
TSDB_CODE_SYN_INVALID_MSGLEN
;
if
(
pHead
->
type
<=
TAOS_SMSG_START
||
pHead
->
type
>=
TAOS_SMSG_END
)
return
TSDB_CODE_SYN_INVALID_MSGTYPE
;
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)
pHead
,
sizeof
(
SSyncHead
)))
return
TSDB_CODE_SYN_INVALID_CHECKSUM
;
return
TSDB_CODE_SUCCESS
;
}
void
syncBuildSyncFwdMsg
(
SSyncHead
*
pHead
,
int32_t
vgId
,
int32_t
len
)
{
pHead
->
type
=
TAOS_SMSG_SYNC_FWD
;
pHead
->
vgId
=
vgId
;
pHead
->
len
=
len
;
syncBuildHead
(
pHead
);
}
void
syncBuildSyncFwdRsp
(
SFwdRsp
*
pMsg
,
int32_t
vgId
,
uint64_t
version
,
int32_t
code
)
{
pMsg
->
head
.
type
=
TAOS_SMSG_SYNC_FWD_RSP
;
pMsg
->
head
.
vgId
=
vgId
;
pMsg
->
head
.
len
=
sizeof
(
SFwdRsp
)
-
sizeof
(
SSyncHead
);
syncBuildHead
(
&
pMsg
->
head
);
pMsg
->
version
=
version
;
pMsg
->
code
=
code
;
}
static
void
syncBuildMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
,
ESyncMsgType
type
)
{
pMsg
->
head
.
type
=
type
;
pMsg
->
head
.
vgId
=
vgId
;
pMsg
->
head
.
len
=
sizeof
(
SSyncMsg
)
-
sizeof
(
SSyncHead
);
syncBuildHead
(
&
pMsg
->
head
);
pMsg
->
port
=
tsSyncPort
;
pMsg
->
tranId
=
syncGenTranId
();
pMsg
->
sourceId
=
vgId
;
tstrncpy
(
pMsg
->
fqdn
,
tsNodeFqdn
,
TSDB_FQDN_LEN
);
}
void
syncBuildSyncReqMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
)
{
syncBuildMsg
(
pMsg
,
vgId
,
TAOS_SMSG_SYNC_REQ
);
}
void
syncBuildSyncDataMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
)
{
syncBuildMsg
(
pMsg
,
vgId
,
TAOS_SMSG_SYNC_DATA
);
}
void
syncBuildSyncSetupMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
)
{
syncBuildMsg
(
pMsg
,
vgId
,
TAOS_SMSG_SETUP
);
}
void
syncBuildPeersStatus
(
SPeersStatus
*
pMsg
,
int32_t
vgId
)
{
pMsg
->
head
.
type
=
TAOS_SMSG_STATUS
;
pMsg
->
head
.
vgId
=
vgId
;
pMsg
->
head
.
len
=
sizeof
(
SPeersStatus
)
-
sizeof
(
SSyncHead
);
syncBuildHead
(
&
pMsg
->
head
);
}
void
syncBuildFileAck
(
SFileAck
*
pMsg
,
int32_t
vgId
)
{
pMsg
->
head
.
type
=
TAOS_SMSG_SYNC_FILE_RSP
;
pMsg
->
head
.
vgId
=
vgId
;
pMsg
->
head
.
len
=
sizeof
(
SFileAck
)
-
sizeof
(
SSyncHead
);
syncBuildHead
(
&
pMsg
->
head
);
}
void
syncBuildFileInfo
(
SFileInfo
*
pMsg
,
int32_t
vgId
)
{
pMsg
->
head
.
type
=
TAOS_SMSG_SYNC_FILE
;
pMsg
->
head
.
vgId
=
vgId
;
pMsg
->
head
.
len
=
sizeof
(
SFileInfo
)
-
sizeof
(
SSyncHead
);
syncBuildHead
(
&
pMsg
->
head
);
}
\ No newline at end of file
src/sync/src/syncRestore.c
浏览文件 @
46c732db
...
...
@@ -56,7 +56,7 @@ static int32_t syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) {
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
SFileInfo
minfo
;
memset
(
&
minfo
,
0
,
sizeof
(
SFileInfo
));
/* = {0}; */
SFileInfo
sinfo
;
memset
(
&
sinfo
,
0
,
sizeof
(
SFileInfo
));
/* = {0}; */
SFileAck
fileAck
=
{
0
}
;
SFileAck
fileAck
;
memset
(
&
fileAck
,
0
,
sizeof
(
SFileAck
))
;
int32_t
code
=
-
1
;
char
name
[
TSDB_FILENAME_LEN
*
2
]
=
{
0
};
uint32_t
pindex
=
0
;
// index in last restore
...
...
@@ -69,7 +69,14 @@ static int32_t syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) {
minfo
.
index
=
-
1
;
int32_t
ret
=
taosReadMsg
(
pPeer
->
syncFd
,
&
minfo
,
sizeof
(
SFileInfo
));
if
(
ret
!=
sizeof
(
SFileInfo
)
||
minfo
.
index
==
-
1
)
{
sError
(
"%s, failed to read file info while restore file since %s"
,
pPeer
->
id
,
strerror
(
errno
));
sError
(
"%s, failed to read fileinfo while restore file since %s"
,
pPeer
->
id
,
strerror
(
errno
));
break
;
}
assert
(
ret
==
sizeof
(
SFileInfo
));
ret
=
syncCheckHead
((
SSyncHead
*
)(
&
minfo
));
if
(
ret
!=
0
)
{
sError
(
"%s, failed to check fileinfo while restore file since %s"
,
pPeer
->
id
,
strerror
(
ret
));
break
;
}
...
...
@@ -94,12 +101,13 @@ static int32_t syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) {
&
sinfo
.
fversion
);
// if file not there or magic is not the same, file shall be synced
memset
(
&
fileAck
,
0
,
sizeof
(
fileAck
));
memset
(
&
fileAck
,
0
,
sizeof
(
SFileAck
));
syncBuildFileAck
(
&
fileAck
,
pNode
->
vgId
);
fileAck
.
sync
=
(
sinfo
.
magic
!=
minfo
.
magic
||
sinfo
.
name
[
0
]
==
0
)
?
1
:
0
;
// send file ack
ret
=
taosWriteMsg
(
pPeer
->
syncFd
,
&
fileAck
,
sizeof
(
f
ileAck
));
if
(
ret
!=
sizeof
(
f
ileAck
))
{
ret
=
taosWriteMsg
(
pPeer
->
syncFd
,
&
fileAck
,
sizeof
(
SF
ileAck
));
if
(
ret
!=
sizeof
(
SF
ileAck
))
{
sError
(
"%s, failed to write file:%s ack while restore file since %s"
,
pPeer
->
id
,
minfo
.
name
,
strerror
(
errno
));
break
;
}
...
...
@@ -289,12 +297,12 @@ static int32_t syncRestoreDataStepByStep(SSyncPeer *pPeer) {
uint64_t
fversion
=
0
;
sInfo
(
"%s, start to restore, sstatus:%s"
,
pPeer
->
id
,
syncStatus
[
pPeer
->
sstatus
]);
S
FirstPktRsp
firstPktR
sp
=
{.
sync
=
1
,
.
tranId
=
syncGenTranId
()};
if
(
taosWriteMsg
(
pPeer
->
syncFd
,
&
firstPktRsp
,
sizeof
(
SFirstPktRsp
))
!=
sizeof
(
SFirstPkt
Rsp
))
{
sError
(
"%s, failed to send sync
firstPkt
rsp since %s"
,
pPeer
->
id
,
strerror
(
errno
));
S
SyncRsp
r
sp
=
{.
sync
=
1
,
.
tranId
=
syncGenTranId
()};
if
(
taosWriteMsg
(
pPeer
->
syncFd
,
&
rsp
,
sizeof
(
SSyncRsp
))
!=
sizeof
(
SSync
Rsp
))
{
sError
(
"%s, failed to send sync rsp since %s"
,
pPeer
->
id
,
strerror
(
errno
));
return
-
1
;
}
sDebug
(
"%s, send
firstPktRsp to peer, tranId:%u"
,
pPeer
->
id
,
firstPktR
sp
.
tranId
);
sDebug
(
"%s, send
sync rsp to peer, tranId:%u"
,
pPeer
->
id
,
r
sp
.
tranId
);
sInfo
(
"%s, start to restore file, set sstatus:%s"
,
pPeer
->
id
,
syncStatus
[
nodeSStatus
]);
int32_t
code
=
syncRestoreFile
(
pPeer
,
&
fversion
);
...
...
src/sync/src/syncRetrieve.c
浏览文件 @
46c732db
...
...
@@ -88,7 +88,7 @@ static bool syncAreFilesModified(SSyncNode *pNode, SSyncPeer *pPeer) {
static
int32_t
syncRetrieveFile
(
SSyncPeer
*
pPeer
)
{
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
SFileInfo
fileInfo
;
memset
(
&
fileInfo
,
0
,
sizeof
(
SFileInfo
));
SFileAck
fileAck
=
{
0
}
;
SFileAck
fileAck
;
memset
(
&
fileAck
,
0
,
sizeof
(
SFileAck
))
;
int32_t
code
=
-
1
;
char
name
[
TSDB_FILENAME_LEN
*
2
]
=
{
0
};
...
...
@@ -103,11 +103,12 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) {
fileInfo
.
size
=
0
;
fileInfo
.
magic
=
(
*
pNode
->
getFileInfo
)(
pNode
->
vgId
,
fileInfo
.
name
,
&
fileInfo
.
index
,
TAOS_SYNC_MAX_INDEX
,
&
fileInfo
.
size
,
&
fileInfo
.
fversion
);
syncBuildFileInfo
(
&
fileInfo
,
pNode
->
vgId
);
sDebug
(
"%s, file:%s info is sent, size:%"
PRId64
,
pPeer
->
id
,
fileInfo
.
name
,
fileInfo
.
size
);
// send the file info
int32_t
ret
=
taosWriteMsg
(
pPeer
->
syncFd
,
&
(
fileInfo
),
sizeof
(
f
ileInfo
));
if
(
ret
!=
sizeof
(
f
ileInfo
))
{
int32_t
ret
=
taosWriteMsg
(
pPeer
->
syncFd
,
&
(
fileInfo
),
sizeof
(
SF
ileInfo
));
if
(
ret
!=
sizeof
(
SF
ileInfo
))
{
code
=
-
1
;
sError
(
"%s, failed to write file:%s info while retrieve file since %s"
,
pPeer
->
id
,
fileInfo
.
name
,
strerror
(
errno
));
break
;
...
...
@@ -128,6 +129,13 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) {
break
;
}
ret
=
syncCheckHead
((
SSyncHead
*
)(
&
fileAck
));
if
(
ret
!=
0
)
{
code
=
-
1
;
sError
(
"%s, failed to check file:%s ack while retrieve file since %s"
,
pPeer
->
id
,
fileInfo
.
name
,
strerror
(
ret
));
break
;
}
// set the peer sync version
pPeer
->
sversion
=
fileInfo
.
fversion
;
...
...
@@ -405,27 +413,22 @@ static int32_t syncRetrieveWal(SSyncPeer *pPeer) {
static
int32_t
syncRetrieveFirstPkt
(
SSyncPeer
*
pPeer
)
{
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
SFirstPkt
firstPkt
;
memset
(
&
firstPkt
,
0
,
sizeof
(
firstPkt
));
firstPkt
.
syncHead
.
type
=
TAOS_SMSG_SYNC_DATA
;
firstPkt
.
syncHead
.
vgId
=
pNode
->
vgId
;
firstPkt
.
tranId
=
syncGenTranId
();
tstrncpy
(
firstPkt
.
fqdn
,
tsNodeFqdn
,
sizeof
(
firstPkt
.
fqdn
));
firstPkt
.
port
=
tsSyncPort
;
SSyncMsg
msg
;
syncBuildSyncDataMsg
(
&
msg
,
pNode
->
vgId
);
if
(
taosWriteMsg
(
pPeer
->
syncFd
,
&
firstPkt
,
sizeof
(
firstPkt
))
!=
sizeof
(
firstPkt
))
{
sError
(
"%s, failed to send sync
firstPkt since %s, tranId:%u"
,
pPeer
->
id
,
strerror
(
errno
),
firstPkt
.
tranId
);
if
(
taosWriteMsg
(
pPeer
->
syncFd
,
&
msg
,
sizeof
(
SSyncMsg
))
!=
sizeof
(
SSyncMsg
))
{
sError
(
"%s, failed to send sync
-data msg since %s, tranId:%u"
,
pPeer
->
id
,
strerror
(
errno
),
msg
.
tranId
);
return
-
1
;
}
sDebug
(
"%s, send sync-data
pkt to peer, tranId:%u"
,
pPeer
->
id
,
firstPkt
.
tranId
);
sDebug
(
"%s, send sync-data
msg to peer, tranId:%u"
,
pPeer
->
id
,
msg
.
tranId
);
S
FirstPktRsp
firstPktR
sp
;
if
(
taosReadMsg
(
pPeer
->
syncFd
,
&
firstPktRsp
,
sizeof
(
SFirstPktRsp
))
!=
sizeof
(
SFirstPkt
Rsp
))
{
sError
(
"%s, failed to read sync
firstPkt rsp since %s, tranId:%u"
,
pPeer
->
id
,
strerror
(
errno
),
firstPkt
.
tranId
);
S
SyncRsp
r
sp
;
if
(
taosReadMsg
(
pPeer
->
syncFd
,
&
rsp
,
sizeof
(
SSyncRsp
))
!=
sizeof
(
SSync
Rsp
))
{
sError
(
"%s, failed to read sync
-data rsp since %s, tranId:%u"
,
pPeer
->
id
,
strerror
(
errno
),
msg
.
tranId
);
return
-
1
;
}
sDebug
(
"%s, recv
firstPktRsp from peer, tranId:%u"
,
pPeer
->
id
,
firstPkt
.
tranId
);
sDebug
(
"%s, recv
sync-data rsp from peer, tranId:%u rsp-tranId:%u"
,
pPeer
->
id
,
msg
.
tranId
,
rsp
.
tranId
);
return
0
;
}
...
...
src/sync/src/
taosTcpPool
.c
→
src/sync/src/
syncTcp
.c
浏览文件 @
46c732db
...
...
@@ -19,10 +19,10 @@
#include "tutil.h"
#include "tsocket.h"
#include "taoserror.h"
#include "taosTcpPool.h"
#include "twal.h"
#include "tsync.h"
#include "syncInt.h"
#include "syncTcp.h"
typedef
struct
SThreadObj
{
pthread_t
thread
;
...
...
@@ -47,12 +47,12 @@ typedef struct {
int32_t
closedByApp
;
}
SConnObj
;
static
void
*
taos
AcceptPeerTcpConnection
(
void
*
argv
);
static
void
*
taos
ProcessTcpData
(
void
*
param
);
static
void
taos
StopPoolThread
(
SThreadObj
*
pThread
);
static
SThreadObj
*
taos
GetTcpThread
(
SPoolObj
*
pPool
);
static
void
*
sync
AcceptPeerTcpConnection
(
void
*
argv
);
static
void
*
sync
ProcessTcpData
(
void
*
param
);
static
void
sync
StopPoolThread
(
SThreadObj
*
pThread
);
static
SThreadObj
*
sync
GetTcpThread
(
SPoolObj
*
pPool
);
void
*
taos
OpenTcpThreadPool
(
SPoolInfo
*
pInfo
)
{
void
*
sync
OpenTcpThreadPool
(
SPoolInfo
*
pInfo
)
{
pthread_attr_t
thattr
;
SPoolObj
*
pPool
=
calloc
(
sizeof
(
SPoolObj
),
1
);
...
...
@@ -80,7 +80,7 @@ void *taosOpenTcpThreadPool(SPoolInfo *pInfo) {
pthread_attr_init
(
&
thattr
);
pthread_attr_setdetachstate
(
&
thattr
,
PTHREAD_CREATE_JOINABLE
);
if
(
pthread_create
(
&
(
pPool
->
thread
),
&
thattr
,
(
void
*
)
taos
AcceptPeerTcpConnection
,
pPool
)
!=
0
)
{
if
(
pthread_create
(
&
(
pPool
->
thread
),
&
thattr
,
(
void
*
)
sync
AcceptPeerTcpConnection
,
pPool
)
!=
0
)
{
sError
(
"failed to create accept thread for TCP server since %s"
,
strerror
(
errno
));
close
(
pPool
->
acceptFd
);
tfree
(
pPool
->
pThread
);
...
...
@@ -94,7 +94,7 @@ void *taosOpenTcpThreadPool(SPoolInfo *pInfo) {
return
pPool
;
}
void
taos
CloseTcpThreadPool
(
void
*
param
)
{
void
sync
CloseTcpThreadPool
(
void
*
param
)
{
SPoolObj
*
pPool
=
param
;
SThreadObj
*
pThread
;
...
...
@@ -103,7 +103,7 @@ void taosCloseTcpThreadPool(void *param) {
for
(
int32_t
i
=
0
;
i
<
pPool
->
info
.
numOfThreads
;
++
i
)
{
pThread
=
pPool
->
pThread
[
i
];
if
(
pThread
)
taos
StopPoolThread
(
pThread
);
if
(
pThread
)
sync
StopPoolThread
(
pThread
);
}
sDebug
(
"%p TCP pool is closed"
,
pPool
);
...
...
@@ -112,7 +112,7 @@ void taosCloseTcpThreadPool(void *param) {
tfree
(
pPool
);
}
void
*
taos
AllocateTcpConn
(
void
*
param
,
void
*
pPeer
,
int32_t
connFd
)
{
void
*
sync
AllocateTcpConn
(
void
*
param
,
void
*
pPeer
,
int32_t
connFd
)
{
struct
epoll_event
event
;
SPoolObj
*
pPool
=
param
;
...
...
@@ -122,7 +122,7 @@ void *taosAllocateTcpConn(void *param, void *pPeer, int32_t connFd) {
return
NULL
;
}
SThreadObj
*
pThread
=
taos
GetTcpThread
(
pPool
);
SThreadObj
*
pThread
=
sync
GetTcpThread
(
pPool
);
if
(
pThread
==
NULL
)
{
tfree
(
pConn
);
return
NULL
;
...
...
@@ -149,7 +149,7 @@ void *taosAllocateTcpConn(void *param, void *pPeer, int32_t connFd) {
return
pConn
;
}
void
taos
FreeTcpConn
(
void
*
param
)
{
void
sync
FreeTcpConn
(
void
*
param
)
{
SConnObj
*
pConn
=
param
;
SThreadObj
*
pThread
=
pConn
->
pThread
;
...
...
@@ -175,7 +175,7 @@ static void taosProcessBrokenLink(SConnObj *pConn) {
#define maxEvents 10
static
void
*
taos
ProcessTcpData
(
void
*
param
)
{
static
void
*
sync
ProcessTcpData
(
void
*
param
)
{
SThreadObj
*
pThread
=
(
SThreadObj
*
)
param
;
SPoolObj
*
pPool
=
pThread
->
pPool
;
SPoolInfo
*
pInfo
=
&
pPool
->
info
;
...
...
@@ -222,7 +222,7 @@ static void *taosProcessTcpData(void *param) {
if
(
pConn
->
closedByApp
==
0
)
{
if
((
*
pInfo
->
processIncomingMsg
)(
pConn
->
ahandle
,
buffer
)
<
0
)
{
taos
FreeTcpConn
(
pConn
);
sync
FreeTcpConn
(
pConn
);
continue
;
}
}
...
...
@@ -239,7 +239,7 @@ static void *taosProcessTcpData(void *param) {
return
NULL
;
}
static
void
*
taos
AcceptPeerTcpConnection
(
void
*
argv
)
{
static
void
*
sync
AcceptPeerTcpConnection
(
void
*
argv
)
{
SPoolObj
*
pPool
=
(
SPoolObj
*
)
argv
;
SPoolInfo
*
pInfo
=
&
pPool
->
info
;
...
...
@@ -268,7 +268,7 @@ static void *taosAcceptPeerTcpConnection(void *argv) {
return
NULL
;
}
static
SThreadObj
*
taos
GetTcpThread
(
SPoolObj
*
pPool
)
{
static
SThreadObj
*
sync
GetTcpThread
(
SPoolObj
*
pPool
)
{
SThreadObj
*
pThread
=
pPool
->
pThread
[
pPool
->
nextId
];
if
(
pThread
)
return
pThread
;
...
...
@@ -286,7 +286,7 @@ static SThreadObj *taosGetTcpThread(SPoolObj *pPool) {
pthread_attr_t
thattr
;
pthread_attr_init
(
&
thattr
);
pthread_attr_setdetachstate
(
&
thattr
,
PTHREAD_CREATE_JOINABLE
);
int32_t
ret
=
pthread_create
(
&
(
pThread
->
thread
),
&
thattr
,
(
void
*
)
taos
ProcessTcpData
,
pThread
);
int32_t
ret
=
pthread_create
(
&
(
pThread
->
thread
),
&
thattr
,
(
void
*
)
sync
ProcessTcpData
,
pThread
);
pthread_attr_destroy
(
&
thattr
);
if
(
ret
!=
0
)
{
...
...
@@ -303,7 +303,7 @@ static SThreadObj *taosGetTcpThread(SPoolObj *pPool) {
return
pThread
;
}
static
void
taos
StopPoolThread
(
SThreadObj
*
pThread
)
{
static
void
sync
StopPoolThread
(
SThreadObj
*
pThread
)
{
pthread_t
thread
=
pThread
->
thread
;
if
(
!
taosCheckPthreadValid
(
thread
))
{
return
;
...
...
src/sync/test/syncServer.c
浏览文件 @
46c732db
...
...
@@ -100,7 +100,7 @@ int processRpcMsg(void *item) {
pHead
->
msgType
=
pMsg
->
msgType
;
pHead
->
len
=
pMsg
->
contLen
;
uDebug
(
"ver:%"
PRIu64
",
pkt
from client processed"
,
pHead
->
version
);
uDebug
(
"ver:%"
PRIu64
",
rsp
from client processed"
,
pHead
->
version
);
writeIntoWal
(
pHead
);
syncForwardToPeer
(
syncHandle
,
pHead
,
item
,
TAOS_QTYPE_RPC
);
...
...
@@ -275,7 +275,7 @@ int getWalInfo(int32_t vgId, char *name, int64_t *index) {
int
writeToCache
(
int32_t
vgId
,
void
*
data
,
int
type
)
{
SWalHead
*
pHead
=
data
;
uDebug
(
"
pkt
from peer is received, ver:%"
PRIu64
" len:%d type:%d"
,
pHead
->
version
,
pHead
->
len
,
type
);
uDebug
(
"
rsp
from peer is received, ver:%"
PRIu64
" len:%d type:%d"
,
pHead
->
version
,
pHead
->
len
,
type
);
int
msgSize
=
pHead
->
len
+
sizeof
(
SWalHead
);
void
*
pMsg
=
taosAllocateQitem
(
msgSize
);
...
...
tests/script/unique/db/replica_add13.sim
浏览文件 @
46c732db
...
...
@@ -110,6 +110,7 @@ sql insert into d1.t1 values(1589529000012, 2)
sql insert into d2.t2 values(1589529000022, 2)
sql insert into d3.t3 values(1589529000032, 2)
sql insert into d4.t4 values(1589529000042, 2)
sleep 1000
sql select * from d1.t1
if $rows != 2 then
...
...
@@ -141,6 +142,7 @@ sql insert into d1.t1 values(1589529000013, 3)
sql insert into d2.t2 values(1589529000023, 3)
sql insert into d3.t3 values(1589529000033, 3)
sql insert into d4.t4 values(1589529000043, 3)
sleep 1000
sql select * from d1.t1
if $rows != 3 then
...
...
@@ -172,6 +174,7 @@ sql insert into d1.t1 values(1589529000014, 4)
sql insert into d2.t2 values(1589529000024, 4)
sql insert into d3.t3 values(1589529000034, 4)
sql insert into d4.t4 values(1589529000044, 4)
sleep 1000
sql select * from d1.t1
print select * from d1.t1 $rows
...
...
@@ -207,6 +210,7 @@ sql insert into d1.t1 values(1589529000015, 5)
sql insert into d2.t2 values(1589529000025, 5)
sql insert into d3.t3 values(1589529000035, 5)
sql insert into d4.t4 values(1589529000045, 5)
sleep 1000
sql select * from d1.t1
if $rows != 5 then
...
...
@@ -238,6 +242,7 @@ sql insert into d1.t1 values(1589529000016, 6)
sql insert into d2.t2 values(1589529000026, 6)
sql insert into d3.t3 values(1589529000036, 6)
sql insert into d4.t4 values(1589529000046, 6)
sleep 1000
sql select * from d1.t1
if $rows != 6 then
...
...
tests/script/unique/db/replica_add23.sim
浏览文件 @
46c732db
...
...
@@ -110,6 +110,7 @@ sql insert into d1.t1 values(1588262400002, 2)
sql insert into d2.t2 values(1588262400002, 2)
sql insert into d3.t3 values(1588262400002, 2)
sql insert into d4.t4 values(1588262400002, 2)
sleep 1000
sql select * from d1.t1
if $rows != 2 then
...
...
@@ -142,6 +143,7 @@ sql insert into d1.t1 values(1588262400003, 3)
sql insert into d2.t2 values(1588262400003, 3)
sql insert into d3.t3 values(1588262400003, 3)
sql insert into d4.t4 values(1588262400003, 3)
sleep 1000
sql select * from d1.t1
if $rows != 3 then
...
...
@@ -173,6 +175,7 @@ sql insert into d1.t1 values(1588262400004, 4)
sql insert into d2.t2 values(1588262400004, 4)
sql insert into d3.t3 values(1588262400004, 4)
sql insert into d4.t4 values(1588262400004, 4)
sleep 1000
sql select * from d1.t1
if $rows != 4 then
...
...
@@ -204,6 +207,7 @@ sql insert into d1.t1 values(1588262400005, 5)
sql insert into d2.t2 values(1588262400005, 5)
sql insert into d3.t3 values(1588262400005, 5)
sql insert into d4.t4 values(1588262400005, 5)
sleep 1000
sql select * from d1.t1
if $rows != 5 then
...
...
@@ -235,6 +239,7 @@ sql insert into d1.t1 values(1588262400006, 6)
sql insert into d2.t2 values(1588262400006, 6)
sql insert into d3.t3 values(1588262400006, 6)
sql insert into d4.t4 values(1588262400006, 6)
sleep 1000
sql select * from d1.t1
if $rows != 6 then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录