check for MDBX_PANIC
This commit is contained in:
parent
d1d5e8ecf5
commit
ab16f6b2e8
@ -98,6 +98,9 @@ pub enum Web3ProxyError {
|
|||||||
#[display(fmt = "{:?}", _0)]
|
#[display(fmt = "{:?}", _0)]
|
||||||
#[error(ignore)]
|
#[error(ignore)]
|
||||||
JsonRpcErrorData(JsonRpcErrorData),
|
JsonRpcErrorData(JsonRpcErrorData),
|
||||||
|
#[from(ignore)]
|
||||||
|
#[display(fmt = "{}", _0)]
|
||||||
|
MdbxPanic(String, Cow<'static, str>),
|
||||||
NoBlockNumberOrHash,
|
NoBlockNumberOrHash,
|
||||||
NoBlocksKnown,
|
NoBlocksKnown,
|
||||||
NoConsensusHeadBlock,
|
NoConsensusHeadBlock,
|
||||||
@ -199,6 +202,7 @@ impl Web3ProxyError {
|
|||||||
|
|
||||||
/// turn the error into an axum response.
|
/// turn the error into an axum response.
|
||||||
/// <https://www.jsonrpc.org/specification#error_object>
|
/// <https://www.jsonrpc.org/specification#error_object>
|
||||||
|
/// TODO? change to `to_response_parts(self)`
|
||||||
pub fn as_response_parts(&self) -> (StatusCode, JsonRpcResponseEnum<Arc<RawValue>>) {
|
pub fn as_response_parts(&self) -> (StatusCode, JsonRpcResponseEnum<Arc<RawValue>>) {
|
||||||
// TODO: include a unique request id in the data
|
// TODO: include a unique request id in the data
|
||||||
let (code, err): (StatusCode, JsonRpcErrorData) = match self {
|
let (code, err): (StatusCode, JsonRpcErrorData) = match self {
|
||||||
@ -642,6 +646,20 @@ impl Web3ProxyError {
|
|||||||
// TODO: do this without clone? the Arc needed it though
|
// TODO: do this without clone? the Arc needed it though
|
||||||
(StatusCode::OK, jsonrpc_error_data.clone())
|
(StatusCode::OK, jsonrpc_error_data.clone())
|
||||||
}
|
}
|
||||||
|
Self::MdbxPanic(rpc, msg) => {
|
||||||
|
error!(%msg, "mdbx panic");
|
||||||
|
|
||||||
|
// TODO: this is bad enough that we should send something to pager duty
|
||||||
|
|
||||||
|
(
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
|
JsonRpcErrorData {
|
||||||
|
message: "mdbx panic".into(),
|
||||||
|
code: StatusCode::INTERNAL_SERVER_ERROR.as_u16().into(),
|
||||||
|
data: Some(serde_json::Value::String(msg.to_string())),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
Self::MethodNotFound(method) => {
|
Self::MethodNotFound(method) => {
|
||||||
warn!("MethodNotFound: {}", method);
|
warn!("MethodNotFound: {}", method);
|
||||||
(
|
(
|
||||||
|
@ -383,6 +383,12 @@ impl OpenRequestHandle {
|
|||||||
|
|
||||||
match error.code {
|
match error.code {
|
||||||
-32000 => {
|
-32000 => {
|
||||||
|
if error.message.contains("MDBX_PANIC:") {
|
||||||
|
response = Err(Web3ProxyError::MdbxPanic(
|
||||||
|
self.connection_name(),
|
||||||
|
error.message.clone(),
|
||||||
|
));
|
||||||
|
} else {
|
||||||
// TODO: regex?
|
// TODO: regex?
|
||||||
let archive_prefixes = [
|
let archive_prefixes = [
|
||||||
"header not found",
|
"header not found",
|
||||||
@ -397,6 +403,7 @@ impl OpenRequestHandle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
-32601 => {
|
-32601 => {
|
||||||
let error_msg = error.message.as_ref();
|
let error_msg = error.message.as_ref();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user