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
76411865
Commit
76411865
authored
7 months ago
by
Georgy Moshkin
Committed by
Yaroslav Dynnikov
7 months ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: add instance id to cas predicate when changing replicaset's target master
Strictness!
parent
2008255a
No related branches found
No related tags found
1 merge request
!1270
follow-ups for compare-and-swap in governor
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/governor/plan.rs
+11
-7
11 additions, 7 deletions
src/governor/plan.rs
with
11 additions
and
7 deletions
src/governor/plan.rs
+
11
−
7
View file @
76411865
...
...
@@ -107,7 +107,8 @@ pub(super) fn action_plan<'i>(
////////////////////////////////////////////////////////////////////////////
// update target replicaset master
let
new_target_master
=
get_new_replicaset_master_if_needed
(
instances
,
replicasets
);
if
let
Some
(
to
)
=
new_target_master
{
if
let
Some
((
to
,
replicaset
))
=
new_target_master
{
debug_assert_eq!
(
to
.replicaset_id
,
replicaset
.replicaset_id
);
let
mut
ops
=
UpdateOps
::
new
();
ops
.assign
(
column_name!
(
Replicaset
,
target_master_id
),
&
to
.instance_id
)
?
;
let
dml
=
Dml
::
update
(
...
...
@@ -116,8 +117,11 @@ pub(super) fn action_plan<'i>(
ops
,
ADMIN_ID
,
)
?
;
// TODO: add range for Instance current & target master
let
ranges
=
vec!
[
cas
::
Range
::
for_dml
(
&
dml
)
?
];
let
ranges
=
vec!
[
cas
::
Range
::
for_dml
(
&
dml
)
?
,
cas
::
Range
::
new
(
ClusterwideTable
::
Instance
)
.eq
([
&
to
.instance_id
]),
cas
::
Range
::
new
(
ClusterwideTable
::
Instance
)
.eq
([
&
replicaset
.target_master_id
]),
];
let
predicate
=
cas
::
Predicate
::
new
(
applied
,
ranges
);
let
cas
=
cas
::
Request
::
new
(
dml
,
predicate
,
ADMIN_ID
)
?
;
return
Ok
(
UpdateTargetReplicasetMaster
{
cas
}
.into
());
...
...
@@ -903,10 +907,10 @@ pub mod stage {
#[inline(always)]
fn
get_new_replicaset_master_if_needed
<
'i
>
(
instances
:
&
'i
[
Instance
],
replicasets
:
&
HashMap
<&
ReplicasetId
,
&
Replicaset
>
,
)
->
Option
<&
'i
Instance
>
{
replicasets
:
&
HashMap
<&
ReplicasetId
,
&
'i
Replicaset
>
,
)
->
Option
<
(
&
'i
Instance
,
&
'i
Replicaset
)
>
{
// TODO: construct a map from replicaset id to instance to improve performance
for
r
in
replicasets
.values
()
{
for
&
r
in
replicasets
.values
()
{
#[rustfmt::skip]
let
Some
(
master
)
=
instances
.iter
()
.find
(|
i
|
i
.instance_id
==
r
.target_master_id
)
else
{
#[rustfmt::skip]
...
...
@@ -935,7 +939,7 @@ fn get_new_replicaset_master_if_needed<'i>(
continue
;
};
return
Some
(
new_master
);
return
Some
(
(
new_master
,
r
)
);
}
None
...
...
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