https://slatedb.io logo
Looking at you fight on this PR, it’s
# general
p
Looking at you fight on this PR, it’s really hard to see this current wave of AI models to do anything unsurpervized, it’s always a “do this do that, not like this, not like that”
c
Yea... I feel like this isn't worth it for this PR 😛
Also.. I just realized that we have some cardinality mismatch here... We have a retry duration for Settings. But GC and Compactor can be created (in their builders) using only GarbageCollectorOptions and CompactorOptions. This leaves us with a few options: 1. Add a setting to CarbageCollectorOptions/CompactorOptions 2. Add a
with_retry_duration
to each of those builders. 3. Hard code it for the GC/compactor builders 4. Not include it for hte GC/compactor builders. I don't really like any of these options. (1) causes 3 different configs which is antithetical to minimizing cfgs, which is something we want to adhere to for Slate. It also makes it confusing to have 3 settings for retry in the main configs. (2) violates the Settings pattern we have in the main builder (config is Settings, components are with_*) (3) or (4) seem.. okay but might be kinda surprising to users.
Is this really necessary for ZeroFS? 😅 I suppose you have to handle Db errors anyway, right?
p
I don’t handle db errors at all right now
Because I felt that it was slatedb duty to maintain a working state. SQLite would never “die”, using a Postgres client would never permanently fail and require a new client instance
You are seeing it in a different light?
Perhaps today, right now, it’d be best for zerofs to create a new slatedb instance when that happens
But it feels very dirty?
It’s a quite common scenario to lose network or for the object store to be temporarily unavailable
Why would slatedb enter a dead state at this point?
I personally don’t think slatedb should ever permanently fail, except when fenced
c
If you remove the directory where the SQLite DB is, it flips to read-only. All future writes fail. Even if you re-create the directory again.
You have no choice but to recreate the connection
p
I wouldn’t mind slatedb failing if the db is removed, but here slatedb fails for anything
I think it’s not only a zerofs thing, but anytime you run slatedb on a laptop, or on a server where the network will fail
c
Fair enough
Lemme think about this a bit.. I just don't like adding all these configs
p
Yeah it’s ugly
I think we are missing something
c
I see it mostly as a preference for operators.. I can see that some might want it to keep trying forever. Others might want their server to die so they know something is really wrong.
p
Even the retrying object store feels borderline
(Even if it makes things work for now)
c
I was thinking about this a few hours ago..
Maybe it makes sense simply to propagate the error with an on_error callback or something
And let users decide whether to ignore it or what
p
If you used a rust Postgres client, wouldn’t you find it bad if it broke and an instance had to be recreated when the network is down?
c
The issue might just be that we're setting error_state for too many kinds of errors
IDK.. if my PG was pointing at an EBS and the EBS got unmounted for 5 minutes, I suspect PG would not work when the EBS mount came back.
p
I don’t know about EBS, but that’s doable with NBD
c
WDYT about resetting the
error_state
after it's returned to the user (rather than keeping it set, which disables all other calls)
p
(Persist + no timeout)
I think there’s a categories of errors that still makes sense to not retry, say you forgot allow http true and used a http endpoint
That’s where it gets hard to me
c
Yea we have different categories that we define in error.rs. @David Calavera did some good work on this
I think we just need to ratchet down which ones are truly permanent
Lemme investigate this a bit..
p
I think network errors are one thing but we are polluted by the local object stores in a way
c
I added the
error
state to db_state somewhat hastily and it seems to be causing a few issues (for example, we use it to trigger clean shutdowns right now, which is also ugly)
p
Here’s something crazy: wouldn’t it makes sense to discard object_store and integrate as a POC with OpenDAL directly, as it seems to handle this and other things better (just for one thing, timeouts)
c
Yea that's a pretty significant change...
p
Indeed
It doesn’t look like there’s a ton of surface area though
c
Ok, so I did a quick check.
record_fatal_error
is only used in 4 places: - compactor thread - wal writer thread - memtable thread - batch writer thread
So essentially it's a way for us to signal to the user that a backend task has died, which is catastrophic
I think the issue is that we allow backend tasks to die too easily
p
To you, in which scenarios would it be legitimate for a task to die?
c
Only an uncaught panic I think
Or an unexpected DB state
p
If we just loop{} until success, do we even need the retrying object store?
c
Copy code
/// Represents the kind of public errors that can be returned to the user.
#[derive(Debug)]
pub enum ErrorKind {
    /// The database attempted to use an invalid configuration.
    Configuration,

    /// The database attempted an invalid operation or an operation with an
    /// invalid parameter (including misconfiguration).
    Operation,

    /// Unexpected internal error. This error is fatal (i.e. the database must be closed).
    System,

    /// Invalid persistent state (e.g. corrupted data files). The state must
    /// be repaired before the database can be restarted.
    PersistentState,

    /// Failed access database resources (e.g. remote storage) due to some
    /// kind of authentication or authorization error. The operation can be
    /// retried after the permission issue is resolved.
    Permission,

    /// The operation failed due to a transient error (such as IO unavailability).
    /// The operation can be retried after backing off.
    Transient(Duration),
}
p
Oh, fenced is not there?
c
So we have two error layers: internal (SlateDBError) and user-facing (ErrorKind)
error.rs shows how we map between the two
Fence is an internal error tha i mapped to
Permission
as a user-facing error
The funny thing is fencing is permanent, but Permission is a retry error
p
Permission is thrown on local even when not really a permission error
I had this with CIFS to indicate rate limiting (yeah, lol)
This has some good details
p
I think the mismatch is that slatedb wants the user to handle errors when issuing requests, but that slatedb has to handle errors itself for background tasks
c
Interestingly, we have this: SlateDBError::Timeout { backoff, .. } => Error::transient(msg, backoff),
Yea.
the bg tasks are basically equivalent to users
p
To me (even if it’s not what the implementation does), it makes sense to think the user facing api as a task queue
My own issue with recreating slatedb every time is that it’s kind of a heavy process in itself
It’s not really “swap that client”
c
Yea
I think we can fix this in slatedb
p
To have the same design everywhere, couldn’t we actually design the request handling api as a message queue?
So that you only have background tasks, and no separate path there
c
That's how it works right now
p
Uh ok
c
only reads are sync.. all writes go through channels.. that's what these bg threads are--they're reading messages off the channel (queue) and then sending messages back to the waiting user thread
Lemme noodle on this a bit.. I like the idea of making the bg tasks more resilient...
We do a bunch of
.await?
all over and then tank the thread if it fails. We should probably convert those to
ErrorKind
(they're SlateDBError right now) and then handle retries if it's a transient/retriable kind
I think I might even be able to do this in the
MessageDispatcher
transparently, so all threads just magically get the new behavior.
Yep, I found the perfect spot for this
In
run_loop
We can simply add backoff and retry here rather than always unwrapping SlateDBErrors and failing the loop
🔥
Yep I think this will be nice. Then we should be able to get rid of RetryingObjectStore
Need to migrate the rest of the tasks to MessageDispatcher tho (tracked here https://github.com/slatedb/slatedb/pull/776)
p
Hmm that sounds great
c
Yea I think that should do the trick'
I'll have to do a pass on the internal -> external error mappings to make sure they're properly categorized tho
p
In some way, it’s a relief that retrying object store will not be a thing anymore
I disliked that thing
Even though it made things works
😂
c
Totally
This will be much cleaner. It dovetails so nicely into
MessageDispatcher
. A nice signal that the refactor is a good idea.
p
With that redesign, is it correct to say that slatedb should never enter a broken state unless a error is actually fatal?
c
Yes. Though we'll need to refine the errors.rs mapping as I said above so that non-fatal errors are classified appropriately. I spotted some cases where we have retryable errors classified incorrectly.
And I'm sure we'll debate endlessly about what "fatal" means 😛
p
I think the whole classification thing will be awful
So it’s my 2c, but me what I’d do is any object storage error during the startup sequence is fatal
During the duration of using the db, nothing is fatal
Except fenced
OR if the s3 bucket has been tempered with
c
What about corrupt files?
p
That’s a panic to me
c
There are also many invariants in the db state that we expect to always be true. We panic on those now.
p
I would be careful about trying to optimize for this case (corrupt files), it’s the whole point of s3 in a sense that this never happens
So I think it’s fair to just panic
Panicking is also more idiomatic to me than “always error out from now”
In a sense, isn’t “always error out from now” slatedb’s own implementation of panic? 🥲
Anyway, there’s no way to have sensible recovery from there
For users that have a extreme edge case where they need to gracefully handle corrupt files, they can still use catch_unwind
c
IDK.. With the errors we set, it gives the process a chance to shutdown cleanly
p
In practice you won’t be able to call close, right?
c
But you might have other stuff unrelated to slatedb that should be shut down
p
Yes but corrupt files will never really happen, ever (if using s3 or a proper implementation)
Fencing is a bit different because it’s not really an error but a state
c
I think most likely is a bug in our code or an improper client migration or somethign rather than s3 corrupting data
p
And you could imagine a take() function (to fence an other client from your side)
c
^ Yea take did cross my mind
to clear it
p
Then panicking is the most appropriate to me
except() / unreachable!() is common in parsing / deserializing code
And if it’s really really a need for a user to do something else if that ever happens, then they can use catch_unwind
c
(assuming you mean expect())
p
Which they should do anyway even if we didn’t panick
Ah yes, it’s python brain rot
Did too much of that lol
I love unreachable personally
It’s pretty elegant
Regarding fencing it can get pretty similar to https://docs.rs/futures/latest/futures/future/struct.Abortable.html in a sense
Especially regarding to is_aborted, and an additional resume() we could imagine
c
Haha I was looking at that
Starting to dig through these internal errors... a lot of them are just panics like you said
r
riffing on this it would be nice having an api to upgrade a reader and vice versa
c
@raftario sounds good! Btw, are you guys using SlateDB at Solar winds?
r
not at the moment, but its been talked about
we're basically in talks across a few teams to rethink our telemetry pipeline from first principles so there's a lot of ideas being thrown around and that's how i learned about it
current spike of interest on my part is for an unrelated personal project tho