Skip to content
Snippets Groups Projects
Commit 384dbdf5 authored by Georgy Moshkin's avatar Georgy Moshkin :speech_balloon:
Browse files

fix: panic Storage::active_learners when peer was rebootstrapped

parent f963d99e
No related branches found
No related tags found
1 merge request!188fix: panic Storage::active_learners when peer was rebootstrapped
Pipeline #9161 passed
......@@ -7,6 +7,7 @@ use ::raft::INVALID_ID;
use ::tarantool::index::IteratorType;
use ::tarantool::space::Space;
use ::tarantool::tuple::Tuple;
use ::tarantool::unwrap_or;
use serde::de::DeserializeOwned;
use serde::Serialize;
use thiserror::Error;
......@@ -28,8 +29,6 @@ enum Error {
NoSuchSpace(String),
#[error("no such index \"{1}\" in space \"{0}\"")]
NoSuchIndex(String, String),
#[error("no peer with id {0}")]
NoSuchPeer(RaftId),
}
macro_rules! box_err {
......@@ -361,11 +360,7 @@ impl Storage {
let learners = Storage::learners()?;
let mut res = Vec::with_capacity(learners.len());
for raft_id in learners {
if Storage::peer_by_raft_id(raft_id)?
.ok_or(Error::NoSuchPeer(raft_id))
.map_err(box_err!())?
.is_active()
{
if unwrap_or!(Storage::peer_by_raft_id(raft_id)?, continue).is_active() {
res.push(raft_id)
}
}
......
......@@ -235,11 +235,11 @@ class Instance:
eprint(f"{self} killed")
self.process = None
def terminate(self, kill_after_seconds=10):
def terminate(self, kill_after_seconds=10) -> int | None:
"""Terminate the instance gracefully with SIGTERM"""
if self.process is None:
# Be idempotent
return
return None
with suppress(ProcessLookupError, PermissionError):
os.killpg(self.process.pid, signal.SIGCONT)
......@@ -247,8 +247,9 @@ class Instance:
self.process.terminate()
try:
self.process.wait(timeout=kill_after_seconds)
eprint(f"{self} terminated")
rc = self.process.wait(timeout=kill_after_seconds)
eprint(f"{self} terminated: rc = {rc}")
return rc
finally:
self.kill()
......
......@@ -237,6 +237,9 @@ def test_rebootstrap_follower(cluster3: Cluster):
i3.wait_ready()
i3.assert_raft_status("Follower")
# git.picodata.io: #114
assert i1.terminate() == 0
def test_join_without_explicit_instance_id(cluster: Cluster):
# Scenario: bootstrap single instance without explicitly given instance id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment