https://slatedb.io logo
Hi all, I'm working through the WAL implementation...
# general
t
Hi all, I'm working through the WAL implementation, and I wish to elicit feed back on how I'm thinking about bit rot vs storage errors during iteration. In the case of bit rot -- if some blocks or rows in the sstable are corrupt -- I believe we should skip those blocks/rows during iteration with a warning, as there is nothing to be done by slatedb as corruption is likely not a transient issue. However, I feel like storage retrieval errors should NOT be skipped as they are likely transient in nature, network I/O errors, Timeout Errors, etc.... If sstable retrieval from storage results in an error, iteration should end and an error should be returned to the caller. Thoughts?
c
Hmmm thinking
I agree on the second part--returning an error on (likely) transient errors
In the case of bitrot, I feel that skipping the corrupt blocks is dangerous. The concern I have is that it could lead to incorrect output for users. For mission-critical stuff, I have always defaulted to hard failures, and letting users figure out what they want to do. For example, when doing payment processing, we always defaulted to halting the system if any strange stats appeared. In this case, things get a little muddled. If we return an error, we'd also need to give users the ability to somehow skip corrupt blocks. The most likely solution would be a config option or method param. But that complicates the user interface for a relatively outlandish use case. But if we don't give them the option to skip blocks, then returning an error is effectively always halting the system with no way around it. The DB is effectively dead. Another thing w.r.t. skipping is that users might be taking backups of their data. Getting an error would be useful in that case, since they could run a recovery on the corrupt data. Yet another thing to consider: are we talking about corrupt blocks on disk or corrupt blocks in S3? If the former (e.g. in a disk cache), then IMO, we should delete the file off disk and restore it from S3. If the latter, then the points above apply.
tl;dr I don't have a good answer to this... but a "skip_corrupt_blocks" config flag seems like maybe the best option?
or more generically "skip_corrupt_files" or something, so we can skip in cases where the metadata in an SST is corrupt as well.
t
My background in data is at Rackspace, where I was part of the team that built and operated cloud block storage. And while we did everything we could to avoid bit rot, when you operate at scale, it does occur. -- perhaps twice in my 5 years there. Everytime this occurred, the data was lost. The second time, it was a customer PostgreSQL database, and we actually wished that PostgreSQL would have warned us about the corrupt data instead of crashing, as we had no knowledge of how to "fix" the PostgreSQL on disk format, nor recover the tables that were corrupted. We only wanted to get the database up and running again asap. Once that was done, we could asses what data was lost. Unless you are expert in sstables and the internals of slateDB, the likely hood of finding corrupt blocks/rows in large files and fixing them is very slim. As such, I'm a big supporter of warnings and having the database automatically recover as much data as possible in the 0.0001% chance that bit rot occurs. The down side is that, is if no one is paying attention to the warnings returned, and later wonders why slateDB lost data. The ideal situation is that you have duplicated the data somewhere else, via some sort of synchronous replication -- or the underlying object storage does this for you -- which allows you to rebuild the corrupt data. In this case, having slateDB warn, but not crash is ideal, as the data can be recovered by the caller.
c
> Unless you are expert in sstables and the internals of slateDB, the likely hood of finding corrupt blocks/rows in large files and fixing them is very slim. The flow that I envisioned was more just "oh, we're getting DB corruption error, let's copy over our backup SSTs"
Not debugging individual blocks
> The down side is that, is if no one is paying attention to the warnings returned, and later wonders why slateDB lost data. This is my concern. For $ transactions, for example, data loss is completely unacceptable, especially when it's quiet.
> The ideal situation is that you have duplicated the data somewhere else, via some sort of synchronous replication -- or the underlying object storage does this for you -- which allows you to rebuild the corrupt data. In this case, having slateDB warn, but not crash is ideal, as the data can be recovered by the caller. Yea, this is where I differ. In this scenario, I want the DB to fall on its face so that everyone gets paged. Then we can run the recovery.
Rather than return with missing data.. (see the $ example earlier)
I think what we're talking about is whether we want downtime or data loss. And the answer probably depends on use case.
This is why I was thinking the config might be the best approach..
Then the question is what the sane default is 🤣
> we actually wished that PostgreSQL would have warned us about the corrupt data instead of crashing Curious about this: did you know it was crashing because of corrupt data? What I'm getting at is, if SlateDB said, "block x on sst Y is corrupt, so failing," would that have been satisfactory?
t
"block x on sst Y is corrupt, so failing,"
would likely mean nothing to 90% of users. questions like "what is an sst?" 😅
c
haha
Yea, I was using shorthand. What I was thinking was something like: "ERROR: SlateDB detected a corrupt file in bucket: foo-bar, path: blah/blah.sst. Please restore this file from a backup. If you have no backup, the data in the file has been lost. Skip reading this file with:
skip_corrupt_files: true
."
t
I like how tiger beetle approaches this, -- although they have replication built in -- in that they skip corrupt blocks, recover what they can, and attempt to use replication to recover. As replication is out of scope for SlateDB, I feel like someone who wants the same level of durability as tigerbeetle should be able to use SlateDB to build such a system. which means SlateDB should inform the caller of the corruption, but allow operation to continue. https://docs.tigerbeetle.com/about/safety/
c
Are you suggesting no config, just always skip corrupt blocks?
Or config with default = true for skip blocks
@User ^ Interesting discussion. WDYT? Note: this is in the context of slatedb-go, but we should think about this for the Rust impl as well.
t
I think you were spot on here > If we return an error, we'd also need to give users the ability to somehow skip corrupt blocks. The most likely solution would be a config option or method param. But that complicates the user interface for a relatively outlandish use case it's likely an outlandish case.
my spide senses are tingling, I feel like I've heard discussion about this in PostgreSQL and SQLlite before. let me do some digging.
c
@thrawn01 mind opening a GH issue for this one on /slatedb? (you can reference from a slated-go issue if you like) I want to have this disucssion documented since it seems critical.
(I should note that CLEAN_SLATE specifically calls out simplifying config as a goal. So skipping the config would be inline with that philosophy. OTOH, it also calls out ACID and transactions. Quietly (yes, IMO, a log line is still quiet vs. hard failure) dropping data seems to fly in the face of this.)
A survey of PG/SQLite/TigerBeetle seems reasonable.
Stand on the shoulders of giants and principle of least astonishment.
With those 3, we should have quorum. Let's do what 2+ of them do. 😅
t
I'll do some reseach and open a GH issue.
c
Thanks!
r
I'm pretty uncomfortable with ignoring errors like this in a way that by default doesn't force manual intervention. For some cases the consequences of silently ignoring data errors can be catastrophic. On the other hand, if you care about availability, this type of error should be rare enough that the loss of availability from going through a manual intervention is small when amortized over all time. I feel like the default flow should be: 1. hard fail and provide the user with as much context as possible, like the corrupted files/blocks, key ranges, timestamps, etc. 2. the user can then choose how to deal with the situation. They can try to recover the data if possible, or account for the loss somehow. For example, for a stream processing use case if you know the time the corruption happened you can reprocess data from that time onwards using an earlier checkpoint. If they want to drop the corrupted data from the db then we should give them tooling to do that, and the error surfaced by slatedb should be sufficient to generate arguments to the tooling. For example, the tool could rewrite an SST without the corrupted blocks, or remove an entire SST if the metadata blocks are corrupted. This at least gives users an opportunity to correct the data either by recovering the corrupted SSTs or the contained data if that's available to them somehow. Even if they can't recover it it's important to know what data may have been affected. I'm also just generally uncomfortable with introducing mainline paths that drop data from the db. It feels likely to introduce corruption bugs (e.g. miscategorizing a transient error as nontransient).
c
> I'm pretty uncomfortable with ignoring errors like this in a way that by default doesn't force manual intervention This was my reaction as well.
> If they want to drop the corrupted data from the db then we should give them tooling to do that, and the error surfaced by slatedb should be sufficient to generate arguments to the tooling. I like this idea. We can add a command to
admin
CLI.
This keeps the configs clean.
t
I believe we can support both availability and durability, as some users may value one over the other, depending upon their workload and the data being stored. I'm collecting my thoughts and putting together a proposal that would allow both without the need for configuration.
a
slightly tangential, but do we checksum the SSTs? how do we even detect bit rot? (I don't see a crc in the sst schema file)
r
we checksum the individual blocks and validate them when decoding
we currently don't do the metadata blocks, but there's an issue open for that
3 Views