Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ac282bdb
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看板
提交
ac282bdb
编写于
3月 22, 2022
作者:
P
plum-lihui
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of github.com:taosdata/TDengine into 3.0
上级
a4e6423b
223721a1
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
25 addition
and
12 deletion
+25
-12
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+1
-1
source/libs/sync/inc/syncEnv.h
source/libs/sync/inc/syncEnv.h
+3
-3
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+5
-0
source/libs/sync/inc/syncUtil.h
source/libs/sync/inc/syncUtil.h
+1
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+10
-5
source/libs/sync/src/syncUtil.c
source/libs/sync/src/syncUtil.c
+4
-1
source/libs/sync/test/syncUtilTest.cpp
source/libs/sync/test/syncUtilTest.cpp
+1
-1
未找到文件。
source/libs/parser/src/parAstCreater.c
浏览文件 @
ac282bdb
...
...
@@ -892,7 +892,7 @@ SDataType createDataType(uint8_t type) {
}
SDataType
createVarLenDataType
(
uint8_t
type
,
const
SToken
*
pLen
)
{
SDataType
dt
=
{
.
type
=
type
,
.
precision
=
0
,
.
scale
=
0
,
.
bytes
=
tDataTypes
[
type
].
bytes
};
SDataType
dt
=
{
.
type
=
type
,
.
precision
=
0
,
.
scale
=
0
,
.
bytes
=
strtol
(
pLen
->
z
,
NULL
,
10
)
};
return
dt
;
}
...
...
source/libs/sync/inc/syncEnv.h
浏览文件 @
ac282bdb
...
...
@@ -31,10 +31,10 @@ extern "C" {
#define TIMER_MAX_MS 0x7FFFFFFF
#define ENV_TICK_TIMER_MS 1000
#define PING_TIMER_MS 1000
#define ELECT_TIMER_MS_MIN 150
0
#define ELECT_TIMER_MS_MAX
3000
#define ELECT_TIMER_MS_MIN 150
#define ELECT_TIMER_MS_MAX
(ELECT_TIMER_MS_MIN * 2)
#define ELECT_TIMER_MS_RANGE (ELECT_TIMER_MS_MAX - ELECT_TIMER_MS_MIN)
#define HEARTBEAT_TIMER_MS 30
0
#define HEARTBEAT_TIMER_MS 30
#define EMPTY_RAFT_ID ((SRaftId){.addr = 0, .vgId = 0})
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
ac282bdb
...
...
@@ -160,6 +160,11 @@ typedef struct SSyncNode {
SSyncLogStore
*
pLogStore
;
SyncIndex
commitIndex
;
// timer ms init
int32_t
pingBaseLine
;
int32_t
electBaseLine
;
int32_t
hbBaseLine
;
// ping timer
tmr_h
pPingTimer
;
int32_t
pingTimerMS
;
...
...
source/libs/sync/inc/syncUtil.h
浏览文件 @
ac282bdb
...
...
@@ -44,7 +44,7 @@ void syncUtilbufCopyDeep(const SSyncBuffer* src, SSyncBuffer* dest);
// ---- misc ----
int32_t
syncUtilRand
(
int32_t
max
);
int32_t
syncUtilElectRandomMS
();
int32_t
syncUtilElectRandomMS
(
int32_t
min
,
int32_t
max
);
int32_t
syncUtilQuorum
(
int32_t
replicaNum
);
cJSON
*
syncUtilNodeInfo2Json
(
const
SNodeInfo
*
p
);
cJSON
*
syncUtilRaftId2Json
(
const
SRaftId
*
p
);
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
ac282bdb
...
...
@@ -242,9 +242,14 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo) {
assert
(
pSyncNode
->
pLogStore
!=
NULL
);
pSyncNode
->
commitIndex
=
SYNC_INDEX_INVALID
;
// timer ms init
pSyncNode
->
pingBaseLine
=
PING_TIMER_MS
;
pSyncNode
->
electBaseLine
=
ELECT_TIMER_MS_MIN
;
pSyncNode
->
hbBaseLine
=
HEARTBEAT_TIMER_MS
;
// init ping timer
pSyncNode
->
pPingTimer
=
NULL
;
pSyncNode
->
pingTimerMS
=
PING_TIMER_MS
;
pSyncNode
->
pingTimerMS
=
pSyncNode
->
pingBaseLine
;
atomic_store_64
(
&
pSyncNode
->
pingTimerLogicClock
,
0
);
atomic_store_64
(
&
pSyncNode
->
pingTimerLogicClockUser
,
0
);
pSyncNode
->
FpPingTimerCB
=
syncNodeEqPingTimer
;
...
...
@@ -252,7 +257,7 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo) {
// init elect timer
pSyncNode
->
pElectTimer
=
NULL
;
pSyncNode
->
electTimerMS
=
syncUtilElectRandomMS
();
pSyncNode
->
electTimerMS
=
syncUtilElectRandomMS
(
pSyncNode
->
electBaseLine
,
2
*
pSyncNode
->
electBaseLine
);
atomic_store_64
(
&
pSyncNode
->
electTimerLogicClock
,
0
);
atomic_store_64
(
&
pSyncNode
->
electTimerLogicClockUser
,
0
);
pSyncNode
->
FpElectTimerCB
=
syncNodeEqElectTimer
;
...
...
@@ -260,7 +265,7 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo) {
// init heartbeat timer
pSyncNode
->
pHeartbeatTimer
=
NULL
;
pSyncNode
->
heartbeatTimerMS
=
HEARTBEAT_TIMER_MS
;
pSyncNode
->
heartbeatTimerMS
=
pSyncNode
->
hbBaseLine
;
atomic_store_64
(
&
pSyncNode
->
heartbeatTimerLogicClock
,
0
);
atomic_store_64
(
&
pSyncNode
->
heartbeatTimerLogicClockUser
,
0
);
pSyncNode
->
FpHeartbeatTimerCB
=
syncNodeEqHeartbeatTimer
;
...
...
@@ -394,7 +399,7 @@ int32_t syncNodeRestartElectTimer(SSyncNode* pSyncNode, int32_t ms) {
int32_t
syncNodeResetElectTimer
(
SSyncNode
*
pSyncNode
)
{
int32_t
ret
=
0
;
int32_t
electMS
=
syncUtilElectRandomMS
();
int32_t
electMS
=
syncUtilElectRandomMS
(
pSyncNode
->
electBaseLine
,
2
*
pSyncNode
->
electBaseLine
);
ret
=
syncNodeRestartElectTimer
(
pSyncNode
,
electMS
);
return
ret
;
}
...
...
@@ -763,7 +768,7 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) {
syncTimeoutDestroy
(
pSyncMsg
);
// reset timer ms
pSyncNode
->
electTimerMS
=
syncUtilElectRandomMS
();
pSyncNode
->
electTimerMS
=
syncUtilElectRandomMS
(
pSyncNode
->
electBaseLine
,
2
*
pSyncNode
->
electBaseLine
);
taosTmrReset
(
syncNodeEqPingTimer
,
pSyncNode
->
pingTimerMS
,
pSyncNode
,
gSyncEnv
->
pTimerManager
,
&
pSyncNode
->
pPingTimer
);
}
else
{
...
...
source/libs/sync/src/syncUtil.c
浏览文件 @
ac282bdb
...
...
@@ -96,7 +96,10 @@ void syncUtilbufCopyDeep(const SSyncBuffer* src, SSyncBuffer* dest) {
int32_t
syncUtilRand
(
int32_t
max
)
{
return
taosRand
()
%
max
;
}
int32_t
syncUtilElectRandomMS
()
{
return
ELECT_TIMER_MS_MIN
+
syncUtilRand
(
ELECT_TIMER_MS_RANGE
);
}
int32_t
syncUtilElectRandomMS
(
int32_t
min
,
int32_t
max
)
{
assert
(
min
>
0
&&
max
>
0
&&
max
>=
min
);
return
min
+
syncUtilRand
(
max
-
min
);
}
int32_t
syncUtilQuorum
(
int32_t
replicaNum
)
{
return
replicaNum
/
2
+
1
;
}
...
...
source/libs/sync/test/syncUtilTest.cpp
浏览文件 @
ac282bdb
...
...
@@ -16,7 +16,7 @@ void logTest() {
void
electRandomMSTest
()
{
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
int32_t
ms
=
syncUtilElectRandomMS
();
int32_t
ms
=
syncUtilElectRandomMS
(
150
,
300
);
printf
(
"syncUtilElectRandomMS: %d
\n
"
,
ms
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录