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
5c7367c5
Commit
5c7367c5
authored
1 year ago
by
Georgy Moshkin
Committed by
Yaroslav Dynnikov
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: used to panic if master changed during application of snapshot
parent
127c60d2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!624
Feat/self-healing
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/storage.rs
+34
-6
34 additions, 6 deletions
src/storage.rs
test/int/test_acl.py
+1
-1
1 addition, 1 deletion
test/int/test_acl.py
with
35 additions
and
7 deletions
src/storage.rs
+
34
−
6
View file @
5c7367c5
...
@@ -644,13 +644,20 @@ impl Clusterwide {
...
@@ -644,13 +644,20 @@ impl Clusterwide {
// If we're not the replication master, the rest of the data will come
// If we're not the replication master, the rest of the data will come
// via tarantool replication.
// via tarantool replication.
if
is_master
{
//
// v_local == v_snapshot could happen for example in case of an
// unfortunately timed replication master failover, in which case the
// schema portion of the snapshot was already applied and we should skip
// it here.
let
v_local
=
local_schema_version
()
?
;
let
v_snapshot
=
data
.schema_version
;
if
is_master
&&
v_local
<
v_snapshot
{
self
.apply_schema_changes_on_master
(
self
.spaces
.iter
()
?
,
&
old_space_versions
)
?
;
self
.apply_schema_changes_on_master
(
self
.spaces
.iter
()
?
,
&
old_space_versions
)
?
;
// TODO: secondary indexes
// TODO: secondary indexes
self
.apply_schema_changes_on_master
(
self
.users
.iter
()
?
,
&
old_user_versions
)
?
;
self
.apply_schema_changes_on_master
(
self
.users
.iter
()
?
,
&
old_user_versions
)
?
;
self
.apply_schema_changes_on_master
(
self
.roles
.iter
()
?
,
&
old_role_versions
)
?
;
self
.apply_schema_changes_on_master
(
self
.roles
.iter
()
?
,
&
old_role_versions
)
?
;
self
.apply_schema_changes_on_master
(
self
.privileges
.iter
()
?
,
&
old_priv_versions
)
?
;
self
.apply_schema_changes_on_master
(
self
.privileges
.iter
()
?
,
&
old_priv_versions
)
?
;
set_local_schema_version
(
data
.schema_version
)
?
;
set_local_schema_version
(
v_snapshot
)
?
;
}
}
for
space_dump
in
&
data
.space_dumps
{
for
space_dump
in
&
data
.space_dumps
{
...
@@ -718,7 +725,14 @@ impl Clusterwide {
...
@@ -718,7 +725,14 @@ impl Clusterwide {
}
}
// Schema definition was dropped.
// Schema definition was dropped.
T
::
on_delete
(
old_key
,
self
)
?
;
if
let
Err
(
e
)
=
T
::
on_delete
(
old_key
,
self
)
{
tlog!
(
Error
,
"failed handling delete of {} with key {old_key:?}: {e}"
,
std
::
any
::
type_name
::
<
T
>
(),
);
return
Err
(
e
);
}
}
}
// Now create any new schema entities, or replace ones that changed.
// Now create any new schema entities, or replace ones that changed.
...
@@ -734,7 +748,14 @@ impl Clusterwide {
...
@@ -734,7 +748,14 @@ impl Clusterwide {
}
}
// Schema entity changed, need to drop it an recreate.
// Schema entity changed, need to drop it an recreate.
T
::
on_delete
(
&
key
,
self
)
?
;
if
let
Err
(
e
)
=
T
::
on_delete
(
&
key
,
self
)
{
tlog!
(
Error
,
"failed handling delete of {} with key {key:?}: {e}"
,
std
::
any
::
type_name
::
<
T
>
(),
);
return
Err
(
e
);
}
}
else
{
}
else
{
// New schema entity.
// New schema entity.
}
}
...
@@ -746,7 +767,14 @@ impl Clusterwide {
...
@@ -746,7 +767,14 @@ impl Clusterwide {
continue
;
continue
;
}
}
T
::
on_insert
(
def
,
self
)
?
;
if
let
Err
(
e
)
=
T
::
on_insert
(
def
,
self
)
{
tlog!
(
Error
,
"failed handling insert of {} with key {key:?}: {e}"
,
std
::
any
::
type_name
::
<
T
>
(),
);
return
Err
(
e
);
}
}
}
Ok
(())
Ok
(())
...
@@ -2280,7 +2308,7 @@ impl ToEntryIter for Privileges {
...
@@ -2280,7 +2308,7 @@ impl ToEntryIter for Privileges {
trait
SchemaDef
{
trait
SchemaDef
{
/// Type of unique key used to identify entities for the purpose of
/// Type of unique key used to identify entities for the purpose of
/// associating the schema version with.
/// associating the schema version with.
type
Key
:
std
::
hash
::
Hash
+
Eq
;
type
Key
:
std
::
hash
::
Hash
+
Eq
+
std
::
fmt
::
Debug
;
/// Extract unique key from the entity.
/// Extract unique key from the entity.
fn
key
(
&
self
)
->
Self
::
Key
;
fn
key
(
&
self
)
->
Self
::
Key
;
...
...
This diff is collapsed.
Click to expand it.
test/int/test_acl.py
+
1
−
1
View file @
5c7367c5
...
@@ -685,7 +685,7 @@ def test_acl_from_snapshot(cluster: Cluster):
...
@@ -685,7 +685,7 @@ def test_acl_from_snapshot(cluster: Cluster):
i3
.
raft_compact_log
()
i3
.
raft_compact_log
()
#
#
# Ca
c
thup by snapshot.
# Cat
c
hup by snapshot.
#
#
i4
.
start
()
i4
.
start
()
i5
.
start
()
i5
.
start
()
...
...
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