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
298d5d40
Commit
298d5d40
authored
2 years ago
by
Georgy Moshkin
Committed by
Yaroslav Dynnikov
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: used to panic during shut down when leader id is None
parent
3066a6b6
No related branches found
No related tags found
1 merge request
!205
Fix/panic in on shutdown
Pipeline
#9999
passed
2 years ago
Stage: build
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main.rs
+4
-4
4 additions, 4 deletions
src/main.rs
src/traft/failover.rs
+6
-2
6 additions, 2 deletions
src/traft/failover.rs
test/int/test_couple.py
+18
-0
18 additions, 0 deletions
test/int/test_couple.py
with
28 additions
and
6 deletions
src/main.rs
+
4
−
4
View file @
298d5d40
...
@@ -720,10 +720,6 @@ fn postjoin(args: &args::Run) {
...
@@ -720,10 +720,6 @@ fn postjoin(args: &args::Run) {
box_cfg
.listen
=
Some
(
args
.listen
.clone
());
box_cfg
.listen
=
Some
(
args
.listen
.clone
());
tarantool
::
set_cfg
(
&
box_cfg
);
tarantool
::
set_cfg
(
&
box_cfg
);
if
let
Err
(
e
)
=
tarantool
::
on_shutdown
(
traft
::
failover
::
on_shutdown
)
{
tlog!
(
Error
,
"failed setting on_shutdown trigger: {e}"
);
}
tlog!
(
Debug
,
"Getting a read barrier..."
);
tlog!
(
Debug
,
"Getting a read barrier..."
);
loop
{
loop
{
if
node
.status
()
.leader_id
==
None
{
if
node
.status
()
.leader_id
==
None
{
...
@@ -746,6 +742,10 @@ fn postjoin(args: &args::Run) {
...
@@ -746,6 +742,10 @@ fn postjoin(args: &args::Run) {
}
}
tlog!
(
Info
,
"Read barrier aquired, raft is ready"
);
tlog!
(
Info
,
"Read barrier aquired, raft is ready"
);
if
let
Err
(
e
)
=
tarantool
::
on_shutdown
(
traft
::
failover
::
on_shutdown
)
{
tlog!
(
Error
,
"failed setting on_shutdown trigger: {e}"
);
}
let
peer
=
traft
::
Storage
::
peer_by_raft_id
(
raft_id
)
.unwrap
()
.unwrap
();
let
peer
=
traft
::
Storage
::
peer_by_raft_id
(
raft_id
)
.unwrap
()
.unwrap
();
box_cfg
.replication
=
traft
::
Storage
::
box_replication
(
&
peer
.replicaset_id
,
None
)
.unwrap
();
box_cfg
.replication
=
traft
::
Storage
::
box_replication
(
&
peer
.replicaset_id
,
None
)
.unwrap
();
tarantool
::
set_cfg
(
&
box_cfg
);
tarantool
::
set_cfg
(
&
box_cfg
);
...
...
This diff is collapsed.
Click to expand it.
src/traft/failover.rs
+
6
−
2
View file @
298d5d40
...
@@ -2,6 +2,7 @@ use std::time::{Duration, Instant};
...
@@ -2,6 +2,7 @@ use std::time::{Duration, Instant};
use
::
tarantool
::
fiber
::
sleep
;
use
::
tarantool
::
fiber
::
sleep
;
use
::
tarantool
::
proc
;
use
::
tarantool
::
proc
;
use
::
tarantool
::
unwrap_or
;
use
crate
::{
stringify_cfunc
,
tarantool
,
tlog
};
use
crate
::{
stringify_cfunc
,
tarantool
,
tlog
};
...
@@ -33,8 +34,11 @@ pub fn on_shutdown() {
...
@@ -33,8 +34,11 @@ pub fn on_shutdown() {
// will run until we get successfully deactivate or tarantool shuts down
// will run until we get successfully deactivate or tarantool shuts down
// the on_shutdown fiber (after 3 secs)
// the on_shutdown fiber (after 3 secs)
loop
{
loop
{
let
status
=
node
::
global
()
.unwrap
()
.status
();
let
node
=
node
::
global
()
.unwrap
();
let
leader_id
=
status
.leader_id
.expect
(
"leader_id deinitialized"
);
let
leader_id
=
unwrap_or!
(
node
.status
()
.leader_id
,
{
node
.wait_status
();
continue
;
});
let
leader
=
Storage
::
peer_by_raft_id
(
leader_id
)
.unwrap
()
.unwrap
();
let
leader
=
Storage
::
peer_by_raft_id
(
leader_id
)
.unwrap
()
.unwrap
();
let
wait_before_retry
=
Duration
::
from_millis
(
300
);
let
wait_before_retry
=
Duration
::
from_millis
(
300
);
let
now
=
Instant
::
now
();
let
now
=
Instant
::
now
();
...
...
This diff is collapsed.
Click to expand it.
test/int/test_couple.py
+
18
−
0
View file @
298d5d40
import
funcy
# type: ignore
import
funcy
# type: ignore
import
pytest
import
pytest
from
conftest
import
Cluster
,
Instance
from
conftest
import
Cluster
,
Instance
from
time
import
sleep
@funcy.retry
(
tries
=
20
,
timeout
=
0.1
)
@funcy.retry
(
tries
=
20
,
timeout
=
0.1
)
...
@@ -179,3 +180,20 @@ def test_deactivation(cluster2: Cluster):
...
@@ -179,3 +180,20 @@ def test_deactivation(cluster2: Cluster):
assert
raft_update_peer
(
i2
,
target
=
i2
,
is_active
=
True
)
==
[{}]
assert
raft_update_peer
(
i2
,
target
=
i2
,
is_active
=
True
)
==
[{}]
assert
raft_update_peer
(
i2
,
target
=
i2
,
is_active
=
True
)
==
[{}]
assert
raft_update_peer
(
i2
,
target
=
i2
,
is_active
=
True
)
==
[{}]
def
test_gl119_panic_in_on_shutdown
(
cluster2
:
Cluster
):
i1
,
i2
=
cluster2
.
instances
i2
.
call
(
"
picolib.raft_timeout_now
"
,
timeout
=
0.01
)
assert
i2
.
terminate
()
==
0
# second instance terminates first, so it becomes a follower
i2
.
terminate
()
# terminate the leader, so the follower can't acquire the read barrier
i1
.
terminate
()
i2
.
start
()
# wait for the follower to start acquiring the read barrier
sleep
(
1
)
assert
i2
.
terminate
()
==
0
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