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
3c609337
Commit
3c609337
authored
1 year ago
by
Georgy Moshkin
Committed by
Georgy Moshkin
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
rename: change up error messages so they are easier to parse from strings
parent
f5744bf4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!611
Fix/reentarable pico schema change api
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/cas.rs
+10
-6
10 additions, 6 deletions
src/cas.rs
src/traft/error.rs
+6
-2
6 additions, 2 deletions
src/traft/error.rs
test/int/test_cas.py
+6
-6
6 additions, 6 deletions
test/int/test_cas.py
with
22 additions
and
14 deletions
src/cas.rs
+
10
−
6
View file @
3c609337
...
...
@@ -288,43 +288,47 @@ crate::define_rpc_request! {
/// Usually it can't be handled and should be either retried from
/// scratch or returned to a user as is.
///
// NOTE: these error messages are relied on in luamod.lua,
// don't forget to update them everywhere if you're changing them.
#[derive(Debug,
::thiserror::Error)]
pub
enum
Error
{
/// Can't check the predicate because raft log is compacted.
#[error(
"raft index {requested} is compacted at {compacted_index}"
)]
#[error(
"
Compacted:
raft index {requested} is compacted at {compacted_index}"
)]
Compacted
{
requested
:
RaftIndex
,
compacted_index
:
RaftIndex
,
},
/// Nearly impossible error indicating invalid request.
#[error(
"raft entry at index {requested} does not exist yet, the last is {last_index}"
)]
#[error(
"NoSuchIndex: raft entry at index {requested} does not exist yet, the last is {last_index}"
)]
NoSuchIndex
{
requested
:
RaftIndex
,
last_index
:
RaftIndex
,
},
/// Checking the predicate revealed a collision.
#[error(
"comparison failed for index {requested} as it conflicts with {conflict_index}"
)]
#[error(
"
ConflictFound:
comparison failed for index {requested} as it conflicts with {conflict_index}"
)]
ConflictFound
{
requested
:
RaftIndex
,
conflict_index
:
RaftIndex
,
},
/// Checking the predicate revealed a collision.
#[error(
"entry at index {index} has term {actual_term}, request implies term {expected_term}"
)]
#[error(
"
EntryTermMismatch:
entry at index {index} has term {actual_term}, request implies term {expected_term}"
)]
EntryTermMismatch
{
index
:
RaftIndex
,
expected_term
:
RaftTerm
,
actual_term
:
RaftTerm
,
},
#[error(
"space {space} is prohibited for use in a predicate"
)]
#[error(
"
SpaceNotAllowed:
space {space} is prohibited for use in a predicate"
)]
SpaceNotAllowed
{
space
:
String
},
/// An error related to `key_def` operation arised from tarantool
/// depths while checking the predicate.
#[error(
"failed comparing predicate ranges: {0}"
)]
#[error(
"
KeyTypeMismatch:
failed comparing predicate ranges: {0}"
)]
KeyTypeMismatch
(
#[from]
TntError
),
}
...
...
This diff is collapsed.
Click to expand it.
src/traft/error.rs
+
6
−
2
View file @
3c609337
...
...
@@ -35,11 +35,15 @@ pub enum Error {
instance_rsid
:
String
,
requested_rsid
:
String
,
},
// NOTE: this error message is relied on in luamod.lua,
// don't forget to update it everywhere if you're changing it.
#[error(
"operation request from different term {requested}, current term is {current}"
)]
TermMismatch
{
requested
:
RaftTerm
,
current
:
RaftTerm
,
},
// NOTE: this error message is relied on in luamod.lua,
// don't forget to update it everywhere if you're changing it.
#[error(
"not a leader"
)]
NotALeader
,
#[error(
"lua error: {0}"
)]
...
...
@@ -61,7 +65,7 @@ pub enum Error {
#[error(
"governor has stopped"
)]
GovernorStopped
,
#[error(
"compare-and-swap
request failed
: {0}"
)]
#[error(
"compare-and-swap: {0}"
)]
Cas
(
#[from]
crate
::
cas
::
Error
),
#[error(
"ddl failed: {0}"
)]
Ddl
(
#[from]
crate
::
schema
::
DdlError
),
...
...
@@ -86,7 +90,7 @@ impl Error {
/// Temporary solution until proc_cas returns structured errors
pub
fn
is_cas_err
(
&
self
)
->
bool
{
self
.to_string
()
.contains
(
"compare-and-swap
request failed
"
)
self
.to_string
()
.contains
(
"compare-and-swap"
)
}
/// Temporary solution until proc_cas returns structured errors
...
...
This diff is collapsed.
Click to expand it.
test/int/test_cas.py
+
6
−
6
View file @
3c609337
...
...
@@ -52,7 +52,7 @@ def test_cas_errors(instance: Instance):
)
assert
e3
.
value
.
args
==
(
"
ER_PROC_C
"
,
"
compare-and-swap
request failed
: entry at index 1 has term 1, request implies term 2
"
,
"
compare-and-swap
: EntryTermMismatch
: entry at index 1 has term 1, request implies term 2
"
,
)
# Wrong index (too big)
...
...
@@ -65,7 +65,7 @@ def test_cas_errors(instance: Instance):
)
assert
e4
.
value
.
args
==
(
"
ER_PROC_C
"
,
"
compare-and-swap
request failed
:
"
"
compare-and-swap
: NoSuchIndex
:
"
+
f
"
raft entry at index 2048 does not exist yet, the last is
{
index
}
"
,
)
...
...
@@ -77,7 +77,7 @@ def test_cas_errors(instance: Instance):
instance
.
cas
(
"
insert
"
,
"
_pico_property
"
,
[
"
foo
"
,
"
420
"
],
index
=
index
-
1
)
assert
e5
.
value
.
args
==
(
"
ER_PROC_C
"
,
"
compare-and-swap
request fail
ed:
"
"
compare-and-swap
: Compact
ed:
"
+
f
"
raft index
{
index
-
1
}
is compacted at
{
index
}
"
,
)
...
...
@@ -92,7 +92,7 @@ def test_cas_errors(instance: Instance):
)
assert
e5
.
value
.
args
==
(
"
ER_PROC_C
"
,
f
"
compare-and-swap
request fail
ed: space
{
space
}
is prohibited for use
"
f
"
compare-and-swap
: SpaceNotAllow
ed: space
{
space
}
is prohibited for use
"
+
"
in a predicate
"
,
)
...
...
@@ -128,7 +128,7 @@ def test_cas_predicate(instance: Instance):
)
assert
e5
.
value
.
args
==
(
"
ER_PROC_C
"
,
"
compare-and-swap
request faile
d:
"
"
compare-and-swap
: ConflictFoun
d:
"
+
f
"
comparison failed for index
{
read_index
}
"
+
f
"
as it conflicts with
{
read_index
+
1
}
"
,
)
...
...
@@ -194,7 +194,7 @@ def test_cas_lua_api(cluster: Cluster):
ranges
=
[
CasRange
(
eq
=
"
fruit
"
)],
)
assert
e5
.
value
.
args
==
(
"
compare-and-swap
request faile
d:
"
"
compare-and-swap
: ConflictFoun
d:
"
+
f
"
comparison failed for index
{
read_index
}
"
+
f
"
as it conflicts with
{
read_index
+
1
}
"
,
)
...
...
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