use faultbox::DomainContext;
use faultbox::serde_json::{Value, json};
pub(super) struct MemtableCellCorrupt<'a> {
pub collection: &'a str,
pub column: &'a str,
pub detail: String,
}
pub(super) struct WalRowCorrupt {
pub detail: String,
}
impl DomainContext for WalRowCorrupt {
fn domain_kind(&self) -> &'static str {
"nodedb_columnar.wal_row_corrupt"
}
fn grouping_key(&self) -> String {
"wal_row".to_string()
}
fn to_json(&self) -> Value {
json!({
"detail": self.detail,
"why_fatal": "the row the record carries cannot be rebuilt, so its decode is \
refused",
"operator_action": "restore the collection from a snapshot taken before the \
damaged record",
})
}
}
pub(super) struct StringCellNotUtf8<'a> {
pub column: &'a str,
pub detail: String,
}
impl DomainContext for StringCellNotUtf8<'_> {
fn domain_kind(&self) -> &'static str {
"nodedb_columnar.string_cell_not_utf8"
}
fn grouping_key(&self) -> String {
format!("column={}", self.column)
}
fn to_json(&self) -> Value {
json!({
"column": self.column,
"detail": self.detail,
"why_fatal": "the segment write is refused: block statistics built from these \
bytes would prune rows a predicate matches",
"operator_action": "rewrite or delete the named row, then let the flush retry",
})
}
}
impl DomainContext for MemtableCellCorrupt<'_> {
fn domain_kind(&self) -> &'static str {
"nodedb_columnar.memtable_cell_corrupt"
}
fn grouping_key(&self) -> String {
format!("collection={} column={}", self.collection, self.column)
}
fn to_json(&self) -> Value {
json!({
"collection": self.collection,
"column": self.column,
"detail": self.detail,
"why_fatal": "every read of the row is refused until the row is rewritten or \
removed. A flush of the memtable would copy the bad bytes into a \
segment",
"operator_action": "rewrite or delete the named row. If many rows fail, \
restore the collection from a snapshot",
})
}
}