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
df4ea4ee
Commit
df4ea4ee
authored
11 months ago
by
Kurdakov Alexander
Committed by
Alexander Kurdakov
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: check for tier existence while joining
parent
a2143d90
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!959
fix proc_join, check tier explicitly
Pipeline
#38260
passed
11 months ago
Stage: test
Stage: stress-test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/instance.rs
+8
-1
8 additions, 1 deletion
src/instance.rs
src/rpc/join.rs
+16
-13
16 additions, 13 deletions
src/rpc/join.rs
with
24 additions
and
14 deletions
src/instance.rs
+
8
−
1
View file @
df4ea4ee
...
...
@@ -627,7 +627,14 @@ mod tests {
assert_eq!
(
build_instance
(
None
,
None
,
&
faildoms!
{
planet
:
5
},
&
storage
,
"noexistent_tier"
)
.unwrap_err
(),
"tier
\"
noexistent_tier
\"
for current instance should exists"
,
r#"tier "noexistent_tier" doesn't exist"#
,
);
// gl589
assert_eq!
(
build_instance
(
None
,
Some
(
&
ReplicasetId
::
from
(
"just to skip choose_replicaset function call"
)),
&
faildoms!
{
planet
:
5
},
&
storage
,
"noexistent_tier"
)
.unwrap_err
(),
r#"tier "noexistent_tier" doesn't exist"#
,
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/rpc/join.rs
+
16
−
13
View file @
df4ea4ee
...
...
@@ -12,6 +12,7 @@ use crate::replicaset::ReplicasetId;
use
crate
::
schema
::
ADMIN_ID
;
use
crate
::
storage
::
ClusterwideTable
;
use
crate
::
storage
::{
Clusterwide
,
ToEntryIter
as
_
};
use
crate
::
tier
::
Tier
;
use
crate
::
traft
::
op
::{
Dml
,
Op
};
use
crate
::
traft
::{
self
,
RaftId
};
use
crate
::
traft
::{
error
::
Error
,
node
,
Address
,
PeerAddress
,
Result
};
...
...
@@ -185,6 +186,13 @@ pub fn build_instance(
return
Err
(
e
);
}
}
let
Some
(
tier
)
=
storage
.tiers
.by_name
(
tier
)
.expect
(
"storage should not fail"
)
else
{
return
Err
(
format!
(
r#"tier "{}" doesn't exist"#
,
tier
));
};
let
existing_fds
=
storage
.instances
...
...
@@ -203,7 +211,7 @@ pub fn build_instance(
.unwrap_or_else
(||
choose_instance_id
(
raft_id
,
storage
));
let
replicaset_id
=
match
replicaset_id
{
Some
(
replicaset_id
)
=>
replicaset_id
.clone
(),
None
=>
choose_replicaset_id
(
failure_domain
,
storage
,
tier
)
?
,
None
=>
choose_replicaset_id
(
failure_domain
,
storage
,
&
tier
)
?
,
};
let
instance
=
Instance
::
new
(
...
...
@@ -213,7 +221,7 @@ pub fn build_instance(
Grade
::
new
(
Offline
,
0
),
Grade
::
new
(
Offline
,
0
),
failure_domain
.clone
(),
tier
,
&
tier
.name
,
);
Ok
(
instance
)
...
...
@@ -246,20 +254,15 @@ fn choose_instance_id(raft_id: RaftId, storage: &Clusterwide) -> InstanceId {
fn
choose_replicaset_id
(
failure_domain
:
&
FailureDomain
,
storage
:
&
Clusterwide
,
tier
:
&
str
,
Tier
{
replication_factor
,
name
:
tier_name
,
}:
&
Tier
,
)
->
core
::
result
::
Result
<
ReplicasetId
,
String
>
{
let
replication_factor
=
storage
.tiers
.by_name
(
tier
)
.expect
(
"storage should not fail"
)
.ok_or
(
format!
(
"tier
\"
{tier}
\"
for current instance should exists"
))
?
.replication_factor
.into
();
// `BTreeMap` is used so that we get a determenistic order of instance addition to replicasets.
// E.g. if both "r1" and "r2" are suitable, "r1" will always be prefered.
let
mut
replicasets
:
BTreeMap
<
_
,
Vec
<
_
>>
=
BTreeMap
::
new
();
let
replication_factor
=
(
*
replication_factor
)
.into
();
for
instance
in
storage
.instances
.all_instances
()
...
...
@@ -277,7 +280,7 @@ fn choose_replicaset_id(
.first
()
.expect
(
"should not fail, each replicaset consists of at least one instance"
)
.tier
==
tier
==
*
tier
_name
{
for
instance
in
instances
{
if
instance
.failure_domain
.intersects
(
failure_domain
)
{
...
...
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