Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
picodata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
picodata
Commits
71cb0388
Commit
71cb0388
authored
2 years ago
by
Georgy Moshkin
Committed by
Georgy Moshkin
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor: simplify checking joint state
parent
20f78220
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!219
Resolve "Graceful shutdown times out quite often"
Pipeline
#10921
canceled
2 years ago
Stage: build
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/traft/node.rs
+6
-11
6 additions, 11 deletions
src/traft/node.rs
with
6 additions
and
11 deletions
src/traft/node.rs
+
6
−
11
View file @
71cb0388
...
...
@@ -532,14 +532,14 @@ fn handle_committed_conf_change(entry: traft::Entry, raw_node: &mut RawNode) {
// `ConfChangeTransition::Auto` implies that `ConfChangeV2` may be
// applied in an instant without entering the joint state.
let
conf_state
=
match
entry
.entry_type
{
let
(
is_joint
,
conf_state
)
=
match
entry
.entry_type
{
raft
::
EntryType
::
EntryConfChange
=>
{
let
mut
cc
=
raft
::
ConfChange
::
default
();
cc
.merge_from_bytes
(
&
entry
.data
)
.unwrap
();
latch_unlock
();
raw_node
.apply_conf_change
(
&
cc
)
.unwrap
()
(
false
,
raw_node
.apply_conf_change
(
&
cc
)
.unwrap
()
)
}
raft
::
EntryType
::
EntryConfChangeV2
=>
{
let
mut
cc
=
raft
::
ConfChangeV2
::
default
();
...
...
@@ -548,14 +548,15 @@ fn handle_committed_conf_change(entry: traft::Entry, raw_node: &mut RawNode) {
// Unlock the latch when either of conditions is met:
// - conf_change will leave the joint state;
// - or it will be applied without even entering one.
if
cc
.leave_joint
()
||
cc
.enter_joint
()
.is_none
()
{
let
leave_joint
=
cc
.leave_joint
()
||
cc
.enter_joint
()
.is_none
();
if
leave_joint
{
latch_unlock
();
}
// ConfChangeTransition::Auto implies that at this
// moment raft-rs will implicitly propose another empty
// conf change that represents leaving the joint state.
raw_node
.apply_conf_change
(
&
cc
)
.unwrap
()
(
!
leave_joint
,
raw_node
.apply_conf_change
(
&
cc
)
.unwrap
()
)
}
_
=>
unreachable!
(),
};
...
...
@@ -563,13 +564,7 @@ fn handle_committed_conf_change(entry: traft::Entry, raw_node: &mut RawNode) {
let
raft_id
=
&
raw_node
.raft.id
;
let
voters_old
=
Storage
::
voters
()
.unwrap
();
if
voters_old
.contains
(
raft_id
)
&&
!
conf_state
.voters
.contains
(
raft_id
)
{
#[rustfmt::skip]
let
is_joint_state
=
with_joint_state_latch
(|
latch
|
{
// joint_state_latch is stored in `Cell` so to check it's value
// we must take it out and put it back in
latch
.take
()
.map
(|
l
|
{
latch
.set
(
Some
(
l
));
true
})
.unwrap_or
(
false
)
});
if
is_joint_state
{
if
is_joint
{
event
::
broadcast_when
(
Event
::
Demoted
,
Event
::
LeaveJointState
)
.ok
();
}
else
{
event
::
broadcast
(
Event
::
Demoted
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment