Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
orchestrator
提交
0792076b
O
orchestrator
项目概览
github
/
orchestrator
9 个月 前同步成功
通知
18
Star
5143
Fork
916
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
orchestrator
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
0792076b
编写于
7月 13, 2021
作者:
P
Philipp Heckel
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More simplifications; still not done
上级
a1da8e15
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
13 deletion
+14
-13
go/inst/instance_topology_dao.go
go/inst/instance_topology_dao.go
+12
-12
go/logic/topology_recovery.go
go/logic/topology_recovery.go
+2
-1
未找到文件。
go/inst/instance_topology_dao.go
浏览文件 @
0792076b
...
...
@@ -611,7 +611,7 @@ func MaybeEnableSemiSyncReplica(replicaInstance *Instance) (*Instance, error) {
// given replica instance is in the list of replicas to have semi-sync enabled (according to the priority).
logFn
:=
func
(
s
string
,
a
...
interface
{})
{
log
.
Debugf
(
s
,
a
...
)
}
if
_
,
err
:=
RecoverSemiSyncReplicas
(
&
replicaInstance
.
MasterKey
,
&
replicaInstance
.
Key
,
config
.
Config
.
EnforceExactSemiSyncReplicas
,
logFn
);
err
!=
nil
{
return
replicaInstance
,
log
.
Error
e
(
err
)
return
replicaInstance
,
log
.
Error
f
(
"semi-sync: %w"
,
err
)
}
return
replicaInstance
,
nil
...
...
@@ -645,12 +645,12 @@ func RecoverSemiSyncReplicas(masterKey *InstanceKey, recoverOnlyReplicaKey *Inst
// Classify and prioritize replicas & figure out which replicas need to be acted upon
possibleSemiSyncReplicas
,
asyncReplicas
,
excludedReplicas
:=
classifyAndPrioritizeReplicas
(
replicas
,
recoverOnlyReplicaKey
)
actions
:=
determineSemiSyncReplicaActions
(
possibleSemiSyncReplicas
,
asyncReplicas
,
masterInstance
.
SemiSyncMasterWaitForReplicaCount
,
masterInstance
.
SemiSyncMasterClient
s
,
exactReplicaTopology
)
actions
:=
determineSemiSyncReplicaActions
(
masterInstance
,
possibleSemiSyncReplicas
,
asyncReplica
s
,
exactReplicaTopology
)
// Log analysis
logf
(
"semi-sync: analysis results for recovery of cluster %+v:"
,
masterInstance
.
ClusterName
)
logf
(
"semi-sync: master = %+v, replica repair scope = %+v, master semi-sync wait count = %d, master semi-sync replica count = %d"
,
masterKey
,
recoverOnlyReplicaKey
,
masterInstance
.
SemiSyncMasterWaitForReplicaCount
,
masterInstance
.
SemiSyncMasterClients
)
L
ogSemiSyncReplicaAnalysis
(
possibleSemiSyncReplicas
,
asyncReplicas
,
excludedReplicas
,
actions
,
logf
)
l
ogSemiSyncReplicaAnalysis
(
possibleSemiSyncReplicas
,
asyncReplicas
,
excludedReplicas
,
actions
,
logf
)
// Bail out if we cannot succeed
if
uint
(
len
(
possibleSemiSyncReplicas
))
<
masterInstance
.
SemiSyncMasterWaitForReplicaCount
{
...
...
@@ -719,20 +719,20 @@ func classifyAndPrioritizeReplicas(replicas []*Instance, includeNonReplicatingIn
// determineSemiSyncReplicaActions returns a map of replicas for which to change the semi-sync replica setting.
// A value of true indicates semi-sync needs to be enabled, false that it needs to be disabled.
func
determineSemiSyncReplicaActions
(
possibleSemiSyncReplicas
[]
*
Instance
,
asyncReplicas
[]
*
Instance
,
waitCount
uint
,
currentSemiSyncReplicas
uint
,
exactReplicaTopology
bool
)
map
[
*
Instance
]
bool
{
func
determineSemiSyncReplicaActions
(
masterInstance
*
Instance
,
possibleSemiSyncReplicas
[]
*
Instance
,
asyncReplicas
[]
*
Instance
,
exactReplicaTopology
bool
)
map
[
*
Instance
]
bool
{
if
exactReplicaTopology
{
return
determineSemiSyncReplicaActionsForExactTopology
(
possibleSemiSyncReplicas
,
asyncReplicas
,
waitCount
)
return
determineSemiSyncReplicaActionsForExactTopology
(
masterInstance
,
possibleSemiSyncReplicas
,
asyncReplicas
)
}
return
determineSemiSyncReplicaActionsForEnoughTopology
(
possibleSemiSyncReplicas
,
waitCount
,
current
SemiSyncReplicas
)
return
determineSemiSyncReplicaActionsForEnoughTopology
(
masterInstance
,
possible
SemiSyncReplicas
)
}
// determineSemiSyncReplicaActionsForExactTopology takes a priority-list of possible semi-sync replicas and always-async replicas and returns a list
// of actions to perform on them. If the current state of a replica's semi-sync flag does not match the desired state, an action is returned for it.
func
determineSemiSyncReplicaActionsForExactTopology
(
possibleSemiSyncReplicas
[]
*
Instance
,
asyncReplicas
[]
*
Instance
,
waitCount
uint
)
map
[
*
Instance
]
bool
{
func
determineSemiSyncReplicaActionsForExactTopology
(
masterInstance
*
Instance
,
possibleSemiSyncReplicas
[]
*
Instance
,
asyncReplicas
[]
*
Instance
)
map
[
*
Instance
]
bool
{
actions
:=
make
(
map
[
*
Instance
]
bool
,
0
)
// true = enable semi-sync, false = disable semi-sync
for
i
,
replica
:=
range
possibleSemiSyncReplicas
{
isSemiSyncEnabled
:=
replica
.
SemiSyncReplicaEnabled
shouldSemiSyncBeEnabled
:=
uint
(
i
)
<
wait
Count
shouldSemiSyncBeEnabled
:=
uint
(
i
)
<
masterInstance
.
SemiSyncMasterWaitForReplica
Count
if
shouldSemiSyncBeEnabled
&&
!
isSemiSyncEnabled
{
actions
[
replica
]
=
true
}
else
if
!
shouldSemiSyncBeEnabled
&&
isSemiSyncEnabled
{
...
...
@@ -749,7 +749,7 @@ func determineSemiSyncReplicaActionsForExactTopology(possibleSemiSyncReplicas []
// determineSemiSyncReplicaActionsForEnoughTopology takes a priority-list of possible semi-sync replicas and returns a list of actions to increase the
// number of semi-sync replicas to the semi-sync master wait count. This function will never return actions to disable a semi-sync replica.
func
determineSemiSyncReplicaActionsForEnoughTopology
(
possibleSemiSyncReplicas
[]
*
Instance
,
waitCount
uint
,
currentSemiSyncReplicas
uint
)
map
[
*
Instance
]
bool
{
func
determineSemiSyncReplicaActionsForEnoughTopology
(
masterInstance
*
Instance
,
possibleSemiSyncReplicas
[]
*
Instance
)
map
[
*
Instance
]
bool
{
actions
:=
make
(
map
[
*
Instance
]
bool
,
0
)
// true = enable semi-sync, false = disable semi-sync
enabled
:=
uint
(
0
)
for
_
,
replica
:=
range
possibleSemiSyncReplicas
{
...
...
@@ -757,15 +757,15 @@ func determineSemiSyncReplicaActionsForEnoughTopology(possibleSemiSyncReplicas [
actions
[
replica
]
=
true
enabled
++
}
if
enabled
==
waitCount
-
currentSemiSyncReplica
s
{
if
enabled
==
masterInstance
.
SemiSyncMasterWaitForReplicaCount
-
masterInstance
.
SemiSyncMasterClient
s
{
break
}
}
return
actions
}
//
L
ogSemiSyncReplicaAnalysis outputs the analysis results for a semi-sync analysis using the given log function
func
L
ogSemiSyncReplicaAnalysis
(
possibleSemiSyncReplicas
[]
*
Instance
,
asyncReplicas
[]
*
Instance
,
excludedReplicas
[]
*
Instance
,
actions
map
[
*
Instance
]
bool
,
logf
func
(
s
string
,
a
...
interface
{}))
{
//
l
ogSemiSyncReplicaAnalysis outputs the analysis results for a semi-sync analysis using the given log function
func
l
ogSemiSyncReplicaAnalysis
(
possibleSemiSyncReplicas
[]
*
Instance
,
asyncReplicas
[]
*
Instance
,
excludedReplicas
[]
*
Instance
,
actions
map
[
*
Instance
]
bool
,
logf
func
(
s
string
,
a
...
interface
{}))
{
logReplicas
(
"possible semi-sync replicas (in priority order)"
,
possibleSemiSyncReplicas
,
logf
)
logReplicas
(
"always-async replicas"
,
asyncReplicas
,
logf
)
logReplicas
(
"excluded replicas (defunct)"
,
excludedReplicas
,
logf
)
...
...
go/logic/topology_recovery.go
浏览文件 @
0792076b
...
...
@@ -1511,7 +1511,8 @@ func recoverSemiSyncReplicas(topologyRecovery *TopologyRecovery, analysisEntry i
logFn
:=
func
(
s
string
,
a
...
interface
{})
{
AuditTopologyRecovery
(
topologyRecovery
,
fmt
.
Sprintf
(
s
,
a
...
))
}
masterInstance
,
err
:=
inst
.
RecoverSemiSyncReplicas
(
&
analysisEntry
.
AnalyzedInstanceKey
,
nil
,
exactReplicaTopology
,
logFn
)
if
err
!=
nil
{
return
true
,
topologyRecovery
,
err
AuditTopologyRecovery
(
topologyRecovery
,
fmt
.
Sprintf
(
"semi-sync: %s"
,
err
.
Error
()))
return
true
,
topologyRecovery
,
log
.
Errorf
(
"semi-sync: %w"
,
err
)
}
// TODO even though we resolve correctly here, we are re-triggering the same analysis until the next polling interval. WHY?
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录