mirror of
https://github.com/Cuprate/cuprate.git
synced 2025-03-09 10:15:01 +00:00
abort on DB error
This commit is contained in:
parent
48a4fa89a9
commit
ec473944b7
1 changed files with 14 additions and 6 deletions
|
@ -112,14 +112,22 @@ fn promote(
|
|||
let env_inner = env.env_inner();
|
||||
let tx_rw = env_inner.tx_rw()?;
|
||||
|
||||
let mut tx_infos = env_inner.open_db_rw::<TransactionInfos>(&tx_rw)?;
|
||||
let res = || {
|
||||
let mut tx_infos = env_inner.open_db_rw::<TransactionInfos>(&tx_rw)?;
|
||||
|
||||
tx_infos.update(tx_hash, |mut info| {
|
||||
info.flags.remove(TxStateFlags::STATE_STEM);
|
||||
Some(info)
|
||||
})?;
|
||||
tx_infos.update(tx_hash, |mut info| {
|
||||
info.flags.remove(TxStateFlags::STATE_STEM);
|
||||
Some(info)
|
||||
})
|
||||
};
|
||||
|
||||
drop(tx_infos);
|
||||
if let Err(e) = res() {
|
||||
// error promoting the tx, abort the DB transaction.
|
||||
TxRw::abort(tx_rw)
|
||||
.expect("could not maintain database atomicity by aborting write transaction");
|
||||
|
||||
return Err(e);
|
||||
}
|
||||
|
||||
TxRw::commit(tx_rw)?;
|
||||
Ok(TxpoolWriteResponse::Ok)
|
||||
|
|
Loading…
Reference in a new issue