https://slatedb.io logo
Hello, I wanted to understand some
# general
h
Hello, I wanted to understand some details on error handling in SSI Transactions. Generally, I wanted to retry on conflict errors and it seems conflicts return Operation ErrorKind. Based on the docs, Operation error kind is for invalid args or invalid operation which doesn't seem to fit for conflict errors ? I was looking for retryable error for commit. either Transient ErrorKind or maybe a specific Conflict error kind. Just wondering what are your thoughts on conflict error retrying in general.
c
The current error messages are kind of a mess. I just merged in a change to address that issue this weekend: https://github.com/slatedb/slatedb/pull/933 This is a first step toward addressing a broad array of annoyances with our error handling.
In main, we now have a
Transaction
ErrorKind
This is the new set of ErrorKinds:
Copy code
rs
/// Represents the kind of public errors that can be returned to the user.
///
/// These are less specific and more prescriptive. Application developers or operators must
/// decide how to proceed. Adding new [ErrorKind]s requires an RFC, and should happen very
/// infrequently.
#[non_exhaustive]
#[derive(Debug, Clone, Copy)]
pub enum ErrorKind {
    /// A transaction conflict occurred. The transaction must be retried or dropped.
    Transaction,

    /// The database has been shutdown. The instance is no longer usable. The user must
    /// create a new instance to continue using the database.
    Closed(CloseReason),

    /// A storage or network service is unavailable. The user must retry or drop the
    /// operation.
    Unavailable,

    /// User attempted an invalid request. This might be:
    ///
    /// - An invalid configuration on initialization
    /// - An invalid argument to a method
    /// - An invalid method call
    /// - A user-supplied plugin such as the compaction schedule supplier or logical clock
    ///   failed.
    ///
    /// The user must correct the code, configuration, or argument and retry the operation.
    Invalid,

    /// Persisted data is in an unexpected state. This could be caused by:
    ///
    /// - Temporary or permanent machine or object storage corruption
    /// - Incompatible file format versions between clients
    /// - An eventual consistency issue in object storage
    ///
    /// The user must fix the data, use a compatible client version, retry the operation,
    /// or drop the operation.
    Data,

    /// An unexpected internal error occurred. Users should not expect to see this error.
    /// Please [open a Github issue](https://github.com/slatedb/slatedb/issues/new?template=bug_report.md&title=Internal+error+returned)
    /// if you receive this error.
    Internal,
}
The CloseReason can be `Clean`/`Fenced`/`Panic`
I plan to expose panic payloads via a
db.panics()
method
h
oh this is perfect, exactly what I was looking for.
is Data error generally considered retryable for a few retries and then give up because it can be not temporary ?
c
I tried not to be prescriptive about retries because it really depends on the context. But, yes, I'd suggest retrying a few times then giving up.
If file or network corruption is temporary, retries should be good. Same if you're using an eventually consistent bucket (e.g. multi-region with eventual consistency).
In general, you're only going to see that error if something is really wrong, though.
h
Thanks for the details!
c
No prob. We've been iterating on this, so if you have feedback or run into weirdness, please let me know!
(If you're interested, there's a lot more context here https://discord.com/channels/1232385660460204122/1422263353530781777)