https://slatedb.io logo
If panics can be there due to a
# general
p
If panics can be there due to a transient remote state, not so much
c
Lemme show you some draft code
These are the user-facing errors I'm planning to expose:
Copy code
/// 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(CloseKind),

    /// 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,
}
This is the CloseKind:
Copy code
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum CloseKind {
    /// The database has been shutdown cleanly.
    Clean,

    /// The current instance has been fenced and is no longer usable.
    Fenced,

    /// One or more background tasks panicked.
    Panic,
}
Error is exposed in two ways: 1. When a user calls get/put/scan/etc and their operation fails. 2. When a user calls db.poll_panic(). The
db
is closed three ways: 1. A user calls db.close() (this is a CloseKind::Clean) 2. The DB detects a fence (this is CloseKind::Fenced, could be from BG task or a user operation the detects it) 3. A background task panics (this is CloseKind::Panic) When CloseKind::Panic is set, the user may retrieve any panics (multiple bg tasks can panic) using
db.poll_panic()
. This will returna
Box<dyn Any + Send
. This could be a SlateDB
Error
or any other payload. In practice, it will not be a SlateDB error, though. Users may downcast it to various types to see what it is and act accordingly.
BG tasks will auto-retry if they see an Unavailable and Data, shutdown cleanly on Closed, and panic on Invalid, Transaction, and Internal.
BG tasks will auto retry on all SlateDB errors
I'm hoping to get a draft PR up today/tomorrow to get some comments ๐Ÿ™‚
(I will update the RFC, too)
p
Ok thank you
But what can make a task panic?
c
majorly nasty stuff like oom, fs panics, etc
We call unwrap and expect in various spots, as well
For things that are unreachable
etc etc
Shit breaks in weird ways ๐Ÿ˜›
I'm curious: do you think if a bg task fails with something like data corruption, should we just keep retrying that forever?
Doing so could halt writes, make reads stale, pause all GC, and/or halt compaction.
corruption is tricky.. could be transient.. could not. Could be on something really bad like a manifest, or something less bad like an SST where reads in other SSTs could still be served...
r
ooo this is so much nicer already
p
I think itโ€™s fine to bubble the panic up to me
As in outside the bg task
Transient corruption should never happen with https, except if the object storage is completely broken
So I donโ€™t think slatedb should invest too much into this flow
c
@Pierre do you think the DB should shut down after as well?
IMO it should
p
I think it would be fine to just panic the main handling code
Because you probably cannot shutdown cleanly?