feat: Recover from fallback writer state (#3000)

Add a timer and new `FallbackRecovery` state to try to recover from
`Fallback` writer state every hour.
Fixes #2997
This commit is contained in:
Sergey Kuznetsov
2026-03-16 14:09:26 +00:00
committed by GitHub
parent 1140b9e3a5
commit 2316cced64
16 changed files with 741 additions and 40 deletions

View File

@@ -66,6 +66,10 @@ ClioNode::from(
return ClioNode::DbRole::Fallback;
}
if (writerState.isFallbackRecovery()) {
return ClioNode::DbRole::FallbackRecovery;
}
return writerState.isWriting() ? ClioNode::DbRole::Writer : ClioNode::DbRole::NotWriter;
}();
return ClioNode{
@@ -105,7 +109,7 @@ tag_invoke(boost::json::value_to_tag<ClioNode>, boost::json::value const& jv)
auto dbRole = ClioNode::DbRole::Fallback;
if (auto const* v = obj.if_contains(JsonFields::kDB_ROLE)) {
auto const dbRoleValue = v->as_int64();
if (dbRoleValue > static_cast<int64_t>(ClioNode::DbRole::MAX))
if (dbRoleValue > static_cast<int64_t>(ClioNode::DbRole::Max))
throw std::runtime_error("Invalid db_role value");
dbRole = static_cast<ClioNode::DbRole>(dbRoleValue);
}