Skip to content
Snippets Groups Projects
Commit 4e9d64ea authored by Georgy Moshkin's avatar Georgy Moshkin :speech_balloon:
Browse files

fix: guard against read-onlyness in proc_apply_schema_change

parent 94086784
No related branches found
No related tags found
1 merge request!570Fix/unfinished ddl by snapshot
......@@ -7,7 +7,7 @@ use crate::traft::node;
use crate::traft::Result;
use crate::traft::{RaftIndex, RaftTerm};
use std::time::Duration;
use tarantool::error::TarantoolError;
use tarantool::error::{TarantoolError, TarantoolErrorCode};
use tarantool::ffi::tarantool as ffi;
use tarantool::space::{Space, SystemSpace};
......@@ -25,6 +25,14 @@ crate::define_rpc_request! {
return Ok(Response::Ok);
}
if crate::tarantool::eval("return box.info.ro")? {
let e = tarantool::set_and_get_error!(
TarantoolErrorCode::Readonly,
"cannot apply schema change on a read only instance"
);
return Err(e.into());
}
let ddl = storage.properties.pending_schema_change()?.ok_or_else(|| Error::other("pending schema change not found"))?;
// FIXME: start_transaction api is awful, it would be too ugly to
......
......@@ -104,6 +104,12 @@ impl From<::tarantool::error::TransactionError> for Error {
}
}
impl From<::tarantool::error::TarantoolError> for Error {
fn from(err: ::tarantool::error::TarantoolError) -> Self {
Self::Tarantool(err.into())
}
}
#[derive(Debug, Error)]
pub enum CoercionError {
#[error("unknown entry type ({0})")]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment