-
Notifications
You must be signed in to change notification settings - Fork 247
fix(universaldb): report the last error when transaction retries are exhausted #5695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,10 @@ pub enum DatabaseError { | |
| #[error("transaction is too old to perform reads or be committed")] | ||
| TransactionTooOld, | ||
|
|
||
| #[error("max number of transaction retries reached")] | ||
| MaxRetriesReached, | ||
| // Stores the last error. The alternate format prints the whole context chain, so the cause the | ||
| // context names is reported alongside the underlying variant. | ||
| #[error("max number of transaction retries reached, last error: {0:#}")] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 Medium · Preserve the last error in the error source chain The tuple field is formatted into this error, but it is not marked as a Mark the wrapped |
||
| MaxRetriesReached(anyhow::Error), | ||
|
|
||
| #[error("operation issued while a commit was outstanding")] | ||
| UsedDuringCommit, | ||
|
|
@@ -22,7 +24,7 @@ impl DatabaseError { | |
| use DatabaseError::*; | ||
|
|
||
| match self { | ||
| NotCommitted | TransactionTooOld | MaxRetriesReached => true, | ||
| NotCommitted | TransactionTooOld | MaxRetriesReached(_) => true, | ||
| _ => false, | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 Medium · Preserve the last error in the error source chain
The tuple field is formatted into this error, but it is not marked as a
thiserrorsource. Consequentlyanyhow::Error::chain()stops atMaxRetriesReachedand callers cannot inspect or downcast the retry-exhaustingTransactionTooOld,NotCommitted, or its contextual cause programmatically; only the rendered alternate display includes it.Mark the wrapped
anyhow::Errorwith#[source](or use a namedsourcefield) so the reported cause remains part of the standard error chain.