Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小楼昨夜-听风雨
TDengine
提交
9d6e3776
T
TDengine
项目概览
小楼昨夜-听风雨
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9d6e3776
编写于
11月 18, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1898
上级
52e99a8a
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
86 addition
and
85 deletion
+86
-85
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+64
-66
src/sync/inc/syncInt.h
src/sync/inc/syncInt.h
+1
-1
src/sync/src/syncMain.c
src/sync/src/syncMain.c
+17
-14
src/sync/src/syncRestore.c
src/sync/src/syncRestore.c
+1
-1
src/sync/src/syncRetrieve.c
src/sync/src/syncRetrieve.c
+1
-1
src/wal/src/walWrite.c
src/wal/src/walWrite.c
+2
-2
未找到文件。
src/mnode/src/mnodeSdb.c
浏览文件 @
9d6e3776
此差异已折叠。
点击以展开。
src/sync/inc/syncInt.h
浏览文件 @
9d6e3776
...
...
@@ -106,7 +106,7 @@ typedef struct {
int8_t
nacks
;
int8_t
confirmed
;
int32_t
code
;
uint64_t
time
;
int64_t
time
;
}
SFwdInfo
;
typedef
struct
{
...
...
src/sync/src/syncMain.c
浏览文件 @
9d6e3776
...
...
@@ -689,7 +689,7 @@ static void syncCheckRole(SSyncPeer *pPeer, SPeerStatus peersStatus[], int8_t ne
if
(
pMaster
)
{
// master is there
pNode
->
pMaster
=
pMaster
;
sDebug
(
"%s, it is the master, ver:%"
PRIu64
,
pMaster
->
id
,
pMaster
->
version
);
sDebug
(
"%s, it is the master,
s
ver:%"
PRIu64
,
pMaster
->
id
,
pMaster
->
version
);
if
(
syncValidateMaster
(
pPeer
)
<
0
)
return
;
...
...
@@ -697,7 +697,7 @@ static void syncCheckRole(SSyncPeer *pPeer, SPeerStatus peersStatus[], int8_t ne
if
(
nodeVersion
<
pMaster
->
version
)
{
syncRequired
=
1
;
}
else
{
sInfo
(
"%s is master, work as slave, ver:%"
PRIu64
,
pMaster
->
id
,
pMaster
->
version
);
sInfo
(
"%s is master, work as slave,
s
ver:%"
PRIu64
,
pMaster
->
id
,
pMaster
->
version
);
nodeRole
=
TAOS_SYNC_ROLE_SLAVE
;
(
*
pNode
->
notifyRole
)(
pNode
->
ahandle
,
nodeRole
);
}
...
...
@@ -854,7 +854,7 @@ static void syncProcessFwdResponse(char *cont, SSyncPeer *pPeer) {
SSyncFwds
*
pSyncFwds
=
pNode
->
pSyncFwds
;
SFwdInfo
*
pFwdInfo
;
sDebug
(
"%s, forward-rsp is received, code:%x ver:%"
PRIu64
,
pPeer
->
id
,
pFwdRsp
->
code
,
pFwdRsp
->
version
);
sDebug
(
"%s, forward-rsp is received, code:%x
h
ver:%"
PRIu64
,
pPeer
->
id
,
pFwdRsp
->
code
,
pFwdRsp
->
version
);
SFwdInfo
*
pFirst
=
pSyncFwds
->
fwdInfo
+
pSyncFwds
->
first
;
if
(
pFirst
->
version
<=
pFwdRsp
->
version
&&
pSyncFwds
->
fwds
>
0
)
{
...
...
@@ -891,7 +891,7 @@ static void syncProcessPeersStatusMsg(char *cont, SSyncPeer *pPeer) {
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
SPeersStatus
*
pPeersStatus
=
(
SPeersStatus
*
)
cont
;
sDebug
(
"%s, status msg is received, self:%s
ver:%"
PRIu64
" peer:%s
ver:%"
PRIu64
", ack:%d"
,
pPeer
->
id
,
sDebug
(
"%s, status msg is received, self:%s
sver:%"
PRIu64
" peer:%s s
ver:%"
PRIu64
", ack:%d"
,
pPeer
->
id
,
syncRole
[
nodeRole
],
nodeVersion
,
syncRole
[
pPeersStatus
->
role
],
pPeersStatus
->
version
,
pPeersStatus
->
ack
);
pPeer
->
version
=
pPeersStatus
->
version
;
...
...
@@ -979,7 +979,7 @@ static void syncSendPeersStatusMsgToPeer(SSyncPeer *pPeer, char ack) {
int32_t
retLen
=
write
(
pPeer
->
peerFd
,
msg
,
statusMsgLen
);
if
(
retLen
==
statusMsgLen
)
{
sDebug
(
"%s, status msg is sent, self:%s ver:%"
PRIu64
", ack:%d"
,
pPeer
->
id
,
syncRole
[
pPeersStatus
->
role
],
sDebug
(
"%s, status msg is sent, self:%s
s
ver:%"
PRIu64
", ack:%d"
,
pPeer
->
id
,
syncRole
[
pPeersStatus
->
role
],
pPeersStatus
->
version
,
pPeersStatus
->
ack
);
}
else
{
sDebug
(
"%s, failed to send status msg, restart"
,
pPeer
->
id
);
...
...
@@ -1154,7 +1154,7 @@ static void syncSaveFwdInfo(SSyncNode *pNode, uint64_t version, void *mhandle) {
pFwdInfo
->
time
=
time
;
pSyncFwds
->
fwds
++
;
sDebug
(
"vgId:%d, fwd info is saved, ver:%"
PRIu64
" fwds:%d "
,
pNode
->
vgId
,
version
,
pSyncFwds
->
fwds
);
sDebug
(
"vgId:%d, fwd info is saved,
h
ver:%"
PRIu64
" fwds:%d "
,
pNode
->
vgId
,
version
,
pSyncFwds
->
fwds
);
}
static
void
syncRemoveConfirmedFwdInfo
(
SSyncNode
*
pNode
)
{
...
...
@@ -1168,7 +1168,7 @@ static void syncRemoveConfirmedFwdInfo(SSyncNode *pNode) {
pSyncFwds
->
first
=
(
pSyncFwds
->
first
+
1
)
%
tsMaxFwdInfo
;
pSyncFwds
->
fwds
--
;
if
(
pSyncFwds
->
fwds
==
0
)
pSyncFwds
->
first
=
pSyncFwds
->
last
;
// sDebug("vgId:%d, fwd info is removed, ver:%d, fwds:%d",
// sDebug("vgId:%d, fwd info is removed,
h
ver:%d, fwds:%d",
// pNode->vgId, pFwdInfo->version, pSyncFwds->fwds);
memset
(
pFwdInfo
,
0
,
sizeof
(
SFwdInfo
));
}
...
...
@@ -1191,7 +1191,7 @@ static void syncProcessFwdAck(SSyncNode *pNode, SFwdInfo *pFwdInfo, int32_t code
}
if
(
confirm
&&
pFwdInfo
->
confirmed
==
0
)
{
sDebug
(
"vgId:%d, forward is confirmed, ver:%"
PRIu64
" code:%x"
,
pNode
->
vgId
,
pFwdInfo
->
version
,
pFwdInfo
->
code
);
sDebug
(
"vgId:%d, forward is confirmed,
h
ver:%"
PRIu64
" code:%x"
,
pNode
->
vgId
,
pFwdInfo
->
version
,
pFwdInfo
->
code
);
(
*
pNode
->
confirmForward
)(
pNode
->
ahandle
,
pFwdInfo
->
mhandle
,
pFwdInfo
->
code
);
pFwdInfo
->
confirmed
=
1
;
}
...
...
@@ -1204,14 +1204,17 @@ static void syncMonitorFwdInfos(void *param, void *tmrId) {
SSyncFwds
*
pSyncFwds
=
pNode
->
pSyncFwds
;
if
(
pSyncFwds
)
{
;
uint64_t
time
=
taosGetTimestampMs
();
if
(
pSyncFwds
)
{
int64_t
time
=
taosGetTimestampMs
();
if
(
pSyncFwds
->
fwds
>
0
)
{
pthread_mutex_lock
(
&
(
pNode
->
mutex
));
for
(
int32_t
i
=
0
;
i
<
pSyncFwds
->
fwds
;
++
i
)
{
SFwdInfo
*
pFwdInfo
=
pSyncFwds
->
fwdInfo
+
(
pSyncFwds
->
first
+
i
)
%
tsMaxFwdInfo
;
if
(
time
-
pFwdInfo
->
time
<
2000
)
break
;
if
(
ABS
(
time
-
pFwdInfo
->
time
)
<
2000
)
break
;
sDebug
(
"vgId:%d, forward info expired, hver:%"
PRIu64
" curtime:%"
PRIu64
" savetime:%"
PRIu64
,
pNode
->
vgId
,
pFwdInfo
->
version
,
time
,
pFwdInfo
->
time
);
syncProcessFwdAck
(
pNode
,
pFwdInfo
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
...
...
@@ -1234,7 +1237,7 @@ static int32_t syncForwardToPeerImpl(SSyncNode *pNode, void *data, void *mhandle
if
(
pWalHead
->
version
>
nodeVersion
+
1
)
{
sError
(
"vgId:%d, hver:%"
PRIu64
", inconsistent with ver:%"
PRIu64
,
pNode
->
vgId
,
pWalHead
->
version
,
nodeVersion
);
sError
(
"vgId:%d, hver:%"
PRIu64
", inconsistent with
s
ver:%"
PRIu64
,
pNode
->
vgId
,
pWalHead
->
version
,
nodeVersion
);
if
(
nodeRole
==
TAOS_SYNC_ROLE_SLAVE
)
{
sInfo
(
"vgId:%d, restart connection"
,
pNode
->
vgId
);
for
(
int32_t
i
=
0
;
i
<
pNode
->
replica
;
++
i
)
{
...
...
@@ -1277,9 +1280,9 @@ static int32_t syncForwardToPeerImpl(SSyncNode *pNode, void *data, void *mhandle
int32_t
retLen
=
write
(
pPeer
->
peerFd
,
pSyncHead
,
fwdLen
);
if
(
retLen
==
fwdLen
)
{
sDebug
(
"%s, forward is sent, ver:%"
PRIu64
" contLen:%d"
,
pPeer
->
id
,
pWalHead
->
version
,
pWalHead
->
len
);
sDebug
(
"%s, forward is sent,
h
ver:%"
PRIu64
" contLen:%d"
,
pPeer
->
id
,
pWalHead
->
version
,
pWalHead
->
len
);
}
else
{
sError
(
"%s, failed to forward, ver:%"
PRIu64
" retLen:%d"
,
pPeer
->
id
,
pWalHead
->
version
,
retLen
);
sError
(
"%s, failed to forward,
h
ver:%"
PRIu64
" retLen:%d"
,
pPeer
->
id
,
pWalHead
->
version
,
retLen
);
syncRestartConnection
(
pPeer
);
}
}
...
...
src/sync/src/syncRestore.c
浏览文件 @
9d6e3776
...
...
@@ -214,7 +214,7 @@ int32_t syncSaveIntoBuffer(SSyncPeer *pPeer, SWalHead *pHead) {
memcpy
(
pRecv
->
offset
,
pHead
,
len
);
pRecv
->
offset
+=
len
;
pRecv
->
forwards
++
;
sDebug
(
"%s, fwd is saved into queue, ver:%"
PRIu64
" fwds:%d"
,
pPeer
->
id
,
pHead
->
version
,
pRecv
->
forwards
);
sDebug
(
"%s, fwd is saved into queue,
h
ver:%"
PRIu64
" fwds:%d"
,
pPeer
->
id
,
pHead
->
version
,
pRecv
->
forwards
);
}
else
{
sError
(
"%s, buffer size:%d is too small"
,
pPeer
->
id
,
pRecv
->
bufferSize
);
pRecv
->
code
=
-
1
;
// set error code
...
...
src/sync/src/syncRetrieve.c
浏览文件 @
9d6e3776
...
...
@@ -268,7 +268,7 @@ static int32_t syncRetrieveLastWal(SSyncPeer *pPeer, char *name, uint64_t fversi
break
;
}
sDebug
(
"%s, last wal is forwarded, ver:%"
PRIu64
,
pPeer
->
id
,
pHead
->
version
);
sDebug
(
"%s, last wal is forwarded,
h
ver:%"
PRIu64
,
pPeer
->
id
,
pHead
->
version
);
int32_t
ret
=
taosWriteMsg
(
pPeer
->
syncFd
,
pHead
,
wsize
);
if
(
ret
!=
wsize
)
break
;
pPeer
->
sversion
=
pHead
->
version
;
...
...
src/wal/src/walWrite.c
浏览文件 @
9d6e3776
...
...
@@ -144,9 +144,9 @@ void walFsync(void *handle, bool forceFsync) {
if
(
pWal
==
NULL
||
pWal
->
fd
<
0
)
return
;
if
(
forceFsync
||
(
pWal
->
level
==
TAOS_WAL_FSYNC
&&
pWal
->
fsyncPeriod
==
0
))
{
wTrace
(
"vgId:%d, file
:%s, do fsync"
,
pWal
->
vgId
,
pWal
->
name
);
wTrace
(
"vgId:%d, file
Id:%"
PRId64
", do fsync"
,
pWal
->
vgId
,
pWal
->
fileId
);
if
(
fsync
(
pWal
->
fd
)
<
0
)
{
wError
(
"vgId:%d, file
:%s, fsync failed since %s"
,
pWal
->
vgId
,
pWal
->
name
,
strerror
(
errno
));
wError
(
"vgId:%d, file
Id:%"
PRId64
", fsync failed since %s"
,
pWal
->
vgId
,
pWal
->
fileId
,
strerror
(
errno
));
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录