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
93309ba7
Commit
93309ba7
authored
2 years ago
by
Georgy Moshkin
Browse files
Options
Downloads
Patches
Plain Diff
refactor(network): remove ConnectionPool::call_and_wait[_timeout]
parent
11b8766a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!424
refactor(network): async fn ConnectionPool::call
Pipeline
#14263
passed
2 years ago
Stage: test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/governor/mod.rs
+43
-36
43 additions, 36 deletions
src/governor/mod.rs
src/traft/network.rs
+0
-37
0 additions, 37 deletions
src/traft/network.rs
with
43 additions
and
73 deletions
src/governor/mod.rs
+
43
−
36
View file @
93309ba7
...
...
@@ -217,7 +217,7 @@ impl Loop {
return
Continue
;
}
let
res
=
(||
->
Result
<
_
>
{
let
res
:
Result
<
_
>
=
async
{
// Promote the replication leader again
// because of tarantool bugs
if
let
Some
(
replicaset
)
=
storage
.replicasets
.get
(
replicaset_id
)
?
{
...
...
@@ -226,19 +226,21 @@ impl Loop {
"instance_id"
=>
%
replicaset
.master_id
);
let
commit
=
raft_storage
.commit
()
?
.unwrap
();
pool
.call
_and_wait_timeout
(
pool
.call
(
&
replicaset
.master_id
,
&
replication
::
promote
::
Request
{
term
,
commit
,
timeout
:
Self
::
SYNC_TIMEOUT
,
},
// TODO: don't hard code timeout
Duration
::
from_secs
(
3
),
)
?
;
)
?
// TODO: don't hard code timeout
.timeout
(
Duration
::
from_secs
(
3
))
.await
??
;
}
Ok
(())
})();
}
.await
;
if
let
Err
(
e
)
=
res
{
tlog!
(
Warning
,
"failed calling rpc::replication::promote: {e}"
;
...
...
@@ -332,8 +334,10 @@ impl Loop {
timeout
:
Self
::
SYNC_TIMEOUT
,
};
let
replication
::
promote
::
Response
{}
=
pool
.call
(
instance_id
,
&
req
)
?
// TODO: don't hard code the timeout
.call_and_wait_timeout
(
instance_id
,
&
req
,
Duration
::
from_secs
(
3
))
?
;
.timeout
(
Duration
::
from_secs
(
3
))
.await
??
;
Ok
(())
}
.await
;
...
...
@@ -613,35 +617,38 @@ impl Loop {
timeout
:
Self
::
SYNC_TIMEOUT
,
migration_id
:
migration
.id
,
};
let
res
=
pool
.call_and_wait
(
&
instance
.raft_id
,
&
req
);
match
res
{
Ok
(
_
)
=>
{
let
mut
ops
=
UpdateOps
::
new
();
ops
.assign
(
"current_schema_version"
,
migration
.id
)
.unwrap
();
let
op
=
OpDML
::
update
(
ClusterwideSpace
::
Replicaset
,
&
[
replicaset
.replicaset_id
.clone
()],
ops
,
)
.unwrap
();
node
.propose_and_wait
(
op
,
Duration
::
MAX
)
.unwrap
()
.unwrap
();
tlog!
(
Info
,
"Migration {0} applied to replicaset {1}"
,
migration
.id
,
replicaset
.replicaset_id
);
}
Err
(
e
)
=>
{
tlog!
(
Warning
,
"Could not apply migration {0} to replicaset {1}, error: {2}"
,
migration
.id
,
replicaset
.replicaset_id
,
e
);
return
Continue
;
}
let
res
:
Result
<
_
>
=
async
{
let
rpc
::
migration
::
apply
::
Response
{}
=
pool
.call
(
&
instance
.raft_id
,
&
req
)
?
// TODO: don't hard code timeout
.timeout
(
Duration
::
from_secs
(
3
))
.await
??
;
let
mut
ops
=
UpdateOps
::
new
();
ops
.assign
(
"current_schema_version"
,
migration
.id
)
?
;
let
op
=
OpDML
::
update
(
ClusterwideSpace
::
Replicaset
,
&
[
replicaset
.replicaset_id
.clone
()],
ops
,
)
?
;
node
.propose_and_wait
(
op
,
Duration
::
MAX
)
??
;
tlog!
(
Info
,
"Migration {0} applied to replicaset {1}"
,
migration
.id
,
replicaset
.replicaset_id
);
Ok
(())
}
.await
;
if
let
Err
(
e
)
=
res
{
tlog!
(
Warning
,
"Could not apply migration {0} to replicaset {1}, error: {2}"
,
migration
.id
,
replicaset
.replicaset_id
,
e
);
return
Continue
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/traft/network.rs
+
0
−
37
View file @
93309ba7
...
...
@@ -464,43 +464,6 @@ impl ConnectionPool {
self
.get_or_create_by_raft_id
(
msg
.to
)
?
.send
(
msg
)
}
/// Send a request to instance with `id` (see `IdOfInstance`) and wait for the result.
///
/// If the request failed, it's a responsibility of the caller
/// to re-send it later.
///
/// **This function yields.**
#[allow(dead_code)]
pub
fn
call_and_wait_timeout
<
R
>
(
&
mut
self
,
id
:
&
impl
IdOfInstance
,
req
:
&
R
,
timeout
:
Duration
,
)
->
Result
<
R
::
Response
>
where
R
:
Request
,
{
let
(
rx
,
tx
)
=
fiber
::
Channel
::
new
(
1
)
.into_clones
();
id
.get_or_create_in
(
self
)
?
.rpc
(
req
,
move
|
res
|
tx
.send
(
res
)
.unwrap
());
rx
.recv_timeout
(
timeout
)
.map_err
(|
_
|
Error
::
Timeout
)
?
}
/// Send a request to instance with `id` (see `InstanceId`) and wait for the result.
///
/// If the request failed, it's a responsibility of the caller
/// to re-send it later.
///
/// **This function yields.**
#[allow(dead_code)]
#[inline(always)]
pub
fn
call_and_wait
<
R
>
(
&
mut
self
,
id
:
&
impl
IdOfInstance
,
req
:
&
R
)
->
Result
<
R
::
Response
>
where
R
:
Request
,
{
self
.call_and_wait_timeout
(
id
,
req
,
Duration
::
MAX
)
}
/// Send a request to instance with `id` (see `IdOfInstance`) returning a
/// future.
///
...
...
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