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
b348a5b1
Commit
b348a5b1
authored
1 year ago
by
Yaroslav Dynnikov
Browse files
Options
Downloads
Patches
Plain Diff
draft: refactor applying snapshot
parent
32a176af
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!643
refactor applying snapshot
Pipeline
#22366
passed
1 year ago
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/traft/node.rs
+27
-32
27 additions, 32 deletions
src/traft/node.rs
with
27 additions
and
32 deletions
src/traft/node.rs
+
27
−
32
View file @
b348a5b1
...
@@ -1229,42 +1229,26 @@ impl NodeImpl {
...
@@ -1229,42 +1229,26 @@ impl NodeImpl {
}
}
);
);
let
v_local
=
local_schema_version
()
.expect
(
"storage souldn't fail"
);
let
v_global
=
self
.storage
.properties
.global_schema_version
()
.expect
(
"storage shouldn't fail"
);
let
v_snapshot
=
snapshot_data
.schema_version
;
let
v_snapshot
=
snapshot_data
.schema_version
;
assert!
(
loop
{
v_global
<=
v_local
,
let
v_local
=
local_schema_version
()
.expect
(
"storage souldn't fail"
);
"global schema version is only ever increased after local"
let
v_global
=
self
);
.storage
assert!
(
.properties
v_global
<=
v_snapshot
,
.global_schema_version
()
"global schema version updates are distributed via raft"
.expect
(
"storage shouldn't fail"
);
);
if
v_local
>
v_snapshot
{
assert!
(
tlog!
(
v_global
<=
v_local
,
Warning
,
"global schema version is only ever increased after local"
"skipping stale snapshot: local schema version: {}, snapshot schema version: {}"
,
v_local
,
snapshot_data
.schema_version
,
);
);
return
None
;
}
loop
{
assert!
(
if
!
self
.is_readonly
()
{
v_global
<=
v_snapshot
,
break
;
"global schema version updates are distributed via raft"
}
);
let
v_local
=
local_schema_version
()
.expect
(
"storage error"
);
if
v_local
==
v_snapshot
{
break
;
}
if
v_local
>
v_snapshot
{
if
v_local
>
v_snapshot
{
tlog!
(
tlog!
(
Warning
,
Warning
,
...
@@ -1275,11 +1259,22 @@ impl NodeImpl {
...
@@ -1275,11 +1259,22 @@ impl NodeImpl {
return
None
;
return
None
;
}
}
if
!
self
.is_readonly
()
{
// Replicaset leader applies the schema changes directly.
return
Some
(
snapshot_data
);
}
if
v_local
==
v_snapshot
{
// Replicaset follower has synced schema with the leader,
// now global space dumps should be handled.
return
Some
(
snapshot_data
);
}
// Replicaset follower needs to sync with leader via tarantool
// replication.
let
timeout
=
MainLoop
::
TICK
*
4
;
let
timeout
=
MainLoop
::
TICK
*
4
;
fiber
::
sleep
(
timeout
);
fiber
::
sleep
(
timeout
);
}
}
Some
(
snapshot_data
)
})();
})();
if
let
Some
(
snapshot_data
)
=
snapshot_data
{
if
let
Some
(
snapshot_data
)
=
snapshot_data
{
...
...
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