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
c16fabf1
Commit
c16fabf1
authored
1 year ago
by
Georgy Moshkin
Browse files
Options
Downloads
Patches
Plain Diff
fix: exponential decay when retrying self activation attempts
parent
9e507671
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!700
fix: exponential decay when retrying self activation attempts
Pipeline
#25602
passed
1 year ago
Stage: test
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib.rs
+22
-8
22 additions, 8 deletions
src/lib.rs
with
22 additions
and
8 deletions
src/lib.rs
+
22
−
8
View file @
c16fabf1
...
...
@@ -7,11 +7,12 @@ use ::raft::prelude as raft;
use
::
tarantool
::
error
::
Error
as
TntError
;
use
::
tarantool
::
fiber
;
use
::
tarantool
::
fiber
::
r
#
async
::
timeout
::{
self
,
IntoTimeout
};
use
::
tarantool
::
time
::
Instant
;
use
::
tarantool
::
tlua
;
use
::
tarantool
::
transaction
::
transaction
;
use
rpc
::{
join
,
update_instance
};
use
std
::
convert
::
TryFrom
;
use
std
::
time
::
{
Duration
,
Instant
}
;
use
std
::
time
::
Duration
;
use
storage
::
tweak_max_space_id
;
use
storage
::
Clusterwide
;
use
storage
::{
ClusterwideSpace
,
PropertyName
};
...
...
@@ -693,6 +694,13 @@ fn postjoin(args: &args::Run, storage: Clusterwide, raft_storage: RaftSpaceAcces
tlog!
(
Error
,
"failed setting on_shutdown trigger: {e}"
);
}
// We will shut down, if we don't receive a confirmation of target grade
// change from leader before this time.
let
activation_deadline
=
Instant
::
now
()
.saturating_add
(
Duration
::
from_secs
(
10
));
// This will be doubled on each retry.
let
mut
retry_timeout
=
Duration
::
from_millis
(
250
);
// Activates instance
loop
{
let
instance
=
storage
...
...
@@ -707,7 +715,7 @@ fn postjoin(args: &args::Run, storage: Clusterwide, raft_storage: RaftSpaceAcces
let
leader_address
=
leader_id
.and_then
(|
id
|
storage
.peer_addresses
.try_get
(
id
)
.ok
());
let
Some
(
leader_address
)
=
leader_address
else
{
// FIXME: don't hard code timeout
let
timeout
=
Duration
::
from_millis
(
100
0
);
let
timeout
=
Duration
::
from_millis
(
25
0
);
tlog!
(
Debug
,
"leader address is still unkown, retrying in {timeout:?}"
...
...
@@ -725,19 +733,25 @@ fn postjoin(args: &args::Run, storage: Clusterwide, raft_storage: RaftSpaceAcces
.with_target_grade
(
TargetGradeVariant
::
Online
)
.with_failure_domain
(
args
.failure_domain
());
let
now
=
Instant
::
now
();
let
timeout
=
Duration
::
from_secs
(
10
);
match
fiber
::
block_on
(
rpc
::
network_call
(
&
leader_address
,
&
req
)
.timeout
(
timeo
ut
)
)
{
let
fut
=
rpc
::
network_call
(
&
leader_address
,
&
req
)
.timeout
(
activation_deadline
-
now
);
match
fiber
::
block_on
(
f
ut
)
{
Ok
(
update_instance
::
Response
{})
=>
{
break
;
}
Err
(
timeout
::
Error
::
Failed
(
TntError
::
Tcp
(
e
)))
=>
{
tlog!
(
Warning
,
"failed to activate myself: {e}, retrying..."
);
fiber
::
sleep
(
timeout
.saturating_sub
(
now
.elapsed
()));
let
timeout
=
retry_timeout
.saturating_sub
(
now
.elapsed
());
retry_timeout
*=
2
;
#[rustfmt::skip]
tlog!
(
Warning
,
"failed to activate myself: {e}, retrying in {timeout:.02?}..."
);
fiber
::
sleep
(
timeout
);
continue
;
}
Err
(
timeout
::
Error
::
Failed
(
TntError
::
IO
(
e
)))
=>
{
tlog!
(
Warning
,
"failed to activate myself: {e}, retrying..."
);
fiber
::
sleep
(
timeout
.saturating_sub
(
now
.elapsed
()));
let
timeout
=
retry_timeout
.saturating_sub
(
now
.elapsed
());
retry_timeout
*=
2
;
#[rustfmt::skip]
tlog!
(
Warning
,
"failed to activate myself: {e}, retrying in {timeout:.02?}..."
);
fiber
::
sleep
(
timeout
);
continue
;
}
Err
(
e
)
=>
{
...
...
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