https://slatedb.io logo
Hi all, just joined this channel and saw
# general
f
Hi all, just joined this channel and saw a few error handling related recent thread, which is what my question is about: how to recover after a db (using a S3 object store) connection gets in a bad state. In a streaming application, there is an Arc instance that is cloned into various places, e.g. into write heavy workers and an axum server for reads. I have observed that at some point the database writes start failing, at times with a "Permission error: detected newer DB client", or with a fenced writer error (I suspect due to temporary issues with the S3 object store). One option is to use ArcSwap, and replace the db connection upon a failure, but I would be curious to see examples how others have built similar mechanisms.
c
Yea, ArcSwap should work. We're working to make the DB close itself far less frequently. But "detected newer DB client" is a fence, which will always close the DB. If this is a huge pain for you, a GH issue is welcome. We briefly discussed a db.reconnect() or equivalent type function (which RocksDB) has, but opted for "simpler" (at least on our end): just asking the app to recreate a new DB.
f
Thanks! I can see the benefit of keeping this complexity out of the client, especially in view of the many different ways things can go wrong with object store connections. That said, it will be (or already is) a recurring question.
c
@fak I'm curious: what would your preferred solution look like?
f
I noticed the ongoing effort around error handling, getting more visibility will definitely be nice - in my case I find it hard to even know what the underlying issue is. And I suspect many issues can/should be resolved at the object store level. In regards to a solution, I don't have an answer. From a user perspective having a
reconnect()
would of course be nice, but it would only make a big difference if the db instance also takes care of the required "inner mutability" to replace the connection.
In a way this is also more of a rust question. The docs & examples all just use a Arc, but in a "real" application this is not going to be sufficient. So the user will have to deal with that, with some wrapper struct that manages the db connection. I was e.g. considering wrapping in a rwlock, but that feels sketchy for a db connection, and I only learned about ArcSwap through my AI friends. Maybe adding some docs or an example for that purpose would also help.
c
@Pierre how are you handling this? Kinda curious
p
What’s the issue with Arc?
With the new retry stuff that should be enough
That’s what I am doing @criccomini
c
@Pierre how are you handling the case where the SlateDB instance shuts itself down permanently? Or are you just saying, since close is either going to be fence/requested clean close/panic that the DB will never need to be replaced. If so, the whole process must be restarted?
p
Yes, non 0 exit on fencing + clean retries = no need to swap
f
My application keeps other state that I want to preserve in case of db connection issue. I am not sure why there is a fencing error in the first place, there shouldn't be. I will look into that more before starting to swap db instances. Thanks to both of you for your input.
c
@fak You bet. BTW, what version are you using?
f
object_store = { version = "0.12.3", features = ["aws"] } slatedb = "0.8.2"