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
cd0cb4e0
Commit
cd0cb4e0
authored
6 months ago
by
Georgy Moshkin
Committed by
Yaroslav Dynnikov
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: retry "not a leader" errors when self-activating on startup
parent
f99647f1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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/lib.rs
+16
-13
16 additions, 13 deletions
src/lib.rs
with
16 additions
and
13 deletions
src/lib.rs
+
16
−
13
View file @
cd0cb4e0
...
...
@@ -16,6 +16,7 @@ use std::path::Path;
use
::
raft
::
prelude
as
raft
;
use
::
tarantool
::
error
::
Error
as
TntError
;
use
::
tarantool
::
error
::
IntoBoxError
;
use
::
tarantool
::
fiber
::
r
#
async
::
timeout
::{
self
,
IntoTimeout
};
use
::
tarantool
::
time
::
Instant
;
use
::
tarantool
::
tlua
;
...
...
@@ -28,6 +29,7 @@ use traft::RaftSpaceAccess;
use
crate
::
access_control
::
user_by_id
;
use
crate
::
address
::
HttpAddress
;
use
crate
::
error_code
::
ErrorCode
;
use
crate
::
instance
::
Instance
;
use
crate
::
instance
::
State
;
use
crate
::
instance
::
StateVariant
::
*
;
...
...
@@ -979,8 +981,9 @@ fn postjoin(
// change from leader before this time.
let
activation_deadline
=
Instant
::
now_fiber
()
.saturating_add
(
Duration
::
from_secs
(
10
));
// This will be doubled on each retry.
// This will be doubled on each retry
, until max_retry_timeout is reached
.
let
mut
retry_timeout
=
Duration
::
from_millis
(
250
);
let
max_retry_timeout
=
Duration
::
from_secs
(
5
);
// Activates instance
loop
{
...
...
@@ -1035,25 +1038,19 @@ fn postjoin(
&
req
,
)
.timeout
(
activation_deadline
-
now
);
let
error_message
;
match
fiber
::
block_on
(
fut
)
{
Ok
(
rpc
::
update_instance
::
Response
{})
=>
{
break
;
}
Err
(
timeout
::
Error
::
Failed
(
TntError
::
Tcp
(
e
)))
=>
{
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
;
error_message
=
e
.to_string
();
}
Err
(
timeout
::
Error
::
Failed
(
TntError
::
IO
(
e
)))
=>
{
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
;
error_message
=
e
.to_string
();
}
Err
(
timeout
::
Error
::
Failed
(
e
))
if
e
.error_code
()
==
ErrorCode
::
NotALeader
as
u32
=>
{
error_message
=
e
.to_string
();
}
Err
(
e
)
=>
{
return
Err
(
Error
::
other
(
format!
(
...
...
@@ -1061,6 +1058,12 @@ fn postjoin(
)));
}
}
let
timeout
=
retry_timeout
.saturating_sub
(
now
.elapsed
());
retry_timeout
=
max_retry_timeout
.max
(
retry_timeout
*
2
);
#[rustfmt::skip]
tlog!
(
Warning
,
"failed to activate myself: {error_message}, retrying in {timeout:.02?}..."
);
fiber
::
sleep
(
timeout
);
}
// Wait for target state to change to Online, so that sentinel doesn't send
...
...
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